@dxos/echo-pipeline 0.8.4-main.f5c0578 → 0.8.4-main.fcc0d83b33

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 (187) hide show
  1. package/dist/lib/{browser/chunk-2543T5DX.mjs → neutral/chunk-VIHYDCCC.mjs} +162 -637
  2. package/dist/lib/neutral/chunk-VIHYDCCC.mjs.map +7 -0
  3. package/dist/lib/neutral/chunk-YBC6ONBZ.mjs +247 -0
  4. package/dist/lib/neutral/chunk-YBC6ONBZ.mjs.map +7 -0
  5. package/dist/lib/{browser → neutral}/filter/index.mjs +3 -2
  6. package/dist/lib/neutral/index.mjs +6245 -0
  7. package/dist/lib/neutral/index.mjs.map +7 -0
  8. package/dist/lib/neutral/meta.json +1 -0
  9. package/dist/lib/{browser → neutral}/testing/index.mjs +52 -306
  10. package/dist/lib/neutral/testing/index.mjs.map +7 -0
  11. package/dist/types/src/automerge/automerge-host.d.ts +57 -50
  12. package/dist/types/src/automerge/automerge-host.d.ts.map +1 -1
  13. package/dist/types/src/automerge/automerge-repo.test.d.ts +1 -1
  14. package/dist/types/src/automerge/automerge-repo.test.d.ts.map +1 -1
  15. package/dist/types/src/automerge/collection-synchronizer.d.ts +5 -3
  16. package/dist/types/src/automerge/collection-synchronizer.d.ts.map +1 -1
  17. package/dist/types/src/automerge/echo-data-monitor.d.ts.map +1 -1
  18. package/dist/types/src/automerge/echo-network-adapter.d.ts +23 -10
  19. package/dist/types/src/automerge/echo-network-adapter.d.ts.map +1 -1
  20. package/dist/types/src/automerge/echo-replicator.d.ts +37 -14
  21. package/dist/types/src/automerge/echo-replicator.d.ts.map +1 -1
  22. package/dist/types/src/automerge/heads-store.d.ts +9 -2
  23. package/dist/types/src/automerge/heads-store.d.ts.map +1 -1
  24. package/dist/types/src/automerge/leveldb-storage-adapter.d.ts +4 -4
  25. package/dist/types/src/automerge/leveldb-storage-adapter.d.ts.map +1 -1
  26. package/dist/types/src/automerge/mesh-echo-replicator-connection.d.ts +9 -8
  27. package/dist/types/src/automerge/mesh-echo-replicator-connection.d.ts.map +1 -1
  28. package/dist/types/src/automerge/mesh-echo-replicator.d.ts +6 -5
  29. package/dist/types/src/automerge/mesh-echo-replicator.d.ts.map +1 -1
  30. package/dist/types/src/automerge/network-protocol.d.ts.map +1 -1
  31. package/dist/types/src/automerge/space-collection.d.ts.map +1 -1
  32. package/dist/types/src/common/codec.d.ts +1 -1
  33. package/dist/types/src/common/codec.d.ts.map +1 -1
  34. package/dist/types/src/common/feeds.d.ts.map +1 -1
  35. package/dist/types/src/common/space-id.d.ts.map +1 -1
  36. package/dist/types/src/db-host/automerge-data-source.d.ts +35 -0
  37. package/dist/types/src/db-host/automerge-data-source.d.ts.map +1 -0
  38. package/dist/types/src/db-host/automerge-data-source.test.d.ts +2 -0
  39. package/dist/types/src/db-host/automerge-data-source.test.d.ts.map +1 -0
  40. package/dist/types/src/db-host/automerge-metrics.d.ts.map +1 -1
  41. package/dist/types/src/db-host/data-service.d.ts +7 -6
  42. package/dist/types/src/db-host/data-service.d.ts.map +1 -1
  43. package/dist/types/src/db-host/database-root.d.ts.map +1 -1
  44. package/dist/types/src/db-host/documents-synchronizer.d.ts +8 -7
  45. package/dist/types/src/db-host/documents-synchronizer.d.ts.map +1 -1
  46. package/dist/types/src/db-host/echo-host.d.ts +58 -28
  47. package/dist/types/src/db-host/echo-host.d.ts.map +1 -1
  48. package/dist/types/src/db-host/index.d.ts +1 -0
  49. package/dist/types/src/db-host/index.d.ts.map +1 -1
  50. package/dist/types/src/db-host/local-queue-service.d.ts +19 -0
  51. package/dist/types/src/db-host/local-queue-service.d.ts.map +1 -0
  52. package/dist/types/src/db-host/query-service.d.ts +13 -8
  53. package/dist/types/src/db-host/query-service.d.ts.map +1 -1
  54. package/dist/types/src/db-host/queue-data-source.d.ts +38 -0
  55. package/dist/types/src/db-host/queue-data-source.d.ts.map +1 -0
  56. package/dist/types/src/db-host/queue-service.test.d.ts +2 -0
  57. package/dist/types/src/db-host/queue-service.test.d.ts.map +1 -0
  58. package/dist/types/src/db-host/space-state-manager.d.ts +1 -0
  59. package/dist/types/src/db-host/space-state-manager.d.ts.map +1 -1
  60. package/dist/types/src/db-host/stub.d.ts +11 -0
  61. package/dist/types/src/db-host/stub.d.ts.map +1 -0
  62. package/dist/types/src/edge/echo-edge-replicator.d.ts +10 -7
  63. package/dist/types/src/edge/echo-edge-replicator.d.ts.map +1 -1
  64. package/dist/types/src/edge/inflight-request-limiter.d.ts.map +1 -1
  65. package/dist/types/src/filter/filter-match.d.ts +4 -1
  66. package/dist/types/src/filter/filter-match.d.ts.map +1 -1
  67. package/dist/types/src/metadata/metadata-store.d.ts.map +1 -1
  68. package/dist/types/src/pipeline/message-selector.d.ts.map +1 -1
  69. package/dist/types/src/pipeline/pipeline.d.ts +2 -2
  70. package/dist/types/src/pipeline/pipeline.d.ts.map +1 -1
  71. package/dist/types/src/pipeline/timeframe-clock.d.ts.map +1 -1
  72. package/dist/types/src/query/errors.d.ts +20 -21
  73. package/dist/types/src/query/errors.d.ts.map +1 -1
  74. package/dist/types/src/query/plan.d.ts +66 -8
  75. package/dist/types/src/query/plan.d.ts.map +1 -1
  76. package/dist/types/src/query/query-executor.d.ts +54 -9
  77. package/dist/types/src/query/query-executor.d.ts.map +1 -1
  78. package/dist/types/src/query/query-planner.d.ts +12 -1
  79. package/dist/types/src/query/query-planner.d.ts.map +1 -1
  80. package/dist/types/src/space/admission-discovery-extension.d.ts.map +1 -1
  81. package/dist/types/src/space/auth.d.ts +3 -3
  82. package/dist/types/src/space/auth.d.ts.map +1 -1
  83. package/dist/types/src/space/control-pipeline.d.ts +4 -3
  84. package/dist/types/src/space/control-pipeline.d.ts.map +1 -1
  85. package/dist/types/src/space/space-manager.d.ts +7 -7
  86. package/dist/types/src/space/space-manager.d.ts.map +1 -1
  87. package/dist/types/src/space/space-protocol.d.ts +9 -8
  88. package/dist/types/src/space/space-protocol.d.ts.map +1 -1
  89. package/dist/types/src/space/space.d.ts +5 -5
  90. package/dist/types/src/space/space.d.ts.map +1 -1
  91. package/dist/types/src/testing/change-metadata.d.ts.map +1 -1
  92. package/dist/types/src/testing/index.d.ts +0 -2
  93. package/dist/types/src/testing/index.d.ts.map +1 -1
  94. package/dist/types/src/testing/test-agent-builder.d.ts.map +1 -1
  95. package/dist/types/src/testing/test-feed-builder.d.ts.map +1 -1
  96. package/dist/types/src/testing/test-network-adapter.d.ts +1 -1
  97. package/dist/types/src/testing/test-network-adapter.d.ts.map +1 -1
  98. package/dist/types/src/testing/test-replicator.d.ts +14 -13
  99. package/dist/types/src/testing/test-replicator.d.ts.map +1 -1
  100. package/dist/types/src/util.d.ts.map +1 -1
  101. package/dist/types/tsconfig.tsbuildinfo +1 -1
  102. package/package.json +51 -54
  103. package/src/automerge/automerge-host.test.ts +57 -29
  104. package/src/automerge/automerge-host.ts +394 -133
  105. package/src/automerge/automerge-repo.test.ts +149 -32
  106. package/src/automerge/collection-synchronizer.test.ts +19 -13
  107. package/src/automerge/collection-synchronizer.ts +69 -28
  108. package/src/automerge/echo-network-adapter.test.ts +2 -1
  109. package/src/automerge/echo-network-adapter.ts +69 -27
  110. package/src/automerge/echo-replicator.ts +39 -14
  111. package/src/automerge/heads-store.ts +42 -3
  112. package/src/automerge/leveldb-storage-adapter.ts +10 -10
  113. package/src/automerge/mesh-echo-replicator-connection.ts +12 -8
  114. package/src/automerge/mesh-echo-replicator.ts +14 -11
  115. package/src/db-host/automerge-data-source.test.ts +299 -0
  116. package/src/db-host/automerge-data-source.ts +186 -0
  117. package/src/db-host/data-service.ts +18 -20
  118. package/src/db-host/documents-synchronizer.test.ts +143 -14
  119. package/src/db-host/documents-synchronizer.ts +54 -51
  120. package/src/db-host/echo-host.ts +267 -86
  121. package/src/db-host/index.ts +1 -0
  122. package/src/db-host/local-queue-service.ts +127 -0
  123. package/src/db-host/query-service.ts +29 -104
  124. package/src/db-host/queue-data-source.ts +159 -0
  125. package/src/db-host/queue-service.test.ts +145 -0
  126. package/src/db-host/space-state-manager.ts +5 -1
  127. package/src/db-host/stub.ts +33 -0
  128. package/src/edge/echo-edge-replicator.test.ts +12 -11
  129. package/src/edge/echo-edge-replicator.ts +111 -46
  130. package/src/filter/filter-match.test.ts +67 -31
  131. package/src/filter/filter-match.ts +184 -20
  132. package/src/metadata/metadata-store.ts +8 -5
  133. package/src/pipeline/pipeline-stress.test.ts +1 -3
  134. package/src/pipeline/pipeline.test.ts +0 -1
  135. package/src/pipeline/pipeline.ts +2 -3
  136. package/src/query/errors.ts +3 -1
  137. package/src/query/plan.ts +82 -8
  138. package/src/query/query-executor.ts +1025 -161
  139. package/src/query/query-planner.test.ts +993 -82
  140. package/src/query/query-planner.ts +467 -27
  141. package/src/space/admission-discovery-extension.ts +1 -1
  142. package/src/space/auth.ts +6 -6
  143. package/src/space/control-pipeline.test.ts +2 -2
  144. package/src/space/control-pipeline.ts +12 -9
  145. package/src/space/space-manager.ts +12 -17
  146. package/src/space/space-protocol.browser.test.ts +13 -12
  147. package/src/space/space-protocol.test.ts +13 -13
  148. package/src/space/space-protocol.ts +16 -15
  149. package/src/space/space.test.ts +2 -2
  150. package/src/space/space.ts +9 -10
  151. package/src/testing/index.ts +0 -2
  152. package/src/testing/test-agent-builder.ts +0 -1
  153. package/src/testing/test-network-adapter.ts +16 -3
  154. package/src/testing/test-replicator.ts +23 -18
  155. package/src/util.ts +7 -3
  156. package/dist/lib/browser/chunk-2543T5DX.mjs.map +0 -7
  157. package/dist/lib/browser/chunk-CGS2ULMK.mjs +0 -11
  158. package/dist/lib/browser/chunk-CGS2ULMK.mjs.map +0 -7
  159. package/dist/lib/browser/chunk-VUXUDIPM.mjs +0 -126
  160. package/dist/lib/browser/chunk-VUXUDIPM.mjs.map +0 -7
  161. package/dist/lib/browser/index.mjs +0 -4920
  162. package/dist/lib/browser/index.mjs.map +0 -7
  163. package/dist/lib/browser/meta.json +0 -1
  164. package/dist/lib/browser/testing/index.mjs.map +0 -7
  165. package/dist/lib/node-esm/chunk-HSLMI22Q.mjs +0 -11
  166. package/dist/lib/node-esm/chunk-HSLMI22Q.mjs.map +0 -7
  167. package/dist/lib/node-esm/chunk-PGZYXNYE.mjs +0 -126
  168. package/dist/lib/node-esm/chunk-PGZYXNYE.mjs.map +0 -7
  169. package/dist/lib/node-esm/chunk-UQI6R3TD.mjs +0 -2146
  170. package/dist/lib/node-esm/chunk-UQI6R3TD.mjs.map +0 -7
  171. package/dist/lib/node-esm/filter/index.mjs +0 -11
  172. package/dist/lib/node-esm/filter/index.mjs.map +0 -7
  173. package/dist/lib/node-esm/index.mjs +0 -4920
  174. package/dist/lib/node-esm/index.mjs.map +0 -7
  175. package/dist/lib/node-esm/meta.json +0 -1
  176. package/dist/lib/node-esm/testing/index.mjs +0 -767
  177. package/dist/lib/node-esm/testing/index.mjs.map +0 -7
  178. package/dist/types/src/db-host/documents-iterator.d.ts +0 -7
  179. package/dist/types/src/db-host/documents-iterator.d.ts.map +0 -1
  180. package/dist/types/src/testing/test-data.d.ts +0 -18
  181. package/dist/types/src/testing/test-data.d.ts.map +0 -1
  182. package/dist/types/src/testing/test-schema.d.ts +0 -37
  183. package/dist/types/src/testing/test-schema.d.ts.map +0 -1
  184. package/src/db-host/documents-iterator.ts +0 -74
  185. package/src/testing/test-data.ts +0 -127
  186. package/src/testing/test-schema.ts +0 -53
  187. /package/dist/lib/{browser → neutral}/filter/index.mjs.map +0 -0
@@ -10,24 +10,8 @@ var valueEncoding = createCodecEncoding(codec);
10
10
  import { invariant } from "@dxos/invariant";
11
11
  var __dxlog_file = "/__w/dxos/dxos/packages/core/echo/echo-pipeline/src/common/feeds.ts";
12
12
  var createMappedFeedWriter = (mapper, writer) => {
13
- invariant(mapper, void 0, {
14
- F: __dxlog_file,
15
- L: 16,
16
- S: void 0,
17
- A: [
18
- "mapper",
19
- ""
20
- ]
21
- });
22
- invariant(writer, void 0, {
23
- F: __dxlog_file,
24
- L: 17,
25
- S: void 0,
26
- A: [
27
- "writer",
28
- ""
29
- ]
30
- });
13
+ invariant(mapper, void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file, L: 8, S: void 0, A: ["mapper", ""] });
14
+ invariant(writer, void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file, L: 9, S: void 0, A: ["writer", ""] });
31
15
  return {
32
16
  write: async (data, options) => await writer.write(await mapper(data), options)
33
17
  };
@@ -61,13 +45,13 @@ import { DataCorruptionError, STORAGE_VERSION } from "@dxos/protocols";
61
45
  import { schema as schema2 } from "@dxos/protocols/proto";
62
46
  import { Invitation, SpaceState } from "@dxos/protocols/proto/dxos/client/services";
63
47
  import { ComplexMap as ComplexMap2, arrayToBuffer, forEachAsync, isNonNullable } from "@dxos/util";
48
+ var __dxlog_file2 = "/__w/dxos/dxos/packages/core/echo/echo-pipeline/src/metadata/metadata-store.ts";
64
49
  function _ts_decorate(decorators, target, key, desc) {
65
50
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
66
51
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
67
52
  else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
68
53
  return c > 3 && r && Object.defineProperty(target, key, r), r;
69
54
  }
70
- var __dxlog_file2 = "/__w/dxos/dxos/packages/core/echo/echo-pipeline/src/metadata/metadata-store.ts";
71
55
  var EXPIRED_INVITATION_CLEANUP_INTERVAL = 60 * 60 * 1e3;
72
56
  var emptyEchoMetadata = () => ({
73
57
  version: STORAGE_VERSION,
@@ -83,10 +67,7 @@ var MetadataStore = class {
83
67
  _spaceLargeMetadata = new ComplexMap2(PublicKey2.hash);
84
68
  _metadataFile = void 0;
85
69
  update = new Event();
86
- _invitationCleanupCtx = new Context(void 0, {
87
- F: __dxlog_file2,
88
- L: 55
89
- });
70
+ _invitationCleanupCtx = new Context(void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file2, L: 35 });
90
71
  /**
91
72
  * @internal
92
73
  */
@@ -119,22 +100,22 @@ var MetadataStore = class {
119
100
  size: dataSize,
120
101
  checksum,
121
102
  name: file.filename
122
- }, {
123
- F: __dxlog_file2,
124
- L: 91,
125
- S: this,
126
- C: (f, a) => f(...a)
127
- });
103
+ }, { "~LogMeta": "~LogMeta", F: __dxlog_file2, L: 63, S: this });
128
104
  if (fileLength < dataSize + 8) {
129
- throw new DataCorruptionError("Metadata size is smaller than expected.", {
130
- fileLength,
131
- dataSize
105
+ throw new DataCorruptionError({
106
+ message: "Metadata size is smaller than expected.",
107
+ context: {
108
+ fileLength,
109
+ dataSize
110
+ }
132
111
  });
133
112
  }
134
113
  const data = await file.read(8, dataSize);
135
114
  const calculatedChecksum = CRC32.buf(data);
136
115
  if (calculatedChecksum !== checksum) {
137
- throw new DataCorruptionError("Metadata checksum is invalid.");
116
+ throw new DataCorruptionError({
117
+ message: "Metadata checksum is invalid."
118
+ });
138
119
  }
139
120
  return codec2.decode(data);
140
121
  } finally {
@@ -155,12 +136,7 @@ var MetadataStore = class {
155
136
  log("saved", {
156
137
  size: encoded.length,
157
138
  checksum
158
- }, {
159
- F: __dxlog_file2,
160
- L: 126,
161
- S: this,
162
- C: (f, a) => f(...a)
163
- });
139
+ }, { "~LogMeta": "~LogMeta", F: __dxlog_file2, L: 100, S: this });
164
140
  }
165
141
  async close() {
166
142
  await this._invitationCleanupCtx.dispose();
@@ -188,12 +164,7 @@ var MetadataStore = class {
188
164
  } catch (err) {
189
165
  log.error("failed to load metadata", {
190
166
  err
191
- }, {
192
- F: __dxlog_file2,
193
- L: 158,
194
- S: this,
195
- C: (f, a) => f(...a)
196
- });
167
+ }, { "~LogMeta": "~LogMeta", F: __dxlog_file2, L: 129, S: this });
197
168
  this._metadata = emptyEchoMetadata();
198
169
  }
199
170
  await forEachAsync([
@@ -205,12 +176,7 @@ var MetadataStore = class {
205
176
  } catch (err) {
206
177
  log.error("failed to load space large metadata", {
207
178
  err
208
- }, {
209
- F: __dxlog_file2,
210
- L: 170,
211
- S: this,
212
- C: (f, a) => f(...a)
213
- });
179
+ }, { "~LogMeta": "~LogMeta", F: __dxlog_file2, L: 141, S: this });
214
180
  }
215
181
  });
216
182
  scheduleTaskInterval(this._invitationCleanupCtx, async () => {
@@ -242,12 +208,7 @@ var MetadataStore = class {
242
208
  } catch (err) {
243
209
  log.error("failed to load space large metadata", {
244
210
  err
245
- }, {
246
- F: __dxlog_file2,
247
- L: 212,
248
- S: this,
249
- C: (f, a) => f(...a)
250
- });
211
+ }, { "~LogMeta": "~LogMeta", F: __dxlog_file2, L: 174, S: this });
251
212
  }
252
213
  }
253
214
  async _saveSpaceLargeMetadata(key) {
@@ -263,15 +224,7 @@ var MetadataStore = class {
263
224
  return this._metadata.identity.haloSpace;
264
225
  }
265
226
  const space = this.spaces.find((space2) => space2.key.equals(spaceKey));
266
- invariant2(space, "Space not found", {
267
- F: __dxlog_file2,
268
- L: 234,
269
- S: this,
270
- A: [
271
- "space",
272
- "'Space not found'"
273
- ]
274
- });
227
+ invariant2(space, "Space not found", { "~LogMeta": "~LogMeta", F: __dxlog_file2, L: 193, S: this, A: ["space", "'Space not found'"] });
275
228
  return space;
276
229
  }
277
230
  hasSpace(spaceKey) {
@@ -293,12 +246,7 @@ var MetadataStore = class {
293
246
  * Clears storage - doesn't work for now.
294
247
  */
295
248
  async clear() {
296
- log("clearing all metadata", void 0, {
297
- F: __dxlog_file2,
298
- L: 262,
299
- S: this,
300
- C: (f, a) => f(...a)
301
- });
249
+ log("clearing all metadata", void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file2, L: 215, S: this });
302
250
  await this._directory.delete();
303
251
  this._metadata = emptyEchoMetadata();
304
252
  }
@@ -306,15 +254,7 @@ var MetadataStore = class {
306
254
  return this._metadata.identity;
307
255
  }
308
256
  async setIdentityRecord(record) {
309
- invariant2(!this._metadata.identity, "Cannot overwrite existing identity in metadata", {
310
- F: __dxlog_file2,
311
- L: 272,
312
- S: this,
313
- A: [
314
- "!this._metadata.identity",
315
- "'Cannot overwrite existing identity in metadata'"
316
- ]
317
- });
257
+ invariant2(!this._metadata.identity, "Cannot overwrite existing identity in metadata", { "~LogMeta": "~LogMeta", F: __dxlog_file2, L: 223, S: this, A: ["!this._metadata.identity", "'Cannot overwrite existing identity in metadata'"] });
318
258
  this._metadata.identity = record;
319
259
  await this._save();
320
260
  await this.flush();
@@ -336,15 +276,7 @@ var MetadataStore = class {
336
276
  await this.flush();
337
277
  }
338
278
  async addSpace(record) {
339
- invariant2(!(this._metadata.spaces ?? []).find((space) => space.key.equals(record.key)), "Cannot overwrite existing space in metadata", {
340
- F: __dxlog_file2,
341
- L: 300,
342
- S: this,
343
- A: [
344
- "!(this._metadata.spaces ?? []).find((space) => space.key.equals(record.key))",
345
- "'Cannot overwrite existing space in metadata'"
346
- ]
347
- });
279
+ invariant2(!(this._metadata.spaces ?? []).find((space) => space.key.equals(record.key)), "Cannot overwrite existing space in metadata", { "~LogMeta": "~LogMeta", F: __dxlog_file2, L: 245, S: this, A: ["!(this._metadata.spaces ?? []).find((space)=>space.key.equals(record.key))", "'Cannot overwrite existing space in metadata'"] });
348
280
  (this._metadata.spaces ??= []).push(record);
349
281
  await this._save();
350
282
  await this.flush();
@@ -413,13 +345,13 @@ import { Event as Event2 } from "@dxos/async";
413
345
  import { timed } from "@dxos/debug";
414
346
  import { log as log2 } from "@dxos/log";
415
347
  import { Timeframe } from "@dxos/timeframe";
348
+ var __dxlog_file3 = "/__w/dxos/dxos/packages/core/echo/echo-pipeline/src/pipeline/timeframe-clock.ts";
416
349
  function _ts_decorate2(decorators, target, key, desc) {
417
350
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
418
351
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
419
352
  else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
420
353
  return c > 3 && r && Object.defineProperty(target, key, r), r;
421
354
  }
422
- var __dxlog_file3 = "/__w/dxos/dxos/packages/core/echo/echo-pipeline/src/pipeline/timeframe-clock.ts";
423
355
  var mapTimeframeToFeedIndexes = (timeframe) => timeframe.frames().map(([feedKey, index]) => ({
424
356
  feedKey,
425
357
  index
@@ -434,11 +366,10 @@ var startAfter = (timeframe) => timeframe.frames().map(([feedKey, index]) => ({
434
366
  }));
435
367
  var TimeframeClock = class {
436
368
  _timeframe;
437
- update;
369
+ update = new Event2();
438
370
  _pendingTimeframe;
439
371
  constructor(_timeframe = new Timeframe()) {
440
372
  this._timeframe = _timeframe;
441
- this.update = new Event2();
442
373
  this._pendingTimeframe = _timeframe;
443
374
  }
444
375
  /**
@@ -479,23 +410,13 @@ var TimeframeClock = class {
479
410
  log2("waitUntilReached", {
480
411
  target,
481
412
  current: this._timeframe
482
- }, {
483
- F: __dxlog_file3,
484
- L: 70,
485
- S: this,
486
- C: (f, a) => f(...a)
487
- });
413
+ }, { "~LogMeta": "~LogMeta", F: __dxlog_file3, L: 69, S: this });
488
414
  await this.update.waitForCondition(() => {
489
415
  log2("check if reached", {
490
416
  target,
491
417
  current: this._timeframe,
492
418
  deps: Timeframe.dependencies(target, this._timeframe)
493
- }, {
494
- F: __dxlog_file3,
495
- L: 72,
496
- S: this,
497
- C: (f, a) => f(...a)
498
- });
419
+ }, { "~LogMeta": "~LogMeta", F: __dxlog_file3, L: 74, S: this });
499
420
  return Timeframe.dependencies(target, this._timeframe).isEmpty();
500
421
  });
501
422
  }
@@ -523,52 +444,39 @@ var createMessageSelector = (timeframeClock) => {
523
444
  return (messages) => {
524
445
  for (let i = 0; i < messages.length; i++) {
525
446
  const { data: { timeframe } } = messages[i];
526
- invariant3(timeframe, void 0, {
527
- F: __dxlog_file4,
528
- L: 25,
529
- S: void 0,
530
- A: [
531
- "timeframe",
532
- ""
533
- ]
534
- });
447
+ invariant3(timeframe, void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file4, L: 16, S: void 0, A: ["timeframe", ""] });
535
448
  if (!timeframeClock.hasGaps(timeframe)) {
536
449
  return i;
537
450
  }
538
451
  }
539
- log3("Skipping...", void 0, {
540
- F: __dxlog_file4,
541
- L: 33,
542
- S: void 0,
543
- C: (f, a) => f(...a)
544
- });
452
+ log3("Skipping...", void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file4, L: 22, S: void 0 });
545
453
  };
546
454
  };
547
455
 
548
456
  // src/pipeline/pipeline.ts
457
+ var __dxlog_file5 = "/__w/dxos/dxos/packages/core/echo/echo-pipeline/src/pipeline/pipeline.ts";
549
458
  function _ts_decorate3(decorators, target, key, desc) {
550
459
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
551
460
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
552
461
  else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
553
462
  return c > 3 && r && Object.defineProperty(target, key, r), r;
554
463
  }
555
- var __dxlog_file5 = "/__w/dxos/dxos/packages/core/echo/echo-pipeline/src/pipeline/pipeline.ts";
556
464
  var PipelineState = class {
557
465
  _feeds;
558
466
  _timeframeClock;
559
467
  /**
560
468
  * @internal
561
469
  */
562
- _ctx;
470
+ _ctx = new Context2(void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file5, L: 29 });
563
471
  // TODO(dmaretskyi): Remove?. Avoid accessing `_timeframeClock` before constructor initialization.
564
472
  get timeframeUpdate() {
565
473
  return this._timeframeClock.update;
566
474
  }
567
- stalled;
475
+ stalled = new Event3();
568
476
  /**
569
477
  * @internal
570
478
  */
571
- _startTimeframe;
479
+ _startTimeframe = new Timeframe2();
572
480
  /**
573
481
  * Target timeframe we are waiting to reach.
574
482
  */
@@ -580,17 +488,10 @@ var PipelineState = class {
580
488
  /**
581
489
  * @internal
582
490
  */
583
- _reachedTarget;
491
+ _reachedTarget = false;
584
492
  constructor(_feeds, _timeframeClock) {
585
493
  this._feeds = _feeds;
586
494
  this._timeframeClock = _timeframeClock;
587
- this._ctx = new Context2(void 0, {
588
- F: __dxlog_file5,
589
- L: 42
590
- });
591
- this.stalled = new Event3();
592
- this._startTimeframe = new Timeframe2();
593
- this._reachedTarget = false;
594
495
  }
595
496
  /**
596
497
  * Latest theoretical timeframe based on the last mutation in each feed.
@@ -634,20 +535,12 @@ var PipelineState = class {
634
535
  *
635
536
  * @param timeout Timeout in milliseconds to specify the maximum wait time.
636
537
  */
637
- async waitUntilReachedTargetTimeframe({ ctx = new Context2(void 0, {
638
- F: __dxlog_file5,
639
- L: 132
640
- }), timeout, breakOnStall = true } = {}) {
538
+ async waitUntilReachedTargetTimeframe({ ctx = new Context2(void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file5, L: 91 }), timeout, breakOnStall = true } = {}) {
641
539
  log4("waitUntilReachedTargetTimeframe", {
642
540
  timeout,
643
541
  current: this.timeframe,
644
542
  target: this.targetTimeframe
645
- }, {
646
- F: __dxlog_file5,
647
- L: 136,
648
- S: this,
649
- C: (f, a) => f(...a)
650
- });
543
+ }, { "~LogMeta": "~LogMeta", F: __dxlog_file5, L: 92, S: this });
651
544
  this._reachedTargetPromise ??= Promise.race([
652
545
  this._timeframeClock.update.waitForCondition(() => {
653
546
  return Timeframe2.dependencies(this.targetTimeframe, this.timeframe).isEmpty();
@@ -674,12 +567,7 @@ var PipelineState = class {
674
567
  current: this.timeframe,
675
568
  target: this.targetTimeframe,
676
569
  dependencies: Timeframe2.dependencies(this.targetTimeframe, this.timeframe)
677
- }, {
678
- F: __dxlog_file5,
679
- L: 164,
680
- S: this,
681
- C: (f, a) => f(...a)
682
- });
570
+ }, { "~LogMeta": "~LogMeta", F: __dxlog_file5, L: 118, S: this });
683
571
  })
684
572
  ]);
685
573
  } else {
@@ -709,15 +597,7 @@ var Pipeline = class {
709
597
  return this._state;
710
598
  }
711
599
  get writer() {
712
- invariant4(this._writer, "Writer not set.", {
713
- F: __dxlog_file5,
714
- L: 246,
715
- S: this,
716
- A: [
717
- "this._writer",
718
- "'Writer not set.'"
719
- ]
720
- });
600
+ invariant4(this._writer, "Writer not set.", { "~LogMeta": "~LogMeta", F: __dxlog_file5, L: 184, S: this, A: ["this._writer", "'Writer not set.'"] });
721
601
  return this._writer;
722
602
  }
723
603
  hasFeed(feedKey) {
@@ -738,54 +618,20 @@ var Pipeline = class {
738
618
  }
739
619
  }
740
620
  setWriteFeed(feed) {
741
- invariant4(!this._writer, "Writer already set.", {
742
- F: __dxlog_file5,
743
- L: 273,
744
- S: this,
745
- A: [
746
- "!this._writer",
747
- "'Writer already set.'"
748
- ]
749
- });
750
- invariant4(feed.properties.writable, "Feed must be writable.", {
751
- F: __dxlog_file5,
752
- L: 274,
753
- S: this,
754
- A: [
755
- "feed.properties.writable",
756
- "'Feed must be writable.'"
757
- ]
758
- });
621
+ invariant4(!this._writer, "Writer already set.", { "~LogMeta": "~LogMeta", F: __dxlog_file5, L: 205, S: this, A: ["!this._writer", "'Writer already set.'"] });
622
+ invariant4(feed.properties.writable, "Feed must be writable.", { "~LogMeta": "~LogMeta", F: __dxlog_file5, L: 206, S: this, A: ["feed.properties.writable", "'Feed must be writable.'"] });
759
623
  this._writer = createMappedFeedWriter((payload) => ({
760
624
  timeframe: this._timeframeClock.timeframe,
761
625
  payload
762
626
  }), feed.createFeedWriter());
763
627
  }
764
628
  async start() {
765
- invariant4(!this._isStarted, "Pipeline is already started.", {
766
- F: __dxlog_file5,
767
- L: 287,
768
- S: this,
769
- A: [
770
- "!this._isStarted",
771
- "'Pipeline is already started.'"
772
- ]
773
- });
774
- log4("starting...", void 0, {
775
- F: __dxlog_file5,
776
- L: 288,
777
- S: this,
778
- C: (f, a) => f(...a)
779
- });
629
+ invariant4(!this._isStarted, "Pipeline is already started.", { "~LogMeta": "~LogMeta", F: __dxlog_file5, L: 213, S: this, A: ["!this._isStarted", "'Pipeline is already started.'"] });
630
+ log4("starting...", void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file5, L: 214, S: this });
780
631
  await this._initIterator();
781
632
  await this._feedSetIterator.open();
782
633
  this._isStarted = true;
783
- log4("started", void 0, {
784
- F: __dxlog_file5,
785
- L: 292,
786
- S: this,
787
- C: (f, a) => f(...a)
788
- });
634
+ log4("started", void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file5, L: 218, S: this });
789
635
  if (!this._isPaused) {
790
636
  for (const feed of this._feeds.values()) {
791
637
  this._setFeedDownloadState(feed);
@@ -793,12 +639,7 @@ var Pipeline = class {
793
639
  }
794
640
  }
795
641
  async stop() {
796
- log4("stopping...", void 0, {
797
- F: __dxlog_file5,
798
- L: 303,
799
- S: this,
800
- C: (f, a) => f(...a)
801
- });
642
+ log4("stopping...", void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file5, L: 226, S: this });
802
643
  this._isStopping = true;
803
644
  for (const [feed, handle] of this._downloads.entries()) {
804
645
  feed.undownload(handle);
@@ -807,34 +648,18 @@ var Pipeline = class {
807
648
  await this._feedSetIterator?.close();
808
649
  await this._processingTrigger.wait();
809
650
  await this._state._ctx.dispose();
810
- this._state._ctx = new Context2(void 0, {
811
- F: __dxlog_file5,
812
- L: 312
813
- });
651
+ this._state._ctx = new Context2(void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file5, L: 235 });
814
652
  this._state._reachedTargetPromise = void 0;
815
653
  this._state._reachedTarget = false;
816
654
  this._isStarted = false;
817
- log4("stopped", void 0, {
818
- F: __dxlog_file5,
819
- L: 316,
820
- S: this,
821
- C: (f, a) => f(...a)
822
- });
655
+ log4("stopped", void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file5, L: 239, S: this });
823
656
  }
824
657
  /**
825
658
  * @param timeframe Timeframe of already processed messages.
826
659
  * The pipeline will start processing messages AFTER this timeframe.
827
660
  */
828
661
  async setCursor(timeframe) {
829
- invariant4(!this._isStarted || this._isPaused, "Invalid state.", {
830
- F: __dxlog_file5,
831
- L: 325,
832
- S: this,
833
- A: [
834
- "!this._isStarted || this._isPaused",
835
- "'Invalid state.'"
836
- ]
837
- });
662
+ invariant4(!this._isStarted || this._isPaused, "Invalid state.", { "~LogMeta": "~LogMeta", F: __dxlog_file5, L: 245, S: this, A: ["!this._isStarted || this._isPaused", "'Invalid state.'"] });
838
663
  this._state._startTimeframe = timeframe;
839
664
  this._timeframeClock.setTimeframe(timeframe);
840
665
  if (this._feedSetIterator) {
@@ -855,15 +680,7 @@ var Pipeline = class {
855
680
  this._isPaused = true;
856
681
  }
857
682
  async unpause() {
858
- invariant4(this._isPaused, "Pipeline is not paused.", {
859
- F: __dxlog_file5,
860
- L: 354,
861
- S: this,
862
- A: [
863
- "this._isPaused",
864
- "'Pipeline is not paused.'"
865
- ]
866
- });
683
+ invariant4(this._isPaused, "Pipeline is not paused.", { "~LogMeta": "~LogMeta", F: __dxlog_file5, L: 266, S: this, A: ["this._isPaused", "'Pipeline is not paused.'"] });
867
684
  this._pauseTrigger.wake();
868
685
  this._isPaused = false;
869
686
  for (const feed of this._feeds.values()) {
@@ -875,39 +692,15 @@ var Pipeline = class {
875
692
  * Updates the timeframe clock after the message has bee processed.
876
693
  */
877
694
  async *consume() {
878
- invariant4(!this._isBeingConsumed, "Pipeline is already being consumed.", {
879
- F: __dxlog_file5,
880
- L: 369,
881
- S: this,
882
- A: [
883
- "!this._isBeingConsumed",
884
- "'Pipeline is already being consumed.'"
885
- ]
886
- });
695
+ invariant4(!this._isBeingConsumed, "Pipeline is already being consumed.", { "~LogMeta": "~LogMeta", F: __dxlog_file5, L: 277, S: this, A: ["!this._isBeingConsumed", "'Pipeline is already being consumed.'"] });
887
696
  this._isBeingConsumed = true;
888
- invariant4(this._feedSetIterator, "Iterator not initialized.", {
889
- F: __dxlog_file5,
890
- L: 372,
891
- S: this,
892
- A: [
893
- "this._feedSetIterator",
894
- "'Iterator not initialized.'"
895
- ]
896
- });
697
+ invariant4(this._feedSetIterator, "Iterator not initialized.", { "~LogMeta": "~LogMeta", F: __dxlog_file5, L: 279, S: this, A: ["this._feedSetIterator", "'Iterator not initialized.'"] });
897
698
  let lastFeedSetIterator = this._feedSetIterator;
898
699
  let iterable = lastFeedSetIterator[Symbol.asyncIterator]();
899
700
  while (!this._isStopping) {
900
701
  await this._pauseTrigger.wait();
901
702
  if (lastFeedSetIterator !== this._feedSetIterator) {
902
- invariant4(this._feedSetIterator, "Iterator not initialized.", {
903
- F: __dxlog_file5,
904
- L: 381,
905
- S: this,
906
- A: [
907
- "this._feedSetIterator",
908
- "'Iterator not initialized.'"
909
- ]
910
- });
703
+ invariant4(this._feedSetIterator, "Iterator not initialized.", { "~LogMeta": "~LogMeta", F: __dxlog_file5, L: 286, S: this, A: ["this._feedSetIterator", "'Iterator not initialized.'"] });
911
704
  lastFeedSetIterator = this._feedSetIterator;
912
705
  iterable = lastFeedSetIterator[Symbol.asyncIterator]();
913
706
  }
@@ -934,12 +727,7 @@ var Pipeline = class {
934
727
  feed: feed.key.truncate(),
935
728
  seq,
936
729
  length: feed.length
937
- }, {
938
- F: __dxlog_file5,
939
- L: 410,
940
- S: this,
941
- C: (f, a) => f(...a)
942
- });
730
+ }, { "~LogMeta": "~LogMeta", F: __dxlog_file5, L: 311, S: this });
943
731
  handle = feed.download({
944
732
  start: seq + 1,
945
733
  linear: true
@@ -948,12 +736,7 @@ var Pipeline = class {
948
736
  } else {
949
737
  log4("downloaded", {
950
738
  data
951
- }, {
952
- F: __dxlog_file5,
953
- L: 415,
954
- S: this,
955
- C: (f, a) => f(...a)
956
- });
739
+ }, { "~LogMeta": "~LogMeta", F: __dxlog_file5, L: 323, S: this });
957
740
  }
958
741
  });
959
742
  this._downloads.set(feed, handle);
@@ -967,12 +750,7 @@ var Pipeline = class {
967
750
  log4.warn(`Stalled after ${iterator.options.stallTimeout}ms with ${iterator.size} feeds.`, {
968
751
  currentTimeframe: this._timeframeClock.timeframe,
969
752
  targetTimeframe: this._state.targetTimeframe
970
- }, {
971
- F: __dxlog_file5,
972
- L: 429,
973
- S: this,
974
- C: (f, a) => f(...a)
975
- });
753
+ }, { "~LogMeta": "~LogMeta", F: __dxlog_file5, L: 336, S: this });
976
754
  this._state.stalled.emit();
977
755
  });
978
756
  for (const feed of this._feeds.values()) {
@@ -1006,9 +784,13 @@ import { schema as schema3 } from "@dxos/protocols/proto";
1006
784
  import { RpcExtension } from "@dxos/teleport";
1007
785
  var __dxlog_file6 = "/__w/dxos/dxos/packages/core/echo/echo-pipeline/src/space/auth.ts";
1008
786
  var AuthExtension = class extends RpcExtension {
1009
- _authParams;
1010
- _ctx;
1011
- constructor(_authParams) {
787
+ _authProps;
788
+ _ctx = new Context3({
789
+ onError: (err) => {
790
+ log5.catch(err, void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file6, L: 15, S: this });
791
+ }
792
+ }, { "~LogMeta": "~LogMeta", F: __dxlog_file6, L: 13 });
793
+ constructor(_authProps) {
1012
794
  super({
1013
795
  requested: {
1014
796
  AuthService: schema3.getService("dxos.mesh.teleport.auth.AuthService")
@@ -1017,26 +799,14 @@ var AuthExtension = class extends RpcExtension {
1017
799
  AuthService: schema3.getService("dxos.mesh.teleport.auth.AuthService")
1018
800
  },
1019
801
  timeout: 60 * 1e3
1020
- }), this._authParams = _authParams, this._ctx = new Context3({
1021
- onError: (err) => {
1022
- log5.catch(err, void 0, {
1023
- F: __dxlog_file6,
1024
- L: 28,
1025
- S: this,
1026
- C: (f, a) => f(...a)
1027
- });
1028
- }
1029
- }, {
1030
- F: __dxlog_file6,
1031
- L: 26
1032
- });
802
+ }), this._authProps = _authProps;
1033
803
  }
1034
804
  async getHandlers() {
1035
805
  return {
1036
806
  AuthService: {
1037
807
  authenticate: async ({ challenge }) => {
1038
808
  try {
1039
- const credential = await this._authParams.provider(challenge);
809
+ const credential = await this._authProps.provider(challenge);
1040
810
  if (!credential) {
1041
811
  throw new Error("auth rejected");
1042
812
  }
@@ -1044,12 +814,7 @@ var AuthExtension = class extends RpcExtension {
1044
814
  credential
1045
815
  };
1046
816
  } catch (err) {
1047
- log5.error("failed to generate auth credentials", err, {
1048
- F: __dxlog_file6,
1049
- L: 55,
1050
- S: this,
1051
- C: (f, a) => f(...a)
1052
- });
817
+ log5.error("failed to generate auth credentials", err, { "~LogMeta": "~LogMeta", F: __dxlog_file6, L: 42, S: this });
1053
818
  throw new Error("auth rejected");
1054
819
  }
1055
820
  }
@@ -1064,35 +829,14 @@ var AuthExtension = class extends RpcExtension {
1064
829
  const { credential } = await this.rpc.AuthService.authenticate({
1065
830
  challenge
1066
831
  });
1067
- invariant5(credential?.length > 0, "invalid credential", {
1068
- F: __dxlog_file6,
1069
- L: 69,
1070
- S: this,
1071
- A: [
1072
- "credential?.length > 0",
1073
- "'invalid credential'"
1074
- ]
1075
- });
1076
- const success = await this._authParams.verifier(challenge, credential);
1077
- invariant5(success, "credential not verified", {
1078
- F: __dxlog_file6,
1079
- L: 71,
1080
- S: this,
1081
- A: [
1082
- "success",
1083
- "'credential not verified'"
1084
- ]
1085
- });
1086
- runInContext(this._ctx, () => this._authParams.onAuthSuccess());
832
+ invariant5(credential?.length > 0, "invalid credential", { "~LogMeta": "~LogMeta", F: __dxlog_file6, L: 57, S: this, A: ["credential?.length > 0", "'invalid credential'"] });
833
+ const success = await this._authProps.verifier(challenge, credential);
834
+ invariant5(success, "credential not verified", { "~LogMeta": "~LogMeta", F: __dxlog_file6, L: 59, S: this, A: ["success", "'credential not verified'"] });
835
+ runInContext(this._ctx, () => this._authProps.onAuthSuccess());
1087
836
  } catch (err) {
1088
- log5("auth failed", err, {
1089
- F: __dxlog_file6,
1090
- L: 74,
1091
- S: this,
1092
- C: (f, a) => f(...a)
1093
- });
837
+ log5("auth failed", err, { "~LogMeta": "~LogMeta", F: __dxlog_file6, L: 62, S: this });
1094
838
  this.close();
1095
- this._authParams.onAuthFailure();
839
+ this._authProps.onAuthFailure();
1096
840
  }
1097
841
  });
1098
842
  }
@@ -1107,7 +851,7 @@ var AuthExtension = class extends RpcExtension {
1107
851
  };
1108
852
 
1109
853
  // src/space/space.ts
1110
- import { Event as Event4, scheduleMicroTask, synchronized as synchronized3, trackLeaks as trackLeaks2 } from "@dxos/async";
854
+ import { Event as Event4, scheduleMicroTask as scheduleMicroTask2, synchronized as synchronized3, trackLeaks as trackLeaks2 } from "@dxos/async";
1111
855
  import { Resource } from "@dxos/context";
1112
856
  import { invariant as invariant6 } from "@dxos/invariant";
1113
857
  import { log as log7, logInfo } from "@dxos/log";
@@ -1116,7 +860,7 @@ import { trace as trace2 } from "@dxos/tracing";
1116
860
  import { Callback as Callback2 } from "@dxos/util";
1117
861
 
1118
862
  // src/space/control-pipeline.ts
1119
- import { DeferredTask, sleepWithContext as sleepWithContext2, trackLeaks } from "@dxos/async";
863
+ import { DeferredTask, scheduleMicroTask, sleepWithContext as sleepWithContext2, trackLeaks } from "@dxos/async";
1120
864
  import { Context as Context4 } from "@dxos/context";
1121
865
  import { SpaceStateMachine } from "@dxos/credentials";
1122
866
  import { PublicKey as PublicKey4 } from "@dxos/keys";
@@ -1125,21 +869,18 @@ import { AdmittedFeed } from "@dxos/protocols/proto/dxos/halo/credentials";
1125
869
  import { Timeframe as Timeframe3 } from "@dxos/timeframe";
1126
870
  import { TimeSeriesCounter, TimeUsageCounter, trace } from "@dxos/tracing";
1127
871
  import { Callback, tracer } from "@dxos/util";
872
+ var __dxlog_file7 = "/__w/dxos/dxos/packages/core/echo/echo-pipeline/src/space/control-pipeline.ts";
1128
873
  function _ts_decorate4(decorators, target, key, desc) {
1129
874
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
1130
875
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
1131
876
  else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
1132
877
  return c > 3 && r && Object.defineProperty(target, key, r), r;
1133
878
  }
1134
- var __dxlog_file7 = "/__w/dxos/dxos/packages/core/echo/echo-pipeline/src/space/control-pipeline.ts";
1135
879
  var TIMEFRAME_SAVE_DEBOUNCE_INTERVAL = 500;
1136
880
  var CONTROL_PIPELINE_SNAPSHOT_DELAY = 1e4;
1137
881
  var USE_SNAPSHOTS = true;
1138
882
  var ControlPipeline = class {
1139
- _ctx = new Context4(void 0, {
1140
- F: __dxlog_file7,
1141
- L: 47
1142
- });
883
+ _ctx = new Context4(void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file7, L: 24 });
1143
884
  _pipeline;
1144
885
  _spaceStateMachine;
1145
886
  _spaceKey;
@@ -1166,26 +907,19 @@ var ControlPipeline = class {
1166
907
  this._spaceStateMachine.onFeedAdmitted.set(async (info) => {
1167
908
  log6("feed admitted", {
1168
909
  key: info.key
1169
- }, {
1170
- F: __dxlog_file7,
1171
- L: 82,
1172
- S: this,
1173
- C: (f, a) => f(...a)
1174
- });
910
+ }, { "~LogMeta": "~LogMeta", F: __dxlog_file7, L: 50, S: this });
1175
911
  if (info.assertion.designation === AdmittedFeed.Designation.CONTROL && !info.key.equals(genesisFeed.key)) {
1176
- queueMicrotask(async () => {
912
+ scheduleMicroTask(this._ctx, async () => {
1177
913
  try {
1178
914
  const feed = await feedProvider(info.key);
915
+ if (this._ctx.disposed) {
916
+ return;
917
+ }
1179
918
  if (!this._pipeline.hasFeed(feed.key)) {
1180
919
  await this._pipeline.addFeed(feed);
1181
920
  }
1182
921
  } catch (err) {
1183
- log6.catch(err, void 0, {
1184
- F: __dxlog_file7,
1185
- L: 93,
1186
- S: this,
1187
- C: (f, a) => f(...a)
1188
- });
922
+ log6.catch(err, void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file7, L: 65, S: this });
1189
923
  }
1190
924
  });
1191
925
  }
@@ -1206,40 +940,22 @@ var ControlPipeline = class {
1206
940
  await this._pipeline.addFeed(feed);
1207
941
  this._pipeline.setWriteFeed(feed);
1208
942
  }
1209
- async start() {
943
+ async start(ctx) {
1210
944
  const snapshot = this._metadata.getSpaceControlPipelineSnapshot(this._spaceKey);
1211
945
  log6("load snapshot", {
1212
946
  key: this._spaceKey,
1213
947
  present: !!snapshot,
1214
948
  tf: snapshot?.timeframe
1215
- }, {
1216
- F: __dxlog_file7,
1217
- L: 123,
1218
- S: this,
1219
- C: (f, a) => f(...a)
1220
- });
949
+ }, { "~LogMeta": "~LogMeta", F: __dxlog_file7, L: 88, S: this });
1221
950
  if (USE_SNAPSHOTS && snapshot) {
1222
951
  await this._processSnapshot(snapshot);
1223
952
  }
1224
- log6("starting...", void 0, {
1225
- F: __dxlog_file7,
1226
- L: 128,
1227
- S: this,
1228
- C: (f, a) => f(...a)
1229
- });
953
+ log6("starting...", void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file7, L: 96, S: this });
1230
954
  setTimeout(async () => {
1231
- void this._consumePipeline(new Context4(void 0, {
1232
- F: __dxlog_file7,
1233
- L: 130
1234
- }));
955
+ void this._consumePipeline(ctx);
1235
956
  });
1236
957
  await this._pipeline.start();
1237
- log6("started", void 0, {
1238
- F: __dxlog_file7,
1239
- L: 134,
1240
- S: this,
1241
- C: (f, a) => f(...a)
1242
- });
958
+ log6("started", void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file7, L: 101, S: this });
1243
959
  }
1244
960
  async _processSnapshot(snapshot) {
1245
961
  await this._pipeline.setCursor(snapshot.timeframe);
@@ -1251,12 +967,7 @@ var ControlPipeline = class {
1251
967
  if (!result) {
1252
968
  log6.warn("credential processing failed from snapshot", {
1253
969
  message
1254
- }, {
1255
- F: __dxlog_file7,
1256
- L: 147,
1257
- S: this,
1258
- C: (f, a) => f(...a)
1259
- });
970
+ }, { "~LogMeta": "~LogMeta", F: __dxlog_file7, L: 111, S: this });
1260
971
  }
1261
972
  }
1262
973
  }
@@ -1273,12 +984,7 @@ var ControlPipeline = class {
1273
984
  log6("save snapshot", {
1274
985
  key: this._spaceKey,
1275
986
  snapshot: getSnapshotLoggerContext(snapshot)
1276
- }, {
1277
- F: __dxlog_file7,
1278
- L: 163,
1279
- S: this,
1280
- C: (f, a) => f(...a)
1281
- });
987
+ }, { "~LogMeta": "~LogMeta", F: __dxlog_file7, L: 127, S: this });
1282
988
  await this._metadata.setSpaceControlPipelineSnapshot(this._spaceKey, snapshot);
1283
989
  }
1284
990
  async _consumePipeline(ctx) {
@@ -1288,12 +994,7 @@ var ControlPipeline = class {
1288
994
  try {
1289
995
  await this._processMessage(ctx, msg);
1290
996
  } catch (err) {
1291
- log6.catch(err, void 0, {
1292
- F: __dxlog_file7,
1293
- L: 176,
1294
- S: this,
1295
- C: (f, a) => f(...a)
1296
- });
997
+ log6.catch(err, void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file7, L: 140, S: this });
1297
998
  }
1298
999
  span.end();
1299
1000
  }
@@ -1302,12 +1003,7 @@ var ControlPipeline = class {
1302
1003
  log6("processing", {
1303
1004
  key: msg.feedKey,
1304
1005
  seq: msg.seq
1305
- }, {
1306
- F: __dxlog_file7,
1307
- L: 185,
1308
- S: this,
1309
- C: (f, a) => f(...a)
1310
- });
1006
+ }, { "~LogMeta": "~LogMeta", F: __dxlog_file7, L: 146, S: this });
1311
1007
  if (msg.data.payload.credential) {
1312
1008
  const timer = tracer.mark("dxos.echo.pipeline.control");
1313
1009
  const result = await this._spaceStateMachine.process(msg.data.payload.credential.credential, {
@@ -1317,12 +1013,7 @@ var ControlPipeline = class {
1317
1013
  if (!result) {
1318
1014
  log6.warn("processing failed", {
1319
1015
  msg
1320
- }, {
1321
- F: __dxlog_file7,
1322
- L: 194,
1323
- S: this,
1324
- C: (f, a) => f(...a)
1325
- });
1016
+ }, { "~LogMeta": "~LogMeta", F: __dxlog_file7, L: 157, S: this });
1326
1017
  } else {
1327
1018
  await this._noteTargetStateIfNeeded(this._pipeline.state.pendingTimeframe);
1328
1019
  }
@@ -1336,21 +1027,11 @@ var ControlPipeline = class {
1336
1027
  }
1337
1028
  }
1338
1029
  async stop() {
1339
- log6("stopping...", void 0, {
1340
- F: __dxlog_file7,
1341
- L: 214,
1342
- S: this,
1343
- C: (f, a) => f(...a)
1344
- });
1030
+ log6("stopping...", void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file7, L: 174, S: this });
1345
1031
  await this._ctx.dispose();
1346
1032
  await this._pipeline.stop();
1347
1033
  await this._saveTargetTimeframe(this._pipeline.state.timeframe);
1348
- log6("stopped", void 0, {
1349
- F: __dxlog_file7,
1350
- L: 218,
1351
- S: this,
1352
- C: (f, a) => f(...a)
1353
- });
1034
+ log6("stopped", void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file7, L: 178, S: this });
1354
1035
  }
1355
1036
  async _saveTargetTimeframe(timeframe) {
1356
1037
  try {
@@ -1358,15 +1039,15 @@ var ControlPipeline = class {
1358
1039
  await this._metadata.setSpaceControlLatestTimeframe(this._spaceKey, newTimeframe);
1359
1040
  this._targetTimeframe = newTimeframe;
1360
1041
  } catch (err) {
1361
- log6(err, void 0, {
1362
- F: __dxlog_file7,
1363
- L: 227,
1364
- S: this,
1365
- C: (f, a) => f(...a)
1366
- });
1042
+ log6(err, void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file7, L: 186, S: this });
1367
1043
  }
1368
1044
  }
1369
1045
  };
1046
+ _ts_decorate4([
1047
+ trace.info({
1048
+ spanAttribute: true
1049
+ })
1050
+ ], ControlPipeline.prototype, "_spaceKey", void 0);
1370
1051
  _ts_decorate4([
1371
1052
  trace.metricsCounter()
1372
1053
  ], ControlPipeline.prototype, "_usage", void 0);
@@ -1375,14 +1056,15 @@ _ts_decorate4([
1375
1056
  ], ControlPipeline.prototype, "_mutations", void 0);
1376
1057
  _ts_decorate4([
1377
1058
  trace.span({
1378
- showInBrowserTimeline: true
1059
+ showInBrowserTimeline: true,
1060
+ op: "lifecycle"
1379
1061
  })
1380
1062
  ], ControlPipeline.prototype, "start", null);
1381
1063
  _ts_decorate4([
1382
- trace.span()
1383
- ], ControlPipeline.prototype, "_consumePipeline", null);
1384
- _ts_decorate4([
1385
- trace.span()
1064
+ trace.span({
1065
+ showInBrowserTimeline: true,
1066
+ showInRemoteTracing: false
1067
+ })
1386
1068
  ], ControlPipeline.prototype, "_processMessage", null);
1387
1069
  ControlPipeline = _ts_decorate4([
1388
1070
  trace.resource(),
@@ -1402,13 +1084,13 @@ var getSnapshotLoggerContext = (snapshot) => {
1402
1084
  };
1403
1085
 
1404
1086
  // src/space/space.ts
1087
+ var __dxlog_file8 = "/__w/dxos/dxos/packages/core/echo/echo-pipeline/src/space/space.ts";
1405
1088
  function _ts_decorate5(decorators, target, key, desc) {
1406
1089
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
1407
1090
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
1408
1091
  else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
1409
1092
  return c > 3 && r && Object.defineProperty(target, key, r), r;
1410
1093
  }
1411
- var __dxlog_file8 = "/__w/dxos/dxos/packages/core/echo/echo-pipeline/src/space/space.ts";
1412
1094
  var Space = class extends Resource {
1413
1095
  onCredentialProcessed = new Callback2();
1414
1096
  stateUpdate = new Event4();
@@ -1422,15 +1104,7 @@ var Space = class extends Resource {
1422
1104
  _dataFeed;
1423
1105
  constructor(params) {
1424
1106
  super();
1425
- invariant6(params.spaceKey && params.feedProvider, void 0, {
1426
- F: __dxlog_file8,
1427
- L: 73,
1428
- S: this,
1429
- A: [
1430
- "params.spaceKey && params.feedProvider",
1431
- ""
1432
- ]
1433
- });
1107
+ invariant6(params.spaceKey && params.feedProvider, void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file8, L: 31, S: this, A: ["params.spaceKey && params.feedProvider", ""] });
1434
1108
  this._id = params.id;
1435
1109
  this._key = params.spaceKey;
1436
1110
  this._genesisFeedKey = params.genesisFeed.key;
@@ -1444,7 +1118,7 @@ var Space = class extends Resource {
1444
1118
  this._controlPipeline.onFeedAdmitted.set(async (info) => {
1445
1119
  const sparse = info.assertion.designation === AdmittedFeed2.Designation.DATA;
1446
1120
  if (!info.key.equals(params.genesisFeed.key)) {
1447
- scheduleMicroTask(this._ctx, async () => {
1121
+ scheduleMicroTask2(this._ctx, async () => {
1448
1122
  await this.protocol.addFeed(await params.feedProvider(info.key, {
1449
1123
  sparse
1450
1124
  }));
@@ -1455,34 +1129,19 @@ var Space = class extends Resource {
1455
1129
  await this.onCredentialProcessed.callIfSet(credential);
1456
1130
  log7("onCredentialProcessed", {
1457
1131
  credential
1458
- }, {
1459
- F: __dxlog_file8,
1460
- L: 100,
1461
- S: this,
1462
- C: (f, a) => f(...a)
1463
- });
1132
+ }, { "~LogMeta": "~LogMeta", F: __dxlog_file8, L: 56, S: this });
1464
1133
  this.stateUpdate.emit();
1465
1134
  });
1466
1135
  this._controlPipeline.onDelegatedInvitation.set(async (invitation) => {
1467
1136
  log7("onDelegatedInvitation", {
1468
1137
  invitation
1469
- }, {
1470
- F: __dxlog_file8,
1471
- L: 104,
1472
- S: this,
1473
- C: (f, a) => f(...a)
1474
- });
1138
+ }, { "~LogMeta": "~LogMeta", F: __dxlog_file8, L: 62, S: this });
1475
1139
  await params.onDelegatedInvitationStatusChange(invitation, true);
1476
1140
  });
1477
1141
  this._controlPipeline.onDelegatedInvitationRemoved.set(async (invitation) => {
1478
1142
  log7("onDelegatedInvitationRemoved", {
1479
1143
  invitation
1480
- }, {
1481
- F: __dxlog_file8,
1482
- L: 108,
1483
- S: this,
1484
- C: (f, a) => f(...a)
1485
- });
1144
+ }, { "~LogMeta": "~LogMeta", F: __dxlog_file8, L: 68, S: this });
1486
1145
  await params.onDelegatedInvitationStatusChange(invitation, false);
1487
1146
  });
1488
1147
  this._controlPipeline.onMemberRoleChanged.set(async (changedMembers) => {
@@ -1491,12 +1150,7 @@ var Space = class extends Resource {
1491
1150
  m.key,
1492
1151
  m.role
1493
1152
  ])
1494
- }), {
1495
- F: __dxlog_file8,
1496
- L: 112,
1497
- S: this,
1498
- C: (f, a) => f(...a)
1499
- });
1153
+ }), { "~LogMeta": "~LogMeta", F: __dxlog_file8, L: 74, S: this });
1500
1154
  await params.onMemberRolesChanged(changedMembers);
1501
1155
  });
1502
1156
  this.protocol = params.protocol;
@@ -1526,29 +1180,13 @@ var Space = class extends Resource {
1526
1180
  return this._controlPipeline.pipeline;
1527
1181
  }
1528
1182
  async setControlFeed(feed) {
1529
- invariant6(!this._controlFeed, "Control feed already set.", {
1530
- F: __dxlog_file8,
1531
- L: 156,
1532
- S: this,
1533
- A: [
1534
- "!this._controlFeed",
1535
- "'Control feed already set.'"
1536
- ]
1537
- });
1183
+ invariant6(!this._controlFeed, "Control feed already set.", { "~LogMeta": "~LogMeta", F: __dxlog_file8, L: 109, S: this, A: ["!this._controlFeed", "'Control feed already set.'"] });
1538
1184
  this._controlFeed = feed;
1539
1185
  await this._controlPipeline.setWriteFeed(feed);
1540
1186
  return this;
1541
1187
  }
1542
1188
  async setDataFeed(feed) {
1543
- invariant6(!this._dataFeed, "Data feed already set.", {
1544
- F: __dxlog_file8,
1545
- L: 163,
1546
- S: this,
1547
- A: [
1548
- "!this._dataFeed",
1549
- "'Data feed already set.'"
1550
- ]
1551
- });
1189
+ invariant6(!this._dataFeed, "Data feed already set.", { "~LogMeta": "~LogMeta", F: __dxlog_file8, L: 115, S: this, A: ["!this._dataFeed", "'Data feed already set.'"] });
1552
1190
  this._dataFeed = feed;
1553
1191
  return this;
1554
1192
  }
@@ -1559,50 +1197,22 @@ var Space = class extends Resource {
1559
1197
  return Array.from(this._controlPipeline.spaceState.feeds.values());
1560
1198
  }
1561
1199
  async _open(ctx) {
1562
- log7("opening...", void 0, {
1563
- F: __dxlog_file8,
1564
- L: 177,
1565
- S: this,
1566
- C: (f, a) => f(...a)
1567
- });
1568
- await this._controlPipeline.start();
1569
- log7("opened", void 0, {
1570
- F: __dxlog_file8,
1571
- L: 182,
1572
- S: this,
1573
- C: (f, a) => f(...a)
1574
- });
1200
+ log7("opening...", void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file8, L: 125, S: this });
1201
+ await this._controlPipeline.start(ctx);
1202
+ log7("opened", void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file8, L: 128, S: this });
1575
1203
  }
1576
- async startProtocol() {
1577
- invariant6(this.isOpen, void 0, {
1578
- F: __dxlog_file8,
1579
- L: 187,
1580
- S: this,
1581
- A: [
1582
- "this.isOpen",
1583
- ""
1584
- ]
1585
- });
1586
- await this.protocol.start();
1204
+ async startProtocol(ctx) {
1205
+ invariant6(this.isOpen, void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file8, L: 131, S: this, A: ["this.isOpen", ""] });
1206
+ await this.protocol.start(ctx);
1587
1207
  await this.protocol.addFeed(await this._feedProvider(this._genesisFeedKey));
1588
1208
  }
1589
- async _close() {
1209
+ async _close(ctx) {
1590
1210
  log7("closing...", {
1591
1211
  key: this._key
1592
- }, {
1593
- F: __dxlog_file8,
1594
- L: 194,
1595
- S: this,
1596
- C: (f, a) => f(...a)
1597
- });
1598
- await this.protocol.stop();
1212
+ }, { "~LogMeta": "~LogMeta", F: __dxlog_file8, L: 136, S: this });
1213
+ await this.protocol.stop(ctx);
1599
1214
  await this._controlPipeline.stop();
1600
- log7("closed", void 0, {
1601
- F: __dxlog_file8,
1602
- L: 200,
1603
- S: this,
1604
- C: (f, a) => f(...a)
1605
- });
1215
+ log7("closed", void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file8, L: 142, S: this });
1606
1216
  }
1607
1217
  };
1608
1218
  _ts_decorate5([
@@ -1620,7 +1230,9 @@ _ts_decorate5([
1620
1230
  trace2.info()
1621
1231
  ], Space.prototype, "key", null);
1622
1232
  _ts_decorate5([
1623
- trace2.span()
1233
+ trace2.span({
1234
+ op: "lifecycle"
1235
+ })
1624
1236
  ], Space.prototype, "_open", null);
1625
1237
  _ts_decorate5([
1626
1238
  synchronized3
@@ -1643,16 +1255,13 @@ var __dxlog_file9 = "/__w/dxos/dxos/packages/core/echo/echo-pipeline/src/space/a
1643
1255
  var CredentialRetrieverExtension = class extends RpcExtension2 {
1644
1256
  _request;
1645
1257
  _onResult;
1646
- _ctx;
1258
+ _ctx = new Context5(void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file9, L: 14 });
1647
1259
  constructor(_request, _onResult) {
1648
1260
  super({
1649
1261
  requested: {
1650
1262
  AdmissionDiscoveryService: schema4.getService("dxos.mesh.teleport.AdmissionDiscoveryService")
1651
1263
  }
1652
- }), this._request = _request, this._onResult = _onResult, this._ctx = new Context5(void 0, {
1653
- F: __dxlog_file9,
1654
- L: 26
1655
- });
1264
+ }), this._request = _request, this._onResult = _onResult;
1656
1265
  }
1657
1266
  async getHandlers() {
1658
1267
  return {};
@@ -1690,7 +1299,12 @@ var CredentialServerExtension = class extends RpcExtension2 {
1690
1299
  getAdmissionCredential: async (request) => {
1691
1300
  const memberInfo = this._space.spaceState.members.get(request.memberKey);
1692
1301
  if (!memberInfo?.credential) {
1693
- throw new ProtocolError("Space member not found.", request);
1302
+ throw new ProtocolError({
1303
+ message: "Space member not found.",
1304
+ context: {
1305
+ ...request
1306
+ }
1307
+ });
1694
1308
  }
1695
1309
  return {
1696
1310
  admissionCredential: memberInfo.credential
@@ -1711,13 +1325,13 @@ import { BlobSync } from "@dxos/teleport-extension-object-sync";
1711
1325
  import { ReplicatorExtension } from "@dxos/teleport-extension-replicator";
1712
1326
  import { trace as trace3 } from "@dxos/tracing";
1713
1327
  import { CallbackCollection, ComplexMap as ComplexMap4 } from "@dxos/util";
1328
+ var __dxlog_file10 = "/__w/dxos/dxos/packages/core/echo/echo-pipeline/src/space/space-protocol.ts";
1714
1329
  function _ts_decorate6(decorators, target, key, desc) {
1715
1330
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
1716
1331
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
1717
1332
  else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
1718
1333
  return c > 3 && r && Object.defineProperty(target, key, r), r;
1719
1334
  }
1720
- var __dxlog_file10 = "/__w/dxos/dxos/packages/core/echo/echo-pipeline/src/space/space-protocol.ts";
1721
1335
  var MOCK_AUTH_PROVIDER = async (nonce) => Buffer.from("mock");
1722
1336
  var MOCK_AUTH_VERIFIER = async (nonce, credential) => true;
1723
1337
  var SpaceProtocol = class {
@@ -1764,12 +1378,7 @@ var SpaceProtocol = class {
1764
1378
  async addFeed(feed) {
1765
1379
  log8("addFeed", {
1766
1380
  key: feed.key
1767
- }, {
1768
- F: __dxlog_file10,
1769
- L: 131,
1770
- S: this,
1771
- C: (f, a) => f(...a)
1772
- });
1381
+ }, { "~LogMeta": "~LogMeta", F: __dxlog_file10, L: 65, S: this });
1773
1382
  this._feeds.add(feed);
1774
1383
  for (const session of this._sessions.values()) {
1775
1384
  session.replicator.addFeed(feed);
@@ -1777,64 +1386,44 @@ var SpaceProtocol = class {
1777
1386
  await this.feedAdded.callSerial(feed);
1778
1387
  }
1779
1388
  // TODO(burdon): Rename open? Common open/close interfaces for all services?
1780
- async start() {
1389
+ async start(ctx) {
1781
1390
  if (this._connection) {
1782
1391
  return;
1783
1392
  }
1784
1393
  const credentials = await this._swarmIdentity.credentialProvider(Buffer.from(""));
1785
1394
  await this.blobSync.open();
1786
- log8("starting...", void 0, {
1787
- F: __dxlog_file10,
1788
- L: 152,
1789
- S: this,
1790
- C: (f, a) => f(...a)
1791
- });
1395
+ log8("starting...", void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file10, L: 82, S: this });
1792
1396
  const topic = await this._topic;
1793
- this._connection = await this._networkManager.joinSwarm({
1397
+ this._connection = await this._networkManager.joinSwarm(ctx, {
1794
1398
  protocolProvider: this._createProtocolProvider(credentials),
1795
1399
  topic,
1796
1400
  topology: this._topology,
1797
1401
  label: `swarm ${topic.truncate()} for space ${this._spaceKey.truncate()}`
1798
1402
  });
1799
- log8("started", void 0, {
1800
- F: __dxlog_file10,
1801
- L: 161,
1802
- S: this,
1803
- C: (f, a) => f(...a)
1804
- });
1403
+ log8("started", void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file10, L: 90, S: this });
1805
1404
  }
1806
1405
  updateTopology() {
1807
1406
  this._topology.forceUpdate();
1808
1407
  }
1809
- async stop() {
1408
+ async stop(ctx) {
1810
1409
  await this.blobSync.close();
1811
1410
  if (this._connection) {
1812
- log8("stopping...", void 0, {
1813
- F: __dxlog_file10,
1814
- L: 172,
1815
- S: this,
1816
- C: (f, a) => f(...a)
1817
- });
1818
- await this._connection.close();
1819
- log8("stopped", void 0, {
1820
- F: __dxlog_file10,
1821
- L: 174,
1822
- S: this,
1823
- C: (f, a) => f(...a)
1824
- });
1411
+ log8("stopping...", void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file10, L: 98, S: this });
1412
+ await this._connection.close(ctx);
1413
+ log8("stopped", void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file10, L: 100, S: this });
1825
1414
  }
1826
1415
  }
1827
1416
  _createProtocolProvider(credentials) {
1828
- return (wireParams) => {
1417
+ return (wireProps) => {
1829
1418
  const session = new SpaceProtocolSession({
1830
- wireParams,
1419
+ wireProps,
1831
1420
  swarmIdentity: this._swarmIdentity,
1832
1421
  onSessionAuth: this._onSessionAuth,
1833
1422
  onAuthFailure: this._onAuthFailure,
1834
1423
  blobSync: this.blobSync,
1835
1424
  disableP2pReplication: this._disableP2pReplication
1836
1425
  });
1837
- this._sessions.set(wireParams.remotePeerId, session);
1426
+ this._sessions.set(wireProps.remotePeerId, session);
1838
1427
  for (const feed of this._feeds) {
1839
1428
  session.replicator.addFeed(feed);
1840
1429
  }
@@ -1855,14 +1444,14 @@ _ts_decorate6([
1855
1444
  SpaceProtocol = _ts_decorate6([
1856
1445
  trace3.resource()
1857
1446
  ], SpaceProtocol);
1858
- var AuthStatus = /* @__PURE__ */ function(AuthStatus2) {
1447
+ var AuthStatus = /* @__PURE__ */ (function(AuthStatus2) {
1859
1448
  AuthStatus2["INITIAL"] = "INITIAL";
1860
1449
  AuthStatus2["SUCCESS"] = "SUCCESS";
1861
1450
  AuthStatus2["FAILURE"] = "FAILURE";
1862
1451
  return AuthStatus2;
1863
- }({});
1452
+ })({});
1864
1453
  var SpaceProtocolSession = class {
1865
- _wireParams;
1454
+ _wireProps;
1866
1455
  _disableP2pReplication;
1867
1456
  _onSessionAuth;
1868
1457
  _onAuthFailure;
@@ -1881,13 +1470,13 @@ var SpaceProtocolSession = class {
1881
1470
  return this._teleport.stats;
1882
1471
  }
1883
1472
  // TODO(dmaretskyi): Allow to pass in extra extensions.
1884
- constructor({ wireParams, swarmIdentity, onSessionAuth, onAuthFailure, blobSync, disableP2pReplication }) {
1885
- this._wireParams = wireParams;
1473
+ constructor({ wireProps, swarmIdentity, onSessionAuth, onAuthFailure, blobSync, disableP2pReplication }) {
1474
+ this._wireProps = wireProps;
1886
1475
  this._swarmIdentity = swarmIdentity;
1887
1476
  this._onSessionAuth = onSessionAuth;
1888
1477
  this._onAuthFailure = onAuthFailure;
1889
1478
  this._blobSync = blobSync;
1890
- this._teleport = new Teleport(wireParams);
1479
+ this._teleport = new Teleport(wireProps);
1891
1480
  this._disableP2pReplication = disableP2pReplication ?? false;
1892
1481
  }
1893
1482
  get stream() {
@@ -1899,12 +1488,7 @@ var SpaceProtocolSession = class {
1899
1488
  provider: this._swarmIdentity.credentialProvider,
1900
1489
  verifier: this._swarmIdentity.credentialAuthenticator,
1901
1490
  onAuthSuccess: () => {
1902
- log8("Peer authenticated", void 0, {
1903
- F: __dxlog_file10,
1904
- L: 285,
1905
- S: this,
1906
- C: (f, a) => f(...a)
1907
- });
1491
+ log8("Peer authenticated", void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file10, L: 181, S: this });
1908
1492
  this._authStatus = "SUCCESS";
1909
1493
  this._onSessionAuth?.(this._teleport);
1910
1494
  },
@@ -1919,12 +1503,7 @@ var SpaceProtocolSession = class {
1919
1503
  this._teleport.addExtension("dxos.mesh.teleport.blobsync", this._blobSync.createExtension());
1920
1504
  }
1921
1505
  async close() {
1922
- log8("close", void 0, {
1923
- F: __dxlog_file10,
1924
- L: 304,
1925
- S: this,
1926
- C: (f, a) => f(...a)
1927
- });
1506
+ log8("close", void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file10, L: 197, S: this });
1928
1507
  await this._teleport.close();
1929
1508
  }
1930
1509
  async abort() {
@@ -1933,7 +1512,7 @@ var SpaceProtocolSession = class {
1933
1512
  };
1934
1513
  _ts_decorate6([
1935
1514
  logInfo2
1936
- ], SpaceProtocolSession.prototype, "_wireParams", void 0);
1515
+ ], SpaceProtocolSession.prototype, "_wireProps", void 0);
1937
1516
  _ts_decorate6([
1938
1517
  logInfo2
1939
1518
  ], SpaceProtocolSession.prototype, "authStatus", null);
@@ -1945,22 +1524,20 @@ import { getCredentialAssertion } from "@dxos/credentials";
1945
1524
  import { failUndefined as failUndefined2 } from "@dxos/debug";
1946
1525
  import { PublicKey as PublicKey6 } from "@dxos/keys";
1947
1526
  import { log as log9 } from "@dxos/log";
1948
- import { trace as trace4 } from "@dxos/protocols";
1949
1527
  import { ComplexMap as ComplexMap5 } from "@dxos/util";
1528
+ var __dxlog_file11 = "/__w/dxos/dxos/packages/core/echo/echo-pipeline/src/space/space-manager.ts";
1950
1529
  function _ts_decorate7(decorators, target, key, desc) {
1951
1530
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
1952
1531
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
1953
1532
  else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
1954
1533
  return c > 3 && r && Object.defineProperty(target, key, r), r;
1955
1534
  }
1956
- var __dxlog_file11 = "/__w/dxos/dxos/packages/core/echo/echo-pipeline/src/space/space-manager.ts";
1957
1535
  var SpaceManager = class {
1958
1536
  _spaces = new ComplexMap5(PublicKey6.hash);
1959
1537
  _feedStore;
1960
1538
  _networkManager;
1961
1539
  _metadataStore;
1962
1540
  _blobStore;
1963
- _instanceId = PublicKey6.random().toHex();
1964
1541
  _disableP2pReplication;
1965
1542
  constructor({ feedStore, networkManager, metadataStore, blobStore, disableP2pReplication }) {
1966
1543
  this._feedStore = feedStore;
@@ -1981,22 +1558,9 @@ var SpaceManager = class {
1981
1558
  ].map((space) => space.close()));
1982
1559
  }
1983
1560
  async constructSpace({ metadata, swarmIdentity, onAuthorizedConnection, onAuthFailure, onDelegatedInvitationStatusChange, onMemberRolesChanged, memberKey }) {
1984
- log9.trace("dxos.echo.space-manager.construct-space", trace4.begin({
1985
- id: this._instanceId
1986
- }), {
1987
- F: __dxlog_file11,
1988
- L: 103,
1989
- S: this,
1990
- C: (f, a) => f(...a)
1991
- });
1992
1561
  log9("constructing space...", {
1993
1562
  spaceKey: metadata.genesisFeedKey
1994
- }, {
1995
- F: __dxlog_file11,
1996
- L: 104,
1997
- S: this,
1998
- C: (f, a) => f(...a)
1999
- });
1563
+ }, { "~LogMeta": "~LogMeta", F: __dxlog_file11, L: 47, S: this });
2000
1564
  const genesisFeed = await this._feedStore.openFeed(metadata.genesisFeedKey ?? failUndefined2());
2001
1565
  const spaceKey = metadata.key;
2002
1566
  const spaceId = await createIdFromSpaceKey(spaceKey);
@@ -2021,34 +1585,12 @@ var SpaceManager = class {
2021
1585
  onMemberRolesChanged
2022
1586
  });
2023
1587
  this._spaces.set(space.key, space);
2024
- log9.trace("dxos.echo.space-manager.construct-space", trace4.end({
2025
- id: this._instanceId
2026
- }), {
2027
- F: __dxlog_file11,
2028
- L: 134,
2029
- S: this,
2030
- C: (f, a) => f(...a)
2031
- });
2032
1588
  return space;
2033
1589
  }
2034
- async requestSpaceAdmissionCredential(params) {
2035
- const traceKey = "dxos.echo.space-manager.request-space-admission";
2036
- log9.trace(traceKey, trace4.begin({
2037
- id: this._instanceId
2038
- }), {
2039
- F: __dxlog_file11,
2040
- L: 140,
2041
- S: this,
2042
- C: (f, a) => f(...a)
2043
- });
1590
+ async requestSpaceAdmissionCredential(ctx, params) {
2044
1591
  log9("requesting space admission credential...", {
2045
1592
  spaceKey: params.spaceKey
2046
- }, {
2047
- F: __dxlog_file11,
2048
- L: 141,
2049
- S: this,
2050
- C: (f, a) => f(...a)
2051
- });
1593
+ }, { "~LogMeta": "~LogMeta", F: __dxlog_file11, L: 78, S: this });
2052
1594
  const onCredentialResolved = new Trigger2();
2053
1595
  const protocol = new SpaceProtocol({
2054
1596
  topic: params.spaceKey,
@@ -2065,32 +1607,15 @@ var SpaceManager = class {
2065
1607
  disableP2pReplication: this._disableP2pReplication
2066
1608
  });
2067
1609
  try {
2068
- await protocol.start();
1610
+ await protocol.start(ctx);
2069
1611
  const credential = await onCredentialResolved.wait({
2070
1612
  timeout: params.timeout
2071
1613
  });
2072
- log9.trace(traceKey, trace4.end({
2073
- id: this._instanceId
2074
- }), {
2075
- F: __dxlog_file11,
2076
- L: 165,
2077
- S: this,
2078
- C: (f, a) => f(...a)
2079
- });
2080
1614
  return credential;
2081
1615
  } catch (err) {
2082
- log9.trace(traceKey, trace4.error({
2083
- id: this._instanceId,
2084
- error: err
2085
- }), {
2086
- F: __dxlog_file11,
2087
- L: 168,
2088
- S: this,
2089
- C: (f, a) => f(...a)
2090
- });
2091
1616
  throw err;
2092
1617
  } finally {
2093
- await protocol.stop();
1618
+ await protocol.stop(ctx);
2094
1619
  }
2095
1620
  }
2096
1621
  findSpaceByRootDocumentId(documentId) {
@@ -2143,4 +1668,4 @@ export {
2143
1668
  SpaceProtocolSession,
2144
1669
  SpaceManager
2145
1670
  };
2146
- //# sourceMappingURL=chunk-2543T5DX.mjs.map
1671
+ //# sourceMappingURL=chunk-VIHYDCCC.mjs.map