@dxos/echo-pipeline 0.6.13 → 0.6.14-main.69511f5

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 (129) hide show
  1. package/dist/lib/browser/{chunk-UKXIJW43.mjs → chunk-RRKGEIVZ.mjs} +102 -52
  2. package/dist/lib/browser/chunk-RRKGEIVZ.mjs.map +7 -0
  3. package/dist/lib/browser/index.mjs +3476 -17
  4. package/dist/lib/browser/index.mjs.map +4 -4
  5. package/dist/lib/browser/meta.json +1 -1
  6. package/dist/lib/browser/testing/index.mjs +17 -7
  7. package/dist/lib/browser/testing/index.mjs.map +3 -3
  8. package/dist/lib/node/{chunk-7HHYCGUR.cjs → chunk-6KAVD3GU.cjs} +116 -64
  9. package/dist/lib/node/chunk-6KAVD3GU.cjs.map +7 -0
  10. package/dist/lib/node/index.cjs +3454 -35
  11. package/dist/lib/node/index.cjs.map +4 -4
  12. package/dist/lib/node/meta.json +1 -1
  13. package/dist/lib/node/testing/index.cjs +25 -15
  14. package/dist/lib/node/testing/index.cjs.map +3 -3
  15. package/dist/lib/node-esm/chunk-4QES5F4H.mjs +2052 -0
  16. package/dist/lib/node-esm/chunk-4QES5F4H.mjs.map +7 -0
  17. package/dist/lib/{browser/chunk-MPWFDDQK.mjs → node-esm/index.mjs} +1723 -342
  18. package/dist/lib/node-esm/index.mjs.map +7 -0
  19. package/dist/lib/node-esm/meta.json +1 -0
  20. package/dist/lib/node-esm/testing/index.mjs +562 -0
  21. package/dist/lib/node-esm/testing/index.mjs.map +7 -0
  22. package/dist/types/src/automerge/automerge-host.d.ts +24 -1
  23. package/dist/types/src/automerge/automerge-host.d.ts.map +1 -1
  24. package/dist/types/src/automerge/collection-synchronizer.d.ts +2 -0
  25. package/dist/types/src/automerge/collection-synchronizer.d.ts.map +1 -1
  26. package/dist/types/src/automerge/echo-network-adapter.d.ts.map +1 -1
  27. package/dist/types/src/automerge/echo-replicator.d.ts +3 -3
  28. package/dist/types/src/automerge/echo-replicator.d.ts.map +1 -1
  29. package/dist/types/src/automerge/mesh-echo-replicator-connection.d.ts +3 -3
  30. package/dist/types/src/automerge/mesh-echo-replicator-connection.d.ts.map +1 -1
  31. package/dist/types/src/automerge/mesh-echo-replicator.d.ts.map +1 -1
  32. package/dist/types/src/automerge/space-collection.d.ts +3 -2
  33. package/dist/types/src/automerge/space-collection.d.ts.map +1 -1
  34. package/dist/types/src/db-host/automerge-metrics.d.ts +11 -0
  35. package/dist/types/src/db-host/automerge-metrics.d.ts.map +1 -0
  36. package/dist/types/src/db-host/data-service.d.ts +3 -2
  37. package/dist/types/src/db-host/data-service.d.ts.map +1 -1
  38. package/dist/types/src/db-host/database-root.d.ts +20 -0
  39. package/dist/types/src/db-host/database-root.d.ts.map +1 -0
  40. package/dist/types/src/db-host/documents-iterator.d.ts +7 -0
  41. package/dist/types/src/db-host/documents-iterator.d.ts.map +1 -0
  42. package/dist/types/src/db-host/echo-host.d.ts +73 -0
  43. package/dist/types/src/db-host/echo-host.d.ts.map +1 -0
  44. package/dist/types/src/db-host/index.d.ts +5 -0
  45. package/dist/types/src/db-host/index.d.ts.map +1 -1
  46. package/dist/types/src/db-host/migration.d.ts +8 -0
  47. package/dist/types/src/db-host/migration.d.ts.map +1 -0
  48. package/dist/types/src/db-host/query-service.d.ts +25 -0
  49. package/dist/types/src/db-host/query-service.d.ts.map +1 -0
  50. package/dist/types/src/db-host/query-state.d.ts +41 -0
  51. package/dist/types/src/db-host/query-state.d.ts.map +1 -0
  52. package/dist/types/src/db-host/space-state-manager.d.ts +23 -0
  53. package/dist/types/src/db-host/space-state-manager.d.ts.map +1 -0
  54. package/dist/types/src/edge/echo-edge-replicator.d.ts +23 -0
  55. package/dist/types/src/edge/echo-edge-replicator.d.ts.map +1 -0
  56. package/dist/types/src/edge/echo-edge-replicator.test.d.ts +2 -0
  57. package/dist/types/src/edge/echo-edge-replicator.test.d.ts.map +1 -0
  58. package/dist/types/src/edge/index.d.ts +2 -0
  59. package/dist/types/src/edge/index.d.ts.map +1 -0
  60. package/dist/types/src/index.d.ts +1 -0
  61. package/dist/types/src/index.d.ts.map +1 -1
  62. package/dist/types/src/metadata/metadata-store.d.ts +4 -1
  63. package/dist/types/src/metadata/metadata-store.d.ts.map +1 -1
  64. package/dist/types/src/space/space-protocol.d.ts.map +1 -1
  65. package/dist/types/src/space/space.d.ts +1 -0
  66. package/dist/types/src/space/space.d.ts.map +1 -1
  67. package/dist/types/src/testing/test-agent-builder.d.ts +2 -0
  68. package/dist/types/src/testing/test-agent-builder.d.ts.map +1 -1
  69. package/dist/types/src/testing/test-replicator.d.ts +4 -4
  70. package/dist/types/src/testing/test-replicator.d.ts.map +1 -1
  71. package/package.json +41 -56
  72. package/src/automerge/automerge-host.test.ts +8 -9
  73. package/src/automerge/automerge-host.ts +46 -7
  74. package/src/automerge/automerge-repo.test.ts +18 -16
  75. package/src/automerge/collection-synchronizer.test.ts +10 -5
  76. package/src/automerge/collection-synchronizer.ts +17 -6
  77. package/src/automerge/echo-data-monitor.test.ts +1 -3
  78. package/src/automerge/echo-network-adapter.test.ts +4 -3
  79. package/src/automerge/echo-network-adapter.ts +5 -4
  80. package/src/automerge/echo-replicator.ts +3 -3
  81. package/src/automerge/mesh-echo-replicator-connection.ts +10 -9
  82. package/src/automerge/mesh-echo-replicator.ts +2 -1
  83. package/src/automerge/space-collection.ts +3 -2
  84. package/src/automerge/storage-adapter.test.ts +2 -3
  85. package/src/db-host/automerge-metrics.ts +38 -0
  86. package/src/db-host/data-service.ts +29 -14
  87. package/src/db-host/database-root.ts +87 -0
  88. package/src/db-host/documents-iterator.ts +73 -0
  89. package/src/db-host/documents-synchronizer.test.ts +2 -2
  90. package/src/db-host/echo-host.ts +257 -0
  91. package/src/db-host/index.ts +6 -1
  92. package/src/db-host/migration.ts +57 -0
  93. package/src/db-host/query-service.ts +209 -0
  94. package/src/db-host/query-state.ts +214 -0
  95. package/src/db-host/space-state-manager.ts +90 -0
  96. package/src/edge/echo-edge-replicator.test.ts +96 -0
  97. package/src/edge/echo-edge-replicator.ts +341 -0
  98. package/src/edge/index.ts +5 -0
  99. package/src/index.ts +1 -0
  100. package/src/metadata/metadata-store.ts +22 -2
  101. package/src/pipeline/pipeline-stress.test.ts +44 -47
  102. package/src/pipeline/pipeline.test.ts +3 -4
  103. package/src/space/control-pipeline.test.ts +2 -3
  104. package/src/space/control-pipeline.ts +10 -1
  105. package/src/space/replication.browser.test.ts +2 -8
  106. package/src/space/space-manager.browser.test.ts +6 -5
  107. package/src/space/space-protocol.browser.test.ts +29 -34
  108. package/src/space/space-protocol.test.ts +37 -27
  109. package/src/space/space-protocol.ts +0 -4
  110. package/src/space/space.test.ts +30 -11
  111. package/src/space/space.ts +7 -2
  112. package/src/testing/test-agent-builder.ts +16 -4
  113. package/src/testing/test-replicator.ts +3 -3
  114. package/dist/lib/browser/chunk-MPWFDDQK.mjs.map +0 -7
  115. package/dist/lib/browser/chunk-UKXIJW43.mjs.map +0 -7
  116. package/dist/lib/browser/chunk-XPCF2V5U.mjs +0 -31
  117. package/dist/lib/browser/chunk-XPCF2V5U.mjs.map +0 -7
  118. package/dist/lib/browser/light.mjs +0 -32
  119. package/dist/lib/browser/light.mjs.map +0 -7
  120. package/dist/lib/node/chunk-5DH4KR2S.cjs +0 -2148
  121. package/dist/lib/node/chunk-5DH4KR2S.cjs.map +0 -7
  122. package/dist/lib/node/chunk-7HHYCGUR.cjs.map +0 -7
  123. package/dist/lib/node/chunk-DZVH7HDD.cjs +0 -43
  124. package/dist/lib/node/chunk-DZVH7HDD.cjs.map +0 -7
  125. package/dist/lib/node/light.cjs +0 -52
  126. package/dist/lib/node/light.cjs.map +0 -7
  127. package/dist/types/src/light.d.ts +0 -4
  128. package/dist/types/src/light.d.ts.map +0 -1
  129. package/src/light.ts +0 -7
@@ -1,8 +1,4 @@
1
1
  import "@dxos/node-std/globals";
2
- import {
3
- Buffer,
4
- createIdFromSpaceKey
5
- } from "./chunk-XPCF2V5U.mjs";
6
2
 
7
3
  // packages/core/echo/echo-pipeline/src/common/codec.ts
8
4
  import { createCodecEncoding } from "@dxos/hypercore";
@@ -37,17 +33,34 @@ var createMappedFeedWriter = (mapper, writer) => {
37
33
  };
38
34
  };
39
35
 
36
+ // packages/core/echo/echo-pipeline/src/common/space-id.ts
37
+ import { subtleCrypto } from "@dxos/crypto";
38
+ import { PublicKey, SpaceId } from "@dxos/keys";
39
+ import { ComplexMap } from "@dxos/util";
40
+ var SPACE_IDS_CACHE = new ComplexMap(PublicKey.hash);
41
+ var createIdFromSpaceKey = async (spaceKey) => {
42
+ const cachedValue = SPACE_IDS_CACHE.get(spaceKey);
43
+ if (cachedValue !== void 0) {
44
+ return cachedValue;
45
+ }
46
+ const digest = await subtleCrypto.digest("SHA-256", spaceKey.asUint8Array());
47
+ const bytes = new Uint8Array(digest).slice(0, SpaceId.byteLength);
48
+ const spaceId = SpaceId.encode(bytes);
49
+ SPACE_IDS_CACHE.set(spaceKey, spaceId);
50
+ return spaceId;
51
+ };
52
+
40
53
  // packages/core/echo/echo-pipeline/src/metadata/metadata-store.ts
41
54
  import CRC32 from "crc-32";
42
55
  import { Event, scheduleTaskInterval, synchronized } from "@dxos/async";
43
56
  import { Context } from "@dxos/context";
44
57
  import { invariant as invariant2 } from "@dxos/invariant";
45
- import { PublicKey } from "@dxos/keys";
58
+ import { PublicKey as PublicKey2 } from "@dxos/keys";
46
59
  import { log } from "@dxos/log";
47
60
  import { DataCorruptionError, STORAGE_VERSION } from "@dxos/protocols";
48
61
  import { schema as schema2 } from "@dxos/protocols/proto";
49
62
  import { Invitation, SpaceState } from "@dxos/protocols/proto/dxos/client/services";
50
- import { ComplexMap, arrayToBuffer, forEachAsync, isNotNullOrUndefined } from "@dxos/util";
63
+ import { ComplexMap as ComplexMap2, arrayToBuffer, forEachAsync, isNotNullOrUndefined } from "@dxos/util";
51
64
  function _ts_decorate(decorators, target, key, desc) {
52
65
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
53
66
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
@@ -68,12 +81,12 @@ var LargeSpaceMetadata = schema2.getCodecForType("dxos.echo.metadata.LargeSpaceM
68
81
  var MetadataStore = class {
69
82
  constructor(directory) {
70
83
  this._metadata = emptyEchoMetadata();
71
- this._spaceLargeMetadata = new ComplexMap(PublicKey.hash);
84
+ this._spaceLargeMetadata = new ComplexMap2(PublicKey2.hash);
72
85
  this._metadataFile = void 0;
73
86
  this.update = new Event();
74
87
  this._invitationCleanupCtx = new Context(void 0, {
75
88
  F: __dxlog_file2,
76
- L: 54
89
+ L: 55
77
90
  });
78
91
  this._directory = directory;
79
92
  }
@@ -104,7 +117,7 @@ var MetadataStore = class {
104
117
  name: file.filename
105
118
  }, {
106
119
  F: __dxlog_file2,
107
- L: 90,
120
+ L: 91,
108
121
  S: this,
109
122
  C: (f, a) => f(...a)
110
123
  });
@@ -140,7 +153,7 @@ var MetadataStore = class {
140
153
  checksum
141
154
  }, {
142
155
  F: __dxlog_file2,
143
- L: 125,
156
+ L: 126,
144
157
  S: this,
145
158
  C: (f, a) => f(...a)
146
159
  });
@@ -173,7 +186,7 @@ var MetadataStore = class {
173
186
  err
174
187
  }, {
175
188
  F: __dxlog_file2,
176
- L: 157,
189
+ L: 158,
177
190
  S: this,
178
191
  C: (f, a) => f(...a)
179
192
  });
@@ -190,7 +203,7 @@ var MetadataStore = class {
190
203
  err
191
204
  }, {
192
205
  F: __dxlog_file2,
193
- L: 169,
206
+ L: 170,
194
207
  S: this,
195
208
  C: (f, a) => f(...a)
196
209
  });
@@ -227,7 +240,7 @@ var MetadataStore = class {
227
240
  err
228
241
  }, {
229
242
  F: __dxlog_file2,
230
- L: 211,
243
+ L: 212,
231
244
  S: this,
232
245
  C: (f, a) => f(...a)
233
246
  });
@@ -245,10 +258,10 @@ var MetadataStore = class {
245
258
  if (this._metadata.identity?.haloSpace.key.equals(spaceKey)) {
246
259
  return this._metadata.identity.haloSpace;
247
260
  }
248
- const space = this.spaces.find((space2) => space2.key === spaceKey);
261
+ const space = this.spaces.find((space2) => space2.key.equals(spaceKey));
249
262
  invariant2(space, "Space not found", {
250
263
  F: __dxlog_file2,
251
- L: 233,
264
+ L: 234,
252
265
  S: this,
253
266
  A: [
254
267
  "space",
@@ -257,6 +270,12 @@ var MetadataStore = class {
257
270
  });
258
271
  return space;
259
272
  }
273
+ hasSpace(spaceKey) {
274
+ if (this._metadata.identity?.haloSpace.key.equals(spaceKey)) {
275
+ return true;
276
+ }
277
+ return !!this.spaces.find((space) => space.key.equals(spaceKey));
278
+ }
260
279
  _getLargeSpaceMetadata(key) {
261
280
  let entry = this._spaceLargeMetadata.get(key);
262
281
  if (entry) {
@@ -272,7 +291,7 @@ var MetadataStore = class {
272
291
  async clear() {
273
292
  log("clearing all metadata", void 0, {
274
293
  F: __dxlog_file2,
275
- L: 252,
294
+ L: 262,
276
295
  S: this,
277
296
  C: (f, a) => f(...a)
278
297
  });
@@ -285,7 +304,7 @@ var MetadataStore = class {
285
304
  async setIdentityRecord(record) {
286
305
  invariant2(!this._metadata.identity, "Cannot overwrite existing identity in metadata", {
287
306
  F: __dxlog_file2,
288
- L: 262,
307
+ L: 272,
289
308
  S: this,
290
309
  A: [
291
310
  "!this._metadata.identity",
@@ -313,12 +332,12 @@ var MetadataStore = class {
313
332
  await this.flush();
314
333
  }
315
334
  async addSpace(record) {
316
- invariant2(!(this._metadata.spaces ?? []).find((space) => space.key === record.key), "Cannot overwrite existing space in metadata", {
335
+ invariant2(!(this._metadata.spaces ?? []).find((space) => space.key.equals(record.key)), "Cannot overwrite existing space in metadata", {
317
336
  F: __dxlog_file2,
318
- L: 290,
337
+ L: 300,
319
338
  S: this,
320
339
  A: [
321
- "!(this._metadata.spaces ?? []).find((space) => space.key === record.key)",
340
+ "!(this._metadata.spaces ?? []).find((space) => space.key.equals(record.key))",
322
341
  "'Cannot overwrite existing space in metadata'"
323
342
  ]
324
343
  });
@@ -359,6 +378,14 @@ var MetadataStore = class {
359
378
  await this._saveSpaceLargeMetadata(spaceKey);
360
379
  await this.flush();
361
380
  }
381
+ getSpaceEdgeReplicationSetting(spaceKey) {
382
+ return this.hasSpace(spaceKey) ? this._getSpace(spaceKey).edgeReplication : void 0;
383
+ }
384
+ async setSpaceEdgeReplicationSetting(spaceKey, setting) {
385
+ this._getSpace(spaceKey).edgeReplication = setting;
386
+ await this._save();
387
+ await this.flush();
388
+ }
362
389
  };
363
390
  _ts_decorate([
364
391
  synchronized
@@ -476,10 +503,10 @@ import { Context as Context2, rejectOnDispose } from "@dxos/context";
476
503
  import { failUndefined } from "@dxos/debug";
477
504
  import { FeedSetIterator } from "@dxos/feed-store";
478
505
  import { invariant as invariant4 } from "@dxos/invariant";
479
- import { PublicKey as PublicKey2 } from "@dxos/keys";
506
+ import { PublicKey as PublicKey3 } from "@dxos/keys";
480
507
  import { log as log4 } from "@dxos/log";
481
508
  import { Timeframe as Timeframe2 } from "@dxos/timeframe";
482
- import { ComplexMap as ComplexMap2 } from "@dxos/util";
509
+ import { ComplexMap as ComplexMap3 } from "@dxos/util";
483
510
 
484
511
  // packages/core/echo/echo-pipeline/src/pipeline/message-selector.ts
485
512
  import { invariant as invariant3 } from "@dxos/invariant";
@@ -630,14 +657,14 @@ var PipelineState = class {
630
657
  var Pipeline = class {
631
658
  constructor() {
632
659
  this._timeframeClock = new TimeframeClock(new Timeframe2());
633
- this._feeds = new ComplexMap2(PublicKey2.hash);
660
+ this._feeds = new ComplexMap3(PublicKey3.hash);
634
661
  // External state accessor.
635
662
  this._state = new PipelineState(this._feeds, this._timeframeClock);
636
663
  // Waits for the message consumer to process the message and yield control back to the pipeline.
637
664
  this._processingTrigger = new Trigger().wake();
638
665
  this._pauseTrigger = new Trigger().wake();
639
666
  // Pending downloads.
640
- this._downloads = new ComplexMap2((value) => PublicKey2.hash(value.key));
667
+ this._downloads = new ComplexMap3((value) => PublicKey3.hash(value.key));
641
668
  this._isStopping = false;
642
669
  this._isStarted = false;
643
670
  this._isBeingConsumed = false;
@@ -853,7 +880,7 @@ var Pipeline = class {
853
880
  if (!done) {
854
881
  const block = value ?? failUndefined();
855
882
  this._processingTrigger.reset();
856
- this._timeframeClock.updatePendingTimeframe(PublicKey2.from(block.feedKey), block.seq);
883
+ this._timeframeClock.updatePendingTimeframe(PublicKey3.from(block.feedKey), block.seq);
857
884
  yield block;
858
885
  this._processingTrigger.wake();
859
886
  this._timeframeClock.updateTimeframe();
@@ -1054,7 +1081,7 @@ import { Callback as Callback2 } from "@dxos/util";
1054
1081
  import { DeferredTask, sleepWithContext as sleepWithContext2, trackLeaks } from "@dxos/async";
1055
1082
  import { Context as Context4 } from "@dxos/context";
1056
1083
  import { SpaceStateMachine } from "@dxos/credentials";
1057
- import { PublicKey as PublicKey3 } from "@dxos/keys";
1084
+ import { PublicKey as PublicKey4 } from "@dxos/keys";
1058
1085
  import { log as log6 } from "@dxos/log";
1059
1086
  import { AdmittedFeed } from "@dxos/protocols/proto/dxos/halo/credentials";
1060
1087
  import { Timeframe as Timeframe3 } from "@dxos/timeframe";
@@ -1198,7 +1225,7 @@ var ControlPipeline = class {
1198
1225
  await this._pipeline.unpause();
1199
1226
  log6("save snapshot", {
1200
1227
  key: this._spaceKey,
1201
- snapshot
1228
+ snapshot: getSnapshotLoggerContext(snapshot)
1202
1229
  }, {
1203
1230
  F: __dxlog_file7,
1204
1231
  L: 163,
@@ -1237,7 +1264,7 @@ var ControlPipeline = class {
1237
1264
  if (msg.data.payload.credential) {
1238
1265
  const timer = tracer.mark("dxos.echo.pipeline.control");
1239
1266
  const result = await this._spaceStateMachine.process(msg.data.payload.credential.credential, {
1240
- sourceFeed: PublicKey3.from(msg.feedKey)
1267
+ sourceFeed: PublicKey4.from(msg.feedKey)
1241
1268
  });
1242
1269
  timer.end();
1243
1270
  if (!result) {
@@ -1314,6 +1341,18 @@ ControlPipeline = _ts_decorate4([
1314
1341
  trace.resource(),
1315
1342
  trackLeaks("start", "stop")
1316
1343
  ], ControlPipeline);
1344
+ var getSnapshotLoggerContext = (snapshot) => {
1345
+ return snapshot.messages?.map((msg) => {
1346
+ const issuer = msg.credential.issuer;
1347
+ const subject = msg.credential.subject.id;
1348
+ const type = msg.credential.subject.assertion["@type"];
1349
+ return {
1350
+ issuer,
1351
+ subject,
1352
+ type
1353
+ };
1354
+ });
1355
+ };
1317
1356
 
1318
1357
  // packages/core/echo/echo-pipeline/src/space/space.ts
1319
1358
  function _ts_decorate5(decorators, target, key, desc) {
@@ -1472,21 +1511,32 @@ var Space = class extends Resource {
1472
1511
  C: (f, a) => f(...a)
1473
1512
  });
1474
1513
  await this._controlPipeline.start();
1475
- await this.protocol.start();
1476
- await this.protocol.addFeed(await this._feedProvider(this._genesisFeedKey));
1477
1514
  log7("opened", void 0, {
1478
1515
  F: __dxlog_file8,
1479
- L: 182,
1516
+ L: 180,
1480
1517
  S: this,
1481
1518
  C: (f, a) => f(...a)
1482
1519
  });
1483
1520
  }
1521
+ async startProtocol() {
1522
+ invariant6(this.isOpen, void 0, {
1523
+ F: __dxlog_file8,
1524
+ L: 185,
1525
+ S: this,
1526
+ A: [
1527
+ "this.isOpen",
1528
+ ""
1529
+ ]
1530
+ });
1531
+ await this.protocol.start();
1532
+ await this.protocol.addFeed(await this._feedProvider(this._genesisFeedKey));
1533
+ }
1484
1534
  async _close() {
1485
1535
  log7("closing...", {
1486
1536
  key: this._key
1487
1537
  }, {
1488
1538
  F: __dxlog_file8,
1489
- L: 187,
1539
+ L: 192,
1490
1540
  S: this,
1491
1541
  C: (f, a) => f(...a)
1492
1542
  });
@@ -1494,7 +1544,7 @@ var Space = class extends Resource {
1494
1544
  await this._controlPipeline.stop();
1495
1545
  log7("closed", void 0, {
1496
1546
  F: __dxlog_file8,
1497
- L: 193,
1547
+ L: 198,
1498
1548
  S: this,
1499
1549
  C: (f, a) => f(...a)
1500
1550
  });
@@ -1517,6 +1567,9 @@ _ts_decorate5([
1517
1567
  _ts_decorate5([
1518
1568
  trace2.span()
1519
1569
  ], Space.prototype, "_open", null);
1570
+ _ts_decorate5([
1571
+ synchronized3
1572
+ ], Space.prototype, "startProtocol", null);
1520
1573
  _ts_decorate5([
1521
1574
  synchronized3
1522
1575
  ], Space.prototype, "_close", null);
@@ -1594,15 +1647,15 @@ var CredentialServerExtension = class extends RpcExtension2 {
1594
1647
  };
1595
1648
 
1596
1649
  // packages/core/echo/echo-pipeline/src/space/space-protocol.ts
1597
- import { discoveryKey, subtleCrypto } from "@dxos/crypto";
1598
- import { PublicKey as PublicKey4 } from "@dxos/keys";
1650
+ import { discoveryKey, subtleCrypto as subtleCrypto2 } from "@dxos/crypto";
1651
+ import { PublicKey as PublicKey5 } from "@dxos/keys";
1599
1652
  import { log as log8, logInfo as logInfo2 } from "@dxos/log";
1600
1653
  import { MMSTTopology } from "@dxos/network-manager";
1601
1654
  import { Teleport } from "@dxos/teleport";
1602
1655
  import { BlobSync } from "@dxos/teleport-extension-object-sync";
1603
1656
  import { ReplicatorExtension } from "@dxos/teleport-extension-replicator";
1604
1657
  import { trace as trace3 } from "@dxos/tracing";
1605
- import { CallbackCollection, ComplexMap as ComplexMap3 } from "@dxos/util";
1658
+ import { CallbackCollection, ComplexMap as ComplexMap4 } from "@dxos/util";
1606
1659
  function _ts_decorate6(decorators, target, key, desc) {
1607
1660
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
1608
1661
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
@@ -1615,7 +1668,7 @@ var MOCK_AUTH_VERIFIER = async (nonce, credential) => true;
1615
1668
  var SpaceProtocol = class {
1616
1669
  constructor({ topic, swarmIdentity, networkManager, onSessionAuth, onAuthFailure, blobStore, disableP2pReplication }) {
1617
1670
  this._feeds = /* @__PURE__ */ new Set();
1618
- this._sessions = new ComplexMap3(PublicKey4.hash);
1671
+ this._sessions = new ComplexMap4(PublicKey5.hash);
1619
1672
  // TODO(burdon): Move to config (with sensible defaults).
1620
1673
  this._topology = new MMSTTopology({
1621
1674
  originateConnections: 4,
@@ -1631,7 +1684,7 @@ var SpaceProtocol = class {
1631
1684
  this.blobSync = new BlobSync({
1632
1685
  blobStore
1633
1686
  });
1634
- this._topic = subtleCrypto.digest("SHA-256", topic.asBuffer()).then(discoveryKey).then(PublicKey4.from);
1687
+ this._topic = subtleCrypto2.digest("SHA-256", topic.asBuffer()).then(discoveryKey).then(PublicKey5.from);
1635
1688
  this._disableP2pReplication = disableP2pReplication ?? false;
1636
1689
  }
1637
1690
  get sessions() {
@@ -1675,17 +1728,13 @@ var SpaceProtocol = class {
1675
1728
  const topic = await this._topic;
1676
1729
  this._connection = await this._networkManager.joinSwarm({
1677
1730
  protocolProvider: this._createProtocolProvider(credentials),
1678
- peerInfo: {
1679
- peerKey: this._swarmIdentity.peerKey.toHex(),
1680
- identityKey: this._swarmIdentity.identityKey.toHex()
1681
- },
1682
1731
  topic,
1683
1732
  topology: this._topology,
1684
1733
  label: `swarm ${topic.truncate()} for space ${this._spaceKey.truncate()}`
1685
1734
  });
1686
1735
  log8("started", void 0, {
1687
1736
  F: __dxlog_file10,
1688
- L: 162,
1737
+ L: 158,
1689
1738
  S: this,
1690
1739
  C: (f, a) => f(...a)
1691
1740
  });
@@ -1698,14 +1747,14 @@ var SpaceProtocol = class {
1698
1747
  if (this._connection) {
1699
1748
  log8("stopping...", void 0, {
1700
1749
  F: __dxlog_file10,
1701
- L: 173,
1750
+ L: 169,
1702
1751
  S: this,
1703
1752
  C: (f, a) => f(...a)
1704
1753
  });
1705
1754
  await this._connection.close();
1706
1755
  log8("stopped", void 0, {
1707
1756
  F: __dxlog_file10,
1708
- L: 175,
1757
+ L: 171,
1709
1758
  S: this,
1710
1759
  C: (f, a) => f(...a)
1711
1760
  });
@@ -1781,7 +1830,7 @@ var SpaceProtocolSession = class {
1781
1830
  onAuthSuccess: () => {
1782
1831
  log8("Peer authenticated", void 0, {
1783
1832
  F: __dxlog_file10,
1784
- L: 286,
1833
+ L: 282,
1785
1834
  S: this,
1786
1835
  C: (f, a) => f(...a)
1787
1836
  });
@@ -1801,7 +1850,7 @@ var SpaceProtocolSession = class {
1801
1850
  async close() {
1802
1851
  log8("close", void 0, {
1803
1852
  F: __dxlog_file10,
1804
- L: 305,
1853
+ L: 301,
1805
1854
  S: this,
1806
1855
  C: (f, a) => f(...a)
1807
1856
  });
@@ -1821,10 +1870,10 @@ _ts_decorate6([
1821
1870
  // packages/core/echo/echo-pipeline/src/space/space-manager.ts
1822
1871
  import { synchronized as synchronized4, trackLeaks as trackLeaks3, Trigger as Trigger2 } from "@dxos/async";
1823
1872
  import { failUndefined as failUndefined2 } from "@dxos/debug";
1824
- import { PublicKey as PublicKey5 } from "@dxos/keys";
1873
+ import { PublicKey as PublicKey6 } from "@dxos/keys";
1825
1874
  import { log as log9 } from "@dxos/log";
1826
1875
  import { trace as trace4 } from "@dxos/protocols";
1827
- import { ComplexMap as ComplexMap4 } from "@dxos/util";
1876
+ import { ComplexMap as ComplexMap5 } from "@dxos/util";
1828
1877
  function _ts_decorate7(decorators, target, key, desc) {
1829
1878
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
1830
1879
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
@@ -1834,8 +1883,8 @@ function _ts_decorate7(decorators, target, key, desc) {
1834
1883
  var __dxlog_file11 = "/home/runner/work/dxos/dxos/packages/core/echo/echo-pipeline/src/space/space-manager.ts";
1835
1884
  var SpaceManager = class {
1836
1885
  constructor({ feedStore, networkManager, metadataStore, blobStore, disableP2pReplication }) {
1837
- this._spaces = new ComplexMap4(PublicKey5.hash);
1838
- this._instanceId = PublicKey5.random().toHex();
1886
+ this._spaces = new ComplexMap5(PublicKey6.hash);
1887
+ this._instanceId = PublicKey6.random().toHex();
1839
1888
  this._feedStore = feedStore;
1840
1889
  this._networkManager = networkManager;
1841
1890
  this._metadataStore = metadataStore;
@@ -1981,6 +2030,7 @@ export {
1981
2030
  codec,
1982
2031
  valueEncoding,
1983
2032
  createMappedFeedWriter,
2033
+ createIdFromSpaceKey,
1984
2034
  MetadataStore,
1985
2035
  hasInvitationExpired,
1986
2036
  mapTimeframeToFeedIndexes,
@@ -1999,4 +2049,4 @@ export {
1999
2049
  SpaceProtocolSession,
2000
2050
  SpaceManager
2001
2051
  };
2002
- //# sourceMappingURL=chunk-UKXIJW43.mjs.map
2052
+ //# sourceMappingURL=chunk-RRKGEIVZ.mjs.map