@dxos/echo-pipeline 0.4.8-next.fff1521 → 0.4.9-main.4fd47cd
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-3FVT6KX6.mjs → chunk-WAN2XUWE.mjs} +38 -698
- package/dist/lib/browser/chunk-WAN2XUWE.mjs.map +7 -0
- package/dist/lib/browser/index.mjs +633 -6
- package/dist/lib/browser/index.mjs.map +4 -4
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/testing/index.mjs +2 -274
- package/dist/lib/browser/testing/index.mjs.map +4 -4
- package/dist/lib/node/{chunk-WZ4WTAN6.cjs → chunk-U6J2HC4T.cjs} +39 -689
- package/dist/lib/node/chunk-U6J2HC4T.cjs.map +7 -0
- package/dist/lib/node/index.cjs +647 -30
- package/dist/lib/node/index.cjs.map +4 -4
- package/dist/lib/node/meta.json +1 -1
- package/dist/lib/node/testing/index.cjs +12 -282
- package/dist/lib/node/testing/index.cjs.map +4 -4
- package/dist/types/src/space/control-pipeline.d.ts.map +1 -1
- package/dist/types/src/space/data-pipeline.d.ts +0 -1
- package/dist/types/src/space/data-pipeline.d.ts.map +1 -1
- package/dist/types/src/testing/index.d.ts +0 -1
- package/dist/types/src/testing/index.d.ts.map +1 -1
- package/dist/types/src/testing/util.d.ts +2 -6
- package/dist/types/src/testing/util.d.ts.map +1 -1
- package/package.json +33 -33
- package/src/space/control-pipeline.ts +3 -1
- package/src/space/data-pipeline.ts +1 -44
- package/src/testing/index.ts +0 -1
- package/src/testing/util.ts +2 -26
- package/dist/lib/browser/chunk-3FVT6KX6.mjs.map +0 -7
- package/dist/lib/node/chunk-WZ4WTAN6.cjs.map +0 -7
- package/dist/types/src/testing/database-test-rig.d.ts +0 -67
- package/dist/types/src/testing/database-test-rig.d.ts.map +0 -1
- package/dist/types/src/tests/database.test.d.ts +0 -2
- package/dist/types/src/tests/database.test.d.ts.map +0 -1
- package/src/testing/database-test-rig.ts +0 -289
- package/src/tests/database.test.ts +0 -100
|
@@ -26,21 +26,17 @@ 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_U6J2HC4T_exports = {};
|
|
30
|
+
__export(chunk_U6J2HC4T_exports, {
|
|
31
31
|
AuthExtension: () => AuthExtension,
|
|
32
32
|
AuthStatus: () => AuthStatus,
|
|
33
|
-
AutomergeHost: () => AutomergeHost,
|
|
34
|
-
AutomergeStorageAdapter: () => AutomergeStorageAdapter,
|
|
35
33
|
DataPipeline: () => DataPipeline,
|
|
36
34
|
DataServiceHost: () => DataServiceHost,
|
|
37
35
|
DataServiceImpl: () => DataServiceImpl,
|
|
38
36
|
DataServiceSubscriptions: () => DataServiceSubscriptions,
|
|
39
37
|
DatabaseHost: () => DatabaseHost,
|
|
40
|
-
LocalHostNetworkAdapter: () => LocalHostNetworkAdapter,
|
|
41
38
|
MOCK_AUTH_PROVIDER: () => MOCK_AUTH_PROVIDER,
|
|
42
39
|
MOCK_AUTH_VERIFIER: () => MOCK_AUTH_VERIFIER,
|
|
43
|
-
MeshNetworkAdapter: () => MeshNetworkAdapter,
|
|
44
40
|
MetadataStore: () => MetadataStore,
|
|
45
41
|
Pipeline: () => Pipeline,
|
|
46
42
|
SnapshotManager: () => SnapshotManager,
|
|
@@ -52,13 +48,12 @@ __export(chunk_WZ4WTAN6_exports, {
|
|
|
52
48
|
TimeframeClock: () => TimeframeClock,
|
|
53
49
|
codec: () => codec,
|
|
54
50
|
createMappedFeedWriter: () => createMappedFeedWriter,
|
|
55
|
-
getSpaceKeyFromDoc: () => getSpaceKeyFromDoc,
|
|
56
51
|
mapFeedIndexesToTimeframe: () => mapFeedIndexesToTimeframe,
|
|
57
52
|
mapTimeframeToFeedIndexes: () => mapTimeframeToFeedIndexes,
|
|
58
53
|
startAfter: () => startAfter,
|
|
59
54
|
valueEncoding: () => valueEncoding
|
|
60
55
|
});
|
|
61
|
-
module.exports = __toCommonJS(
|
|
56
|
+
module.exports = __toCommonJS(chunk_U6J2HC4T_exports);
|
|
62
57
|
var import_hypercore = require("@dxos/hypercore");
|
|
63
58
|
var import_protocols = require("@dxos/protocols");
|
|
64
59
|
var import_invariant = require("@dxos/invariant");
|
|
@@ -153,27 +148,6 @@ var import_keys7 = require("@dxos/keys");
|
|
|
153
148
|
var import_log12 = require("@dxos/log");
|
|
154
149
|
var import_protocols7 = require("@dxos/protocols");
|
|
155
150
|
var import_util9 = require("@dxos/util");
|
|
156
|
-
var import_util10 = require("@dxos/util");
|
|
157
|
-
var import_async10 = require("@dxos/async");
|
|
158
|
-
var import_automerge_repo = require("@dxos/automerge/automerge-repo");
|
|
159
|
-
var import_codec_protobuf2 = require("@dxos/codec-protobuf");
|
|
160
|
-
var import_invariant10 = require("@dxos/invariant");
|
|
161
|
-
var import_log13 = require("@dxos/log");
|
|
162
|
-
var import_async11 = require("@dxos/async");
|
|
163
|
-
var import_automerge_repo2 = require("@dxos/automerge/automerge-repo");
|
|
164
|
-
var import_invariant11 = require("@dxos/invariant");
|
|
165
|
-
var import_log14 = require("@dxos/log");
|
|
166
|
-
var import_teleport_extension_automerge_replicator = require("@dxos/teleport-extension-automerge-replicator");
|
|
167
|
-
var import_automerge = require("@dxos/automerge/automerge");
|
|
168
|
-
var import_automerge_repo3 = require("@dxos/automerge/automerge-repo");
|
|
169
|
-
var import_automerge_repo_storage_indexeddb = require("@dxos/automerge/automerge-repo-storage-indexeddb");
|
|
170
|
-
var import_context8 = require("@dxos/context");
|
|
171
|
-
var import_keys8 = require("@dxos/keys");
|
|
172
|
-
var import_log15 = require("@dxos/log");
|
|
173
|
-
var import_protocols8 = require("@dxos/protocols");
|
|
174
|
-
var import_random_access_storage = require("@dxos/random-access-storage");
|
|
175
|
-
var import_tracing5 = require("@dxos/tracing");
|
|
176
|
-
var import_util11 = require("@dxos/util");
|
|
177
151
|
var codec = import_protocols.schema.getCodecForType("dxos.echo.feed.FeedMessage");
|
|
178
152
|
var valueEncoding = (0, import_hypercore.createCodecEncoding)(codec);
|
|
179
153
|
var __dxlog_file = "/home/runner/work/dxos/dxos/packages/core/echo/echo-pipeline/src/common/feeds.ts";
|
|
@@ -1578,8 +1552,6 @@ function _ts_decorate4(decorators, target, key, desc) {
|
|
|
1578
1552
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
1579
1553
|
}
|
|
1580
1554
|
var __dxlog_file9 = "/home/runner/work/dxos/dxos/packages/core/echo/echo-pipeline/src/space/data-pipeline.ts";
|
|
1581
|
-
var MESSAGES_PER_SNAPSHOT = 10;
|
|
1582
|
-
var AUTOMATIC_SNAPSHOT_DEBOUNCE_INTERVAL = 5e3;
|
|
1583
1555
|
var TIMEFRAME_SAVE_DEBOUNCE_INTERVAL = 5e3;
|
|
1584
1556
|
var DataPipeline = class {
|
|
1585
1557
|
constructor(_params) {
|
|
@@ -1635,7 +1607,7 @@ var DataPipeline = class {
|
|
|
1635
1607
|
write: (data, options) => {
|
|
1636
1608
|
(0, import_invariant8.invariant)(this._pipeline, "Pipeline is not initialized.", {
|
|
1637
1609
|
F: __dxlog_file9,
|
|
1638
|
-
L:
|
|
1610
|
+
L: 152,
|
|
1639
1611
|
S: this,
|
|
1640
1612
|
A: [
|
|
1641
1613
|
"this._pipeline",
|
|
@@ -1644,7 +1616,7 @@ var DataPipeline = class {
|
|
|
1644
1616
|
});
|
|
1645
1617
|
(0, import_invariant8.invariant)(this.currentEpoch, "Epoch is not initialized.", {
|
|
1646
1618
|
F: __dxlog_file9,
|
|
1647
|
-
L:
|
|
1619
|
+
L: 153,
|
|
1648
1620
|
S: this,
|
|
1649
1621
|
A: [
|
|
1650
1622
|
"this.currentEpoch",
|
|
@@ -1670,7 +1642,7 @@ var DataPipeline = class {
|
|
|
1670
1642
|
}
|
|
1671
1643
|
(0, import_log8.log)("close", void 0, {
|
|
1672
1644
|
F: __dxlog_file9,
|
|
1673
|
-
L:
|
|
1645
|
+
L: 177,
|
|
1674
1646
|
S: this,
|
|
1675
1647
|
C: (f, a) => f(...a)
|
|
1676
1648
|
});
|
|
@@ -1678,14 +1650,13 @@ var DataPipeline = class {
|
|
|
1678
1650
|
await this._ctx.dispose();
|
|
1679
1651
|
await this._pipeline?.stop();
|
|
1680
1652
|
try {
|
|
1681
|
-
await this._saveCache();
|
|
1682
1653
|
if (this._pipeline) {
|
|
1683
1654
|
await this._saveTargetTimeframe(this._pipeline.state.timeframe);
|
|
1684
1655
|
}
|
|
1685
1656
|
} catch (err) {
|
|
1686
1657
|
import_log8.log.catch(err, void 0, {
|
|
1687
1658
|
F: __dxlog_file9,
|
|
1688
|
-
L:
|
|
1659
|
+
L: 189,
|
|
1689
1660
|
S: this,
|
|
1690
1661
|
C: (f, a) => f(...a)
|
|
1691
1662
|
});
|
|
@@ -1711,7 +1682,7 @@ var DataPipeline = class {
|
|
|
1711
1682
|
let messageCounter = 0;
|
|
1712
1683
|
(0, import_invariant8.invariant)(pipeline, "Pipeline is not initialized.", {
|
|
1713
1684
|
F: __dxlog_file9,
|
|
1714
|
-
L:
|
|
1685
|
+
L: 216,
|
|
1715
1686
|
S: this,
|
|
1716
1687
|
A: [
|
|
1717
1688
|
"pipeline",
|
|
@@ -1727,7 +1698,7 @@ var DataPipeline = class {
|
|
|
1727
1698
|
seq
|
|
1728
1699
|
}, {
|
|
1729
1700
|
F: __dxlog_file9,
|
|
1730
|
-
L:
|
|
1701
|
+
L: 222,
|
|
1731
1702
|
S: this,
|
|
1732
1703
|
C: (f, a) => f(...a)
|
|
1733
1704
|
});
|
|
@@ -1739,7 +1710,7 @@ var DataPipeline = class {
|
|
|
1739
1710
|
feedKey
|
|
1740
1711
|
}, {
|
|
1741
1712
|
F: __dxlog_file9,
|
|
1742
|
-
L:
|
|
1713
|
+
L: 228,
|
|
1743
1714
|
S: this,
|
|
1744
1715
|
C: (f, a) => f(...a)
|
|
1745
1716
|
});
|
|
@@ -1762,7 +1733,7 @@ var DataPipeline = class {
|
|
|
1762
1733
|
spaceKey: this._params.spaceKey.toHex()
|
|
1763
1734
|
}, {
|
|
1764
1735
|
F: __dxlog_file9,
|
|
1765
|
-
L:
|
|
1736
|
+
L: 245,
|
|
1766
1737
|
S: this,
|
|
1767
1738
|
C: (f, a) => f(...a)
|
|
1768
1739
|
});
|
|
@@ -1771,7 +1742,7 @@ var DataPipeline = class {
|
|
|
1771
1742
|
} catch (err) {
|
|
1772
1743
|
import_log8.log.catch(err, void 0, {
|
|
1773
1744
|
F: __dxlog_file9,
|
|
1774
|
-
L:
|
|
1745
|
+
L: 255,
|
|
1775
1746
|
S: this,
|
|
1776
1747
|
C: (f, a) => f(...a)
|
|
1777
1748
|
});
|
|
@@ -1786,7 +1757,7 @@ var DataPipeline = class {
|
|
|
1786
1757
|
_createSnapshot() {
|
|
1787
1758
|
(0, import_invariant8.invariant)(this.databaseHost, "Database backend is not initialized.", {
|
|
1788
1759
|
F: __dxlog_file9,
|
|
1789
|
-
L:
|
|
1760
|
+
L: 269,
|
|
1790
1761
|
S: this,
|
|
1791
1762
|
A: [
|
|
1792
1763
|
"this.databaseHost",
|
|
@@ -1804,24 +1775,6 @@ var DataPipeline = class {
|
|
|
1804
1775
|
await this._params.metadataStore.setSpaceDataLatestTimeframe(this._params.spaceKey, newTimeframe);
|
|
1805
1776
|
this._targetTimeframe = newTimeframe;
|
|
1806
1777
|
}
|
|
1807
|
-
async _saveCache() {
|
|
1808
|
-
const cache = {};
|
|
1809
|
-
try {
|
|
1810
|
-
const propertiesItem = this.itemManager.items.find((item) => item.modelMeta?.type === "dxos.org/model/document" && // TODO(burdon): Document?
|
|
1811
|
-
((0, import_echo_db3.getStateMachineFromItem)(item)?.snapshot()).type === import_echo_db3.TYPE_PROPERTIES);
|
|
1812
|
-
if (propertiesItem) {
|
|
1813
|
-
cache.properties = (0, import_echo_db3.getStateMachineFromItem)(propertiesItem)?.snapshot();
|
|
1814
|
-
}
|
|
1815
|
-
} catch (err) {
|
|
1816
|
-
import_log8.log.warn("Failed to cache properties", err, {
|
|
1817
|
-
F: __dxlog_file9,
|
|
1818
|
-
L: 311,
|
|
1819
|
-
S: this,
|
|
1820
|
-
C: (f, a) => f(...a)
|
|
1821
|
-
});
|
|
1822
|
-
}
|
|
1823
|
-
await this._params.metadataStore.setCache(this._params.spaceKey, cache);
|
|
1824
|
-
}
|
|
1825
1778
|
async _noteTargetStateIfNeeded(timeframe) {
|
|
1826
1779
|
if (!this._pipeline?.state.reachedTarget) {
|
|
1827
1780
|
return;
|
|
@@ -1830,9 +1783,6 @@ var DataPipeline = class {
|
|
|
1830
1783
|
this._lastTimeframeSaveTime = Date.now();
|
|
1831
1784
|
await this._saveTargetTimeframe(timeframe);
|
|
1832
1785
|
}
|
|
1833
|
-
if (Date.now() - this._lastSnapshotSaveTime > AUTOMATIC_SNAPSHOT_DEBOUNCE_INTERVAL && timeframe.totalMessages() - this._lastAutomaticSnapshotTimeframe.totalMessages() > MESSAGES_PER_SNAPSHOT) {
|
|
1834
|
-
await this._saveCache();
|
|
1835
|
-
}
|
|
1836
1786
|
}
|
|
1837
1787
|
async _processEpochInSeparateTask(epoch) {
|
|
1838
1788
|
if (epoch.subject.assertion.number <= this._lastProcessedEpoch) {
|
|
@@ -1844,14 +1794,14 @@ var DataPipeline = class {
|
|
|
1844
1794
|
if (err instanceof import_protocols6.CancelledError) {
|
|
1845
1795
|
(0, import_log8.log)("Epoch processing cancelled.", void 0, {
|
|
1846
1796
|
F: __dxlog_file9,
|
|
1847
|
-
L:
|
|
1797
|
+
L: 305,
|
|
1848
1798
|
S: this,
|
|
1849
1799
|
C: (f, a) => f(...a)
|
|
1850
1800
|
});
|
|
1851
1801
|
} else {
|
|
1852
1802
|
import_log8.log.catch(err, void 0, {
|
|
1853
1803
|
F: __dxlog_file9,
|
|
1854
|
-
L:
|
|
1804
|
+
L: 307,
|
|
1855
1805
|
S: this,
|
|
1856
1806
|
C: (f, a) => f(...a)
|
|
1857
1807
|
});
|
|
@@ -1874,7 +1824,7 @@ var DataPipeline = class {
|
|
|
1874
1824
|
async _processEpoch(ctx, epoch) {
|
|
1875
1825
|
(0, import_invariant8.invariant)(this._isOpen, "Space is closed.", {
|
|
1876
1826
|
F: __dxlog_file9,
|
|
1877
|
-
L:
|
|
1827
|
+
L: 331,
|
|
1878
1828
|
S: this,
|
|
1879
1829
|
A: [
|
|
1880
1830
|
"this._isOpen",
|
|
@@ -1883,7 +1833,7 @@ var DataPipeline = class {
|
|
|
1883
1833
|
});
|
|
1884
1834
|
(0, import_invariant8.invariant)(this._pipeline, void 0, {
|
|
1885
1835
|
F: __dxlog_file9,
|
|
1886
|
-
L:
|
|
1836
|
+
L: 332,
|
|
1887
1837
|
S: this,
|
|
1888
1838
|
A: [
|
|
1889
1839
|
"this._pipeline",
|
|
@@ -1895,7 +1845,7 @@ var DataPipeline = class {
|
|
|
1895
1845
|
epoch: (0, import_log8.omit)(epoch, "proof")
|
|
1896
1846
|
}, {
|
|
1897
1847
|
F: __dxlog_file9,
|
|
1898
|
-
L:
|
|
1848
|
+
L: 335,
|
|
1899
1849
|
S: this,
|
|
1900
1850
|
C: (f, a) => f(...a)
|
|
1901
1851
|
});
|
|
@@ -1905,7 +1855,7 @@ var DataPipeline = class {
|
|
|
1905
1855
|
}
|
|
1906
1856
|
(0, import_log8.log)("restarting pipeline from epoch", void 0, {
|
|
1907
1857
|
F: __dxlog_file9,
|
|
1908
|
-
L:
|
|
1858
|
+
L: 341,
|
|
1909
1859
|
S: this,
|
|
1910
1860
|
C: (f, a) => f(...a)
|
|
1911
1861
|
});
|
|
@@ -1916,7 +1866,7 @@ var DataPipeline = class {
|
|
|
1916
1866
|
async waitUntilTimeframe(timeframe) {
|
|
1917
1867
|
(0, import_invariant8.invariant)(this._pipeline, "Pipeline is not initialized.", {
|
|
1918
1868
|
F: __dxlog_file9,
|
|
1919
|
-
L:
|
|
1869
|
+
L: 348,
|
|
1920
1870
|
S: this,
|
|
1921
1871
|
A: [
|
|
1922
1872
|
"this._pipeline",
|
|
@@ -1928,7 +1878,7 @@ var DataPipeline = class {
|
|
|
1928
1878
|
async createEpoch() {
|
|
1929
1879
|
(0, import_invariant8.invariant)(this._pipeline, void 0, {
|
|
1930
1880
|
F: __dxlog_file9,
|
|
1931
|
-
L:
|
|
1881
|
+
L: 354,
|
|
1932
1882
|
S: this,
|
|
1933
1883
|
A: [
|
|
1934
1884
|
"this._pipeline",
|
|
@@ -1937,7 +1887,7 @@ var DataPipeline = class {
|
|
|
1937
1887
|
});
|
|
1938
1888
|
(0, import_invariant8.invariant)(this.currentEpoch, void 0, {
|
|
1939
1889
|
F: __dxlog_file9,
|
|
1940
|
-
L:
|
|
1890
|
+
L: 355,
|
|
1941
1891
|
S: this,
|
|
1942
1892
|
A: [
|
|
1943
1893
|
"this.currentEpoch",
|
|
@@ -1961,14 +1911,13 @@ var DataPipeline = class {
|
|
|
1961
1911
|
}
|
|
1962
1912
|
async _flush() {
|
|
1963
1913
|
try {
|
|
1964
|
-
await this._saveCache();
|
|
1965
1914
|
if (this._pipeline) {
|
|
1966
1915
|
await this._saveTargetTimeframe(this._pipeline.state.timeframe);
|
|
1967
1916
|
}
|
|
1968
1917
|
} catch (err) {
|
|
1969
1918
|
import_log8.log.catch(err, void 0, {
|
|
1970
1919
|
F: __dxlog_file9,
|
|
1971
|
-
L:
|
|
1920
|
+
L: 384,
|
|
1972
1921
|
S: this,
|
|
1973
1922
|
C: (f, a) => f(...a)
|
|
1974
1923
|
});
|
|
@@ -2066,11 +2015,13 @@ var ControlPipeline = class {
|
|
|
2066
2015
|
queueMicrotask(async () => {
|
|
2067
2016
|
try {
|
|
2068
2017
|
const feed = await feedProvider(info.key);
|
|
2069
|
-
|
|
2018
|
+
if (!this._pipeline.hasFeed(feed.key)) {
|
|
2019
|
+
await this._pipeline.addFeed(feed);
|
|
2020
|
+
}
|
|
2070
2021
|
} catch (err) {
|
|
2071
2022
|
import_log10.log.catch(err, void 0, {
|
|
2072
2023
|
F: __dxlog_file10,
|
|
2073
|
-
L:
|
|
2024
|
+
L: 85,
|
|
2074
2025
|
S: this,
|
|
2075
2026
|
C: (f, a) => f(...a)
|
|
2076
2027
|
});
|
|
@@ -2100,7 +2051,7 @@ var ControlPipeline = class {
|
|
|
2100
2051
|
tf: snapshot?.timeframe
|
|
2101
2052
|
}, {
|
|
2102
2053
|
F: __dxlog_file10,
|
|
2103
|
-
L:
|
|
2054
|
+
L: 113,
|
|
2104
2055
|
S: this,
|
|
2105
2056
|
C: (f, a) => f(...a)
|
|
2106
2057
|
});
|
|
@@ -2109,7 +2060,7 @@ var ControlPipeline = class {
|
|
|
2109
2060
|
}
|
|
2110
2061
|
(0, import_log10.log)("starting...", void 0, {
|
|
2111
2062
|
F: __dxlog_file10,
|
|
2112
|
-
L:
|
|
2063
|
+
L: 118,
|
|
2113
2064
|
S: this,
|
|
2114
2065
|
C: (f, a) => f(...a)
|
|
2115
2066
|
});
|
|
@@ -2119,7 +2070,7 @@ var ControlPipeline = class {
|
|
|
2119
2070
|
await this._pipeline.start();
|
|
2120
2071
|
(0, import_log10.log)("started", void 0, {
|
|
2121
2072
|
F: __dxlog_file10,
|
|
2122
|
-
L:
|
|
2073
|
+
L: 124,
|
|
2123
2074
|
S: this,
|
|
2124
2075
|
C: (f, a) => f(...a)
|
|
2125
2076
|
});
|
|
@@ -2136,7 +2087,7 @@ var ControlPipeline = class {
|
|
|
2136
2087
|
message
|
|
2137
2088
|
}, {
|
|
2138
2089
|
F: __dxlog_file10,
|
|
2139
|
-
L:
|
|
2090
|
+
L: 137,
|
|
2140
2091
|
S: this,
|
|
2141
2092
|
C: (f, a) => f(...a)
|
|
2142
2093
|
});
|
|
@@ -2158,7 +2109,7 @@ var ControlPipeline = class {
|
|
|
2158
2109
|
snapshot
|
|
2159
2110
|
}, {
|
|
2160
2111
|
F: __dxlog_file10,
|
|
2161
|
-
L:
|
|
2112
|
+
L: 153,
|
|
2162
2113
|
S: this,
|
|
2163
2114
|
C: (f, a) => f(...a)
|
|
2164
2115
|
});
|
|
@@ -2173,7 +2124,7 @@ var ControlPipeline = class {
|
|
|
2173
2124
|
} catch (err) {
|
|
2174
2125
|
import_log10.log.catch(err, void 0, {
|
|
2175
2126
|
F: __dxlog_file10,
|
|
2176
|
-
L:
|
|
2127
|
+
L: 166,
|
|
2177
2128
|
S: this,
|
|
2178
2129
|
C: (f, a) => f(...a)
|
|
2179
2130
|
});
|
|
@@ -2187,7 +2138,7 @@ var ControlPipeline = class {
|
|
|
2187
2138
|
seq: msg.seq
|
|
2188
2139
|
}, {
|
|
2189
2140
|
F: __dxlog_file10,
|
|
2190
|
-
L:
|
|
2141
|
+
L: 176,
|
|
2191
2142
|
S: this,
|
|
2192
2143
|
C: (f, a) => f(...a)
|
|
2193
2144
|
});
|
|
@@ -2202,7 +2153,7 @@ var ControlPipeline = class {
|
|
|
2202
2153
|
msg
|
|
2203
2154
|
}, {
|
|
2204
2155
|
F: __dxlog_file10,
|
|
2205
|
-
L:
|
|
2156
|
+
L: 185,
|
|
2206
2157
|
S: this,
|
|
2207
2158
|
C: (f, a) => f(...a)
|
|
2208
2159
|
});
|
|
@@ -2221,7 +2172,7 @@ var ControlPipeline = class {
|
|
|
2221
2172
|
async stop() {
|
|
2222
2173
|
(0, import_log10.log)("stopping...", void 0, {
|
|
2223
2174
|
F: __dxlog_file10,
|
|
2224
|
-
L:
|
|
2175
|
+
L: 205,
|
|
2225
2176
|
S: this,
|
|
2226
2177
|
C: (f, a) => f(...a)
|
|
2227
2178
|
});
|
|
@@ -2230,7 +2181,7 @@ var ControlPipeline = class {
|
|
|
2230
2181
|
await this._saveTargetTimeframe(this._pipeline.state.timeframe);
|
|
2231
2182
|
(0, import_log10.log)("stopped", void 0, {
|
|
2232
2183
|
F: __dxlog_file10,
|
|
2233
|
-
L:
|
|
2184
|
+
L: 209,
|
|
2234
2185
|
S: this,
|
|
2235
2186
|
C: (f, a) => f(...a)
|
|
2236
2187
|
});
|
|
@@ -2243,7 +2194,7 @@ var ControlPipeline = class {
|
|
|
2243
2194
|
} catch (err) {
|
|
2244
2195
|
(0, import_log10.log)(err, void 0, {
|
|
2245
2196
|
F: __dxlog_file10,
|
|
2246
|
-
L:
|
|
2197
|
+
L: 218,
|
|
2247
2198
|
S: this,
|
|
2248
2199
|
C: (f, a) => f(...a)
|
|
2249
2200
|
});
|
|
@@ -2823,617 +2774,17 @@ _ts_decorate8([
|
|
|
2823
2774
|
SpaceManager = _ts_decorate8([
|
|
2824
2775
|
(0, import_async9.trackLeaks)("open", "close")
|
|
2825
2776
|
], SpaceManager);
|
|
2826
|
-
var AutomergeStorageAdapter = class {
|
|
2827
|
-
constructor(_directory) {
|
|
2828
|
-
this._directory = _directory;
|
|
2829
|
-
this._state = "opened";
|
|
2830
|
-
}
|
|
2831
|
-
async load(key) {
|
|
2832
|
-
if (this._state !== "opened") {
|
|
2833
|
-
return void 0;
|
|
2834
|
-
}
|
|
2835
|
-
const filename = this._getFilename(key);
|
|
2836
|
-
const file = this._directory.getOrCreateFile(filename);
|
|
2837
|
-
const { size } = await file.stat();
|
|
2838
|
-
if (!size || size === 0) {
|
|
2839
|
-
return void 0;
|
|
2840
|
-
}
|
|
2841
|
-
const buffer = await file.read(0, size);
|
|
2842
|
-
return (0, import_util10.bufferToArray)(buffer);
|
|
2843
|
-
}
|
|
2844
|
-
async save(key, data) {
|
|
2845
|
-
if (this._state !== "opened") {
|
|
2846
|
-
return void 0;
|
|
2847
|
-
}
|
|
2848
|
-
const filename = this._getFilename(key);
|
|
2849
|
-
const file = this._directory.getOrCreateFile(filename);
|
|
2850
|
-
await file.write(0, (0, import_util10.arrayToBuffer)(data));
|
|
2851
|
-
await file.truncate?.(data.length);
|
|
2852
|
-
await file.flush?.();
|
|
2853
|
-
}
|
|
2854
|
-
async remove(key) {
|
|
2855
|
-
if (this._state !== "opened") {
|
|
2856
|
-
return void 0;
|
|
2857
|
-
}
|
|
2858
|
-
const filename = this._getFilename(key);
|
|
2859
|
-
const file = this._directory.getOrCreateFile(filename);
|
|
2860
|
-
await file.destroy();
|
|
2861
|
-
}
|
|
2862
|
-
async loadRange(keyPrefix) {
|
|
2863
|
-
if (this._state !== "opened") {
|
|
2864
|
-
return [];
|
|
2865
|
-
}
|
|
2866
|
-
const filename = this._getFilename(keyPrefix);
|
|
2867
|
-
const entries = await this._directory.list();
|
|
2868
|
-
return Promise.all(entries.filter((entry) => entry.startsWith(filename)).map(async (entry) => {
|
|
2869
|
-
const file = this._directory.getOrCreateFile(entry);
|
|
2870
|
-
const { size } = await file.stat();
|
|
2871
|
-
const buffer = await file.read(0, size);
|
|
2872
|
-
return {
|
|
2873
|
-
key: this._getKeyFromFilename(entry),
|
|
2874
|
-
data: (0, import_util10.bufferToArray)(buffer)
|
|
2875
|
-
};
|
|
2876
|
-
}));
|
|
2877
|
-
}
|
|
2878
|
-
async removeRange(keyPrefix) {
|
|
2879
|
-
if (this._state !== "opened") {
|
|
2880
|
-
return void 0;
|
|
2881
|
-
}
|
|
2882
|
-
const filename = this._getFilename(keyPrefix);
|
|
2883
|
-
const entries = await this._directory.list();
|
|
2884
|
-
await Promise.all(entries.filter((entry) => entry.startsWith(filename)).map(async (entry) => {
|
|
2885
|
-
const file = this._directory.getOrCreateFile(entry);
|
|
2886
|
-
await file.destroy();
|
|
2887
|
-
}));
|
|
2888
|
-
}
|
|
2889
|
-
async close() {
|
|
2890
|
-
this._state = "closed";
|
|
2891
|
-
}
|
|
2892
|
-
_getFilename(key) {
|
|
2893
|
-
return key.map((k) => k.replaceAll("%", "%25").replaceAll("-", "%2D")).join("-");
|
|
2894
|
-
}
|
|
2895
|
-
_getKeyFromFilename(filename) {
|
|
2896
|
-
return filename.split("-").map((k) => k.replaceAll("%2D", "-").replaceAll("%25", "%"));
|
|
2897
|
-
}
|
|
2898
|
-
};
|
|
2899
|
-
var __dxlog_file14 = "/home/runner/work/dxos/dxos/packages/core/echo/echo-pipeline/src/automerge/local-host-network-adapter.ts";
|
|
2900
|
-
var LocalHostNetworkAdapter = class extends import_automerge_repo.NetworkAdapter {
|
|
2901
|
-
constructor() {
|
|
2902
|
-
super(...arguments);
|
|
2903
|
-
this._peers = /* @__PURE__ */ new Map();
|
|
2904
|
-
this._connected = new import_async10.Trigger();
|
|
2905
|
-
}
|
|
2906
|
-
/**
|
|
2907
|
-
* Emits `ready` event. That signals to `Repo` that it can start using the adapter.
|
|
2908
|
-
*/
|
|
2909
|
-
ready() {
|
|
2910
|
-
this.emit("ready", {
|
|
2911
|
-
network: this
|
|
2912
|
-
});
|
|
2913
|
-
}
|
|
2914
|
-
connect(peerId) {
|
|
2915
|
-
this.peerId = peerId;
|
|
2916
|
-
this._connected.wake();
|
|
2917
|
-
}
|
|
2918
|
-
send(message) {
|
|
2919
|
-
const peer = this._peers.get(message.targetId);
|
|
2920
|
-
(0, import_invariant10.invariant)(peer, "Peer not found.", {
|
|
2921
|
-
F: __dxlog_file14,
|
|
2922
|
-
L: 45,
|
|
2923
|
-
S: this,
|
|
2924
|
-
A: [
|
|
2925
|
-
"peer",
|
|
2926
|
-
"'Peer not found.'"
|
|
2927
|
-
]
|
|
2928
|
-
});
|
|
2929
|
-
peer.send(message);
|
|
2930
|
-
}
|
|
2931
|
-
async close() {
|
|
2932
|
-
this._peers.forEach((peer) => peer.disconnect());
|
|
2933
|
-
this.emit("close");
|
|
2934
|
-
}
|
|
2935
|
-
disconnect() {
|
|
2936
|
-
}
|
|
2937
|
-
syncRepo({ id, syncMessage }) {
|
|
2938
|
-
const peerId = this._getPeerId(id);
|
|
2939
|
-
return new import_codec_protobuf2.Stream(({ next, close }) => {
|
|
2940
|
-
(0, import_invariant10.invariant)(!this._peers.has(peerId), "Peer already connected.", {
|
|
2941
|
-
F: __dxlog_file14,
|
|
2942
|
-
L: 63,
|
|
2943
|
-
S: this,
|
|
2944
|
-
A: [
|
|
2945
|
-
"!this._peers.has(peerId)",
|
|
2946
|
-
"'Peer already connected.'"
|
|
2947
|
-
]
|
|
2948
|
-
});
|
|
2949
|
-
this._peers.set(peerId, {
|
|
2950
|
-
connected: true,
|
|
2951
|
-
send: (message) => {
|
|
2952
|
-
next({
|
|
2953
|
-
syncMessage: import_automerge_repo.cbor.encode(message)
|
|
2954
|
-
});
|
|
2955
|
-
},
|
|
2956
|
-
disconnect: () => {
|
|
2957
|
-
this._peers.delete(peerId);
|
|
2958
|
-
close();
|
|
2959
|
-
this.emit("peer-disconnected", {
|
|
2960
|
-
peerId
|
|
2961
|
-
});
|
|
2962
|
-
}
|
|
2963
|
-
});
|
|
2964
|
-
this._connected.wait({
|
|
2965
|
-
timeout: 1e3
|
|
2966
|
-
}).then(() => {
|
|
2967
|
-
this.emit("peer-candidate", {
|
|
2968
|
-
peerMetadata: {},
|
|
2969
|
-
peerId
|
|
2970
|
-
});
|
|
2971
|
-
}).catch((err) => import_log13.log.catch(err, void 0, {
|
|
2972
|
-
F: __dxlog_file14,
|
|
2973
|
-
L: 88,
|
|
2974
|
-
S: this,
|
|
2975
|
-
C: (f, a) => f(...a)
|
|
2976
|
-
}));
|
|
2977
|
-
});
|
|
2978
|
-
}
|
|
2979
|
-
async sendSyncMessage({ id, syncMessage }) {
|
|
2980
|
-
await this._connected.wait({
|
|
2981
|
-
timeout: 1e3
|
|
2982
|
-
});
|
|
2983
|
-
const message = import_automerge_repo.cbor.decode(syncMessage);
|
|
2984
|
-
this.emit("message", message);
|
|
2985
|
-
}
|
|
2986
|
-
async getHostInfo() {
|
|
2987
|
-
await this._connected.wait({
|
|
2988
|
-
timeout: 1e3
|
|
2989
|
-
});
|
|
2990
|
-
(0, import_invariant10.invariant)(this.peerId, "Peer id not set.", {
|
|
2991
|
-
F: __dxlog_file14,
|
|
2992
|
-
L: 100,
|
|
2993
|
-
S: this,
|
|
2994
|
-
A: [
|
|
2995
|
-
"this.peerId",
|
|
2996
|
-
"'Peer id not set.'"
|
|
2997
|
-
]
|
|
2998
|
-
});
|
|
2999
|
-
return {
|
|
3000
|
-
peerId: this.peerId
|
|
3001
|
-
};
|
|
3002
|
-
}
|
|
3003
|
-
_getPeerId(id) {
|
|
3004
|
-
return id;
|
|
3005
|
-
}
|
|
3006
|
-
};
|
|
3007
|
-
var __dxlog_file15 = "/home/runner/work/dxos/dxos/packages/core/echo/echo-pipeline/src/automerge/mesh-network-adapter.ts";
|
|
3008
|
-
var MeshNetworkAdapter = class extends import_automerge_repo2.NetworkAdapter {
|
|
3009
|
-
constructor() {
|
|
3010
|
-
super(...arguments);
|
|
3011
|
-
this._extensions = /* @__PURE__ */ new Map();
|
|
3012
|
-
this._connected = new import_async11.Trigger();
|
|
3013
|
-
}
|
|
3014
|
-
/**
|
|
3015
|
-
* Emits `ready` event. That signals to `Repo` that it can start using the adapter.
|
|
3016
|
-
*/
|
|
3017
|
-
ready() {
|
|
3018
|
-
this.emit("ready", {
|
|
3019
|
-
network: this
|
|
3020
|
-
});
|
|
3021
|
-
}
|
|
3022
|
-
connect(peerId) {
|
|
3023
|
-
this.peerId = peerId;
|
|
3024
|
-
this._connected.wake();
|
|
3025
|
-
}
|
|
3026
|
-
send(message) {
|
|
3027
|
-
const receiverId = message.targetId;
|
|
3028
|
-
const extension = this._extensions.get(receiverId);
|
|
3029
|
-
(0, import_invariant11.invariant)(extension, "Extension not found.", {
|
|
3030
|
-
F: __dxlog_file15,
|
|
3031
|
-
L: 38,
|
|
3032
|
-
S: this,
|
|
3033
|
-
A: [
|
|
3034
|
-
"extension",
|
|
3035
|
-
"'Extension not found.'"
|
|
3036
|
-
]
|
|
3037
|
-
});
|
|
3038
|
-
extension.sendSyncMessage({
|
|
3039
|
-
payload: import_automerge_repo2.cbor.encode(message)
|
|
3040
|
-
}).catch((err) => import_log14.log.catch(err, void 0, {
|
|
3041
|
-
F: __dxlog_file15,
|
|
3042
|
-
L: 39,
|
|
3043
|
-
S: this,
|
|
3044
|
-
C: (f, a) => f(...a)
|
|
3045
|
-
}));
|
|
3046
|
-
}
|
|
3047
|
-
disconnect() {
|
|
3048
|
-
}
|
|
3049
|
-
createExtension() {
|
|
3050
|
-
(0, import_invariant11.invariant)(this.peerId, "Peer id not set.", {
|
|
3051
|
-
F: __dxlog_file15,
|
|
3052
|
-
L: 47,
|
|
3053
|
-
S: this,
|
|
3054
|
-
A: [
|
|
3055
|
-
"this.peerId",
|
|
3056
|
-
"'Peer id not set.'"
|
|
3057
|
-
]
|
|
3058
|
-
});
|
|
3059
|
-
let peerInfo;
|
|
3060
|
-
const extension = new import_teleport_extension_automerge_replicator.AutomergeReplicator({
|
|
3061
|
-
peerId: this.peerId
|
|
3062
|
-
}, {
|
|
3063
|
-
onStartReplication: async (info, remotePeerId) => {
|
|
3064
|
-
await this._connected.wait();
|
|
3065
|
-
(0, import_log14.log)("onStartReplication", {
|
|
3066
|
-
id: info.id,
|
|
3067
|
-
thisPeerId: this.peerId,
|
|
3068
|
-
remotePeerId: remotePeerId.toHex()
|
|
3069
|
-
}, {
|
|
3070
|
-
F: __dxlog_file15,
|
|
3071
|
-
L: 70,
|
|
3072
|
-
S: this,
|
|
3073
|
-
C: (f, a) => f(...a)
|
|
3074
|
-
});
|
|
3075
|
-
if (!this._extensions.has(info.id)) {
|
|
3076
|
-
peerInfo = info;
|
|
3077
|
-
this._extensions.set(info.id, extension);
|
|
3078
|
-
(0, import_log14.log)("peer-candidate", {
|
|
3079
|
-
id: info.id,
|
|
3080
|
-
thisPeerId: this.peerId,
|
|
3081
|
-
remotePeerId: remotePeerId.toHex()
|
|
3082
|
-
}, {
|
|
3083
|
-
F: __dxlog_file15,
|
|
3084
|
-
L: 76,
|
|
3085
|
-
S: this,
|
|
3086
|
-
C: (f, a) => f(...a)
|
|
3087
|
-
});
|
|
3088
|
-
this.emit("peer-candidate", {
|
|
3089
|
-
// TODO(mykola): Hack, stop abusing `peerMetadata` field.
|
|
3090
|
-
peerMetadata: {
|
|
3091
|
-
dxos_deviceKey: remotePeerId.toHex()
|
|
3092
|
-
},
|
|
3093
|
-
peerId: info.id
|
|
3094
|
-
});
|
|
3095
|
-
}
|
|
3096
|
-
},
|
|
3097
|
-
onSyncMessage: async ({ payload }) => {
|
|
3098
|
-
if (!peerInfo) {
|
|
3099
|
-
return;
|
|
3100
|
-
}
|
|
3101
|
-
const message = import_automerge_repo2.cbor.decode(payload);
|
|
3102
|
-
this.emit("message", message);
|
|
3103
|
-
},
|
|
3104
|
-
onClose: async () => {
|
|
3105
|
-
if (!peerInfo) {
|
|
3106
|
-
return;
|
|
3107
|
-
}
|
|
3108
|
-
this.emit("peer-disconnected", {
|
|
3109
|
-
peerId: peerInfo.id
|
|
3110
|
-
});
|
|
3111
|
-
this._extensions.delete(peerInfo.id);
|
|
3112
|
-
}
|
|
3113
|
-
});
|
|
3114
|
-
return extension;
|
|
3115
|
-
}
|
|
3116
|
-
};
|
|
3117
|
-
var AutomergeStorageWrapper = class {
|
|
3118
|
-
constructor({ storage, callbacks }) {
|
|
3119
|
-
this._storage = storage;
|
|
3120
|
-
this._callbacks = callbacks;
|
|
3121
|
-
}
|
|
3122
|
-
async load(key) {
|
|
3123
|
-
return this._storage.load(key);
|
|
3124
|
-
}
|
|
3125
|
-
async save(key, value) {
|
|
3126
|
-
await this._callbacks.beforeSave?.(key);
|
|
3127
|
-
await this._storage.save(key, value);
|
|
3128
|
-
await this._callbacks.afterSave?.(key);
|
|
3129
|
-
}
|
|
3130
|
-
async remove(key) {
|
|
3131
|
-
return this._storage.remove(key);
|
|
3132
|
-
}
|
|
3133
|
-
async loadRange(keyPrefix) {
|
|
3134
|
-
return this._storage.loadRange(keyPrefix);
|
|
3135
|
-
}
|
|
3136
|
-
async removeRange(keyPrefix) {
|
|
3137
|
-
return this._storage.removeRange(keyPrefix);
|
|
3138
|
-
}
|
|
3139
|
-
async close() {
|
|
3140
|
-
if (this._storage instanceof AutomergeStorageAdapter) {
|
|
3141
|
-
return this._storage.close();
|
|
3142
|
-
}
|
|
3143
|
-
}
|
|
3144
|
-
};
|
|
3145
|
-
function _ts_decorate9(decorators, target, key, desc) {
|
|
3146
|
-
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3147
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
|
|
3148
|
-
r = Reflect.decorate(decorators, target, key, desc);
|
|
3149
|
-
else
|
|
3150
|
-
for (var i = decorators.length - 1; i >= 0; i--)
|
|
3151
|
-
if (d = decorators[i])
|
|
3152
|
-
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
3153
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
3154
|
-
}
|
|
3155
|
-
var __dxlog_file16 = "/home/runner/work/dxos/dxos/packages/core/echo/echo-pipeline/src/automerge/automerge-host.ts";
|
|
3156
|
-
var AutomergeHost = class {
|
|
3157
|
-
constructor({ directory, metadata }) {
|
|
3158
|
-
this._ctx = new import_context8.Context();
|
|
3159
|
-
this._authorizedDevices = new import_util11.ComplexMap(import_keys8.PublicKey.hash);
|
|
3160
|
-
this._updatingMetadata = /* @__PURE__ */ new Map();
|
|
3161
|
-
this._requestedDocs = /* @__PURE__ */ new Set();
|
|
3162
|
-
this._metadata = metadata;
|
|
3163
|
-
this._meshNetwork = new MeshNetworkAdapter();
|
|
3164
|
-
this._clientNetwork = new LocalHostNetworkAdapter();
|
|
3165
|
-
this._storage = new AutomergeStorageWrapper({
|
|
3166
|
-
storage: (
|
|
3167
|
-
// TODO(mykola): Delete specific handling of IDB storage.
|
|
3168
|
-
directory.type === import_random_access_storage.StorageType.IDB ? new import_automerge_repo_storage_indexeddb.IndexedDBStorageAdapter(directory.path, "data") : new AutomergeStorageAdapter(directory)
|
|
3169
|
-
),
|
|
3170
|
-
callbacks: {
|
|
3171
|
-
beforeSave: (params) => this._beforeSave(params)
|
|
3172
|
-
}
|
|
3173
|
-
});
|
|
3174
|
-
this._peerId = `host-${import_keys8.PublicKey.random().toHex()}`;
|
|
3175
|
-
this._repo = new import_automerge_repo3.Repo({
|
|
3176
|
-
peerId: this._peerId,
|
|
3177
|
-
network: [
|
|
3178
|
-
this._clientNetwork,
|
|
3179
|
-
this._meshNetwork
|
|
3180
|
-
],
|
|
3181
|
-
storage: this._storage,
|
|
3182
|
-
// TODO(dmaretskyi): Share based on HALO permissions and space affinity.
|
|
3183
|
-
// Hosts, running in the worker, don't share documents unless requested by other peers.
|
|
3184
|
-
sharePolicy: async (peerId, documentId) => {
|
|
3185
|
-
if (peerId.startsWith("client-")) {
|
|
3186
|
-
return false;
|
|
3187
|
-
}
|
|
3188
|
-
if (!documentId) {
|
|
3189
|
-
return false;
|
|
3190
|
-
}
|
|
3191
|
-
const doc = this._repo.handles[documentId]?.docSync();
|
|
3192
|
-
if (!doc) {
|
|
3193
|
-
const isRequested = this._requestedDocs.has(`automerge:${documentId}`);
|
|
3194
|
-
(0, import_log15.log)("doc share policy check", {
|
|
3195
|
-
peerId,
|
|
3196
|
-
documentId,
|
|
3197
|
-
isRequested
|
|
3198
|
-
}, {
|
|
3199
|
-
F: __dxlog_file16,
|
|
3200
|
-
L: 96,
|
|
3201
|
-
S: this,
|
|
3202
|
-
C: (f, a) => f(...a)
|
|
3203
|
-
});
|
|
3204
|
-
return isRequested;
|
|
3205
|
-
}
|
|
3206
|
-
try {
|
|
3207
|
-
const spaceKey = getSpaceKeyFromDoc(doc);
|
|
3208
|
-
if (!spaceKey) {
|
|
3209
|
-
(0, import_log15.log)("space key not found for share policy check", {
|
|
3210
|
-
peerId,
|
|
3211
|
-
documentId
|
|
3212
|
-
}, {
|
|
3213
|
-
F: __dxlog_file16,
|
|
3214
|
-
L: 103,
|
|
3215
|
-
S: this,
|
|
3216
|
-
C: (f, a) => f(...a)
|
|
3217
|
-
});
|
|
3218
|
-
return false;
|
|
3219
|
-
}
|
|
3220
|
-
const authorizedDevices = this._authorizedDevices.get(import_keys8.PublicKey.from(spaceKey));
|
|
3221
|
-
const deviceKeyHex = this.repo.peerMetadataByPeerId[peerId]?.dxos_deviceKey;
|
|
3222
|
-
if (!deviceKeyHex) {
|
|
3223
|
-
(0, import_log15.log)("device key not found for share policy check", {
|
|
3224
|
-
peerId,
|
|
3225
|
-
documentId
|
|
3226
|
-
}, {
|
|
3227
|
-
F: __dxlog_file16,
|
|
3228
|
-
L: 112,
|
|
3229
|
-
S: this,
|
|
3230
|
-
C: (f, a) => f(...a)
|
|
3231
|
-
});
|
|
3232
|
-
return false;
|
|
3233
|
-
}
|
|
3234
|
-
const deviceKey = import_keys8.PublicKey.from(deviceKeyHex);
|
|
3235
|
-
const isAuthorized = authorizedDevices?.has(deviceKey) ?? false;
|
|
3236
|
-
(0, import_log15.log)("share policy check", {
|
|
3237
|
-
localPeer: this._peerId,
|
|
3238
|
-
remotePeer: peerId,
|
|
3239
|
-
documentId,
|
|
3240
|
-
deviceKey,
|
|
3241
|
-
spaceKey,
|
|
3242
|
-
isAuthorized
|
|
3243
|
-
}, {
|
|
3244
|
-
F: __dxlog_file16,
|
|
3245
|
-
L: 118,
|
|
3246
|
-
S: this,
|
|
3247
|
-
C: (f, a) => f(...a)
|
|
3248
|
-
});
|
|
3249
|
-
return isAuthorized;
|
|
3250
|
-
} catch (err) {
|
|
3251
|
-
import_log15.log.catch(err, void 0, {
|
|
3252
|
-
F: __dxlog_file16,
|
|
3253
|
-
L: 128,
|
|
3254
|
-
S: this,
|
|
3255
|
-
C: (f, a) => f(...a)
|
|
3256
|
-
});
|
|
3257
|
-
return false;
|
|
3258
|
-
}
|
|
3259
|
-
}
|
|
3260
|
-
});
|
|
3261
|
-
this._clientNetwork.ready();
|
|
3262
|
-
this._meshNetwork.ready();
|
|
3263
|
-
{
|
|
3264
|
-
const listener = ({ handle }) => this._onDocument(handle);
|
|
3265
|
-
this._repo.on("document", listener);
|
|
3266
|
-
this._ctx.onDispose(() => {
|
|
3267
|
-
this._repo.off("document", listener);
|
|
3268
|
-
});
|
|
3269
|
-
}
|
|
3270
|
-
}
|
|
3271
|
-
get repo() {
|
|
3272
|
-
return this._repo;
|
|
3273
|
-
}
|
|
3274
|
-
async _beforeSave(path) {
|
|
3275
|
-
const id = path[0];
|
|
3276
|
-
if (this._updatingMetadata.has(id)) {
|
|
3277
|
-
return this._updatingMetadata.get(id);
|
|
3278
|
-
}
|
|
3279
|
-
}
|
|
3280
|
-
_onDocument(handle) {
|
|
3281
|
-
const listener = (event) => this._onUpdate(event);
|
|
3282
|
-
handle.on("change", listener);
|
|
3283
|
-
this._ctx.onDispose(() => {
|
|
3284
|
-
handle.off("change", listener);
|
|
3285
|
-
});
|
|
3286
|
-
}
|
|
3287
|
-
_onUpdate(event) {
|
|
3288
|
-
if (this._metadata == null) {
|
|
3289
|
-
return;
|
|
3290
|
-
}
|
|
3291
|
-
const objectIds = getInlineChanges(event);
|
|
3292
|
-
if (objectIds.length === 0) {
|
|
3293
|
-
return;
|
|
3294
|
-
}
|
|
3295
|
-
const heads = (0, import_automerge.getHeads)(event.doc);
|
|
3296
|
-
const lastAvailableHash = heads.at(-1);
|
|
3297
|
-
if (!lastAvailableHash) {
|
|
3298
|
-
return;
|
|
3299
|
-
}
|
|
3300
|
-
const encodedIds = objectIds.map((objectId) => import_protocols8.idCodec.encode({
|
|
3301
|
-
documentId: event.handle.documentId,
|
|
3302
|
-
objectId
|
|
3303
|
-
}));
|
|
3304
|
-
const idToLastHash = new Map(encodedIds.map((id) => [
|
|
3305
|
-
id,
|
|
3306
|
-
lastAvailableHash
|
|
3307
|
-
]));
|
|
3308
|
-
const markingDirtyPromise = this._metadata.markDirty(idToLastHash).then(() => {
|
|
3309
|
-
this._updatingMetadata.delete(event.handle.documentId);
|
|
3310
|
-
}).catch((err) => {
|
|
3311
|
-
this._ctx.disposed && import_log15.log.catch(err, void 0, {
|
|
3312
|
-
F: __dxlog_file16,
|
|
3313
|
-
L: 188,
|
|
3314
|
-
S: this,
|
|
3315
|
-
C: (f, a) => f(...a)
|
|
3316
|
-
});
|
|
3317
|
-
});
|
|
3318
|
-
this._updatingMetadata.set(event.handle.documentId, markingDirtyPromise);
|
|
3319
|
-
}
|
|
3320
|
-
_automergeDocs() {
|
|
3321
|
-
return (0, import_util11.mapValues)(this._repo.handles, (handle) => ({
|
|
3322
|
-
state: handle.state,
|
|
3323
|
-
hasDoc: !!handle.docSync(),
|
|
3324
|
-
heads: handle.docSync() ? import_automerge.next.getHeads(handle.docSync()) : null,
|
|
3325
|
-
data: handle.docSync()?.doc && (0, import_util11.mapValues)(handle.docSync()?.doc, (value, key) => {
|
|
3326
|
-
try {
|
|
3327
|
-
switch (key) {
|
|
3328
|
-
case "access":
|
|
3329
|
-
case "links":
|
|
3330
|
-
return value;
|
|
3331
|
-
case "objects":
|
|
3332
|
-
return Object.keys(value);
|
|
3333
|
-
default:
|
|
3334
|
-
return `${value}`;
|
|
3335
|
-
}
|
|
3336
|
-
} catch (err) {
|
|
3337
|
-
return `${err}`;
|
|
3338
|
-
}
|
|
3339
|
-
})
|
|
3340
|
-
}));
|
|
3341
|
-
}
|
|
3342
|
-
_automergePeers() {
|
|
3343
|
-
return this._repo.peers;
|
|
3344
|
-
}
|
|
3345
|
-
async close() {
|
|
3346
|
-
await this._storage.close();
|
|
3347
|
-
await this._clientNetwork.close();
|
|
3348
|
-
await this._ctx.dispose();
|
|
3349
|
-
}
|
|
3350
|
-
//
|
|
3351
|
-
// Methods for client-services.
|
|
3352
|
-
//
|
|
3353
|
-
syncRepo(request) {
|
|
3354
|
-
return this._clientNetwork.syncRepo(request);
|
|
3355
|
-
}
|
|
3356
|
-
sendSyncMessage(request) {
|
|
3357
|
-
return this._clientNetwork.sendSyncMessage(request);
|
|
3358
|
-
}
|
|
3359
|
-
async getHostInfo() {
|
|
3360
|
-
return this._clientNetwork.getHostInfo();
|
|
3361
|
-
}
|
|
3362
|
-
//
|
|
3363
|
-
// Mesh replication.
|
|
3364
|
-
//
|
|
3365
|
-
createExtension() {
|
|
3366
|
-
return this._meshNetwork.createExtension();
|
|
3367
|
-
}
|
|
3368
|
-
authorizeDevice(spaceKey, deviceKey) {
|
|
3369
|
-
(0, import_log15.log)("authorizeDevice", {
|
|
3370
|
-
spaceKey,
|
|
3371
|
-
deviceKey
|
|
3372
|
-
}, {
|
|
3373
|
-
F: __dxlog_file16,
|
|
3374
|
-
L: 255,
|
|
3375
|
-
S: this,
|
|
3376
|
-
C: (f, a) => f(...a)
|
|
3377
|
-
});
|
|
3378
|
-
(0, import_util11.defaultMap)(this._authorizedDevices, spaceKey, () => new import_util11.ComplexSet(import_keys8.PublicKey.hash)).add(deviceKey);
|
|
3379
|
-
}
|
|
3380
|
-
};
|
|
3381
|
-
_ts_decorate9([
|
|
3382
|
-
import_tracing5.trace.info()
|
|
3383
|
-
], AutomergeHost.prototype, "_peerId", void 0);
|
|
3384
|
-
_ts_decorate9([
|
|
3385
|
-
import_tracing5.trace.info({
|
|
3386
|
-
depth: null
|
|
3387
|
-
})
|
|
3388
|
-
], AutomergeHost.prototype, "_automergeDocs", null);
|
|
3389
|
-
_ts_decorate9([
|
|
3390
|
-
import_tracing5.trace.info({
|
|
3391
|
-
depth: null
|
|
3392
|
-
})
|
|
3393
|
-
], AutomergeHost.prototype, "_automergePeers", null);
|
|
3394
|
-
AutomergeHost = _ts_decorate9([
|
|
3395
|
-
import_tracing5.trace.resource()
|
|
3396
|
-
], AutomergeHost);
|
|
3397
|
-
var getInlineChanges = (event) => {
|
|
3398
|
-
const inlineChangedObjectIds = /* @__PURE__ */ new Set();
|
|
3399
|
-
for (const { path } of event.patches) {
|
|
3400
|
-
if (path.length < 2) {
|
|
3401
|
-
continue;
|
|
3402
|
-
}
|
|
3403
|
-
switch (path[0]) {
|
|
3404
|
-
case "objects":
|
|
3405
|
-
if (path.length >= 2) {
|
|
3406
|
-
inlineChangedObjectIds.add(path[1]);
|
|
3407
|
-
}
|
|
3408
|
-
break;
|
|
3409
|
-
}
|
|
3410
|
-
}
|
|
3411
|
-
return [
|
|
3412
|
-
...inlineChangedObjectIds
|
|
3413
|
-
];
|
|
3414
|
-
};
|
|
3415
|
-
var getSpaceKeyFromDoc = (doc) => {
|
|
3416
|
-
const rawSpaceKey = doc.access?.spaceKey ?? doc.experimental_spaceKey;
|
|
3417
|
-
if (rawSpaceKey == null) {
|
|
3418
|
-
return null;
|
|
3419
|
-
}
|
|
3420
|
-
return String(rawSpaceKey);
|
|
3421
|
-
};
|
|
3422
2777
|
// Annotate the CommonJS export names for ESM import in node:
|
|
3423
2778
|
0 && (module.exports = {
|
|
3424
2779
|
AuthExtension,
|
|
3425
2780
|
AuthStatus,
|
|
3426
|
-
AutomergeHost,
|
|
3427
|
-
AutomergeStorageAdapter,
|
|
3428
2781
|
DataPipeline,
|
|
3429
2782
|
DataServiceHost,
|
|
3430
2783
|
DataServiceImpl,
|
|
3431
2784
|
DataServiceSubscriptions,
|
|
3432
2785
|
DatabaseHost,
|
|
3433
|
-
LocalHostNetworkAdapter,
|
|
3434
2786
|
MOCK_AUTH_PROVIDER,
|
|
3435
2787
|
MOCK_AUTH_VERIFIER,
|
|
3436
|
-
MeshNetworkAdapter,
|
|
3437
2788
|
MetadataStore,
|
|
3438
2789
|
Pipeline,
|
|
3439
2790
|
SnapshotManager,
|
|
@@ -3445,10 +2796,9 @@ var getSpaceKeyFromDoc = (doc) => {
|
|
|
3445
2796
|
TimeframeClock,
|
|
3446
2797
|
codec,
|
|
3447
2798
|
createMappedFeedWriter,
|
|
3448
|
-
getSpaceKeyFromDoc,
|
|
3449
2799
|
mapFeedIndexesToTimeframe,
|
|
3450
2800
|
mapTimeframeToFeedIndexes,
|
|
3451
2801
|
startAfter,
|
|
3452
2802
|
valueEncoding
|
|
3453
2803
|
});
|
|
3454
|
-
//# sourceMappingURL=chunk-
|
|
2804
|
+
//# sourceMappingURL=chunk-U6J2HC4T.cjs.map
|