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