@dxos/echo-pipeline 0.8.4-main.e098934 → 0.8.4-main.e8ec1fe
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-I4JBIZSN.mjs → chunk-FR6GJ4S4.mjs} +341 -427
- package/dist/lib/browser/{chunk-I4JBIZSN.mjs.map → chunk-FR6GJ4S4.mjs.map} +2 -2
- package/dist/lib/browser/{chunk-KQYT6ADL.mjs → chunk-WJJXJTNS.mjs} +11 -3
- package/dist/lib/browser/chunk-WJJXJTNS.mjs.map +7 -0
- package/dist/lib/browser/filter/index.mjs +1 -1
- package/dist/lib/browser/index.mjs +780 -795
- package/dist/lib/browser/index.mjs.map +3 -3
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/testing/index.mjs +65 -106
- package/dist/lib/browser/testing/index.mjs.map +3 -3
- package/dist/lib/node-esm/{chunk-YOL7JY5W.mjs → chunk-JQCCVDLT.mjs} +341 -427
- package/dist/lib/node-esm/{chunk-YOL7JY5W.mjs.map → chunk-JQCCVDLT.mjs.map} +2 -2
- package/dist/lib/node-esm/{chunk-W4ACY3YC.mjs → chunk-LEQ77KAT.mjs} +11 -3
- package/dist/lib/node-esm/chunk-LEQ77KAT.mjs.map +7 -0
- package/dist/lib/node-esm/filter/index.mjs +1 -1
- package/dist/lib/node-esm/index.mjs +780 -795
- package/dist/lib/node-esm/index.mjs.map +3 -3
- package/dist/lib/node-esm/meta.json +1 -1
- package/dist/lib/node-esm/testing/index.mjs +65 -106
- package/dist/lib/node-esm/testing/index.mjs.map +3 -3
- package/dist/types/src/automerge/automerge-host.d.ts.map +1 -1
- package/dist/types/src/automerge/collection-synchronizer.d.ts +2 -1
- package/dist/types/src/automerge/collection-synchronizer.d.ts.map +1 -1
- package/dist/types/src/db-host/query-service.d.ts.map +1 -1
- package/dist/types/src/edge/echo-edge-replicator.d.ts.map +1 -1
- package/dist/types/src/filter/filter-match.d.ts +2 -2
- package/dist/types/src/filter/filter-match.d.ts.map +1 -1
- package/dist/types/src/query/errors.d.ts +7 -9
- package/dist/types/src/query/errors.d.ts.map +1 -1
- package/dist/types/src/query/query-executor.d.ts +9 -0
- package/dist/types/src/query/query-executor.d.ts.map +1 -1
- package/dist/types/src/query/query-planner.d.ts.map +1 -1
- package/dist/types/src/testing/test-data.d.ts.map +1 -1
- package/dist/types/src/testing/test-schema.d.ts +1 -1
- package/dist/types/src/testing/test-schema.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +37 -39
- package/src/automerge/automerge-host.ts +34 -21
- package/src/automerge/collection-synchronizer.test.ts +4 -3
- package/src/automerge/collection-synchronizer.ts +14 -9
- package/src/db-host/echo-host.ts +1 -1
- package/src/db-host/query-service.ts +2 -1
- package/src/edge/echo-edge-replicator.ts +30 -9
- package/src/filter/filter-match.test.ts +22 -22
- package/src/filter/filter-match.ts +19 -10
- package/src/query/query-executor.ts +121 -36
- package/src/query/query-planner.test.ts +90 -5
- package/src/query/query-planner.ts +35 -4
- package/src/testing/test-data.ts +1 -1
- package/src/testing/test-schema.ts +1 -1
- package/dist/lib/browser/chunk-KQYT6ADL.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-W4ACY3YC.mjs.map +0 -7
|
@@ -61,19 +61,6 @@ 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
|
-
}
|
|
77
64
|
function _ts_decorate(decorators, target, key, desc) {
|
|
78
65
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
79
66
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -92,6 +79,21 @@ var emptyLargeSpaceMetadata = () => ({});
|
|
|
92
79
|
var EchoMetadata = schema2.getCodecForType("dxos.echo.metadata.EchoMetadata");
|
|
93
80
|
var LargeSpaceMetadata = schema2.getCodecForType("dxos.echo.metadata.LargeSpaceMetadata");
|
|
94
81
|
var MetadataStore = class {
|
|
82
|
+
_metadata = emptyEchoMetadata();
|
|
83
|
+
_spaceLargeMetadata = new ComplexMap2(PublicKey2.hash);
|
|
84
|
+
_metadataFile = void 0;
|
|
85
|
+
update = new Event();
|
|
86
|
+
_invitationCleanupCtx = new Context(void 0, {
|
|
87
|
+
F: __dxlog_file2,
|
|
88
|
+
L: 55
|
|
89
|
+
});
|
|
90
|
+
/**
|
|
91
|
+
* @internal
|
|
92
|
+
*/
|
|
93
|
+
_directory;
|
|
94
|
+
constructor(directory) {
|
|
95
|
+
this._directory = directory;
|
|
96
|
+
}
|
|
95
97
|
get metadata() {
|
|
96
98
|
return this._metadata;
|
|
97
99
|
}
|
|
@@ -181,8 +183,7 @@ var MetadataStore = class {
|
|
|
181
183
|
this._metadata = metadata;
|
|
182
184
|
}
|
|
183
185
|
this._metadata.spaces?.forEach((space) => {
|
|
184
|
-
|
|
185
|
-
(_space = space).state ?? (_space.state = SpaceState.SPACE_ACTIVE);
|
|
186
|
+
space.state ??= SpaceState.SPACE_ACTIVE;
|
|
186
187
|
});
|
|
187
188
|
} catch (err) {
|
|
188
189
|
log.error("failed to load metadata", {
|
|
@@ -322,11 +323,10 @@ var MetadataStore = class {
|
|
|
322
323
|
return this._metadata.invitations ?? [];
|
|
323
324
|
}
|
|
324
325
|
async addInvitation(invitation) {
|
|
325
|
-
var _this__metadata;
|
|
326
326
|
if (this._metadata.invitations?.find((i) => i.invitationId === invitation.invitationId)) {
|
|
327
327
|
return;
|
|
328
328
|
}
|
|
329
|
-
(
|
|
329
|
+
(this._metadata.invitations ??= []).push(invitation);
|
|
330
330
|
await this._save();
|
|
331
331
|
await this.flush();
|
|
332
332
|
}
|
|
@@ -336,7 +336,6 @@ var MetadataStore = class {
|
|
|
336
336
|
await this.flush();
|
|
337
337
|
}
|
|
338
338
|
async addSpace(record) {
|
|
339
|
-
var _this__metadata;
|
|
340
339
|
invariant2(!(this._metadata.spaces ?? []).find((space) => space.key.equals(record.key)), "Cannot overwrite existing space in metadata", {
|
|
341
340
|
F: __dxlog_file2,
|
|
342
341
|
L: 300,
|
|
@@ -346,7 +345,7 @@ var MetadataStore = class {
|
|
|
346
345
|
"'Cannot overwrite existing space in metadata'"
|
|
347
346
|
]
|
|
348
347
|
});
|
|
349
|
-
(
|
|
348
|
+
(this._metadata.spaces ??= []).push(record);
|
|
350
349
|
await this._save();
|
|
351
350
|
await this.flush();
|
|
352
351
|
}
|
|
@@ -391,18 +390,6 @@ var MetadataStore = class {
|
|
|
391
390
|
await this._save();
|
|
392
391
|
await this.flush();
|
|
393
392
|
}
|
|
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
|
-
}
|
|
406
393
|
};
|
|
407
394
|
_ts_decorate([
|
|
408
395
|
synchronized
|
|
@@ -426,19 +413,6 @@ import { Event as Event2 } from "@dxos/async";
|
|
|
426
413
|
import { timed } from "@dxos/debug";
|
|
427
414
|
import { log as log2 } from "@dxos/log";
|
|
428
415
|
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
|
-
}
|
|
442
416
|
function _ts_decorate2(decorators, target, key, desc) {
|
|
443
417
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
444
418
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -459,6 +433,13 @@ var startAfter = (timeframe) => timeframe.frames().map(([feedKey, index]) => ({
|
|
|
459
433
|
index: index + 1
|
|
460
434
|
}));
|
|
461
435
|
var TimeframeClock = class {
|
|
436
|
+
_timeframe;
|
|
437
|
+
update = new Event2();
|
|
438
|
+
_pendingTimeframe;
|
|
439
|
+
constructor(_timeframe = new Timeframe()) {
|
|
440
|
+
this._timeframe = _timeframe;
|
|
441
|
+
this._pendingTimeframe = _timeframe;
|
|
442
|
+
}
|
|
462
443
|
/**
|
|
463
444
|
* Timeframe that was processed by ECHO.
|
|
464
445
|
*/
|
|
@@ -517,14 +498,6 @@ var TimeframeClock = class {
|
|
|
517
498
|
return Timeframe.dependencies(target, this._timeframe).isEmpty();
|
|
518
499
|
});
|
|
519
500
|
}
|
|
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
|
-
}
|
|
528
501
|
};
|
|
529
502
|
_ts_decorate2([
|
|
530
503
|
timed(5e3)
|
|
@@ -572,19 +545,6 @@ var createMessageSelector = (timeframeClock) => {
|
|
|
572
545
|
};
|
|
573
546
|
|
|
574
547
|
// 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
|
-
}
|
|
588
548
|
function _ts_decorate3(decorators, target, key, desc) {
|
|
589
549
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
590
550
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -593,10 +553,40 @@ function _ts_decorate3(decorators, target, key, desc) {
|
|
|
593
553
|
}
|
|
594
554
|
var __dxlog_file5 = "/__w/dxos/dxos/packages/core/echo/echo-pipeline/src/pipeline/pipeline.ts";
|
|
595
555
|
var PipelineState = class {
|
|
556
|
+
_feeds;
|
|
557
|
+
_timeframeClock;
|
|
558
|
+
/**
|
|
559
|
+
* @internal
|
|
560
|
+
*/
|
|
561
|
+
_ctx = new Context2(void 0, {
|
|
562
|
+
F: __dxlog_file5,
|
|
563
|
+
L: 42
|
|
564
|
+
});
|
|
596
565
|
// TODO(dmaretskyi): Remove?. Avoid accessing `_timeframeClock` before constructor initialization.
|
|
597
566
|
get timeframeUpdate() {
|
|
598
567
|
return this._timeframeClock.update;
|
|
599
568
|
}
|
|
569
|
+
stalled = new Event3();
|
|
570
|
+
/**
|
|
571
|
+
* @internal
|
|
572
|
+
*/
|
|
573
|
+
_startTimeframe = new Timeframe2();
|
|
574
|
+
/**
|
|
575
|
+
* Target timeframe we are waiting to reach.
|
|
576
|
+
*/
|
|
577
|
+
_targetTimeframe;
|
|
578
|
+
/**
|
|
579
|
+
* @internal
|
|
580
|
+
*/
|
|
581
|
+
_reachedTargetPromise;
|
|
582
|
+
/**
|
|
583
|
+
* @internal
|
|
584
|
+
*/
|
|
585
|
+
_reachedTarget = false;
|
|
586
|
+
constructor(_feeds, _timeframeClock) {
|
|
587
|
+
this._feeds = _feeds;
|
|
588
|
+
this._timeframeClock = _timeframeClock;
|
|
589
|
+
}
|
|
600
590
|
/**
|
|
601
591
|
* Latest theoretical timeframe based on the last mutation in each feed.
|
|
602
592
|
* NOTE: This might never be reached if the mutation dependencies
|
|
@@ -653,14 +643,14 @@ var PipelineState = class {
|
|
|
653
643
|
S: this,
|
|
654
644
|
C: (f, a) => f(...a)
|
|
655
645
|
});
|
|
656
|
-
this._reachedTargetPromise
|
|
646
|
+
this._reachedTargetPromise ??= Promise.race([
|
|
657
647
|
this._timeframeClock.update.waitForCondition(() => {
|
|
658
648
|
return Timeframe2.dependencies(this.targetTimeframe, this.timeframe).isEmpty();
|
|
659
649
|
}),
|
|
660
650
|
...breakOnStall ? [
|
|
661
651
|
this.stalled.discardParameter().waitForCount(1)
|
|
662
652
|
] : []
|
|
663
|
-
])
|
|
653
|
+
]);
|
|
664
654
|
let done = false;
|
|
665
655
|
if (timeout) {
|
|
666
656
|
return Promise.race([
|
|
@@ -691,27 +681,25 @@ var PipelineState = class {
|
|
|
691
681
|
return this._reachedTargetPromise;
|
|
692
682
|
}
|
|
693
683
|
}
|
|
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
|
-
}
|
|
713
684
|
};
|
|
714
685
|
var Pipeline = class {
|
|
686
|
+
_timeframeClock = new TimeframeClock(new Timeframe2());
|
|
687
|
+
_feeds = new ComplexMap3(PublicKey3.hash);
|
|
688
|
+
// External state accessor.
|
|
689
|
+
_state = new PipelineState(this._feeds, this._timeframeClock);
|
|
690
|
+
// Waits for the message consumer to process the message and yield control back to the pipeline.
|
|
691
|
+
_processingTrigger = new Trigger().wake();
|
|
692
|
+
_pauseTrigger = new Trigger().wake();
|
|
693
|
+
// Pending downloads.
|
|
694
|
+
_downloads = new ComplexMap3((value) => PublicKey3.hash(value.key));
|
|
695
|
+
// Inbound feed stream.
|
|
696
|
+
_feedSetIterator;
|
|
697
|
+
// Outbound feed writer.
|
|
698
|
+
_writer;
|
|
699
|
+
_isStopping = false;
|
|
700
|
+
_isStarted = false;
|
|
701
|
+
_isBeingConsumed = false;
|
|
702
|
+
_isPaused = false;
|
|
715
703
|
get state() {
|
|
716
704
|
return this._state;
|
|
717
705
|
}
|
|
@@ -986,20 +974,6 @@ var Pipeline = class {
|
|
|
986
974
|
await this._feedSetIterator.addFeed(feed);
|
|
987
975
|
}
|
|
988
976
|
}
|
|
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
|
-
}
|
|
1003
977
|
};
|
|
1004
978
|
_ts_decorate3([
|
|
1005
979
|
synchronized2
|
|
@@ -1025,21 +999,33 @@ import { invariant as invariant5 } from "@dxos/invariant";
|
|
|
1025
999
|
import { log as log5 } from "@dxos/log";
|
|
1026
1000
|
import { schema as schema3 } from "@dxos/protocols/proto";
|
|
1027
1001
|
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
|
-
}
|
|
1041
1002
|
var __dxlog_file6 = "/__w/dxos/dxos/packages/core/echo/echo-pipeline/src/space/auth.ts";
|
|
1042
1003
|
var AuthExtension = class extends RpcExtension {
|
|
1004
|
+
_authParams;
|
|
1005
|
+
_ctx = new Context3({
|
|
1006
|
+
onError: (err) => {
|
|
1007
|
+
log5.catch(err, void 0, {
|
|
1008
|
+
F: __dxlog_file6,
|
|
1009
|
+
L: 28,
|
|
1010
|
+
S: this,
|
|
1011
|
+
C: (f, a) => f(...a)
|
|
1012
|
+
});
|
|
1013
|
+
}
|
|
1014
|
+
}, {
|
|
1015
|
+
F: __dxlog_file6,
|
|
1016
|
+
L: 26
|
|
1017
|
+
});
|
|
1018
|
+
constructor(_authParams) {
|
|
1019
|
+
super({
|
|
1020
|
+
requested: {
|
|
1021
|
+
AuthService: schema3.getService("dxos.mesh.teleport.auth.AuthService")
|
|
1022
|
+
},
|
|
1023
|
+
exposed: {
|
|
1024
|
+
AuthService: schema3.getService("dxos.mesh.teleport.auth.AuthService")
|
|
1025
|
+
},
|
|
1026
|
+
timeout: 60 * 1e3
|
|
1027
|
+
}), this._authParams = _authParams;
|
|
1028
|
+
}
|
|
1043
1029
|
async getHandlers() {
|
|
1044
1030
|
return {
|
|
1045
1031
|
AuthService: {
|
|
@@ -1113,29 +1099,6 @@ var AuthExtension = class extends RpcExtension {
|
|
|
1113
1099
|
await this._ctx.dispose();
|
|
1114
1100
|
await super.onAbort();
|
|
1115
1101
|
}
|
|
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
|
-
}
|
|
1139
1102
|
};
|
|
1140
1103
|
|
|
1141
1104
|
// src/space/space.ts
|
|
@@ -1157,19 +1120,6 @@ import { AdmittedFeed } from "@dxos/protocols/proto/dxos/halo/credentials";
|
|
|
1157
1120
|
import { Timeframe as Timeframe3 } from "@dxos/timeframe";
|
|
1158
1121
|
import { TimeSeriesCounter, TimeUsageCounter, trace } from "@dxos/tracing";
|
|
1159
1122
|
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
|
-
}
|
|
1173
1123
|
function _ts_decorate4(decorators, target, key, desc) {
|
|
1174
1124
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
1175
1125
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -1181,6 +1131,69 @@ var TIMEFRAME_SAVE_DEBOUNCE_INTERVAL = 500;
|
|
|
1181
1131
|
var CONTROL_PIPELINE_SNAPSHOT_DELAY = 1e4;
|
|
1182
1132
|
var USE_SNAPSHOTS = true;
|
|
1183
1133
|
var ControlPipeline = class {
|
|
1134
|
+
_ctx = new Context4(void 0, {
|
|
1135
|
+
F: __dxlog_file7,
|
|
1136
|
+
L: 47
|
|
1137
|
+
});
|
|
1138
|
+
_pipeline;
|
|
1139
|
+
_spaceStateMachine;
|
|
1140
|
+
_spaceKey;
|
|
1141
|
+
_metadata;
|
|
1142
|
+
_targetTimeframe;
|
|
1143
|
+
_lastTimeframeSaveTime = Date.now();
|
|
1144
|
+
onFeedAdmitted = new Callback();
|
|
1145
|
+
onMemberRoleChanged;
|
|
1146
|
+
onCredentialProcessed;
|
|
1147
|
+
onDelegatedInvitation;
|
|
1148
|
+
onDelegatedInvitationRemoved;
|
|
1149
|
+
_usage = new TimeUsageCounter();
|
|
1150
|
+
_mutations = new TimeSeriesCounter();
|
|
1151
|
+
_snapshotTask = new DeferredTask(this._ctx, async () => {
|
|
1152
|
+
await sleepWithContext2(this._ctx, CONTROL_PIPELINE_SNAPSHOT_DELAY);
|
|
1153
|
+
await this._saveSnapshot();
|
|
1154
|
+
});
|
|
1155
|
+
constructor({ spaceKey, genesisFeed, feedProvider, metadataStore }) {
|
|
1156
|
+
this._spaceKey = spaceKey;
|
|
1157
|
+
this._metadata = metadataStore;
|
|
1158
|
+
this._pipeline = new Pipeline();
|
|
1159
|
+
void this._pipeline.addFeed(genesisFeed);
|
|
1160
|
+
this._spaceStateMachine = new SpaceStateMachine(spaceKey);
|
|
1161
|
+
this._spaceStateMachine.onFeedAdmitted.set(async (info) => {
|
|
1162
|
+
log6("feed admitted", {
|
|
1163
|
+
key: info.key
|
|
1164
|
+
}, {
|
|
1165
|
+
F: __dxlog_file7,
|
|
1166
|
+
L: 82,
|
|
1167
|
+
S: this,
|
|
1168
|
+
C: (f, a) => f(...a)
|
|
1169
|
+
});
|
|
1170
|
+
if (info.assertion.designation === AdmittedFeed.Designation.CONTROL && !info.key.equals(genesisFeed.key)) {
|
|
1171
|
+
scheduleMicroTask(this._ctx, async () => {
|
|
1172
|
+
try {
|
|
1173
|
+
const feed = await feedProvider(info.key);
|
|
1174
|
+
if (this._ctx.disposed) {
|
|
1175
|
+
return;
|
|
1176
|
+
}
|
|
1177
|
+
if (!this._pipeline.hasFeed(feed.key)) {
|
|
1178
|
+
await this._pipeline.addFeed(feed);
|
|
1179
|
+
}
|
|
1180
|
+
} catch (err) {
|
|
1181
|
+
log6.catch(err, void 0, {
|
|
1182
|
+
F: __dxlog_file7,
|
|
1183
|
+
L: 96,
|
|
1184
|
+
S: this,
|
|
1185
|
+
C: (f, a) => f(...a)
|
|
1186
|
+
});
|
|
1187
|
+
}
|
|
1188
|
+
});
|
|
1189
|
+
}
|
|
1190
|
+
await this.onFeedAdmitted.callIfSet(info);
|
|
1191
|
+
});
|
|
1192
|
+
this.onMemberRoleChanged = this._spaceStateMachine.onMemberRoleChanged;
|
|
1193
|
+
this.onCredentialProcessed = this._spaceStateMachine.onCredentialProcessed;
|
|
1194
|
+
this.onDelegatedInvitation = this._spaceStateMachine.onDelegatedInvitation;
|
|
1195
|
+
this.onDelegatedInvitationRemoved = this._spaceStateMachine.onDelegatedInvitationRemoved;
|
|
1196
|
+
}
|
|
1184
1197
|
get spaceState() {
|
|
1185
1198
|
return this._spaceStateMachine;
|
|
1186
1199
|
}
|
|
@@ -1351,69 +1364,6 @@ var ControlPipeline = class {
|
|
|
1351
1364
|
});
|
|
1352
1365
|
}
|
|
1353
1366
|
}
|
|
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
|
-
}
|
|
1417
1367
|
};
|
|
1418
1368
|
_ts_decorate4([
|
|
1419
1369
|
trace.metricsCounter()
|
|
@@ -1450,19 +1400,6 @@ var getSnapshotLoggerContext = (snapshot) => {
|
|
|
1450
1400
|
};
|
|
1451
1401
|
|
|
1452
1402
|
// 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
|
-
}
|
|
1466
1403
|
function _ts_decorate5(decorators, target, key, desc) {
|
|
1467
1404
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
1468
1405
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -1471,6 +1408,97 @@ function _ts_decorate5(decorators, target, key, desc) {
|
|
|
1471
1408
|
}
|
|
1472
1409
|
var __dxlog_file8 = "/__w/dxos/dxos/packages/core/echo/echo-pipeline/src/space/space.ts";
|
|
1473
1410
|
var Space = class extends Resource {
|
|
1411
|
+
onCredentialProcessed = new Callback2();
|
|
1412
|
+
stateUpdate = new Event4();
|
|
1413
|
+
protocol;
|
|
1414
|
+
_id;
|
|
1415
|
+
_key;
|
|
1416
|
+
_genesisFeedKey;
|
|
1417
|
+
_feedProvider;
|
|
1418
|
+
_controlPipeline;
|
|
1419
|
+
_controlFeed;
|
|
1420
|
+
_dataFeed;
|
|
1421
|
+
constructor(params) {
|
|
1422
|
+
super();
|
|
1423
|
+
invariant6(params.spaceKey && params.feedProvider, void 0, {
|
|
1424
|
+
F: __dxlog_file8,
|
|
1425
|
+
L: 73,
|
|
1426
|
+
S: this,
|
|
1427
|
+
A: [
|
|
1428
|
+
"params.spaceKey && params.feedProvider",
|
|
1429
|
+
""
|
|
1430
|
+
]
|
|
1431
|
+
});
|
|
1432
|
+
this._id = params.id;
|
|
1433
|
+
this._key = params.spaceKey;
|
|
1434
|
+
this._genesisFeedKey = params.genesisFeed.key;
|
|
1435
|
+
this._feedProvider = params.feedProvider;
|
|
1436
|
+
this._controlPipeline = new ControlPipeline({
|
|
1437
|
+
spaceKey: params.spaceKey,
|
|
1438
|
+
genesisFeed: params.genesisFeed,
|
|
1439
|
+
feedProvider: params.feedProvider,
|
|
1440
|
+
metadataStore: params.metadataStore
|
|
1441
|
+
});
|
|
1442
|
+
this._controlPipeline.onFeedAdmitted.set(async (info) => {
|
|
1443
|
+
const sparse = info.assertion.designation === AdmittedFeed2.Designation.DATA;
|
|
1444
|
+
if (!info.key.equals(params.genesisFeed.key)) {
|
|
1445
|
+
scheduleMicroTask2(this._ctx, async () => {
|
|
1446
|
+
await this.protocol.addFeed(await params.feedProvider(info.key, {
|
|
1447
|
+
sparse
|
|
1448
|
+
}));
|
|
1449
|
+
});
|
|
1450
|
+
}
|
|
1451
|
+
});
|
|
1452
|
+
this._controlPipeline.onCredentialProcessed.set(async (credential) => {
|
|
1453
|
+
await this.onCredentialProcessed.callIfSet(credential);
|
|
1454
|
+
log7("onCredentialProcessed", {
|
|
1455
|
+
credential
|
|
1456
|
+
}, {
|
|
1457
|
+
F: __dxlog_file8,
|
|
1458
|
+
L: 100,
|
|
1459
|
+
S: this,
|
|
1460
|
+
C: (f, a) => f(...a)
|
|
1461
|
+
});
|
|
1462
|
+
this.stateUpdate.emit();
|
|
1463
|
+
});
|
|
1464
|
+
this._controlPipeline.onDelegatedInvitation.set(async (invitation) => {
|
|
1465
|
+
log7("onDelegatedInvitation", {
|
|
1466
|
+
invitation
|
|
1467
|
+
}, {
|
|
1468
|
+
F: __dxlog_file8,
|
|
1469
|
+
L: 104,
|
|
1470
|
+
S: this,
|
|
1471
|
+
C: (f, a) => f(...a)
|
|
1472
|
+
});
|
|
1473
|
+
await params.onDelegatedInvitationStatusChange(invitation, true);
|
|
1474
|
+
});
|
|
1475
|
+
this._controlPipeline.onDelegatedInvitationRemoved.set(async (invitation) => {
|
|
1476
|
+
log7("onDelegatedInvitationRemoved", {
|
|
1477
|
+
invitation
|
|
1478
|
+
}, {
|
|
1479
|
+
F: __dxlog_file8,
|
|
1480
|
+
L: 108,
|
|
1481
|
+
S: this,
|
|
1482
|
+
C: (f, a) => f(...a)
|
|
1483
|
+
});
|
|
1484
|
+
await params.onDelegatedInvitationStatusChange(invitation, false);
|
|
1485
|
+
});
|
|
1486
|
+
this._controlPipeline.onMemberRoleChanged.set(async (changedMembers) => {
|
|
1487
|
+
log7("onMemberRoleChanged", () => ({
|
|
1488
|
+
changedMembers: changedMembers.map((m) => [
|
|
1489
|
+
m.key,
|
|
1490
|
+
m.role
|
|
1491
|
+
])
|
|
1492
|
+
}), {
|
|
1493
|
+
F: __dxlog_file8,
|
|
1494
|
+
L: 112,
|
|
1495
|
+
S: this,
|
|
1496
|
+
C: (f, a) => f(...a)
|
|
1497
|
+
});
|
|
1498
|
+
await params.onMemberRolesChanged(changedMembers);
|
|
1499
|
+
});
|
|
1500
|
+
this.protocol = params.protocol;
|
|
1501
|
+
}
|
|
1474
1502
|
get id() {
|
|
1475
1503
|
return this._id;
|
|
1476
1504
|
}
|
|
@@ -1574,87 +1602,6 @@ var Space = class extends Resource {
|
|
|
1574
1602
|
C: (f, a) => f(...a)
|
|
1575
1603
|
});
|
|
1576
1604
|
}
|
|
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
|
-
}
|
|
1658
1605
|
};
|
|
1659
1606
|
_ts_decorate5([
|
|
1660
1607
|
trace2.info()
|
|
@@ -1690,21 +1637,21 @@ import { Context as Context5 } from "@dxos/context";
|
|
|
1690
1637
|
import { ProtocolError } from "@dxos/protocols";
|
|
1691
1638
|
import { schema as schema4 } from "@dxos/protocols/proto";
|
|
1692
1639
|
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
|
-
}
|
|
1706
1640
|
var __dxlog_file9 = "/__w/dxos/dxos/packages/core/echo/echo-pipeline/src/space/admission-discovery-extension.ts";
|
|
1707
1641
|
var CredentialRetrieverExtension = class extends RpcExtension2 {
|
|
1642
|
+
_request;
|
|
1643
|
+
_onResult;
|
|
1644
|
+
_ctx = new Context5(void 0, {
|
|
1645
|
+
F: __dxlog_file9,
|
|
1646
|
+
L: 26
|
|
1647
|
+
});
|
|
1648
|
+
constructor(_request, _onResult) {
|
|
1649
|
+
super({
|
|
1650
|
+
requested: {
|
|
1651
|
+
AdmissionDiscoveryService: schema4.getService("dxos.mesh.teleport.AdmissionDiscoveryService")
|
|
1652
|
+
}
|
|
1653
|
+
}), this._request = _request, this._onResult = _onResult;
|
|
1654
|
+
}
|
|
1708
1655
|
async getHandlers() {
|
|
1709
1656
|
return {};
|
|
1710
1657
|
}
|
|
@@ -1725,18 +1672,16 @@ var CredentialRetrieverExtension = class extends RpcExtension2 {
|
|
|
1725
1672
|
async onAbort() {
|
|
1726
1673
|
await this._ctx.dispose();
|
|
1727
1674
|
}
|
|
1728
|
-
|
|
1675
|
+
};
|
|
1676
|
+
var CredentialServerExtension = class extends RpcExtension2 {
|
|
1677
|
+
_space;
|
|
1678
|
+
constructor(_space) {
|
|
1729
1679
|
super({
|
|
1730
|
-
|
|
1680
|
+
exposed: {
|
|
1731
1681
|
AdmissionDiscoveryService: schema4.getService("dxos.mesh.teleport.AdmissionDiscoveryService")
|
|
1732
1682
|
}
|
|
1733
|
-
}),
|
|
1734
|
-
F: __dxlog_file9,
|
|
1735
|
-
L: 26
|
|
1736
|
-
});
|
|
1683
|
+
}), this._space = _space;
|
|
1737
1684
|
}
|
|
1738
|
-
};
|
|
1739
|
-
var CredentialServerExtension = class extends RpcExtension2 {
|
|
1740
1685
|
async getHandlers() {
|
|
1741
1686
|
return {
|
|
1742
1687
|
AdmissionDiscoveryService: {
|
|
@@ -1752,13 +1697,6 @@ var CredentialServerExtension = class extends RpcExtension2 {
|
|
|
1752
1697
|
}
|
|
1753
1698
|
};
|
|
1754
1699
|
}
|
|
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
|
-
}
|
|
1762
1700
|
};
|
|
1763
1701
|
|
|
1764
1702
|
// src/space/space-protocol.ts
|
|
@@ -1771,19 +1709,6 @@ import { BlobSync } from "@dxos/teleport-extension-object-sync";
|
|
|
1771
1709
|
import { ReplicatorExtension } from "@dxos/teleport-extension-replicator";
|
|
1772
1710
|
import { trace as trace3 } from "@dxos/tracing";
|
|
1773
1711
|
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
|
-
}
|
|
1787
1712
|
function _ts_decorate6(decorators, target, key, desc) {
|
|
1788
1713
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
1789
1714
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -1794,6 +1719,24 @@ var __dxlog_file10 = "/__w/dxos/dxos/packages/core/echo/echo-pipeline/src/space/
|
|
|
1794
1719
|
var MOCK_AUTH_PROVIDER = async (nonce) => Buffer.from("mock");
|
|
1795
1720
|
var MOCK_AUTH_VERIFIER = async (nonce, credential) => true;
|
|
1796
1721
|
var SpaceProtocol = class {
|
|
1722
|
+
_networkManager;
|
|
1723
|
+
_swarmIdentity;
|
|
1724
|
+
_onSessionAuth;
|
|
1725
|
+
_onAuthFailure;
|
|
1726
|
+
blobSync;
|
|
1727
|
+
_disableP2pReplication;
|
|
1728
|
+
_topic;
|
|
1729
|
+
_spaceKey;
|
|
1730
|
+
_feeds = /* @__PURE__ */ new Set();
|
|
1731
|
+
_sessions = new ComplexMap4(PublicKey5.hash);
|
|
1732
|
+
// TODO(burdon): Move to config (with sensible defaults).
|
|
1733
|
+
_topology = new MMSTTopology({
|
|
1734
|
+
originateConnections: 4,
|
|
1735
|
+
maxPeers: 10,
|
|
1736
|
+
sampleSize: 20
|
|
1737
|
+
});
|
|
1738
|
+
_connection;
|
|
1739
|
+
feedAdded = new CallbackCollection();
|
|
1797
1740
|
get sessions() {
|
|
1798
1741
|
return this._sessions;
|
|
1799
1742
|
}
|
|
@@ -1803,6 +1746,18 @@ var SpaceProtocol = class {
|
|
|
1803
1746
|
get _ownPeerKey() {
|
|
1804
1747
|
return this._swarmIdentity.peerKey;
|
|
1805
1748
|
}
|
|
1749
|
+
constructor({ topic, swarmIdentity, networkManager, onSessionAuth, onAuthFailure, blobStore, disableP2pReplication }) {
|
|
1750
|
+
this._spaceKey = topic;
|
|
1751
|
+
this._networkManager = networkManager;
|
|
1752
|
+
this._swarmIdentity = swarmIdentity;
|
|
1753
|
+
this._onSessionAuth = onSessionAuth;
|
|
1754
|
+
this._onAuthFailure = onAuthFailure;
|
|
1755
|
+
this.blobSync = new BlobSync({
|
|
1756
|
+
blobStore
|
|
1757
|
+
});
|
|
1758
|
+
this._topic = subtleCrypto2.digest("SHA-256", topic.asBuffer()).then(discoveryKey).then(PublicKey5.from);
|
|
1759
|
+
this._disableP2pReplication = disableP2pReplication ?? false;
|
|
1760
|
+
}
|
|
1806
1761
|
// TODO(burdon): Create abstraction for Space (e.g., add keys and have provider).
|
|
1807
1762
|
async addFeed(feed) {
|
|
1808
1763
|
log8("addFeed", {
|
|
@@ -1884,35 +1839,6 @@ var SpaceProtocol = class {
|
|
|
1884
1839
|
return session;
|
|
1885
1840
|
};
|
|
1886
1841
|
}
|
|
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
|
-
}
|
|
1916
1842
|
};
|
|
1917
1843
|
_ts_decorate6([
|
|
1918
1844
|
logInfo2,
|
|
@@ -1927,19 +1853,41 @@ _ts_decorate6([
|
|
|
1927
1853
|
SpaceProtocol = _ts_decorate6([
|
|
1928
1854
|
trace3.resource()
|
|
1929
1855
|
], SpaceProtocol);
|
|
1930
|
-
var AuthStatus = /* @__PURE__ */ function(AuthStatus2) {
|
|
1856
|
+
var AuthStatus = /* @__PURE__ */ (function(AuthStatus2) {
|
|
1931
1857
|
AuthStatus2["INITIAL"] = "INITIAL";
|
|
1932
1858
|
AuthStatus2["SUCCESS"] = "SUCCESS";
|
|
1933
1859
|
AuthStatus2["FAILURE"] = "FAILURE";
|
|
1934
1860
|
return AuthStatus2;
|
|
1935
|
-
}({});
|
|
1861
|
+
})({});
|
|
1936
1862
|
var SpaceProtocolSession = class {
|
|
1863
|
+
_wireParams;
|
|
1864
|
+
_disableP2pReplication;
|
|
1865
|
+
_onSessionAuth;
|
|
1866
|
+
_onAuthFailure;
|
|
1867
|
+
_swarmIdentity;
|
|
1868
|
+
_blobSync;
|
|
1869
|
+
_teleport;
|
|
1870
|
+
// TODO(dmaretskyi): Start with upload=false when switching it on the fly works.
|
|
1871
|
+
replicator = new ReplicatorExtension().setOptions({
|
|
1872
|
+
upload: true
|
|
1873
|
+
});
|
|
1874
|
+
_authStatus = "INITIAL";
|
|
1937
1875
|
get authStatus() {
|
|
1938
1876
|
return this._authStatus;
|
|
1939
1877
|
}
|
|
1940
1878
|
get stats() {
|
|
1941
1879
|
return this._teleport.stats;
|
|
1942
1880
|
}
|
|
1881
|
+
// TODO(dmaretskyi): Allow to pass in extra extensions.
|
|
1882
|
+
constructor({ wireParams, swarmIdentity, onSessionAuth, onAuthFailure, blobSync, disableP2pReplication }) {
|
|
1883
|
+
this._wireParams = wireParams;
|
|
1884
|
+
this._swarmIdentity = swarmIdentity;
|
|
1885
|
+
this._onSessionAuth = onSessionAuth;
|
|
1886
|
+
this._onAuthFailure = onAuthFailure;
|
|
1887
|
+
this._blobSync = blobSync;
|
|
1888
|
+
this._teleport = new Teleport(wireParams);
|
|
1889
|
+
this._disableP2pReplication = disableP2pReplication ?? false;
|
|
1890
|
+
}
|
|
1943
1891
|
get stream() {
|
|
1944
1892
|
return this._teleport.stream;
|
|
1945
1893
|
}
|
|
@@ -1980,27 +1928,6 @@ var SpaceProtocolSession = class {
|
|
|
1980
1928
|
async abort() {
|
|
1981
1929
|
await this._teleport.abort();
|
|
1982
1930
|
}
|
|
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
|
-
}
|
|
2004
1931
|
};
|
|
2005
1932
|
_ts_decorate6([
|
|
2006
1933
|
logInfo2
|
|
@@ -2018,19 +1945,6 @@ import { PublicKey as PublicKey6 } from "@dxos/keys";
|
|
|
2018
1945
|
import { log as log9 } from "@dxos/log";
|
|
2019
1946
|
import { trace as trace4 } from "@dxos/protocols";
|
|
2020
1947
|
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
|
-
}
|
|
2034
1948
|
function _ts_decorate7(decorators, target, key, desc) {
|
|
2035
1949
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
2036
1950
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -2039,6 +1953,20 @@ function _ts_decorate7(decorators, target, key, desc) {
|
|
|
2039
1953
|
}
|
|
2040
1954
|
var __dxlog_file11 = "/__w/dxos/dxos/packages/core/echo/echo-pipeline/src/space/space-manager.ts";
|
|
2041
1955
|
var SpaceManager = class {
|
|
1956
|
+
_spaces = new ComplexMap5(PublicKey6.hash);
|
|
1957
|
+
_feedStore;
|
|
1958
|
+
_networkManager;
|
|
1959
|
+
_metadataStore;
|
|
1960
|
+
_blobStore;
|
|
1961
|
+
_instanceId = PublicKey6.random().toHex();
|
|
1962
|
+
_disableP2pReplication;
|
|
1963
|
+
constructor({ feedStore, networkManager, metadataStore, blobStore, disableP2pReplication }) {
|
|
1964
|
+
this._feedStore = feedStore;
|
|
1965
|
+
this._networkManager = networkManager;
|
|
1966
|
+
this._metadataStore = metadataStore;
|
|
1967
|
+
this._blobStore = blobStore;
|
|
1968
|
+
this._disableP2pReplication = disableP2pReplication ?? false;
|
|
1969
|
+
}
|
|
2042
1970
|
// TODO(burdon): Remove.
|
|
2043
1971
|
get spaces() {
|
|
2044
1972
|
return this._spaces;
|
|
@@ -2179,20 +2107,6 @@ var SpaceManager = class {
|
|
|
2179
2107
|
});
|
|
2180
2108
|
});
|
|
2181
2109
|
}
|
|
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
|
-
}
|
|
2196
2110
|
};
|
|
2197
2111
|
_ts_decorate7([
|
|
2198
2112
|
synchronized4
|
|
@@ -2227,4 +2141,4 @@ export {
|
|
|
2227
2141
|
SpaceProtocolSession,
|
|
2228
2142
|
SpaceManager
|
|
2229
2143
|
};
|
|
2230
|
-
//# sourceMappingURL=chunk-
|
|
2144
|
+
//# sourceMappingURL=chunk-FR6GJ4S4.mjs.map
|