@dxos/echo-pipeline 0.1.53-main.e7b89d1 → 0.1.53-main.f5aedb7

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.
@@ -1,14 +1,14 @@
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
10
  import { arrayToBuffer } from "@dxos/util";
11
- var __decorate = function(decorators, target, key, desc) {
11
+ function _ts_decorate(decorators, target, key, desc) {
12
12
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
13
13
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
14
14
  r = Reflect.decorate(decorators, target, key, desc);
@@ -17,7 +17,8 @@ var __decorate = function(decorators, target, key, desc) {
17
17
  if (d = decorators[i])
18
18
  r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
19
19
  return c > 3 && r && Object.defineProperty(target, key, r), r;
20
- };
20
+ }
21
+ var __dxlog_file = "/home/runner/work/dxos/dxos/packages/core/echo/echo-pipeline/src/metadata/metadata-store.ts";
21
22
  var emptyEchoMetadata = () => ({
22
23
  version: STORAGE_VERSION,
23
24
  spaces: [],
@@ -62,10 +63,10 @@ var MetadataStore = class {
62
63
  size: dataSize,
63
64
  checksum
64
65
  }, {
65
- file: "metadata-store.ts",
66
- line: 69,
67
- scope: this,
68
- callSite: (f, a) => f(...a)
66
+ F: __dxlog_file,
67
+ L: 69,
68
+ S: this,
69
+ C: (f, a) => f(...a)
69
70
  });
70
71
  if (fileLength < dataSize + 8) {
71
72
  throw new DataCorruptionError("Metadata size is smaller than expected.");
@@ -80,10 +81,10 @@ var MetadataStore = class {
80
81
  log.error("failed to load metadata", {
81
82
  err
82
83
  }, {
83
- file: "metadata-store.ts",
84
- line: 84,
85
- scope: this,
86
- callSite: (f, a) => f(...a)
84
+ F: __dxlog_file,
85
+ L: 84,
86
+ S: this,
87
+ C: (f, a) => f(...a)
87
88
  });
88
89
  this._metadata = emptyEchoMetadata();
89
90
  } finally {
@@ -112,10 +113,10 @@ var MetadataStore = class {
112
113
  size: encoded.length,
113
114
  checksum
114
115
  }, {
115
- file: "metadata-store.ts",
116
- line: 116,
117
- scope: this,
118
- callSite: (f, a) => f(...a)
116
+ F: __dxlog_file,
117
+ L: 116,
118
+ S: this,
119
+ C: (f, a) => f(...a)
119
120
  });
120
121
  } finally {
121
122
  await file.close();
@@ -127,18 +128,18 @@ var MetadataStore = class {
127
128
  return this._metadata.identity.haloSpace;
128
129
  }
129
130
  const space = this.spaces.find((space2) => space2.key === spaceKey);
130
- assert(space, "Space not found");
131
+ invariant(space, "Space not found");
131
132
  return space;
132
133
  }
133
134
  /**
134
135
  * Clears storage - doesn't work for now.
135
136
  */
136
137
  async clear() {
137
- log("clearing all metadata", {}, {
138
- file: "metadata-store.ts",
139
- line: 137,
140
- scope: this,
141
- callSite: (f, a) => f(...a)
138
+ log("clearing all metadata", void 0, {
139
+ F: __dxlog_file,
140
+ L: 137,
141
+ S: this,
142
+ C: (f, a) => f(...a)
142
143
  });
143
144
  await this._directory.delete();
144
145
  this._metadata = emptyEchoMetadata();
@@ -147,13 +148,13 @@ var MetadataStore = class {
147
148
  return this._metadata.identity;
148
149
  }
149
150
  async setIdentityRecord(record) {
150
- assert(!this._metadata.identity, "Cannot overwrite existing identity in metadata");
151
+ invariant(!this._metadata.identity, "Cannot overwrite existing identity in metadata");
151
152
  this._metadata.identity = record;
152
153
  await this._save();
153
154
  }
154
155
  async addSpace(record) {
155
156
  var _a, _b, _c;
156
- assert(!((_a = this._metadata.spaces) != null ? _a : []).find((space) => space.key === record.key), "Cannot overwrite existing space in metadata");
157
+ invariant(!((_a = this._metadata.spaces) != null ? _a : []).find((space) => space.key === record.key), "Cannot overwrite existing space in metadata");
157
158
  ((_c = (_b = this._metadata).spaces) != null ? _c : _b.spaces = []).push(record);
158
159
  await this._save();
159
160
  }
@@ -176,10 +177,10 @@ var MetadataStore = class {
176
177
  await this._save();
177
178
  }
178
179
  };
179
- __decorate([
180
+ _ts_decorate([
180
181
  synchronized
181
182
  ], MetadataStore.prototype, "load", null);
182
- __decorate([
183
+ _ts_decorate([
183
184
  synchronized
184
185
  ], MetadataStore.prototype, "_save", null);
185
186
  var fromBytesInt32 = (buf) => buf.readInt32LE(0);
@@ -191,10 +192,10 @@ var codec = schema2.getCodecForType("dxos.echo.feed.FeedMessage");
191
192
  var valueEncoding = createCodecEncoding(codec);
192
193
 
193
194
  // packages/core/echo/echo-pipeline/src/common/feeds.ts
194
- import assert2 from "@dxos/node-std/assert";
195
+ import invariant2 from "tiny-invariant";
195
196
  var createMappedFeedWriter = (mapper, writer) => {
196
- assert2(mapper);
197
- assert2(writer);
197
+ invariant2(mapper);
198
+ invariant2(writer);
198
199
  return {
199
200
  write: async (data, options) => await writer.write(await mapper(data), options)
200
201
  };
@@ -205,7 +206,7 @@ import { Event as Event2 } from "@dxos/async";
205
206
  import { timed } from "@dxos/debug";
206
207
  import { log as log2 } from "@dxos/log";
207
208
  import { Timeframe } from "@dxos/timeframe";
208
- var __decorate2 = function(decorators, target, key, desc) {
209
+ function _ts_decorate2(decorators, target, key, desc) {
209
210
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
210
211
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
211
212
  r = Reflect.decorate(decorators, target, key, desc);
@@ -214,7 +215,8 @@ var __decorate2 = function(decorators, target, key, desc) {
214
215
  if (d = decorators[i])
215
216
  r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
216
217
  return c > 3 && r && Object.defineProperty(target, key, r), r;
217
- };
218
+ }
219
+ var __dxlog_file2 = "/home/runner/work/dxos/dxos/packages/core/echo/echo-pipeline/src/pipeline/timeframe-clock.ts";
218
220
  var mapTimeframeToFeedIndexes = (timeframe) => timeframe.frames().map(([feedKey, index]) => ({
219
221
  feedKey,
220
222
  index
@@ -273,10 +275,10 @@ var TimeframeClock = class {
273
275
  target,
274
276
  current: this._timeframe
275
277
  }, {
276
- file: "timeframe-clock.ts",
277
- line: 73,
278
- scope: this,
279
- callSite: (f, a) => f(...a)
278
+ F: __dxlog_file2,
279
+ L: 73,
280
+ S: this,
281
+ C: (f, a) => f(...a)
280
282
  });
281
283
  await this.update.waitForCondition(() => {
282
284
  log2("check if reached", {
@@ -284,21 +286,21 @@ var TimeframeClock = class {
284
286
  current: this._timeframe,
285
287
  deps: Timeframe.dependencies(target, this._timeframe)
286
288
  }, {
287
- file: "timeframe-clock.ts",
288
- line: 75,
289
- scope: this,
290
- callSite: (f, a) => f(...a)
289
+ F: __dxlog_file2,
290
+ L: 75,
291
+ S: this,
292
+ C: (f, a) => f(...a)
291
293
  });
292
294
  return Timeframe.dependencies(target, this._timeframe).isEmpty();
293
295
  });
294
296
  }
295
297
  };
296
- __decorate2([
298
+ _ts_decorate2([
297
299
  timed(5e3)
298
300
  ], TimeframeClock.prototype, "waitUntilReached", null);
299
301
 
300
302
  // packages/core/echo/echo-pipeline/src/pipeline/pipeline.ts
301
- import assert4 from "@dxos/node-std/assert";
303
+ import invariant4 from "tiny-invariant";
302
304
  import { Event as Event3, sleep, synchronized as synchronized2, Trigger } from "@dxos/async";
303
305
  import { Context, rejectOnDispose } from "@dxos/context";
304
306
  import { failUndefined } from "@dxos/debug";
@@ -309,24 +311,29 @@ import { Timeframe as Timeframe2 } from "@dxos/timeframe";
309
311
  import { ComplexMap } from "@dxos/util";
310
312
 
311
313
  // 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");
314
+ import invariant3 from "tiny-invariant";
315
+ import { log as log3 } from "@dxos/log";
316
+ var __dxlog_file3 = "/home/runner/work/dxos/dxos/packages/core/echo/echo-pipeline/src/pipeline/message-selector.ts";
315
317
  var createMessageSelector = (timeframeClock) => {
316
318
  return (messages) => {
317
319
  for (let i = 0; i < messages.length; i++) {
318
320
  const { data: { timeframe } } = messages[i];
319
- assert3(timeframe);
321
+ invariant3(timeframe);
320
322
  if (!timeframeClock.hasGaps(timeframe)) {
321
323
  return i;
322
324
  }
323
325
  }
324
- log3("Skipping...");
326
+ log3("Skipping...", void 0, {
327
+ F: __dxlog_file3,
328
+ L: 34,
329
+ S: void 0,
330
+ C: (f, a) => f(...a)
331
+ });
325
332
  };
326
333
  };
327
334
 
328
335
  // packages/core/echo/echo-pipeline/src/pipeline/pipeline.ts
329
- var __decorate3 = function(decorators, target, key, desc) {
336
+ function _ts_decorate3(decorators, target, key, desc) {
330
337
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
331
338
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
332
339
  r = Reflect.decorate(decorators, target, key, desc);
@@ -335,7 +342,8 @@ var __decorate3 = function(decorators, target, key, desc) {
335
342
  if (d = decorators[i])
336
343
  r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
337
344
  return c > 3 && r && Object.defineProperty(target, key, r), r;
338
- };
345
+ }
346
+ var __dxlog_file4 = "/home/runner/work/dxos/dxos/packages/core/echo/echo-pipeline/src/pipeline/pipeline.ts";
339
347
  var PipelineState = class {
340
348
  // prettier-ignore
341
349
  constructor(_feeds, _timeframeClock) {
@@ -391,10 +399,10 @@ var PipelineState = class {
391
399
  current: this.timeframe,
392
400
  target: this.targetTimeframe
393
401
  }, {
394
- file: "pipeline.ts",
395
- line: 118,
396
- scope: this,
397
- callSite: (f, a) => f(...a)
402
+ F: __dxlog_file4,
403
+ L: 118,
404
+ S: this,
405
+ C: (f, a) => f(...a)
398
406
  });
399
407
  (_a = this._reachedTargetPromise) != null ? _a : this._reachedTargetPromise = Promise.race([
400
408
  this._timeframeClock.update.waitForCondition(() => {
@@ -421,10 +429,10 @@ var PipelineState = class {
421
429
  target: this.targetTimeframe,
422
430
  dependencies: Timeframe2.dependencies(this.targetTimeframe, this.timeframe)
423
431
  }, {
424
- file: "pipeline.ts",
425
- line: 144,
426
- scope: this,
427
- callSite: (f, a) => f(...a)
432
+ F: __dxlog_file4,
433
+ L: 144,
434
+ S: this,
435
+ C: (f, a) => f(...a)
428
436
  });
429
437
  })
430
438
  ]);
@@ -451,7 +459,7 @@ var Pipeline = class {
451
459
  return this._state;
452
460
  }
453
461
  get writer() {
454
- assert4(this._writer, "Writer not set.");
462
+ invariant4(this._writer, "Writer not set.");
455
463
  return this._writer;
456
464
  }
457
465
  getFeeds() {
@@ -470,8 +478,8 @@ var Pipeline = class {
470
478
  return this._feeds.has(feedKey);
471
479
  }
472
480
  setWriteFeed(feed) {
473
- assert4(!this._writer, "Writer already set.");
474
- assert4(feed.properties.writable, "Feed must be writable.");
481
+ invariant4(!this._writer, "Writer already set.");
482
+ invariant4(feed.properties.writable, "Feed must be writable.");
475
483
  this._writer = createMappedFeedWriter((payload) => ({
476
484
  timeframe: this._timeframeClock.timeframe,
477
485
  payload
@@ -479,37 +487,37 @@ var Pipeline = class {
479
487
  }
480
488
  async start() {
481
489
  log4("starting...", {}, {
482
- file: "pipeline.ts",
483
- line: 264,
484
- scope: this,
485
- callSite: (f, a) => f(...a)
490
+ F: __dxlog_file4,
491
+ L: 264,
492
+ S: this,
493
+ C: (f, a) => f(...a)
486
494
  });
487
495
  await this._initIterator();
488
496
  await this._feedSetIterator.open();
489
- log4("started", {}, {
490
- file: "pipeline.ts",
491
- line: 267,
492
- scope: this,
493
- callSite: (f, a) => f(...a)
497
+ log4("started", void 0, {
498
+ F: __dxlog_file4,
499
+ L: 267,
500
+ S: this,
501
+ C: (f, a) => f(...a)
494
502
  });
495
503
  this._isStarted = true;
496
504
  }
497
505
  async stop() {
498
506
  var _a;
499
507
  log4("stopping...", {}, {
500
- file: "pipeline.ts",
501
- line: 273,
502
- scope: this,
503
- callSite: (f, a) => f(...a)
508
+ F: __dxlog_file4,
509
+ L: 273,
510
+ S: this,
511
+ C: (f, a) => f(...a)
504
512
  });
505
513
  this._isStopping = true;
506
514
  await ((_a = this._feedSetIterator) == null ? void 0 : _a.close());
507
515
  await this._processingTrigger.wait();
508
- log4("stopped", {}, {
509
- file: "pipeline.ts",
510
- line: 277,
511
- scope: this,
512
- callSite: (f, a) => f(...a)
516
+ log4("stopped", void 0, {
517
+ F: __dxlog_file4,
518
+ L: 277,
519
+ S: this,
520
+ C: (f, a) => f(...a)
513
521
  });
514
522
  this._isStarted = false;
515
523
  }
@@ -517,7 +525,7 @@ var Pipeline = class {
517
525
  * @param timeframe Timeframe of already processed messages. The pipeline will start processing messages AFTER this timeframe.
518
526
  */
519
527
  async setCursor(timeframe) {
520
- assert4(!this._isStarted || this._isPaused, "Invalid state.");
528
+ invariant4(!this._isStarted || this._isPaused, "Invalid state.");
521
529
  this._state._startTimeframe = timeframe;
522
530
  this._timeframeClock.setTimeframe(timeframe);
523
531
  for (const feed of this._feeds.values()) {
@@ -533,7 +541,7 @@ var Pipeline = class {
533
541
  * Calling pause while processing will cause a deadlock.
534
542
  */
535
543
  async pause() {
536
- assert4(this._isStarted, "Pipeline is not open.");
544
+ invariant4(this._isStarted, "Pipeline is not open.");
537
545
  if (this._isPaused) {
538
546
  return;
539
547
  }
@@ -542,8 +550,8 @@ var Pipeline = class {
542
550
  this._isPaused = true;
543
551
  }
544
552
  async unpause() {
545
- assert4(this._isStarted, "Pipeline is not open.");
546
- assert4(this._isPaused, "Pipeline is not paused.");
553
+ invariant4(this._isStarted, "Pipeline is not open.");
554
+ invariant4(this._isPaused, "Pipeline is not paused.");
547
555
  this._pauseTrigger.wake();
548
556
  this._isPaused = false;
549
557
  }
@@ -552,15 +560,15 @@ var Pipeline = class {
552
560
  * Updates the timeframe clock after the message has bee processed.
553
561
  */
554
562
  async *consume() {
555
- assert4(!this._isOpen, "Pipeline is already being consumed.");
563
+ invariant4(!this._isOpen, "Pipeline is already being consumed.");
556
564
  this._isOpen = true;
557
- assert4(this._feedSetIterator, "Iterator not initialized.");
565
+ invariant4(this._feedSetIterator, "Iterator not initialized.");
558
566
  let lastFeedSetIterator = this._feedSetIterator;
559
567
  let iterable = lastFeedSetIterator[Symbol.asyncIterator]();
560
568
  while (!this._isStopping) {
561
569
  await this._pauseTrigger.wait();
562
570
  if (lastFeedSetIterator !== this._feedSetIterator) {
563
- assert4(this._feedSetIterator, "Iterator not initialized.");
571
+ invariant4(this._feedSetIterator, "Iterator not initialized.");
564
572
  lastFeedSetIterator = this._feedSetIterator;
565
573
  iterable = lastFeedSetIterator[Symbol.asyncIterator]();
566
574
  }
@@ -582,11 +590,11 @@ var Pipeline = class {
582
590
  const timeframe = this._state._startTimeframe;
583
591
  const seq = (_a = timeframe.get(feed.key)) != null ? _a : 0;
584
592
  feed.undownload({
585
- callback: () => log4("Undownloaded", {}, {
586
- file: "pipeline.ts",
587
- line: 371,
588
- scope: this,
589
- callSite: (f, a) => f(...a)
593
+ callback: () => log4("Undownloaded", void 0, {
594
+ F: __dxlog_file4,
595
+ L: 371,
596
+ S: this,
597
+ C: (f, a) => f(...a)
590
598
  })
591
599
  });
592
600
  feed.download({
@@ -596,10 +604,10 @@ var Pipeline = class {
596
604
  log4("failed to download feed", {
597
605
  err
598
606
  }, {
599
- file: "pipeline.ts",
600
- line: 374,
601
- scope: this,
602
- callSite: (f, a) => f(...a)
607
+ F: __dxlog_file4,
608
+ L: 374,
609
+ S: this,
610
+ C: (f, a) => f(...a)
603
611
  });
604
612
  });
605
613
  }
@@ -609,11 +617,11 @@ var Pipeline = class {
609
617
  stallTimeout: 1e3
610
618
  });
611
619
  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)
620
+ log4.warn(`Stalled after ${iterator.options.stallTimeout}ms with ${iterator.size} feeds.`, void 0, {
621
+ F: __dxlog_file4,
622
+ L: 384,
623
+ S: this,
624
+ C: (f, a) => f(...a)
617
625
  });
618
626
  this._state.stalled.emit();
619
627
  });
@@ -622,30 +630,31 @@ var Pipeline = class {
622
630
  }
623
631
  }
624
632
  };
625
- __decorate3([
633
+ _ts_decorate3([
626
634
  synchronized2
627
635
  ], Pipeline.prototype, "start", null);
628
- __decorate3([
636
+ _ts_decorate3([
629
637
  synchronized2
630
638
  ], Pipeline.prototype, "stop", null);
631
- __decorate3([
639
+ _ts_decorate3([
632
640
  synchronized2
633
641
  ], Pipeline.prototype, "setCursor", null);
634
- __decorate3([
642
+ _ts_decorate3([
635
643
  synchronized2
636
644
  ], Pipeline.prototype, "pause", null);
637
- __decorate3([
645
+ _ts_decorate3([
638
646
  synchronized2
639
647
  ], Pipeline.prototype, "unpause", null);
640
648
 
641
649
  // packages/core/echo/echo-pipeline/src/space/auth.ts
642
- import assert5 from "@dxos/node-std/assert";
650
+ import invariant5 from "tiny-invariant";
643
651
  import { runInContext, scheduleTask } from "@dxos/async";
644
652
  import { Context as Context2 } from "@dxos/context";
645
653
  import { randomBytes } from "@dxos/crypto";
646
654
  import { log as log5 } from "@dxos/log";
647
655
  import { schema as schema3 } from "@dxos/protocols";
648
656
  import { RpcExtension } from "@dxos/teleport";
657
+ var __dxlog_file5 = "/home/runner/work/dxos/dxos/packages/core/echo/echo-pipeline/src/space/auth.ts";
649
658
  var AuthExtension = class extends RpcExtension {
650
659
  constructor(_authParams) {
651
660
  super({
@@ -660,11 +669,11 @@ var AuthExtension = class extends RpcExtension {
660
669
  this._authParams = _authParams;
661
670
  this._ctx = new Context2({
662
671
  onError: (err) => {
663
- log5.catch(err, {}, {
664
- file: "auth.ts",
665
- line: 29,
666
- scope: this,
667
- callSite: (f, a) => f(...a)
672
+ log5.catch(err, void 0, {
673
+ F: __dxlog_file5,
674
+ L: 29,
675
+ S: this,
676
+ C: (f, a) => f(...a)
668
677
  });
669
678
  }
670
679
  });
@@ -683,10 +692,10 @@ var AuthExtension = class extends RpcExtension {
683
692
  };
684
693
  } catch (err) {
685
694
  log5.error("failed to generate auth credentials", err, {
686
- file: "auth.ts",
687
- line: 56,
688
- scope: this,
689
- callSite: (f, a) => f(...a)
695
+ F: __dxlog_file5,
696
+ L: 56,
697
+ S: this,
698
+ C: (f, a) => f(...a)
690
699
  });
691
700
  throw new Error("auth rejected");
692
701
  }
@@ -702,16 +711,16 @@ var AuthExtension = class extends RpcExtension {
702
711
  const { credential } = await this.rpc.AuthService.authenticate({
703
712
  challenge
704
713
  });
705
- assert5((credential == null ? void 0 : credential.length) > 0, "invalid credential");
714
+ invariant5((credential == null ? void 0 : credential.length) > 0, "invalid credential");
706
715
  const success = await this._authParams.verifier(challenge, credential);
707
- assert5(success, "credential not verified");
716
+ invariant5(success, "credential not verified");
708
717
  runInContext(this._ctx, () => this._authParams.onAuthSuccess());
709
718
  } catch (err) {
710
719
  log5("auth failed", err, {
711
- file: "auth.ts",
712
- line: 75,
713
- scope: this,
714
- callSite: (f, a) => f(...a)
720
+ F: __dxlog_file5,
721
+ L: 75,
722
+ S: this,
723
+ C: (f, a) => f(...a)
715
724
  });
716
725
  this.close();
717
726
  this._authParams.onAuthFailure();
@@ -725,11 +734,12 @@ var AuthExtension = class extends RpcExtension {
725
734
  };
726
735
 
727
736
  // packages/core/echo/echo-pipeline/src/dbhost/data-service-host.ts
728
- import assert6 from "@dxos/node-std/assert";
737
+ import invariant6 from "tiny-invariant";
729
738
  import { Stream } from "@dxos/codec-protobuf";
730
739
  import { tagMutationsInBatch, setMetadataOnObject } from "@dxos/echo-db";
731
740
  import { log as log6 } from "@dxos/log";
732
741
  import { ComplexMap as ComplexMap2 } from "@dxos/util";
742
+ var __dxlog_file6 = "/home/runner/work/dxos/dxos/packages/core/echo/echo-pipeline/src/dbhost/data-service-host.ts";
733
743
  var DataServiceHost = class {
734
744
  constructor(_itemManager, _itemDemuxer, _writeStream) {
735
745
  this._itemManager = _itemManager;
@@ -751,15 +761,15 @@ var DataServiceHost = class {
751
761
  this._itemDemuxer.mutation.on(ctx, (message) => {
752
762
  var _a;
753
763
  const { batch, meta } = message;
754
- assert6(!meta.clientTag, "Unexpected client tag in mutation message");
764
+ invariant6(!meta.clientTag, "Unexpected client tag in mutation message");
755
765
  log6("message", {
756
766
  batch,
757
767
  meta
758
768
  }, {
759
- file: "data-service-host.ts",
760
- line: 51,
761
- scope: this,
762
- callSite: (f, a) => f(...a)
769
+ F: __dxlog_file6,
770
+ L: 51,
771
+ S: this,
772
+ C: (f, a) => f(...a)
763
773
  });
764
774
  const clientTag = this._clientTagMap.get([
765
775
  message.meta.feedKey,
@@ -784,15 +794,15 @@ var DataServiceHost = class {
784
794
  }
785
795
  async write(request) {
786
796
  var _a, _b;
787
- assert6(this._writeStream, "Cannot write mutations in readonly mode");
797
+ invariant6(this._writeStream, "Cannot write mutations in readonly mode");
788
798
  log6("write", {
789
799
  clientTag: request.clientTag,
790
800
  objectCount: (_b = (_a = request.batch.objects) == null ? void 0 : _a.length) != null ? _b : 0
791
801
  }, {
792
- file: "data-service-host.ts",
793
- line: 79,
794
- scope: this,
795
- callSite: (f, a) => f(...a)
802
+ F: __dxlog_file6,
803
+ L: 79,
804
+ S: this,
805
+ C: (f, a) => f(...a)
796
806
  });
797
807
  const message = createDataMessage(request.batch);
798
808
  const receipt = await this._writeStream.write(message, {
@@ -803,10 +813,10 @@ var DataServiceHost = class {
803
813
  feedKey: receipt2.feedKey,
804
814
  seq: receipt2.seq
805
815
  }, {
806
- file: "data-service-host.ts",
807
- line: 88,
808
- scope: this,
809
- callSite: (f, a) => f(...a)
816
+ F: __dxlog_file6,
817
+ L: 88,
818
+ S: this,
819
+ C: (f, a) => f(...a)
810
820
  });
811
821
  this._clientTagMap.set([
812
822
  receipt2.feedKey,
@@ -876,7 +886,7 @@ import { timed as timed2 } from "@dxos/debug";
876
886
  import { PublicKey as PublicKey2 } from "@dxos/keys";
877
887
  import { schema as schema4 } from "@dxos/protocols";
878
888
  import { BlobMeta } from "@dxos/protocols/proto/dxos/echo/blob";
879
- var __decorate4 = function(decorators, target, key, desc) {
889
+ function _ts_decorate4(decorators, target, key, desc) {
880
890
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
881
891
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
882
892
  r = Reflect.decorate(decorators, target, key, desc);
@@ -885,7 +895,7 @@ var __decorate4 = function(decorators, target, key, desc) {
885
895
  if (d = decorators[i])
886
896
  r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
887
897
  return c > 3 && r && Object.defineProperty(target, key, r), r;
888
- };
898
+ }
889
899
  var SnapshotManager = class SnapshotManager2 {
890
900
  // prettier-ignore
891
901
  constructor(_snapshotStore, _blobStore, _blobSync) {
@@ -916,10 +926,10 @@ var SnapshotManager = class SnapshotManager2 {
916
926
  return PublicKey2.from(id).toHex();
917
927
  }
918
928
  };
919
- __decorate4([
929
+ _ts_decorate4([
920
930
  timed2(1e4)
921
931
  ], SnapshotManager.prototype, "load", null);
922
- SnapshotManager = __decorate4([
932
+ SnapshotManager = _ts_decorate4([
923
933
  trackLeaks("open", "close")
924
934
  ], SnapshotManager);
925
935
 
@@ -969,11 +979,12 @@ var SnapshotStore = class {
969
979
  };
970
980
 
971
981
  // packages/core/echo/echo-pipeline/src/dbhost/data-service.ts
972
- import assert7 from "@dxos/node-std/assert";
982
+ import invariant7 from "tiny-invariant";
973
983
  import { raise } from "@dxos/debug";
974
984
  import { PublicKey as PublicKey3 } from "@dxos/keys";
975
985
  import { log as log7 } from "@dxos/log";
976
986
  import { ComplexMap as ComplexMap3 } from "@dxos/util";
987
+ var __dxlog_file7 = "/home/runner/work/dxos/dxos/packages/core/echo/echo-pipeline/src/dbhost/data-service.ts";
977
988
  var DataServiceSubscriptions = class {
978
989
  constructor() {
979
990
  this._spaces = new ComplexMap3(PublicKey3.hash);
@@ -985,10 +996,10 @@ var DataServiceSubscriptions = class {
985
996
  log7("Registering space", {
986
997
  spaceKey
987
998
  }, {
988
- file: "data-service.ts",
989
- line: 31,
990
- scope: this,
991
- callSite: (f, a) => f(...a)
999
+ F: __dxlog_file7,
1000
+ L: 31,
1001
+ S: this,
1002
+ C: (f, a) => f(...a)
992
1003
  });
993
1004
  this._spaces.set(spaceKey, host);
994
1005
  }
@@ -996,10 +1007,10 @@ var DataServiceSubscriptions = class {
996
1007
  log7("Unregistering space", {
997
1008
  spaceKey
998
1009
  }, {
999
- file: "data-service.ts",
1000
- line: 36,
1001
- scope: this,
1002
- callSite: (f, a) => f(...a)
1010
+ F: __dxlog_file7,
1011
+ L: 36,
1012
+ S: this,
1013
+ C: (f, a) => f(...a)
1003
1014
  });
1004
1015
  this._spaces.delete(spaceKey);
1005
1016
  }
@@ -1013,21 +1024,21 @@ var DataServiceImpl = class {
1013
1024
  }
1014
1025
  subscribe(request) {
1015
1026
  var _a;
1016
- assert7(request.spaceKey);
1027
+ invariant7(request.spaceKey);
1017
1028
  const host = (_a = this._subscriptions.getDataService(request.spaceKey)) != null ? _a : raise(new Error(`space not found: ${request.spaceKey}`));
1018
1029
  return host.subscribe();
1019
1030
  }
1020
1031
  write(request) {
1021
1032
  var _a;
1022
- assert7(request.spaceKey);
1023
- assert7(request.batch);
1033
+ invariant7(request.spaceKey);
1034
+ invariant7(request.batch);
1024
1035
  const host = (_a = this._subscriptions.getDataService(request.spaceKey)) != null ? _a : raise(new Error(`space not found: ${request.spaceKey}`));
1025
1036
  return host.write(request);
1026
1037
  }
1027
1038
  };
1028
1039
 
1029
1040
  // packages/core/echo/echo-pipeline/src/space/data-pipeline.ts
1030
- import assert8 from "@dxos/node-std/assert";
1041
+ import invariant8 from "tiny-invariant";
1031
1042
  import { Event as Event4, scheduleTask as scheduleTask2, synchronized as synchronized3, trackLeaks as trackLeaks2 } from "@dxos/async";
1032
1043
  import { Context as Context3 } from "@dxos/context";
1033
1044
  import { checkCredentialType } from "@dxos/credentials";
@@ -1035,7 +1046,7 @@ import { getStateMachineFromItem, ItemManager } from "@dxos/echo-db";
1035
1046
  import { CancelledError } from "@dxos/errors";
1036
1047
  import { log as log8 } from "@dxos/log";
1037
1048
  import { Timeframe as Timeframe3 } from "@dxos/timeframe";
1038
- var __decorate5 = function(decorators, target, key, desc) {
1049
+ function _ts_decorate5(decorators, target, key, desc) {
1039
1050
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
1040
1051
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
1041
1052
  r = Reflect.decorate(decorators, target, key, desc);
@@ -1044,7 +1055,8 @@ var __decorate5 = function(decorators, target, key, desc) {
1044
1055
  if (d = decorators[i])
1045
1056
  r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
1046
1057
  return c > 3 && r && Object.defineProperty(target, key, r), r;
1047
- };
1058
+ }
1059
+ var __dxlog_file8 = "/home/runner/work/dxos/dxos/packages/core/echo/echo-pipeline/src/space/data-pipeline.ts";
1048
1060
  var MESSAGES_PER_SNAPSHOT = 10;
1049
1061
  var AUTOMATIC_SNAPSHOT_DEBOUNCE_INTERVAL = 5e3;
1050
1062
  var TIMEFRAME_SAVE_DEBOUNCE_INTERVAL = 500;
@@ -1100,8 +1112,8 @@ var DataPipeline = class DataPipeline2 {
1100
1112
  }
1101
1113
  const feedWriter = {
1102
1114
  write: (data, options) => {
1103
- assert8(this._pipeline, "Pipeline is not initialized.");
1104
- assert8(this.currentEpoch, "Epoch is not initialized.");
1115
+ invariant8(this._pipeline, "Pipeline is not initialized.");
1116
+ invariant8(this.currentEpoch, "Epoch is not initialized.");
1105
1117
  return this._pipeline.writer.write({
1106
1118
  data
1107
1119
  }, options);
@@ -1120,11 +1132,11 @@ var DataPipeline = class DataPipeline2 {
1120
1132
  if (!this._isOpen) {
1121
1133
  return;
1122
1134
  }
1123
- log8("close", {}, {
1124
- file: "data-pipeline.ts",
1125
- line: 174,
1126
- scope: this,
1127
- callSite: (f, a) => f(...a)
1135
+ log8("close", void 0, {
1136
+ F: __dxlog_file8,
1137
+ L: 174,
1138
+ S: this,
1139
+ C: (f, a) => f(...a)
1128
1140
  });
1129
1141
  this._isOpen = false;
1130
1142
  await this._ctx.dispose();
@@ -1135,11 +1147,11 @@ var DataPipeline = class DataPipeline2 {
1135
1147
  await this._saveTargetTimeframe(this._pipeline.state.timeframe);
1136
1148
  }
1137
1149
  } catch (err) {
1138
- log8.catch(err, {}, {
1139
- file: "data-pipeline.ts",
1140
- line: 187,
1141
- scope: this,
1142
- callSite: (f, a) => f(...a)
1150
+ log8.catch(err, void 0, {
1151
+ F: __dxlog_file8,
1152
+ L: 187,
1153
+ S: this,
1154
+ C: (f, a) => f(...a)
1143
1155
  });
1144
1156
  }
1145
1157
  await ((_b = this.databaseHost) == null ? void 0 : _b.close());
@@ -1151,17 +1163,17 @@ var DataPipeline = class DataPipeline2 {
1151
1163
  await this._processEpochInSeparateTask(this.currentEpoch);
1152
1164
  await waitForOneEpoch;
1153
1165
  }
1154
- assert8(this._pipeline, "Pipeline is not initialized.");
1166
+ invariant8(this._pipeline, "Pipeline is not initialized.");
1155
1167
  for await (const msg of this._pipeline.consume()) {
1156
1168
  const { feedKey, seq, data } = msg;
1157
1169
  log8("processing message", {
1158
1170
  feedKey,
1159
1171
  seq
1160
1172
  }, {
1161
- file: "data-pipeline.ts",
1162
- line: 204,
1163
- scope: this,
1164
- callSite: (f, a) => f(...a)
1173
+ F: __dxlog_file8,
1174
+ L: 204,
1175
+ S: this,
1176
+ C: (f, a) => f(...a)
1165
1177
  });
1166
1178
  try {
1167
1179
  if (data.payload.data) {
@@ -1170,10 +1182,10 @@ var DataPipeline = class DataPipeline2 {
1170
1182
  log8.error("Could not find feed.", {
1171
1183
  feedKey
1172
1184
  }, {
1173
- file: "data-pipeline.ts",
1174
- line: 210,
1175
- scope: this,
1176
- callSite: (f, a) => f(...a)
1185
+ F: __dxlog_file8,
1186
+ L: 210,
1187
+ S: this,
1188
+ C: (f, a) => f(...a)
1177
1189
  });
1178
1190
  continue;
1179
1191
  }
@@ -1191,25 +1203,25 @@ var DataPipeline = class DataPipeline2 {
1191
1203
  seq,
1192
1204
  spaceKey: this._params.spaceKey.toHex()
1193
1205
  }, {
1194
- file: "data-pipeline.ts",
1195
- line: 224,
1196
- scope: this,
1197
- callSite: (f, a) => f(...a)
1206
+ F: __dxlog_file8,
1207
+ L: 224,
1208
+ S: this,
1209
+ C: (f, a) => f(...a)
1198
1210
  });
1199
1211
  await this._noteTargetStateIfNeeded(this._pipeline.state.pendingTimeframe);
1200
1212
  }
1201
1213
  } catch (err) {
1202
- log8.catch(err, {}, {
1203
- file: "data-pipeline.ts",
1204
- line: 234,
1205
- scope: this,
1206
- callSite: (f, a) => f(...a)
1214
+ log8.catch(err, void 0, {
1215
+ F: __dxlog_file8,
1216
+ L: 234,
1217
+ S: this,
1218
+ C: (f, a) => f(...a)
1207
1219
  });
1208
1220
  }
1209
1221
  }
1210
1222
  }
1211
1223
  _createSnapshot() {
1212
- assert8(this.databaseHost, "Database backend is not initialized.");
1224
+ invariant8(this.databaseHost, "Database backend is not initialized.");
1213
1225
  return {
1214
1226
  spaceKey: this._params.spaceKey.asUint8Array(),
1215
1227
  timeframe: this._pipeline.state.timeframe,
@@ -1228,18 +1240,17 @@ var DataPipeline = class DataPipeline2 {
1228
1240
  try {
1229
1241
  const propertiesItem = this.itemManager.items.find((item) => {
1230
1242
  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";
1243
+ 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
1244
  });
1234
1245
  if (propertiesItem) {
1235
1246
  cache.properties = (_a = getStateMachineFromItem(propertiesItem)) == null ? void 0 : _a.snapshot();
1236
1247
  }
1237
1248
  } catch (err) {
1238
1249
  log8.warn("Failed to cache properties", err, {
1239
- file: "data-pipeline.ts",
1240
- line: 269,
1241
- scope: this,
1242
- callSite: (f, a) => f(...a)
1250
+ F: __dxlog_file8,
1251
+ L: 269,
1252
+ S: this,
1253
+ C: (f, a) => f(...a)
1243
1254
  });
1244
1255
  }
1245
1256
  await this._params.metadataStore.setCache(this._params.spaceKey, cache);
@@ -1262,18 +1273,18 @@ var DataPipeline = class DataPipeline2 {
1262
1273
  const ctx = new Context3({
1263
1274
  onError: (err) => {
1264
1275
  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)
1276
+ log8("Epoch processing cancelled.", void 0, {
1277
+ F: __dxlog_file8,
1278
+ L: 301,
1279
+ S: this,
1280
+ C: (f, a) => f(...a)
1270
1281
  });
1271
1282
  } else {
1272
- log8.catch(err, {}, {
1273
- file: "data-pipeline.ts",
1274
- line: 303,
1275
- scope: this,
1276
- callSite: (f, a) => f(...a)
1283
+ log8.catch(err, void 0, {
1284
+ F: __dxlog_file8,
1285
+ L: 303,
1286
+ S: this,
1287
+ C: (f, a) => f(...a)
1277
1288
  });
1278
1289
  }
1279
1290
  }
@@ -1286,10 +1297,10 @@ var DataPipeline = class DataPipeline2 {
1286
1297
  log8("process epoch", {
1287
1298
  epoch
1288
1299
  }, {
1289
- file: "data-pipeline.ts",
1290
- line: 313,
1291
- scope: this,
1292
- callSite: (f, a) => f(...a)
1300
+ F: __dxlog_file8,
1301
+ L: 313,
1302
+ S: this,
1303
+ C: (f, a) => f(...a)
1293
1304
  });
1294
1305
  await this._processEpoch(ctx, epoch.subject.assertion);
1295
1306
  this.appliedEpoch = epoch;
@@ -1297,38 +1308,38 @@ var DataPipeline = class DataPipeline2 {
1297
1308
  });
1298
1309
  }
1299
1310
  async _processEpoch(ctx, epoch) {
1300
- assert8(this._isOpen, "Space is closed.");
1301
- assert8(this._pipeline);
1311
+ invariant8(this._isOpen, "Space is closed.");
1312
+ invariant8(this._pipeline);
1302
1313
  this._lastProcessedEpoch = epoch.number;
1303
1314
  log8("Processing epoch", {
1304
1315
  epoch
1305
1316
  }, {
1306
- file: "data-pipeline.ts",
1307
- line: 327,
1308
- scope: this,
1309
- callSite: (f, a) => f(...a)
1317
+ F: __dxlog_file8,
1318
+ L: 327,
1319
+ S: this,
1320
+ C: (f, a) => f(...a)
1310
1321
  });
1311
1322
  if (epoch.snapshotCid) {
1312
1323
  const snapshot = await this._params.snapshotManager.load(ctx, epoch.snapshotCid);
1313
1324
  this.databaseHost._itemDemuxer.restoreFromSnapshot(snapshot.database);
1314
1325
  }
1315
- log8("restarting pipeline for epoch", {}, {
1316
- file: "data-pipeline.ts",
1317
- line: 335,
1318
- scope: this,
1319
- callSite: (f, a) => f(...a)
1326
+ log8("restarting pipeline for epoch", void 0, {
1327
+ F: __dxlog_file8,
1328
+ L: 335,
1329
+ S: this,
1330
+ C: (f, a) => f(...a)
1320
1331
  });
1321
1332
  await this._pipeline.pause();
1322
1333
  await this._pipeline.setCursor(epoch.timeframe);
1323
1334
  await this._pipeline.unpause();
1324
1335
  }
1325
1336
  async waitUntilTimeframe(timeframe) {
1326
- assert8(this._pipeline, "Pipeline is not initialized.");
1337
+ invariant8(this._pipeline, "Pipeline is not initialized.");
1327
1338
  await this._pipeline.state.waitUntilTimeframe(timeframe);
1328
1339
  }
1329
1340
  async createEpoch() {
1330
- assert8(this._pipeline);
1331
- assert8(this.currentEpoch);
1341
+ invariant8(this._pipeline);
1342
+ invariant8(this.currentEpoch);
1332
1343
  await this._pipeline.pause();
1333
1344
  const snapshot = await this._createSnapshot();
1334
1345
  const snapshotCid = await this._params.snapshotManager.store(snapshot);
@@ -1345,24 +1356,24 @@ var DataPipeline = class DataPipeline2 {
1345
1356
  await this.onNewEpoch.waitForCondition(() => !!this.currentEpoch);
1346
1357
  }
1347
1358
  };
1348
- __decorate5([
1359
+ _ts_decorate5([
1349
1360
  synchronized3
1350
1361
  ], DataPipeline.prototype, "open", null);
1351
- __decorate5([
1362
+ _ts_decorate5([
1352
1363
  synchronized3
1353
1364
  ], DataPipeline.prototype, "close", null);
1354
- __decorate5([
1365
+ _ts_decorate5([
1355
1366
  synchronized3
1356
1367
  ], DataPipeline.prototype, "_processEpoch", null);
1357
- __decorate5([
1368
+ _ts_decorate5([
1358
1369
  synchronized3
1359
1370
  ], DataPipeline.prototype, "createEpoch", null);
1360
- DataPipeline = __decorate5([
1371
+ DataPipeline = _ts_decorate5([
1361
1372
  trackLeaks2("open", "close")
1362
1373
  ], DataPipeline);
1363
1374
 
1364
1375
  // packages/core/echo/echo-pipeline/src/space/space.ts
1365
- import assert9 from "@dxos/node-std/assert";
1376
+ import invariant9 from "tiny-invariant";
1366
1377
  import { Event as Event5, synchronized as synchronized4, trackLeaks as trackLeaks3, Lock } from "@dxos/async";
1367
1378
  import { log as log10, logInfo } from "@dxos/log";
1368
1379
  import { AdmittedFeed as AdmittedFeed2 } from "@dxos/protocols/proto/dxos/halo/credentials";
@@ -1375,6 +1386,7 @@ import { log as log9 } from "@dxos/log";
1375
1386
  import { AdmittedFeed } from "@dxos/protocols/proto/dxos/halo/credentials";
1376
1387
  import { Timeframe as Timeframe4 } from "@dxos/timeframe";
1377
1388
  import { Callback } from "@dxos/util";
1389
+ var __dxlog_file9 = "/home/runner/work/dxos/dxos/packages/core/echo/echo-pipeline/src/space/control-pipeline.ts";
1378
1390
  var TIMEFRAME_SAVE_DEBOUNCE_INTERVAL2 = 500;
1379
1391
  var ControlPipeline = class {
1380
1392
  constructor({ spaceKey, genesisFeed, feedProvider, metadataStore }) {
@@ -1389,21 +1401,21 @@ var ControlPipeline = class {
1389
1401
  log9("feed admitted", {
1390
1402
  key: info.key
1391
1403
  }, {
1392
- file: "control-pipeline.ts",
1393
- line: 51,
1394
- scope: this,
1395
- callSite: (f, a) => f(...a)
1404
+ F: __dxlog_file9,
1405
+ L: 51,
1406
+ S: this,
1407
+ C: (f, a) => f(...a)
1396
1408
  });
1397
1409
  if (info.assertion.designation === AdmittedFeed.Designation.CONTROL && !info.key.equals(genesisFeed.key)) {
1398
1410
  try {
1399
1411
  const feed = await feedProvider(info.key);
1400
1412
  await this._pipeline.addFeed(feed);
1401
1413
  } catch (err) {
1402
- log9.catch(err, {}, {
1403
- file: "control-pipeline.ts",
1404
- line: 59,
1405
- scope: this,
1406
- callSite: (f, a) => f(...a)
1414
+ log9.catch(err, void 0, {
1415
+ F: __dxlog_file9,
1416
+ L: 59,
1417
+ S: this,
1418
+ C: (f, a) => f(...a)
1407
1419
  });
1408
1420
  }
1409
1421
  }
@@ -1422,11 +1434,11 @@ var ControlPipeline = class {
1422
1434
  this._pipeline.setWriteFeed(feed);
1423
1435
  }
1424
1436
  async start() {
1425
- log9("starting...", {}, {
1426
- file: "control-pipeline.ts",
1427
- line: 83,
1428
- scope: this,
1429
- callSite: (f, a) => f(...a)
1437
+ log9("starting...", void 0, {
1438
+ F: __dxlog_file9,
1439
+ L: 83,
1440
+ S: this,
1441
+ C: (f, a) => f(...a)
1430
1442
  });
1431
1443
  setTimeout(async () => {
1432
1444
  for await (const msg of this._pipeline.consume()) {
@@ -1435,10 +1447,10 @@ var ControlPipeline = class {
1435
1447
  key: msg.feedKey,
1436
1448
  seq: msg.seq
1437
1449
  }, {
1438
- file: "control-pipeline.ts",
1439
- line: 88,
1440
- scope: this,
1441
- callSite: (f, a) => f(...a)
1450
+ F: __dxlog_file9,
1451
+ L: 88,
1452
+ S: this,
1453
+ C: (f, a) => f(...a)
1442
1454
  });
1443
1455
  if (msg.data.payload.credential) {
1444
1456
  const result = await this._spaceStateMachine.process(msg.data.payload.credential.credential, PublicKey4.from(msg.feedKey));
@@ -1446,31 +1458,31 @@ var ControlPipeline = class {
1446
1458
  log9.warn("processing failed", {
1447
1459
  msg
1448
1460
  }, {
1449
- file: "control-pipeline.ts",
1450
- line: 95,
1451
- scope: this,
1452
- callSite: (f, a) => f(...a)
1461
+ F: __dxlog_file9,
1462
+ L: 95,
1463
+ S: this,
1464
+ C: (f, a) => f(...a)
1453
1465
  });
1454
1466
  } else {
1455
1467
  await this._noteTargetStateIfNeeded(this._pipeline.state.pendingTimeframe);
1456
1468
  }
1457
1469
  }
1458
1470
  } catch (err) {
1459
- log9.catch(err, {}, {
1460
- file: "control-pipeline.ts",
1461
- line: 101,
1462
- scope: this,
1463
- callSite: (f, a) => f(...a)
1471
+ log9.catch(err, void 0, {
1472
+ F: __dxlog_file9,
1473
+ L: 101,
1474
+ S: this,
1475
+ C: (f, a) => f(...a)
1464
1476
  });
1465
1477
  }
1466
1478
  }
1467
1479
  });
1468
1480
  await this._pipeline.start();
1469
- log9("started", {}, {
1470
- file: "control-pipeline.ts",
1471
- line: 107,
1472
- scope: this,
1473
- callSite: (f, a) => f(...a)
1481
+ log9("started", void 0, {
1482
+ F: __dxlog_file9,
1483
+ L: 107,
1484
+ S: this,
1485
+ C: (f, a) => f(...a)
1474
1486
  });
1475
1487
  }
1476
1488
  async _noteTargetStateIfNeeded(timeframe) {
@@ -1480,19 +1492,19 @@ var ControlPipeline = class {
1480
1492
  }
1481
1493
  }
1482
1494
  async stop() {
1483
- log9("stopping...", {}, {
1484
- file: "control-pipeline.ts",
1485
- line: 121,
1486
- scope: this,
1487
- callSite: (f, a) => f(...a)
1495
+ log9("stopping...", void 0, {
1496
+ F: __dxlog_file9,
1497
+ L: 121,
1498
+ S: this,
1499
+ C: (f, a) => f(...a)
1488
1500
  });
1489
1501
  await this._pipeline.stop();
1490
1502
  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)
1503
+ log9("stopped", void 0, {
1504
+ F: __dxlog_file9,
1505
+ L: 124,
1506
+ S: this,
1507
+ C: (f, a) => f(...a)
1496
1508
  });
1497
1509
  }
1498
1510
  async _saveTargetTimeframe(timeframe) {
@@ -1502,18 +1514,18 @@ var ControlPipeline = class {
1502
1514
  await this._metadata.setSpaceControlLatestTimeframe(this._spaceKey, newTimeframe);
1503
1515
  this._targetTimeframe = newTimeframe;
1504
1516
  } catch (err) {
1505
- log9(err, {}, {
1506
- file: "control-pipeline.ts",
1507
- line: 133,
1508
- scope: this,
1509
- callSite: (f, a) => f(...a)
1517
+ log9(err, void 0, {
1518
+ F: __dxlog_file9,
1519
+ L: 133,
1520
+ S: this,
1521
+ C: (f, a) => f(...a)
1510
1522
  });
1511
1523
  }
1512
1524
  }
1513
1525
  };
1514
1526
 
1515
1527
  // packages/core/echo/echo-pipeline/src/space/space.ts
1516
- var __decorate6 = function(decorators, target, key, desc) {
1528
+ function _ts_decorate6(decorators, target, key, desc) {
1517
1529
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
1518
1530
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
1519
1531
  r = Reflect.decorate(decorators, target, key, desc);
@@ -1522,7 +1534,8 @@ var __decorate6 = function(decorators, target, key, desc) {
1522
1534
  if (d = decorators[i])
1523
1535
  r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
1524
1536
  return c > 3 && r && Object.defineProperty(target, key, r), r;
1525
- };
1537
+ }
1538
+ var __dxlog_file10 = "/home/runner/work/dxos/dxos/packages/core/echo/echo-pipeline/src/space/space.ts";
1526
1539
  var Space = class Space2 {
1527
1540
  constructor(params) {
1528
1541
  this._addFeedLock = new Lock();
@@ -1531,7 +1544,7 @@ var Space = class Space2 {
1531
1544
  // Processes epoch credentials.
1532
1545
  this._dataPipelineCredentialConsumer = void 0;
1533
1546
  this._isOpen = false;
1534
- assert9(params.spaceKey && params.feedProvider);
1547
+ invariant9(params.spaceKey && params.feedProvider);
1535
1548
  this._key = params.spaceKey;
1536
1549
  this._genesisFeedKey = params.genesisFeed.key;
1537
1550
  this._feedProvider = params.feedProvider;
@@ -1566,10 +1579,10 @@ var Space = class Space2 {
1566
1579
  log10("onCredentialProcessed", {
1567
1580
  credential
1568
1581
  }, {
1569
- file: "space.ts",
1570
- line: 110,
1571
- scope: this,
1572
- callSite: (f, a) => f(...a)
1582
+ F: __dxlog_file10,
1583
+ L: 110,
1584
+ S: this,
1585
+ C: (f, a) => f(...a)
1573
1586
  });
1574
1587
  this.stateUpdate.emit();
1575
1588
  });
@@ -1632,14 +1645,14 @@ var Space = class Space2 {
1632
1645
  return this._snapshotManager;
1633
1646
  }
1634
1647
  setControlFeed(feed) {
1635
- assert9(!this._controlFeed, "Control feed already set.");
1648
+ invariant9(!this._controlFeed, "Control feed already set.");
1636
1649
  this._controlFeed = feed;
1637
1650
  this._controlPipeline.setWriteFeed(feed);
1638
1651
  return this;
1639
1652
  }
1640
1653
  setDataFeed(feed) {
1641
1654
  var _a;
1642
- assert9(!this._dataFeed, "Data feed already set.");
1655
+ invariant9(!this._dataFeed, "Data feed already set.");
1643
1656
  this._dataFeed = feed;
1644
1657
  (_a = this._dataPipeline.pipeline) == null ? void 0 : _a.setWriteFeed(feed);
1645
1658
  return this;
@@ -1657,11 +1670,11 @@ var Space = class Space2 {
1657
1670
  // return this._dataPipeline?.getFeeds();
1658
1671
  // }
1659
1672
  async open() {
1660
- log10("opening...", {}, {
1661
- file: "space.ts",
1662
- line: 212,
1663
- scope: this,
1664
- callSite: (f, a) => f(...a)
1673
+ log10("opening...", void 0, {
1674
+ F: __dxlog_file10,
1675
+ L: 212,
1676
+ S: this,
1677
+ C: (f, a) => f(...a)
1665
1678
  });
1666
1679
  if (this._isOpen) {
1667
1680
  return;
@@ -1671,11 +1684,11 @@ var Space = class Space2 {
1671
1684
  this._dataPipelineCredentialConsumer = this._controlPipeline.spaceState.registerProcessor(this._dataPipeline.createCredentialProcessor());
1672
1685
  await this._dataPipelineCredentialConsumer.open();
1673
1686
  this._isOpen = true;
1674
- log10("opened", {}, {
1675
- file: "space.ts",
1676
- line: 228,
1677
- scope: this,
1678
- callSite: (f, a) => f(...a)
1687
+ log10("opened", void 0, {
1688
+ F: __dxlog_file10,
1689
+ L: 228,
1690
+ S: this,
1691
+ C: (f, a) => f(...a)
1679
1692
  });
1680
1693
  }
1681
1694
  async close() {
@@ -1683,10 +1696,10 @@ var Space = class Space2 {
1683
1696
  log10("closing...", {
1684
1697
  key: this._key
1685
1698
  }, {
1686
- file: "space.ts",
1687
- line: 233,
1688
- scope: this,
1689
- callSite: (f, a) => f(...a)
1699
+ F: __dxlog_file10,
1700
+ L: 233,
1701
+ S: this,
1702
+ C: (f, a) => f(...a)
1690
1703
  });
1691
1704
  if (!this._isOpen) {
1692
1705
  return;
@@ -1697,42 +1710,42 @@ var Space = class Space2 {
1697
1710
  await this.protocol.stop();
1698
1711
  await this._controlPipeline.stop();
1699
1712
  this._isOpen = false;
1700
- log10("closed", {}, {
1701
- file: "space.ts",
1702
- line: 247,
1703
- scope: this,
1704
- callSite: (f, a) => f(...a)
1713
+ log10("closed", void 0, {
1714
+ F: __dxlog_file10,
1715
+ L: 247,
1716
+ S: this,
1717
+ C: (f, a) => f(...a)
1705
1718
  });
1706
1719
  }
1707
1720
  async initializeDataPipeline() {
1708
- log10("initializeDataPipeline", {}, {
1709
- file: "space.ts",
1710
- line: 252,
1711
- scope: this,
1712
- callSite: (f, a) => f(...a)
1721
+ log10("initializeDataPipeline", void 0, {
1722
+ F: __dxlog_file10,
1723
+ L: 252,
1724
+ S: this,
1725
+ C: (f, a) => f(...a)
1713
1726
  });
1714
- assert9(this._isOpen, "Space must be open to initialize data pipeline.");
1727
+ invariant9(this._isOpen, "Space must be open to initialize data pipeline.");
1715
1728
  await this._dataPipeline.open();
1716
1729
  }
1717
1730
  };
1718
- __decorate6([
1731
+ _ts_decorate6([
1719
1732
  logInfo
1720
1733
  ], Space.prototype, "key", null);
1721
- __decorate6([
1734
+ _ts_decorate6([
1722
1735
  synchronized4
1723
1736
  ], Space.prototype, "open", null);
1724
- __decorate6([
1737
+ _ts_decorate6([
1725
1738
  synchronized4
1726
1739
  ], Space.prototype, "close", null);
1727
- __decorate6([
1740
+ _ts_decorate6([
1728
1741
  synchronized4
1729
1742
  ], Space.prototype, "initializeDataPipeline", null);
1730
- Space = __decorate6([
1743
+ Space = _ts_decorate6([
1731
1744
  trackLeaks3("open", "close")
1732
1745
  ], Space);
1733
1746
 
1734
1747
  // packages/core/echo/echo-pipeline/src/space/space-protocol.ts
1735
- import { discoveryKey, sha256 } from "@dxos/crypto";
1748
+ import { discoveryKey, subtleCrypto as subtleCrypto2 } from "@dxos/crypto";
1736
1749
  import { PublicKey as PublicKey5 } from "@dxos/keys";
1737
1750
  import { log as log11, logInfo as logInfo2 } from "@dxos/log";
1738
1751
  import { MMSTTopology } from "@dxos/network-manager";
@@ -1740,7 +1753,7 @@ import { Teleport } from "@dxos/teleport";
1740
1753
  import { BlobSync } from "@dxos/teleport-extension-object-sync";
1741
1754
  import { ReplicatorExtension } from "@dxos/teleport-extension-replicator";
1742
1755
  import { ComplexMap as ComplexMap4 } from "@dxos/util";
1743
- var __decorate7 = function(decorators, target, key, desc) {
1756
+ function _ts_decorate7(decorators, target, key, desc) {
1744
1757
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
1745
1758
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
1746
1759
  r = Reflect.decorate(decorators, target, key, desc);
@@ -1749,7 +1762,8 @@ var __decorate7 = function(decorators, target, key, desc) {
1749
1762
  if (d = decorators[i])
1750
1763
  r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
1751
1764
  return c > 3 && r && Object.defineProperty(target, key, r), r;
1752
- };
1765
+ }
1766
+ var __dxlog_file11 = "/home/runner/work/dxos/dxos/packages/core/echo/echo-pipeline/src/space/space-protocol.ts";
1753
1767
  var MOCK_AUTH_PROVIDER = async (nonce) => Buffer.from("mock");
1754
1768
  var MOCK_AUTH_VERIFIER = async (nonce, credential) => true;
1755
1769
  var SpaceProtocol = class {
@@ -1763,7 +1777,7 @@ var SpaceProtocol = class {
1763
1777
  this.blobSync = new BlobSync({
1764
1778
  blobStore
1765
1779
  });
1766
- this._topic = PublicKey5.from(discoveryKey(sha256(topic.toHex())));
1780
+ this._topic = subtleCrypto2.digest("SHA-256", topic.asBuffer()).then(discoveryKey).then(PublicKey5.from);
1767
1781
  }
1768
1782
  get sessions() {
1769
1783
  return this._sessions;
@@ -1779,10 +1793,10 @@ var SpaceProtocol = class {
1779
1793
  log11("addFeed", {
1780
1794
  key: feed.key
1781
1795
  }, {
1782
- file: "space-protocol.ts",
1783
- line: 96,
1784
- scope: this,
1785
- callSite: (f, a) => f(...a)
1796
+ F: __dxlog_file11,
1797
+ L: 96,
1798
+ S: this,
1799
+ C: (f, a) => f(...a)
1786
1800
  });
1787
1801
  this._feeds.add(feed);
1788
1802
  for (const session of this._sessions.values()) {
@@ -1800,41 +1814,41 @@ var SpaceProtocol = class {
1800
1814
  sampleSize: 20
1801
1815
  };
1802
1816
  await this.blobSync.open();
1803
- log11("starting...", {}, {
1804
- file: "space-protocol.ts",
1805
- line: 121,
1806
- scope: this,
1807
- callSite: (f, a) => f(...a)
1817
+ log11("starting...", void 0, {
1818
+ F: __dxlog_file11,
1819
+ L: 121,
1820
+ S: this,
1821
+ C: (f, a) => f(...a)
1808
1822
  });
1809
1823
  this._connection = await this._networkManager.joinSwarm({
1810
1824
  protocolProvider: this._createProtocolProvider(credentials),
1811
1825
  peerId: this._swarmIdentity.peerKey,
1812
- topic: this._topic,
1826
+ topic: await this._topic,
1813
1827
  topology: new MMSTTopology(topologyConfig),
1814
1828
  label: `Protocol swarm: ${this._topic}`
1815
1829
  });
1816
- log11("started", {}, {
1817
- file: "space-protocol.ts",
1818
- line: 130,
1819
- scope: this,
1820
- callSite: (f, a) => f(...a)
1830
+ log11("started", void 0, {
1831
+ F: __dxlog_file11,
1832
+ L: 130,
1833
+ S: this,
1834
+ C: (f, a) => f(...a)
1821
1835
  });
1822
1836
  }
1823
1837
  async stop() {
1824
1838
  await this.blobSync.close();
1825
1839
  if (this._connection) {
1826
- log11("stopping...", {}, {
1827
- file: "space-protocol.ts",
1828
- line: 137,
1829
- scope: this,
1830
- callSite: (f, a) => f(...a)
1840
+ log11("stopping...", void 0, {
1841
+ F: __dxlog_file11,
1842
+ L: 137,
1843
+ S: this,
1844
+ C: (f, a) => f(...a)
1831
1845
  });
1832
1846
  await this._connection.close();
1833
- log11("stopped", {}, {
1834
- file: "space-protocol.ts",
1835
- line: 139,
1836
- scope: this,
1837
- callSite: (f, a) => f(...a)
1847
+ log11("stopped", void 0, {
1848
+ F: __dxlog_file11,
1849
+ L: 139,
1850
+ S: this,
1851
+ C: (f, a) => f(...a)
1838
1852
  });
1839
1853
  }
1840
1854
  }
@@ -1855,10 +1869,10 @@ var SpaceProtocol = class {
1855
1869
  };
1856
1870
  }
1857
1871
  };
1858
- __decorate7([
1872
+ _ts_decorate7([
1859
1873
  logInfo2
1860
1874
  ], SpaceProtocol.prototype, "_topic", void 0);
1861
- __decorate7([
1875
+ _ts_decorate7([
1862
1876
  logInfo2
1863
1877
  ], SpaceProtocol.prototype, "_ownPeerKey", null);
1864
1878
  var AuthStatus;
@@ -1898,11 +1912,11 @@ var SpaceProtocolSession = class {
1898
1912
  verifier: this._swarmIdentity.credentialAuthenticator,
1899
1913
  onAuthSuccess: () => {
1900
1914
  var _a;
1901
- log11("Peer authenticated", {}, {
1902
- file: "space-protocol.ts",
1903
- line: 236,
1904
- scope: this,
1905
- callSite: (f, a) => f(...a)
1915
+ log11("Peer authenticated", void 0, {
1916
+ F: __dxlog_file11,
1917
+ L: 236,
1918
+ S: this,
1919
+ C: (f, a) => f(...a)
1906
1920
  });
1907
1921
  this._authStatus = AuthStatus.SUCCESS;
1908
1922
  (_a = this._onSessionAuth) == null ? void 0 : _a.call(this, this._teleport);
@@ -1920,10 +1934,10 @@ var SpaceProtocolSession = class {
1920
1934
  await this._teleport.close();
1921
1935
  }
1922
1936
  };
1923
- __decorate7([
1937
+ _ts_decorate7([
1924
1938
  logInfo2
1925
1939
  ], SpaceProtocolSession.prototype, "_wireParams", void 0);
1926
- __decorate7([
1940
+ _ts_decorate7([
1927
1941
  logInfo2
1928
1942
  ], SpaceProtocolSession.prototype, "authStatus", null);
1929
1943
 
@@ -1934,7 +1948,7 @@ import { PublicKey as PublicKey6 } from "@dxos/keys";
1934
1948
  import { log as log12 } from "@dxos/log";
1935
1949
  import { trace } from "@dxos/protocols";
1936
1950
  import { ComplexMap as ComplexMap5 } from "@dxos/util";
1937
- var __decorate8 = function(decorators, target, key, desc) {
1951
+ function _ts_decorate8(decorators, target, key, desc) {
1938
1952
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
1939
1953
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
1940
1954
  r = Reflect.decorate(decorators, target, key, desc);
@@ -1943,7 +1957,8 @@ var __decorate8 = function(decorators, target, key, desc) {
1943
1957
  if (d = decorators[i])
1944
1958
  r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
1945
1959
  return c > 3 && r && Object.defineProperty(target, key, r), r;
1946
- };
1960
+ }
1961
+ var __dxlog_file12 = "/home/runner/work/dxos/dxos/packages/core/echo/echo-pipeline/src/space/space-manager.ts";
1947
1962
  var SpaceManager = class SpaceManager2 {
1948
1963
  constructor({ feedStore, networkManager, modelFactory, metadataStore, snapshotStore, blobStore }) {
1949
1964
  this._spaces = new ComplexMap5(PublicKey6.hash);
@@ -1971,18 +1986,18 @@ var SpaceManager = class SpaceManager2 {
1971
1986
  log12.trace("dxos.echo.space-manager.construct-space", trace.begin({
1972
1987
  id: this._instanceId
1973
1988
  }), {
1974
- file: "space-manager.ts",
1975
- line: 97,
1976
- scope: this,
1977
- callSite: (f, a) => f(...a)
1989
+ F: __dxlog_file12,
1990
+ L: 97,
1991
+ S: this,
1992
+ C: (f, a) => f(...a)
1978
1993
  });
1979
1994
  log12("constructing space...", {
1980
1995
  spaceKey: metadata.genesisFeedKey
1981
1996
  }, {
1982
- file: "space-manager.ts",
1983
- line: 98,
1984
- scope: this,
1985
- callSite: (f, a) => f(...a)
1997
+ F: __dxlog_file12,
1998
+ L: 98,
1999
+ S: this,
2000
+ C: (f, a) => f(...a)
1986
2001
  });
1987
2002
  const genesisFeed = await this._feedStore.openFeed((_a = metadata.genesisFeedKey) != null ? _a : failUndefined2());
1988
2003
  const spaceKey = metadata.key;
@@ -2009,21 +2024,21 @@ var SpaceManager = class SpaceManager2 {
2009
2024
  log12.trace("dxos.echo.space-manager.construct-space", trace.end({
2010
2025
  id: this._instanceId
2011
2026
  }), {
2012
- file: "space-manager.ts",
2013
- line: 125,
2014
- scope: this,
2015
- callSite: (f, a) => f(...a)
2027
+ F: __dxlog_file12,
2028
+ L: 125,
2029
+ S: this,
2030
+ C: (f, a) => f(...a)
2016
2031
  });
2017
2032
  return space;
2018
2033
  }
2019
2034
  };
2020
- __decorate8([
2035
+ _ts_decorate8([
2021
2036
  synchronized5
2022
2037
  ], SpaceManager.prototype, "open", null);
2023
- __decorate8([
2038
+ _ts_decorate8([
2024
2039
  synchronized5
2025
2040
  ], SpaceManager.prototype, "close", null);
2026
- SpaceManager = __decorate8([
2041
+ SpaceManager = _ts_decorate8([
2027
2042
  trackLeaks4("open", "close")
2028
2043
  ], SpaceManager);
2029
2044
 
@@ -2053,4 +2068,4 @@ export {
2053
2068
  SpaceProtocolSession,
2054
2069
  SpaceManager
2055
2070
  };
2056
- //# sourceMappingURL=chunk-VTZ6AASA.mjs.map
2071
+ //# sourceMappingURL=chunk-SCMKAWNW.mjs.map