@dxos/echo-pipeline 0.3.2-main.ce2190e → 0.3.2-main.d77d2bc
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-RLO353OB.mjs → chunk-65J7PLAQ.mjs} +68 -81
- package/dist/lib/browser/chunk-65J7PLAQ.mjs.map +7 -0
- package/dist/lib/browser/index.mjs +1 -1
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/testing/index.mjs +243 -1
- package/dist/lib/browser/testing/index.mjs.map +4 -4
- package/dist/lib/node/index.cjs +104 -117
- package/dist/lib/node/index.cjs.map +3 -3
- package/dist/lib/node/meta.json +1 -1
- package/dist/lib/node/testing/index.cjs +350 -119
- package/dist/lib/node/testing/index.cjs.map +4 -4
- package/dist/types/src/db-host/snapshot-manager.d.ts.map +1 -1
- package/dist/types/src/pipeline/pipeline.d.ts.map +1 -1
- package/dist/types/src/space/control-pipeline.d.ts.map +1 -1
- package/dist/types/src/testing/index.d.ts +1 -0
- package/dist/types/src/testing/index.d.ts.map +1 -1
- package/package.json +32 -32
- package/src/db-host/snapshot-manager.ts +0 -2
- package/src/pipeline/pipeline.ts +2 -2
- package/src/space/control-pipeline.ts +5 -4
- package/src/testing/index.ts +1 -0
- package/dist/lib/browser/chunk-RLO353OB.mjs.map +0 -7
|
@@ -30,6 +30,8 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
30
30
|
// packages/core/echo/echo-pipeline/src/testing/index.ts
|
|
31
31
|
var testing_exports = {};
|
|
32
32
|
__export(testing_exports, {
|
|
33
|
+
DatabaseTestBuilder: () => DatabaseTestBuilder,
|
|
34
|
+
DatabaseTestPeer: () => DatabaseTestPeer,
|
|
33
35
|
MemoryNetworkManagerProvider: () => MemoryNetworkManagerProvider,
|
|
34
36
|
TestAgent: () => TestAgent,
|
|
35
37
|
TestAgentBuilder: () => TestAgentBuilder,
|
|
@@ -285,23 +287,12 @@ var DatabaseHost = class {
|
|
|
285
287
|
};
|
|
286
288
|
|
|
287
289
|
// packages/core/echo/echo-pipeline/src/db-host/snapshot-manager.ts
|
|
288
|
-
var import_async = require("@dxos/async");
|
|
289
290
|
var import_context2 = require("@dxos/context");
|
|
290
291
|
var import_keys = require("@dxos/keys");
|
|
291
292
|
var import_protocols2 = require("@dxos/protocols");
|
|
292
293
|
var import_blob = require("@dxos/protocols/proto/dxos/echo/blob");
|
|
293
|
-
function _ts_decorate(decorators, target, key, desc) {
|
|
294
|
-
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
295
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
|
|
296
|
-
r = Reflect.decorate(decorators, target, key, desc);
|
|
297
|
-
else
|
|
298
|
-
for (var i = decorators.length - 1; i >= 0; i--)
|
|
299
|
-
if (d = decorators[i])
|
|
300
|
-
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
301
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
302
|
-
}
|
|
303
294
|
var SpaceSnapshot = import_protocols2.schema.getCodecForType("dxos.echo.snapshot.SpaceSnapshot");
|
|
304
|
-
var SnapshotManager = class
|
|
295
|
+
var SnapshotManager = class {
|
|
305
296
|
constructor(_snapshotStore, _blobStore, _blobSync) {
|
|
306
297
|
this._snapshotStore = _snapshotStore;
|
|
307
298
|
this._blobStore = _blobStore;
|
|
@@ -330,9 +321,6 @@ var SnapshotManager = class SnapshotManager2 {
|
|
|
330
321
|
return import_keys.PublicKey.from(id).toHex();
|
|
331
322
|
}
|
|
332
323
|
};
|
|
333
|
-
SnapshotManager = _ts_decorate([
|
|
334
|
-
(0, import_async.trackLeaks)("open", "close")
|
|
335
|
-
], SnapshotManager);
|
|
336
324
|
|
|
337
325
|
// packages/core/echo/echo-pipeline/src/db-host/snapshot-store.ts
|
|
338
326
|
var import_crypto = require("@dxos/crypto");
|
|
@@ -487,14 +475,14 @@ var DataServiceImpl = class {
|
|
|
487
475
|
|
|
488
476
|
// packages/core/echo/echo-pipeline/src/metadata/metadata-store.ts
|
|
489
477
|
var import_crc_32 = __toESM(require("crc-32"));
|
|
490
|
-
var
|
|
478
|
+
var import_async = require("@dxos/async");
|
|
491
479
|
var import_invariant4 = require("@dxos/invariant");
|
|
492
480
|
var import_keys3 = require("@dxos/keys");
|
|
493
481
|
var import_log3 = require("@dxos/log");
|
|
494
482
|
var import_protocols4 = require("@dxos/protocols");
|
|
495
483
|
var import_services = require("@dxos/protocols/proto/dxos/client/services");
|
|
496
484
|
var import_util3 = require("@dxos/util");
|
|
497
|
-
function
|
|
485
|
+
function _ts_decorate(decorators, target, key, desc) {
|
|
498
486
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
499
487
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
|
|
500
488
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -520,7 +508,7 @@ var MetadataStore = class {
|
|
|
520
508
|
this._metadata = emptyEchoMetadata();
|
|
521
509
|
this._spaceLargeMetadata = new import_util3.ComplexMap(import_keys3.PublicKey.hash);
|
|
522
510
|
this._metadataFile = void 0;
|
|
523
|
-
this.update = new
|
|
511
|
+
this.update = new import_async.Event();
|
|
524
512
|
}
|
|
525
513
|
get metadata() {
|
|
526
514
|
return this._metadata;
|
|
@@ -778,19 +766,19 @@ var MetadataStore = class {
|
|
|
778
766
|
await this.flush();
|
|
779
767
|
}
|
|
780
768
|
};
|
|
781
|
-
|
|
782
|
-
|
|
769
|
+
_ts_decorate([
|
|
770
|
+
import_async.synchronized
|
|
783
771
|
], MetadataStore.prototype, "load", null);
|
|
784
|
-
|
|
785
|
-
|
|
772
|
+
_ts_decorate([
|
|
773
|
+
import_async.synchronized
|
|
786
774
|
], MetadataStore.prototype, "_save", null);
|
|
787
|
-
|
|
788
|
-
|
|
775
|
+
_ts_decorate([
|
|
776
|
+
import_async.synchronized
|
|
789
777
|
], MetadataStore.prototype, "_saveSpaceLargeMetadata", null);
|
|
790
778
|
var fromBytesInt32 = (buf) => buf.readInt32LE(0);
|
|
791
779
|
|
|
792
780
|
// packages/core/echo/echo-pipeline/src/space/auth.ts
|
|
793
|
-
var
|
|
781
|
+
var import_async2 = require("@dxos/async");
|
|
794
782
|
var import_context3 = require("@dxos/context");
|
|
795
783
|
var import_crypto2 = require("@dxos/crypto");
|
|
796
784
|
var import_invariant5 = require("@dxos/invariant");
|
|
@@ -848,7 +836,7 @@ var AuthExtension = class extends import_teleport.RpcExtension {
|
|
|
848
836
|
}
|
|
849
837
|
async onOpen(context) {
|
|
850
838
|
await super.onOpen(context);
|
|
851
|
-
(0,
|
|
839
|
+
(0, import_async2.scheduleTask)(this._ctx, async () => {
|
|
852
840
|
try {
|
|
853
841
|
const challenge = (0, import_crypto2.randomBytes)(32);
|
|
854
842
|
const { credential } = await this.rpc.AuthService.authenticate({
|
|
@@ -873,7 +861,7 @@ var AuthExtension = class extends import_teleport.RpcExtension {
|
|
|
873
861
|
"'credential not verified'"
|
|
874
862
|
]
|
|
875
863
|
});
|
|
876
|
-
(0,
|
|
864
|
+
(0, import_async2.runInContext)(this._ctx, () => this._authParams.onAuthSuccess());
|
|
877
865
|
} catch (err) {
|
|
878
866
|
(0, import_log4.log)("auth failed", err, {
|
|
879
867
|
F: __dxlog_file5,
|
|
@@ -897,7 +885,7 @@ var AuthExtension = class extends import_teleport.RpcExtension {
|
|
|
897
885
|
};
|
|
898
886
|
|
|
899
887
|
// packages/core/echo/echo-pipeline/src/space/space.ts
|
|
900
|
-
var
|
|
888
|
+
var import_async7 = require("@dxos/async");
|
|
901
889
|
var import_invariant9 = require("@dxos/invariant");
|
|
902
890
|
var import_log10 = require("@dxos/log");
|
|
903
891
|
var import_credentials4 = require("@dxos/protocols/proto/dxos/halo/credentials");
|
|
@@ -905,7 +893,7 @@ var import_tracing3 = require("@dxos/tracing");
|
|
|
905
893
|
var import_util7 = require("@dxos/util");
|
|
906
894
|
|
|
907
895
|
// packages/core/echo/echo-pipeline/src/space/control-pipeline.ts
|
|
908
|
-
var
|
|
896
|
+
var import_async5 = require("@dxos/async");
|
|
909
897
|
var import_context5 = require("@dxos/context");
|
|
910
898
|
var import_credentials = require("@dxos/credentials");
|
|
911
899
|
var import_keys5 = require("@dxos/keys");
|
|
@@ -916,7 +904,7 @@ var import_tracing = require("@dxos/tracing");
|
|
|
916
904
|
var import_util5 = require("@dxos/util");
|
|
917
905
|
|
|
918
906
|
// packages/core/echo/echo-pipeline/src/pipeline/pipeline.ts
|
|
919
|
-
var
|
|
907
|
+
var import_async4 = require("@dxos/async");
|
|
920
908
|
var import_context4 = require("@dxos/context");
|
|
921
909
|
var import_debug3 = require("@dxos/debug");
|
|
922
910
|
var import_feed_store = require("@dxos/feed-store");
|
|
@@ -957,11 +945,11 @@ var createMessageSelector = (timeframeClock) => {
|
|
|
957
945
|
};
|
|
958
946
|
|
|
959
947
|
// packages/core/echo/echo-pipeline/src/pipeline/timeframe-clock.ts
|
|
960
|
-
var
|
|
948
|
+
var import_async3 = require("@dxos/async");
|
|
961
949
|
var import_debug2 = require("@dxos/debug");
|
|
962
950
|
var import_log6 = require("@dxos/log");
|
|
963
951
|
var import_timeframe = require("@dxos/timeframe");
|
|
964
|
-
function
|
|
952
|
+
function _ts_decorate2(decorators, target, key, desc) {
|
|
965
953
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
966
954
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
|
|
967
955
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -983,7 +971,7 @@ var startAfter = (timeframe) => timeframe.frames().map(([feedKey, index]) => ({
|
|
|
983
971
|
var TimeframeClock = class {
|
|
984
972
|
constructor(_timeframe = new import_timeframe.Timeframe()) {
|
|
985
973
|
this._timeframe = _timeframe;
|
|
986
|
-
this.update = new
|
|
974
|
+
this.update = new import_async3.Event();
|
|
987
975
|
this._pendingTimeframe = _timeframe;
|
|
988
976
|
}
|
|
989
977
|
/**
|
|
@@ -1045,12 +1033,12 @@ var TimeframeClock = class {
|
|
|
1045
1033
|
});
|
|
1046
1034
|
}
|
|
1047
1035
|
};
|
|
1048
|
-
|
|
1036
|
+
_ts_decorate2([
|
|
1049
1037
|
(0, import_debug2.timed)(5e3)
|
|
1050
1038
|
], TimeframeClock.prototype, "waitUntilReached", null);
|
|
1051
1039
|
|
|
1052
1040
|
// packages/core/echo/echo-pipeline/src/pipeline/pipeline.ts
|
|
1053
|
-
function
|
|
1041
|
+
function _ts_decorate3(decorators, target, key, desc) {
|
|
1054
1042
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
1055
1043
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
|
|
1056
1044
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -1067,7 +1055,7 @@ var PipelineState = class {
|
|
|
1067
1055
|
this._timeframeClock = _timeframeClock;
|
|
1068
1056
|
this._ctx = new import_context4.Context();
|
|
1069
1057
|
this.timeframeUpdate = this._timeframeClock.update;
|
|
1070
|
-
this.stalled = new
|
|
1058
|
+
this.stalled = new import_async4.Event();
|
|
1071
1059
|
this._startTimeframe = new import_timeframe2.Timeframe();
|
|
1072
1060
|
this._reachedTarget = false;
|
|
1073
1061
|
}
|
|
@@ -1141,7 +1129,7 @@ var PipelineState = class {
|
|
|
1141
1129
|
done = true;
|
|
1142
1130
|
this._reachedTarget = true;
|
|
1143
1131
|
}),
|
|
1144
|
-
(0,
|
|
1132
|
+
(0, import_async4.sleepWithContext)(this._ctx, timeout).then(() => {
|
|
1145
1133
|
if (done) {
|
|
1146
1134
|
return;
|
|
1147
1135
|
}
|
|
@@ -1170,8 +1158,8 @@ var Pipeline = class {
|
|
|
1170
1158
|
// External state accessor.
|
|
1171
1159
|
this._state = new PipelineState(this._feeds, this._timeframeClock);
|
|
1172
1160
|
// Waits for the message consumer to process the message and yield control back to the pipeline.
|
|
1173
|
-
this._processingTrigger = new
|
|
1174
|
-
this._pauseTrigger = new
|
|
1161
|
+
this._processingTrigger = new import_async4.Trigger().wake();
|
|
1162
|
+
this._pauseTrigger = new import_async4.Trigger().wake();
|
|
1175
1163
|
// Pending downloads.
|
|
1176
1164
|
this._downloads = new import_util4.ComplexMap((value) => import_keys4.PublicKey.hash(value.key));
|
|
1177
1165
|
this._isStopping = false;
|
|
@@ -1448,24 +1436,24 @@ var Pipeline = class {
|
|
|
1448
1436
|
}
|
|
1449
1437
|
}
|
|
1450
1438
|
};
|
|
1451
|
-
|
|
1452
|
-
|
|
1439
|
+
_ts_decorate3([
|
|
1440
|
+
import_async4.synchronized
|
|
1453
1441
|
], Pipeline.prototype, "start", null);
|
|
1454
|
-
|
|
1455
|
-
|
|
1442
|
+
_ts_decorate3([
|
|
1443
|
+
import_async4.synchronized
|
|
1456
1444
|
], Pipeline.prototype, "stop", null);
|
|
1457
|
-
|
|
1458
|
-
|
|
1445
|
+
_ts_decorate3([
|
|
1446
|
+
import_async4.synchronized
|
|
1459
1447
|
], Pipeline.prototype, "setCursor", null);
|
|
1460
|
-
|
|
1461
|
-
|
|
1448
|
+
_ts_decorate3([
|
|
1449
|
+
import_async4.synchronized
|
|
1462
1450
|
], Pipeline.prototype, "pause", null);
|
|
1463
|
-
|
|
1464
|
-
|
|
1451
|
+
_ts_decorate3([
|
|
1452
|
+
import_async4.synchronized
|
|
1465
1453
|
], Pipeline.prototype, "unpause", null);
|
|
1466
1454
|
|
|
1467
1455
|
// packages/core/echo/echo-pipeline/src/space/control-pipeline.ts
|
|
1468
|
-
function
|
|
1456
|
+
function _ts_decorate4(decorators, target, key, desc) {
|
|
1469
1457
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
1470
1458
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
|
|
1471
1459
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -1486,8 +1474,8 @@ var ControlPipeline = class ControlPipeline2 {
|
|
|
1486
1474
|
this.onFeedAdmitted = new import_util5.Callback();
|
|
1487
1475
|
this._usage = new import_tracing.TimeUsageCounter();
|
|
1488
1476
|
this._mutations = new import_tracing.TimeSeriesCounter();
|
|
1489
|
-
this._snapshotTask = new
|
|
1490
|
-
await (0,
|
|
1477
|
+
this._snapshotTask = new import_async5.DeferredTask(this._ctx, async () => {
|
|
1478
|
+
await (0, import_async5.sleepWithContext)(this._ctx, CONTROL_PIPELINE_SNAPSHOT_DELAY);
|
|
1491
1479
|
await this._saveSnapshot();
|
|
1492
1480
|
});
|
|
1493
1481
|
this._spaceKey = spaceKey;
|
|
@@ -1500,7 +1488,7 @@ var ControlPipeline = class ControlPipeline2 {
|
|
|
1500
1488
|
key: info.key
|
|
1501
1489
|
}, {
|
|
1502
1490
|
F: __dxlog_file9,
|
|
1503
|
-
L:
|
|
1491
|
+
L: 74,
|
|
1504
1492
|
S: this,
|
|
1505
1493
|
C: (f, a) => f(...a)
|
|
1506
1494
|
});
|
|
@@ -1512,7 +1500,7 @@ var ControlPipeline = class ControlPipeline2 {
|
|
|
1512
1500
|
} catch (err) {
|
|
1513
1501
|
import_log8.log.catch(err, void 0, {
|
|
1514
1502
|
F: __dxlog_file9,
|
|
1515
|
-
L:
|
|
1503
|
+
L: 83,
|
|
1516
1504
|
S: this,
|
|
1517
1505
|
C: (f, a) => f(...a)
|
|
1518
1506
|
});
|
|
@@ -1541,16 +1529,16 @@ var ControlPipeline = class ControlPipeline2 {
|
|
|
1541
1529
|
tf: snapshot?.timeframe
|
|
1542
1530
|
}, {
|
|
1543
1531
|
F: __dxlog_file9,
|
|
1544
|
-
L:
|
|
1532
|
+
L: 110,
|
|
1545
1533
|
S: this,
|
|
1546
1534
|
C: (f, a) => f(...a)
|
|
1547
1535
|
});
|
|
1548
1536
|
if (USE_SNAPSHOTS && snapshot) {
|
|
1549
1537
|
await this._processSnapshot(snapshot);
|
|
1550
1538
|
}
|
|
1551
|
-
|
|
1539
|
+
import_log8.log.info("starting...", void 0, {
|
|
1552
1540
|
F: __dxlog_file9,
|
|
1553
|
-
L:
|
|
1541
|
+
L: 115,
|
|
1554
1542
|
S: this,
|
|
1555
1543
|
C: (f, a) => f(...a)
|
|
1556
1544
|
});
|
|
@@ -1560,7 +1548,7 @@ var ControlPipeline = class ControlPipeline2 {
|
|
|
1560
1548
|
await this._pipeline.start();
|
|
1561
1549
|
(0, import_log8.log)("started", void 0, {
|
|
1562
1550
|
F: __dxlog_file9,
|
|
1563
|
-
L:
|
|
1551
|
+
L: 121,
|
|
1564
1552
|
S: this,
|
|
1565
1553
|
C: (f, a) => f(...a)
|
|
1566
1554
|
});
|
|
@@ -1577,7 +1565,7 @@ var ControlPipeline = class ControlPipeline2 {
|
|
|
1577
1565
|
message
|
|
1578
1566
|
}, {
|
|
1579
1567
|
F: __dxlog_file9,
|
|
1580
|
-
L:
|
|
1568
|
+
L: 134,
|
|
1581
1569
|
S: this,
|
|
1582
1570
|
C: (f, a) => f(...a)
|
|
1583
1571
|
});
|
|
@@ -1599,7 +1587,7 @@ var ControlPipeline = class ControlPipeline2 {
|
|
|
1599
1587
|
snapshot
|
|
1600
1588
|
}, {
|
|
1601
1589
|
F: __dxlog_file9,
|
|
1602
|
-
L:
|
|
1590
|
+
L: 150,
|
|
1603
1591
|
S: this,
|
|
1604
1592
|
C: (f, a) => f(...a)
|
|
1605
1593
|
});
|
|
@@ -1614,7 +1602,7 @@ var ControlPipeline = class ControlPipeline2 {
|
|
|
1614
1602
|
} catch (err) {
|
|
1615
1603
|
import_log8.log.catch(err, void 0, {
|
|
1616
1604
|
F: __dxlog_file9,
|
|
1617
|
-
L:
|
|
1605
|
+
L: 163,
|
|
1618
1606
|
S: this,
|
|
1619
1607
|
C: (f, a) => f(...a)
|
|
1620
1608
|
});
|
|
@@ -1628,7 +1616,7 @@ var ControlPipeline = class ControlPipeline2 {
|
|
|
1628
1616
|
seq: msg.seq
|
|
1629
1617
|
}, {
|
|
1630
1618
|
F: __dxlog_file9,
|
|
1631
|
-
L:
|
|
1619
|
+
L: 173,
|
|
1632
1620
|
S: this,
|
|
1633
1621
|
C: (f, a) => f(...a)
|
|
1634
1622
|
});
|
|
@@ -1643,7 +1631,7 @@ var ControlPipeline = class ControlPipeline2 {
|
|
|
1643
1631
|
msg
|
|
1644
1632
|
}, {
|
|
1645
1633
|
F: __dxlog_file9,
|
|
1646
|
-
L:
|
|
1634
|
+
L: 182,
|
|
1647
1635
|
S: this,
|
|
1648
1636
|
C: (f, a) => f(...a)
|
|
1649
1637
|
});
|
|
@@ -1660,9 +1648,9 @@ var ControlPipeline = class ControlPipeline2 {
|
|
|
1660
1648
|
}
|
|
1661
1649
|
}
|
|
1662
1650
|
async stop() {
|
|
1663
|
-
|
|
1651
|
+
import_log8.log.warn("stopping...", void 0, {
|
|
1664
1652
|
F: __dxlog_file9,
|
|
1665
|
-
L:
|
|
1653
|
+
L: 202,
|
|
1666
1654
|
S: this,
|
|
1667
1655
|
C: (f, a) => f(...a)
|
|
1668
1656
|
});
|
|
@@ -1671,7 +1659,7 @@ var ControlPipeline = class ControlPipeline2 {
|
|
|
1671
1659
|
await this._saveTargetTimeframe(this._pipeline.state.timeframe);
|
|
1672
1660
|
(0, import_log8.log)("stopped", void 0, {
|
|
1673
1661
|
F: __dxlog_file9,
|
|
1674
|
-
L:
|
|
1662
|
+
L: 206,
|
|
1675
1663
|
S: this,
|
|
1676
1664
|
C: (f, a) => f(...a)
|
|
1677
1665
|
});
|
|
@@ -1684,36 +1672,37 @@ var ControlPipeline = class ControlPipeline2 {
|
|
|
1684
1672
|
} catch (err) {
|
|
1685
1673
|
(0, import_log8.log)(err, void 0, {
|
|
1686
1674
|
F: __dxlog_file9,
|
|
1687
|
-
L:
|
|
1675
|
+
L: 215,
|
|
1688
1676
|
S: this,
|
|
1689
1677
|
C: (f, a) => f(...a)
|
|
1690
1678
|
});
|
|
1691
1679
|
}
|
|
1692
1680
|
}
|
|
1693
1681
|
};
|
|
1694
|
-
|
|
1682
|
+
_ts_decorate4([
|
|
1695
1683
|
import_tracing.trace.metricsCounter()
|
|
1696
1684
|
], ControlPipeline.prototype, "_usage", void 0);
|
|
1697
|
-
|
|
1685
|
+
_ts_decorate4([
|
|
1698
1686
|
import_tracing.trace.metricsCounter()
|
|
1699
1687
|
], ControlPipeline.prototype, "_mutations", void 0);
|
|
1700
|
-
|
|
1688
|
+
_ts_decorate4([
|
|
1701
1689
|
import_tracing.trace.span({
|
|
1702
1690
|
showInBrowserTimeline: true
|
|
1703
1691
|
})
|
|
1704
1692
|
], ControlPipeline.prototype, "start", null);
|
|
1705
|
-
|
|
1693
|
+
_ts_decorate4([
|
|
1706
1694
|
import_tracing.trace.span()
|
|
1707
1695
|
], ControlPipeline.prototype, "_consumePipeline", null);
|
|
1708
|
-
|
|
1696
|
+
_ts_decorate4([
|
|
1709
1697
|
import_tracing.trace.span()
|
|
1710
1698
|
], ControlPipeline.prototype, "_processMessage", null);
|
|
1711
|
-
ControlPipeline =
|
|
1712
|
-
import_tracing.trace.resource()
|
|
1699
|
+
ControlPipeline = _ts_decorate4([
|
|
1700
|
+
import_tracing.trace.resource(),
|
|
1701
|
+
(0, import_async5.trackLeaks)("start", "stop")
|
|
1713
1702
|
], ControlPipeline);
|
|
1714
1703
|
|
|
1715
1704
|
// packages/core/echo/echo-pipeline/src/space/data-pipeline.ts
|
|
1716
|
-
var
|
|
1705
|
+
var import_async6 = require("@dxos/async");
|
|
1717
1706
|
var import_context6 = require("@dxos/context");
|
|
1718
1707
|
var import_credentials3 = require("@dxos/credentials");
|
|
1719
1708
|
var import_echo_db3 = require("@dxos/echo-db");
|
|
@@ -1723,7 +1712,7 @@ var import_protocols6 = require("@dxos/protocols");
|
|
|
1723
1712
|
var import_timeframe4 = require("@dxos/timeframe");
|
|
1724
1713
|
var import_tracing2 = require("@dxos/tracing");
|
|
1725
1714
|
var import_util6 = require("@dxos/util");
|
|
1726
|
-
function
|
|
1715
|
+
function _ts_decorate5(decorators, target, key, desc) {
|
|
1727
1716
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
1728
1717
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
|
|
1729
1718
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -1752,7 +1741,7 @@ var DataPipeline = class DataPipeline2 {
|
|
|
1752
1741
|
this._mutations = new import_tracing2.TimeSeriesCounter();
|
|
1753
1742
|
this.currentEpoch = void 0;
|
|
1754
1743
|
this.appliedEpoch = void 0;
|
|
1755
|
-
this.onNewEpoch = new
|
|
1744
|
+
this.onNewEpoch = new import_async6.Event();
|
|
1756
1745
|
}
|
|
1757
1746
|
get isOpen() {
|
|
1758
1747
|
return this._isOpen;
|
|
@@ -1815,7 +1804,7 @@ var DataPipeline = class DataPipeline2 {
|
|
|
1815
1804
|
this.databaseHost = new DatabaseHost(feedWriter, () => this._flush());
|
|
1816
1805
|
this.itemManager = new import_echo_db3.ItemManager(this._params.modelFactory);
|
|
1817
1806
|
await this.databaseHost.open(this.itemManager, this._params.modelFactory);
|
|
1818
|
-
(0,
|
|
1807
|
+
(0, import_async6.scheduleTask)(this._ctx, async () => {
|
|
1819
1808
|
await this._consumePipeline();
|
|
1820
1809
|
});
|
|
1821
1810
|
this._isOpen = true;
|
|
@@ -1934,7 +1923,7 @@ var DataPipeline = class DataPipeline2 {
|
|
|
1934
1923
|
span.end();
|
|
1935
1924
|
if (++messageCounter > 1e3) {
|
|
1936
1925
|
messageCounter = 0;
|
|
1937
|
-
await (0,
|
|
1926
|
+
await (0, import_async6.sleep)(1);
|
|
1938
1927
|
}
|
|
1939
1928
|
}
|
|
1940
1929
|
}
|
|
@@ -2014,7 +2003,7 @@ var DataPipeline = class DataPipeline2 {
|
|
|
2014
2003
|
}
|
|
2015
2004
|
});
|
|
2016
2005
|
this._epochCtx = ctx;
|
|
2017
|
-
(0,
|
|
2006
|
+
(0, import_async6.scheduleTask)(ctx, async () => {
|
|
2018
2007
|
if (!this._isOpen) {
|
|
2019
2008
|
return;
|
|
2020
2009
|
}
|
|
@@ -2128,31 +2117,31 @@ var DataPipeline = class DataPipeline2 {
|
|
|
2128
2117
|
await this._params.metadataStore.flush();
|
|
2129
2118
|
}
|
|
2130
2119
|
};
|
|
2131
|
-
|
|
2120
|
+
_ts_decorate5([
|
|
2132
2121
|
import_tracing2.trace.metricsCounter()
|
|
2133
2122
|
], DataPipeline.prototype, "_usage", void 0);
|
|
2134
|
-
|
|
2123
|
+
_ts_decorate5([
|
|
2135
2124
|
import_tracing2.trace.metricsCounter()
|
|
2136
2125
|
], DataPipeline.prototype, "_mutations", void 0);
|
|
2137
|
-
|
|
2138
|
-
|
|
2126
|
+
_ts_decorate5([
|
|
2127
|
+
import_async6.synchronized
|
|
2139
2128
|
], DataPipeline.prototype, "open", null);
|
|
2140
|
-
|
|
2141
|
-
|
|
2129
|
+
_ts_decorate5([
|
|
2130
|
+
import_async6.synchronized
|
|
2142
2131
|
], DataPipeline.prototype, "close", null);
|
|
2143
|
-
|
|
2144
|
-
|
|
2132
|
+
_ts_decorate5([
|
|
2133
|
+
import_async6.synchronized
|
|
2145
2134
|
], DataPipeline.prototype, "_processEpoch", null);
|
|
2146
|
-
|
|
2147
|
-
|
|
2135
|
+
_ts_decorate5([
|
|
2136
|
+
import_async6.synchronized
|
|
2148
2137
|
], DataPipeline.prototype, "createEpoch", null);
|
|
2149
|
-
DataPipeline =
|
|
2150
|
-
(0,
|
|
2138
|
+
DataPipeline = _ts_decorate5([
|
|
2139
|
+
(0, import_async6.trackLeaks)("open", "close"),
|
|
2151
2140
|
import_tracing2.trace.resource()
|
|
2152
2141
|
], DataPipeline);
|
|
2153
2142
|
|
|
2154
2143
|
// packages/core/echo/echo-pipeline/src/space/space.ts
|
|
2155
|
-
function
|
|
2144
|
+
function _ts_decorate6(decorators, target, key, desc) {
|
|
2156
2145
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
2157
2146
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
|
|
2158
2147
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -2165,9 +2154,9 @@ function _ts_decorate7(decorators, target, key, desc) {
|
|
|
2165
2154
|
var __dxlog_file11 = "/home/runner/work/dxos/dxos/packages/core/echo/echo-pipeline/src/space/space.ts";
|
|
2166
2155
|
var Space = class Space2 {
|
|
2167
2156
|
constructor(params) {
|
|
2168
|
-
this._addFeedLock = new
|
|
2157
|
+
this._addFeedLock = new import_async7.Lock();
|
|
2169
2158
|
this.onCredentialProcessed = new import_util7.Callback();
|
|
2170
|
-
this.stateUpdate = new
|
|
2159
|
+
this.stateUpdate = new import_async7.Event();
|
|
2171
2160
|
this._isOpen = false;
|
|
2172
2161
|
(0, import_invariant9.invariant)(params.spaceKey && params.feedProvider, void 0, {
|
|
2173
2162
|
F: __dxlog_file11,
|
|
@@ -2381,27 +2370,27 @@ var Space = class Space2 {
|
|
|
2381
2370
|
await this._dataPipeline.open();
|
|
2382
2371
|
}
|
|
2383
2372
|
};
|
|
2384
|
-
|
|
2373
|
+
_ts_decorate6([
|
|
2385
2374
|
import_log10.logInfo,
|
|
2386
2375
|
import_tracing3.trace.info()
|
|
2387
2376
|
], Space.prototype, "key", null);
|
|
2388
|
-
|
|
2389
|
-
|
|
2377
|
+
_ts_decorate6([
|
|
2378
|
+
import_async7.synchronized,
|
|
2390
2379
|
import_tracing3.trace.span()
|
|
2391
2380
|
], Space.prototype, "open", null);
|
|
2392
|
-
|
|
2393
|
-
|
|
2381
|
+
_ts_decorate6([
|
|
2382
|
+
import_async7.synchronized
|
|
2394
2383
|
], Space.prototype, "close", null);
|
|
2395
|
-
|
|
2396
|
-
|
|
2384
|
+
_ts_decorate6([
|
|
2385
|
+
import_async7.synchronized
|
|
2397
2386
|
], Space.prototype, "initializeDataPipeline", null);
|
|
2398
|
-
Space =
|
|
2399
|
-
(0,
|
|
2387
|
+
Space = _ts_decorate6([
|
|
2388
|
+
(0, import_async7.trackLeaks)("open", "close"),
|
|
2400
2389
|
import_tracing3.trace.resource()
|
|
2401
2390
|
], Space);
|
|
2402
2391
|
|
|
2403
2392
|
// packages/core/echo/echo-pipeline/src/space/space-manager.ts
|
|
2404
|
-
var
|
|
2393
|
+
var import_async8 = require("@dxos/async");
|
|
2405
2394
|
var import_debug4 = require("@dxos/debug");
|
|
2406
2395
|
var import_keys7 = require("@dxos/keys");
|
|
2407
2396
|
var import_log12 = require("@dxos/log");
|
|
@@ -2417,7 +2406,7 @@ var import_teleport2 = require("@dxos/teleport");
|
|
|
2417
2406
|
var import_teleport_extension_object_sync = require("@dxos/teleport-extension-object-sync");
|
|
2418
2407
|
var import_teleport_extension_replicator = require("@dxos/teleport-extension-replicator");
|
|
2419
2408
|
var import_util8 = require("@dxos/util");
|
|
2420
|
-
function
|
|
2409
|
+
function _ts_decorate7(decorators, target, key, desc) {
|
|
2421
2410
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
2422
2411
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
|
|
2423
2412
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -2535,10 +2524,10 @@ var SpaceProtocol = class {
|
|
|
2535
2524
|
};
|
|
2536
2525
|
}
|
|
2537
2526
|
};
|
|
2538
|
-
|
|
2527
|
+
_ts_decorate7([
|
|
2539
2528
|
import_log11.logInfo
|
|
2540
2529
|
], SpaceProtocol.prototype, "_topic", void 0);
|
|
2541
|
-
|
|
2530
|
+
_ts_decorate7([
|
|
2542
2531
|
import_log11.logInfo
|
|
2543
2532
|
], SpaceProtocol.prototype, "_ownPeerKey", null);
|
|
2544
2533
|
var AuthStatus;
|
|
@@ -2607,15 +2596,15 @@ var SpaceProtocolSession = class {
|
|
|
2607
2596
|
await this._teleport.abort();
|
|
2608
2597
|
}
|
|
2609
2598
|
};
|
|
2610
|
-
|
|
2599
|
+
_ts_decorate7([
|
|
2611
2600
|
import_log11.logInfo
|
|
2612
2601
|
], SpaceProtocolSession.prototype, "_wireParams", void 0);
|
|
2613
|
-
|
|
2602
|
+
_ts_decorate7([
|
|
2614
2603
|
import_log11.logInfo
|
|
2615
2604
|
], SpaceProtocolSession.prototype, "authStatus", null);
|
|
2616
2605
|
|
|
2617
2606
|
// packages/core/echo/echo-pipeline/src/space/space-manager.ts
|
|
2618
|
-
function
|
|
2607
|
+
function _ts_decorate8(decorators, target, key, desc) {
|
|
2619
2608
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
2620
2609
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
|
|
2621
2610
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -2698,14 +2687,14 @@ var SpaceManager = class SpaceManager2 {
|
|
|
2698
2687
|
return space;
|
|
2699
2688
|
}
|
|
2700
2689
|
};
|
|
2701
|
-
|
|
2702
|
-
|
|
2690
|
+
_ts_decorate8([
|
|
2691
|
+
import_async8.synchronized
|
|
2703
2692
|
], SpaceManager.prototype, "open", null);
|
|
2704
|
-
|
|
2705
|
-
|
|
2693
|
+
_ts_decorate8([
|
|
2694
|
+
import_async8.synchronized
|
|
2706
2695
|
], SpaceManager.prototype, "close", null);
|
|
2707
|
-
SpaceManager =
|
|
2708
|
-
(0,
|
|
2696
|
+
SpaceManager = _ts_decorate8([
|
|
2697
|
+
(0, import_async8.trackLeaks)("open", "close")
|
|
2709
2698
|
], SpaceManager);
|
|
2710
2699
|
|
|
2711
2700
|
// packages/core/echo/echo-pipeline/src/testing/test-agent-builder.ts
|
|
@@ -2882,7 +2871,7 @@ var TestAgent = class {
|
|
|
2882
2871
|
};
|
|
2883
2872
|
|
|
2884
2873
|
// packages/core/echo/echo-pipeline/src/testing/util.ts
|
|
2885
|
-
var
|
|
2874
|
+
var import_async9 = require("@dxos/async");
|
|
2886
2875
|
var import_document_model2 = require("@dxos/document-model");
|
|
2887
2876
|
var import_echo_db4 = require("@dxos/echo-db");
|
|
2888
2877
|
var import_testing2 = require("@dxos/feed-store/testing");
|
|
@@ -2944,10 +2933,252 @@ var testLocalDatabase = async (create, check = create) => {
|
|
|
2944
2933
|
]
|
|
2945
2934
|
}
|
|
2946
2935
|
});
|
|
2947
|
-
await (0,
|
|
2936
|
+
await (0, import_async9.asyncTimeout)(check.databaseHost._itemDemuxer.mutation.waitForCondition(() => check.itemManager.entities.has(objectId)), 2e3);
|
|
2937
|
+
};
|
|
2938
|
+
|
|
2939
|
+
// packages/core/echo/echo-pipeline/src/testing/database-test-rig.ts
|
|
2940
|
+
var import_async10 = require("@dxos/async");
|
|
2941
|
+
var import_document_model3 = require("@dxos/document-model");
|
|
2942
|
+
var import_echo_db5 = require("@dxos/echo-db");
|
|
2943
|
+
var import_invariant10 = require("@dxos/invariant");
|
|
2944
|
+
var import_keys10 = require("@dxos/keys");
|
|
2945
|
+
var import_model_factory3 = require("@dxos/model-factory");
|
|
2946
|
+
var import_protocols8 = require("@dxos/protocols");
|
|
2947
|
+
var import_text_model = require("@dxos/text-model");
|
|
2948
|
+
var import_timeframe6 = require("@dxos/timeframe");
|
|
2949
|
+
var import_util11 = require("@dxos/util");
|
|
2950
|
+
var __dxlog_file14 = "/home/runner/work/dxos/dxos/packages/core/echo/echo-pipeline/src/testing/database-test-rig.ts";
|
|
2951
|
+
var SPACE_KEY = import_keys10.PublicKey.random();
|
|
2952
|
+
var DatabaseTestBuilder = class {
|
|
2953
|
+
constructor() {
|
|
2954
|
+
this.peers = new import_util11.ComplexMap(import_keys10.PublicKey.hash);
|
|
2955
|
+
}
|
|
2956
|
+
async createPeer() {
|
|
2957
|
+
const peer = new DatabaseTestPeer(this);
|
|
2958
|
+
this.peers.set(peer.key, peer);
|
|
2959
|
+
await peer.open();
|
|
2960
|
+
return peer;
|
|
2961
|
+
}
|
|
2962
|
+
};
|
|
2963
|
+
var DatabaseTestPeer = class {
|
|
2964
|
+
constructor(rig) {
|
|
2965
|
+
this.rig = rig;
|
|
2966
|
+
this.modelFactory = new import_model_factory3.ModelFactory().registerModel(import_document_model3.DocumentModel).registerModel(import_text_model.TextModel);
|
|
2967
|
+
this.key = import_keys10.PublicKey.random();
|
|
2968
|
+
this.feedMessages = [];
|
|
2969
|
+
this.snapshots = /* @__PURE__ */ new Map();
|
|
2970
|
+
this.confirmed = -1;
|
|
2971
|
+
this.timeframe = new import_timeframe6.Timeframe();
|
|
2972
|
+
this._onConfirm = new import_async10.Event();
|
|
2973
|
+
this._writes = /* @__PURE__ */ new Set();
|
|
2974
|
+
}
|
|
2975
|
+
async open() {
|
|
2976
|
+
this.hostItems = new import_echo_db5.ItemManager(this.modelFactory);
|
|
2977
|
+
this.host = new DatabaseHost({
|
|
2978
|
+
write: async (message, { afterWrite }) => {
|
|
2979
|
+
const seq = this.feedMessages.push({
|
|
2980
|
+
timeframe: this.timeframe,
|
|
2981
|
+
payload: {
|
|
2982
|
+
data: message
|
|
2983
|
+
}
|
|
2984
|
+
}) - 1;
|
|
2985
|
+
const request = {
|
|
2986
|
+
receipt: {
|
|
2987
|
+
seq,
|
|
2988
|
+
feedKey: this.key
|
|
2989
|
+
},
|
|
2990
|
+
options: {
|
|
2991
|
+
afterWrite
|
|
2992
|
+
},
|
|
2993
|
+
trigger: new import_async10.Trigger()
|
|
2994
|
+
};
|
|
2995
|
+
this._writes.add(request);
|
|
2996
|
+
await request.trigger.wait();
|
|
2997
|
+
return request.receipt;
|
|
2998
|
+
}
|
|
2999
|
+
}, async () => {
|
|
3000
|
+
});
|
|
3001
|
+
await this.host.open(this.hostItems, this.modelFactory);
|
|
3002
|
+
if (this.snapshot) {
|
|
3003
|
+
this.host._itemDemuxer.restoreFromSnapshot(this.snapshot.database);
|
|
3004
|
+
}
|
|
3005
|
+
this.items = new import_echo_db5.ItemManager(this.modelFactory);
|
|
3006
|
+
this.proxy = new import_echo_db5.DatabaseProxy({
|
|
3007
|
+
service: this.host.createDataServiceHost(),
|
|
3008
|
+
itemManager: this.items,
|
|
3009
|
+
spaceKey: SPACE_KEY
|
|
3010
|
+
});
|
|
3011
|
+
await this.proxy.open(this.modelFactory);
|
|
3012
|
+
}
|
|
3013
|
+
/**
|
|
3014
|
+
* Confirm mutations written to the local feed.
|
|
3015
|
+
* @param seq Sequence number of the mutation to confirm. If not specified, all mutations will be confirmed.
|
|
3016
|
+
*/
|
|
3017
|
+
async confirm(seq) {
|
|
3018
|
+
this.confirmed = seq ?? this.feedMessages.length - 1;
|
|
3019
|
+
this._onConfirm.emit();
|
|
3020
|
+
for (const request of [
|
|
3021
|
+
...this._writes
|
|
3022
|
+
]) {
|
|
3023
|
+
if (this.confirmed >= request.receipt.seq) {
|
|
3024
|
+
this._writes.delete(request);
|
|
3025
|
+
await request.options.afterWrite?.(request.receipt);
|
|
3026
|
+
request.trigger.wake();
|
|
3027
|
+
}
|
|
3028
|
+
}
|
|
3029
|
+
this._processMessages(import_timeframe6.Timeframe.merge(this.timeframe, new import_timeframe6.Timeframe([
|
|
3030
|
+
[
|
|
3031
|
+
this.key,
|
|
3032
|
+
this.confirmed
|
|
3033
|
+
]
|
|
3034
|
+
])));
|
|
3035
|
+
}
|
|
3036
|
+
/**
|
|
3037
|
+
* Replicate the database to the specified timeframe.
|
|
3038
|
+
* @param to Timeframe to replicate to. If not specified, the database will be replicated to the latest timeframe (based on all other peers).
|
|
3039
|
+
*/
|
|
3040
|
+
replicate(to) {
|
|
3041
|
+
const toTimeframe = import_timeframe6.Timeframe.merge(to ?? new import_timeframe6.Timeframe(Array.from(this.rig.peers.values()).map((peer) => [
|
|
3042
|
+
peer.key,
|
|
3043
|
+
peer.confirmed
|
|
3044
|
+
])), this.timeframe);
|
|
3045
|
+
toTimeframe.set(this.key, this.confirmed);
|
|
3046
|
+
this._processMessages(toTimeframe);
|
|
3047
|
+
}
|
|
3048
|
+
/**
|
|
3049
|
+
* Reload data from the feed. Wipes unconfirmed mutations.
|
|
3050
|
+
*/
|
|
3051
|
+
async reload() {
|
|
3052
|
+
await this.open();
|
|
3053
|
+
const timeframe = this.timeframe;
|
|
3054
|
+
this.timeframe = this.snapshot?.timeframe ?? new import_timeframe6.Timeframe();
|
|
3055
|
+
this._processMessages(timeframe);
|
|
3056
|
+
}
|
|
3057
|
+
/**
|
|
3058
|
+
* Create snapshot and use it for the next reload.
|
|
3059
|
+
*/
|
|
3060
|
+
makeSnapshot() {
|
|
3061
|
+
this.snapshot = {
|
|
3062
|
+
spaceKey: SPACE_KEY.asUint8Array(),
|
|
3063
|
+
database: this.host.createSnapshot(),
|
|
3064
|
+
timeframe: this.timeframe
|
|
3065
|
+
};
|
|
3066
|
+
return this.snapshot;
|
|
3067
|
+
}
|
|
3068
|
+
createEpoch(mockSnapshot) {
|
|
3069
|
+
const snapshot = this.makeSnapshot();
|
|
3070
|
+
mockSnapshot && (snapshot.database = mockSnapshot);
|
|
3071
|
+
const snapshotCid = import_keys10.PublicKey.from(import_protocols8.schema.getCodecForType("dxos.echo.snapshot.SpaceSnapshot").encode(snapshot)).toHex();
|
|
3072
|
+
this.snapshots.set(snapshotCid, snapshot);
|
|
3073
|
+
const epoch = {
|
|
3074
|
+
previousId: import_keys10.PublicKey.random(),
|
|
3075
|
+
timeframe: this.timeframe,
|
|
3076
|
+
number: this.currentEpoch ? this.currentEpoch.number + 1 : 0,
|
|
3077
|
+
snapshotCid
|
|
3078
|
+
};
|
|
3079
|
+
this.currentEpoch = epoch;
|
|
3080
|
+
this.host._itemDemuxer.restoreFromSnapshot(snapshot.database);
|
|
3081
|
+
}
|
|
3082
|
+
/**
|
|
3083
|
+
* Gets all candidate messages according to the current timeframe.
|
|
3084
|
+
* Does not take into account the current snapshot, timeframe dependencies, or the confirmed, or replicated state.
|
|
3085
|
+
*/
|
|
3086
|
+
_getHeads() {
|
|
3087
|
+
return Array.from(this.rig.peers.values()).map((peer) => {
|
|
3088
|
+
const seq = this.timeframe.get(peer.key) ?? -1;
|
|
3089
|
+
const message = peer.feedMessages[seq + 1];
|
|
3090
|
+
return message && {
|
|
3091
|
+
feedKey: peer.key,
|
|
3092
|
+
seq: seq + 1,
|
|
3093
|
+
data: message
|
|
3094
|
+
};
|
|
3095
|
+
}).filter(import_util11.isNotNullOrUndefined);
|
|
3096
|
+
}
|
|
3097
|
+
_processMessages(to) {
|
|
3098
|
+
let run = true;
|
|
3099
|
+
while (run) {
|
|
3100
|
+
run = false;
|
|
3101
|
+
const heads = this._getHeads();
|
|
3102
|
+
for (const candidate of heads) {
|
|
3103
|
+
const toSeq = to.get(candidate.feedKey) ?? -1;
|
|
3104
|
+
if (toSeq < candidate.seq) {
|
|
3105
|
+
continue;
|
|
3106
|
+
}
|
|
3107
|
+
const snapshotSeq = this.snapshot?.timeframe?.get(candidate.feedKey) ?? -1;
|
|
3108
|
+
if (candidate.seq <= snapshotSeq) {
|
|
3109
|
+
continue;
|
|
3110
|
+
}
|
|
3111
|
+
if (!import_timeframe6.Timeframe.dependencies(candidate.data.timeframe, this.timeframe).isEmpty()) {
|
|
3112
|
+
continue;
|
|
3113
|
+
}
|
|
3114
|
+
run = true;
|
|
3115
|
+
this.host.echoProcessor({
|
|
3116
|
+
batch: candidate.data.payload.data.batch,
|
|
3117
|
+
meta: {
|
|
3118
|
+
feedKey: candidate.feedKey,
|
|
3119
|
+
seq: candidate.seq,
|
|
3120
|
+
memberKey: candidate.feedKey,
|
|
3121
|
+
timeframe: candidate.data.timeframe
|
|
3122
|
+
}
|
|
3123
|
+
});
|
|
3124
|
+
this.timeframe = import_timeframe6.Timeframe.merge(this.timeframe, new import_timeframe6.Timeframe([
|
|
3125
|
+
[
|
|
3126
|
+
candidate.feedKey,
|
|
3127
|
+
candidate.seq
|
|
3128
|
+
]
|
|
3129
|
+
]));
|
|
3130
|
+
}
|
|
3131
|
+
}
|
|
3132
|
+
}
|
|
3133
|
+
getModel(id) {
|
|
3134
|
+
const item = this.items.getItem(id);
|
|
3135
|
+
if (!item) {
|
|
3136
|
+
return;
|
|
3137
|
+
}
|
|
3138
|
+
(0, import_invariant10.invariant)(item.modelMeta, void 0, {
|
|
3139
|
+
F: __dxlog_file14,
|
|
3140
|
+
L: 262,
|
|
3141
|
+
S: this,
|
|
3142
|
+
A: [
|
|
3143
|
+
"item.modelMeta",
|
|
3144
|
+
""
|
|
3145
|
+
]
|
|
3146
|
+
});
|
|
3147
|
+
const ModelConstructor = this.modelFactory.getModel(item.modelMeta.type)?.constructor;
|
|
3148
|
+
(0, import_invariant10.invariant)(ModelConstructor, void 0, {
|
|
3149
|
+
F: __dxlog_file14,
|
|
3150
|
+
L: 264,
|
|
3151
|
+
S: this,
|
|
3152
|
+
A: [
|
|
3153
|
+
"ModelConstructor",
|
|
3154
|
+
""
|
|
3155
|
+
]
|
|
3156
|
+
});
|
|
3157
|
+
const model = new ModelConstructor(item.modelMeta, item.id, () => item.state, async (mutation) => {
|
|
3158
|
+
(0, import_invariant10.invariant)(item.modelMeta, void 0, {
|
|
3159
|
+
F: __dxlog_file14,
|
|
3160
|
+
L: 271,
|
|
3161
|
+
S: this,
|
|
3162
|
+
A: [
|
|
3163
|
+
"item.modelMeta",
|
|
3164
|
+
""
|
|
3165
|
+
]
|
|
3166
|
+
});
|
|
3167
|
+
this.proxy.mutate((0, import_echo_db5.createModelMutation)(id, (0, import_echo_db5.encodeModelMutation)(item.modelMeta, mutation)));
|
|
3168
|
+
return {
|
|
3169
|
+
feedKey: import_keys10.PublicKey.from("00"),
|
|
3170
|
+
seq: 0,
|
|
3171
|
+
waitToBeProcessed: () => Promise.resolve()
|
|
3172
|
+
};
|
|
3173
|
+
});
|
|
3174
|
+
model.initialize();
|
|
3175
|
+
return model;
|
|
3176
|
+
}
|
|
2948
3177
|
};
|
|
2949
3178
|
// Annotate the CommonJS export names for ESM import in node:
|
|
2950
3179
|
0 && (module.exports = {
|
|
3180
|
+
DatabaseTestBuilder,
|
|
3181
|
+
DatabaseTestPeer,
|
|
2951
3182
|
MemoryNetworkManagerProvider,
|
|
2952
3183
|
TestAgent,
|
|
2953
3184
|
TestAgentBuilder,
|