@livestore/adapter-web 0.4.0-dev.18 → 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/in-memory/in-memory-adapter.d.ts +2 -2
- package/dist/in-memory/in-memory-adapter.d.ts.map +1 -1
- package/dist/in-memory/in-memory-adapter.js +6 -5
- package/dist/in-memory/in-memory-adapter.js.map +1 -1
- package/dist/web-worker/client-session/client-session-devtools.d.ts +1 -1
- package/dist/web-worker/client-session/client-session-devtools.d.ts.map +1 -1
- package/dist/web-worker/client-session/client-session-devtools.js +3 -2
- package/dist/web-worker/client-session/client-session-devtools.js.map +1 -1
- package/dist/web-worker/client-session/persisted-adapter.d.ts.map +1 -1
- package/dist/web-worker/client-session/persisted-adapter.js +27 -23
- package/dist/web-worker/client-session/persisted-adapter.js.map +1 -1
- package/dist/web-worker/common/persisted-sqlite.d.ts +11 -29
- package/dist/web-worker/common/persisted-sqlite.d.ts.map +1 -1
- package/dist/web-worker/common/persisted-sqlite.js +70 -184
- package/dist/web-worker/common/persisted-sqlite.js.map +1 -1
- package/dist/web-worker/common/shutdown-channel.d.ts +3 -2
- package/dist/web-worker/common/shutdown-channel.d.ts.map +1 -1
- package/dist/web-worker/common/shutdown-channel.js +2 -2
- package/dist/web-worker/common/shutdown-channel.js.map +1 -1
- package/dist/web-worker/common/worker-disconnect-channel.d.ts +2 -6
- package/dist/web-worker/common/worker-disconnect-channel.d.ts.map +1 -1
- package/dist/web-worker/common/worker-disconnect-channel.js +3 -2
- package/dist/web-worker/common/worker-disconnect-channel.js.map +1 -1
- package/dist/web-worker/common/worker-schema.d.ts +69 -46
- package/dist/web-worker/common/worker-schema.d.ts.map +1 -1
- package/dist/web-worker/common/worker-schema.js +20 -20
- package/dist/web-worker/common/worker-schema.js.map +1 -1
- package/dist/web-worker/leader-worker/make-leader-worker.d.ts.map +1 -1
- package/dist/web-worker/leader-worker/make-leader-worker.js +19 -16
- package/dist/web-worker/leader-worker/make-leader-worker.js.map +1 -1
- package/dist/web-worker/shared-worker/make-shared-worker.d.ts.map +1 -1
- package/dist/web-worker/shared-worker/make-shared-worker.js +10 -9
- package/dist/web-worker/shared-worker/make-shared-worker.js.map +1 -1
- package/package.json +7 -8
- package/src/in-memory/in-memory-adapter.ts +8 -16
- package/src/web-worker/ambient.d.ts +0 -20
- package/src/web-worker/client-session/client-session-devtools.ts +3 -2
- package/src/web-worker/client-session/persisted-adapter.ts +35 -27
- package/src/web-worker/common/persisted-sqlite.ts +186 -299
- package/src/web-worker/common/shutdown-channel.ts +10 -3
- package/src/web-worker/common/worker-disconnect-channel.ts +10 -3
- package/src/web-worker/common/worker-schema.ts +21 -21
- package/src/web-worker/leader-worker/make-leader-worker.ts +22 -23
- package/src/web-worker/shared-worker/make-shared-worker.ts +14 -15
- package/dist/opfs-utils.d.ts +0 -7
- package/dist/opfs-utils.d.ts.map +0 -1
- package/dist/opfs-utils.js +0 -43
- package/dist/opfs-utils.js.map +0 -1
- package/src/opfs-utils.ts +0 -61
|
@@ -1,97 +1,66 @@
|
|
|
1
|
-
import { liveStoreStorageFormatVersion
|
|
2
|
-
import {
|
|
1
|
+
import { liveStoreStorageFormatVersion } from '@livestore/common';
|
|
2
|
+
import { decodeAccessHandlePoolFilename, HEADER_OFFSET_DATA, } from '@livestore/sqlite-wasm/browser';
|
|
3
3
|
import { isDevEnv } from '@livestore/utils';
|
|
4
|
-
import { Effect, Schedule, Schema } from '@livestore/utils/effect';
|
|
5
|
-
import
|
|
4
|
+
import { Chunk, Effect, Option, Order, Schedule, Schema, Stream } from '@livestore/utils/effect';
|
|
5
|
+
import { Opfs } from '@livestore/utils/effect/browser';
|
|
6
6
|
export class PersistedSqliteError extends Schema.TaggedError()('PersistedSqliteError', {
|
|
7
7
|
message: Schema.String,
|
|
8
|
-
cause: Schema.Defect,
|
|
8
|
+
cause: Schema.optional(Schema.Defect),
|
|
9
9
|
}) {
|
|
10
10
|
}
|
|
11
|
-
export const
|
|
12
|
-
const
|
|
13
|
-
const
|
|
14
|
-
|
|
15
|
-
|
|
11
|
+
export const readPersistedStateDbFromClientSession = Effect.fn('@livestore/adapter-web:readPersistedStateDbFromClientSession')(function* ({ storageOptions, storeId, schema }) {
|
|
12
|
+
const accessHandlePoolDirString = yield* sanitizeOpfsDir(storageOptions.directory, storeId);
|
|
13
|
+
const accessHandlePoolDirHandle = yield* Opfs.getDirectoryHandleByPath(accessHandlePoolDirString);
|
|
14
|
+
const stateDbFileName = `/${getStateDbFileName(schema)}`;
|
|
15
|
+
const handlesStream = yield* Opfs.Opfs.values(accessHandlePoolDirHandle);
|
|
16
|
+
const stateDbFileOption = yield* handlesStream.pipe(Stream.filter((handle) => handle.kind === 'file'), Stream.mapEffect((fileHandle) => Effect.gen(function* () {
|
|
17
|
+
const file = yield* Opfs.Opfs.getFile(fileHandle);
|
|
18
|
+
const fileName = yield* Effect.promise(() => decodeAccessHandlePoolFilename(file));
|
|
19
|
+
return { file, fileName };
|
|
20
|
+
}), { concurrency: 'unbounded' }), Stream.find(({ fileName }) => fileName === stateDbFileName), Stream.runHead);
|
|
21
|
+
if (Option.isNone(stateDbFileOption)) {
|
|
22
|
+
return yield* new PersistedSqliteError({
|
|
23
|
+
message: `State database file not found in client session (expected '${stateDbFileName}' in '${accessHandlePoolDirString}')`,
|
|
24
|
+
});
|
|
16
25
|
}
|
|
17
|
-
const
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
for await (const value of asyncIterator) {
|
|
25
|
-
if (value.kind === 'file') {
|
|
26
|
-
results.push(value);
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
return results;
|
|
30
|
-
};
|
|
31
|
-
const files = await getAllFiles(sahPoolOpaqueDir.values());
|
|
32
|
-
const fileResults = await Promise.all(files.map(tryGetDbFile));
|
|
33
|
-
const appDbFileName = `/${getStateDbFileName(schema)}`;
|
|
34
|
-
const dbFileRes = fileResults.find((_) => _?.fileName === appDbFileName);
|
|
35
|
-
// console.debug('fileResults', fileResults, 'dbFileRes', dbFileRes)
|
|
36
|
-
if (dbFileRes !== undefined) {
|
|
37
|
-
const data = await dbFileRes.file.slice(HEADER_OFFSET_DATA).arrayBuffer();
|
|
38
|
-
// console.debug('readPersistedAppDbFromClientSession', data.byteLength, data)
|
|
39
|
-
// Given the SAH pool always eagerly creates files with empty non-header data,
|
|
40
|
-
// we want to return undefined if the file exists but is empty
|
|
41
|
-
if (data.byteLength === 0) {
|
|
42
|
-
return undefined;
|
|
43
|
-
}
|
|
44
|
-
return new Uint8Array(data);
|
|
26
|
+
const stateDbBuffer = yield* Effect.promise(() => stateDbFileOption.value.file.slice(HEADER_OFFSET_DATA).arrayBuffer());
|
|
27
|
+
// Given the access handle pool always eagerly creates files with empty non-header data,
|
|
28
|
+
// we want to return undefined if the file exists but is empty
|
|
29
|
+
if (stateDbBuffer.byteLength === 0) {
|
|
30
|
+
return yield* new PersistedSqliteError({
|
|
31
|
+
message: `State database file is empty in client session (expected '${stateDbFileName}' in '${accessHandlePoolDirString}')`,
|
|
32
|
+
});
|
|
45
33
|
}
|
|
46
|
-
return
|
|
47
|
-
}
|
|
34
|
+
return new Uint8Array(stateDbBuffer);
|
|
35
|
+
}, Effect.logWarnIfTakesLongerThan({
|
|
48
36
|
duration: 1000,
|
|
49
|
-
label: '@livestore/adapter-web:
|
|
50
|
-
}), Effect.withPerformanceMeasure('@livestore/adapter-web:
|
|
51
|
-
export const resetPersistedDataFromClientSession = ({ storageOptions, storeId
|
|
52
|
-
const directory = sanitizeOpfsDir(storageOptions.directory, storeId);
|
|
53
|
-
yield*
|
|
54
|
-
|
|
37
|
+
label: '@livestore/adapter-web:readPersistedStateDbFromClientSession',
|
|
38
|
+
}), Effect.withPerformanceMeasure('@livestore/adapter-web:readPersistedStateDbFromClientSession'));
|
|
39
|
+
export const resetPersistedDataFromClientSession = Effect.fn('@livestore/adapter-web:resetPersistedDataFromClientSession')(function* ({ storageOptions, storeId }) {
|
|
40
|
+
const directory = yield* sanitizeOpfsDir(storageOptions.directory, storeId);
|
|
41
|
+
yield* Opfs.remove(directory).pipe(
|
|
42
|
+
// We ignore NotFoundError here as it may not exist or have already been deleted
|
|
43
|
+
Effect.catchTag('@livestore/utils/Web/NotFoundError', () => Effect.void));
|
|
44
|
+
}, Effect.retry({
|
|
55
45
|
schedule: Schedule.exponentialBackoff10Sec,
|
|
56
|
-
})
|
|
57
|
-
const
|
|
58
|
-
|
|
59
|
-
const root = await OpfsUtils.rootHandlePromise;
|
|
60
|
-
// Split the absolute path to traverse directories
|
|
61
|
-
const pathParts = absPath.split('/').filter((part) => part.length);
|
|
62
|
-
try {
|
|
63
|
-
// Traverse to the target file handle
|
|
64
|
-
let currentDir = root;
|
|
65
|
-
for (let i = 0; i < pathParts.length - 1; i++) {
|
|
66
|
-
currentDir = await currentDir.getDirectoryHandle(pathParts[i]);
|
|
67
|
-
}
|
|
68
|
-
// Delete the file
|
|
69
|
-
await currentDir.removeEntry(pathParts.at(-1), { recursive: true });
|
|
70
|
-
}
|
|
71
|
-
catch (error) {
|
|
72
|
-
if (error instanceof DOMException && error.name === 'NotFoundError') {
|
|
73
|
-
// Can ignore as it's already been deleted or not there in the first place
|
|
74
|
-
return;
|
|
75
|
-
}
|
|
76
|
-
else {
|
|
77
|
-
throw error;
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
}).pipe(UnexpectedError.mapToUnexpectedError, Effect.withSpan('@livestore/adapter-web:worker:opfsDeleteFile', { attributes: { absFilePath: absPath } }));
|
|
81
|
-
export const sanitizeOpfsDir = (directory, storeId) => {
|
|
82
|
-
// Root dir should be `''` not `/`
|
|
83
|
-
if (directory === undefined || directory === '' || directory === '/')
|
|
46
|
+
}));
|
|
47
|
+
export const sanitizeOpfsDir = Effect.fn('@livestore/adapter-web:sanitizeOpfsDir')(function* (directory, storeId) {
|
|
48
|
+
if (directory === undefined || directory === '' || directory === '/') {
|
|
84
49
|
return `livestore-${storeId}@${liveStoreStorageFormatVersion}`;
|
|
50
|
+
}
|
|
85
51
|
if (directory.includes('/')) {
|
|
86
|
-
|
|
52
|
+
return yield* new PersistedSqliteError({
|
|
53
|
+
message: `Nested directories are not yet supported ('${directory}')`,
|
|
54
|
+
});
|
|
87
55
|
}
|
|
88
56
|
return `${directory}@${liveStoreStorageFormatVersion}`;
|
|
89
|
-
};
|
|
57
|
+
});
|
|
90
58
|
export const getStateDbFileName = (schema) => {
|
|
91
59
|
const schemaHashSuffix = schema.state.sqlite.migrations.strategy === 'manual' ? 'fixed' : schema.state.sqlite.hash.toString();
|
|
92
60
|
return `state${schemaHashSuffix}.db`;
|
|
93
61
|
};
|
|
94
62
|
export const MAX_ARCHIVED_STATE_DBS_IN_DEV = 3;
|
|
63
|
+
export const ARCHIVE_DIR_NAME = 'archive';
|
|
95
64
|
/**
|
|
96
65
|
* Cleanup old state database files after successful migration.
|
|
97
66
|
* This prevents OPFS file pool capacity from being exhausted by accumulated schema files.
|
|
@@ -99,7 +68,7 @@ export const MAX_ARCHIVED_STATE_DBS_IN_DEV = 3;
|
|
|
99
68
|
* @param vfs - The AccessHandlePoolVFS instance for safe file operations
|
|
100
69
|
* @param currentSchema - Current schema (to avoid deleting the active database)
|
|
101
70
|
*/
|
|
102
|
-
export const cleanupOldStateDbFiles = Effect.fn('@livestore/adapter-web:cleanupOldStateDbFiles')(function* ({ vfs, currentSchema, opfsDirectory
|
|
71
|
+
export const cleanupOldStateDbFiles = Effect.fn('@livestore/adapter-web:cleanupOldStateDbFiles')(function* ({ vfs, currentSchema, opfsDirectory }) {
|
|
103
72
|
// Only cleanup for auto migration strategy because:
|
|
104
73
|
// - Auto strategy: Creates new database files per schema change (e.g., state123.db, state456.db)
|
|
105
74
|
// which accumulate over time and can exhaust OPFS file pool capacity
|
|
@@ -115,130 +84,47 @@ export const cleanupOldStateDbFiles = Effect.fn('@livestore/adapter-web:cleanupO
|
|
|
115
84
|
const allPaths = yield* Effect.sync(() => vfs.getTrackedFilePaths());
|
|
116
85
|
const oldStateDbPaths = allPaths.filter((path) => path.startsWith('/state') && path.endsWith('.db') && path !== currentPath);
|
|
117
86
|
if (oldStateDbPaths.length === 0) {
|
|
118
|
-
yield* Effect.logDebug('
|
|
87
|
+
yield* Effect.logDebug('No old database files found');
|
|
119
88
|
return;
|
|
120
89
|
}
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
let archiveDirHandle;
|
|
90
|
+
const absoluteArchiveDirName = `${opfsDirectory}/${ARCHIVE_DIR_NAME}`;
|
|
91
|
+
if (isDev && !(yield* Opfs.exists(absoluteArchiveDirName)))
|
|
92
|
+
yield* Opfs.makeDirectory(absoluteArchiveDirName);
|
|
125
93
|
for (const path of oldStateDbPaths) {
|
|
126
94
|
const fileName = path.startsWith('/') ? path.slice(1) : path;
|
|
127
95
|
if (isDev) {
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
});
|
|
132
|
-
const archivedFileName = yield* archiveStateDbFile({
|
|
133
|
-
vfs,
|
|
134
|
-
fileName,
|
|
135
|
-
archiveDirHandle,
|
|
136
|
-
});
|
|
137
|
-
archivedFileNames.push(archivedFileName);
|
|
96
|
+
const archiveFileData = yield* vfs.readFilePayload(fileName);
|
|
97
|
+
const archiveFileName = `${Date.now()}-${fileName}`;
|
|
98
|
+
yield* Opfs.writeFile(`${opfsDirectory}/archive/${archiveFileName}`, new Uint8Array(archiveFileData));
|
|
138
99
|
}
|
|
139
100
|
const vfsResultCode = yield* Effect.try({
|
|
140
101
|
try: () => vfs.jDelete(fileName, 0),
|
|
141
|
-
catch: (cause) => new
|
|
102
|
+
catch: (cause) => new PersistedSqliteError({ message: `Failed to delete old state database file: ${fileName}`, cause }),
|
|
142
103
|
});
|
|
143
104
|
// 0 indicates a successful result in SQLite.
|
|
144
105
|
// See https://www.sqlite.org/c3ref/c_abort.html
|
|
145
106
|
if (vfsResultCode !== 0) {
|
|
146
|
-
return yield* new
|
|
147
|
-
|
|
148
|
-
fileName,
|
|
149
|
-
vfsResultCode,
|
|
107
|
+
return yield* new PersistedSqliteError({
|
|
108
|
+
message: `Failed to delete old state database file: ${fileName}, got result code: ${vfsResultCode}`,
|
|
150
109
|
});
|
|
151
110
|
}
|
|
152
|
-
|
|
153
|
-
yield* Effect.logDebug(`Successfully deleted old state database file: ${fileName}`);
|
|
111
|
+
yield* Effect.logDebug(`Deleted old state database file: ${fileName}`);
|
|
154
112
|
}
|
|
155
|
-
if (isDev
|
|
156
|
-
|
|
157
|
-
|
|
113
|
+
if (isDev) {
|
|
114
|
+
yield* pruneArchiveDirectory({
|
|
115
|
+
archiveDirectory: absoluteArchiveDirName,
|
|
158
116
|
keep: MAX_ARCHIVED_STATE_DBS_IN_DEV,
|
|
159
117
|
});
|
|
160
|
-
yield* Effect.logDebug(`State db cleanup completed: archived ${archivedFileNames.length} file(s); removed ${deletedCount} old database file(s) from active pool; archive retained ${pruneResult.retained.length} file(s)`);
|
|
161
118
|
}
|
|
162
|
-
else {
|
|
163
|
-
yield* Effect.logDebug(`State db cleanup completed: removed ${deletedCount} old database file(s)`);
|
|
164
|
-
}
|
|
165
|
-
}, Effect.mapError((error) => new PersistedSqliteError({
|
|
166
|
-
message: 'Failed to clean up old state database file(s)',
|
|
167
|
-
cause: error,
|
|
168
|
-
})));
|
|
169
|
-
const archiveStateDbFile = Effect.fn('@livestore/adapter-web:archiveStateDbFile')(function* ({ vfs, fileName, archiveDirHandle, }) {
|
|
170
|
-
const stateDbBuffer = vfs.readFilePayload(fileName);
|
|
171
|
-
const archiveFileName = `${Date.now()}-${fileName}`;
|
|
172
|
-
const archiveFileHandle = yield* Effect.tryPromise({
|
|
173
|
-
try: () => archiveDirHandle.getFileHandle(archiveFileName, { create: true }),
|
|
174
|
-
catch: (cause) => new ArchiveStateDbError({
|
|
175
|
-
message: 'Failed to open archive file handle',
|
|
176
|
-
fileName: archiveFileName,
|
|
177
|
-
cause,
|
|
178
|
-
}),
|
|
179
|
-
});
|
|
180
|
-
const archiveFileAccessHandle = yield* Effect.acquireRelease(Effect.tryPromise({
|
|
181
|
-
try: () => archiveFileHandle.createSyncAccessHandle(),
|
|
182
|
-
catch: (cause) => new ArchiveStateDbError({
|
|
183
|
-
message: 'Failed to create sync access handle for archived file',
|
|
184
|
-
fileName: archiveFileName,
|
|
185
|
-
cause,
|
|
186
|
-
}),
|
|
187
|
-
}), (handle) => Effect.sync(() => handle.close()).pipe(Effect.ignoreLogged));
|
|
188
|
-
yield* Effect.try({
|
|
189
|
-
try: () => {
|
|
190
|
-
archiveFileAccessHandle.write(stateDbBuffer);
|
|
191
|
-
archiveFileAccessHandle.flush();
|
|
192
|
-
},
|
|
193
|
-
catch: (cause) => new ArchiveStateDbError({
|
|
194
|
-
message: 'Failed to write archived state database',
|
|
195
|
-
fileName: archiveFileName,
|
|
196
|
-
cause,
|
|
197
|
-
}),
|
|
198
|
-
});
|
|
199
|
-
return archiveFileName;
|
|
200
|
-
}, Effect.scoped);
|
|
201
|
-
const pruneArchiveDir = Effect.fn('@livestore/adapter-web:pruneArchiveDir')(function* ({ archiveDirHandle, keep, }) {
|
|
202
|
-
const files = yield* Effect.tryPromise({
|
|
203
|
-
try: async () => {
|
|
204
|
-
const result = [];
|
|
205
|
-
for await (const entry of archiveDirHandle.values()) {
|
|
206
|
-
if (entry.kind !== 'file')
|
|
207
|
-
continue;
|
|
208
|
-
const fileHandle = await archiveDirHandle.getFileHandle(entry.name);
|
|
209
|
-
const file = await fileHandle.getFile();
|
|
210
|
-
result.push({ name: entry.name, lastModified: file.lastModified });
|
|
211
|
-
}
|
|
212
|
-
return result.sort((a, b) => b.lastModified - a.lastModified);
|
|
213
|
-
},
|
|
214
|
-
catch: (cause) => new ArchiveStateDbError({ message: 'Failed to enumerate archived state databases', cause }),
|
|
215
|
-
});
|
|
216
|
-
const retained = files.slice(0, keep);
|
|
217
|
-
const toDelete = files.slice(keep);
|
|
218
|
-
yield* Effect.forEach(toDelete, ({ name }) => Effect.tryPromise({
|
|
219
|
-
try: () => archiveDirHandle.removeEntry(name),
|
|
220
|
-
catch: (cause) => new ArchiveStateDbError({
|
|
221
|
-
message: 'Failed to delete archived state database',
|
|
222
|
-
fileName: name,
|
|
223
|
-
cause,
|
|
224
|
-
}),
|
|
225
|
-
}));
|
|
226
|
-
return {
|
|
227
|
-
retained,
|
|
228
|
-
deleted: toDelete,
|
|
229
|
-
};
|
|
230
119
|
});
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
cause: Schema.optional(Schema.Defect),
|
|
242
|
-
}) {
|
|
243
|
-
}
|
|
120
|
+
const pruneArchiveDirectory = Effect.fn('@livestore/adapter-web:pruneArchiveDirectory')(function* ({ archiveDirectory, keep, }) {
|
|
121
|
+
const archiveDirHandle = yield* Opfs.getDirectoryHandleByPath(archiveDirectory);
|
|
122
|
+
const handlesStream = yield* Opfs.Opfs.values(archiveDirHandle);
|
|
123
|
+
const filesWithMetadata = yield* handlesStream.pipe(Stream.filter((handle) => handle.kind === 'file'), Stream.mapEffect((fileHandle) => Opfs.getMetadata(fileHandle)), Stream.runCollect);
|
|
124
|
+
const filesToDelete = filesWithMetadata.pipe(Chunk.sort(Order.mapInput(Order.number, (entry) => entry.lastModified)), Chunk.drop(keep), Chunk.toReadonlyArray);
|
|
125
|
+
if (filesToDelete.length === 0)
|
|
126
|
+
return;
|
|
127
|
+
yield* Effect.forEach(filesToDelete, ({ name }) => Opfs.Opfs.removeEntry(archiveDirHandle, name));
|
|
128
|
+
yield* Effect.logDebug(`Pruned ${filesToDelete.length} old database file(s) from archive directory`);
|
|
129
|
+
});
|
|
244
130
|
//# sourceMappingURL=persisted-sqlite.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"persisted-sqlite.js","sourceRoot":"","sources":["../../../src/web-worker/common/persisted-sqlite.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,6BAA6B,EAAE,
|
|
1
|
+
{"version":3,"file":"persisted-sqlite.js","sourceRoot":"","sources":["../../../src/web-worker/common/persisted-sqlite.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,6BAA6B,EAAE,MAAM,mBAAmB,CAAA;AAEjE,OAAO,EACL,8BAA8B,EAC9B,kBAAkB,GAEnB,MAAM,gCAAgC,CAAA;AACvC,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAA;AAC3C,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,yBAAyB,CAAA;AAChG,OAAO,EAAE,IAAI,EAAiB,MAAM,iCAAiC,CAAA;AAGrE,MAAM,OAAO,oBAAqB,SAAQ,MAAM,CAAC,WAAW,EAAwB,CAAC,sBAAsB,EAAE;IAC3G,OAAO,EAAE,MAAM,CAAC,MAAM;IACtB,KAAK,EAAE,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC,MAAM,CAAC;CACtC,CAAC;CAAG;AAEL,MAAM,CAAC,MAAM,qCAAqC,GAgB9C,MAAM,CAAC,EAAE,CAAC,8DAA8D,CAAC,CAC3E,QAAQ,CAAC,EAAE,EAAE,cAAc,EAAE,OAAO,EAAE,MAAM,EAAE;IAC5C,MAAM,yBAAyB,GAAG,KAAK,CAAC,CAAC,eAAe,CAAC,cAAc,CAAC,SAAS,EAAE,OAAO,CAAC,CAAA;IAE3F,MAAM,yBAAyB,GAAG,KAAK,CAAC,CAAC,IAAI,CAAC,wBAAwB,CAAC,yBAAyB,CAAC,CAAA;IAEjG,MAAM,eAAe,GAAG,IAAI,kBAAkB,CAAC,MAAM,CAAC,EAAE,CAAA;IAExD,MAAM,aAAa,GAAG,KAAK,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,yBAAyB,CAAC,CAAA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C,EAC9D,MAAM,CAAC,UAAU,CAClB,CAAA;IACD,MAAM,aAAa,GAAG,iBAAiB,CAAC,IAAI,CAC1C,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,KAAK,CAAC,MAAM,EAAE,CAAC,KAA+B,EAAE,EAAE,CAAC,KAAK,CAAC,YAAY,CAAC,CAAC,EACjG,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,EAChB,KAAK,CAAC,eAAe,CACtB,CAAA;IAED,IAAI,aAAa,CAAC,MAAM,KAAK,CAAC;QAAE,OAAM;IAEtC,KAAK,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,aAAa,EAAE,CAAC,EAAE,IAAI,EAAE,EAAE,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,WAAW,CAAC,gBAAgB,EAAE,IAAI,CAAC,CAAC,CAAA;IAEjG,KAAK,CAAC,CAAC,MAAM,CAAC,QAAQ,CAAC,UAAU,aAAa,CAAC,MAAM,8CAA8C,CAAC,CAAA;AACtG,CAAC,CAAC,CAAA"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
1
|
+
import { ShutdownChannel } from '@livestore/common/leader-thread';
|
|
2
|
+
import type { Effect, Scope, WebChannel } from '@livestore/utils/effect';
|
|
3
|
+
export declare const makeShutdownChannel: (storeId: string) => Effect.Effect<WebChannel.WebChannel<typeof ShutdownChannel.All.Type, typeof ShutdownChannel.All.Type>, never, Scope.Scope>;
|
|
3
4
|
//# sourceMappingURL=shutdown-channel.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"shutdown-channel.d.ts","sourceRoot":"","sources":["../../../src/web-worker/common/shutdown-channel.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"shutdown-channel.d.ts","sourceRoot":"","sources":["../../../src/web-worker/common/shutdown-channel.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,iCAAiC,CAAA;AACjE,OAAO,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAA;AAGxE,eAAO,MAAM,mBAAmB,GAC9B,SAAS,MAAM,KACd,MAAM,CAAC,MAAM,CACd,UAAU,CAAC,UAAU,CAAC,OAAO,eAAe,CAAC,GAAG,CAAC,IAAI,EAAE,OAAO,eAAe,CAAC,GAAG,CAAC,IAAI,CAAC,EACvF,KAAK,EACL,KAAK,CAAC,KAAK,CAKT,CAAA"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ShutdownChannel } from '@livestore/common/leader-thread';
|
|
2
|
-
import {
|
|
3
|
-
export const makeShutdownChannel = (storeId) =>
|
|
2
|
+
import { WebChannelBrowser } from '@livestore/utils/effect/browser';
|
|
3
|
+
export const makeShutdownChannel = (storeId) => WebChannelBrowser.broadcastChannel({
|
|
4
4
|
channelName: `livestore.shutdown.${storeId}`,
|
|
5
5
|
schema: ShutdownChannel.All,
|
|
6
6
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"shutdown-channel.js","sourceRoot":"","sources":["../../../src/web-worker/common/shutdown-channel.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,iCAAiC,CAAA;
|
|
1
|
+
{"version":3,"file":"shutdown-channel.js","sourceRoot":"","sources":["../../../src/web-worker/common/shutdown-channel.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,iCAAiC,CAAA;AAEjE,OAAO,EAAE,iBAAiB,EAAE,MAAM,iCAAiC,CAAA;AAEnE,MAAM,CAAC,MAAM,mBAAmB,GAAG,CACjC,OAAe,EAKf,EAAE,CACF,iBAAiB,CAAC,gBAAgB,CAAC;IACjC,WAAW,EAAE,sBAAsB,OAAO,EAAE;IAC5C,MAAM,EAAE,eAAe,CAAC,GAAG;CAC5B,CAAC,CAAA"}
|
|
@@ -1,12 +1,8 @@
|
|
|
1
|
-
import { Schema, WebChannel } from '@livestore/utils/effect';
|
|
1
|
+
import { type Effect, Schema, type Scope, type WebChannel } from '@livestore/utils/effect';
|
|
2
2
|
declare const DedicatedWorkerDisconnectBroadcast_base: Schema.TaggedStruct<"DedicatedWorkerDisconnectBroadcast", {}>;
|
|
3
3
|
export declare class DedicatedWorkerDisconnectBroadcast extends DedicatedWorkerDisconnectBroadcast_base {
|
|
4
4
|
}
|
|
5
5
|
/** Used across workers for leader election purposes */
|
|
6
|
-
export declare const makeWorkerDisconnectChannel: (storeId: string) =>
|
|
7
|
-
readonly _tag: "DedicatedWorkerDisconnectBroadcast";
|
|
8
|
-
}, {
|
|
9
|
-
readonly _tag: "DedicatedWorkerDisconnectBroadcast";
|
|
10
|
-
}, never>, never, import("effect/Scope").Scope>;
|
|
6
|
+
export declare const makeWorkerDisconnectChannel: (storeId: string) => Effect.Effect<WebChannel.WebChannel<typeof DedicatedWorkerDisconnectBroadcast.Type, typeof DedicatedWorkerDisconnectBroadcast.Type>, never, Scope.Scope>;
|
|
11
7
|
export {};
|
|
12
8
|
//# sourceMappingURL=worker-disconnect-channel.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"worker-disconnect-channel.d.ts","sourceRoot":"","sources":["../../../src/web-worker/common/worker-disconnect-channel.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAA;;
|
|
1
|
+
{"version":3,"file":"worker-disconnect-channel.d.ts","sourceRoot":"","sources":["../../../src/web-worker/common/worker-disconnect-channel.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,MAAM,EAAE,MAAM,EAAE,KAAK,KAAK,EAAE,KAAK,UAAU,EAAE,MAAM,yBAAyB,CAAA;;AAG1F,qBAAa,kCAAmC,SAAQ,uCAA6D;CAAG;AAExH,uDAAuD;AACvD,eAAO,MAAM,2BAA2B,GACtC,SAAS,MAAM,KACd,MAAM,CAAC,MAAM,CACd,UAAU,CAAC,UAAU,CAAC,OAAO,kCAAkC,CAAC,IAAI,EAAE,OAAO,kCAAkC,CAAC,IAAI,CAAC,EACrH,KAAK,EACL,KAAK,CAAC,KAAK,CAKT,CAAA"}
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import { Schema
|
|
1
|
+
import { Schema } from '@livestore/utils/effect';
|
|
2
|
+
import { WebChannelBrowser } from '@livestore/utils/effect/browser';
|
|
2
3
|
export class DedicatedWorkerDisconnectBroadcast extends Schema.TaggedStruct('DedicatedWorkerDisconnectBroadcast', {}) {
|
|
3
4
|
}
|
|
4
5
|
/** Used across workers for leader election purposes */
|
|
5
|
-
export const makeWorkerDisconnectChannel = (storeId) =>
|
|
6
|
+
export const makeWorkerDisconnectChannel = (storeId) => WebChannelBrowser.broadcastChannel({
|
|
6
7
|
channelName: `livestore.worker-disconnect.${storeId}`,
|
|
7
8
|
schema: DedicatedWorkerDisconnectBroadcast,
|
|
8
9
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"worker-disconnect-channel.js","sourceRoot":"","sources":["../../../src/web-worker/common/worker-disconnect-channel.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"worker-disconnect-channel.js","sourceRoot":"","sources":["../../../src/web-worker/common/worker-disconnect-channel.ts"],"names":[],"mappings":"AAAA,OAAO,EAAe,MAAM,EAA+B,MAAM,yBAAyB,CAAA;AAC1F,OAAO,EAAE,iBAAiB,EAAE,MAAM,iCAAiC,CAAA;AAEnE,MAAM,OAAO,kCAAmC,SAAQ,MAAM,CAAC,YAAY,CAAC,oCAAoC,EAAE,EAAE,CAAC;CAAG;AAExH,uDAAuD;AACvD,MAAM,CAAC,MAAM,2BAA2B,GAAG,CACzC,OAAe,EAKf,EAAE,CACF,iBAAiB,CAAC,gBAAgB,CAAC;IACjC,WAAW,EAAE,+BAA+B,OAAO,EAAE;IACrD,MAAM,EAAE,kCAAkC;CAC3C,CAAC,CAAA"}
|