cry-synced-db-client 0.1.60 → 0.1.61

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
@@ -3311,16 +3311,7 @@ class SyncedDb {
3311
3311
  this.inMemManager.deleteObjectsMetadata(collection, _ids);
3312
3312
  }
3313
3313
  getOrCreateWindowId() {
3314
- const storageKey = `synced-db-window-id-${this.tenant}`;
3315
- if (typeof sessionStorage !== "undefined") {
3316
- let windowId = sessionStorage.getItem(storageKey);
3317
- if (!windowId) {
3318
- windowId = `${Date.now()}-${Math.random().toString(36).slice(2, 9)}`;
3319
- sessionStorage.setItem(storageKey, windowId);
3320
- }
3321
- return windowId;
3322
- }
3323
- return `${Date.now()}-${Math.random().toString(36).slice(2, 9)}`;
3314
+ return `shared-${this.tenant}`;
3324
3315
  }
3325
3316
  assertCollection(name) {
3326
3317
  if (!this.collections.has(name)) {
@@ -81,9 +81,13 @@ export declare class SyncedDb implements I_SyncedDb {
81
81
  deleteObjectMetadata(collection: string, _id: Id): void;
82
82
  deleteObjectsMetadata(collection: string, _ids: Id[]): void;
83
83
  /**
84
- * Get or create a window-scoped ID.
85
- * Persists across page reloads but unique per browser window.
86
- * Used for window-scoped leader election.
84
+ * Get the shared window ID for all tabs in the same origin.
85
+ * All tabs sharing the same BroadcastChannel should use the same windowId
86
+ * so they compete for the same leader lock.
87
+ *
88
+ * Note: "window" here means "group of tabs sharing BroadcastChannel" (same origin),
89
+ * not a physical browser window. sessionStorage is NOT shared between tabs,
90
+ * so we use a constant value to ensure all tabs compete for the same lock.
87
91
  */
88
92
  private getOrCreateWindowId;
89
93
  private assertCollection;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cry-synced-db-client",
3
- "version": "0.1.60",
3
+ "version": "0.1.61",
4
4
  "type": "module",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.js",