@dxos/echo-pipeline 0.1.53-main.706990e → 0.1.53-main.770f0f5

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 (47) hide show
  1. package/dist/lib/browser/{chunk-RD75WUUV.mjs → chunk-RFRZMQ5T.mjs} +444 -393
  2. package/dist/lib/browser/chunk-RFRZMQ5T.mjs.map +7 -0
  3. package/dist/lib/browser/index.mjs +2 -2
  4. package/dist/lib/browser/index.mjs.map +1 -1
  5. package/dist/lib/browser/meta.json +1 -1
  6. package/dist/lib/browser/testing/index.mjs +3 -3
  7. package/dist/lib/browser/testing/index.mjs.map +2 -2
  8. package/dist/lib/node/index.cjs +512 -461
  9. package/dist/lib/node/index.cjs.map +3 -3
  10. package/dist/lib/node/meta.json +1 -1
  11. package/dist/lib/node/testing/index.cjs +502 -451
  12. package/dist/lib/node/testing/index.cjs.map +3 -3
  13. package/dist/types/src/dbhost/data-service-host.d.ts +3 -0
  14. package/dist/types/src/dbhost/data-service-host.d.ts.map +1 -1
  15. package/dist/types/src/dbhost/data-service.d.ts +2 -2
  16. package/dist/types/src/dbhost/data-service.d.ts.map +1 -1
  17. package/dist/types/src/dbhost/snapshot-store.d.ts +3 -0
  18. package/dist/types/src/dbhost/snapshot-store.d.ts.map +1 -1
  19. package/dist/types/src/metadata/metadata-store.d.ts +4 -0
  20. package/dist/types/src/metadata/metadata-store.d.ts.map +1 -1
  21. package/dist/types/src/pipeline/message-selector.d.ts.map +1 -1
  22. package/dist/types/src/pipeline/pipeline.d.ts +0 -1
  23. package/dist/types/src/pipeline/pipeline.d.ts.map +1 -1
  24. package/dist/types/src/space/data-pipeline.d.ts +3 -3
  25. package/dist/types/src/space/data-pipeline.d.ts.map +1 -1
  26. package/dist/types/src/space/space-protocol.d.ts +3 -0
  27. package/dist/types/src/space/space-protocol.d.ts.map +1 -1
  28. package/dist/types/src/space/space.d.ts +0 -1
  29. package/dist/types/src/space/space.d.ts.map +1 -1
  30. package/package.json +31 -32
  31. package/src/common/feeds.ts +3 -3
  32. package/src/dbhost/data-service-host.ts +17 -4
  33. package/src/dbhost/data-service.ts +10 -6
  34. package/src/dbhost/snapshot-store.ts +3 -0
  35. package/src/metadata/metadata-store.ts +20 -6
  36. package/src/pipeline/message-selector.ts +3 -5
  37. package/src/pipeline/pipeline.ts +24 -12
  38. package/src/space/auth.ts +3 -3
  39. package/src/space/data-pipeline.ts +35 -29
  40. package/src/space/space-protocol.browser.test.ts +2 -2
  41. package/src/space/space-protocol.test.ts +2 -2
  42. package/src/space/space-protocol.ts +10 -4
  43. package/src/space/space.test.ts +46 -5
  44. package/src/space/space.ts +8 -17
  45. package/src/testing/util.ts +1 -1
  46. package/src/tests/database.test.ts +1 -1
  47. package/dist/lib/browser/chunk-RD75WUUV.mjs.map +0 -7
@@ -1,13 +1,15 @@
1
- import "@dxos/node-std/globals"
1
+ import "@dxos/node-std/globals";
2
2
 
3
3
  // packages/core/echo/echo-pipeline/src/metadata/metadata-store.ts
4
4
  import CRC32 from "crc-32";
5
- import assert from "@dxos/node-std/assert";
5
+ import invariant from "tiny-invariant";
6
6
  import { synchronized, Event } from "@dxos/async";
7
7
  import { DataCorruptionError } from "@dxos/errors";
8
8
  import { log } from "@dxos/log";
9
9
  import { STORAGE_VERSION, schema } from "@dxos/protocols";
10
- var __decorate = function(decorators, target, key, desc) {
10
+ import { SpaceState } from "@dxos/protocols/proto/dxos/client/services";
11
+ import { arrayToBuffer } from "@dxos/util";
12
+ function _ts_decorate(decorators, target, key, desc) {
11
13
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
12
14
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
13
15
  r = Reflect.decorate(decorators, target, key, desc);
@@ -16,13 +18,15 @@ var __decorate = function(decorators, target, key, desc) {
16
18
  if (d = decorators[i])
17
19
  r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
18
20
  return c > 3 && r && Object.defineProperty(target, key, r), r;
19
- };
21
+ }
22
+ var __dxlog_file = "/home/runner/work/dxos/dxos/packages/core/echo/echo-pipeline/src/metadata/metadata-store.ts";
20
23
  var emptyEchoMetadata = () => ({
21
24
  version: STORAGE_VERSION,
22
25
  spaces: [],
23
26
  created: new Date(),
24
27
  updated: new Date()
25
28
  });
29
+ var EchoMetadata = schema.getCodecForType("dxos.echo.metadata.EchoMetadata");
26
30
  var MetadataStore = class {
27
31
  // prettier-ignore
28
32
  constructor(_directory) {
@@ -49,6 +53,7 @@ var MetadataStore = class {
49
53
  * Loads metadata from persistent storage.
50
54
  */
51
55
  async load() {
56
+ var _a;
52
57
  const file = this._directory.getOrCreateFile("EchoMetadata");
53
58
  try {
54
59
  const { size: fileLength } = await file.stat();
@@ -61,10 +66,10 @@ var MetadataStore = class {
61
66
  size: dataSize,
62
67
  checksum
63
68
  }, {
64
- file: "metadata-store.ts",
65
- line: 68,
66
- scope: this,
67
- callSite: (f, a) => f(...a)
69
+ F: __dxlog_file,
70
+ L: 72,
71
+ S: this,
72
+ C: (f, a) => f(...a)
68
73
  });
69
74
  if (fileLength < dataSize + 8) {
70
75
  throw new DataCorruptionError("Metadata size is smaller than expected.");
@@ -74,15 +79,19 @@ var MetadataStore = class {
74
79
  if (calculatedChecksum !== checksum) {
75
80
  throw new DataCorruptionError("Metadata checksum is invalid.");
76
81
  }
77
- this._metadata = schema.getCodecForType("dxos.echo.metadata.EchoMetadata").decode(data);
82
+ this._metadata = EchoMetadata.decode(data);
83
+ (_a = this._metadata.spaces) == null ? void 0 : _a.forEach((space) => {
84
+ var _a2;
85
+ (_a2 = space.state) != null ? _a2 : space.state = SpaceState.ACTIVE;
86
+ });
78
87
  } catch (err) {
79
88
  log.error("failed to load metadata", {
80
89
  err
81
90
  }, {
82
- file: "metadata-store.ts",
83
- line: 83,
84
- scope: this,
85
- callSite: (f, a) => f(...a)
91
+ F: __dxlog_file,
92
+ L: 92,
93
+ S: this,
94
+ C: (f, a) => f(...a)
86
95
  });
87
96
  this._metadata = emptyEchoMetadata();
88
97
  } finally {
@@ -100,7 +109,7 @@ var MetadataStore = class {
100
109
  this.update.emit(data);
101
110
  const file = this._directory.getOrCreateFile("EchoMetadata");
102
111
  try {
103
- const encoded = Buffer.from(schema.getCodecForType("dxos.echo.metadata.EchoMetadata").encode(data));
112
+ const encoded = arrayToBuffer(EchoMetadata.encode(data));
104
113
  const checksum = CRC32.buf(encoded);
105
114
  const result = Buffer.alloc(8 + encoded.length);
106
115
  result.writeInt32LE(encoded.length, 0);
@@ -111,10 +120,10 @@ var MetadataStore = class {
111
120
  size: encoded.length,
112
121
  checksum
113
122
  }, {
114
- file: "metadata-store.ts",
115
- line: 115,
116
- scope: this,
117
- callSite: (f, a) => f(...a)
123
+ F: __dxlog_file,
124
+ L: 124,
125
+ S: this,
126
+ C: (f, a) => f(...a)
118
127
  });
119
128
  } finally {
120
129
  await file.close();
@@ -126,18 +135,18 @@ var MetadataStore = class {
126
135
  return this._metadata.identity.haloSpace;
127
136
  }
128
137
  const space = this.spaces.find((space2) => space2.key === spaceKey);
129
- assert(space, "Space not found");
138
+ invariant(space, "Space not found");
130
139
  return space;
131
140
  }
132
141
  /**
133
142
  * Clears storage - doesn't work for now.
134
143
  */
135
144
  async clear() {
136
- log("clearing all metadata", {}, {
137
- file: "metadata-store.ts",
138
- line: 136,
139
- scope: this,
140
- callSite: (f, a) => f(...a)
145
+ log("clearing all metadata", void 0, {
146
+ F: __dxlog_file,
147
+ L: 145,
148
+ S: this,
149
+ C: (f, a) => f(...a)
141
150
  });
142
151
  await this._directory.delete();
143
152
  this._metadata = emptyEchoMetadata();
@@ -146,13 +155,13 @@ var MetadataStore = class {
146
155
  return this._metadata.identity;
147
156
  }
148
157
  async setIdentityRecord(record) {
149
- assert(!this._metadata.identity, "Cannot overwrite existing identity in metadata");
158
+ invariant(!this._metadata.identity, "Cannot overwrite existing identity in metadata");
150
159
  this._metadata.identity = record;
151
160
  await this._save();
152
161
  }
153
162
  async addSpace(record) {
154
163
  var _a, _b, _c;
155
- assert(!((_a = this._metadata.spaces) != null ? _a : []).find((space) => space.key === record.key), "Cannot overwrite existing space in metadata");
164
+ invariant(!((_a = this._metadata.spaces) != null ? _a : []).find((space) => space.key === record.key), "Cannot overwrite existing space in metadata");
156
165
  ((_c = (_b = this._metadata).spaces) != null ? _c : _b.spaces = []).push(record);
157
166
  await this._save();
158
167
  }
@@ -174,11 +183,15 @@ var MetadataStore = class {
174
183
  space.dataFeedKey = dataFeedKey;
175
184
  await this._save();
176
185
  }
186
+ async setSpaceState(spaceKey, state) {
187
+ this._getSpace(spaceKey).state = state;
188
+ await this._save();
189
+ }
177
190
  };
178
- __decorate([
191
+ _ts_decorate([
179
192
  synchronized
180
193
  ], MetadataStore.prototype, "load", null);
181
- __decorate([
194
+ _ts_decorate([
182
195
  synchronized
183
196
  ], MetadataStore.prototype, "_save", null);
184
197
  var fromBytesInt32 = (buf) => buf.readInt32LE(0);
@@ -190,10 +203,10 @@ var codec = schema2.getCodecForType("dxos.echo.feed.FeedMessage");
190
203
  var valueEncoding = createCodecEncoding(codec);
191
204
 
192
205
  // packages/core/echo/echo-pipeline/src/common/feeds.ts
193
- import assert2 from "@dxos/node-std/assert";
206
+ import invariant2 from "tiny-invariant";
194
207
  var createMappedFeedWriter = (mapper, writer) => {
195
- assert2(mapper);
196
- assert2(writer);
208
+ invariant2(mapper);
209
+ invariant2(writer);
197
210
  return {
198
211
  write: async (data, options) => await writer.write(await mapper(data), options)
199
212
  };
@@ -204,7 +217,7 @@ import { Event as Event2 } from "@dxos/async";
204
217
  import { timed } from "@dxos/debug";
205
218
  import { log as log2 } from "@dxos/log";
206
219
  import { Timeframe } from "@dxos/timeframe";
207
- var __decorate2 = function(decorators, target, key, desc) {
220
+ function _ts_decorate2(decorators, target, key, desc) {
208
221
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
209
222
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
210
223
  r = Reflect.decorate(decorators, target, key, desc);
@@ -213,7 +226,8 @@ var __decorate2 = function(decorators, target, key, desc) {
213
226
  if (d = decorators[i])
214
227
  r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
215
228
  return c > 3 && r && Object.defineProperty(target, key, r), r;
216
- };
229
+ }
230
+ var __dxlog_file2 = "/home/runner/work/dxos/dxos/packages/core/echo/echo-pipeline/src/pipeline/timeframe-clock.ts";
217
231
  var mapTimeframeToFeedIndexes = (timeframe) => timeframe.frames().map(([feedKey, index]) => ({
218
232
  feedKey,
219
233
  index
@@ -272,10 +286,10 @@ var TimeframeClock = class {
272
286
  target,
273
287
  current: this._timeframe
274
288
  }, {
275
- file: "timeframe-clock.ts",
276
- line: 73,
277
- scope: this,
278
- callSite: (f, a) => f(...a)
289
+ F: __dxlog_file2,
290
+ L: 73,
291
+ S: this,
292
+ C: (f, a) => f(...a)
279
293
  });
280
294
  await this.update.waitForCondition(() => {
281
295
  log2("check if reached", {
@@ -283,21 +297,21 @@ var TimeframeClock = class {
283
297
  current: this._timeframe,
284
298
  deps: Timeframe.dependencies(target, this._timeframe)
285
299
  }, {
286
- file: "timeframe-clock.ts",
287
- line: 75,
288
- scope: this,
289
- callSite: (f, a) => f(...a)
300
+ F: __dxlog_file2,
301
+ L: 75,
302
+ S: this,
303
+ C: (f, a) => f(...a)
290
304
  });
291
305
  return Timeframe.dependencies(target, this._timeframe).isEmpty();
292
306
  });
293
307
  }
294
308
  };
295
- __decorate2([
309
+ _ts_decorate2([
296
310
  timed(5e3)
297
311
  ], TimeframeClock.prototype, "waitUntilReached", null);
298
312
 
299
313
  // packages/core/echo/echo-pipeline/src/pipeline/pipeline.ts
300
- import assert4 from "@dxos/node-std/assert";
314
+ import invariant4 from "tiny-invariant";
301
315
  import { Event as Event3, sleep, synchronized as synchronized2, Trigger } from "@dxos/async";
302
316
  import { Context, rejectOnDispose } from "@dxos/context";
303
317
  import { failUndefined } from "@dxos/debug";
@@ -308,24 +322,29 @@ import { Timeframe as Timeframe2 } from "@dxos/timeframe";
308
322
  import { ComplexMap } from "@dxos/util";
309
323
 
310
324
  // packages/core/echo/echo-pipeline/src/pipeline/message-selector.ts
311
- import debug from "debug";
312
- import assert3 from "@dxos/node-std/assert";
313
- var log3 = debug("dxos:echo-db:message-selector");
325
+ import invariant3 from "tiny-invariant";
326
+ import { log as log3 } from "@dxos/log";
327
+ var __dxlog_file3 = "/home/runner/work/dxos/dxos/packages/core/echo/echo-pipeline/src/pipeline/message-selector.ts";
314
328
  var createMessageSelector = (timeframeClock) => {
315
329
  return (messages) => {
316
330
  for (let i = 0; i < messages.length; i++) {
317
331
  const { data: { timeframe } } = messages[i];
318
- assert3(timeframe);
332
+ invariant3(timeframe);
319
333
  if (!timeframeClock.hasGaps(timeframe)) {
320
334
  return i;
321
335
  }
322
336
  }
323
- log3("Skipping...");
337
+ log3("Skipping...", void 0, {
338
+ F: __dxlog_file3,
339
+ L: 34,
340
+ S: void 0,
341
+ C: (f, a) => f(...a)
342
+ });
324
343
  };
325
344
  };
326
345
 
327
346
  // packages/core/echo/echo-pipeline/src/pipeline/pipeline.ts
328
- var __decorate3 = function(decorators, target, key, desc) {
347
+ function _ts_decorate3(decorators, target, key, desc) {
329
348
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
330
349
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
331
350
  r = Reflect.decorate(decorators, target, key, desc);
@@ -334,12 +353,14 @@ var __decorate3 = function(decorators, target, key, desc) {
334
353
  if (d = decorators[i])
335
354
  r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
336
355
  return c > 3 && r && Object.defineProperty(target, key, r), r;
337
- };
356
+ }
357
+ var __dxlog_file4 = "/home/runner/work/dxos/dxos/packages/core/echo/echo-pipeline/src/pipeline/pipeline.ts";
338
358
  var PipelineState = class {
339
359
  // prettier-ignore
340
360
  constructor(_feeds, _timeframeClock) {
341
361
  this._feeds = _feeds;
342
362
  this._timeframeClock = _timeframeClock;
363
+ this._ctx = new Context();
343
364
  this.timeframeUpdate = this._timeframeClock.update;
344
365
  this.stalled = new Event3();
345
366
  this._startTimeframe = new Timeframe2();
@@ -390,10 +411,10 @@ var PipelineState = class {
390
411
  current: this.timeframe,
391
412
  target: this.targetTimeframe
392
413
  }, {
393
- file: "pipeline.ts",
394
- line: 118,
395
- scope: this,
396
- callSite: (f, a) => f(...a)
414
+ F: __dxlog_file4,
415
+ L: 126,
416
+ S: this,
417
+ C: (f, a) => f(...a)
397
418
  });
398
419
  (_a = this._reachedTargetPromise) != null ? _a : this._reachedTargetPromise = Promise.race([
399
420
  this._timeframeClock.update.waitForCondition(() => {
@@ -407,6 +428,7 @@ var PipelineState = class {
407
428
  if (timeout) {
408
429
  return Promise.race([
409
430
  rejectOnDispose(ctx),
431
+ rejectOnDispose(this._ctx),
410
432
  this._reachedTargetPromise.then(() => {
411
433
  done = true;
412
434
  }),
@@ -420,10 +442,10 @@ var PipelineState = class {
420
442
  target: this.targetTimeframe,
421
443
  dependencies: Timeframe2.dependencies(this.targetTimeframe, this.timeframe)
422
444
  }, {
423
- file: "pipeline.ts",
424
- line: 144,
425
- scope: this,
426
- callSite: (f, a) => f(...a)
445
+ F: __dxlog_file4,
446
+ L: 153,
447
+ S: this,
448
+ C: (f, a) => f(...a)
427
449
  });
428
450
  })
429
451
  ]);
@@ -450,7 +472,7 @@ var Pipeline = class {
450
472
  return this._state;
451
473
  }
452
474
  get writer() {
453
- assert4(this._writer, "Writer not set.");
475
+ invariant4(this._writer, "Writer not set.");
454
476
  return this._writer;
455
477
  }
456
478
  getFeeds() {
@@ -469,8 +491,8 @@ var Pipeline = class {
469
491
  return this._feeds.has(feedKey);
470
492
  }
471
493
  setWriteFeed(feed) {
472
- assert4(!this._writer, "Writer already set.");
473
- assert4(feed.properties.writable, "Feed must be writable.");
494
+ invariant4(!this._writer, "Writer already set.");
495
+ invariant4(feed.properties.writable, "Feed must be writable.");
474
496
  this._writer = createMappedFeedWriter((payload) => ({
475
497
  timeframe: this._timeframeClock.timeframe,
476
498
  payload
@@ -478,37 +500,40 @@ var Pipeline = class {
478
500
  }
479
501
  async start() {
480
502
  log4("starting...", {}, {
481
- file: "pipeline.ts",
482
- line: 264,
483
- scope: this,
484
- callSite: (f, a) => f(...a)
503
+ F: __dxlog_file4,
504
+ L: 273,
505
+ S: this,
506
+ C: (f, a) => f(...a)
485
507
  });
486
508
  await this._initIterator();
487
509
  await this._feedSetIterator.open();
488
- log4("started", {}, {
489
- file: "pipeline.ts",
490
- line: 267,
491
- scope: this,
492
- callSite: (f, a) => f(...a)
510
+ log4("started", void 0, {
511
+ F: __dxlog_file4,
512
+ L: 276,
513
+ S: this,
514
+ C: (f, a) => f(...a)
493
515
  });
494
516
  this._isStarted = true;
495
517
  }
496
518
  async stop() {
497
519
  var _a;
498
520
  log4("stopping...", {}, {
499
- file: "pipeline.ts",
500
- line: 273,
501
- scope: this,
502
- callSite: (f, a) => f(...a)
521
+ F: __dxlog_file4,
522
+ L: 282,
523
+ S: this,
524
+ C: (f, a) => f(...a)
503
525
  });
504
526
  this._isStopping = true;
505
527
  await ((_a = this._feedSetIterator) == null ? void 0 : _a.close());
506
528
  await this._processingTrigger.wait();
507
- log4("stopped", {}, {
508
- file: "pipeline.ts",
509
- line: 277,
510
- scope: this,
511
- callSite: (f, a) => f(...a)
529
+ await this._state._ctx.dispose();
530
+ this._state._ctx = new Context();
531
+ this._state._reachedTargetPromise = void 0;
532
+ log4("stopped", void 0, {
533
+ F: __dxlog_file4,
534
+ L: 289,
535
+ S: this,
536
+ C: (f, a) => f(...a)
512
537
  });
513
538
  this._isStarted = false;
514
539
  }
@@ -516,7 +541,7 @@ var Pipeline = class {
516
541
  * @param timeframe Timeframe of already processed messages. The pipeline will start processing messages AFTER this timeframe.
517
542
  */
518
543
  async setCursor(timeframe) {
519
- assert4(!this._isStarted || this._isPaused, "Invalid state.");
544
+ invariant4(!this._isStarted || this._isPaused, "Invalid state.");
520
545
  this._state._startTimeframe = timeframe;
521
546
  this._timeframeClock.setTimeframe(timeframe);
522
547
  for (const feed of this._feeds.values()) {
@@ -532,7 +557,7 @@ var Pipeline = class {
532
557
  * Calling pause while processing will cause a deadlock.
533
558
  */
534
559
  async pause() {
535
- assert4(this._isStarted, "Pipeline is not open.");
560
+ invariant4(this._isStarted, "Pipeline is not open.");
536
561
  if (this._isPaused) {
537
562
  return;
538
563
  }
@@ -541,8 +566,8 @@ var Pipeline = class {
541
566
  this._isPaused = true;
542
567
  }
543
568
  async unpause() {
544
- assert4(this._isStarted, "Pipeline is not open.");
545
- assert4(this._isPaused, "Pipeline is not paused.");
569
+ invariant4(this._isStarted, "Pipeline is not open.");
570
+ invariant4(this._isPaused, "Pipeline is not paused.");
546
571
  this._pauseTrigger.wake();
547
572
  this._isPaused = false;
548
573
  }
@@ -551,15 +576,15 @@ var Pipeline = class {
551
576
  * Updates the timeframe clock after the message has bee processed.
552
577
  */
553
578
  async *consume() {
554
- assert4(!this._isOpen, "Pipeline is already being consumed.");
579
+ invariant4(!this._isOpen, "Pipeline is already being consumed.");
555
580
  this._isOpen = true;
556
- assert4(this._feedSetIterator, "Iterator not initialized.");
581
+ invariant4(this._feedSetIterator, "Iterator not initialized.");
557
582
  let lastFeedSetIterator = this._feedSetIterator;
558
583
  let iterable = lastFeedSetIterator[Symbol.asyncIterator]();
559
584
  while (!this._isStopping) {
560
585
  await this._pauseTrigger.wait();
561
586
  if (lastFeedSetIterator !== this._feedSetIterator) {
562
- assert4(this._feedSetIterator, "Iterator not initialized.");
587
+ invariant4(this._feedSetIterator, "Iterator not initialized.");
563
588
  lastFeedSetIterator = this._feedSetIterator;
564
589
  iterable = lastFeedSetIterator[Symbol.asyncIterator]();
565
590
  }
@@ -581,11 +606,11 @@ var Pipeline = class {
581
606
  const timeframe = this._state._startTimeframe;
582
607
  const seq = (_a = timeframe.get(feed.key)) != null ? _a : 0;
583
608
  feed.undownload({
584
- callback: () => log4("Undownloaded", {}, {
585
- file: "pipeline.ts",
586
- line: 371,
587
- scope: this,
588
- callSite: (f, a) => f(...a)
609
+ callback: () => log4("Undownloaded", void 0, {
610
+ F: __dxlog_file4,
611
+ L: 383,
612
+ S: this,
613
+ C: (f, a) => f(...a)
589
614
  })
590
615
  });
591
616
  feed.download({
@@ -595,10 +620,10 @@ var Pipeline = class {
595
620
  log4("failed to download feed", {
596
621
  err
597
622
  }, {
598
- file: "pipeline.ts",
599
- line: 374,
600
- scope: this,
601
- callSite: (f, a) => f(...a)
623
+ F: __dxlog_file4,
624
+ L: 386,
625
+ S: this,
626
+ C: (f, a) => f(...a)
602
627
  });
603
628
  });
604
629
  }
@@ -608,11 +633,11 @@ var Pipeline = class {
608
633
  stallTimeout: 1e3
609
634
  });
610
635
  this._feedSetIterator.stalled.on((iterator) => {
611
- log4.warn(`Stalled after ${iterator.options.stallTimeout}ms with ${iterator.size} feeds.`, {}, {
612
- file: "pipeline.ts",
613
- line: 384,
614
- scope: this,
615
- callSite: (f, a) => f(...a)
636
+ log4.warn(`Stalled after ${iterator.options.stallTimeout}ms with ${iterator.size} feeds.`, void 0, {
637
+ F: __dxlog_file4,
638
+ L: 396,
639
+ S: this,
640
+ C: (f, a) => f(...a)
616
641
  });
617
642
  this._state.stalled.emit();
618
643
  });
@@ -621,30 +646,31 @@ var Pipeline = class {
621
646
  }
622
647
  }
623
648
  };
624
- __decorate3([
649
+ _ts_decorate3([
625
650
  synchronized2
626
651
  ], Pipeline.prototype, "start", null);
627
- __decorate3([
652
+ _ts_decorate3([
628
653
  synchronized2
629
654
  ], Pipeline.prototype, "stop", null);
630
- __decorate3([
655
+ _ts_decorate3([
631
656
  synchronized2
632
657
  ], Pipeline.prototype, "setCursor", null);
633
- __decorate3([
658
+ _ts_decorate3([
634
659
  synchronized2
635
660
  ], Pipeline.prototype, "pause", null);
636
- __decorate3([
661
+ _ts_decorate3([
637
662
  synchronized2
638
663
  ], Pipeline.prototype, "unpause", null);
639
664
 
640
665
  // packages/core/echo/echo-pipeline/src/space/auth.ts
641
- import assert5 from "@dxos/node-std/assert";
666
+ import invariant5 from "tiny-invariant";
642
667
  import { runInContext, scheduleTask } from "@dxos/async";
643
668
  import { Context as Context2 } from "@dxos/context";
644
669
  import { randomBytes } from "@dxos/crypto";
645
670
  import { log as log5 } from "@dxos/log";
646
671
  import { schema as schema3 } from "@dxos/protocols";
647
672
  import { RpcExtension } from "@dxos/teleport";
673
+ var __dxlog_file5 = "/home/runner/work/dxos/dxos/packages/core/echo/echo-pipeline/src/space/auth.ts";
648
674
  var AuthExtension = class extends RpcExtension {
649
675
  constructor(_authParams) {
650
676
  super({
@@ -659,11 +685,11 @@ var AuthExtension = class extends RpcExtension {
659
685
  this._authParams = _authParams;
660
686
  this._ctx = new Context2({
661
687
  onError: (err) => {
662
- log5.catch(err, {}, {
663
- file: "auth.ts",
664
- line: 29,
665
- scope: this,
666
- callSite: (f, a) => f(...a)
688
+ log5.catch(err, void 0, {
689
+ F: __dxlog_file5,
690
+ L: 29,
691
+ S: this,
692
+ C: (f, a) => f(...a)
667
693
  });
668
694
  }
669
695
  });
@@ -682,10 +708,10 @@ var AuthExtension = class extends RpcExtension {
682
708
  };
683
709
  } catch (err) {
684
710
  log5.error("failed to generate auth credentials", err, {
685
- file: "auth.ts",
686
- line: 56,
687
- scope: this,
688
- callSite: (f, a) => f(...a)
711
+ F: __dxlog_file5,
712
+ L: 56,
713
+ S: this,
714
+ C: (f, a) => f(...a)
689
715
  });
690
716
  throw new Error("auth rejected");
691
717
  }
@@ -701,16 +727,16 @@ var AuthExtension = class extends RpcExtension {
701
727
  const { credential } = await this.rpc.AuthService.authenticate({
702
728
  challenge
703
729
  });
704
- assert5((credential == null ? void 0 : credential.length) > 0, "invalid credential");
730
+ invariant5((credential == null ? void 0 : credential.length) > 0, "invalid credential");
705
731
  const success = await this._authParams.verifier(challenge, credential);
706
- assert5(success, "credential not verified");
732
+ invariant5(success, "credential not verified");
707
733
  runInContext(this._ctx, () => this._authParams.onAuthSuccess());
708
734
  } catch (err) {
709
735
  log5("auth failed", err, {
710
- file: "auth.ts",
711
- line: 75,
712
- scope: this,
713
- callSite: (f, a) => f(...a)
736
+ F: __dxlog_file5,
737
+ L: 75,
738
+ S: this,
739
+ C: (f, a) => f(...a)
714
740
  });
715
741
  this.close();
716
742
  this._authParams.onAuthFailure();
@@ -724,23 +750,32 @@ var AuthExtension = class extends RpcExtension {
724
750
  };
725
751
 
726
752
  // packages/core/echo/echo-pipeline/src/dbhost/data-service-host.ts
727
- import assert6 from "@dxos/node-std/assert";
753
+ import invariant6 from "tiny-invariant";
728
754
  import { Stream } from "@dxos/codec-protobuf";
755
+ import { Context as Context3 } from "@dxos/context";
729
756
  import { tagMutationsInBatch, setMetadataOnObject } from "@dxos/echo-db";
730
757
  import { log as log6 } from "@dxos/log";
731
758
  import { ComplexMap as ComplexMap2 } from "@dxos/util";
759
+ var __dxlog_file6 = "/home/runner/work/dxos/dxos/packages/core/echo/echo-pipeline/src/dbhost/data-service-host.ts";
732
760
  var DataServiceHost = class {
733
761
  constructor(_itemManager, _itemDemuxer, _writeStream) {
734
762
  this._itemManager = _itemManager;
735
763
  this._itemDemuxer = _itemDemuxer;
736
764
  this._writeStream = _writeStream;
765
+ this._ctx = new Context3();
737
766
  this._clientTagMap = new ComplexMap2(([feedKey, seq]) => `${feedKey.toHex()}:${seq}`);
738
767
  }
768
+ async open() {
769
+ }
770
+ async close() {
771
+ await this._ctx.dispose();
772
+ }
739
773
  /**
740
774
  * Real-time subscription to data objects in a space.
741
775
  */
742
776
  subscribe() {
743
- return new Stream(({ next, ctx }) => {
777
+ return new Stream(({ next, close, ctx }) => {
778
+ ctx.onDispose(this._ctx.onDispose(close));
744
779
  const objects = Array.from(this._itemManager.entities.values()).map((entity) => entity.createSnapshot());
745
780
  next({
746
781
  batch: {
@@ -750,15 +785,15 @@ var DataServiceHost = class {
750
785
  this._itemDemuxer.mutation.on(ctx, (message) => {
751
786
  var _a;
752
787
  const { batch, meta } = message;
753
- assert6(!meta.clientTag, "Unexpected client tag in mutation message");
788
+ invariant6(!meta.clientTag, "Unexpected client tag in mutation message");
754
789
  log6("message", {
755
790
  batch,
756
791
  meta
757
792
  }, {
758
- file: "data-service-host.ts",
759
- line: 51,
760
- scope: this,
761
- callSite: (f, a) => f(...a)
793
+ F: __dxlog_file6,
794
+ L: 63,
795
+ S: this,
796
+ C: (f, a) => f(...a)
762
797
  });
763
798
  const clientTag = this._clientTagMap.get([
764
799
  message.meta.feedKey,
@@ -783,15 +818,16 @@ var DataServiceHost = class {
783
818
  }
784
819
  async write(request) {
785
820
  var _a, _b;
786
- assert6(this._writeStream, "Cannot write mutations in readonly mode");
821
+ invariant6(!this._ctx.disposed, "Cannot write to closed DataServiceHost");
822
+ invariant6(this._writeStream, "Cannot write mutations in readonly mode");
787
823
  log6("write", {
788
824
  clientTag: request.clientTag,
789
825
  objectCount: (_b = (_a = request.batch.objects) == null ? void 0 : _a.length) != null ? _b : 0
790
826
  }, {
791
- file: "data-service-host.ts",
792
- line: 79,
793
- scope: this,
794
- callSite: (f, a) => f(...a)
827
+ F: __dxlog_file6,
828
+ L: 92,
829
+ S: this,
830
+ C: (f, a) => f(...a)
795
831
  });
796
832
  const message = createDataMessage(request.batch);
797
833
  const receipt = await this._writeStream.write(message, {
@@ -802,10 +838,10 @@ var DataServiceHost = class {
802
838
  feedKey: receipt2.feedKey,
803
839
  seq: receipt2.seq
804
840
  }, {
805
- file: "data-service-host.ts",
806
- line: 88,
807
- scope: this,
808
- callSite: (f, a) => f(...a)
841
+ F: __dxlog_file6,
842
+ L: 101,
843
+ S: this,
844
+ C: (f, a) => f(...a)
809
845
  });
810
846
  this._clientTagMap.set([
811
847
  receipt2.feedKey,
@@ -875,7 +911,7 @@ import { timed as timed2 } from "@dxos/debug";
875
911
  import { PublicKey as PublicKey2 } from "@dxos/keys";
876
912
  import { schema as schema4 } from "@dxos/protocols";
877
913
  import { BlobMeta } from "@dxos/protocols/proto/dxos/echo/blob";
878
- var __decorate4 = function(decorators, target, key, desc) {
914
+ function _ts_decorate4(decorators, target, key, desc) {
879
915
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
880
916
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
881
917
  r = Reflect.decorate(decorators, target, key, desc);
@@ -884,7 +920,7 @@ var __decorate4 = function(decorators, target, key, desc) {
884
920
  if (d = decorators[i])
885
921
  r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
886
922
  return c > 3 && r && Object.defineProperty(target, key, r), r;
887
- };
923
+ }
888
924
  var SnapshotManager = class SnapshotManager2 {
889
925
  // prettier-ignore
890
926
  constructor(_snapshotStore, _blobStore, _blobSync) {
@@ -915,10 +951,10 @@ var SnapshotManager = class SnapshotManager2 {
915
951
  return PublicKey2.from(id).toHex();
916
952
  }
917
953
  };
918
- __decorate4([
954
+ _ts_decorate4([
919
955
  timed2(1e4)
920
956
  ], SnapshotManager.prototype, "load", null);
921
- SnapshotManager = __decorate4([
957
+ SnapshotManager = _ts_decorate4([
922
958
  trackLeaks("open", "close")
923
959
  ], SnapshotManager);
924
960
 
@@ -968,11 +1004,12 @@ var SnapshotStore = class {
968
1004
  };
969
1005
 
970
1006
  // packages/core/echo/echo-pipeline/src/dbhost/data-service.ts
971
- import assert7 from "@dxos/node-std/assert";
1007
+ import invariant7 from "tiny-invariant";
972
1008
  import { raise } from "@dxos/debug";
973
1009
  import { PublicKey as PublicKey3 } from "@dxos/keys";
974
1010
  import { log as log7 } from "@dxos/log";
975
1011
  import { ComplexMap as ComplexMap3 } from "@dxos/util";
1012
+ var __dxlog_file7 = "/home/runner/work/dxos/dxos/packages/core/echo/echo-pipeline/src/dbhost/data-service.ts";
976
1013
  var DataServiceSubscriptions = class {
977
1014
  constructor() {
978
1015
  this._spaces = new ComplexMap3(PublicKey3.hash);
@@ -980,26 +1017,30 @@ var DataServiceSubscriptions = class {
980
1017
  clear() {
981
1018
  this._spaces.clear();
982
1019
  }
983
- registerSpace(spaceKey, host) {
1020
+ async registerSpace(spaceKey, host) {
984
1021
  log7("Registering space", {
985
1022
  spaceKey
986
1023
  }, {
987
- file: "data-service.ts",
988
- line: 31,
989
- scope: this,
990
- callSite: (f, a) => f(...a)
1024
+ F: __dxlog_file7,
1025
+ L: 31,
1026
+ S: this,
1027
+ C: (f, a) => f(...a)
991
1028
  });
1029
+ invariant7(!this._spaces.has(spaceKey));
1030
+ await host.open();
992
1031
  this._spaces.set(spaceKey, host);
993
1032
  }
994
- unregisterSpace(spaceKey) {
1033
+ async unregisterSpace(spaceKey) {
995
1034
  log7("Unregistering space", {
996
1035
  spaceKey
997
1036
  }, {
998
- file: "data-service.ts",
999
- line: 36,
1000
- scope: this,
1001
- callSite: (f, a) => f(...a)
1037
+ F: __dxlog_file7,
1038
+ L: 38,
1039
+ S: this,
1040
+ C: (f, a) => f(...a)
1002
1041
  });
1042
+ const host = this._spaces.get(spaceKey);
1043
+ await (host == null ? void 0 : host.close());
1003
1044
  this._spaces.delete(spaceKey);
1004
1045
  }
1005
1046
  getDataService(spaceKey) {
@@ -1012,29 +1053,29 @@ var DataServiceImpl = class {
1012
1053
  }
1013
1054
  subscribe(request) {
1014
1055
  var _a;
1015
- assert7(request.spaceKey);
1056
+ invariant7(request.spaceKey);
1016
1057
  const host = (_a = this._subscriptions.getDataService(request.spaceKey)) != null ? _a : raise(new Error(`space not found: ${request.spaceKey}`));
1017
1058
  return host.subscribe();
1018
1059
  }
1019
1060
  write(request) {
1020
1061
  var _a;
1021
- assert7(request.spaceKey);
1022
- assert7(request.batch);
1062
+ invariant7(request.spaceKey);
1063
+ invariant7(request.batch);
1023
1064
  const host = (_a = this._subscriptions.getDataService(request.spaceKey)) != null ? _a : raise(new Error(`space not found: ${request.spaceKey}`));
1024
1065
  return host.write(request);
1025
1066
  }
1026
1067
  };
1027
1068
 
1028
1069
  // packages/core/echo/echo-pipeline/src/space/data-pipeline.ts
1029
- import assert8 from "@dxos/node-std/assert";
1070
+ import invariant8 from "tiny-invariant";
1030
1071
  import { Event as Event4, scheduleTask as scheduleTask2, synchronized as synchronized3, trackLeaks as trackLeaks2 } from "@dxos/async";
1031
- import { Context as Context3 } from "@dxos/context";
1072
+ import { Context as Context4 } from "@dxos/context";
1032
1073
  import { checkCredentialType } from "@dxos/credentials";
1033
1074
  import { getStateMachineFromItem, ItemManager } from "@dxos/echo-db";
1034
1075
  import { CancelledError } from "@dxos/errors";
1035
1076
  import { log as log8 } from "@dxos/log";
1036
1077
  import { Timeframe as Timeframe3 } from "@dxos/timeframe";
1037
- var __decorate5 = function(decorators, target, key, desc) {
1078
+ function _ts_decorate5(decorators, target, key, desc) {
1038
1079
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
1039
1080
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
1040
1081
  r = Reflect.decorate(decorators, target, key, desc);
@@ -1043,18 +1084,23 @@ var __decorate5 = function(decorators, target, key, desc) {
1043
1084
  if (d = decorators[i])
1044
1085
  r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
1045
1086
  return c > 3 && r && Object.defineProperty(target, key, r), r;
1046
- };
1087
+ }
1088
+ var __dxlog_file8 = "/home/runner/work/dxos/dxos/packages/core/echo/echo-pipeline/src/space/data-pipeline.ts";
1047
1089
  var MESSAGES_PER_SNAPSHOT = 10;
1048
1090
  var AUTOMATIC_SNAPSHOT_DEBOUNCE_INTERVAL = 5e3;
1049
1091
  var TIMEFRAME_SAVE_DEBOUNCE_INTERVAL = 500;
1050
1092
  var DataPipeline = class DataPipeline2 {
1051
1093
  constructor(_params) {
1052
1094
  this._params = _params;
1053
- this._ctx = new Context3();
1095
+ this._ctx = new Context4();
1096
+ this._pipeline = void 0;
1097
+ this._targetTimeframe = void 0;
1054
1098
  this._lastAutomaticSnapshotTimeframe = new Timeframe3();
1055
1099
  this._isOpen = false;
1056
1100
  this._lastTimeframeSaveTime = 0;
1057
1101
  this._lastSnapshotSaveTime = 0;
1102
+ this.currentEpoch = void 0;
1103
+ this.appliedEpoch = void 0;
1058
1104
  this._lastProcessedEpoch = -1;
1059
1105
  this.onNewEpoch = new Event4();
1060
1106
  }
@@ -1073,18 +1119,14 @@ var DataPipeline = class DataPipeline2 {
1073
1119
  this._targetTimeframe = timeframe;
1074
1120
  (_a = this._pipeline) == null ? void 0 : _a.state.setTargetTimeframe(timeframe);
1075
1121
  }
1076
- createCredentialProcessor() {
1077
- return {
1078
- process: async (credential) => {
1079
- if (!checkCredentialType(credential, "dxos.halo.credentials.Epoch")) {
1080
- return;
1081
- }
1082
- this.currentEpoch = credential;
1083
- if (this._isOpen) {
1084
- await this._processEpochInSeparateTask(credential);
1085
- }
1086
- }
1087
- };
1122
+ async processCredential(credential) {
1123
+ if (!checkCredentialType(credential, "dxos.halo.credentials.Epoch")) {
1124
+ return;
1125
+ }
1126
+ this.currentEpoch = credential;
1127
+ if (this._isOpen) {
1128
+ await this._processEpochInSeparateTask(credential);
1129
+ }
1088
1130
  }
1089
1131
  async open() {
1090
1132
  if (this._isOpen) {
@@ -1099,8 +1141,8 @@ var DataPipeline = class DataPipeline2 {
1099
1141
  }
1100
1142
  const feedWriter = {
1101
1143
  write: (data, options) => {
1102
- assert8(this._pipeline, "Pipeline is not initialized.");
1103
- assert8(this.currentEpoch, "Epoch is not initialized.");
1144
+ invariant8(this._pipeline, "Pipeline is not initialized.");
1145
+ invariant8(this.currentEpoch, "Epoch is not initialized.");
1104
1146
  return this._pipeline.writer.write({
1105
1147
  data
1106
1148
  }, options);
@@ -1119,11 +1161,11 @@ var DataPipeline = class DataPipeline2 {
1119
1161
  if (!this._isOpen) {
1120
1162
  return;
1121
1163
  }
1122
- log8("close", {}, {
1123
- file: "data-pipeline.ts",
1124
- line: 174,
1125
- scope: this,
1126
- callSite: (f, a) => f(...a)
1164
+ log8("close", void 0, {
1165
+ F: __dxlog_file8,
1166
+ L: 171,
1167
+ S: this,
1168
+ C: (f, a) => f(...a)
1127
1169
  });
1128
1170
  this._isOpen = false;
1129
1171
  await this._ctx.dispose();
@@ -1134,15 +1176,23 @@ var DataPipeline = class DataPipeline2 {
1134
1176
  await this._saveTargetTimeframe(this._pipeline.state.timeframe);
1135
1177
  }
1136
1178
  } catch (err) {
1137
- log8.catch(err, {}, {
1138
- file: "data-pipeline.ts",
1139
- line: 187,
1140
- scope: this,
1141
- callSite: (f, a) => f(...a)
1179
+ log8.catch(err, void 0, {
1180
+ F: __dxlog_file8,
1181
+ L: 184,
1182
+ S: this,
1183
+ C: (f, a) => f(...a)
1142
1184
  });
1143
1185
  }
1144
1186
  await ((_b = this.databaseHost) == null ? void 0 : _b.close());
1145
1187
  await ((_c = this.itemManager) == null ? void 0 : _c.destroy());
1188
+ this._ctx = new Context4();
1189
+ this._pipeline = void 0;
1190
+ this._targetTimeframe = void 0;
1191
+ this._lastAutomaticSnapshotTimeframe = new Timeframe3();
1192
+ this.currentEpoch = void 0;
1193
+ this.appliedEpoch = void 0;
1194
+ this._lastProcessedEpoch = -1;
1195
+ this._epochCtx = void 0;
1146
1196
  }
1147
1197
  async _consumePipeline() {
1148
1198
  if (this.currentEpoch) {
@@ -1150,17 +1200,17 @@ var DataPipeline = class DataPipeline2 {
1150
1200
  await this._processEpochInSeparateTask(this.currentEpoch);
1151
1201
  await waitForOneEpoch;
1152
1202
  }
1153
- assert8(this._pipeline, "Pipeline is not initialized.");
1203
+ invariant8(this._pipeline, "Pipeline is not initialized.");
1154
1204
  for await (const msg of this._pipeline.consume()) {
1155
1205
  const { feedKey, seq, data } = msg;
1156
1206
  log8("processing message", {
1157
1207
  feedKey,
1158
1208
  seq
1159
1209
  }, {
1160
- file: "data-pipeline.ts",
1161
- line: 204,
1162
- scope: this,
1163
- callSite: (f, a) => f(...a)
1210
+ F: __dxlog_file8,
1211
+ L: 210,
1212
+ S: this,
1213
+ C: (f, a) => f(...a)
1164
1214
  });
1165
1215
  try {
1166
1216
  if (data.payload.data) {
@@ -1169,10 +1219,10 @@ var DataPipeline = class DataPipeline2 {
1169
1219
  log8.error("Could not find feed.", {
1170
1220
  feedKey
1171
1221
  }, {
1172
- file: "data-pipeline.ts",
1173
- line: 210,
1174
- scope: this,
1175
- callSite: (f, a) => f(...a)
1222
+ F: __dxlog_file8,
1223
+ L: 216,
1224
+ S: this,
1225
+ C: (f, a) => f(...a)
1176
1226
  });
1177
1227
  continue;
1178
1228
  }
@@ -1190,25 +1240,25 @@ var DataPipeline = class DataPipeline2 {
1190
1240
  seq,
1191
1241
  spaceKey: this._params.spaceKey.toHex()
1192
1242
  }, {
1193
- file: "data-pipeline.ts",
1194
- line: 224,
1195
- scope: this,
1196
- callSite: (f, a) => f(...a)
1243
+ F: __dxlog_file8,
1244
+ L: 230,
1245
+ S: this,
1246
+ C: (f, a) => f(...a)
1197
1247
  });
1198
1248
  await this._noteTargetStateIfNeeded(this._pipeline.state.pendingTimeframe);
1199
1249
  }
1200
1250
  } catch (err) {
1201
- log8.catch(err, {}, {
1202
- file: "data-pipeline.ts",
1203
- line: 234,
1204
- scope: this,
1205
- callSite: (f, a) => f(...a)
1251
+ log8.catch(err, void 0, {
1252
+ F: __dxlog_file8,
1253
+ L: 240,
1254
+ S: this,
1255
+ C: (f, a) => f(...a)
1206
1256
  });
1207
1257
  }
1208
1258
  }
1209
1259
  }
1210
1260
  _createSnapshot() {
1211
- assert8(this.databaseHost, "Database backend is not initialized.");
1261
+ invariant8(this.databaseHost, "Database backend is not initialized.");
1212
1262
  return {
1213
1263
  spaceKey: this._params.spaceKey.asUint8Array(),
1214
1264
  timeframe: this._pipeline.state.timeframe,
@@ -1227,18 +1277,17 @@ var DataPipeline = class DataPipeline2 {
1227
1277
  try {
1228
1278
  const propertiesItem = this.itemManager.items.find((item) => {
1229
1279
  var _a2, _b;
1230
- return ((_a2 = item.modelMeta) == null ? void 0 : _a2.type) === "dxos:model/document" && // TODO(burdon): Document?
1231
- ((_b = getStateMachineFromItem(item)) == null ? void 0 : _b.snapshot().type) === "dxos.sdk.client.Properties";
1280
+ return ((_a2 = item.modelMeta) == null ? void 0 : _a2.type) === "dxos:model/document" && ((_b = getStateMachineFromItem(item)) == null ? void 0 : _b.snapshot()).type === "dxos.sdk.client.Properties";
1232
1281
  });
1233
1282
  if (propertiesItem) {
1234
1283
  cache.properties = (_a = getStateMachineFromItem(propertiesItem)) == null ? void 0 : _a.snapshot();
1235
1284
  }
1236
1285
  } catch (err) {
1237
1286
  log8.warn("Failed to cache properties", err, {
1238
- file: "data-pipeline.ts",
1239
- line: 269,
1240
- scope: this,
1241
- callSite: (f, a) => f(...a)
1287
+ F: __dxlog_file8,
1288
+ L: 275,
1289
+ S: this,
1290
+ C: (f, a) => f(...a)
1242
1291
  });
1243
1292
  }
1244
1293
  await this._params.metadataStore.setCache(this._params.spaceKey, cache);
@@ -1258,21 +1307,21 @@ var DataPipeline = class DataPipeline2 {
1258
1307
  return;
1259
1308
  }
1260
1309
  await ((_a = this._epochCtx) == null ? void 0 : _a.dispose());
1261
- const ctx = new Context3({
1310
+ const ctx = new Context4({
1262
1311
  onError: (err) => {
1263
1312
  if (err instanceof CancelledError) {
1264
- log8("Epoch processing cancelled.", {}, {
1265
- file: "data-pipeline.ts",
1266
- line: 301,
1267
- scope: this,
1268
- callSite: (f, a) => f(...a)
1313
+ log8("Epoch processing cancelled.", void 0, {
1314
+ F: __dxlog_file8,
1315
+ L: 307,
1316
+ S: this,
1317
+ C: (f, a) => f(...a)
1269
1318
  });
1270
1319
  } else {
1271
- log8.catch(err, {}, {
1272
- file: "data-pipeline.ts",
1273
- line: 303,
1274
- scope: this,
1275
- callSite: (f, a) => f(...a)
1320
+ log8.catch(err, void 0, {
1321
+ F: __dxlog_file8,
1322
+ L: 309,
1323
+ S: this,
1324
+ C: (f, a) => f(...a)
1276
1325
  });
1277
1326
  }
1278
1327
  }
@@ -1285,10 +1334,10 @@ var DataPipeline = class DataPipeline2 {
1285
1334
  log8("process epoch", {
1286
1335
  epoch
1287
1336
  }, {
1288
- file: "data-pipeline.ts",
1289
- line: 313,
1290
- scope: this,
1291
- callSite: (f, a) => f(...a)
1337
+ F: __dxlog_file8,
1338
+ L: 319,
1339
+ S: this,
1340
+ C: (f, a) => f(...a)
1292
1341
  });
1293
1342
  await this._processEpoch(ctx, epoch.subject.assertion);
1294
1343
  this.appliedEpoch = epoch;
@@ -1296,38 +1345,38 @@ var DataPipeline = class DataPipeline2 {
1296
1345
  });
1297
1346
  }
1298
1347
  async _processEpoch(ctx, epoch) {
1299
- assert8(this._isOpen, "Space is closed.");
1300
- assert8(this._pipeline);
1348
+ invariant8(this._isOpen, "Space is closed.");
1349
+ invariant8(this._pipeline);
1301
1350
  this._lastProcessedEpoch = epoch.number;
1302
1351
  log8("Processing epoch", {
1303
1352
  epoch
1304
1353
  }, {
1305
- file: "data-pipeline.ts",
1306
- line: 327,
1307
- scope: this,
1308
- callSite: (f, a) => f(...a)
1354
+ F: __dxlog_file8,
1355
+ L: 333,
1356
+ S: this,
1357
+ C: (f, a) => f(...a)
1309
1358
  });
1310
1359
  if (epoch.snapshotCid) {
1311
1360
  const snapshot = await this._params.snapshotManager.load(ctx, epoch.snapshotCid);
1312
1361
  this.databaseHost._itemDemuxer.restoreFromSnapshot(snapshot.database);
1313
1362
  }
1314
- log8("restarting pipeline for epoch", {}, {
1315
- file: "data-pipeline.ts",
1316
- line: 335,
1317
- scope: this,
1318
- callSite: (f, a) => f(...a)
1363
+ log8("restarting pipeline for epoch", void 0, {
1364
+ F: __dxlog_file8,
1365
+ L: 341,
1366
+ S: this,
1367
+ C: (f, a) => f(...a)
1319
1368
  });
1320
1369
  await this._pipeline.pause();
1321
1370
  await this._pipeline.setCursor(epoch.timeframe);
1322
1371
  await this._pipeline.unpause();
1323
1372
  }
1324
1373
  async waitUntilTimeframe(timeframe) {
1325
- assert8(this._pipeline, "Pipeline is not initialized.");
1374
+ invariant8(this._pipeline, "Pipeline is not initialized.");
1326
1375
  await this._pipeline.state.waitUntilTimeframe(timeframe);
1327
1376
  }
1328
1377
  async createEpoch() {
1329
- assert8(this._pipeline);
1330
- assert8(this.currentEpoch);
1378
+ invariant8(this._pipeline);
1379
+ invariant8(this.currentEpoch);
1331
1380
  await this._pipeline.pause();
1332
1381
  const snapshot = await this._createSnapshot();
1333
1382
  const snapshotCid = await this._params.snapshotManager.store(snapshot);
@@ -1344,24 +1393,24 @@ var DataPipeline = class DataPipeline2 {
1344
1393
  await this.onNewEpoch.waitForCondition(() => !!this.currentEpoch);
1345
1394
  }
1346
1395
  };
1347
- __decorate5([
1396
+ _ts_decorate5([
1348
1397
  synchronized3
1349
1398
  ], DataPipeline.prototype, "open", null);
1350
- __decorate5([
1399
+ _ts_decorate5([
1351
1400
  synchronized3
1352
1401
  ], DataPipeline.prototype, "close", null);
1353
- __decorate5([
1402
+ _ts_decorate5([
1354
1403
  synchronized3
1355
1404
  ], DataPipeline.prototype, "_processEpoch", null);
1356
- __decorate5([
1405
+ _ts_decorate5([
1357
1406
  synchronized3
1358
1407
  ], DataPipeline.prototype, "createEpoch", null);
1359
- DataPipeline = __decorate5([
1408
+ DataPipeline = _ts_decorate5([
1360
1409
  trackLeaks2("open", "close")
1361
1410
  ], DataPipeline);
1362
1411
 
1363
1412
  // packages/core/echo/echo-pipeline/src/space/space.ts
1364
- import assert9 from "@dxos/node-std/assert";
1413
+ import invariant9 from "tiny-invariant";
1365
1414
  import { Event as Event5, synchronized as synchronized4, trackLeaks as trackLeaks3, Lock } from "@dxos/async";
1366
1415
  import { log as log10, logInfo } from "@dxos/log";
1367
1416
  import { AdmittedFeed as AdmittedFeed2 } from "@dxos/protocols/proto/dxos/halo/credentials";
@@ -1374,6 +1423,7 @@ import { log as log9 } from "@dxos/log";
1374
1423
  import { AdmittedFeed } from "@dxos/protocols/proto/dxos/halo/credentials";
1375
1424
  import { Timeframe as Timeframe4 } from "@dxos/timeframe";
1376
1425
  import { Callback } from "@dxos/util";
1426
+ var __dxlog_file9 = "/home/runner/work/dxos/dxos/packages/core/echo/echo-pipeline/src/space/control-pipeline.ts";
1377
1427
  var TIMEFRAME_SAVE_DEBOUNCE_INTERVAL2 = 500;
1378
1428
  var ControlPipeline = class {
1379
1429
  constructor({ spaceKey, genesisFeed, feedProvider, metadataStore }) {
@@ -1388,21 +1438,21 @@ var ControlPipeline = class {
1388
1438
  log9("feed admitted", {
1389
1439
  key: info.key
1390
1440
  }, {
1391
- file: "control-pipeline.ts",
1392
- line: 51,
1393
- scope: this,
1394
- callSite: (f, a) => f(...a)
1441
+ F: __dxlog_file9,
1442
+ L: 51,
1443
+ S: this,
1444
+ C: (f, a) => f(...a)
1395
1445
  });
1396
1446
  if (info.assertion.designation === AdmittedFeed.Designation.CONTROL && !info.key.equals(genesisFeed.key)) {
1397
1447
  try {
1398
1448
  const feed = await feedProvider(info.key);
1399
1449
  await this._pipeline.addFeed(feed);
1400
1450
  } catch (err) {
1401
- log9.catch(err, {}, {
1402
- file: "control-pipeline.ts",
1403
- line: 59,
1404
- scope: this,
1405
- callSite: (f, a) => f(...a)
1451
+ log9.catch(err, void 0, {
1452
+ F: __dxlog_file9,
1453
+ L: 59,
1454
+ S: this,
1455
+ C: (f, a) => f(...a)
1406
1456
  });
1407
1457
  }
1408
1458
  }
@@ -1421,11 +1471,11 @@ var ControlPipeline = class {
1421
1471
  this._pipeline.setWriteFeed(feed);
1422
1472
  }
1423
1473
  async start() {
1424
- log9("starting...", {}, {
1425
- file: "control-pipeline.ts",
1426
- line: 83,
1427
- scope: this,
1428
- callSite: (f, a) => f(...a)
1474
+ log9("starting...", void 0, {
1475
+ F: __dxlog_file9,
1476
+ L: 83,
1477
+ S: this,
1478
+ C: (f, a) => f(...a)
1429
1479
  });
1430
1480
  setTimeout(async () => {
1431
1481
  for await (const msg of this._pipeline.consume()) {
@@ -1434,10 +1484,10 @@ var ControlPipeline = class {
1434
1484
  key: msg.feedKey,
1435
1485
  seq: msg.seq
1436
1486
  }, {
1437
- file: "control-pipeline.ts",
1438
- line: 88,
1439
- scope: this,
1440
- callSite: (f, a) => f(...a)
1487
+ F: __dxlog_file9,
1488
+ L: 88,
1489
+ S: this,
1490
+ C: (f, a) => f(...a)
1441
1491
  });
1442
1492
  if (msg.data.payload.credential) {
1443
1493
  const result = await this._spaceStateMachine.process(msg.data.payload.credential.credential, PublicKey4.from(msg.feedKey));
@@ -1445,31 +1495,31 @@ var ControlPipeline = class {
1445
1495
  log9.warn("processing failed", {
1446
1496
  msg
1447
1497
  }, {
1448
- file: "control-pipeline.ts",
1449
- line: 95,
1450
- scope: this,
1451
- callSite: (f, a) => f(...a)
1498
+ F: __dxlog_file9,
1499
+ L: 95,
1500
+ S: this,
1501
+ C: (f, a) => f(...a)
1452
1502
  });
1453
1503
  } else {
1454
1504
  await this._noteTargetStateIfNeeded(this._pipeline.state.pendingTimeframe);
1455
1505
  }
1456
1506
  }
1457
1507
  } catch (err) {
1458
- log9.catch(err, {}, {
1459
- file: "control-pipeline.ts",
1460
- line: 101,
1461
- scope: this,
1462
- callSite: (f, a) => f(...a)
1508
+ log9.catch(err, void 0, {
1509
+ F: __dxlog_file9,
1510
+ L: 101,
1511
+ S: this,
1512
+ C: (f, a) => f(...a)
1463
1513
  });
1464
1514
  }
1465
1515
  }
1466
1516
  });
1467
1517
  await this._pipeline.start();
1468
- log9("started", {}, {
1469
- file: "control-pipeline.ts",
1470
- line: 107,
1471
- scope: this,
1472
- callSite: (f, a) => f(...a)
1518
+ log9("started", void 0, {
1519
+ F: __dxlog_file9,
1520
+ L: 107,
1521
+ S: this,
1522
+ C: (f, a) => f(...a)
1473
1523
  });
1474
1524
  }
1475
1525
  async _noteTargetStateIfNeeded(timeframe) {
@@ -1479,19 +1529,19 @@ var ControlPipeline = class {
1479
1529
  }
1480
1530
  }
1481
1531
  async stop() {
1482
- log9("stopping...", {}, {
1483
- file: "control-pipeline.ts",
1484
- line: 121,
1485
- scope: this,
1486
- callSite: (f, a) => f(...a)
1532
+ log9("stopping...", void 0, {
1533
+ F: __dxlog_file9,
1534
+ L: 121,
1535
+ S: this,
1536
+ C: (f, a) => f(...a)
1487
1537
  });
1488
1538
  await this._pipeline.stop();
1489
1539
  await this._saveTargetTimeframe(this._pipeline.state.timeframe);
1490
- log9("stopped", {}, {
1491
- file: "control-pipeline.ts",
1492
- line: 124,
1493
- scope: this,
1494
- callSite: (f, a) => f(...a)
1540
+ log9("stopped", void 0, {
1541
+ F: __dxlog_file9,
1542
+ L: 124,
1543
+ S: this,
1544
+ C: (f, a) => f(...a)
1495
1545
  });
1496
1546
  }
1497
1547
  async _saveTargetTimeframe(timeframe) {
@@ -1501,18 +1551,18 @@ var ControlPipeline = class {
1501
1551
  await this._metadata.setSpaceControlLatestTimeframe(this._spaceKey, newTimeframe);
1502
1552
  this._targetTimeframe = newTimeframe;
1503
1553
  } catch (err) {
1504
- log9(err, {}, {
1505
- file: "control-pipeline.ts",
1506
- line: 133,
1507
- scope: this,
1508
- callSite: (f, a) => f(...a)
1554
+ log9(err, void 0, {
1555
+ F: __dxlog_file9,
1556
+ L: 133,
1557
+ S: this,
1558
+ C: (f, a) => f(...a)
1509
1559
  });
1510
1560
  }
1511
1561
  }
1512
1562
  };
1513
1563
 
1514
1564
  // packages/core/echo/echo-pipeline/src/space/space.ts
1515
- var __decorate6 = function(decorators, target, key, desc) {
1565
+ function _ts_decorate6(decorators, target, key, desc) {
1516
1566
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
1517
1567
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
1518
1568
  r = Reflect.decorate(decorators, target, key, desc);
@@ -1521,16 +1571,15 @@ var __decorate6 = function(decorators, target, key, desc) {
1521
1571
  if (d = decorators[i])
1522
1572
  r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
1523
1573
  return c > 3 && r && Object.defineProperty(target, key, r), r;
1524
- };
1574
+ }
1575
+ var __dxlog_file10 = "/home/runner/work/dxos/dxos/packages/core/echo/echo-pipeline/src/space/space.ts";
1525
1576
  var Space = class Space2 {
1526
1577
  constructor(params) {
1527
1578
  this._addFeedLock = new Lock();
1528
1579
  this.onCredentialProcessed = new Callback2();
1529
1580
  this.stateUpdate = new Event5();
1530
- // Processes epoch credentials.
1531
- this._dataPipelineCredentialConsumer = void 0;
1532
1581
  this._isOpen = false;
1533
- assert9(params.spaceKey && params.feedProvider);
1582
+ invariant9(params.spaceKey && params.feedProvider);
1534
1583
  this._key = params.spaceKey;
1535
1584
  this._genesisFeedKey = params.genesisFeed.key;
1536
1585
  this._feedProvider = params.feedProvider;
@@ -1565,10 +1614,10 @@ var Space = class Space2 {
1565
1614
  log10("onCredentialProcessed", {
1566
1615
  credential
1567
1616
  }, {
1568
- file: "space.ts",
1569
- line: 110,
1570
- scope: this,
1571
- callSite: (f, a) => f(...a)
1617
+ F: __dxlog_file10,
1618
+ L: 107,
1619
+ S: this,
1620
+ C: (f, a) => f(...a)
1572
1621
  });
1573
1622
  this.stateUpdate.emit();
1574
1623
  });
@@ -1631,14 +1680,14 @@ var Space = class Space2 {
1631
1680
  return this._snapshotManager;
1632
1681
  }
1633
1682
  setControlFeed(feed) {
1634
- assert9(!this._controlFeed, "Control feed already set.");
1683
+ invariant9(!this._controlFeed, "Control feed already set.");
1635
1684
  this._controlFeed = feed;
1636
1685
  this._controlPipeline.setWriteFeed(feed);
1637
1686
  return this;
1638
1687
  }
1639
1688
  setDataFeed(feed) {
1640
1689
  var _a;
1641
- assert9(!this._dataFeed, "Data feed already set.");
1690
+ invariant9(!this._dataFeed, "Data feed already set.");
1642
1691
  this._dataFeed = feed;
1643
1692
  (_a = this._dataPipeline.pipeline) == null ? void 0 : _a.setWriteFeed(feed);
1644
1693
  return this;
@@ -1656,82 +1705,79 @@ var Space = class Space2 {
1656
1705
  // return this._dataPipeline?.getFeeds();
1657
1706
  // }
1658
1707
  async open() {
1659
- log10("opening...", {}, {
1660
- file: "space.ts",
1661
- line: 212,
1662
- scope: this,
1663
- callSite: (f, a) => f(...a)
1708
+ log10("opening...", void 0, {
1709
+ F: __dxlog_file10,
1710
+ L: 209,
1711
+ S: this,
1712
+ C: (f, a) => f(...a)
1664
1713
  });
1665
1714
  if (this._isOpen) {
1666
1715
  return;
1667
1716
  }
1668
1717
  await this._controlPipeline.start();
1669
1718
  await this.protocol.start();
1670
- this._dataPipelineCredentialConsumer = this._controlPipeline.spaceState.registerProcessor(this._dataPipeline.createCredentialProcessor());
1671
- await this._dataPipelineCredentialConsumer.open();
1719
+ await this._controlPipeline.spaceState.addCredentialProcessor(this._dataPipeline);
1672
1720
  this._isOpen = true;
1673
- log10("opened", {}, {
1674
- file: "space.ts",
1675
- line: 228,
1676
- scope: this,
1677
- callSite: (f, a) => f(...a)
1721
+ log10("opened", void 0, {
1722
+ F: __dxlog_file10,
1723
+ L: 220,
1724
+ S: this,
1725
+ C: (f, a) => f(...a)
1678
1726
  });
1679
1727
  }
1680
1728
  async close() {
1681
- var _a;
1682
1729
  log10("closing...", {
1683
1730
  key: this._key
1684
1731
  }, {
1685
- file: "space.ts",
1686
- line: 233,
1687
- scope: this,
1688
- callSite: (f, a) => f(...a)
1732
+ F: __dxlog_file10,
1733
+ L: 225,
1734
+ S: this,
1735
+ C: (f, a) => f(...a)
1689
1736
  });
1690
1737
  if (!this._isOpen) {
1691
1738
  return;
1692
1739
  }
1693
- await ((_a = this._dataPipelineCredentialConsumer) == null ? void 0 : _a.close());
1694
- this._dataPipelineCredentialConsumer = void 0;
1740
+ await this._controlPipeline.spaceState.removeCredentialProcessor(this._dataPipeline);
1695
1741
  await this._dataPipeline.close();
1696
1742
  await this.protocol.stop();
1697
1743
  await this._controlPipeline.stop();
1698
1744
  this._isOpen = false;
1699
- log10("closed", {}, {
1700
- file: "space.ts",
1701
- line: 247,
1702
- scope: this,
1703
- callSite: (f, a) => f(...a)
1745
+ log10("closed", void 0, {
1746
+ F: __dxlog_file10,
1747
+ L: 238,
1748
+ S: this,
1749
+ C: (f, a) => f(...a)
1704
1750
  });
1705
1751
  }
1706
1752
  async initializeDataPipeline() {
1707
- log10("initializeDataPipeline", {}, {
1708
- file: "space.ts",
1709
- line: 252,
1710
- scope: this,
1711
- callSite: (f, a) => f(...a)
1753
+ log10("initializeDataPipeline", void 0, {
1754
+ F: __dxlog_file10,
1755
+ L: 243,
1756
+ S: this,
1757
+ C: (f, a) => f(...a)
1712
1758
  });
1713
- assert9(this._isOpen, "Space must be open to initialize data pipeline.");
1759
+ invariant9(this._isOpen, "Space must be open to initialize data pipeline.");
1714
1760
  await this._dataPipeline.open();
1715
1761
  }
1716
1762
  };
1717
- __decorate6([
1763
+ _ts_decorate6([
1718
1764
  logInfo
1719
1765
  ], Space.prototype, "key", null);
1720
- __decorate6([
1766
+ _ts_decorate6([
1721
1767
  synchronized4
1722
1768
  ], Space.prototype, "open", null);
1723
- __decorate6([
1769
+ _ts_decorate6([
1724
1770
  synchronized4
1725
1771
  ], Space.prototype, "close", null);
1726
- __decorate6([
1772
+ _ts_decorate6([
1727
1773
  synchronized4
1728
1774
  ], Space.prototype, "initializeDataPipeline", null);
1729
- Space = __decorate6([
1775
+ Space = _ts_decorate6([
1730
1776
  trackLeaks3("open", "close")
1731
1777
  ], Space);
1732
1778
 
1733
1779
  // packages/core/echo/echo-pipeline/src/space/space-protocol.ts
1734
- import { discoveryKey, sha256 } from "@dxos/crypto";
1780
+ import { discoveryKey, subtleCrypto as subtleCrypto2 } from "@dxos/crypto";
1735
1781
  import { PublicKey as PublicKey5 } from "@dxos/keys";
1736
1782
  import { log as log11, logInfo as logInfo2 } from "@dxos/log";
1737
1783
  import { MMSTTopology } from "@dxos/network-manager";
@@ -1739,7 +1785,7 @@ import { Teleport } from "@dxos/teleport";
1739
1785
  import { BlobSync } from "@dxos/teleport-extension-object-sync";
1740
1786
  import { ReplicatorExtension } from "@dxos/teleport-extension-replicator";
1741
1787
  import { ComplexMap as ComplexMap4 } from "@dxos/util";
1742
- var __decorate7 = function(decorators, target, key, desc) {
1788
+ function _ts_decorate7(decorators, target, key, desc) {
1743
1789
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
1744
1790
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
1745
1791
  r = Reflect.decorate(decorators, target, key, desc);
@@ -1748,7 +1794,8 @@ var __decorate7 = function(decorators, target, key, desc) {
1748
1794
  if (d = decorators[i])
1749
1795
  r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
1750
1796
  return c > 3 && r && Object.defineProperty(target, key, r), r;
1751
- };
1797
+ }
1798
+ var __dxlog_file11 = "/home/runner/work/dxos/dxos/packages/core/echo/echo-pipeline/src/space/space-protocol.ts";
1752
1799
  var MOCK_AUTH_PROVIDER = async (nonce) => Buffer.from("mock");
1753
1800
  var MOCK_AUTH_VERIFIER = async (nonce, credential) => true;
1754
1801
  var SpaceProtocol = class {
@@ -1762,7 +1809,7 @@ var SpaceProtocol = class {
1762
1809
  this.blobSync = new BlobSync({
1763
1810
  blobStore
1764
1811
  });
1765
- this._topic = PublicKey5.from(discoveryKey(sha256(topic.toHex())));
1812
+ this._topic = subtleCrypto2.digest("SHA-256", topic.asBuffer()).then(discoveryKey).then(PublicKey5.from);
1766
1813
  }
1767
1814
  get sessions() {
1768
1815
  return this._sessions;
@@ -1778,10 +1825,10 @@ var SpaceProtocol = class {
1778
1825
  log11("addFeed", {
1779
1826
  key: feed.key
1780
1827
  }, {
1781
- file: "space-protocol.ts",
1782
- line: 94,
1783
- scope: this,
1784
- callSite: (f, a) => f(...a)
1828
+ F: __dxlog_file11,
1829
+ L: 96,
1830
+ S: this,
1831
+ C: (f, a) => f(...a)
1785
1832
  });
1786
1833
  this._feeds.add(feed);
1787
1834
  for (const session of this._sessions.values()) {
@@ -1799,41 +1846,41 @@ var SpaceProtocol = class {
1799
1846
  sampleSize: 20
1800
1847
  };
1801
1848
  await this.blobSync.open();
1802
- log11("starting...", {}, {
1803
- file: "space-protocol.ts",
1804
- line: 119,
1805
- scope: this,
1806
- callSite: (f, a) => f(...a)
1849
+ log11("starting...", void 0, {
1850
+ F: __dxlog_file11,
1851
+ L: 121,
1852
+ S: this,
1853
+ C: (f, a) => f(...a)
1807
1854
  });
1808
1855
  this._connection = await this._networkManager.joinSwarm({
1809
1856
  protocolProvider: this._createProtocolProvider(credentials),
1810
1857
  peerId: this._swarmIdentity.peerKey,
1811
- topic: this._topic,
1858
+ topic: await this._topic,
1812
1859
  topology: new MMSTTopology(topologyConfig),
1813
1860
  label: `Protocol swarm: ${this._topic}`
1814
1861
  });
1815
- log11("started", {}, {
1816
- file: "space-protocol.ts",
1817
- line: 128,
1818
- scope: this,
1819
- callSite: (f, a) => f(...a)
1862
+ log11("started", void 0, {
1863
+ F: __dxlog_file11,
1864
+ L: 130,
1865
+ S: this,
1866
+ C: (f, a) => f(...a)
1820
1867
  });
1821
1868
  }
1822
1869
  async stop() {
1823
1870
  await this.blobSync.close();
1824
1871
  if (this._connection) {
1825
- log11("stopping...", {}, {
1826
- file: "space-protocol.ts",
1827
- line: 135,
1828
- scope: this,
1829
- callSite: (f, a) => f(...a)
1872
+ log11("stopping...", void 0, {
1873
+ F: __dxlog_file11,
1874
+ L: 137,
1875
+ S: this,
1876
+ C: (f, a) => f(...a)
1830
1877
  });
1831
1878
  await this._connection.close();
1832
- log11("stopped", {}, {
1833
- file: "space-protocol.ts",
1834
- line: 137,
1835
- scope: this,
1836
- callSite: (f, a) => f(...a)
1879
+ log11("stopped", void 0, {
1880
+ F: __dxlog_file11,
1881
+ L: 139,
1882
+ S: this,
1883
+ C: (f, a) => f(...a)
1837
1884
  });
1838
1885
  }
1839
1886
  }
@@ -1854,10 +1901,10 @@ var SpaceProtocol = class {
1854
1901
  };
1855
1902
  }
1856
1903
  };
1857
- __decorate7([
1904
+ _ts_decorate7([
1858
1905
  logInfo2
1859
1906
  ], SpaceProtocol.prototype, "_topic", void 0);
1860
- __decorate7([
1907
+ _ts_decorate7([
1861
1908
  logInfo2
1862
1909
  ], SpaceProtocol.prototype, "_ownPeerKey", null);
1863
1910
  var AuthStatus;
@@ -1884,6 +1931,9 @@ var SpaceProtocolSession = class {
1884
1931
  get authStatus() {
1885
1932
  return this._authStatus;
1886
1933
  }
1934
+ get stats() {
1935
+ return this._teleport.stats;
1936
+ }
1887
1937
  get stream() {
1888
1938
  return this._teleport.stream;
1889
1939
  }
@@ -1894,11 +1944,11 @@ var SpaceProtocolSession = class {
1894
1944
  verifier: this._swarmIdentity.credentialAuthenticator,
1895
1945
  onAuthSuccess: () => {
1896
1946
  var _a;
1897
- log11("Peer authenticated", {}, {
1898
- file: "space-protocol.ts",
1899
- line: 230,
1900
- scope: this,
1901
- callSite: (f, a) => f(...a)
1947
+ log11("Peer authenticated", void 0, {
1948
+ F: __dxlog_file11,
1949
+ L: 236,
1950
+ S: this,
1951
+ C: (f, a) => f(...a)
1902
1952
  });
1903
1953
  this._authStatus = AuthStatus.SUCCESS;
1904
1954
  (_a = this._onSessionAuth) == null ? void 0 : _a.call(this, this._teleport);
@@ -1916,10 +1966,10 @@ var SpaceProtocolSession = class {
1916
1966
  await this._teleport.close();
1917
1967
  }
1918
1968
  };
1919
- __decorate7([
1969
+ _ts_decorate7([
1920
1970
  logInfo2
1921
1971
  ], SpaceProtocolSession.prototype, "_wireParams", void 0);
1922
- __decorate7([
1972
+ _ts_decorate7([
1923
1973
  logInfo2
1924
1974
  ], SpaceProtocolSession.prototype, "authStatus", null);
1925
1975
 
@@ -1930,7 +1980,7 @@ import { PublicKey as PublicKey6 } from "@dxos/keys";
1930
1980
  import { log as log12 } from "@dxos/log";
1931
1981
  import { trace } from "@dxos/protocols";
1932
1982
  import { ComplexMap as ComplexMap5 } from "@dxos/util";
1933
- var __decorate8 = function(decorators, target, key, desc) {
1983
+ function _ts_decorate8(decorators, target, key, desc) {
1934
1984
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
1935
1985
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
1936
1986
  r = Reflect.decorate(decorators, target, key, desc);
@@ -1939,7 +1989,8 @@ var __decorate8 = function(decorators, target, key, desc) {
1939
1989
  if (d = decorators[i])
1940
1990
  r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
1941
1991
  return c > 3 && r && Object.defineProperty(target, key, r), r;
1942
- };
1992
+ }
1993
+ var __dxlog_file12 = "/home/runner/work/dxos/dxos/packages/core/echo/echo-pipeline/src/space/space-manager.ts";
1943
1994
  var SpaceManager = class SpaceManager2 {
1944
1995
  constructor({ feedStore, networkManager, modelFactory, metadataStore, snapshotStore, blobStore }) {
1945
1996
  this._spaces = new ComplexMap5(PublicKey6.hash);
@@ -1967,18 +2018,18 @@ var SpaceManager = class SpaceManager2 {
1967
2018
  log12.trace("dxos.echo.space-manager.construct-space", trace.begin({
1968
2019
  id: this._instanceId
1969
2020
  }), {
1970
- file: "space-manager.ts",
1971
- line: 97,
1972
- scope: this,
1973
- callSite: (f, a) => f(...a)
2021
+ F: __dxlog_file12,
2022
+ L: 97,
2023
+ S: this,
2024
+ C: (f, a) => f(...a)
1974
2025
  });
1975
2026
  log12("constructing space...", {
1976
2027
  spaceKey: metadata.genesisFeedKey
1977
2028
  }, {
1978
- file: "space-manager.ts",
1979
- line: 98,
1980
- scope: this,
1981
- callSite: (f, a) => f(...a)
2029
+ F: __dxlog_file12,
2030
+ L: 98,
2031
+ S: this,
2032
+ C: (f, a) => f(...a)
1982
2033
  });
1983
2034
  const genesisFeed = await this._feedStore.openFeed((_a = metadata.genesisFeedKey) != null ? _a : failUndefined2());
1984
2035
  const spaceKey = metadata.key;
@@ -2005,21 +2056,21 @@ var SpaceManager = class SpaceManager2 {
2005
2056
  log12.trace("dxos.echo.space-manager.construct-space", trace.end({
2006
2057
  id: this._instanceId
2007
2058
  }), {
2008
- file: "space-manager.ts",
2009
- line: 125,
2010
- scope: this,
2011
- callSite: (f, a) => f(...a)
2059
+ F: __dxlog_file12,
2060
+ L: 125,
2061
+ S: this,
2062
+ C: (f, a) => f(...a)
2012
2063
  });
2013
2064
  return space;
2014
2065
  }
2015
2066
  };
2016
- __decorate8([
2067
+ _ts_decorate8([
2017
2068
  synchronized5
2018
2069
  ], SpaceManager.prototype, "open", null);
2019
- __decorate8([
2070
+ _ts_decorate8([
2020
2071
  synchronized5
2021
2072
  ], SpaceManager.prototype, "close", null);
2022
- SpaceManager = __decorate8([
2073
+ SpaceManager = _ts_decorate8([
2023
2074
  trackLeaks4("open", "close")
2024
2075
  ], SpaceManager);
2025
2076
 
@@ -2049,4 +2100,4 @@ export {
2049
2100
  SpaceProtocolSession,
2050
2101
  SpaceManager
2051
2102
  };
2052
- //# sourceMappingURL=chunk-RD75WUUV.mjs.map
2103
+ //# sourceMappingURL=chunk-RFRZMQ5T.mjs.map