@livestore/sqlite-wasm 0.4.0-dev.17 → 0.4.0-dev.19
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/.tsbuildinfo +1 -1
- package/dist/FacadeVFS.d.ts.map +1 -1
- package/dist/FacadeVFS.js +4 -0
- package/dist/FacadeVFS.js.map +1 -1
- package/dist/browser/mod.d.ts +14 -7
- package/dist/browser/mod.d.ts.map +1 -1
- package/dist/browser/mod.js +49 -43
- package/dist/browser/mod.js.map +1 -1
- package/dist/browser/opfs/AccessHandlePoolVFS.d.ts +24 -18
- package/dist/browser/opfs/AccessHandlePoolVFS.d.ts.map +1 -1
- package/dist/browser/opfs/AccessHandlePoolVFS.js +155 -158
- package/dist/browser/opfs/AccessHandlePoolVFS.js.map +1 -1
- package/dist/browser/opfs/index.d.ts +3 -2
- package/dist/browser/opfs/index.d.ts.map +1 -1
- package/dist/browser/opfs/index.js +1 -1
- package/dist/browser/opfs/index.js.map +1 -1
- package/dist/browser/opfs/opfs-sah-pool.d.ts +1 -1
- package/dist/browser/opfs/opfs-sah-pool.d.ts.map +1 -1
- package/dist/browser/opfs/opfs-sah-pool.js +1 -1
- package/dist/browser/opfs/opfs-sah-pool.js.map +1 -1
- package/dist/cf/mod.d.ts.map +1 -1
- package/dist/cf/mod.js +2 -2
- package/dist/cf/mod.js.map +1 -1
- package/dist/make-sqlite-db.d.ts.map +1 -1
- package/dist/make-sqlite-db.js +1 -4
- package/dist/make-sqlite-db.js.map +1 -1
- package/dist/node/mod.d.ts.map +1 -1
- package/dist/node/mod.js +2 -2
- package/dist/node/mod.js.map +1 -1
- package/package.json +7 -7
- package/src/FacadeVFS.ts +5 -0
- package/src/browser/mod.ts +38 -13
- package/src/browser/opfs/AccessHandlePoolVFS.ts +337 -253
- package/src/browser/opfs/index.ts +4 -3
- package/src/browser/opfs/opfs-sah-pool.ts +1 -1
- package/src/cf/mod.ts +2 -2
- package/src/make-sqlite-db.ts +1 -4
- package/src/node/mod.ts +2 -2
- package/src/ambient.d.ts +0 -18
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { Effect } from '@livestore/utils/effect'
|
|
1
|
+
import { Effect, type Scope } from '@livestore/utils/effect'
|
|
2
|
+
import type { Opfs } from '@livestore/utils/effect/browser'
|
|
2
3
|
import type * as WaSqlite from '@livestore/wa-sqlite'
|
|
3
4
|
|
|
4
5
|
import { AccessHandlePoolVFS } from './AccessHandlePoolVFS.ts'
|
|
@@ -14,7 +15,7 @@ export const makeOpfsDb = ({
|
|
|
14
15
|
sqlite3: WaSqlite.SQLiteAPI
|
|
15
16
|
directory: string
|
|
16
17
|
fileName: string
|
|
17
|
-
}) =>
|
|
18
|
+
}): Effect.Effect<{ dbPointer: number; vfs: AccessHandlePoolVFS }, never, Opfs.Opfs | Scope.Scope> =>
|
|
18
19
|
Effect.gen(function* () {
|
|
19
20
|
// Replace all special characters with underscores
|
|
20
21
|
const safePath = directory.replaceAll(/["*/:<>?\\|]/g, '_')
|
|
@@ -22,7 +23,7 @@ export const makeOpfsDb = ({
|
|
|
22
23
|
const vfsName = `opfs${pathSegment}`
|
|
23
24
|
|
|
24
25
|
if (sqlite3.vfs_registered.has(vfsName) === false) {
|
|
25
|
-
const vfs = yield*
|
|
26
|
+
const vfs = yield* AccessHandlePoolVFS.create(vfsName, directory, (sqlite3 as any).module)
|
|
26
27
|
|
|
27
28
|
sqlite3.vfs_register(vfs, false)
|
|
28
29
|
opfsVfsMap.set(vfsName, vfs)
|
|
@@ -14,7 +14,7 @@ const PERSISTENT_FILE_TYPES =
|
|
|
14
14
|
|
|
15
15
|
const textDecoder = new TextDecoder()
|
|
16
16
|
|
|
17
|
-
export const
|
|
17
|
+
export const decodeAccessHandlePoolFilename = async (file: File): Promise<string> => {
|
|
18
18
|
// Read the path and digest of the path from the file.
|
|
19
19
|
const corpus = new Uint8Array(await file.slice(0, HEADER_CORPUS_SIZE).arrayBuffer())
|
|
20
20
|
|
package/src/cf/mod.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// import path from 'node:path'
|
|
2
2
|
|
|
3
|
-
import { type MakeSqliteDb, type PersistenceInfo, type SqliteDb,
|
|
3
|
+
import { type MakeSqliteDb, type PersistenceInfo, type SqliteDb, UnknownError } from '@livestore/common'
|
|
4
4
|
import type { CfTypes } from '@livestore/common-cf'
|
|
5
5
|
import { Effect } from '@livestore/utils/effect'
|
|
6
6
|
import type * as WaSqlite from '@livestore/wa-sqlite'
|
|
@@ -140,4 +140,4 @@ const makeCloudflareFsDb = ({
|
|
|
140
140
|
const dbPointer = sqlite3.open_v2Sync(fileName, undefined, vfsName)
|
|
141
141
|
|
|
142
142
|
return { dbPointer, vfs: {} as UNUSED<'only needed in web adapter currently and should longer-term be removed'> }
|
|
143
|
-
}).pipe(
|
|
143
|
+
}).pipe(UnknownError.mapToUnknownError)
|
package/src/make-sqlite-db.ts
CHANGED
|
@@ -35,7 +35,7 @@ export const makeSqliteDb = <
|
|
|
35
35
|
metadata,
|
|
36
36
|
debug: {
|
|
37
37
|
// Setting initially to root but will be set to correct value shortly after
|
|
38
|
-
head: EventSequenceNumber.ROOT,
|
|
38
|
+
head: EventSequenceNumber.Client.ROOT,
|
|
39
39
|
},
|
|
40
40
|
prepare: (queryStr) => {
|
|
41
41
|
try {
|
|
@@ -149,9 +149,6 @@ export const makeSqliteDb = <
|
|
|
149
149
|
sqliteDb.close()
|
|
150
150
|
|
|
151
151
|
metadata.deleteDb()
|
|
152
|
-
// if (metadata._tag === 'opfs') {
|
|
153
|
-
// metadata.vfs.resetAccessHandle(metadata.fileName)
|
|
154
|
-
// }
|
|
155
152
|
},
|
|
156
153
|
close: () => {
|
|
157
154
|
if (isClosed) {
|
package/src/node/mod.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import path from 'node:path'
|
|
2
2
|
|
|
3
|
-
import { type MakeSqliteDb, type PersistenceInfo, type SqliteDb,
|
|
3
|
+
import { type MakeSqliteDb, type PersistenceInfo, type SqliteDb, UnknownError } from '@livestore/common'
|
|
4
4
|
import { Effect, FileSystem } from '@livestore/utils/effect'
|
|
5
5
|
import type * as WaSqlite from '@livestore/wa-sqlite'
|
|
6
6
|
import type { MemoryVFS } from '@livestore/wa-sqlite/src/examples/MemoryVFS.js'
|
|
@@ -129,4 +129,4 @@ const makeNodeFsDb = ({
|
|
|
129
129
|
const dbPointer = sqlite3.open_v2Sync(fileName, undefined, vfsName)
|
|
130
130
|
|
|
131
131
|
return { dbPointer, vfs: {} as UNUSED<'only needed in web adapter currently and should longer-term be removed'> }
|
|
132
|
-
}).pipe(
|
|
132
|
+
}).pipe(UnknownError.mapToUnknownError)
|
package/src/ambient.d.ts
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
// https://developer.mozilla.org/en-US/docs/Web/API/FileSystemSyncAccessHandle
|
|
2
|
-
interface FileSystemSyncAccessHandle {
|
|
3
|
-
close: () => void
|
|
4
|
-
flush: () => Promise<void>
|
|
5
|
-
getSize: () => number
|
|
6
|
-
read: (buffer: Uint8Array<ArrayBuffer> | Uint32Array, options?: FileSystemReadWriteOptions) => number
|
|
7
|
-
truncate: (newSize: number) => void
|
|
8
|
-
write: (buffer: Uint8Array<ArrayBuffer> | Uint32Array, options?: FileSystemReadWriteOptions) => number
|
|
9
|
-
seek: (offset: number) => void
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
interface FileSystemReadWriteOptions {
|
|
13
|
-
at?: number
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
interface FileSystemFileHandle {
|
|
17
|
-
createSyncAccessHandle: () => Promise<FileSystemSyncAccessHandle>
|
|
18
|
-
}
|