@spooky-sync/core 0.0.1-canary.118 → 0.0.1-canary.119

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/index.js CHANGED
@@ -1563,7 +1563,7 @@ function pureWriteOpResult(op) {
1563
1563
  }
1564
1564
  /**
1565
1565
  * Local cache backend on official SQLite-WASM in a dedicated Worker (see
1566
- * `sqlite-worker.ts`), with OPFS SAHPool persistence. Storage model: one table
1566
+ * `sqlite-worker.js`), with OPFS SAHPool persistence. Storage model: one table
1567
1567
  * per schema table, `id TEXT PRIMARY KEY, data TEXT` where `data` is the row as
1568
1568
  * JSON. Filtering/ordering use `json_extract`. Relations are decomposed by the
1569
1569
  * shared {@link resolveRelations} — identical to the SurrealDB backend.
@@ -5100,8 +5100,8 @@ function parseBackendInfo(raw) {
5100
5100
 
5101
5101
  //#endregion
5102
5102
  //#region src/modules/devtools/index.ts
5103
- const CORE_VERSION = "0.0.1-canary.118";
5104
- const WASM_VERSION = "0.0.1-canary.118";
5103
+ const CORE_VERSION = "0.0.1-canary.119";
5104
+ const WASM_VERSION = "0.0.1-canary.119";
5105
5105
  const SURREAL_VERSION = "3.0.3";
5106
5106
  var DevToolsService = class {
5107
5107
  eventsHistory = [];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@spooky-sync/core",
3
- "version": "0.0.1-canary.118",
3
+ "version": "0.0.1-canary.119",
4
4
  "type": "module",
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",
@@ -59,8 +59,8 @@
59
59
  }
60
60
  },
61
61
  "dependencies": {
62
- "@spooky-sync/query-builder": "0.0.1-canary.118",
63
- "@spooky-sync/ssp-wasm": "0.0.1-canary.118",
62
+ "@spooky-sync/query-builder": "0.0.1-canary.119",
63
+ "@spooky-sync/ssp-wasm": "0.0.1-canary.119",
64
64
  "@sqlite.org/sqlite-wasm": "3.53.0-build1",
65
65
  "@surrealdb/wasm": "^3.0.3",
66
66
  "fast-json-patch": "^3.1.1",
@@ -106,11 +106,14 @@ export class SqliteCacheEngine implements LocalStore {
106
106
  // ---- worker plumbing -----------------------------------------------------
107
107
 
108
108
  private spawnWorker(): Worker {
109
- // The worker is a separate tsdown entry emitted at `dist/sqlite-worker.js`
110
- // (see tsdown.config.ts). This URL must point at the emitted `.js` so it
111
- // resolves after bundling into the flat `dist/index.js`; a `.ts` here ships
112
- // a dangling reference the consumer's bundler can't resolve.
113
- const worker = new Worker(new URL('./sqlite-worker.js', import.meta.url), { type: 'module' });
109
+ // Source references the `.ts` so the monorepo's src-bundling consumers
110
+ // (e.g. the example app, which aliases `@spooky-sync/core` to `src`) resolve
111
+ // it Vite handles `.ts` workers. For the published package, the tsdown
112
+ // build rewrites this to `./sqlite-worker.js` (the top-level emitted entry;
113
+ // see tsdown.config.ts), which the flat `dist/index.js` resolves. The worker
114
+ // (+ `@sqlite.org/sqlite-wasm`) still loads lazily — only when `localEngine:
115
+ // 'sqlite'` is used.
116
+ const worker = new Worker(new URL('./sqlite-worker.ts', import.meta.url), { type: 'module' });
114
117
  worker.onmessage = (ev: MessageEvent) => {
115
118
  const { id, ok, error, ...rest } = ev.data ?? {};
116
119
  const p = this.pending.get(id);
package/tsdown.config.ts CHANGED
@@ -53,6 +53,19 @@ const versionDefinePlugin = {
53
53
  },
54
54
  };
55
55
 
56
+ // The SQLite worker URL is written as `./sqlite-worker.ts` in source so Vite's
57
+ // src-bundling consumers (the example app aliases core to `src`) resolve it.
58
+ // In the published build the worker is emitted at `dist/sqlite-worker.js`, so
59
+ // rewrite the reference to `.js` here — otherwise the flat `dist/index.js`
60
+ // carries a dangling `.ts` URL that a consumer's bundler can't resolve.
61
+ const sqliteWorkerUrlPlugin = {
62
+ name: 'sp00ky-sqlite-worker-url',
63
+ transform(code: string) {
64
+ if (!code.includes('sqlite-worker.ts')) return null;
65
+ return code.split('sqlite-worker.ts').join('sqlite-worker.js');
66
+ },
67
+ };
68
+
56
69
  export default defineConfig({
57
70
  // `sqlite-worker` is emitted at `dist/sqlite-worker.js` (top level, NOT under
58
71
  // services/database) so the `new URL('./sqlite-worker.js', import.meta.url)`
@@ -68,5 +81,5 @@ export default defineConfig({
68
81
  dts: true,
69
82
  clean: true,
70
83
  hash: false,
71
- plugins: [versionDefinePlugin],
84
+ plugins: [versionDefinePlugin, sqliteWorkerUrlPlugin],
72
85
  });