@dxos/echo-pipeline 0.8.4-main.b97322e → 0.8.4-main.dedc0f3
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.
- package/dist/lib/browser/{chunk-GBFX5J5B.mjs → chunk-I4JBIZSN.mjs} +485 -322
- package/dist/lib/browser/chunk-I4JBIZSN.mjs.map +7 -0
- package/dist/lib/browser/{chunk-ANZAS5CC.mjs → chunk-MBMJB3V7.mjs} +57 -1
- package/dist/lib/browser/chunk-MBMJB3V7.mjs.map +7 -0
- package/dist/lib/browser/filter/index.mjs +3 -1
- package/dist/lib/browser/index.mjs +1236 -545
- package/dist/lib/browser/index.mjs.map +4 -4
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/testing/index.mjs +107 -44
- package/dist/lib/browser/testing/index.mjs.map +3 -3
- package/dist/lib/node-esm/{chunk-2SAZ7CCF.mjs → chunk-XJZTCD4G.mjs} +57 -1
- package/dist/lib/node-esm/chunk-XJZTCD4G.mjs.map +7 -0
- package/dist/lib/node-esm/{chunk-FQFKWA3X.mjs → chunk-YOL7JY5W.mjs} +485 -322
- package/dist/lib/node-esm/chunk-YOL7JY5W.mjs.map +7 -0
- package/dist/lib/node-esm/filter/index.mjs +3 -1
- package/dist/lib/node-esm/index.mjs +1236 -545
- package/dist/lib/node-esm/index.mjs.map +4 -4
- package/dist/lib/node-esm/meta.json +1 -1
- package/dist/lib/node-esm/testing/index.mjs +107 -44
- package/dist/lib/node-esm/testing/index.mjs.map +3 -3
- package/dist/types/src/automerge/automerge-host.d.ts +15 -28
- package/dist/types/src/automerge/automerge-host.d.ts.map +1 -1
- package/dist/types/src/automerge/collection-synchronizer.d.ts +1 -1
- package/dist/types/src/automerge/collection-synchronizer.d.ts.map +1 -1
- package/dist/types/src/automerge/echo-network-adapter.d.ts +8 -1
- package/dist/types/src/automerge/echo-network-adapter.d.ts.map +1 -1
- package/dist/types/src/automerge/echo-replicator.d.ts +20 -1
- package/dist/types/src/automerge/echo-replicator.d.ts.map +1 -1
- package/dist/types/src/automerge/leveldb-storage-adapter.d.ts +1 -1
- package/dist/types/src/automerge/leveldb-storage-adapter.d.ts.map +1 -1
- package/dist/types/src/automerge/mesh-echo-replicator-connection.d.ts +1 -0
- package/dist/types/src/automerge/mesh-echo-replicator-connection.d.ts.map +1 -1
- package/dist/types/src/automerge/mesh-echo-replicator.d.ts.map +1 -1
- package/dist/types/src/common/codec.d.ts +1 -1
- package/dist/types/src/common/codec.d.ts.map +1 -1
- package/dist/types/src/db-host/data-service.d.ts +2 -2
- package/dist/types/src/db-host/data-service.d.ts.map +1 -1
- package/dist/types/src/db-host/database-root.d.ts.map +1 -1
- package/dist/types/src/db-host/documents-synchronizer.d.ts +2 -2
- package/dist/types/src/db-host/documents-synchronizer.d.ts.map +1 -1
- package/dist/types/src/db-host/echo-host.d.ts +2 -2
- package/dist/types/src/db-host/echo-host.d.ts.map +1 -1
- package/dist/types/src/db-host/query-service.d.ts +1 -1
- package/dist/types/src/db-host/query-service.d.ts.map +1 -1
- package/dist/types/src/db-host/space-state-manager.d.ts +1 -1
- package/dist/types/src/db-host/space-state-manager.d.ts.map +1 -1
- package/dist/types/src/edge/echo-edge-replicator.d.ts +4 -2
- package/dist/types/src/edge/echo-edge-replicator.d.ts.map +1 -1
- package/dist/types/src/filter/filter-match.d.ts +4 -1
- package/dist/types/src/filter/filter-match.d.ts.map +1 -1
- package/dist/types/src/metadata/metadata-store.d.ts +1 -1
- package/dist/types/src/metadata/metadata-store.d.ts.map +1 -1
- package/dist/types/src/pipeline/pipeline.d.ts +1 -1
- package/dist/types/src/pipeline/pipeline.d.ts.map +1 -1
- package/dist/types/src/query/errors.d.ts +5 -4
- package/dist/types/src/query/errors.d.ts.map +1 -1
- package/dist/types/src/query/plan.d.ts +8 -1
- package/dist/types/src/query/plan.d.ts.map +1 -1
- package/dist/types/src/query/query-executor.d.ts +4 -1
- package/dist/types/src/query/query-executor.d.ts.map +1 -1
- package/dist/types/src/query/query-planner.d.ts +2 -0
- package/dist/types/src/query/query-planner.d.ts.map +1 -1
- package/dist/types/src/space/admission-discovery-extension.d.ts.map +1 -1
- package/dist/types/src/space/control-pipeline.d.ts +1 -1
- package/dist/types/src/space/control-pipeline.d.ts.map +1 -1
- package/dist/types/src/space/space-manager.d.ts +1 -1
- package/dist/types/src/space/space-manager.d.ts.map +1 -1
- package/dist/types/src/space/space-protocol.d.ts +1 -1
- package/dist/types/src/space/space-protocol.d.ts.map +1 -1
- package/dist/types/src/space/space.d.ts +1 -1
- package/dist/types/src/space/space.d.ts.map +1 -1
- package/dist/types/src/testing/test-agent-builder.d.ts +2 -2
- package/dist/types/src/testing/test-agent-builder.d.ts.map +1 -1
- package/dist/types/src/testing/test-replicator.d.ts +1 -0
- package/dist/types/src/testing/test-replicator.d.ts.map +1 -1
- package/dist/types/src/util.d.ts +1 -1
- package/dist/types/src/util.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +42 -38
- package/src/automerge/automerge-host.test.ts +18 -8
- package/src/automerge/automerge-host.ts +251 -65
- package/src/automerge/automerge-repo.test.ts +67 -16
- package/src/automerge/collection-synchronizer.test.ts +2 -2
- package/src/automerge/collection-synchronizer.ts +4 -4
- package/src/automerge/echo-data-monitor.ts +1 -1
- package/src/automerge/echo-network-adapter.test.ts +3 -3
- package/src/automerge/echo-network-adapter.ts +38 -6
- package/src/automerge/echo-replicator.ts +21 -1
- package/src/automerge/leveldb-storage-adapter.ts +7 -7
- package/src/automerge/mesh-echo-replicator-connection.ts +4 -0
- package/src/automerge/mesh-echo-replicator.ts +2 -1
- package/src/automerge/storage-adapter.test.ts +1 -1
- package/src/common/space-id.ts +1 -1
- package/src/db-host/data-service.ts +9 -17
- package/src/db-host/database-root.ts +2 -2
- package/src/db-host/documents-synchronizer.test.ts +1 -1
- package/src/db-host/documents-synchronizer.ts +36 -26
- package/src/db-host/echo-host.ts +13 -14
- package/src/db-host/query-service.ts +2 -1
- package/src/db-host/space-state-manager.ts +2 -2
- package/src/edge/echo-edge-replicator.test.ts +5 -3
- package/src/edge/echo-edge-replicator.ts +44 -7
- package/src/filter/filter-match.test.ts +2 -2
- package/src/filter/filter-match.ts +79 -2
- package/src/metadata/metadata-store.ts +3 -3
- package/src/pipeline/pipeline-stress.test.ts +4 -2
- package/src/pipeline/pipeline.test.ts +3 -2
- package/src/pipeline/pipeline.ts +8 -5
- package/src/query/plan.ts +12 -1
- package/src/query/query-executor.ts +66 -11
- package/src/query/query-planner.test.ts +146 -2
- package/src/query/query-planner.ts +39 -0
- package/src/space/admission-discovery-extension.ts +2 -2
- package/src/space/control-pipeline.test.ts +4 -3
- package/src/space/control-pipeline.ts +9 -6
- package/src/space/space-manager.browser.test.ts +1 -1
- package/src/space/space-manager.ts +5 -4
- package/src/space/space-protocol.browser.test.ts +2 -2
- package/src/space/space-protocol.test.ts +3 -2
- package/src/space/space-protocol.ts +6 -3
- package/src/space/space.test.ts +1 -1
- package/src/space/space.ts +3 -2
- package/src/testing/test-agent-builder.ts +4 -3
- package/src/testing/test-replicator.ts +4 -0
- package/src/util.ts +1 -1
- package/dist/lib/browser/chunk-ANZAS5CC.mjs.map +0 -7
- package/dist/lib/browser/chunk-GBFX5J5B.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-2SAZ7CCF.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-FQFKWA3X.mjs.map +0 -7
|
@@ -61,6 +61,19 @@ import { DataCorruptionError, STORAGE_VERSION } from "@dxos/protocols";
|
|
|
61
61
|
import { schema as schema2 } from "@dxos/protocols/proto";
|
|
62
62
|
import { Invitation, SpaceState } from "@dxos/protocols/proto/dxos/client/services";
|
|
63
63
|
import { ComplexMap as ComplexMap2, arrayToBuffer, forEachAsync, isNonNullable } from "@dxos/util";
|
|
64
|
+
function _define_property(obj, key, value) {
|
|
65
|
+
if (key in obj) {
|
|
66
|
+
Object.defineProperty(obj, key, {
|
|
67
|
+
value,
|
|
68
|
+
enumerable: true,
|
|
69
|
+
configurable: true,
|
|
70
|
+
writable: true
|
|
71
|
+
});
|
|
72
|
+
} else {
|
|
73
|
+
obj[key] = value;
|
|
74
|
+
}
|
|
75
|
+
return obj;
|
|
76
|
+
}
|
|
64
77
|
function _ts_decorate(decorators, target, key, desc) {
|
|
65
78
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
66
79
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -79,17 +92,6 @@ var emptyLargeSpaceMetadata = () => ({});
|
|
|
79
92
|
var EchoMetadata = schema2.getCodecForType("dxos.echo.metadata.EchoMetadata");
|
|
80
93
|
var LargeSpaceMetadata = schema2.getCodecForType("dxos.echo.metadata.LargeSpaceMetadata");
|
|
81
94
|
var MetadataStore = class {
|
|
82
|
-
constructor(directory) {
|
|
83
|
-
this._metadata = emptyEchoMetadata();
|
|
84
|
-
this._spaceLargeMetadata = new ComplexMap2(PublicKey2.hash);
|
|
85
|
-
this._metadataFile = void 0;
|
|
86
|
-
this.update = new Event();
|
|
87
|
-
this._invitationCleanupCtx = new Context(void 0, {
|
|
88
|
-
F: __dxlog_file2,
|
|
89
|
-
L: 55
|
|
90
|
-
});
|
|
91
|
-
this._directory = directory;
|
|
92
|
-
}
|
|
93
95
|
get metadata() {
|
|
94
96
|
return this._metadata;
|
|
95
97
|
}
|
|
@@ -179,7 +181,8 @@ var MetadataStore = class {
|
|
|
179
181
|
this._metadata = metadata;
|
|
180
182
|
}
|
|
181
183
|
this._metadata.spaces?.forEach((space) => {
|
|
182
|
-
|
|
184
|
+
var _space;
|
|
185
|
+
(_space = space).state ?? (_space.state = SpaceState.SPACE_ACTIVE);
|
|
183
186
|
});
|
|
184
187
|
} catch (err) {
|
|
185
188
|
log.error("failed to load metadata", {
|
|
@@ -319,10 +322,11 @@ var MetadataStore = class {
|
|
|
319
322
|
return this._metadata.invitations ?? [];
|
|
320
323
|
}
|
|
321
324
|
async addInvitation(invitation) {
|
|
325
|
+
var _this__metadata;
|
|
322
326
|
if (this._metadata.invitations?.find((i) => i.invitationId === invitation.invitationId)) {
|
|
323
327
|
return;
|
|
324
328
|
}
|
|
325
|
-
(this._metadata.invitations
|
|
329
|
+
((_this__metadata = this._metadata).invitations ?? (_this__metadata.invitations = [])).push(invitation);
|
|
326
330
|
await this._save();
|
|
327
331
|
await this.flush();
|
|
328
332
|
}
|
|
@@ -332,6 +336,7 @@ var MetadataStore = class {
|
|
|
332
336
|
await this.flush();
|
|
333
337
|
}
|
|
334
338
|
async addSpace(record) {
|
|
339
|
+
var _this__metadata;
|
|
335
340
|
invariant2(!(this._metadata.spaces ?? []).find((space) => space.key.equals(record.key)), "Cannot overwrite existing space in metadata", {
|
|
336
341
|
F: __dxlog_file2,
|
|
337
342
|
L: 300,
|
|
@@ -341,7 +346,7 @@ var MetadataStore = class {
|
|
|
341
346
|
"'Cannot overwrite existing space in metadata'"
|
|
342
347
|
]
|
|
343
348
|
});
|
|
344
|
-
(this._metadata.spaces
|
|
349
|
+
((_this__metadata = this._metadata).spaces ?? (_this__metadata.spaces = [])).push(record);
|
|
345
350
|
await this._save();
|
|
346
351
|
await this.flush();
|
|
347
352
|
}
|
|
@@ -386,6 +391,18 @@ var MetadataStore = class {
|
|
|
386
391
|
await this._save();
|
|
387
392
|
await this.flush();
|
|
388
393
|
}
|
|
394
|
+
constructor(directory) {
|
|
395
|
+
_define_property(this, "_metadata", emptyEchoMetadata());
|
|
396
|
+
_define_property(this, "_spaceLargeMetadata", new ComplexMap2(PublicKey2.hash));
|
|
397
|
+
_define_property(this, "_metadataFile", void 0);
|
|
398
|
+
_define_property(this, "update", new Event());
|
|
399
|
+
_define_property(this, "_invitationCleanupCtx", new Context(void 0, {
|
|
400
|
+
F: __dxlog_file2,
|
|
401
|
+
L: 55
|
|
402
|
+
}));
|
|
403
|
+
_define_property(this, "_directory", void 0);
|
|
404
|
+
this._directory = directory;
|
|
405
|
+
}
|
|
389
406
|
};
|
|
390
407
|
_ts_decorate([
|
|
391
408
|
synchronized
|
|
@@ -409,6 +426,19 @@ import { Event as Event2 } from "@dxos/async";
|
|
|
409
426
|
import { timed } from "@dxos/debug";
|
|
410
427
|
import { log as log2 } from "@dxos/log";
|
|
411
428
|
import { Timeframe } from "@dxos/timeframe";
|
|
429
|
+
function _define_property2(obj, key, value) {
|
|
430
|
+
if (key in obj) {
|
|
431
|
+
Object.defineProperty(obj, key, {
|
|
432
|
+
value,
|
|
433
|
+
enumerable: true,
|
|
434
|
+
configurable: true,
|
|
435
|
+
writable: true
|
|
436
|
+
});
|
|
437
|
+
} else {
|
|
438
|
+
obj[key] = value;
|
|
439
|
+
}
|
|
440
|
+
return obj;
|
|
441
|
+
}
|
|
412
442
|
function _ts_decorate2(decorators, target, key, desc) {
|
|
413
443
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
414
444
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -429,11 +459,6 @@ var startAfter = (timeframe) => timeframe.frames().map(([feedKey, index]) => ({
|
|
|
429
459
|
index: index + 1
|
|
430
460
|
}));
|
|
431
461
|
var TimeframeClock = class {
|
|
432
|
-
constructor(_timeframe = new Timeframe()) {
|
|
433
|
-
this._timeframe = _timeframe;
|
|
434
|
-
this.update = new Event2();
|
|
435
|
-
this._pendingTimeframe = _timeframe;
|
|
436
|
-
}
|
|
437
462
|
/**
|
|
438
463
|
* Timeframe that was processed by ECHO.
|
|
439
464
|
*/
|
|
@@ -492,13 +517,21 @@ var TimeframeClock = class {
|
|
|
492
517
|
return Timeframe.dependencies(target, this._timeframe).isEmpty();
|
|
493
518
|
});
|
|
494
519
|
}
|
|
520
|
+
constructor(_timeframe = new Timeframe()) {
|
|
521
|
+
_define_property2(this, "_timeframe", void 0);
|
|
522
|
+
_define_property2(this, "update", void 0);
|
|
523
|
+
_define_property2(this, "_pendingTimeframe", void 0);
|
|
524
|
+
this._timeframe = _timeframe;
|
|
525
|
+
this.update = new Event2();
|
|
526
|
+
this._pendingTimeframe = _timeframe;
|
|
527
|
+
}
|
|
495
528
|
};
|
|
496
529
|
_ts_decorate2([
|
|
497
530
|
timed(5e3)
|
|
498
531
|
], TimeframeClock.prototype, "waitUntilReached", null);
|
|
499
532
|
|
|
500
533
|
// src/pipeline/pipeline.ts
|
|
501
|
-
import { Event as Event3, sleepWithContext, synchronized as synchronized2
|
|
534
|
+
import { Event as Event3, Trigger, sleepWithContext, synchronized as synchronized2 } from "@dxos/async";
|
|
502
535
|
import { Context as Context2, rejectOnDispose } from "@dxos/context";
|
|
503
536
|
import { failUndefined } from "@dxos/debug";
|
|
504
537
|
import { FeedSetIterator } from "@dxos/feed-store";
|
|
@@ -539,6 +572,19 @@ var createMessageSelector = (timeframeClock) => {
|
|
|
539
572
|
};
|
|
540
573
|
|
|
541
574
|
// src/pipeline/pipeline.ts
|
|
575
|
+
function _define_property3(obj, key, value) {
|
|
576
|
+
if (key in obj) {
|
|
577
|
+
Object.defineProperty(obj, key, {
|
|
578
|
+
value,
|
|
579
|
+
enumerable: true,
|
|
580
|
+
configurable: true,
|
|
581
|
+
writable: true
|
|
582
|
+
});
|
|
583
|
+
} else {
|
|
584
|
+
obj[key] = value;
|
|
585
|
+
}
|
|
586
|
+
return obj;
|
|
587
|
+
}
|
|
542
588
|
function _ts_decorate3(decorators, target, key, desc) {
|
|
543
589
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
544
590
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -547,17 +593,9 @@ function _ts_decorate3(decorators, target, key, desc) {
|
|
|
547
593
|
}
|
|
548
594
|
var __dxlog_file5 = "/__w/dxos/dxos/packages/core/echo/echo-pipeline/src/pipeline/pipeline.ts";
|
|
549
595
|
var PipelineState = class {
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
this._timeframeClock
|
|
553
|
-
this._ctx = new Context2(void 0, {
|
|
554
|
-
F: __dxlog_file5,
|
|
555
|
-
L: 41
|
|
556
|
-
});
|
|
557
|
-
this.timeframeUpdate = this._timeframeClock.update;
|
|
558
|
-
this.stalled = new Event3();
|
|
559
|
-
this._startTimeframe = new Timeframe2();
|
|
560
|
-
this._reachedTarget = false;
|
|
596
|
+
// TODO(dmaretskyi): Remove?. Avoid accessing `_timeframeClock` before constructor initialization.
|
|
597
|
+
get timeframeUpdate() {
|
|
598
|
+
return this._timeframeClock.update;
|
|
561
599
|
}
|
|
562
600
|
/**
|
|
563
601
|
* Latest theoretical timeframe based on the last mutation in each feed.
|
|
@@ -603,7 +641,7 @@ var PipelineState = class {
|
|
|
603
641
|
*/
|
|
604
642
|
async waitUntilReachedTargetTimeframe({ ctx = new Context2(void 0, {
|
|
605
643
|
F: __dxlog_file5,
|
|
606
|
-
L:
|
|
644
|
+
L: 132
|
|
607
645
|
}), timeout, breakOnStall = true } = {}) {
|
|
608
646
|
log4("waitUntilReachedTargetTimeframe", {
|
|
609
647
|
timeout,
|
|
@@ -611,18 +649,18 @@ var PipelineState = class {
|
|
|
611
649
|
target: this.targetTimeframe
|
|
612
650
|
}, {
|
|
613
651
|
F: __dxlog_file5,
|
|
614
|
-
L:
|
|
652
|
+
L: 136,
|
|
615
653
|
S: this,
|
|
616
654
|
C: (f, a) => f(...a)
|
|
617
655
|
});
|
|
618
|
-
this._reachedTargetPromise
|
|
656
|
+
this._reachedTargetPromise ?? (this._reachedTargetPromise = Promise.race([
|
|
619
657
|
this._timeframeClock.update.waitForCondition(() => {
|
|
620
658
|
return Timeframe2.dependencies(this.targetTimeframe, this.timeframe).isEmpty();
|
|
621
659
|
}),
|
|
622
660
|
...breakOnStall ? [
|
|
623
661
|
this.stalled.discardParameter().waitForCount(1)
|
|
624
662
|
] : []
|
|
625
|
-
]);
|
|
663
|
+
]));
|
|
626
664
|
let done = false;
|
|
627
665
|
if (timeout) {
|
|
628
666
|
return Promise.race([
|
|
@@ -643,7 +681,7 @@ var PipelineState = class {
|
|
|
643
681
|
dependencies: Timeframe2.dependencies(this.targetTimeframe, this.timeframe)
|
|
644
682
|
}, {
|
|
645
683
|
F: __dxlog_file5,
|
|
646
|
-
L:
|
|
684
|
+
L: 164,
|
|
647
685
|
S: this,
|
|
648
686
|
C: (f, a) => f(...a)
|
|
649
687
|
});
|
|
@@ -653,30 +691,34 @@ var PipelineState = class {
|
|
|
653
691
|
return this._reachedTargetPromise;
|
|
654
692
|
}
|
|
655
693
|
}
|
|
694
|
+
constructor(_feeds, _timeframeClock) {
|
|
695
|
+
_define_property3(this, "_feeds", void 0);
|
|
696
|
+
_define_property3(this, "_timeframeClock", void 0);
|
|
697
|
+
_define_property3(this, "_ctx", void 0);
|
|
698
|
+
_define_property3(this, "stalled", void 0);
|
|
699
|
+
_define_property3(this, "_startTimeframe", void 0);
|
|
700
|
+
_define_property3(this, "_targetTimeframe", void 0);
|
|
701
|
+
_define_property3(this, "_reachedTargetPromise", void 0);
|
|
702
|
+
_define_property3(this, "_reachedTarget", void 0);
|
|
703
|
+
this._feeds = _feeds;
|
|
704
|
+
this._timeframeClock = _timeframeClock;
|
|
705
|
+
this._ctx = new Context2(void 0, {
|
|
706
|
+
F: __dxlog_file5,
|
|
707
|
+
L: 42
|
|
708
|
+
});
|
|
709
|
+
this.stalled = new Event3();
|
|
710
|
+
this._startTimeframe = new Timeframe2();
|
|
711
|
+
this._reachedTarget = false;
|
|
712
|
+
}
|
|
656
713
|
};
|
|
657
714
|
var Pipeline = class {
|
|
658
|
-
constructor() {
|
|
659
|
-
this._timeframeClock = new TimeframeClock(new Timeframe2());
|
|
660
|
-
this._feeds = new ComplexMap3(PublicKey3.hash);
|
|
661
|
-
// External state accessor.
|
|
662
|
-
this._state = new PipelineState(this._feeds, this._timeframeClock);
|
|
663
|
-
// Waits for the message consumer to process the message and yield control back to the pipeline.
|
|
664
|
-
this._processingTrigger = new Trigger().wake();
|
|
665
|
-
this._pauseTrigger = new Trigger().wake();
|
|
666
|
-
// Pending downloads.
|
|
667
|
-
this._downloads = new ComplexMap3((value) => PublicKey3.hash(value.key));
|
|
668
|
-
this._isStopping = false;
|
|
669
|
-
this._isStarted = false;
|
|
670
|
-
this._isBeingConsumed = false;
|
|
671
|
-
this._isPaused = false;
|
|
672
|
-
}
|
|
673
715
|
get state() {
|
|
674
716
|
return this._state;
|
|
675
717
|
}
|
|
676
718
|
get writer() {
|
|
677
719
|
invariant4(this._writer, "Writer not set.", {
|
|
678
720
|
F: __dxlog_file5,
|
|
679
|
-
L:
|
|
721
|
+
L: 246,
|
|
680
722
|
S: this,
|
|
681
723
|
A: [
|
|
682
724
|
"this._writer",
|
|
@@ -705,7 +747,7 @@ var Pipeline = class {
|
|
|
705
747
|
setWriteFeed(feed) {
|
|
706
748
|
invariant4(!this._writer, "Writer already set.", {
|
|
707
749
|
F: __dxlog_file5,
|
|
708
|
-
L:
|
|
750
|
+
L: 273,
|
|
709
751
|
S: this,
|
|
710
752
|
A: [
|
|
711
753
|
"!this._writer",
|
|
@@ -714,7 +756,7 @@ var Pipeline = class {
|
|
|
714
756
|
});
|
|
715
757
|
invariant4(feed.properties.writable, "Feed must be writable.", {
|
|
716
758
|
F: __dxlog_file5,
|
|
717
|
-
L:
|
|
759
|
+
L: 274,
|
|
718
760
|
S: this,
|
|
719
761
|
A: [
|
|
720
762
|
"feed.properties.writable",
|
|
@@ -729,7 +771,7 @@ var Pipeline = class {
|
|
|
729
771
|
async start() {
|
|
730
772
|
invariant4(!this._isStarted, "Pipeline is already started.", {
|
|
731
773
|
F: __dxlog_file5,
|
|
732
|
-
L:
|
|
774
|
+
L: 287,
|
|
733
775
|
S: this,
|
|
734
776
|
A: [
|
|
735
777
|
"!this._isStarted",
|
|
@@ -738,7 +780,7 @@ var Pipeline = class {
|
|
|
738
780
|
});
|
|
739
781
|
log4("starting...", void 0, {
|
|
740
782
|
F: __dxlog_file5,
|
|
741
|
-
L:
|
|
783
|
+
L: 288,
|
|
742
784
|
S: this,
|
|
743
785
|
C: (f, a) => f(...a)
|
|
744
786
|
});
|
|
@@ -747,7 +789,7 @@ var Pipeline = class {
|
|
|
747
789
|
this._isStarted = true;
|
|
748
790
|
log4("started", void 0, {
|
|
749
791
|
F: __dxlog_file5,
|
|
750
|
-
L:
|
|
792
|
+
L: 292,
|
|
751
793
|
S: this,
|
|
752
794
|
C: (f, a) => f(...a)
|
|
753
795
|
});
|
|
@@ -760,7 +802,7 @@ var Pipeline = class {
|
|
|
760
802
|
async stop() {
|
|
761
803
|
log4("stopping...", void 0, {
|
|
762
804
|
F: __dxlog_file5,
|
|
763
|
-
L:
|
|
805
|
+
L: 303,
|
|
764
806
|
S: this,
|
|
765
807
|
C: (f, a) => f(...a)
|
|
766
808
|
});
|
|
@@ -774,14 +816,14 @@ var Pipeline = class {
|
|
|
774
816
|
await this._state._ctx.dispose();
|
|
775
817
|
this._state._ctx = new Context2(void 0, {
|
|
776
818
|
F: __dxlog_file5,
|
|
777
|
-
L:
|
|
819
|
+
L: 312
|
|
778
820
|
});
|
|
779
821
|
this._state._reachedTargetPromise = void 0;
|
|
780
822
|
this._state._reachedTarget = false;
|
|
781
823
|
this._isStarted = false;
|
|
782
824
|
log4("stopped", void 0, {
|
|
783
825
|
F: __dxlog_file5,
|
|
784
|
-
L:
|
|
826
|
+
L: 316,
|
|
785
827
|
S: this,
|
|
786
828
|
C: (f, a) => f(...a)
|
|
787
829
|
});
|
|
@@ -793,7 +835,7 @@ var Pipeline = class {
|
|
|
793
835
|
async setCursor(timeframe) {
|
|
794
836
|
invariant4(!this._isStarted || this._isPaused, "Invalid state.", {
|
|
795
837
|
F: __dxlog_file5,
|
|
796
|
-
L:
|
|
838
|
+
L: 325,
|
|
797
839
|
S: this,
|
|
798
840
|
A: [
|
|
799
841
|
"!this._isStarted || this._isPaused",
|
|
@@ -822,7 +864,7 @@ var Pipeline = class {
|
|
|
822
864
|
async unpause() {
|
|
823
865
|
invariant4(this._isPaused, "Pipeline is not paused.", {
|
|
824
866
|
F: __dxlog_file5,
|
|
825
|
-
L:
|
|
867
|
+
L: 354,
|
|
826
868
|
S: this,
|
|
827
869
|
A: [
|
|
828
870
|
"this._isPaused",
|
|
@@ -842,7 +884,7 @@ var Pipeline = class {
|
|
|
842
884
|
async *consume() {
|
|
843
885
|
invariant4(!this._isBeingConsumed, "Pipeline is already being consumed.", {
|
|
844
886
|
F: __dxlog_file5,
|
|
845
|
-
L:
|
|
887
|
+
L: 369,
|
|
846
888
|
S: this,
|
|
847
889
|
A: [
|
|
848
890
|
"!this._isBeingConsumed",
|
|
@@ -852,7 +894,7 @@ var Pipeline = class {
|
|
|
852
894
|
this._isBeingConsumed = true;
|
|
853
895
|
invariant4(this._feedSetIterator, "Iterator not initialized.", {
|
|
854
896
|
F: __dxlog_file5,
|
|
855
|
-
L:
|
|
897
|
+
L: 372,
|
|
856
898
|
S: this,
|
|
857
899
|
A: [
|
|
858
900
|
"this._feedSetIterator",
|
|
@@ -866,7 +908,7 @@ var Pipeline = class {
|
|
|
866
908
|
if (lastFeedSetIterator !== this._feedSetIterator) {
|
|
867
909
|
invariant4(this._feedSetIterator, "Iterator not initialized.", {
|
|
868
910
|
F: __dxlog_file5,
|
|
869
|
-
L:
|
|
911
|
+
L: 381,
|
|
870
912
|
S: this,
|
|
871
913
|
A: [
|
|
872
914
|
"this._feedSetIterator",
|
|
@@ -901,7 +943,7 @@ var Pipeline = class {
|
|
|
901
943
|
length: feed.length
|
|
902
944
|
}, {
|
|
903
945
|
F: __dxlog_file5,
|
|
904
|
-
L:
|
|
946
|
+
L: 410,
|
|
905
947
|
S: this,
|
|
906
948
|
C: (f, a) => f(...a)
|
|
907
949
|
});
|
|
@@ -915,7 +957,7 @@ var Pipeline = class {
|
|
|
915
957
|
data
|
|
916
958
|
}, {
|
|
917
959
|
F: __dxlog_file5,
|
|
918
|
-
L:
|
|
960
|
+
L: 415,
|
|
919
961
|
S: this,
|
|
920
962
|
C: (f, a) => f(...a)
|
|
921
963
|
});
|
|
@@ -934,7 +976,7 @@ var Pipeline = class {
|
|
|
934
976
|
targetTimeframe: this._state.targetTimeframe
|
|
935
977
|
}, {
|
|
936
978
|
F: __dxlog_file5,
|
|
937
|
-
L:
|
|
979
|
+
L: 429,
|
|
938
980
|
S: this,
|
|
939
981
|
C: (f, a) => f(...a)
|
|
940
982
|
});
|
|
@@ -944,6 +986,20 @@ var Pipeline = class {
|
|
|
944
986
|
await this._feedSetIterator.addFeed(feed);
|
|
945
987
|
}
|
|
946
988
|
}
|
|
989
|
+
constructor() {
|
|
990
|
+
_define_property3(this, "_timeframeClock", new TimeframeClock(new Timeframe2()));
|
|
991
|
+
_define_property3(this, "_feeds", new ComplexMap3(PublicKey3.hash));
|
|
992
|
+
_define_property3(this, "_state", new PipelineState(this._feeds, this._timeframeClock));
|
|
993
|
+
_define_property3(this, "_processingTrigger", new Trigger().wake());
|
|
994
|
+
_define_property3(this, "_pauseTrigger", new Trigger().wake());
|
|
995
|
+
_define_property3(this, "_downloads", new ComplexMap3((value) => PublicKey3.hash(value.key)));
|
|
996
|
+
_define_property3(this, "_feedSetIterator", void 0);
|
|
997
|
+
_define_property3(this, "_writer", void 0);
|
|
998
|
+
_define_property3(this, "_isStopping", false);
|
|
999
|
+
_define_property3(this, "_isStarted", false);
|
|
1000
|
+
_define_property3(this, "_isBeingConsumed", false);
|
|
1001
|
+
_define_property3(this, "_isPaused", false);
|
|
1002
|
+
}
|
|
947
1003
|
};
|
|
948
1004
|
_ts_decorate3([
|
|
949
1005
|
synchronized2
|
|
@@ -969,31 +1025,21 @@ import { invariant as invariant5 } from "@dxos/invariant";
|
|
|
969
1025
|
import { log as log5 } from "@dxos/log";
|
|
970
1026
|
import { schema as schema3 } from "@dxos/protocols/proto";
|
|
971
1027
|
import { RpcExtension } from "@dxos/teleport";
|
|
1028
|
+
function _define_property4(obj, key, value) {
|
|
1029
|
+
if (key in obj) {
|
|
1030
|
+
Object.defineProperty(obj, key, {
|
|
1031
|
+
value,
|
|
1032
|
+
enumerable: true,
|
|
1033
|
+
configurable: true,
|
|
1034
|
+
writable: true
|
|
1035
|
+
});
|
|
1036
|
+
} else {
|
|
1037
|
+
obj[key] = value;
|
|
1038
|
+
}
|
|
1039
|
+
return obj;
|
|
1040
|
+
}
|
|
972
1041
|
var __dxlog_file6 = "/__w/dxos/dxos/packages/core/echo/echo-pipeline/src/space/auth.ts";
|
|
973
1042
|
var AuthExtension = class extends RpcExtension {
|
|
974
|
-
constructor(_authParams) {
|
|
975
|
-
super({
|
|
976
|
-
requested: {
|
|
977
|
-
AuthService: schema3.getService("dxos.mesh.teleport.auth.AuthService")
|
|
978
|
-
},
|
|
979
|
-
exposed: {
|
|
980
|
-
AuthService: schema3.getService("dxos.mesh.teleport.auth.AuthService")
|
|
981
|
-
},
|
|
982
|
-
timeout: 60 * 1e3
|
|
983
|
-
}), this._authParams = _authParams, this._ctx = new Context3({
|
|
984
|
-
onError: (err) => {
|
|
985
|
-
log5.catch(err, void 0, {
|
|
986
|
-
F: __dxlog_file6,
|
|
987
|
-
L: 28,
|
|
988
|
-
S: this,
|
|
989
|
-
C: (f, a) => f(...a)
|
|
990
|
-
});
|
|
991
|
-
}
|
|
992
|
-
}, {
|
|
993
|
-
F: __dxlog_file6,
|
|
994
|
-
L: 26
|
|
995
|
-
});
|
|
996
|
-
}
|
|
997
1043
|
async getHandlers() {
|
|
998
1044
|
return {
|
|
999
1045
|
AuthService: {
|
|
@@ -1067,10 +1113,33 @@ var AuthExtension = class extends RpcExtension {
|
|
|
1067
1113
|
await this._ctx.dispose();
|
|
1068
1114
|
await super.onAbort();
|
|
1069
1115
|
}
|
|
1116
|
+
constructor(_authParams) {
|
|
1117
|
+
super({
|
|
1118
|
+
requested: {
|
|
1119
|
+
AuthService: schema3.getService("dxos.mesh.teleport.auth.AuthService")
|
|
1120
|
+
},
|
|
1121
|
+
exposed: {
|
|
1122
|
+
AuthService: schema3.getService("dxos.mesh.teleport.auth.AuthService")
|
|
1123
|
+
},
|
|
1124
|
+
timeout: 60 * 1e3
|
|
1125
|
+
}), _define_property4(this, "_authParams", void 0), _define_property4(this, "_ctx", void 0), this._authParams = _authParams, this._ctx = new Context3({
|
|
1126
|
+
onError: (err) => {
|
|
1127
|
+
log5.catch(err, void 0, {
|
|
1128
|
+
F: __dxlog_file6,
|
|
1129
|
+
L: 28,
|
|
1130
|
+
S: this,
|
|
1131
|
+
C: (f, a) => f(...a)
|
|
1132
|
+
});
|
|
1133
|
+
}
|
|
1134
|
+
}, {
|
|
1135
|
+
F: __dxlog_file6,
|
|
1136
|
+
L: 26
|
|
1137
|
+
});
|
|
1138
|
+
}
|
|
1070
1139
|
};
|
|
1071
1140
|
|
|
1072
1141
|
// src/space/space.ts
|
|
1073
|
-
import { Event as Event4, scheduleMicroTask, synchronized as synchronized3, trackLeaks as trackLeaks2 } from "@dxos/async";
|
|
1142
|
+
import { Event as Event4, scheduleMicroTask as scheduleMicroTask2, synchronized as synchronized3, trackLeaks as trackLeaks2 } from "@dxos/async";
|
|
1074
1143
|
import { Resource } from "@dxos/context";
|
|
1075
1144
|
import { invariant as invariant6 } from "@dxos/invariant";
|
|
1076
1145
|
import { log as log7, logInfo } from "@dxos/log";
|
|
@@ -1079,7 +1148,7 @@ import { trace as trace2 } from "@dxos/tracing";
|
|
|
1079
1148
|
import { Callback as Callback2 } from "@dxos/util";
|
|
1080
1149
|
|
|
1081
1150
|
// src/space/control-pipeline.ts
|
|
1082
|
-
import { DeferredTask, sleepWithContext as sleepWithContext2, trackLeaks } from "@dxos/async";
|
|
1151
|
+
import { DeferredTask, scheduleMicroTask, sleepWithContext as sleepWithContext2, trackLeaks } from "@dxos/async";
|
|
1083
1152
|
import { Context as Context4 } from "@dxos/context";
|
|
1084
1153
|
import { SpaceStateMachine } from "@dxos/credentials";
|
|
1085
1154
|
import { PublicKey as PublicKey4 } from "@dxos/keys";
|
|
@@ -1088,6 +1157,19 @@ import { AdmittedFeed } from "@dxos/protocols/proto/dxos/halo/credentials";
|
|
|
1088
1157
|
import { Timeframe as Timeframe3 } from "@dxos/timeframe";
|
|
1089
1158
|
import { TimeSeriesCounter, TimeUsageCounter, trace } from "@dxos/tracing";
|
|
1090
1159
|
import { Callback, tracer } from "@dxos/util";
|
|
1160
|
+
function _define_property5(obj, key, value) {
|
|
1161
|
+
if (key in obj) {
|
|
1162
|
+
Object.defineProperty(obj, key, {
|
|
1163
|
+
value,
|
|
1164
|
+
enumerable: true,
|
|
1165
|
+
configurable: true,
|
|
1166
|
+
writable: true
|
|
1167
|
+
});
|
|
1168
|
+
} else {
|
|
1169
|
+
obj[key] = value;
|
|
1170
|
+
}
|
|
1171
|
+
return obj;
|
|
1172
|
+
}
|
|
1091
1173
|
function _ts_decorate4(decorators, target, key, desc) {
|
|
1092
1174
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
1093
1175
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -1099,57 +1181,6 @@ var TIMEFRAME_SAVE_DEBOUNCE_INTERVAL = 500;
|
|
|
1099
1181
|
var CONTROL_PIPELINE_SNAPSHOT_DELAY = 1e4;
|
|
1100
1182
|
var USE_SNAPSHOTS = true;
|
|
1101
1183
|
var ControlPipeline = class {
|
|
1102
|
-
constructor({ spaceKey, genesisFeed, feedProvider, metadataStore }) {
|
|
1103
|
-
this._ctx = new Context4(void 0, {
|
|
1104
|
-
F: __dxlog_file7,
|
|
1105
|
-
L: 47
|
|
1106
|
-
});
|
|
1107
|
-
this._lastTimeframeSaveTime = Date.now();
|
|
1108
|
-
this.onFeedAdmitted = new Callback();
|
|
1109
|
-
this._usage = new TimeUsageCounter();
|
|
1110
|
-
this._mutations = new TimeSeriesCounter();
|
|
1111
|
-
this._snapshotTask = new DeferredTask(this._ctx, async () => {
|
|
1112
|
-
await sleepWithContext2(this._ctx, CONTROL_PIPELINE_SNAPSHOT_DELAY);
|
|
1113
|
-
await this._saveSnapshot();
|
|
1114
|
-
});
|
|
1115
|
-
this._spaceKey = spaceKey;
|
|
1116
|
-
this._metadata = metadataStore;
|
|
1117
|
-
this._pipeline = new Pipeline();
|
|
1118
|
-
void this._pipeline.addFeed(genesisFeed);
|
|
1119
|
-
this._spaceStateMachine = new SpaceStateMachine(spaceKey);
|
|
1120
|
-
this._spaceStateMachine.onFeedAdmitted.set(async (info) => {
|
|
1121
|
-
log6("feed admitted", {
|
|
1122
|
-
key: info.key
|
|
1123
|
-
}, {
|
|
1124
|
-
F: __dxlog_file7,
|
|
1125
|
-
L: 82,
|
|
1126
|
-
S: this,
|
|
1127
|
-
C: (f, a) => f(...a)
|
|
1128
|
-
});
|
|
1129
|
-
if (info.assertion.designation === AdmittedFeed.Designation.CONTROL && !info.key.equals(genesisFeed.key)) {
|
|
1130
|
-
queueMicrotask(async () => {
|
|
1131
|
-
try {
|
|
1132
|
-
const feed = await feedProvider(info.key);
|
|
1133
|
-
if (!this._pipeline.hasFeed(feed.key)) {
|
|
1134
|
-
await this._pipeline.addFeed(feed);
|
|
1135
|
-
}
|
|
1136
|
-
} catch (err) {
|
|
1137
|
-
log6.catch(err, void 0, {
|
|
1138
|
-
F: __dxlog_file7,
|
|
1139
|
-
L: 93,
|
|
1140
|
-
S: this,
|
|
1141
|
-
C: (f, a) => f(...a)
|
|
1142
|
-
});
|
|
1143
|
-
}
|
|
1144
|
-
});
|
|
1145
|
-
}
|
|
1146
|
-
await this.onFeedAdmitted.callIfSet(info);
|
|
1147
|
-
});
|
|
1148
|
-
this.onMemberRoleChanged = this._spaceStateMachine.onMemberRoleChanged;
|
|
1149
|
-
this.onCredentialProcessed = this._spaceStateMachine.onCredentialProcessed;
|
|
1150
|
-
this.onDelegatedInvitation = this._spaceStateMachine.onDelegatedInvitation;
|
|
1151
|
-
this.onDelegatedInvitationRemoved = this._spaceStateMachine.onDelegatedInvitationRemoved;
|
|
1152
|
-
}
|
|
1153
1184
|
get spaceState() {
|
|
1154
1185
|
return this._spaceStateMachine;
|
|
1155
1186
|
}
|
|
@@ -1168,7 +1199,7 @@ var ControlPipeline = class {
|
|
|
1168
1199
|
tf: snapshot?.timeframe
|
|
1169
1200
|
}, {
|
|
1170
1201
|
F: __dxlog_file7,
|
|
1171
|
-
L:
|
|
1202
|
+
L: 126,
|
|
1172
1203
|
S: this,
|
|
1173
1204
|
C: (f, a) => f(...a)
|
|
1174
1205
|
});
|
|
@@ -1177,20 +1208,20 @@ var ControlPipeline = class {
|
|
|
1177
1208
|
}
|
|
1178
1209
|
log6("starting...", void 0, {
|
|
1179
1210
|
F: __dxlog_file7,
|
|
1180
|
-
L:
|
|
1211
|
+
L: 131,
|
|
1181
1212
|
S: this,
|
|
1182
1213
|
C: (f, a) => f(...a)
|
|
1183
1214
|
});
|
|
1184
1215
|
setTimeout(async () => {
|
|
1185
1216
|
void this._consumePipeline(new Context4(void 0, {
|
|
1186
1217
|
F: __dxlog_file7,
|
|
1187
|
-
L:
|
|
1218
|
+
L: 133
|
|
1188
1219
|
}));
|
|
1189
1220
|
});
|
|
1190
1221
|
await this._pipeline.start();
|
|
1191
1222
|
log6("started", void 0, {
|
|
1192
1223
|
F: __dxlog_file7,
|
|
1193
|
-
L:
|
|
1224
|
+
L: 137,
|
|
1194
1225
|
S: this,
|
|
1195
1226
|
C: (f, a) => f(...a)
|
|
1196
1227
|
});
|
|
@@ -1207,7 +1238,7 @@ var ControlPipeline = class {
|
|
|
1207
1238
|
message
|
|
1208
1239
|
}, {
|
|
1209
1240
|
F: __dxlog_file7,
|
|
1210
|
-
L:
|
|
1241
|
+
L: 150,
|
|
1211
1242
|
S: this,
|
|
1212
1243
|
C: (f, a) => f(...a)
|
|
1213
1244
|
});
|
|
@@ -1229,7 +1260,7 @@ var ControlPipeline = class {
|
|
|
1229
1260
|
snapshot: getSnapshotLoggerContext(snapshot)
|
|
1230
1261
|
}, {
|
|
1231
1262
|
F: __dxlog_file7,
|
|
1232
|
-
L:
|
|
1263
|
+
L: 166,
|
|
1233
1264
|
S: this,
|
|
1234
1265
|
C: (f, a) => f(...a)
|
|
1235
1266
|
});
|
|
@@ -1244,7 +1275,7 @@ var ControlPipeline = class {
|
|
|
1244
1275
|
} catch (err) {
|
|
1245
1276
|
log6.catch(err, void 0, {
|
|
1246
1277
|
F: __dxlog_file7,
|
|
1247
|
-
L:
|
|
1278
|
+
L: 179,
|
|
1248
1279
|
S: this,
|
|
1249
1280
|
C: (f, a) => f(...a)
|
|
1250
1281
|
});
|
|
@@ -1258,7 +1289,7 @@ var ControlPipeline = class {
|
|
|
1258
1289
|
seq: msg.seq
|
|
1259
1290
|
}, {
|
|
1260
1291
|
F: __dxlog_file7,
|
|
1261
|
-
L:
|
|
1292
|
+
L: 188,
|
|
1262
1293
|
S: this,
|
|
1263
1294
|
C: (f, a) => f(...a)
|
|
1264
1295
|
});
|
|
@@ -1273,7 +1304,7 @@ var ControlPipeline = class {
|
|
|
1273
1304
|
msg
|
|
1274
1305
|
}, {
|
|
1275
1306
|
F: __dxlog_file7,
|
|
1276
|
-
L:
|
|
1307
|
+
L: 197,
|
|
1277
1308
|
S: this,
|
|
1278
1309
|
C: (f, a) => f(...a)
|
|
1279
1310
|
});
|
|
@@ -1292,7 +1323,7 @@ var ControlPipeline = class {
|
|
|
1292
1323
|
async stop() {
|
|
1293
1324
|
log6("stopping...", void 0, {
|
|
1294
1325
|
F: __dxlog_file7,
|
|
1295
|
-
L:
|
|
1326
|
+
L: 217,
|
|
1296
1327
|
S: this,
|
|
1297
1328
|
C: (f, a) => f(...a)
|
|
1298
1329
|
});
|
|
@@ -1301,7 +1332,7 @@ var ControlPipeline = class {
|
|
|
1301
1332
|
await this._saveTargetTimeframe(this._pipeline.state.timeframe);
|
|
1302
1333
|
log6("stopped", void 0, {
|
|
1303
1334
|
F: __dxlog_file7,
|
|
1304
|
-
L:
|
|
1335
|
+
L: 221,
|
|
1305
1336
|
S: this,
|
|
1306
1337
|
C: (f, a) => f(...a)
|
|
1307
1338
|
});
|
|
@@ -1314,12 +1345,75 @@ var ControlPipeline = class {
|
|
|
1314
1345
|
} catch (err) {
|
|
1315
1346
|
log6(err, void 0, {
|
|
1316
1347
|
F: __dxlog_file7,
|
|
1317
|
-
L:
|
|
1348
|
+
L: 230,
|
|
1318
1349
|
S: this,
|
|
1319
1350
|
C: (f, a) => f(...a)
|
|
1320
1351
|
});
|
|
1321
1352
|
}
|
|
1322
1353
|
}
|
|
1354
|
+
constructor({ spaceKey, genesisFeed, feedProvider, metadataStore }) {
|
|
1355
|
+
_define_property5(this, "_ctx", new Context4(void 0, {
|
|
1356
|
+
F: __dxlog_file7,
|
|
1357
|
+
L: 47
|
|
1358
|
+
}));
|
|
1359
|
+
_define_property5(this, "_pipeline", void 0);
|
|
1360
|
+
_define_property5(this, "_spaceStateMachine", void 0);
|
|
1361
|
+
_define_property5(this, "_spaceKey", void 0);
|
|
1362
|
+
_define_property5(this, "_metadata", void 0);
|
|
1363
|
+
_define_property5(this, "_targetTimeframe", void 0);
|
|
1364
|
+
_define_property5(this, "_lastTimeframeSaveTime", Date.now());
|
|
1365
|
+
_define_property5(this, "onFeedAdmitted", new Callback());
|
|
1366
|
+
_define_property5(this, "onMemberRoleChanged", void 0);
|
|
1367
|
+
_define_property5(this, "onCredentialProcessed", void 0);
|
|
1368
|
+
_define_property5(this, "onDelegatedInvitation", void 0);
|
|
1369
|
+
_define_property5(this, "onDelegatedInvitationRemoved", void 0);
|
|
1370
|
+
_define_property5(this, "_usage", new TimeUsageCounter());
|
|
1371
|
+
_define_property5(this, "_mutations", new TimeSeriesCounter());
|
|
1372
|
+
_define_property5(this, "_snapshotTask", new DeferredTask(this._ctx, async () => {
|
|
1373
|
+
await sleepWithContext2(this._ctx, CONTROL_PIPELINE_SNAPSHOT_DELAY);
|
|
1374
|
+
await this._saveSnapshot();
|
|
1375
|
+
}));
|
|
1376
|
+
this._spaceKey = spaceKey;
|
|
1377
|
+
this._metadata = metadataStore;
|
|
1378
|
+
this._pipeline = new Pipeline();
|
|
1379
|
+
void this._pipeline.addFeed(genesisFeed);
|
|
1380
|
+
this._spaceStateMachine = new SpaceStateMachine(spaceKey);
|
|
1381
|
+
this._spaceStateMachine.onFeedAdmitted.set(async (info) => {
|
|
1382
|
+
log6("feed admitted", {
|
|
1383
|
+
key: info.key
|
|
1384
|
+
}, {
|
|
1385
|
+
F: __dxlog_file7,
|
|
1386
|
+
L: 82,
|
|
1387
|
+
S: this,
|
|
1388
|
+
C: (f, a) => f(...a)
|
|
1389
|
+
});
|
|
1390
|
+
if (info.assertion.designation === AdmittedFeed.Designation.CONTROL && !info.key.equals(genesisFeed.key)) {
|
|
1391
|
+
scheduleMicroTask(this._ctx, async () => {
|
|
1392
|
+
try {
|
|
1393
|
+
const feed = await feedProvider(info.key);
|
|
1394
|
+
if (this._ctx.disposed) {
|
|
1395
|
+
return;
|
|
1396
|
+
}
|
|
1397
|
+
if (!this._pipeline.hasFeed(feed.key)) {
|
|
1398
|
+
await this._pipeline.addFeed(feed);
|
|
1399
|
+
}
|
|
1400
|
+
} catch (err) {
|
|
1401
|
+
log6.catch(err, void 0, {
|
|
1402
|
+
F: __dxlog_file7,
|
|
1403
|
+
L: 96,
|
|
1404
|
+
S: this,
|
|
1405
|
+
C: (f, a) => f(...a)
|
|
1406
|
+
});
|
|
1407
|
+
}
|
|
1408
|
+
});
|
|
1409
|
+
}
|
|
1410
|
+
await this.onFeedAdmitted.callIfSet(info);
|
|
1411
|
+
});
|
|
1412
|
+
this.onMemberRoleChanged = this._spaceStateMachine.onMemberRoleChanged;
|
|
1413
|
+
this.onCredentialProcessed = this._spaceStateMachine.onCredentialProcessed;
|
|
1414
|
+
this.onDelegatedInvitation = this._spaceStateMachine.onDelegatedInvitation;
|
|
1415
|
+
this.onDelegatedInvitationRemoved = this._spaceStateMachine.onDelegatedInvitationRemoved;
|
|
1416
|
+
}
|
|
1323
1417
|
};
|
|
1324
1418
|
_ts_decorate4([
|
|
1325
1419
|
trace.metricsCounter()
|
|
@@ -1356,6 +1450,19 @@ var getSnapshotLoggerContext = (snapshot) => {
|
|
|
1356
1450
|
};
|
|
1357
1451
|
|
|
1358
1452
|
// src/space/space.ts
|
|
1453
|
+
function _define_property6(obj, key, value) {
|
|
1454
|
+
if (key in obj) {
|
|
1455
|
+
Object.defineProperty(obj, key, {
|
|
1456
|
+
value,
|
|
1457
|
+
enumerable: true,
|
|
1458
|
+
configurable: true,
|
|
1459
|
+
writable: true
|
|
1460
|
+
});
|
|
1461
|
+
} else {
|
|
1462
|
+
obj[key] = value;
|
|
1463
|
+
}
|
|
1464
|
+
return obj;
|
|
1465
|
+
}
|
|
1359
1466
|
function _ts_decorate5(decorators, target, key, desc) {
|
|
1360
1467
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
1361
1468
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -1364,89 +1471,6 @@ function _ts_decorate5(decorators, target, key, desc) {
|
|
|
1364
1471
|
}
|
|
1365
1472
|
var __dxlog_file8 = "/__w/dxos/dxos/packages/core/echo/echo-pipeline/src/space/space.ts";
|
|
1366
1473
|
var Space = class extends Resource {
|
|
1367
|
-
constructor(params) {
|
|
1368
|
-
super();
|
|
1369
|
-
this.onCredentialProcessed = new Callback2();
|
|
1370
|
-
this.stateUpdate = new Event4();
|
|
1371
|
-
invariant6(params.spaceKey && params.feedProvider, void 0, {
|
|
1372
|
-
F: __dxlog_file8,
|
|
1373
|
-
L: 72,
|
|
1374
|
-
S: this,
|
|
1375
|
-
A: [
|
|
1376
|
-
"params.spaceKey && params.feedProvider",
|
|
1377
|
-
""
|
|
1378
|
-
]
|
|
1379
|
-
});
|
|
1380
|
-
this._id = params.id;
|
|
1381
|
-
this._key = params.spaceKey;
|
|
1382
|
-
this._genesisFeedKey = params.genesisFeed.key;
|
|
1383
|
-
this._feedProvider = params.feedProvider;
|
|
1384
|
-
this._controlPipeline = new ControlPipeline({
|
|
1385
|
-
spaceKey: params.spaceKey,
|
|
1386
|
-
genesisFeed: params.genesisFeed,
|
|
1387
|
-
feedProvider: params.feedProvider,
|
|
1388
|
-
metadataStore: params.metadataStore
|
|
1389
|
-
});
|
|
1390
|
-
this._controlPipeline.onFeedAdmitted.set(async (info) => {
|
|
1391
|
-
const sparse = info.assertion.designation === AdmittedFeed2.Designation.DATA;
|
|
1392
|
-
if (!info.key.equals(params.genesisFeed.key)) {
|
|
1393
|
-
scheduleMicroTask(this._ctx, async () => {
|
|
1394
|
-
await this.protocol.addFeed(await params.feedProvider(info.key, {
|
|
1395
|
-
sparse
|
|
1396
|
-
}));
|
|
1397
|
-
});
|
|
1398
|
-
}
|
|
1399
|
-
});
|
|
1400
|
-
this._controlPipeline.onCredentialProcessed.set(async (credential) => {
|
|
1401
|
-
await this.onCredentialProcessed.callIfSet(credential);
|
|
1402
|
-
log7("onCredentialProcessed", {
|
|
1403
|
-
credential
|
|
1404
|
-
}, {
|
|
1405
|
-
F: __dxlog_file8,
|
|
1406
|
-
L: 99,
|
|
1407
|
-
S: this,
|
|
1408
|
-
C: (f, a) => f(...a)
|
|
1409
|
-
});
|
|
1410
|
-
this.stateUpdate.emit();
|
|
1411
|
-
});
|
|
1412
|
-
this._controlPipeline.onDelegatedInvitation.set(async (invitation) => {
|
|
1413
|
-
log7("onDelegatedInvitation", {
|
|
1414
|
-
invitation
|
|
1415
|
-
}, {
|
|
1416
|
-
F: __dxlog_file8,
|
|
1417
|
-
L: 103,
|
|
1418
|
-
S: this,
|
|
1419
|
-
C: (f, a) => f(...a)
|
|
1420
|
-
});
|
|
1421
|
-
await params.onDelegatedInvitationStatusChange(invitation, true);
|
|
1422
|
-
});
|
|
1423
|
-
this._controlPipeline.onDelegatedInvitationRemoved.set(async (invitation) => {
|
|
1424
|
-
log7("onDelegatedInvitationRemoved", {
|
|
1425
|
-
invitation
|
|
1426
|
-
}, {
|
|
1427
|
-
F: __dxlog_file8,
|
|
1428
|
-
L: 107,
|
|
1429
|
-
S: this,
|
|
1430
|
-
C: (f, a) => f(...a)
|
|
1431
|
-
});
|
|
1432
|
-
await params.onDelegatedInvitationStatusChange(invitation, false);
|
|
1433
|
-
});
|
|
1434
|
-
this._controlPipeline.onMemberRoleChanged.set(async (changedMembers) => {
|
|
1435
|
-
log7("onMemberRoleChanged", () => ({
|
|
1436
|
-
changedMembers: changedMembers.map((m) => [
|
|
1437
|
-
m.key,
|
|
1438
|
-
m.role
|
|
1439
|
-
])
|
|
1440
|
-
}), {
|
|
1441
|
-
F: __dxlog_file8,
|
|
1442
|
-
L: 111,
|
|
1443
|
-
S: this,
|
|
1444
|
-
C: (f, a) => f(...a)
|
|
1445
|
-
});
|
|
1446
|
-
await params.onMemberRolesChanged(changedMembers);
|
|
1447
|
-
});
|
|
1448
|
-
this.protocol = params.protocol;
|
|
1449
|
-
}
|
|
1450
1474
|
get id() {
|
|
1451
1475
|
return this._id;
|
|
1452
1476
|
}
|
|
@@ -1474,7 +1498,7 @@ var Space = class extends Resource {
|
|
|
1474
1498
|
async setControlFeed(feed) {
|
|
1475
1499
|
invariant6(!this._controlFeed, "Control feed already set.", {
|
|
1476
1500
|
F: __dxlog_file8,
|
|
1477
|
-
L:
|
|
1501
|
+
L: 156,
|
|
1478
1502
|
S: this,
|
|
1479
1503
|
A: [
|
|
1480
1504
|
"!this._controlFeed",
|
|
@@ -1488,7 +1512,7 @@ var Space = class extends Resource {
|
|
|
1488
1512
|
async setDataFeed(feed) {
|
|
1489
1513
|
invariant6(!this._dataFeed, "Data feed already set.", {
|
|
1490
1514
|
F: __dxlog_file8,
|
|
1491
|
-
L:
|
|
1515
|
+
L: 163,
|
|
1492
1516
|
S: this,
|
|
1493
1517
|
A: [
|
|
1494
1518
|
"!this._dataFeed",
|
|
@@ -1507,14 +1531,14 @@ var Space = class extends Resource {
|
|
|
1507
1531
|
async _open(ctx) {
|
|
1508
1532
|
log7("opening...", void 0, {
|
|
1509
1533
|
F: __dxlog_file8,
|
|
1510
|
-
L:
|
|
1534
|
+
L: 177,
|
|
1511
1535
|
S: this,
|
|
1512
1536
|
C: (f, a) => f(...a)
|
|
1513
1537
|
});
|
|
1514
1538
|
await this._controlPipeline.start();
|
|
1515
1539
|
log7("opened", void 0, {
|
|
1516
1540
|
F: __dxlog_file8,
|
|
1517
|
-
L:
|
|
1541
|
+
L: 182,
|
|
1518
1542
|
S: this,
|
|
1519
1543
|
C: (f, a) => f(...a)
|
|
1520
1544
|
});
|
|
@@ -1522,7 +1546,7 @@ var Space = class extends Resource {
|
|
|
1522
1546
|
async startProtocol() {
|
|
1523
1547
|
invariant6(this.isOpen, void 0, {
|
|
1524
1548
|
F: __dxlog_file8,
|
|
1525
|
-
L:
|
|
1549
|
+
L: 187,
|
|
1526
1550
|
S: this,
|
|
1527
1551
|
A: [
|
|
1528
1552
|
"this.isOpen",
|
|
@@ -1537,7 +1561,7 @@ var Space = class extends Resource {
|
|
|
1537
1561
|
key: this._key
|
|
1538
1562
|
}, {
|
|
1539
1563
|
F: __dxlog_file8,
|
|
1540
|
-
L:
|
|
1564
|
+
L: 194,
|
|
1541
1565
|
S: this,
|
|
1542
1566
|
C: (f, a) => f(...a)
|
|
1543
1567
|
});
|
|
@@ -1545,11 +1569,92 @@ var Space = class extends Resource {
|
|
|
1545
1569
|
await this._controlPipeline.stop();
|
|
1546
1570
|
log7("closed", void 0, {
|
|
1547
1571
|
F: __dxlog_file8,
|
|
1548
|
-
L:
|
|
1572
|
+
L: 200,
|
|
1549
1573
|
S: this,
|
|
1550
1574
|
C: (f, a) => f(...a)
|
|
1551
1575
|
});
|
|
1552
1576
|
}
|
|
1577
|
+
constructor(params) {
|
|
1578
|
+
super(), _define_property6(this, "onCredentialProcessed", new Callback2()), _define_property6(this, "stateUpdate", new Event4()), _define_property6(this, "protocol", void 0), _define_property6(this, "_id", void 0), _define_property6(this, "_key", void 0), _define_property6(this, "_genesisFeedKey", void 0), _define_property6(this, "_feedProvider", void 0), _define_property6(this, "_controlPipeline", void 0), _define_property6(this, "_controlFeed", void 0), _define_property6(this, "_dataFeed", void 0);
|
|
1579
|
+
invariant6(params.spaceKey && params.feedProvider, void 0, {
|
|
1580
|
+
F: __dxlog_file8,
|
|
1581
|
+
L: 73,
|
|
1582
|
+
S: this,
|
|
1583
|
+
A: [
|
|
1584
|
+
"params.spaceKey && params.feedProvider",
|
|
1585
|
+
""
|
|
1586
|
+
]
|
|
1587
|
+
});
|
|
1588
|
+
this._id = params.id;
|
|
1589
|
+
this._key = params.spaceKey;
|
|
1590
|
+
this._genesisFeedKey = params.genesisFeed.key;
|
|
1591
|
+
this._feedProvider = params.feedProvider;
|
|
1592
|
+
this._controlPipeline = new ControlPipeline({
|
|
1593
|
+
spaceKey: params.spaceKey,
|
|
1594
|
+
genesisFeed: params.genesisFeed,
|
|
1595
|
+
feedProvider: params.feedProvider,
|
|
1596
|
+
metadataStore: params.metadataStore
|
|
1597
|
+
});
|
|
1598
|
+
this._controlPipeline.onFeedAdmitted.set(async (info) => {
|
|
1599
|
+
const sparse = info.assertion.designation === AdmittedFeed2.Designation.DATA;
|
|
1600
|
+
if (!info.key.equals(params.genesisFeed.key)) {
|
|
1601
|
+
scheduleMicroTask2(this._ctx, async () => {
|
|
1602
|
+
await this.protocol.addFeed(await params.feedProvider(info.key, {
|
|
1603
|
+
sparse
|
|
1604
|
+
}));
|
|
1605
|
+
});
|
|
1606
|
+
}
|
|
1607
|
+
});
|
|
1608
|
+
this._controlPipeline.onCredentialProcessed.set(async (credential) => {
|
|
1609
|
+
await this.onCredentialProcessed.callIfSet(credential);
|
|
1610
|
+
log7("onCredentialProcessed", {
|
|
1611
|
+
credential
|
|
1612
|
+
}, {
|
|
1613
|
+
F: __dxlog_file8,
|
|
1614
|
+
L: 100,
|
|
1615
|
+
S: this,
|
|
1616
|
+
C: (f, a) => f(...a)
|
|
1617
|
+
});
|
|
1618
|
+
this.stateUpdate.emit();
|
|
1619
|
+
});
|
|
1620
|
+
this._controlPipeline.onDelegatedInvitation.set(async (invitation) => {
|
|
1621
|
+
log7("onDelegatedInvitation", {
|
|
1622
|
+
invitation
|
|
1623
|
+
}, {
|
|
1624
|
+
F: __dxlog_file8,
|
|
1625
|
+
L: 104,
|
|
1626
|
+
S: this,
|
|
1627
|
+
C: (f, a) => f(...a)
|
|
1628
|
+
});
|
|
1629
|
+
await params.onDelegatedInvitationStatusChange(invitation, true);
|
|
1630
|
+
});
|
|
1631
|
+
this._controlPipeline.onDelegatedInvitationRemoved.set(async (invitation) => {
|
|
1632
|
+
log7("onDelegatedInvitationRemoved", {
|
|
1633
|
+
invitation
|
|
1634
|
+
}, {
|
|
1635
|
+
F: __dxlog_file8,
|
|
1636
|
+
L: 108,
|
|
1637
|
+
S: this,
|
|
1638
|
+
C: (f, a) => f(...a)
|
|
1639
|
+
});
|
|
1640
|
+
await params.onDelegatedInvitationStatusChange(invitation, false);
|
|
1641
|
+
});
|
|
1642
|
+
this._controlPipeline.onMemberRoleChanged.set(async (changedMembers) => {
|
|
1643
|
+
log7("onMemberRoleChanged", () => ({
|
|
1644
|
+
changedMembers: changedMembers.map((m) => [
|
|
1645
|
+
m.key,
|
|
1646
|
+
m.role
|
|
1647
|
+
])
|
|
1648
|
+
}), {
|
|
1649
|
+
F: __dxlog_file8,
|
|
1650
|
+
L: 112,
|
|
1651
|
+
S: this,
|
|
1652
|
+
C: (f, a) => f(...a)
|
|
1653
|
+
});
|
|
1654
|
+
await params.onMemberRolesChanged(changedMembers);
|
|
1655
|
+
});
|
|
1656
|
+
this.protocol = params.protocol;
|
|
1657
|
+
}
|
|
1553
1658
|
};
|
|
1554
1659
|
_ts_decorate5([
|
|
1555
1660
|
trace2.info()
|
|
@@ -1585,18 +1690,21 @@ import { Context as Context5 } from "@dxos/context";
|
|
|
1585
1690
|
import { ProtocolError } from "@dxos/protocols";
|
|
1586
1691
|
import { schema as schema4 } from "@dxos/protocols/proto";
|
|
1587
1692
|
import { RpcExtension as RpcExtension2 } from "@dxos/teleport";
|
|
1693
|
+
function _define_property7(obj, key, value) {
|
|
1694
|
+
if (key in obj) {
|
|
1695
|
+
Object.defineProperty(obj, key, {
|
|
1696
|
+
value,
|
|
1697
|
+
enumerable: true,
|
|
1698
|
+
configurable: true,
|
|
1699
|
+
writable: true
|
|
1700
|
+
});
|
|
1701
|
+
} else {
|
|
1702
|
+
obj[key] = value;
|
|
1703
|
+
}
|
|
1704
|
+
return obj;
|
|
1705
|
+
}
|
|
1588
1706
|
var __dxlog_file9 = "/__w/dxos/dxos/packages/core/echo/echo-pipeline/src/space/admission-discovery-extension.ts";
|
|
1589
1707
|
var CredentialRetrieverExtension = class extends RpcExtension2 {
|
|
1590
|
-
constructor(_request, _onResult) {
|
|
1591
|
-
super({
|
|
1592
|
-
requested: {
|
|
1593
|
-
AdmissionDiscoveryService: schema4.getService("dxos.mesh.teleport.AdmissionDiscoveryService")
|
|
1594
|
-
}
|
|
1595
|
-
}), this._request = _request, this._onResult = _onResult, this._ctx = new Context5(void 0, {
|
|
1596
|
-
F: __dxlog_file9,
|
|
1597
|
-
L: 26
|
|
1598
|
-
});
|
|
1599
|
-
}
|
|
1600
1708
|
async getHandlers() {
|
|
1601
1709
|
return {};
|
|
1602
1710
|
}
|
|
@@ -1617,15 +1725,18 @@ var CredentialRetrieverExtension = class extends RpcExtension2 {
|
|
|
1617
1725
|
async onAbort() {
|
|
1618
1726
|
await this._ctx.dispose();
|
|
1619
1727
|
}
|
|
1620
|
-
|
|
1621
|
-
var CredentialServerExtension = class extends RpcExtension2 {
|
|
1622
|
-
constructor(_space) {
|
|
1728
|
+
constructor(_request, _onResult) {
|
|
1623
1729
|
super({
|
|
1624
|
-
|
|
1730
|
+
requested: {
|
|
1625
1731
|
AdmissionDiscoveryService: schema4.getService("dxos.mesh.teleport.AdmissionDiscoveryService")
|
|
1626
1732
|
}
|
|
1627
|
-
}), this.
|
|
1733
|
+
}), _define_property7(this, "_request", void 0), _define_property7(this, "_onResult", void 0), _define_property7(this, "_ctx", void 0), this._request = _request, this._onResult = _onResult, this._ctx = new Context5(void 0, {
|
|
1734
|
+
F: __dxlog_file9,
|
|
1735
|
+
L: 26
|
|
1736
|
+
});
|
|
1628
1737
|
}
|
|
1738
|
+
};
|
|
1739
|
+
var CredentialServerExtension = class extends RpcExtension2 {
|
|
1629
1740
|
async getHandlers() {
|
|
1630
1741
|
return {
|
|
1631
1742
|
AdmissionDiscoveryService: {
|
|
@@ -1641,6 +1752,13 @@ var CredentialServerExtension = class extends RpcExtension2 {
|
|
|
1641
1752
|
}
|
|
1642
1753
|
};
|
|
1643
1754
|
}
|
|
1755
|
+
constructor(_space) {
|
|
1756
|
+
super({
|
|
1757
|
+
exposed: {
|
|
1758
|
+
AdmissionDiscoveryService: schema4.getService("dxos.mesh.teleport.AdmissionDiscoveryService")
|
|
1759
|
+
}
|
|
1760
|
+
}), _define_property7(this, "_space", void 0), this._space = _space;
|
|
1761
|
+
}
|
|
1644
1762
|
};
|
|
1645
1763
|
|
|
1646
1764
|
// src/space/space-protocol.ts
|
|
@@ -1653,6 +1771,19 @@ import { BlobSync } from "@dxos/teleport-extension-object-sync";
|
|
|
1653
1771
|
import { ReplicatorExtension } from "@dxos/teleport-extension-replicator";
|
|
1654
1772
|
import { trace as trace3 } from "@dxos/tracing";
|
|
1655
1773
|
import { CallbackCollection, ComplexMap as ComplexMap4 } from "@dxos/util";
|
|
1774
|
+
function _define_property8(obj, key, value) {
|
|
1775
|
+
if (key in obj) {
|
|
1776
|
+
Object.defineProperty(obj, key, {
|
|
1777
|
+
value,
|
|
1778
|
+
enumerable: true,
|
|
1779
|
+
configurable: true,
|
|
1780
|
+
writable: true
|
|
1781
|
+
});
|
|
1782
|
+
} else {
|
|
1783
|
+
obj[key] = value;
|
|
1784
|
+
}
|
|
1785
|
+
return obj;
|
|
1786
|
+
}
|
|
1656
1787
|
function _ts_decorate6(decorators, target, key, desc) {
|
|
1657
1788
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
1658
1789
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -1663,27 +1794,6 @@ var __dxlog_file10 = "/__w/dxos/dxos/packages/core/echo/echo-pipeline/src/space/
|
|
|
1663
1794
|
var MOCK_AUTH_PROVIDER = async (nonce) => Buffer.from("mock");
|
|
1664
1795
|
var MOCK_AUTH_VERIFIER = async (nonce, credential) => true;
|
|
1665
1796
|
var SpaceProtocol = class {
|
|
1666
|
-
constructor({ topic, swarmIdentity, networkManager, onSessionAuth, onAuthFailure, blobStore, disableP2pReplication }) {
|
|
1667
|
-
this._feeds = /* @__PURE__ */ new Set();
|
|
1668
|
-
this._sessions = new ComplexMap4(PublicKey5.hash);
|
|
1669
|
-
// TODO(burdon): Move to config (with sensible defaults).
|
|
1670
|
-
this._topology = new MMSTTopology({
|
|
1671
|
-
originateConnections: 4,
|
|
1672
|
-
maxPeers: 10,
|
|
1673
|
-
sampleSize: 20
|
|
1674
|
-
});
|
|
1675
|
-
this.feedAdded = new CallbackCollection();
|
|
1676
|
-
this._spaceKey = topic;
|
|
1677
|
-
this._networkManager = networkManager;
|
|
1678
|
-
this._swarmIdentity = swarmIdentity;
|
|
1679
|
-
this._onSessionAuth = onSessionAuth;
|
|
1680
|
-
this._onAuthFailure = onAuthFailure;
|
|
1681
|
-
this.blobSync = new BlobSync({
|
|
1682
|
-
blobStore
|
|
1683
|
-
});
|
|
1684
|
-
this._topic = subtleCrypto2.digest("SHA-256", topic.asBuffer()).then(discoveryKey).then(PublicKey5.from);
|
|
1685
|
-
this._disableP2pReplication = disableP2pReplication ?? false;
|
|
1686
|
-
}
|
|
1687
1797
|
get sessions() {
|
|
1688
1798
|
return this._sessions;
|
|
1689
1799
|
}
|
|
@@ -1699,7 +1809,7 @@ var SpaceProtocol = class {
|
|
|
1699
1809
|
key: feed.key
|
|
1700
1810
|
}, {
|
|
1701
1811
|
F: __dxlog_file10,
|
|
1702
|
-
L:
|
|
1812
|
+
L: 131,
|
|
1703
1813
|
S: this,
|
|
1704
1814
|
C: (f, a) => f(...a)
|
|
1705
1815
|
});
|
|
@@ -1718,7 +1828,7 @@ var SpaceProtocol = class {
|
|
|
1718
1828
|
await this.blobSync.open();
|
|
1719
1829
|
log8("starting...", void 0, {
|
|
1720
1830
|
F: __dxlog_file10,
|
|
1721
|
-
L:
|
|
1831
|
+
L: 152,
|
|
1722
1832
|
S: this,
|
|
1723
1833
|
C: (f, a) => f(...a)
|
|
1724
1834
|
});
|
|
@@ -1731,7 +1841,7 @@ var SpaceProtocol = class {
|
|
|
1731
1841
|
});
|
|
1732
1842
|
log8("started", void 0, {
|
|
1733
1843
|
F: __dxlog_file10,
|
|
1734
|
-
L:
|
|
1844
|
+
L: 161,
|
|
1735
1845
|
S: this,
|
|
1736
1846
|
C: (f, a) => f(...a)
|
|
1737
1847
|
});
|
|
@@ -1744,14 +1854,14 @@ var SpaceProtocol = class {
|
|
|
1744
1854
|
if (this._connection) {
|
|
1745
1855
|
log8("stopping...", void 0, {
|
|
1746
1856
|
F: __dxlog_file10,
|
|
1747
|
-
L:
|
|
1857
|
+
L: 172,
|
|
1748
1858
|
S: this,
|
|
1749
1859
|
C: (f, a) => f(...a)
|
|
1750
1860
|
});
|
|
1751
1861
|
await this._connection.close();
|
|
1752
1862
|
log8("stopped", void 0, {
|
|
1753
1863
|
F: __dxlog_file10,
|
|
1754
|
-
L:
|
|
1864
|
+
L: 174,
|
|
1755
1865
|
S: this,
|
|
1756
1866
|
C: (f, a) => f(...a)
|
|
1757
1867
|
});
|
|
@@ -1774,6 +1884,35 @@ var SpaceProtocol = class {
|
|
|
1774
1884
|
return session;
|
|
1775
1885
|
};
|
|
1776
1886
|
}
|
|
1887
|
+
constructor({ topic, swarmIdentity, networkManager, onSessionAuth, onAuthFailure, blobStore, disableP2pReplication }) {
|
|
1888
|
+
_define_property8(this, "_networkManager", void 0);
|
|
1889
|
+
_define_property8(this, "_swarmIdentity", void 0);
|
|
1890
|
+
_define_property8(this, "_onSessionAuth", void 0);
|
|
1891
|
+
_define_property8(this, "_onAuthFailure", void 0);
|
|
1892
|
+
_define_property8(this, "blobSync", void 0);
|
|
1893
|
+
_define_property8(this, "_disableP2pReplication", void 0);
|
|
1894
|
+
_define_property8(this, "_topic", void 0);
|
|
1895
|
+
_define_property8(this, "_spaceKey", void 0);
|
|
1896
|
+
_define_property8(this, "_feeds", /* @__PURE__ */ new Set());
|
|
1897
|
+
_define_property8(this, "_sessions", new ComplexMap4(PublicKey5.hash));
|
|
1898
|
+
_define_property8(this, "_topology", new MMSTTopology({
|
|
1899
|
+
originateConnections: 4,
|
|
1900
|
+
maxPeers: 10,
|
|
1901
|
+
sampleSize: 20
|
|
1902
|
+
}));
|
|
1903
|
+
_define_property8(this, "_connection", void 0);
|
|
1904
|
+
_define_property8(this, "feedAdded", new CallbackCollection());
|
|
1905
|
+
this._spaceKey = topic;
|
|
1906
|
+
this._networkManager = networkManager;
|
|
1907
|
+
this._swarmIdentity = swarmIdentity;
|
|
1908
|
+
this._onSessionAuth = onSessionAuth;
|
|
1909
|
+
this._onAuthFailure = onAuthFailure;
|
|
1910
|
+
this.blobSync = new BlobSync({
|
|
1911
|
+
blobStore
|
|
1912
|
+
});
|
|
1913
|
+
this._topic = subtleCrypto2.digest("SHA-256", topic.asBuffer()).then(discoveryKey).then(PublicKey5.from);
|
|
1914
|
+
this._disableP2pReplication = disableP2pReplication ?? false;
|
|
1915
|
+
}
|
|
1777
1916
|
};
|
|
1778
1917
|
_ts_decorate6([
|
|
1779
1918
|
logInfo2,
|
|
@@ -1795,21 +1934,6 @@ var AuthStatus = /* @__PURE__ */ function(AuthStatus2) {
|
|
|
1795
1934
|
return AuthStatus2;
|
|
1796
1935
|
}({});
|
|
1797
1936
|
var SpaceProtocolSession = class {
|
|
1798
|
-
// TODO(dmaretskyi): Allow to pass in extra extensions.
|
|
1799
|
-
constructor({ wireParams, swarmIdentity, onSessionAuth, onAuthFailure, blobSync, disableP2pReplication }) {
|
|
1800
|
-
// TODO(dmaretskyi): Start with upload=false when switching it on the fly works.
|
|
1801
|
-
this.replicator = new ReplicatorExtension().setOptions({
|
|
1802
|
-
upload: true
|
|
1803
|
-
});
|
|
1804
|
-
this._authStatus = "INITIAL";
|
|
1805
|
-
this._wireParams = wireParams;
|
|
1806
|
-
this._swarmIdentity = swarmIdentity;
|
|
1807
|
-
this._onSessionAuth = onSessionAuth;
|
|
1808
|
-
this._onAuthFailure = onAuthFailure;
|
|
1809
|
-
this._blobSync = blobSync;
|
|
1810
|
-
this._teleport = new Teleport(wireParams);
|
|
1811
|
-
this._disableP2pReplication = disableP2pReplication ?? false;
|
|
1812
|
-
}
|
|
1813
1937
|
get authStatus() {
|
|
1814
1938
|
return this._authStatus;
|
|
1815
1939
|
}
|
|
@@ -1827,7 +1951,7 @@ var SpaceProtocolSession = class {
|
|
|
1827
1951
|
onAuthSuccess: () => {
|
|
1828
1952
|
log8("Peer authenticated", void 0, {
|
|
1829
1953
|
F: __dxlog_file10,
|
|
1830
|
-
L:
|
|
1954
|
+
L: 285,
|
|
1831
1955
|
S: this,
|
|
1832
1956
|
C: (f, a) => f(...a)
|
|
1833
1957
|
});
|
|
@@ -1847,7 +1971,7 @@ var SpaceProtocolSession = class {
|
|
|
1847
1971
|
async close() {
|
|
1848
1972
|
log8("close", void 0, {
|
|
1849
1973
|
F: __dxlog_file10,
|
|
1850
|
-
L:
|
|
1974
|
+
L: 304,
|
|
1851
1975
|
S: this,
|
|
1852
1976
|
C: (f, a) => f(...a)
|
|
1853
1977
|
});
|
|
@@ -1856,6 +1980,27 @@ var SpaceProtocolSession = class {
|
|
|
1856
1980
|
async abort() {
|
|
1857
1981
|
await this._teleport.abort();
|
|
1858
1982
|
}
|
|
1983
|
+
// TODO(dmaretskyi): Allow to pass in extra extensions.
|
|
1984
|
+
constructor({ wireParams, swarmIdentity, onSessionAuth, onAuthFailure, blobSync, disableP2pReplication }) {
|
|
1985
|
+
_define_property8(this, "_wireParams", void 0);
|
|
1986
|
+
_define_property8(this, "_disableP2pReplication", void 0);
|
|
1987
|
+
_define_property8(this, "_onSessionAuth", void 0);
|
|
1988
|
+
_define_property8(this, "_onAuthFailure", void 0);
|
|
1989
|
+
_define_property8(this, "_swarmIdentity", void 0);
|
|
1990
|
+
_define_property8(this, "_blobSync", void 0);
|
|
1991
|
+
_define_property8(this, "_teleport", void 0);
|
|
1992
|
+
_define_property8(this, "replicator", new ReplicatorExtension().setOptions({
|
|
1993
|
+
upload: true
|
|
1994
|
+
}));
|
|
1995
|
+
_define_property8(this, "_authStatus", "INITIAL");
|
|
1996
|
+
this._wireParams = wireParams;
|
|
1997
|
+
this._swarmIdentity = swarmIdentity;
|
|
1998
|
+
this._onSessionAuth = onSessionAuth;
|
|
1999
|
+
this._onAuthFailure = onAuthFailure;
|
|
2000
|
+
this._blobSync = blobSync;
|
|
2001
|
+
this._teleport = new Teleport(wireParams);
|
|
2002
|
+
this._disableP2pReplication = disableP2pReplication ?? false;
|
|
2003
|
+
}
|
|
1859
2004
|
};
|
|
1860
2005
|
_ts_decorate6([
|
|
1861
2006
|
logInfo2
|
|
@@ -1866,13 +2011,26 @@ _ts_decorate6([
|
|
|
1866
2011
|
|
|
1867
2012
|
// src/space/space-manager.ts
|
|
1868
2013
|
import { parseAutomergeUrl } from "@automerge/automerge-repo";
|
|
1869
|
-
import {
|
|
2014
|
+
import { Trigger as Trigger2, synchronized as synchronized4, trackLeaks as trackLeaks3 } from "@dxos/async";
|
|
1870
2015
|
import { getCredentialAssertion } from "@dxos/credentials";
|
|
1871
2016
|
import { failUndefined as failUndefined2 } from "@dxos/debug";
|
|
1872
2017
|
import { PublicKey as PublicKey6 } from "@dxos/keys";
|
|
1873
2018
|
import { log as log9 } from "@dxos/log";
|
|
1874
2019
|
import { trace as trace4 } from "@dxos/protocols";
|
|
1875
2020
|
import { ComplexMap as ComplexMap5 } from "@dxos/util";
|
|
2021
|
+
function _define_property9(obj, key, value) {
|
|
2022
|
+
if (key in obj) {
|
|
2023
|
+
Object.defineProperty(obj, key, {
|
|
2024
|
+
value,
|
|
2025
|
+
enumerable: true,
|
|
2026
|
+
configurable: true,
|
|
2027
|
+
writable: true
|
|
2028
|
+
});
|
|
2029
|
+
} else {
|
|
2030
|
+
obj[key] = value;
|
|
2031
|
+
}
|
|
2032
|
+
return obj;
|
|
2033
|
+
}
|
|
1876
2034
|
function _ts_decorate7(decorators, target, key, desc) {
|
|
1877
2035
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
1878
2036
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -1881,15 +2039,6 @@ function _ts_decorate7(decorators, target, key, desc) {
|
|
|
1881
2039
|
}
|
|
1882
2040
|
var __dxlog_file11 = "/__w/dxos/dxos/packages/core/echo/echo-pipeline/src/space/space-manager.ts";
|
|
1883
2041
|
var SpaceManager = class {
|
|
1884
|
-
constructor({ feedStore, networkManager, metadataStore, blobStore, disableP2pReplication }) {
|
|
1885
|
-
this._spaces = new ComplexMap5(PublicKey6.hash);
|
|
1886
|
-
this._instanceId = PublicKey6.random().toHex();
|
|
1887
|
-
this._feedStore = feedStore;
|
|
1888
|
-
this._networkManager = networkManager;
|
|
1889
|
-
this._metadataStore = metadataStore;
|
|
1890
|
-
this._blobStore = blobStore;
|
|
1891
|
-
this._disableP2pReplication = disableP2pReplication ?? false;
|
|
1892
|
-
}
|
|
1893
2042
|
// TODO(burdon): Remove.
|
|
1894
2043
|
get spaces() {
|
|
1895
2044
|
return this._spaces;
|
|
@@ -1906,7 +2055,7 @@ var SpaceManager = class {
|
|
|
1906
2055
|
id: this._instanceId
|
|
1907
2056
|
}), {
|
|
1908
2057
|
F: __dxlog_file11,
|
|
1909
|
-
L:
|
|
2058
|
+
L: 103,
|
|
1910
2059
|
S: this,
|
|
1911
2060
|
C: (f, a) => f(...a)
|
|
1912
2061
|
});
|
|
@@ -1914,7 +2063,7 @@ var SpaceManager = class {
|
|
|
1914
2063
|
spaceKey: metadata.genesisFeedKey
|
|
1915
2064
|
}, {
|
|
1916
2065
|
F: __dxlog_file11,
|
|
1917
|
-
L:
|
|
2066
|
+
L: 104,
|
|
1918
2067
|
S: this,
|
|
1919
2068
|
C: (f, a) => f(...a)
|
|
1920
2069
|
});
|
|
@@ -1946,7 +2095,7 @@ var SpaceManager = class {
|
|
|
1946
2095
|
id: this._instanceId
|
|
1947
2096
|
}), {
|
|
1948
2097
|
F: __dxlog_file11,
|
|
1949
|
-
L:
|
|
2098
|
+
L: 134,
|
|
1950
2099
|
S: this,
|
|
1951
2100
|
C: (f, a) => f(...a)
|
|
1952
2101
|
});
|
|
@@ -1958,7 +2107,7 @@ var SpaceManager = class {
|
|
|
1958
2107
|
id: this._instanceId
|
|
1959
2108
|
}), {
|
|
1960
2109
|
F: __dxlog_file11,
|
|
1961
|
-
L:
|
|
2110
|
+
L: 140,
|
|
1962
2111
|
S: this,
|
|
1963
2112
|
C: (f, a) => f(...a)
|
|
1964
2113
|
});
|
|
@@ -1966,7 +2115,7 @@ var SpaceManager = class {
|
|
|
1966
2115
|
spaceKey: params.spaceKey
|
|
1967
2116
|
}, {
|
|
1968
2117
|
F: __dxlog_file11,
|
|
1969
|
-
L:
|
|
2118
|
+
L: 141,
|
|
1970
2119
|
S: this,
|
|
1971
2120
|
C: (f, a) => f(...a)
|
|
1972
2121
|
});
|
|
@@ -1994,7 +2143,7 @@ var SpaceManager = class {
|
|
|
1994
2143
|
id: this._instanceId
|
|
1995
2144
|
}), {
|
|
1996
2145
|
F: __dxlog_file11,
|
|
1997
|
-
L:
|
|
2146
|
+
L: 165,
|
|
1998
2147
|
S: this,
|
|
1999
2148
|
C: (f, a) => f(...a)
|
|
2000
2149
|
});
|
|
@@ -2005,7 +2154,7 @@ var SpaceManager = class {
|
|
|
2005
2154
|
error: err
|
|
2006
2155
|
}), {
|
|
2007
2156
|
F: __dxlog_file11,
|
|
2008
|
-
L:
|
|
2157
|
+
L: 168,
|
|
2009
2158
|
S: this,
|
|
2010
2159
|
C: (f, a) => f(...a)
|
|
2011
2160
|
});
|
|
@@ -2030,6 +2179,20 @@ var SpaceManager = class {
|
|
|
2030
2179
|
});
|
|
2031
2180
|
});
|
|
2032
2181
|
}
|
|
2182
|
+
constructor({ feedStore, networkManager, metadataStore, blobStore, disableP2pReplication }) {
|
|
2183
|
+
_define_property9(this, "_spaces", new ComplexMap5(PublicKey6.hash));
|
|
2184
|
+
_define_property9(this, "_feedStore", void 0);
|
|
2185
|
+
_define_property9(this, "_networkManager", void 0);
|
|
2186
|
+
_define_property9(this, "_metadataStore", void 0);
|
|
2187
|
+
_define_property9(this, "_blobStore", void 0);
|
|
2188
|
+
_define_property9(this, "_instanceId", PublicKey6.random().toHex());
|
|
2189
|
+
_define_property9(this, "_disableP2pReplication", void 0);
|
|
2190
|
+
this._feedStore = feedStore;
|
|
2191
|
+
this._networkManager = networkManager;
|
|
2192
|
+
this._metadataStore = metadataStore;
|
|
2193
|
+
this._blobStore = blobStore;
|
|
2194
|
+
this._disableP2pReplication = disableP2pReplication ?? false;
|
|
2195
|
+
}
|
|
2033
2196
|
};
|
|
2034
2197
|
_ts_decorate7([
|
|
2035
2198
|
synchronized4
|
|
@@ -2064,4 +2227,4 @@ export {
|
|
|
2064
2227
|
SpaceProtocolSession,
|
|
2065
2228
|
SpaceManager
|
|
2066
2229
|
};
|
|
2067
|
-
//# sourceMappingURL=chunk-
|
|
2230
|
+
//# sourceMappingURL=chunk-I4JBIZSN.mjs.map
|