@abraca/dabra 1.0.9 → 1.0.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.
@@ -1733,14 +1733,17 @@ var AbracadabraWS = class extends EventEmitter {
1733
1733
  this.receivedOnOpenPayload = event;
1734
1734
  }
1735
1735
  attach(provider) {
1736
+ const existing = this.configuration.providerMap.get(provider.configuration.name);
1737
+ if (existing && existing !== provider) console.warn(`[AbracadabraWS] attach: overwriting provider for "${provider.configuration.name}". This may indicate a duplicate loadChild for the same document.`);
1736
1738
  this.configuration.providerMap.set(provider.configuration.name, provider);
1737
1739
  if (this.status === WebSocketStatus.Disconnected && this.shouldConnect) this.connect();
1738
1740
  if (this.receivedOnOpenPayload && this.status === WebSocketStatus.Connected) provider.onOpen(this.receivedOnOpenPayload);
1739
1741
  }
1740
1742
  detach(provider) {
1741
- if (this.configuration.providerMap.has(provider.configuration.name)) {
1742
- provider.send(CloseMessage, { documentName: provider.configuration.name });
1743
- this.configuration.providerMap.delete(provider.configuration.name);
1743
+ const name = provider.configuration.name;
1744
+ if (this.configuration.providerMap.get(name) === provider) {
1745
+ provider.send(CloseMessage, { documentName: name });
1746
+ this.configuration.providerMap.delete(name);
1744
1747
  }
1745
1748
  }
1746
1749
  setConfiguration(configuration = {}) {
@@ -3260,6 +3263,20 @@ var AbracadabraClient = class {
3260
3263
  if (this.cache) await this.cache.setPermissions(docId, res.permissions).catch(() => null);
3261
3264
  return res.permissions;
3262
3265
  }
3266
+ /** List effective permissions including inherited ones from ancestor documents. */
3267
+ async listEffectivePermissions(docId) {
3268
+ try {
3269
+ return await this.request("GET", `/docs/${encodeURIComponent(docId)}/effective-permissions`);
3270
+ } catch {
3271
+ return {
3272
+ permissions: (await this.listPermissions(docId)).map((p) => ({
3273
+ ...p,
3274
+ source: "direct"
3275
+ })),
3276
+ default_role: "viewer"
3277
+ };
3278
+ }
3279
+ }
3263
3280
  /** Grant or change a user's role on a document (requires Owner). */
3264
3281
  async setPermission(docId, opts) {
3265
3282
  await this.request("POST", `/docs/${encodeURIComponent(docId)}/permissions`, { body: opts });
@@ -7486,7 +7503,7 @@ var FileBlobStore = class extends EventEmitter {
7486
7503
  this.objectUrls = /* @__PURE__ */ new Map();
7487
7504
  this._flushing = false;
7488
7505
  this.origin = serverOrigin;
7489
- this.client = client;
7506
+ this.client = client ?? null;
7490
7507
  this._onlineHandler = () => {
7491
7508
  this.flushQueue().catch(() => null);
7492
7509
  };
@@ -7524,6 +7541,7 @@ var FileBlobStore = class extends EventEmitter {
7524
7541
  return url;
7525
7542
  }
7526
7543
  }
7544
+ if (!this.client) return null;
7527
7545
  let blob;
7528
7546
  try {
7529
7547
  blob = await this.client.getUpload(docId, uploadId);
@@ -7619,7 +7637,7 @@ var FileBlobStore = class extends EventEmitter {
7619
7637
  * Entries that fail are marked with status "error" and left in the queue.
7620
7638
  */
7621
7639
  async flushQueue() {
7622
- if (this._flushing) return;
7640
+ if (this._flushing || !this.client) return;
7623
7641
  this._flushing = true;
7624
7642
  try {
7625
7643
  const pending = (await this.getQueue()).filter((e) => e.status === "pending");