@arcote.tech/arc-adapter-db-sqlite-wasm 0.7.10 → 0.7.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/dist/index.js +31 -0
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -4279,6 +4279,7 @@ class StreamingQueryCache {
|
|
|
4279
4279
|
views = [];
|
|
4280
4280
|
activeStreams = new Map;
|
|
4281
4281
|
pendingUnsubscribes = new Map;
|
|
4282
|
+
streamScopes = new Map;
|
|
4282
4283
|
static UNSUBSCRIBE_DELAY_MS = 5000;
|
|
4283
4284
|
registerViews(views) {
|
|
4284
4285
|
this.views = views;
|
|
@@ -4337,6 +4338,7 @@ class StreamingQueryCache {
|
|
|
4337
4338
|
if (current2 && current2.refCount <= 0) {
|
|
4338
4339
|
current2.unsubscribe();
|
|
4339
4340
|
this.activeStreams.delete(viewName);
|
|
4341
|
+
this.streamScopes.delete(viewName);
|
|
4340
4342
|
}
|
|
4341
4343
|
}, StreamingQueryCache.UNSUBSCRIBE_DELAY_MS);
|
|
4342
4344
|
this.pendingUnsubscribes.set(viewName, timeout);
|
|
@@ -4344,6 +4346,8 @@ class StreamingQueryCache {
|
|
|
4344
4346
|
}
|
|
4345
4347
|
subscribeQuery(descriptor, eventWire, scope) {
|
|
4346
4348
|
const key = descriptor.element;
|
|
4349
|
+
if (scope)
|
|
4350
|
+
this.streamScopes.set(key, scope);
|
|
4347
4351
|
const { unsubscribe } = this.registerStream(key, () => {
|
|
4348
4352
|
const subId = eventWire.subscribeQuery(descriptor, (data) => {
|
|
4349
4353
|
this.setViewData(descriptor.element, data);
|
|
@@ -4352,6 +4356,28 @@ class StreamingQueryCache {
|
|
|
4352
4356
|
});
|
|
4353
4357
|
return unsubscribe;
|
|
4354
4358
|
}
|
|
4359
|
+
invalidateScope(scope) {
|
|
4360
|
+
for (const [viewName, viewScope] of this.streamScopes) {
|
|
4361
|
+
if (viewScope !== scope)
|
|
4362
|
+
continue;
|
|
4363
|
+
const pending = this.pendingUnsubscribes.get(viewName);
|
|
4364
|
+
if (pending) {
|
|
4365
|
+
clearTimeout(pending);
|
|
4366
|
+
this.pendingUnsubscribes.delete(viewName);
|
|
4367
|
+
}
|
|
4368
|
+
const stream = this.activeStreams.get(viewName);
|
|
4369
|
+
if (stream) {
|
|
4370
|
+
try {
|
|
4371
|
+
stream.unsubscribe();
|
|
4372
|
+
} catch {}
|
|
4373
|
+
this.activeStreams.delete(viewName);
|
|
4374
|
+
}
|
|
4375
|
+
this.streamScopes.delete(viewName);
|
|
4376
|
+
const store = this.stores.get(viewName);
|
|
4377
|
+
if (store)
|
|
4378
|
+
store.clear();
|
|
4379
|
+
}
|
|
4380
|
+
}
|
|
4355
4381
|
setViewData(viewName, data) {
|
|
4356
4382
|
const store = this.stores.get(viewName);
|
|
4357
4383
|
if (!store)
|
|
@@ -4399,6 +4425,11 @@ class StreamingQueryCache {
|
|
|
4399
4425
|
stream.unsubscribe();
|
|
4400
4426
|
}
|
|
4401
4427
|
this.activeStreams.clear();
|
|
4428
|
+
this.streamScopes.clear();
|
|
4429
|
+
for (const timeout of this.pendingUnsubscribes.values()) {
|
|
4430
|
+
clearTimeout(timeout);
|
|
4431
|
+
}
|
|
4432
|
+
this.pendingUnsubscribes.clear();
|
|
4402
4433
|
for (const store of this.stores.values()) {
|
|
4403
4434
|
store.clear();
|
|
4404
4435
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@arcote.tech/arc-adapter-db-sqlite-wasm",
|
|
3
|
-
"version": "0.7.
|
|
3
|
+
"version": "0.7.11",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"types": "./dist/index.d.ts",
|
|
@@ -39,7 +39,7 @@
|
|
|
39
39
|
"dev": "bun build ./src/index.ts ./src/worker.ts --outdir ./dist --target browser --format esm --watch"
|
|
40
40
|
},
|
|
41
41
|
"peerDependencies": {
|
|
42
|
-
"@arcote.tech/arc": "^0.7.
|
|
42
|
+
"@arcote.tech/arc": "^0.7.11",
|
|
43
43
|
"@sqlite.org/sqlite-wasm": "^3.46.0-build1"
|
|
44
44
|
},
|
|
45
45
|
"devDependencies": {
|