UNPKG

openclaw

Version:

Multi-channel AI gateway with extensible messaging integrations

1 lines • 2.17 kB
import{_ as e,an as t,n,xt as r}from"./openclaw-state-read-sqlite-database-admission-Ck6VG7rE.mjs";import{u as i}from"./openclaw-state-read-kysely-sync-cache-state-PxpuKzoA.mjs";import{r as a}from"./openclaw-state-read-sqlite-busy-timeout-D5Khm-oR.mjs";import{o}from"./openclaw-state-read-sqlite-reader-lifecycle-BuMxf-e-.mjs";import{g as s}from"./openclaw-state-read-sqlite-schema-facts-DxLfPKu-.mjs";import c from"node:path";import{pathToFileURL as l}from"node:url";let u=!1;function resolveSqliteFilesystemPath(e){return process.platform===`win32`?c.toNamespacedPath(c.resolve(e)):e}function resolveNodeSqliteLocation(e){return e===``||e===`:memory:`||e.startsWith(`file:`)?e:resolveSqliteFilesystemPath(e)}function resolveSqliteFileUriPath(e,t){if(t===`win32`){let t=c.win32.toNamespacedPath(c.win32.resolve(e));return`file:${encodeURIComponent(t)}`}return l(c.resolve(e)).href}function resolveReadOnlyShmSqliteFileUri(e,t=process.platform){return`${resolveSqliteFileUriPath(e,t)}?mode=ro&readonly_shm=1`}function resolveExistingSqliteFileUri(e,t=process.platform){return`${resolveSqliteFileUriPath(e,t)}?mode=rw`}function resolveImmutableSqliteFileUri(e,t=process.platform){return`${resolveSqliteFileUriPath(e,t)}?mode=ro&immutable=1`}function openNodeSqliteDatabase(c,l,d){let f=r(),p=resolveNodeSqliteLocation(c),m=l?.open===!1?void 0:e(p,{create:l?.readOnly!==!0});if(l?.open!==!1&&d!==void 0&&m!==d)throw Error(`SQLite staging database changed before native open`);let h=new f.DatabaseSync(p,l??{});if(h.isOpen)try{n(h,m)}catch(e){throw h.close(),e}return h.open=()=>{let t=e(p,{create:l?.readOnly!==!0});if(d!==void 0&&t!==d)throw Error(`SQLite staging database changed before native open`);f.DatabaseSync.prototype.open.call(h);try{n(h,t)}catch(e){throw h.close(),e}},s(h,{DatabaseSync:f.DatabaseSync,StatementSync:f.StatementSync},l?.readOnly!==!0),h.isOpen&&l?.timeout!==void 0&&a(h,Math.max(0,l.timeout)),t().explicitSqliteCloseReleasesNativeResources||i(h,()=>{u=!0}),o(h),h}export{resolveReadOnlyShmSqliteFileUri as a,resolveImmutableSqliteFileUri as i,openNodeSqliteDatabase as n,resolveSqliteFilesystemPath as o,resolveExistingSqliteFileUri as r,u as t};