@xnetjs/runtime 0.3.0 → 0.3.1

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.
Files changed (2) hide show
  1. package/dist/index.js +13 -7
  2. package/package.json +10 -10
package/dist/index.js CHANGED
@@ -2283,7 +2283,7 @@ function createSyncManager(config) {
2283
2283
  log2("Connecting to signaling server...");
2284
2284
  connection.connect();
2285
2285
  nodeSyncProvider?.attach(connection);
2286
- for (const provider of shareRoomProviders.values()) provider.attach(connection);
2286
+ for (const entry of shareRoomProviders.values()) entry.provider.attach(connection);
2287
2287
  blobSync?.start();
2288
2288
  const tracked = registry.getTracked();
2289
2289
  log2("Joining rooms for", tracked.length, "tracked nodes");
@@ -2301,7 +2301,7 @@ function createSyncManager(config) {
2301
2301
  });
2302
2302
  blobSync?.stop();
2303
2303
  nodeSyncProvider?.detach();
2304
- for (const provider of shareRoomProviders.values()) provider.detach();
2304
+ for (const entry of shareRoomProviders.values()) entry.provider.detach();
2305
2305
  shareRoomProviders.clear();
2306
2306
  for (const nodeId of Array.from(roomCleanups.keys())) {
2307
2307
  leaveNodeRoom(nodeId);
@@ -2332,15 +2332,21 @@ function createSyncManager(config) {
2332
2332
  leaveNodeRoom(nodeId);
2333
2333
  },
2334
2334
  subscribeShareRoom(room) {
2335
- if (shareRoomProviders.has(room)) return;
2335
+ const existing = shareRoomProviders.get(room);
2336
+ if (existing) {
2337
+ existing.refs += 1;
2338
+ return;
2339
+ }
2336
2340
  const provider = new NodeStoreSyncProvider(config.nodeStore, room, true);
2337
- shareRoomProviders.set(room, provider);
2341
+ shareRoomProviders.set(room, { provider, refs: 1 });
2338
2342
  provider.attach(connection);
2339
2343
  },
2340
2344
  unsubscribeShareRoom(room) {
2341
- const provider = shareRoomProviders.get(room);
2342
- if (!provider) return;
2343
- provider.detach();
2345
+ const entry = shareRoomProviders.get(room);
2346
+ if (!entry) return;
2347
+ entry.refs -= 1;
2348
+ if (entry.refs > 0) return;
2349
+ entry.provider.detach();
2344
2350
  shareRoomProviders.delete(room);
2345
2351
  },
2346
2352
  async acquire(nodeId) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xnetjs/runtime",
3
- "version": "0.3.0",
3
+ "version": "0.3.1",
4
4
  "description": "Framework-agnostic xNet runtime: createXNetClient() and sync orchestration, usable from any framework, a CLI, a worker, or a Node service",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -28,15 +28,15 @@
28
28
  "dependencies": {
29
29
  "y-protocols": "^1.0.6",
30
30
  "yjs": "^13.6.24",
31
- "@xnetjs/core": "0.11.0",
32
- "@xnetjs/data": "0.11.0",
33
- "@xnetjs/crypto": "0.11.0",
34
- "@xnetjs/data-bridge": "0.11.0",
35
- "@xnetjs/history": "0.11.0",
36
- "@xnetjs/identity": "0.11.0",
37
- "@xnetjs/plugins": "0.11.0",
38
- "@xnetjs/storage": "0.11.0",
39
- "@xnetjs/sync": "0.11.0"
31
+ "@xnetjs/core": "0.11.1",
32
+ "@xnetjs/crypto": "0.11.1",
33
+ "@xnetjs/data": "0.11.1",
34
+ "@xnetjs/data-bridge": "0.11.1",
35
+ "@xnetjs/history": "0.11.1",
36
+ "@xnetjs/identity": "0.11.1",
37
+ "@xnetjs/plugins": "0.11.1",
38
+ "@xnetjs/storage": "0.11.1",
39
+ "@xnetjs/sync": "0.11.1"
40
40
  },
41
41
  "devDependencies": {
42
42
  "jsdom": "^26.0.0",