@dxos/echo-pipeline 0.4.8-main.ac78619 → 0.4.8-main.b987d6b

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.
@@ -2793,11 +2793,9 @@ SpaceManager = _ts_decorate8([
2793
2793
  ], SpaceManager);
2794
2794
 
2795
2795
  // packages/core/echo/echo-pipeline/src/automerge/automerge-storage-adapter.ts
2796
- import { StorageAdapter } from "@dxos/automerge/automerge-repo";
2797
2796
  import { arrayToBuffer as arrayToBuffer2, bufferToArray } from "@dxos/util";
2798
- var AutomergeStorageAdapter = class extends StorageAdapter {
2797
+ var AutomergeStorageAdapter = class {
2799
2798
  constructor(_directory) {
2800
- super();
2801
2799
  this._directory = _directory;
2802
2800
  this._state = "opened";
2803
2801
  }
@@ -3106,7 +3104,7 @@ var MeshNetworkAdapter = class extends NetworkAdapter2 {
3106
3104
  import { next as automerge, getHeads } from "@dxos/automerge/automerge";
3107
3105
  import { Repo } from "@dxos/automerge/automerge-repo";
3108
3106
  import { IndexedDBStorageAdapter } from "@dxos/automerge/automerge-repo-storage-indexeddb";
3109
- import { Context as Context7, cancelWithContext as cancelWithContext2 } from "@dxos/context";
3107
+ import { Context as Context7 } from "@dxos/context";
3110
3108
  import { PublicKey as PublicKey8 } from "@dxos/keys";
3111
3109
  import { log as log15 } from "@dxos/log";
3112
3110
  import { idCodec } from "@dxos/protocols";
@@ -3210,21 +3208,20 @@ var AutomergeHost = class {
3210
3208
  return isRequested;
3211
3209
  }
3212
3210
  try {
3213
- const rawSpaceKey = doc.access?.spaceKey ?? doc.experimental_spaceKey;
3214
- if (!rawSpaceKey) {
3211
+ const spaceKey = getSpaceKeyFromDoc(doc);
3212
+ if (!spaceKey) {
3215
3213
  log15("space key not found for share policy check", {
3216
3214
  peerId,
3217
3215
  documentId
3218
3216
  }, {
3219
3217
  F: __dxlog_file16,
3220
- L: 104,
3218
+ L: 103,
3221
3219
  S: this,
3222
3220
  C: (f, a) => f(...a)
3223
3221
  });
3224
3222
  return false;
3225
3223
  }
3226
- const spaceKey = PublicKey8.from(rawSpaceKey);
3227
- const authorizedDevices = this._authorizedDevices.get(spaceKey);
3224
+ const authorizedDevices = this._authorizedDevices.get(PublicKey8.from(spaceKey));
3228
3225
  const deviceKeyHex = this.repo.peerMetadataByPeerId[peerId]?.dxos_deviceKey;
3229
3226
  if (!deviceKeyHex) {
3230
3227
  log15("device key not found for share policy check", {
@@ -3232,7 +3229,7 @@ var AutomergeHost = class {
3232
3229
  documentId
3233
3230
  }, {
3234
3231
  F: __dxlog_file16,
3235
- L: 114,
3232
+ L: 112,
3236
3233
  S: this,
3237
3234
  C: (f, a) => f(...a)
3238
3235
  });
@@ -3249,7 +3246,7 @@ var AutomergeHost = class {
3249
3246
  isAuthorized
3250
3247
  }, {
3251
3248
  F: __dxlog_file16,
3252
- L: 120,
3249
+ L: 118,
3253
3250
  S: this,
3254
3251
  C: (f, a) => f(...a)
3255
3252
  });
@@ -3257,7 +3254,7 @@ var AutomergeHost = class {
3257
3254
  } catch (err) {
3258
3255
  log15.catch(err, void 0, {
3259
3256
  F: __dxlog_file16,
3260
- L: 130,
3257
+ L: 128,
3261
3258
  S: this,
3262
3259
  C: (f, a) => f(...a)
3263
3260
  });
@@ -3292,8 +3289,7 @@ var AutomergeHost = class {
3292
3289
  });
3293
3290
  }
3294
3291
  _onUpdate(event) {
3295
- const spaceKey = event.doc.access?.spaceKey;
3296
- if (!spaceKey) {
3292
+ if (this._metadata == null) {
3297
3293
  return;
3298
3294
  }
3299
3295
  const objectIds = getInlineChanges(event);
@@ -3305,17 +3301,20 @@ var AutomergeHost = class {
3305
3301
  if (!lastAvailableHash) {
3306
3302
  return;
3307
3303
  }
3308
- const markingDirtyPromise = Promise.all(objectIds.map(async (objectId) => {
3309
- await cancelWithContext2(this._ctx, this._metadata.markDirty(idCodec.encode({
3310
- documentId: event.handle.documentId,
3311
- objectId
3312
- }), lastAvailableHash));
3313
- })).then(() => {
3304
+ const encodedIds = objectIds.map((objectId) => idCodec.encode({
3305
+ documentId: event.handle.documentId,
3306
+ objectId
3307
+ }));
3308
+ const idToLastHash = new Map(encodedIds.map((id) => [
3309
+ id,
3310
+ lastAvailableHash
3311
+ ]));
3312
+ const markingDirtyPromise = this._metadata.markDirty(idToLastHash).then(() => {
3314
3313
  this._updatingMetadata.delete(event.handle.documentId);
3315
3314
  }).catch((err) => {
3316
- !this._ctx.disposed && log15.catch(err, void 0, {
3315
+ this._ctx.disposed && log15.catch(err, void 0, {
3317
3316
  F: __dxlog_file16,
3318
- L: 198,
3317
+ L: 188,
3319
3318
  S: this,
3320
3319
  C: (f, a) => f(...a)
3321
3320
  });
@@ -3376,7 +3375,7 @@ var AutomergeHost = class {
3376
3375
  deviceKey
3377
3376
  }, {
3378
3377
  F: __dxlog_file16,
3379
- L: 266,
3378
+ L: 255,
3380
3379
  S: this,
3381
3380
  C: (f, a) => f(...a)
3382
3381
  });
@@ -3417,6 +3416,13 @@ var getInlineChanges = (event) => {
3417
3416
  ...inlineChangedObjectIds
3418
3417
  ];
3419
3418
  };
3419
+ var getSpaceKeyFromDoc = (doc) => {
3420
+ const rawSpaceKey = doc.access?.spaceKey ?? doc.experimental_spaceKey;
3421
+ if (rawSpaceKey == null) {
3422
+ return null;
3423
+ }
3424
+ return String(rawSpaceKey);
3425
+ };
3420
3426
 
3421
3427
  export {
3422
3428
  codec,
@@ -3446,6 +3452,7 @@ export {
3446
3452
  AutomergeStorageAdapter,
3447
3453
  LocalHostNetworkAdapter,
3448
3454
  MeshNetworkAdapter,
3449
- AutomergeHost
3455
+ AutomergeHost,
3456
+ getSpaceKeyFromDoc
3450
3457
  };
3451
- //# sourceMappingURL=chunk-LED7X4WK.mjs.map
3458
+ //# sourceMappingURL=chunk-3FVT6KX6.mjs.map