@dxos/echo-pipeline 0.6.14-main.f49f251 → 0.6.14-staging.54a8bab

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.
@@ -3111,7 +3111,7 @@ var findInlineObjectOfType = (spaceDoc, typename) => {
3111
3111
  };
3112
3112
 
3113
3113
  // packages/core/echo/echo-pipeline/src/edge/echo-edge-replicator.ts
3114
- import { Mutex, scheduleTask as scheduleTask2 } from "@dxos/async";
3114
+ import { Mutex, scheduleTask as scheduleTask2, scheduleMicroTask } from "@dxos/async";
3115
3115
  import * as A5 from "@dxos/automerge/automerge";
3116
3116
  import { cbor as cbor2 } from "@dxos/automerge/automerge-repo";
3117
3117
  import { Context as Context6, Resource as Resource10 } from "@dxos/context";
@@ -3214,30 +3214,30 @@ var EchoEdgeReplicator = class {
3214
3214
  F: __dxlog_file16,
3215
3215
  L: 63
3216
3216
  });
3217
- this._edgeConnection.reconnect.on(this._ctx, async () => {
3218
- try {
3219
- var _usingCtx = _using_ctx();
3220
- const _guard = _usingCtx.u(await this._mutex.acquire());
3221
- const spaces = [
3222
- ...this._connectedSpaces
3223
- ];
3224
- for (const connection of this._connections.values()) {
3225
- await connection.close();
3226
- }
3227
- this._connections.clear();
3228
- if (this._context !== null) {
3229
- for (const spaceId of spaces) {
3230
- await this._openConnection(spaceId);
3231
- }
3217
+ this._ctx.onDispose(this._edgeConnection.onReconnected(() => {
3218
+ this._ctx && scheduleMicroTask(this._ctx, () => this._handleReconnect());
3219
+ }));
3220
+ }
3221
+ async _handleReconnect() {
3222
+ try {
3223
+ var _usingCtx = _using_ctx();
3224
+ const _guard = _usingCtx.u(await this._mutex.acquire());
3225
+ const spaces = [
3226
+ ...this._connectedSpaces
3227
+ ];
3228
+ for (const connection of this._connections.values()) {
3229
+ await connection.close();
3230
+ }
3231
+ this._connections.clear();
3232
+ if (this._context !== null) {
3233
+ for (const spaceId of spaces) {
3234
+ await this._openConnection(spaceId);
3232
3235
  }
3233
- } catch (_) {
3234
- _usingCtx.e = _;
3235
- } finally {
3236
- _usingCtx.d();
3237
3236
  }
3238
- });
3239
- for (const spaceId of this._connectedSpaces) {
3240
- await this._openConnection(spaceId);
3237
+ } catch (_) {
3238
+ _usingCtx.e = _;
3239
+ } finally {
3240
+ _usingCtx.d();
3241
3241
  }
3242
3242
  }
3243
3243
  async disconnect() {
@@ -3288,7 +3288,7 @@ var EchoEdgeReplicator = class {
3288
3288
  async _openConnection(spaceId, reconnects = 0) {
3289
3289
  invariant12(this._context, void 0, {
3290
3290
  F: __dxlog_file16,
3291
- L: 119,
3291
+ L: 121,
3292
3292
  S: this,
3293
3293
  A: [
3294
3294
  "this._context",
@@ -3297,7 +3297,7 @@ var EchoEdgeReplicator = class {
3297
3297
  });
3298
3298
  invariant12(!this._connections.has(spaceId), void 0, {
3299
3299
  F: __dxlog_file16,
3300
- L: 120,
3300
+ L: 122,
3301
3301
  S: this,
3302
3302
  A: [
3303
3303
  "!this._connections.has(spaceId)",
@@ -3327,7 +3327,7 @@ var EchoEdgeReplicator = class {
3327
3327
  restartDelay
3328
3328
  }, {
3329
3329
  F: __dxlog_file16,
3330
- L: 143,
3330
+ L: 145,
3331
3331
  S: this,
3332
3332
  C: (f, a) => f(...a)
3333
3333
  });
@@ -3385,11 +3385,11 @@ var EdgeReplicatorConnection = class extends Resource10 {
3385
3385
  async _open(ctx) {
3386
3386
  log11("open", void 0, {
3387
3387
  F: __dxlog_file16,
3388
- L: 237,
3388
+ L: 239,
3389
3389
  S: this,
3390
3390
  C: (f, a) => f(...a)
3391
3391
  });
3392
- this._ctx.onDispose(this._edgeConnection.addListener((msg) => {
3392
+ this._ctx.onDispose(this._edgeConnection.onMessage((msg) => {
3393
3393
  this._onMessage(msg);
3394
3394
  }));
3395
3395
  await this._onRemoteConnected();
@@ -3397,7 +3397,7 @@ var EdgeReplicatorConnection = class extends Resource10 {
3397
3397
  async _close() {
3398
3398
  log11("close", void 0, {
3399
3399
  F: __dxlog_file16,
3400
- L: 249,
3400
+ L: 251,
3401
3401
  S: this,
3402
3402
  C: (f, a) => f(...a)
3403
3403
  });
@@ -3407,7 +3407,7 @@ var EdgeReplicatorConnection = class extends Resource10 {
3407
3407
  get peerId() {
3408
3408
  invariant12(this._remotePeerId, "Not connected", {
3409
3409
  F: __dxlog_file16,
3410
- L: 255,
3410
+ L: 257,
3411
3411
  S: this,
3412
3412
  A: [
3413
3413
  "this._remotePeerId",
@@ -3447,7 +3447,7 @@ var EdgeReplicatorConnection = class extends Resource10 {
3447
3447
  };
3448
3448
  }, {
3449
3449
  F: __dxlog_file16,
3450
- L: 286,
3450
+ L: 288,
3451
3451
  S: this,
3452
3452
  C: (f, a) => f(...a)
3453
3453
  });
@@ -3470,7 +3470,7 @@ var EdgeReplicatorConnection = class extends Resource10 {
3470
3470
  documentId: message.documentId
3471
3471
  }, {
3472
3472
  F: __dxlog_file16,
3473
- L: 316,
3473
+ L: 318,
3474
3474
  S: this,
3475
3475
  C: (f, a) => f(...a)
3476
3476
  });