@dxos/echo-pipeline 0.3.9-main.e4d8e16 → 0.3.9-main.eb5df3b
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-T627FAUD.mjs} +204 -31
- package/dist/lib/browser/chunk-T627FAUD.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-XWUUSV4Y.cjs} +198 -33
- 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/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/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_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_RMIDX4JE_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
|
});
|
|
@@ -2736,10 +2745,166 @@ _ts_decorate8([
|
|
|
2736
2745
|
SpaceManager = _ts_decorate8([
|
|
2737
2746
|
(0, import_async9.trackLeaks)("open", "close")
|
|
2738
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
|
+
};
|
|
2739
2903
|
// Annotate the CommonJS export names for ESM import in node:
|
|
2740
2904
|
0 && (module.exports = {
|
|
2741
2905
|
AuthExtension,
|
|
2742
2906
|
AuthStatus,
|
|
2907
|
+
AutomergeHost,
|
|
2743
2908
|
DataPipeline,
|
|
2744
2909
|
DataServiceHost,
|
|
2745
2910
|
DataServiceImpl,
|
|
@@ -2763,4 +2928,4 @@ SpaceManager = _ts_decorate8([
|
|
|
2763
2928
|
startAfter,
|
|
2764
2929
|
valueEncoding
|
|
2765
2930
|
});
|
|
2766
|
-
//# sourceMappingURL=chunk-
|
|
2931
|
+
//# sourceMappingURL=chunk-XWUUSV4Y.cjs.map
|