@spooky-sync/core 1.0.0-beta.1 → 1.0.0-beta.11
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/AGENTS.md +4 -3
- package/dist/index.d.ts +170 -9
- package/dist/index.js +5398 -2968
- package/dist/rows-worker.d.ts +1 -0
- package/dist/rows-worker.js +2731 -0
- package/dist/sqlite-open.js +1 -1
- package/dist/sqlite-worker.js +1 -1
- package/dist/types.d.ts +131 -13
- package/package.json +9 -4
- package/scripts/check-worker-entries.mjs +15 -2
- package/skills/sp00ky-core/SKILL.md +2 -0
- package/src/client/bucket-handle.ts +21 -1
- package/src/client/eager-paint.test.ts +82 -0
- package/src/client/services.ts +4 -1
- package/src/client/sp00ky-client.test.ts +143 -1
- package/src/client/sp00ky-client.ts +158 -19
- package/src/index.ts +9 -0
- package/src/kernel/effects.ts +12 -2
- package/src/kernel/interpreter.test.ts +17 -0
- package/src/kernel/interpreter.ts +5 -2
- package/src/modules/channel/hub.test.ts +223 -0
- package/src/modules/channel/hub.ts +355 -0
- package/src/modules/channel/index.ts +358 -14
- package/src/modules/channel/room.test.ts +340 -0
- package/src/modules/channel/room.ts +367 -0
- package/src/modules/channel/rooms.fixture.ts +383 -0
- package/src/modules/channel/share.test.ts +535 -0
- package/src/modules/channel/webrtc.ts +2 -2
- package/src/modules/devtools/storage-info.ts +4 -3
- package/src/query/materialize.saga.test.ts +16 -0
- package/src/query/materialize.saga.ts +7 -26
- package/src/query/materialize.ts +79 -3
- package/src/query/register.saga.test.ts +61 -0
- package/src/query/register.saga.ts +39 -2
- package/src/services/database/cache-engine.ts +17 -3
- package/src/services/database/engine-factory.ts +7 -0
- package/src/services/database/index.ts +1 -0
- package/src/services/database/rows-cache-engine.test.ts +1584 -0
- package/src/services/database/rows-cache-engine.ts +1203 -0
- package/src/services/database/rows-exec.integration.test.ts +589 -0
- package/src/services/database/rows-exec.ts +1027 -0
- package/src/services/database/rows-prewarm.ts +251 -0
- package/src/services/database/rows-store.test.ts +635 -0
- package/src/services/database/rows-store.ts +1208 -0
- package/src/services/database/rows-transport.fixture.ts +151 -0
- package/src/services/database/rows-worker.ts +607 -0
- package/src/services/database/rows-yield.test.ts +141 -0
- package/src/services/database/rows-yield.ts +92 -0
- package/src/services/database/sqlite-cache-engine.test.ts +22 -1
- package/src/services/database/sqlite-cache-engine.ts +55 -34
- package/src/services/database/sqlite-transport.ts +7 -5
- package/src/services/tabs/support.ts +6 -4
- package/src/types.ts +41 -6
- package/tsdown.config.ts +42 -1
- package/vitest.config.ts +4 -0
package/tsdown.config.ts
CHANGED
|
@@ -61,15 +61,41 @@ const versionDefinePlugin = {
|
|
|
61
61
|
const workerUrlPlugin = {
|
|
62
62
|
name: 'sp00ky-worker-url',
|
|
63
63
|
transform(code: string) {
|
|
64
|
-
if (
|
|
64
|
+
if (
|
|
65
|
+
!code.includes('sqlite-worker.ts') &&
|
|
66
|
+
!code.includes('rows-worker.ts') &&
|
|
67
|
+
!code.includes('tabs-broker-worker.ts')
|
|
68
|
+
) {
|
|
69
|
+
return null;
|
|
70
|
+
}
|
|
65
71
|
return code
|
|
66
72
|
.split('sqlite-worker.ts')
|
|
67
73
|
.join('sqlite-worker.js')
|
|
74
|
+
.split('rows-worker.ts')
|
|
75
|
+
.join('rows-worker.js')
|
|
68
76
|
.split('tabs-broker-worker.ts')
|
|
69
77
|
.join('tabs-broker-worker.js');
|
|
70
78
|
},
|
|
71
79
|
};
|
|
72
80
|
|
|
81
|
+
// V8 compiles a function the first time it is called, on the thread calling
|
|
82
|
+
// it. `//# allFunctionsCalledOnLoad` as a file's FIRST line (Chrome 136+) has
|
|
83
|
+
// the whole file compiled while it loads, off that thread, and kept in the
|
|
84
|
+
// code cache. Only for the row store's worker: a small file of which every
|
|
85
|
+
// function runs within its first requests, and which a page is waiting for.
|
|
86
|
+
// Measured: 0.6 to 1.5 ms off the worker's first `open`. An app's bundler
|
|
87
|
+
// that minifies the worker drops the comment; the docs say how to keep it.
|
|
88
|
+
const COMPILE_HINT = '//# allFunctionsCalledOnLoad\n';
|
|
89
|
+
const compileHintPlugin = {
|
|
90
|
+
name: 'sp00ky-compile-hint',
|
|
91
|
+
generateBundle(_options: unknown, bundle: Record<string, { type: string; code?: string }>) {
|
|
92
|
+
for (const [name, file] of Object.entries(bundle)) {
|
|
93
|
+
if (name !== 'rows-worker.js') continue;
|
|
94
|
+
if (file.type === 'chunk' && typeof file.code === 'string' && !file.code.startsWith(COMPILE_HINT)) file.code = COMPILE_HINT + file.code;
|
|
95
|
+
}
|
|
96
|
+
},
|
|
97
|
+
};
|
|
98
|
+
|
|
73
99
|
export default defineConfig([
|
|
74
100
|
{
|
|
75
101
|
// `sqlite-worker` is emitted at `dist/sqlite-worker.js` (top level, NOT under
|
|
@@ -120,4 +146,19 @@ export default defineConfig([
|
|
|
120
146
|
},
|
|
121
147
|
plugins: [versionDefinePlugin],
|
|
122
148
|
},
|
|
149
|
+
// The row store's worker (`localEngine: 'rows'`), at `dist/rows-worker.js`
|
|
150
|
+
// like the SQLite one. A build of its own so the file holds everything the
|
|
151
|
+
// worker runs and nothing else: the compile hint on its first line then
|
|
152
|
+
// covers the store and its queries, and no page ever loads hinted code.
|
|
153
|
+
{
|
|
154
|
+
entry: { 'rows-worker': 'src/services/database/rows-worker.ts' },
|
|
155
|
+
format: ['esm'],
|
|
156
|
+
dts: true,
|
|
157
|
+
clean: false,
|
|
158
|
+
hash: false,
|
|
159
|
+
outputOptions: {
|
|
160
|
+
chunkFileNames: (chunk: { name: string }) => (chunk.name === 'rows-worker.d' ? '[name].js' : 'rows-worker-[name].js'),
|
|
161
|
+
},
|
|
162
|
+
plugins: [versionDefinePlugin, compileHintPlugin],
|
|
163
|
+
},
|
|
123
164
|
]);
|
package/vitest.config.ts
CHANGED
|
@@ -3,6 +3,9 @@ import { defineConfig } from 'vitest/config';
|
|
|
3
3
|
// Thresholds start at the numbers the suite hits today and are ratcheted per
|
|
4
4
|
// directory as the saga core lands (see the plan's commit 10). Exclusions:
|
|
5
5
|
// *.fixture.ts / src/testing/** test-only harness code
|
|
6
|
+
// rows-worker.ts runs inside a Worker (OPFS sync access handles +
|
|
7
|
+
// Web Locks); its ops are `handleRowsOp`, which
|
|
8
|
+
// the engine tests run in-process
|
|
6
9
|
// sqlite-worker.ts runs inside a Worker (sqlite-wasm + OPFS +
|
|
7
10
|
// postMessage globals); covered by the sqlite
|
|
8
11
|
// integration tests and the build check
|
|
@@ -25,6 +28,7 @@ export default defineConfig({
|
|
|
25
28
|
'src/**/*.fixture.ts',
|
|
26
29
|
'src/testing/**',
|
|
27
30
|
'src/services/database/sqlite-worker.ts',
|
|
31
|
+
'src/services/database/rows-worker.ts',
|
|
28
32
|
'src/client/services.ts',
|
|
29
33
|
],
|
|
30
34
|
thresholds: {
|