@dxos/echo-pipeline 0.3.9-main.c2ac8a5 → 0.3.9-main.c64f707
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-HSZ2EJ74.mjs → chunk-6XOL2DVG.mjs} +329 -42
- package/dist/lib/browser/chunk-6XOL2DVG.mjs.map +7 -0
- package/dist/lib/browser/index.mjs +3 -1
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/testing/index.mjs +7 -2
- package/dist/lib/browser/testing/index.mjs.map +3 -3
- package/dist/lib/node/{chunk-RMIDX4JE.cjs → chunk-2RIO52RK.cjs} +323 -44
- package/dist/lib/node/chunk-2RIO52RK.cjs.map +7 -0
- package/dist/lib/node/index.cjs +27 -25
- package/dist/lib/node/index.cjs.map +2 -2
- package/dist/lib/node/meta.json +1 -1
- package/dist/lib/node/testing/index.cjs +18 -14
- package/dist/lib/node/testing/index.cjs.map +3 -3
- package/dist/types/src/automerge/automerge-host.d.ts +19 -0
- package/dist/types/src/automerge/automerge-host.d.ts.map +1 -0
- package/dist/types/src/automerge/automerge-host.test.d.ts +2 -0
- package/dist/types/src/automerge/automerge-host.test.d.ts.map +1 -0
- package/dist/types/src/automerge/index.d.ts +2 -0
- package/dist/types/src/automerge/index.d.ts.map +1 -0
- package/dist/types/src/db-host/data-service-host.d.ts +2 -1
- package/dist/types/src/db-host/data-service-host.d.ts.map +1 -1
- package/dist/types/src/db-host/data-service.d.ts +5 -2
- package/dist/types/src/db-host/data-service.d.ts.map +1 -1
- package/dist/types/src/index.d.ts +1 -0
- package/dist/types/src/index.d.ts.map +1 -1
- package/dist/types/src/space/data-pipeline.d.ts +4 -0
- package/dist/types/src/space/data-pipeline.d.ts.map +1 -1
- package/dist/types/src/space/space-manager.d.ts +3 -0
- package/dist/types/src/space/space-manager.d.ts.map +1 -1
- package/dist/types/src/testing/util.d.ts.map +1 -1
- package/package.json +33 -31
- package/src/automerge/automerge-host.test.ts +122 -0
- package/src/automerge/automerge-host.ts +301 -0
- package/src/automerge/index.ts +5 -0
- package/src/db-host/data-service-host.ts +5 -0
- package/src/db-host/data-service.ts +14 -3
- package/src/index.ts +1 -0
- package/src/space/data-pipeline.ts +10 -0
- package/src/space/space-manager.ts +3 -0
- package/src/testing/util.ts +4 -1
- package/src/tests/database.test.ts +4 -1
- package/dist/lib/browser/chunk-HSZ2EJ74.mjs.map +0 -7
- package/dist/lib/node/chunk-RMIDX4JE.cjs.map +0 -7
|
@@ -26,10 +26,11 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
26
26
|
mod
|
|
27
27
|
));
|
|
28
28
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
-
var
|
|
30
|
-
__export(
|
|
29
|
+
var chunk_2RIO52RK_exports = {};
|
|
30
|
+
__export(chunk_2RIO52RK_exports, {
|
|
31
31
|
AuthExtension: () => AuthExtension,
|
|
32
32
|
AuthStatus: () => AuthStatus,
|
|
33
|
+
AutomergeHost: () => AutomergeHost,
|
|
33
34
|
DataPipeline: () => DataPipeline,
|
|
34
35
|
DataServiceHost: () => DataServiceHost,
|
|
35
36
|
DataServiceImpl: () => DataServiceImpl,
|
|
@@ -53,7 +54,7 @@ __export(chunk_RMIDX4JE_exports, {
|
|
|
53
54
|
startAfter: () => startAfter,
|
|
54
55
|
valueEncoding: () => valueEncoding
|
|
55
56
|
});
|
|
56
|
-
module.exports = __toCommonJS(
|
|
57
|
+
module.exports = __toCommonJS(chunk_2RIO52RK_exports);
|
|
57
58
|
var import_hypercore = require("@dxos/hypercore");
|
|
58
59
|
var import_protocols = require("@dxos/protocols");
|
|
59
60
|
var import_invariant = require("@dxos/invariant");
|
|
@@ -146,6 +147,12 @@ var import_keys7 = require("@dxos/keys");
|
|
|
146
147
|
var import_log12 = require("@dxos/log");
|
|
147
148
|
var import_protocols7 = require("@dxos/protocols");
|
|
148
149
|
var import_util9 = require("@dxos/util");
|
|
150
|
+
var import_automerge_repo = require("@dxos/automerge/automerge-repo");
|
|
151
|
+
var import_codec_protobuf2 = require("@dxos/codec-protobuf");
|
|
152
|
+
var import_invariant10 = require("@dxos/invariant");
|
|
153
|
+
var import_log13 = require("@dxos/log");
|
|
154
|
+
var import_teleport_extension_automerge_replicator = require("@dxos/teleport-extension-automerge-replicator");
|
|
155
|
+
var import_util10 = require("@dxos/util");
|
|
149
156
|
var codec = import_protocols.schema.getCodecForType("dxos.echo.feed.FeedMessage");
|
|
150
157
|
var valueEncoding = (0, import_hypercore.createCodecEncoding)(codec);
|
|
151
158
|
var __dxlog_file = "/home/runner/work/dxos/dxos/packages/core/echo/echo-pipeline/src/common/feeds.ts";
|
|
@@ -252,7 +259,7 @@ var DataServiceHost = class {
|
|
|
252
259
|
const { batch, meta } = message;
|
|
253
260
|
(0, import_invariant2.invariant)(!meta.clientTag, "Unexpected client tag in mutation message", {
|
|
254
261
|
F: __dxlog_file2,
|
|
255
|
-
L:
|
|
262
|
+
L: 138,
|
|
256
263
|
S: this,
|
|
257
264
|
A: [
|
|
258
265
|
"!(meta as any).clientTag",
|
|
@@ -264,7 +271,7 @@ var DataServiceHost = class {
|
|
|
264
271
|
meta
|
|
265
272
|
}, {
|
|
266
273
|
F: __dxlog_file2,
|
|
267
|
-
L:
|
|
274
|
+
L: 139,
|
|
268
275
|
S: this,
|
|
269
276
|
C: (f, a) => f(...a)
|
|
270
277
|
});
|
|
@@ -308,7 +315,7 @@ var DataServiceHost = class {
|
|
|
308
315
|
async write(request) {
|
|
309
316
|
(0, import_invariant2.invariant)(!this._ctx.disposed, "Cannot write to closed DataServiceHost", {
|
|
310
317
|
F: __dxlog_file2,
|
|
311
|
-
L:
|
|
318
|
+
L: 184,
|
|
312
319
|
S: this,
|
|
313
320
|
A: [
|
|
314
321
|
"!this._ctx.disposed",
|
|
@@ -317,7 +324,7 @@ var DataServiceHost = class {
|
|
|
317
324
|
});
|
|
318
325
|
(0, import_invariant2.invariant)(this._writeStream, "Cannot write mutations in readonly mode", {
|
|
319
326
|
F: __dxlog_file2,
|
|
320
|
-
L:
|
|
327
|
+
L: 185,
|
|
321
328
|
S: this,
|
|
322
329
|
A: [
|
|
323
330
|
"this._writeStream",
|
|
@@ -329,7 +336,7 @@ var DataServiceHost = class {
|
|
|
329
336
|
objectCount: request.batch.objects?.length ?? 0
|
|
330
337
|
}, {
|
|
331
338
|
F: __dxlog_file2,
|
|
332
|
-
L:
|
|
339
|
+
L: 187,
|
|
333
340
|
S: this,
|
|
334
341
|
C: (f, a) => f(...a)
|
|
335
342
|
});
|
|
@@ -343,7 +350,7 @@ var DataServiceHost = class {
|
|
|
343
350
|
seq: receipt2.seq
|
|
344
351
|
}, {
|
|
345
352
|
F: __dxlog_file2,
|
|
346
|
-
L:
|
|
353
|
+
L: 196,
|
|
347
354
|
S: this,
|
|
348
355
|
C: (f, a) => f(...a)
|
|
349
356
|
});
|
|
@@ -359,6 +366,9 @@ var DataServiceHost = class {
|
|
|
359
366
|
async flush() {
|
|
360
367
|
await this._flush();
|
|
361
368
|
}
|
|
369
|
+
getHostInfo() {
|
|
370
|
+
throw new Error("Method not implemented.");
|
|
371
|
+
}
|
|
362
372
|
syncRepo(request) {
|
|
363
373
|
throw new Error("Method not implemented.");
|
|
364
374
|
}
|
|
@@ -491,13 +501,13 @@ var DataServiceSubscriptions = class {
|
|
|
491
501
|
spaceKey
|
|
492
502
|
}, {
|
|
493
503
|
F: __dxlog_file3,
|
|
494
|
-
L:
|
|
504
|
+
L: 35,
|
|
495
505
|
S: this,
|
|
496
506
|
C: (f, a) => f(...a)
|
|
497
507
|
});
|
|
498
508
|
(0, import_invariant3.invariant)(!this._spaces.has(spaceKey), void 0, {
|
|
499
509
|
F: __dxlog_file3,
|
|
500
|
-
L:
|
|
510
|
+
L: 36,
|
|
501
511
|
S: this,
|
|
502
512
|
A: [
|
|
503
513
|
"!this._spaces.has(spaceKey)",
|
|
@@ -512,7 +522,7 @@ var DataServiceSubscriptions = class {
|
|
|
512
522
|
spaceKey
|
|
513
523
|
}, {
|
|
514
524
|
F: __dxlog_file3,
|
|
515
|
-
L:
|
|
525
|
+
L: 42,
|
|
516
526
|
S: this,
|
|
517
527
|
C: (f, a) => f(...a)
|
|
518
528
|
});
|
|
@@ -525,13 +535,14 @@ var DataServiceSubscriptions = class {
|
|
|
525
535
|
}
|
|
526
536
|
};
|
|
527
537
|
var DataServiceImpl = class {
|
|
528
|
-
constructor(_subscriptions) {
|
|
538
|
+
constructor(_subscriptions, _automergeHost) {
|
|
529
539
|
this._subscriptions = _subscriptions;
|
|
540
|
+
this._automergeHost = _automergeHost;
|
|
530
541
|
}
|
|
531
542
|
subscribe(request) {
|
|
532
543
|
(0, import_invariant3.invariant)(request.spaceKey, void 0, {
|
|
533
544
|
F: __dxlog_file3,
|
|
534
|
-
L:
|
|
545
|
+
L: 64,
|
|
535
546
|
S: this,
|
|
536
547
|
A: [
|
|
537
548
|
"request.spaceKey",
|
|
@@ -544,7 +555,7 @@ var DataServiceImpl = class {
|
|
|
544
555
|
write(request) {
|
|
545
556
|
(0, import_invariant3.invariant)(request.spaceKey, void 0, {
|
|
546
557
|
F: __dxlog_file3,
|
|
547
|
-
L:
|
|
558
|
+
L: 71,
|
|
548
559
|
S: this,
|
|
549
560
|
A: [
|
|
550
561
|
"request.spaceKey",
|
|
@@ -553,7 +564,7 @@ var DataServiceImpl = class {
|
|
|
553
564
|
});
|
|
554
565
|
(0, import_invariant3.invariant)(request.batch, void 0, {
|
|
555
566
|
F: __dxlog_file3,
|
|
556
|
-
L:
|
|
567
|
+
L: 72,
|
|
557
568
|
S: this,
|
|
558
569
|
A: [
|
|
559
570
|
"request.batch",
|
|
@@ -566,7 +577,7 @@ var DataServiceImpl = class {
|
|
|
566
577
|
flush(request) {
|
|
567
578
|
(0, import_invariant3.invariant)(request.spaceKey, void 0, {
|
|
568
579
|
F: __dxlog_file3,
|
|
569
|
-
L:
|
|
580
|
+
L: 79,
|
|
570
581
|
S: this,
|
|
571
582
|
A: [
|
|
572
583
|
"request.spaceKey",
|
|
@@ -576,11 +587,15 @@ var DataServiceImpl = class {
|
|
|
576
587
|
const host = this._subscriptions.getDataService(request.spaceKey) ?? (0, import_debug.raise)(new Error(`space not found: ${request.spaceKey}`));
|
|
577
588
|
return host.flush();
|
|
578
589
|
}
|
|
590
|
+
// Automerge specific.
|
|
591
|
+
async getHostInfo(request) {
|
|
592
|
+
return this._automergeHost.getHostInfo();
|
|
593
|
+
}
|
|
579
594
|
syncRepo(request) {
|
|
580
|
-
|
|
595
|
+
return this._automergeHost.syncRepo(request);
|
|
581
596
|
}
|
|
582
597
|
sendSyncMessage(request) {
|
|
583
|
-
|
|
598
|
+
return this._automergeHost.sendSyncMessage(request);
|
|
584
599
|
}
|
|
585
600
|
};
|
|
586
601
|
function _ts_decorate(decorators, target, key, desc) {
|
|
@@ -1570,7 +1585,7 @@ var DataPipeline = class DataPipeline2 {
|
|
|
1570
1585
|
write: (data, options) => {
|
|
1571
1586
|
(0, import_invariant8.invariant)(this._pipeline, "Pipeline is not initialized.", {
|
|
1572
1587
|
F: __dxlog_file9,
|
|
1573
|
-
L:
|
|
1588
|
+
L: 164,
|
|
1574
1589
|
S: this,
|
|
1575
1590
|
A: [
|
|
1576
1591
|
"this._pipeline",
|
|
@@ -1579,7 +1594,7 @@ var DataPipeline = class DataPipeline2 {
|
|
|
1579
1594
|
});
|
|
1580
1595
|
(0, import_invariant8.invariant)(this.currentEpoch, "Epoch is not initialized.", {
|
|
1581
1596
|
F: __dxlog_file9,
|
|
1582
|
-
L:
|
|
1597
|
+
L: 165,
|
|
1583
1598
|
S: this,
|
|
1584
1599
|
A: [
|
|
1585
1600
|
"this.currentEpoch",
|
|
@@ -1605,7 +1620,7 @@ var DataPipeline = class DataPipeline2 {
|
|
|
1605
1620
|
}
|
|
1606
1621
|
(0, import_log8.log)("close", void 0, {
|
|
1607
1622
|
F: __dxlog_file9,
|
|
1608
|
-
L:
|
|
1623
|
+
L: 189,
|
|
1609
1624
|
S: this,
|
|
1610
1625
|
C: (f, a) => f(...a)
|
|
1611
1626
|
});
|
|
@@ -1620,7 +1635,7 @@ var DataPipeline = class DataPipeline2 {
|
|
|
1620
1635
|
} catch (err) {
|
|
1621
1636
|
import_log8.log.catch(err, void 0, {
|
|
1622
1637
|
F: __dxlog_file9,
|
|
1623
|
-
L:
|
|
1638
|
+
L: 202,
|
|
1624
1639
|
S: this,
|
|
1625
1640
|
C: (f, a) => f(...a)
|
|
1626
1641
|
});
|
|
@@ -1645,7 +1660,7 @@ var DataPipeline = class DataPipeline2 {
|
|
|
1645
1660
|
let messageCounter = 0;
|
|
1646
1661
|
(0, import_invariant8.invariant)(this._pipeline, "Pipeline is not initialized.", {
|
|
1647
1662
|
F: __dxlog_file9,
|
|
1648
|
-
L:
|
|
1663
|
+
L: 228,
|
|
1649
1664
|
S: this,
|
|
1650
1665
|
A: [
|
|
1651
1666
|
"this._pipeline",
|
|
@@ -1661,7 +1676,7 @@ var DataPipeline = class DataPipeline2 {
|
|
|
1661
1676
|
seq
|
|
1662
1677
|
}, {
|
|
1663
1678
|
F: __dxlog_file9,
|
|
1664
|
-
L:
|
|
1679
|
+
L: 234,
|
|
1665
1680
|
S: this,
|
|
1666
1681
|
C: (f, a) => f(...a)
|
|
1667
1682
|
});
|
|
@@ -1673,7 +1688,7 @@ var DataPipeline = class DataPipeline2 {
|
|
|
1673
1688
|
feedKey
|
|
1674
1689
|
}, {
|
|
1675
1690
|
F: __dxlog_file9,
|
|
1676
|
-
L:
|
|
1691
|
+
L: 240,
|
|
1677
1692
|
S: this,
|
|
1678
1693
|
C: (f, a) => f(...a)
|
|
1679
1694
|
});
|
|
@@ -1696,7 +1711,7 @@ var DataPipeline = class DataPipeline2 {
|
|
|
1696
1711
|
spaceKey: this._params.spaceKey.toHex()
|
|
1697
1712
|
}, {
|
|
1698
1713
|
F: __dxlog_file9,
|
|
1699
|
-
L:
|
|
1714
|
+
L: 257,
|
|
1700
1715
|
S: this,
|
|
1701
1716
|
C: (f, a) => f(...a)
|
|
1702
1717
|
});
|
|
@@ -1705,7 +1720,7 @@ var DataPipeline = class DataPipeline2 {
|
|
|
1705
1720
|
} catch (err) {
|
|
1706
1721
|
import_log8.log.catch(err, void 0, {
|
|
1707
1722
|
F: __dxlog_file9,
|
|
1708
|
-
L:
|
|
1723
|
+
L: 267,
|
|
1709
1724
|
S: this,
|
|
1710
1725
|
C: (f, a) => f(...a)
|
|
1711
1726
|
});
|
|
@@ -1720,7 +1735,7 @@ var DataPipeline = class DataPipeline2 {
|
|
|
1720
1735
|
_createSnapshot() {
|
|
1721
1736
|
(0, import_invariant8.invariant)(this.databaseHost, "Database backend is not initialized.", {
|
|
1722
1737
|
F: __dxlog_file9,
|
|
1723
|
-
L:
|
|
1738
|
+
L: 281,
|
|
1724
1739
|
S: this,
|
|
1725
1740
|
A: [
|
|
1726
1741
|
"this.databaseHost",
|
|
@@ -1749,7 +1764,7 @@ var DataPipeline = class DataPipeline2 {
|
|
|
1749
1764
|
} catch (err) {
|
|
1750
1765
|
import_log8.log.warn("Failed to cache properties", err, {
|
|
1751
1766
|
F: __dxlog_file9,
|
|
1752
|
-
L:
|
|
1767
|
+
L: 310,
|
|
1753
1768
|
S: this,
|
|
1754
1769
|
C: (f, a) => f(...a)
|
|
1755
1770
|
});
|
|
@@ -1778,14 +1793,14 @@ var DataPipeline = class DataPipeline2 {
|
|
|
1778
1793
|
if (err instanceof import_protocols6.CancelledError) {
|
|
1779
1794
|
(0, import_log8.log)("Epoch processing cancelled.", void 0, {
|
|
1780
1795
|
F: __dxlog_file9,
|
|
1781
|
-
L:
|
|
1796
|
+
L: 346,
|
|
1782
1797
|
S: this,
|
|
1783
1798
|
C: (f, a) => f(...a)
|
|
1784
1799
|
});
|
|
1785
1800
|
} else {
|
|
1786
1801
|
import_log8.log.catch(err, void 0, {
|
|
1787
1802
|
F: __dxlog_file9,
|
|
1788
|
-
L:
|
|
1803
|
+
L: 348,
|
|
1789
1804
|
S: this,
|
|
1790
1805
|
C: (f, a) => f(...a)
|
|
1791
1806
|
});
|
|
@@ -1798,6 +1813,9 @@ var DataPipeline = class DataPipeline2 {
|
|
|
1798
1813
|
return;
|
|
1799
1814
|
}
|
|
1800
1815
|
await this._processEpoch(ctx, epoch.subject.assertion);
|
|
1816
|
+
if (epoch.subject.assertion.snapshotCid === void 0) {
|
|
1817
|
+
epoch.subject.assertion.snapshotCid = this.appliedEpoch?.subject.assertion.snapshotCid;
|
|
1818
|
+
}
|
|
1801
1819
|
this.appliedEpoch = epoch;
|
|
1802
1820
|
this.onNewEpoch.emit(epoch);
|
|
1803
1821
|
});
|
|
@@ -1805,7 +1823,7 @@ var DataPipeline = class DataPipeline2 {
|
|
|
1805
1823
|
async _processEpoch(ctx, epoch) {
|
|
1806
1824
|
(0, import_invariant8.invariant)(this._isOpen, "Space is closed.", {
|
|
1807
1825
|
F: __dxlog_file9,
|
|
1808
|
-
L:
|
|
1826
|
+
L: 372,
|
|
1809
1827
|
S: this,
|
|
1810
1828
|
A: [
|
|
1811
1829
|
"this._isOpen",
|
|
@@ -1814,7 +1832,7 @@ var DataPipeline = class DataPipeline2 {
|
|
|
1814
1832
|
});
|
|
1815
1833
|
(0, import_invariant8.invariant)(this._pipeline, void 0, {
|
|
1816
1834
|
F: __dxlog_file9,
|
|
1817
|
-
L:
|
|
1835
|
+
L: 373,
|
|
1818
1836
|
S: this,
|
|
1819
1837
|
A: [
|
|
1820
1838
|
"this._pipeline",
|
|
@@ -1826,7 +1844,7 @@ var DataPipeline = class DataPipeline2 {
|
|
|
1826
1844
|
epoch: (0, import_log8.omit)(epoch, "proof")
|
|
1827
1845
|
}, {
|
|
1828
1846
|
F: __dxlog_file9,
|
|
1829
|
-
L:
|
|
1847
|
+
L: 376,
|
|
1830
1848
|
S: this,
|
|
1831
1849
|
C: (f, a) => f(...a)
|
|
1832
1850
|
});
|
|
@@ -1836,7 +1854,7 @@ var DataPipeline = class DataPipeline2 {
|
|
|
1836
1854
|
}
|
|
1837
1855
|
(0, import_log8.log)("restarting pipeline from epoch", void 0, {
|
|
1838
1856
|
F: __dxlog_file9,
|
|
1839
|
-
L:
|
|
1857
|
+
L: 382,
|
|
1840
1858
|
S: this,
|
|
1841
1859
|
C: (f, a) => f(...a)
|
|
1842
1860
|
});
|
|
@@ -1847,7 +1865,7 @@ var DataPipeline = class DataPipeline2 {
|
|
|
1847
1865
|
async waitUntilTimeframe(timeframe) {
|
|
1848
1866
|
(0, import_invariant8.invariant)(this._pipeline, "Pipeline is not initialized.", {
|
|
1849
1867
|
F: __dxlog_file9,
|
|
1850
|
-
L:
|
|
1868
|
+
L: 389,
|
|
1851
1869
|
S: this,
|
|
1852
1870
|
A: [
|
|
1853
1871
|
"this._pipeline",
|
|
@@ -1859,7 +1877,7 @@ var DataPipeline = class DataPipeline2 {
|
|
|
1859
1877
|
async createEpoch() {
|
|
1860
1878
|
(0, import_invariant8.invariant)(this._pipeline, void 0, {
|
|
1861
1879
|
F: __dxlog_file9,
|
|
1862
|
-
L:
|
|
1880
|
+
L: 395,
|
|
1863
1881
|
S: this,
|
|
1864
1882
|
A: [
|
|
1865
1883
|
"this._pipeline",
|
|
@@ -1868,7 +1886,7 @@ var DataPipeline = class DataPipeline2 {
|
|
|
1868
1886
|
});
|
|
1869
1887
|
(0, import_invariant8.invariant)(this.currentEpoch, void 0, {
|
|
1870
1888
|
F: __dxlog_file9,
|
|
1871
|
-
L:
|
|
1889
|
+
L: 396,
|
|
1872
1890
|
S: this,
|
|
1873
1891
|
A: [
|
|
1874
1892
|
"this.currentEpoch",
|
|
@@ -1899,7 +1917,7 @@ var DataPipeline = class DataPipeline2 {
|
|
|
1899
1917
|
} catch (err) {
|
|
1900
1918
|
import_log8.log.catch(err, void 0, {
|
|
1901
1919
|
F: __dxlog_file9,
|
|
1902
|
-
L:
|
|
1920
|
+
L: 426,
|
|
1903
1921
|
S: this,
|
|
1904
1922
|
C: (f, a) => f(...a)
|
|
1905
1923
|
});
|
|
@@ -2682,7 +2700,7 @@ var SpaceManager = class SpaceManager2 {
|
|
|
2682
2700
|
id: this._instanceId
|
|
2683
2701
|
}), {
|
|
2684
2702
|
F: __dxlog_file13,
|
|
2685
|
-
L:
|
|
2703
|
+
L: 100,
|
|
2686
2704
|
S: this,
|
|
2687
2705
|
C: (f, a) => f(...a)
|
|
2688
2706
|
});
|
|
@@ -2690,7 +2708,7 @@ var SpaceManager = class SpaceManager2 {
|
|
|
2690
2708
|
spaceKey: metadata.genesisFeedKey
|
|
2691
2709
|
}, {
|
|
2692
2710
|
F: __dxlog_file13,
|
|
2693
|
-
L:
|
|
2711
|
+
L: 101,
|
|
2694
2712
|
S: this,
|
|
2695
2713
|
C: (f, a) => f(...a)
|
|
2696
2714
|
});
|
|
@@ -2720,7 +2738,7 @@ var SpaceManager = class SpaceManager2 {
|
|
|
2720
2738
|
id: this._instanceId
|
|
2721
2739
|
}), {
|
|
2722
2740
|
F: __dxlog_file13,
|
|
2723
|
-
L:
|
|
2741
|
+
L: 129,
|
|
2724
2742
|
S: this,
|
|
2725
2743
|
C: (f, a) => f(...a)
|
|
2726
2744
|
});
|
|
@@ -2736,10 +2754,271 @@ _ts_decorate8([
|
|
|
2736
2754
|
SpaceManager = _ts_decorate8([
|
|
2737
2755
|
(0, import_async9.trackLeaks)("open", "close")
|
|
2738
2756
|
], SpaceManager);
|
|
2757
|
+
var __dxlog_file14 = "/home/runner/work/dxos/dxos/packages/core/echo/echo-pipeline/src/automerge/automerge-host.ts";
|
|
2758
|
+
var AutomergeHost = class {
|
|
2759
|
+
constructor(storageDirectory) {
|
|
2760
|
+
this._meshNetwork = new MeshNetworkAdapter();
|
|
2761
|
+
this._clientNetwork = new LocalHostNetworkAdapter();
|
|
2762
|
+
this._storage = new AutomergeStorageAdapter(storageDirectory);
|
|
2763
|
+
this._repo = new import_automerge_repo.Repo({
|
|
2764
|
+
network: [
|
|
2765
|
+
this._clientNetwork,
|
|
2766
|
+
this._meshNetwork
|
|
2767
|
+
],
|
|
2768
|
+
storage: this._storage,
|
|
2769
|
+
// TODO(dmaretskyi): Share based on HALO permissions and space affinity.
|
|
2770
|
+
sharePolicy: async (peerId, documentId) => true
|
|
2771
|
+
});
|
|
2772
|
+
this._clientNetwork.ready();
|
|
2773
|
+
this._meshNetwork.ready();
|
|
2774
|
+
}
|
|
2775
|
+
get repo() {
|
|
2776
|
+
return this._repo;
|
|
2777
|
+
}
|
|
2778
|
+
async close() {
|
|
2779
|
+
await this._clientNetwork.close();
|
|
2780
|
+
}
|
|
2781
|
+
//
|
|
2782
|
+
// Methods for client-services.
|
|
2783
|
+
//
|
|
2784
|
+
syncRepo(request) {
|
|
2785
|
+
return this._clientNetwork.syncRepo(request);
|
|
2786
|
+
}
|
|
2787
|
+
sendSyncMessage(request) {
|
|
2788
|
+
return this._clientNetwork.sendSyncMessage(request);
|
|
2789
|
+
}
|
|
2790
|
+
getHostInfo() {
|
|
2791
|
+
return this._clientNetwork.getHostInfo();
|
|
2792
|
+
}
|
|
2793
|
+
//
|
|
2794
|
+
// Mesh replication.
|
|
2795
|
+
//
|
|
2796
|
+
createExtension() {
|
|
2797
|
+
return this._meshNetwork.createExtension();
|
|
2798
|
+
}
|
|
2799
|
+
};
|
|
2800
|
+
var LocalHostNetworkAdapter = class extends import_automerge_repo.NetworkAdapter {
|
|
2801
|
+
constructor() {
|
|
2802
|
+
super(...arguments);
|
|
2803
|
+
this._peers = /* @__PURE__ */ new Map();
|
|
2804
|
+
}
|
|
2805
|
+
/**
|
|
2806
|
+
* Emits `ready` event. That signals to `Repo` that it can start using the adapter.
|
|
2807
|
+
*/
|
|
2808
|
+
ready() {
|
|
2809
|
+
this.emit("ready", {
|
|
2810
|
+
network: this
|
|
2811
|
+
});
|
|
2812
|
+
}
|
|
2813
|
+
connect(peerId) {
|
|
2814
|
+
this.peerId = peerId;
|
|
2815
|
+
}
|
|
2816
|
+
send(message) {
|
|
2817
|
+
const peer = this._peers.get(message.targetId);
|
|
2818
|
+
(0, import_invariant10.invariant)(peer, "Peer not found.", {
|
|
2819
|
+
F: __dxlog_file14,
|
|
2820
|
+
L: 108,
|
|
2821
|
+
S: this,
|
|
2822
|
+
A: [
|
|
2823
|
+
"peer",
|
|
2824
|
+
"'Peer not found.'"
|
|
2825
|
+
]
|
|
2826
|
+
});
|
|
2827
|
+
peer.send(message);
|
|
2828
|
+
}
|
|
2829
|
+
async close() {
|
|
2830
|
+
this._peers.forEach((peer) => peer.disconnect());
|
|
2831
|
+
this.emit("close");
|
|
2832
|
+
}
|
|
2833
|
+
disconnect() {
|
|
2834
|
+
}
|
|
2835
|
+
syncRepo({ id, syncMessage }) {
|
|
2836
|
+
const peerId = this._getPeerId(id);
|
|
2837
|
+
return new import_codec_protobuf2.Stream(({ next, close }) => {
|
|
2838
|
+
(0, import_invariant10.invariant)(!this._peers.has(peerId), "Peer already connected.", {
|
|
2839
|
+
F: __dxlog_file14,
|
|
2840
|
+
L: 126,
|
|
2841
|
+
S: this,
|
|
2842
|
+
A: [
|
|
2843
|
+
"!this._peers.has(peerId)",
|
|
2844
|
+
"'Peer already connected.'"
|
|
2845
|
+
]
|
|
2846
|
+
});
|
|
2847
|
+
this._peers.set(peerId, {
|
|
2848
|
+
connected: true,
|
|
2849
|
+
send: (message) => {
|
|
2850
|
+
next({
|
|
2851
|
+
syncMessage: import_automerge_repo.cbor.encode(message)
|
|
2852
|
+
});
|
|
2853
|
+
},
|
|
2854
|
+
disconnect: () => {
|
|
2855
|
+
this._peers.delete(peerId);
|
|
2856
|
+
close();
|
|
2857
|
+
this.emit("peer-disconnected", {
|
|
2858
|
+
peerId
|
|
2859
|
+
});
|
|
2860
|
+
}
|
|
2861
|
+
});
|
|
2862
|
+
this.emit("peer-candidate", {
|
|
2863
|
+
peerId
|
|
2864
|
+
});
|
|
2865
|
+
});
|
|
2866
|
+
}
|
|
2867
|
+
async sendSyncMessage({ id, syncMessage }) {
|
|
2868
|
+
const message = import_automerge_repo.cbor.decode(syncMessage);
|
|
2869
|
+
this.emit("message", message);
|
|
2870
|
+
}
|
|
2871
|
+
getHostInfo() {
|
|
2872
|
+
(0, import_invariant10.invariant)(this.peerId, "Peer id not set.", {
|
|
2873
|
+
F: __dxlog_file14,
|
|
2874
|
+
L: 155,
|
|
2875
|
+
S: this,
|
|
2876
|
+
A: [
|
|
2877
|
+
"this.peerId",
|
|
2878
|
+
"'Peer id not set.'"
|
|
2879
|
+
]
|
|
2880
|
+
});
|
|
2881
|
+
return {
|
|
2882
|
+
peerId: this.peerId
|
|
2883
|
+
};
|
|
2884
|
+
}
|
|
2885
|
+
_getPeerId(id) {
|
|
2886
|
+
return id;
|
|
2887
|
+
}
|
|
2888
|
+
};
|
|
2889
|
+
var MeshNetworkAdapter = class extends import_automerge_repo.NetworkAdapter {
|
|
2890
|
+
constructor() {
|
|
2891
|
+
super(...arguments);
|
|
2892
|
+
this._extensions = /* @__PURE__ */ new Map();
|
|
2893
|
+
}
|
|
2894
|
+
/**
|
|
2895
|
+
* Emits `ready` event. That signals to `Repo` that it can start using the adapter.
|
|
2896
|
+
*/
|
|
2897
|
+
ready() {
|
|
2898
|
+
this.emit("ready", {
|
|
2899
|
+
network: this
|
|
2900
|
+
});
|
|
2901
|
+
}
|
|
2902
|
+
connect(peerId) {
|
|
2903
|
+
this.peerId = peerId;
|
|
2904
|
+
}
|
|
2905
|
+
send(message) {
|
|
2906
|
+
const receiverId = message.targetId;
|
|
2907
|
+
const extension = this._extensions.get(receiverId);
|
|
2908
|
+
(0, import_invariant10.invariant)(extension, "Extension not found.", {
|
|
2909
|
+
F: __dxlog_file14,
|
|
2910
|
+
L: 190,
|
|
2911
|
+
S: this,
|
|
2912
|
+
A: [
|
|
2913
|
+
"extension",
|
|
2914
|
+
"'Extension not found.'"
|
|
2915
|
+
]
|
|
2916
|
+
});
|
|
2917
|
+
extension.sendSyncMessage({
|
|
2918
|
+
payload: import_automerge_repo.cbor.encode(message)
|
|
2919
|
+
}).catch((err) => import_log13.log.catch(err, void 0, {
|
|
2920
|
+
F: __dxlog_file14,
|
|
2921
|
+
L: 191,
|
|
2922
|
+
S: this,
|
|
2923
|
+
C: (f, a) => f(...a)
|
|
2924
|
+
}));
|
|
2925
|
+
}
|
|
2926
|
+
disconnect() {
|
|
2927
|
+
}
|
|
2928
|
+
createExtension() {
|
|
2929
|
+
(0, import_invariant10.invariant)(this.peerId, "Peer id not set.", {
|
|
2930
|
+
F: __dxlog_file14,
|
|
2931
|
+
L: 199,
|
|
2932
|
+
S: this,
|
|
2933
|
+
A: [
|
|
2934
|
+
"this.peerId",
|
|
2935
|
+
"'Peer id not set.'"
|
|
2936
|
+
]
|
|
2937
|
+
});
|
|
2938
|
+
let peerInfo;
|
|
2939
|
+
const extension = new import_teleport_extension_automerge_replicator.AutomergeReplicator({
|
|
2940
|
+
peerId: this.peerId
|
|
2941
|
+
}, {
|
|
2942
|
+
onStartReplication: async (info) => {
|
|
2943
|
+
peerInfo = info;
|
|
2944
|
+
this._extensions.set(info.id, extension);
|
|
2945
|
+
this.emit("peer-candidate", {
|
|
2946
|
+
peerId: info.id
|
|
2947
|
+
});
|
|
2948
|
+
},
|
|
2949
|
+
onSyncMessage: async ({ payload }) => {
|
|
2950
|
+
const message = import_automerge_repo.cbor.decode(payload);
|
|
2951
|
+
this.emit("message", message);
|
|
2952
|
+
},
|
|
2953
|
+
onClose: async () => {
|
|
2954
|
+
peerInfo && this.emit("peer-disconnected", {
|
|
2955
|
+
peerId: peerInfo.id
|
|
2956
|
+
});
|
|
2957
|
+
}
|
|
2958
|
+
});
|
|
2959
|
+
return extension;
|
|
2960
|
+
}
|
|
2961
|
+
};
|
|
2962
|
+
var AutomergeStorageAdapter = class extends import_automerge_repo.StorageAdapter {
|
|
2963
|
+
constructor(_directory) {
|
|
2964
|
+
super();
|
|
2965
|
+
this._directory = _directory;
|
|
2966
|
+
}
|
|
2967
|
+
async load(key) {
|
|
2968
|
+
const filename = this._getFilename(key);
|
|
2969
|
+
const file = this._directory.getOrCreateFile(filename);
|
|
2970
|
+
const { size } = await file.stat();
|
|
2971
|
+
if (!size || size === 0) {
|
|
2972
|
+
return void 0;
|
|
2973
|
+
}
|
|
2974
|
+
const buffer = await file.read(0, size);
|
|
2975
|
+
return (0, import_util10.bufferToArray)(buffer);
|
|
2976
|
+
}
|
|
2977
|
+
async save(key, data) {
|
|
2978
|
+
const filename = this._getFilename(key);
|
|
2979
|
+
const file = this._directory.getOrCreateFile(filename);
|
|
2980
|
+
await file.write(0, (0, import_util10.arrayToBuffer)(data));
|
|
2981
|
+
await file.truncate?.(data.length);
|
|
2982
|
+
await file.flush?.();
|
|
2983
|
+
}
|
|
2984
|
+
async remove(key) {
|
|
2985
|
+
const filename = this._getFilename(key);
|
|
2986
|
+
const file = this._directory.getOrCreateFile(filename);
|
|
2987
|
+
await file.truncate?.(0);
|
|
2988
|
+
}
|
|
2989
|
+
async loadRange(keyPrefix) {
|
|
2990
|
+
const filename = this._getFilename(keyPrefix);
|
|
2991
|
+
const entries = await this._directory.list();
|
|
2992
|
+
return Promise.all(entries.filter((entry) => entry.startsWith(filename)).map(async (entry) => {
|
|
2993
|
+
const file = this._directory.getOrCreateFile(entry);
|
|
2994
|
+
const { size } = await file.stat();
|
|
2995
|
+
const buffer = await file.read(0, size);
|
|
2996
|
+
return {
|
|
2997
|
+
key: this._getKeyFromFilename(entry),
|
|
2998
|
+
data: (0, import_util10.bufferToArray)(buffer)
|
|
2999
|
+
};
|
|
3000
|
+
}));
|
|
3001
|
+
}
|
|
3002
|
+
async removeRange(keyPrefix) {
|
|
3003
|
+
const filename = this._getFilename(keyPrefix);
|
|
3004
|
+
const entries = await this._directory.list();
|
|
3005
|
+
await Promise.all(entries.filter((entry) => entry.startsWith(filename)).map(async (entry) => {
|
|
3006
|
+
const file = this._directory.getOrCreateFile(filename);
|
|
3007
|
+
await file.truncate?.(0);
|
|
3008
|
+
}));
|
|
3009
|
+
}
|
|
3010
|
+
_getFilename(key) {
|
|
3011
|
+
return key.map((k) => k.replaceAll("%", "%25").replaceAll("-", "%2D")).join("-");
|
|
3012
|
+
}
|
|
3013
|
+
_getKeyFromFilename(filename) {
|
|
3014
|
+
return filename.split("-").map((k) => k.replaceAll("%2D", "-").replaceAll("%25", "%"));
|
|
3015
|
+
}
|
|
3016
|
+
};
|
|
2739
3017
|
// Annotate the CommonJS export names for ESM import in node:
|
|
2740
3018
|
0 && (module.exports = {
|
|
2741
3019
|
AuthExtension,
|
|
2742
3020
|
AuthStatus,
|
|
3021
|
+
AutomergeHost,
|
|
2743
3022
|
DataPipeline,
|
|
2744
3023
|
DataServiceHost,
|
|
2745
3024
|
DataServiceImpl,
|
|
@@ -2763,4 +3042,4 @@ SpaceManager = _ts_decorate8([
|
|
|
2763
3042
|
startAfter,
|
|
2764
3043
|
valueEncoding
|
|
2765
3044
|
});
|
|
2766
|
-
//# sourceMappingURL=chunk-
|
|
3045
|
+
//# sourceMappingURL=chunk-2RIO52RK.cjs.map
|