@dxos/echo-pipeline 0.3.9-main.ee9a520 → 0.3.9-main.ef334cd
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-MPEQ7BV3.mjs → chunk-CLHJJVQE.mjs} +208 -41
- package/dist/lib/browser/chunk-CLHJJVQE.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-YJAADRTG.cjs → chunk-XWUUSV4Y.cjs} +209 -43
- package/dist/lib/node/chunk-XWUUSV4Y.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 +15 -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.d.ts +3 -1
- 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-protocol.d.ts +2 -1
- package/dist/types/src/space/space-protocol.d.ts.map +1 -1
- package/dist/types/src/testing/util.d.ts.map +1 -1
- package/package.json +32 -31
- package/src/automerge/automerge-host.test.ts +42 -0
- package/src/automerge/automerge-host.ts +212 -0
- package/src/automerge/index.ts +5 -0
- package/src/db-host/data-service.ts +5 -1
- package/src/index.ts +1 -0
- package/src/space/data-pipeline.ts +10 -0
- package/src/space/space-protocol.ts +6 -3
- package/src/testing/util.ts +4 -1
- package/src/tests/database.test.ts +4 -1
- package/dist/lib/browser/chunk-MPEQ7BV3.mjs.map +0 -7
- package/dist/lib/node/chunk-YJAADRTG.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_XWUUSV4Y_exports = {};
|
|
30
|
+
__export(chunk_XWUUSV4Y_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_YJAADRTG_exports, {
|
|
|
53
54
|
startAfter: () => startAfter,
|
|
54
55
|
valueEncoding: () => valueEncoding
|
|
55
56
|
});
|
|
56
|
-
module.exports = __toCommonJS(
|
|
57
|
+
module.exports = __toCommonJS(chunk_XWUUSV4Y_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,10 @@ 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_util10 = require("@dxos/util");
|
|
149
154
|
var codec = import_protocols.schema.getCodecForType("dxos.echo.feed.FeedMessage");
|
|
150
155
|
var valueEncoding = (0, import_hypercore.createCodecEncoding)(codec);
|
|
151
156
|
var __dxlog_file = "/home/runner/work/dxos/dxos/packages/core/echo/echo-pipeline/src/common/feeds.ts";
|
|
@@ -491,13 +496,13 @@ var DataServiceSubscriptions = class {
|
|
|
491
496
|
spaceKey
|
|
492
497
|
}, {
|
|
493
498
|
F: __dxlog_file3,
|
|
494
|
-
L:
|
|
499
|
+
L: 34,
|
|
495
500
|
S: this,
|
|
496
501
|
C: (f, a) => f(...a)
|
|
497
502
|
});
|
|
498
503
|
(0, import_invariant3.invariant)(!this._spaces.has(spaceKey), void 0, {
|
|
499
504
|
F: __dxlog_file3,
|
|
500
|
-
L:
|
|
505
|
+
L: 35,
|
|
501
506
|
S: this,
|
|
502
507
|
A: [
|
|
503
508
|
"!this._spaces.has(spaceKey)",
|
|
@@ -512,7 +517,7 @@ var DataServiceSubscriptions = class {
|
|
|
512
517
|
spaceKey
|
|
513
518
|
}, {
|
|
514
519
|
F: __dxlog_file3,
|
|
515
|
-
L:
|
|
520
|
+
L: 41,
|
|
516
521
|
S: this,
|
|
517
522
|
C: (f, a) => f(...a)
|
|
518
523
|
});
|
|
@@ -525,13 +530,14 @@ var DataServiceSubscriptions = class {
|
|
|
525
530
|
}
|
|
526
531
|
};
|
|
527
532
|
var DataServiceImpl = class {
|
|
528
|
-
constructor(_subscriptions) {
|
|
533
|
+
constructor(_subscriptions, _automergeHost) {
|
|
529
534
|
this._subscriptions = _subscriptions;
|
|
535
|
+
this._automergeHost = _automergeHost;
|
|
530
536
|
}
|
|
531
537
|
subscribe(request) {
|
|
532
538
|
(0, import_invariant3.invariant)(request.spaceKey, void 0, {
|
|
533
539
|
F: __dxlog_file3,
|
|
534
|
-
L:
|
|
540
|
+
L: 63,
|
|
535
541
|
S: this,
|
|
536
542
|
A: [
|
|
537
543
|
"request.spaceKey",
|
|
@@ -544,7 +550,7 @@ var DataServiceImpl = class {
|
|
|
544
550
|
write(request) {
|
|
545
551
|
(0, import_invariant3.invariant)(request.spaceKey, void 0, {
|
|
546
552
|
F: __dxlog_file3,
|
|
547
|
-
L:
|
|
553
|
+
L: 70,
|
|
548
554
|
S: this,
|
|
549
555
|
A: [
|
|
550
556
|
"request.spaceKey",
|
|
@@ -553,7 +559,7 @@ var DataServiceImpl = class {
|
|
|
553
559
|
});
|
|
554
560
|
(0, import_invariant3.invariant)(request.batch, void 0, {
|
|
555
561
|
F: __dxlog_file3,
|
|
556
|
-
L:
|
|
562
|
+
L: 71,
|
|
557
563
|
S: this,
|
|
558
564
|
A: [
|
|
559
565
|
"request.batch",
|
|
@@ -566,7 +572,7 @@ var DataServiceImpl = class {
|
|
|
566
572
|
flush(request) {
|
|
567
573
|
(0, import_invariant3.invariant)(request.spaceKey, void 0, {
|
|
568
574
|
F: __dxlog_file3,
|
|
569
|
-
L:
|
|
575
|
+
L: 78,
|
|
570
576
|
S: this,
|
|
571
577
|
A: [
|
|
572
578
|
"request.spaceKey",
|
|
@@ -1570,7 +1576,7 @@ var DataPipeline = class DataPipeline2 {
|
|
|
1570
1576
|
write: (data, options) => {
|
|
1571
1577
|
(0, import_invariant8.invariant)(this._pipeline, "Pipeline is not initialized.", {
|
|
1572
1578
|
F: __dxlog_file9,
|
|
1573
|
-
L:
|
|
1579
|
+
L: 164,
|
|
1574
1580
|
S: this,
|
|
1575
1581
|
A: [
|
|
1576
1582
|
"this._pipeline",
|
|
@@ -1579,7 +1585,7 @@ var DataPipeline = class DataPipeline2 {
|
|
|
1579
1585
|
});
|
|
1580
1586
|
(0, import_invariant8.invariant)(this.currentEpoch, "Epoch is not initialized.", {
|
|
1581
1587
|
F: __dxlog_file9,
|
|
1582
|
-
L:
|
|
1588
|
+
L: 165,
|
|
1583
1589
|
S: this,
|
|
1584
1590
|
A: [
|
|
1585
1591
|
"this.currentEpoch",
|
|
@@ -1605,7 +1611,7 @@ var DataPipeline = class DataPipeline2 {
|
|
|
1605
1611
|
}
|
|
1606
1612
|
(0, import_log8.log)("close", void 0, {
|
|
1607
1613
|
F: __dxlog_file9,
|
|
1608
|
-
L:
|
|
1614
|
+
L: 189,
|
|
1609
1615
|
S: this,
|
|
1610
1616
|
C: (f, a) => f(...a)
|
|
1611
1617
|
});
|
|
@@ -1620,7 +1626,7 @@ var DataPipeline = class DataPipeline2 {
|
|
|
1620
1626
|
} catch (err) {
|
|
1621
1627
|
import_log8.log.catch(err, void 0, {
|
|
1622
1628
|
F: __dxlog_file9,
|
|
1623
|
-
L:
|
|
1629
|
+
L: 202,
|
|
1624
1630
|
S: this,
|
|
1625
1631
|
C: (f, a) => f(...a)
|
|
1626
1632
|
});
|
|
@@ -1645,7 +1651,7 @@ var DataPipeline = class DataPipeline2 {
|
|
|
1645
1651
|
let messageCounter = 0;
|
|
1646
1652
|
(0, import_invariant8.invariant)(this._pipeline, "Pipeline is not initialized.", {
|
|
1647
1653
|
F: __dxlog_file9,
|
|
1648
|
-
L:
|
|
1654
|
+
L: 228,
|
|
1649
1655
|
S: this,
|
|
1650
1656
|
A: [
|
|
1651
1657
|
"this._pipeline",
|
|
@@ -1661,7 +1667,7 @@ var DataPipeline = class DataPipeline2 {
|
|
|
1661
1667
|
seq
|
|
1662
1668
|
}, {
|
|
1663
1669
|
F: __dxlog_file9,
|
|
1664
|
-
L:
|
|
1670
|
+
L: 234,
|
|
1665
1671
|
S: this,
|
|
1666
1672
|
C: (f, a) => f(...a)
|
|
1667
1673
|
});
|
|
@@ -1673,7 +1679,7 @@ var DataPipeline = class DataPipeline2 {
|
|
|
1673
1679
|
feedKey
|
|
1674
1680
|
}, {
|
|
1675
1681
|
F: __dxlog_file9,
|
|
1676
|
-
L:
|
|
1682
|
+
L: 240,
|
|
1677
1683
|
S: this,
|
|
1678
1684
|
C: (f, a) => f(...a)
|
|
1679
1685
|
});
|
|
@@ -1696,7 +1702,7 @@ var DataPipeline = class DataPipeline2 {
|
|
|
1696
1702
|
spaceKey: this._params.spaceKey.toHex()
|
|
1697
1703
|
}, {
|
|
1698
1704
|
F: __dxlog_file9,
|
|
1699
|
-
L:
|
|
1705
|
+
L: 257,
|
|
1700
1706
|
S: this,
|
|
1701
1707
|
C: (f, a) => f(...a)
|
|
1702
1708
|
});
|
|
@@ -1705,7 +1711,7 @@ var DataPipeline = class DataPipeline2 {
|
|
|
1705
1711
|
} catch (err) {
|
|
1706
1712
|
import_log8.log.catch(err, void 0, {
|
|
1707
1713
|
F: __dxlog_file9,
|
|
1708
|
-
L:
|
|
1714
|
+
L: 267,
|
|
1709
1715
|
S: this,
|
|
1710
1716
|
C: (f, a) => f(...a)
|
|
1711
1717
|
});
|
|
@@ -1720,7 +1726,7 @@ var DataPipeline = class DataPipeline2 {
|
|
|
1720
1726
|
_createSnapshot() {
|
|
1721
1727
|
(0, import_invariant8.invariant)(this.databaseHost, "Database backend is not initialized.", {
|
|
1722
1728
|
F: __dxlog_file9,
|
|
1723
|
-
L:
|
|
1729
|
+
L: 281,
|
|
1724
1730
|
S: this,
|
|
1725
1731
|
A: [
|
|
1726
1732
|
"this.databaseHost",
|
|
@@ -1749,7 +1755,7 @@ var DataPipeline = class DataPipeline2 {
|
|
|
1749
1755
|
} catch (err) {
|
|
1750
1756
|
import_log8.log.warn("Failed to cache properties", err, {
|
|
1751
1757
|
F: __dxlog_file9,
|
|
1752
|
-
L:
|
|
1758
|
+
L: 310,
|
|
1753
1759
|
S: this,
|
|
1754
1760
|
C: (f, a) => f(...a)
|
|
1755
1761
|
});
|
|
@@ -1778,14 +1784,14 @@ var DataPipeline = class DataPipeline2 {
|
|
|
1778
1784
|
if (err instanceof import_protocols6.CancelledError) {
|
|
1779
1785
|
(0, import_log8.log)("Epoch processing cancelled.", void 0, {
|
|
1780
1786
|
F: __dxlog_file9,
|
|
1781
|
-
L:
|
|
1787
|
+
L: 346,
|
|
1782
1788
|
S: this,
|
|
1783
1789
|
C: (f, a) => f(...a)
|
|
1784
1790
|
});
|
|
1785
1791
|
} else {
|
|
1786
1792
|
import_log8.log.catch(err, void 0, {
|
|
1787
1793
|
F: __dxlog_file9,
|
|
1788
|
-
L:
|
|
1794
|
+
L: 348,
|
|
1789
1795
|
S: this,
|
|
1790
1796
|
C: (f, a) => f(...a)
|
|
1791
1797
|
});
|
|
@@ -1798,6 +1804,9 @@ var DataPipeline = class DataPipeline2 {
|
|
|
1798
1804
|
return;
|
|
1799
1805
|
}
|
|
1800
1806
|
await this._processEpoch(ctx, epoch.subject.assertion);
|
|
1807
|
+
if (epoch.subject.assertion.snapshotCid === void 0) {
|
|
1808
|
+
epoch.subject.assertion.snapshotCid = this.appliedEpoch?.subject.assertion.snapshotCid;
|
|
1809
|
+
}
|
|
1801
1810
|
this.appliedEpoch = epoch;
|
|
1802
1811
|
this.onNewEpoch.emit(epoch);
|
|
1803
1812
|
});
|
|
@@ -1805,7 +1814,7 @@ var DataPipeline = class DataPipeline2 {
|
|
|
1805
1814
|
async _processEpoch(ctx, epoch) {
|
|
1806
1815
|
(0, import_invariant8.invariant)(this._isOpen, "Space is closed.", {
|
|
1807
1816
|
F: __dxlog_file9,
|
|
1808
|
-
L:
|
|
1817
|
+
L: 372,
|
|
1809
1818
|
S: this,
|
|
1810
1819
|
A: [
|
|
1811
1820
|
"this._isOpen",
|
|
@@ -1814,7 +1823,7 @@ var DataPipeline = class DataPipeline2 {
|
|
|
1814
1823
|
});
|
|
1815
1824
|
(0, import_invariant8.invariant)(this._pipeline, void 0, {
|
|
1816
1825
|
F: __dxlog_file9,
|
|
1817
|
-
L:
|
|
1826
|
+
L: 373,
|
|
1818
1827
|
S: this,
|
|
1819
1828
|
A: [
|
|
1820
1829
|
"this._pipeline",
|
|
@@ -1826,7 +1835,7 @@ var DataPipeline = class DataPipeline2 {
|
|
|
1826
1835
|
epoch: (0, import_log8.omit)(epoch, "proof")
|
|
1827
1836
|
}, {
|
|
1828
1837
|
F: __dxlog_file9,
|
|
1829
|
-
L:
|
|
1838
|
+
L: 376,
|
|
1830
1839
|
S: this,
|
|
1831
1840
|
C: (f, a) => f(...a)
|
|
1832
1841
|
});
|
|
@@ -1836,7 +1845,7 @@ var DataPipeline = class DataPipeline2 {
|
|
|
1836
1845
|
}
|
|
1837
1846
|
(0, import_log8.log)("restarting pipeline from epoch", void 0, {
|
|
1838
1847
|
F: __dxlog_file9,
|
|
1839
|
-
L:
|
|
1848
|
+
L: 382,
|
|
1840
1849
|
S: this,
|
|
1841
1850
|
C: (f, a) => f(...a)
|
|
1842
1851
|
});
|
|
@@ -1847,7 +1856,7 @@ var DataPipeline = class DataPipeline2 {
|
|
|
1847
1856
|
async waitUntilTimeframe(timeframe) {
|
|
1848
1857
|
(0, import_invariant8.invariant)(this._pipeline, "Pipeline is not initialized.", {
|
|
1849
1858
|
F: __dxlog_file9,
|
|
1850
|
-
L:
|
|
1859
|
+
L: 389,
|
|
1851
1860
|
S: this,
|
|
1852
1861
|
A: [
|
|
1853
1862
|
"this._pipeline",
|
|
@@ -1859,7 +1868,7 @@ var DataPipeline = class DataPipeline2 {
|
|
|
1859
1868
|
async createEpoch() {
|
|
1860
1869
|
(0, import_invariant8.invariant)(this._pipeline, void 0, {
|
|
1861
1870
|
F: __dxlog_file9,
|
|
1862
|
-
L:
|
|
1871
|
+
L: 395,
|
|
1863
1872
|
S: this,
|
|
1864
1873
|
A: [
|
|
1865
1874
|
"this._pipeline",
|
|
@@ -1868,7 +1877,7 @@ var DataPipeline = class DataPipeline2 {
|
|
|
1868
1877
|
});
|
|
1869
1878
|
(0, import_invariant8.invariant)(this.currentEpoch, void 0, {
|
|
1870
1879
|
F: __dxlog_file9,
|
|
1871
|
-
L:
|
|
1880
|
+
L: 396,
|
|
1872
1881
|
S: this,
|
|
1873
1882
|
A: [
|
|
1874
1883
|
"this.currentEpoch",
|
|
@@ -1899,7 +1908,7 @@ var DataPipeline = class DataPipeline2 {
|
|
|
1899
1908
|
} catch (err) {
|
|
1900
1909
|
import_log8.log.catch(err, void 0, {
|
|
1901
1910
|
F: __dxlog_file9,
|
|
1902
|
-
L:
|
|
1911
|
+
L: 426,
|
|
1903
1912
|
S: this,
|
|
1904
1913
|
C: (f, a) => f(...a)
|
|
1905
1914
|
});
|
|
@@ -2465,6 +2474,7 @@ var SpaceProtocol = class {
|
|
|
2465
2474
|
constructor({ topic, swarmIdentity, networkManager, onSessionAuth, onAuthFailure, blobStore }) {
|
|
2466
2475
|
this._feeds = /* @__PURE__ */ new Set();
|
|
2467
2476
|
this._sessions = new import_util8.ComplexMap(import_keys6.PublicKey.hash);
|
|
2477
|
+
this._spaceKey = topic;
|
|
2468
2478
|
this._networkManager = networkManager;
|
|
2469
2479
|
this._swarmIdentity = swarmIdentity;
|
|
2470
2480
|
this._onSessionAuth = onSessionAuth;
|
|
@@ -2489,7 +2499,7 @@ var SpaceProtocol = class {
|
|
|
2489
2499
|
key: feed.key
|
|
2490
2500
|
}, {
|
|
2491
2501
|
F: __dxlog_file12,
|
|
2492
|
-
L:
|
|
2502
|
+
L: 99,
|
|
2493
2503
|
S: this,
|
|
2494
2504
|
C: (f, a) => f(...a)
|
|
2495
2505
|
});
|
|
@@ -2512,7 +2522,7 @@ var SpaceProtocol = class {
|
|
|
2512
2522
|
await this.blobSync.open();
|
|
2513
2523
|
(0, import_log11.log)("starting...", void 0, {
|
|
2514
2524
|
F: __dxlog_file12,
|
|
2515
|
-
L:
|
|
2525
|
+
L: 125,
|
|
2516
2526
|
S: this,
|
|
2517
2527
|
C: (f, a) => f(...a)
|
|
2518
2528
|
});
|
|
@@ -2522,11 +2532,11 @@ var SpaceProtocol = class {
|
|
|
2522
2532
|
peerId: this._swarmIdentity.peerKey,
|
|
2523
2533
|
topic,
|
|
2524
2534
|
topology: new import_network_manager.MMSTTopology(topologyConfig),
|
|
2525
|
-
label: `
|
|
2535
|
+
label: `swarm ${topic.truncate()} for space ${this._spaceKey.truncate()}`
|
|
2526
2536
|
});
|
|
2527
2537
|
(0, import_log11.log)("started", void 0, {
|
|
2528
2538
|
F: __dxlog_file12,
|
|
2529
|
-
L:
|
|
2539
|
+
L: 135,
|
|
2530
2540
|
S: this,
|
|
2531
2541
|
C: (f, a) => f(...a)
|
|
2532
2542
|
});
|
|
@@ -2536,14 +2546,14 @@ var SpaceProtocol = class {
|
|
|
2536
2546
|
if (this._connection) {
|
|
2537
2547
|
(0, import_log11.log)("stopping...", void 0, {
|
|
2538
2548
|
F: __dxlog_file12,
|
|
2539
|
-
L:
|
|
2549
|
+
L: 142,
|
|
2540
2550
|
S: this,
|
|
2541
2551
|
C: (f, a) => f(...a)
|
|
2542
2552
|
});
|
|
2543
2553
|
await this._connection.close();
|
|
2544
2554
|
(0, import_log11.log)("stopped", void 0, {
|
|
2545
2555
|
F: __dxlog_file12,
|
|
2546
|
-
L:
|
|
2556
|
+
L: 144,
|
|
2547
2557
|
S: this,
|
|
2548
2558
|
C: (f, a) => f(...a)
|
|
2549
2559
|
});
|
|
@@ -2601,15 +2611,15 @@ var SpaceProtocolSession = class {
|
|
|
2601
2611
|
get stream() {
|
|
2602
2612
|
return this._teleport.stream;
|
|
2603
2613
|
}
|
|
2604
|
-
async open() {
|
|
2605
|
-
await this._teleport.open();
|
|
2614
|
+
async open(sessionId) {
|
|
2615
|
+
await this._teleport.open(sessionId);
|
|
2606
2616
|
this._teleport.addExtension("dxos.mesh.teleport.auth", new AuthExtension({
|
|
2607
2617
|
provider: this._swarmIdentity.credentialProvider,
|
|
2608
2618
|
verifier: this._swarmIdentity.credentialAuthenticator,
|
|
2609
2619
|
onAuthSuccess: () => {
|
|
2610
2620
|
(0, import_log11.log)("Peer authenticated", void 0, {
|
|
2611
2621
|
F: __dxlog_file12,
|
|
2612
|
-
L:
|
|
2622
|
+
L: 241,
|
|
2613
2623
|
S: this,
|
|
2614
2624
|
C: (f, a) => f(...a)
|
|
2615
2625
|
});
|
|
@@ -2627,7 +2637,7 @@ var SpaceProtocolSession = class {
|
|
|
2627
2637
|
async close() {
|
|
2628
2638
|
(0, import_log11.log)("close", void 0, {
|
|
2629
2639
|
F: __dxlog_file12,
|
|
2630
|
-
L:
|
|
2640
|
+
L: 257,
|
|
2631
2641
|
S: this,
|
|
2632
2642
|
C: (f, a) => f(...a)
|
|
2633
2643
|
});
|
|
@@ -2735,10 +2745,166 @@ _ts_decorate8([
|
|
|
2735
2745
|
SpaceManager = _ts_decorate8([
|
|
2736
2746
|
(0, import_async9.trackLeaks)("open", "close")
|
|
2737
2747
|
], SpaceManager);
|
|
2748
|
+
var __dxlog_file14 = "/home/runner/work/dxos/dxos/packages/core/echo/echo-pipeline/src/automerge/automerge-host.ts";
|
|
2749
|
+
var AutomergeHost = class {
|
|
2750
|
+
constructor(storageDirectory) {
|
|
2751
|
+
this._meshNetwork = new MeshNetworkAdapter();
|
|
2752
|
+
this._clientNetwork = new LocalHostNetworkAdapter();
|
|
2753
|
+
this._storage = new AutomergeStorageAdapter(storageDirectory);
|
|
2754
|
+
this._repo = new import_automerge_repo.Repo({
|
|
2755
|
+
network: [
|
|
2756
|
+
// this._meshNetwork,
|
|
2757
|
+
this._clientNetwork
|
|
2758
|
+
],
|
|
2759
|
+
storage: this._storage,
|
|
2760
|
+
// TODO(dmaretskyi): Share based on HALO permissions and space affinity.
|
|
2761
|
+
sharePolicy: async (peerId, documentId) => true
|
|
2762
|
+
});
|
|
2763
|
+
}
|
|
2764
|
+
get repo() {
|
|
2765
|
+
return this._repo;
|
|
2766
|
+
}
|
|
2767
|
+
syncRepo(request) {
|
|
2768
|
+
return this._clientNetwork.syncRepo(request);
|
|
2769
|
+
}
|
|
2770
|
+
sendSyncMessage(request) {
|
|
2771
|
+
return this._clientNetwork.sendSyncMessage(request);
|
|
2772
|
+
}
|
|
2773
|
+
};
|
|
2774
|
+
var LocalHostNetworkAdapter = class extends import_automerge_repo.NetworkAdapter {
|
|
2775
|
+
constructor() {
|
|
2776
|
+
super();
|
|
2777
|
+
this._peers = /* @__PURE__ */ new Map();
|
|
2778
|
+
this.emit("ready", {
|
|
2779
|
+
network: this
|
|
2780
|
+
});
|
|
2781
|
+
}
|
|
2782
|
+
connect(peerId) {
|
|
2783
|
+
}
|
|
2784
|
+
send(message) {
|
|
2785
|
+
const peer = this._peers.get(message.targetId);
|
|
2786
|
+
(0, import_invariant10.invariant)(peer, "Peer not found.", {
|
|
2787
|
+
F: __dxlog_file14,
|
|
2788
|
+
L: 83,
|
|
2789
|
+
S: this,
|
|
2790
|
+
A: [
|
|
2791
|
+
"peer",
|
|
2792
|
+
"'Peer not found.'"
|
|
2793
|
+
]
|
|
2794
|
+
});
|
|
2795
|
+
peer.send(message);
|
|
2796
|
+
}
|
|
2797
|
+
disconnect() {
|
|
2798
|
+
throw new Error("Method not implemented.");
|
|
2799
|
+
}
|
|
2800
|
+
syncRepo({ id, syncMessage }) {
|
|
2801
|
+
const peerId = this._getPeerId(id);
|
|
2802
|
+
return new import_codec_protobuf2.Stream(({ next, close }) => {
|
|
2803
|
+
(0, import_invariant10.invariant)(!this._peers.has(peerId), "Peer already connected.", {
|
|
2804
|
+
F: __dxlog_file14,
|
|
2805
|
+
L: 95,
|
|
2806
|
+
S: this,
|
|
2807
|
+
A: [
|
|
2808
|
+
"!this._peers.has(peerId)",
|
|
2809
|
+
"'Peer already connected.'"
|
|
2810
|
+
]
|
|
2811
|
+
});
|
|
2812
|
+
this._peers.set(peerId, {
|
|
2813
|
+
connected: true,
|
|
2814
|
+
send: (message) => {
|
|
2815
|
+
next({
|
|
2816
|
+
syncMessage: import_automerge_repo.cbor.encode(message)
|
|
2817
|
+
});
|
|
2818
|
+
},
|
|
2819
|
+
disconnect: () => {
|
|
2820
|
+
this._peers.delete(peerId);
|
|
2821
|
+
close();
|
|
2822
|
+
this.emit("peer-disconnected", {
|
|
2823
|
+
peerId
|
|
2824
|
+
});
|
|
2825
|
+
}
|
|
2826
|
+
});
|
|
2827
|
+
this.emit("peer-candidate", {
|
|
2828
|
+
peerId
|
|
2829
|
+
});
|
|
2830
|
+
});
|
|
2831
|
+
}
|
|
2832
|
+
async sendSyncMessage({ id, syncMessage }) {
|
|
2833
|
+
const message = import_automerge_repo.cbor.decode(syncMessage);
|
|
2834
|
+
this.emit("message", message);
|
|
2835
|
+
}
|
|
2836
|
+
_getPeerId(id) {
|
|
2837
|
+
return id;
|
|
2838
|
+
}
|
|
2839
|
+
};
|
|
2840
|
+
var MeshNetworkAdapter = class extends import_automerge_repo.NetworkAdapter {
|
|
2841
|
+
connect(peerId) {
|
|
2842
|
+
throw new Error("Method not implemented.");
|
|
2843
|
+
}
|
|
2844
|
+
send(message) {
|
|
2845
|
+
throw new Error("Method not implemented.");
|
|
2846
|
+
}
|
|
2847
|
+
disconnect() {
|
|
2848
|
+
throw new Error("Method not implemented.");
|
|
2849
|
+
}
|
|
2850
|
+
};
|
|
2851
|
+
var AutomergeStorageAdapter = class extends import_automerge_repo.StorageAdapter {
|
|
2852
|
+
constructor(_directory) {
|
|
2853
|
+
super();
|
|
2854
|
+
this._directory = _directory;
|
|
2855
|
+
}
|
|
2856
|
+
async load(key) {
|
|
2857
|
+
const filename = this._getFilename(key);
|
|
2858
|
+
const file = this._directory.getOrCreateFile(filename);
|
|
2859
|
+
const { size } = await file.stat();
|
|
2860
|
+
const buffer = await file.read(0, size);
|
|
2861
|
+
return (0, import_util10.bufferToArray)(buffer);
|
|
2862
|
+
}
|
|
2863
|
+
async save(key, data) {
|
|
2864
|
+
const filename = this._getFilename(key);
|
|
2865
|
+
const file = this._directory.getOrCreateFile(filename);
|
|
2866
|
+
await file.write(0, (0, import_util10.arrayToBuffer)(data));
|
|
2867
|
+
await file.truncate?.(data.length);
|
|
2868
|
+
await file.flush?.();
|
|
2869
|
+
}
|
|
2870
|
+
async remove(key) {
|
|
2871
|
+
const filename = this._getFilename(key);
|
|
2872
|
+
const file = this._directory.getOrCreateFile(filename);
|
|
2873
|
+
await file.truncate?.(0);
|
|
2874
|
+
}
|
|
2875
|
+
async loadRange(keyPrefix) {
|
|
2876
|
+
const filename = this._getFilename(keyPrefix);
|
|
2877
|
+
const entries = await this._directory.list();
|
|
2878
|
+
return Promise.all(entries.filter((entry) => entry.startsWith(filename)).map(async (entry) => {
|
|
2879
|
+
const file = this._directory.getOrCreateFile(entry);
|
|
2880
|
+
const { size } = await file.stat();
|
|
2881
|
+
const buffer = await file.read(0, size);
|
|
2882
|
+
return {
|
|
2883
|
+
key: this._getKeyFromFilename(entry),
|
|
2884
|
+
data: (0, import_util10.bufferToArray)(buffer)
|
|
2885
|
+
};
|
|
2886
|
+
}));
|
|
2887
|
+
}
|
|
2888
|
+
async removeRange(keyPrefix) {
|
|
2889
|
+
const filename = this._getFilename(keyPrefix);
|
|
2890
|
+
const entries = await this._directory.list();
|
|
2891
|
+
await Promise.all(entries.filter((entry) => entry.startsWith(filename)).map(async (entry) => {
|
|
2892
|
+
const file = this._directory.getOrCreateFile(filename);
|
|
2893
|
+
await file.truncate?.(0);
|
|
2894
|
+
}));
|
|
2895
|
+
}
|
|
2896
|
+
_getFilename(key) {
|
|
2897
|
+
return key.map((k) => k.replaceAll("%", "%25").replaceAll("-", "%2D")).join("-");
|
|
2898
|
+
}
|
|
2899
|
+
_getKeyFromFilename(filename) {
|
|
2900
|
+
return filename.split("-").map((k) => k.replaceAll("%2D", "-").replaceAll("%25", "%"));
|
|
2901
|
+
}
|
|
2902
|
+
};
|
|
2738
2903
|
// Annotate the CommonJS export names for ESM import in node:
|
|
2739
2904
|
0 && (module.exports = {
|
|
2740
2905
|
AuthExtension,
|
|
2741
2906
|
AuthStatus,
|
|
2907
|
+
AutomergeHost,
|
|
2742
2908
|
DataPipeline,
|
|
2743
2909
|
DataServiceHost,
|
|
2744
2910
|
DataServiceImpl,
|
|
@@ -2762,4 +2928,4 @@ SpaceManager = _ts_decorate8([
|
|
|
2762
2928
|
startAfter,
|
|
2763
2929
|
valueEncoding
|
|
2764
2930
|
});
|
|
2765
|
-
//# sourceMappingURL=chunk-
|
|
2931
|
+
//# sourceMappingURL=chunk-XWUUSV4Y.cjs.map
|