@dxos/echo-pipeline 0.3.11-main.ec7a2b3 → 0.3.11-main.ee2b64c
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-WDT56L4E.mjs → chunk-IOUMNVGJ.mjs} +266 -79
- package/dist/lib/browser/chunk-IOUMNVGJ.mjs.map +7 -0
- package/dist/lib/browser/index.mjs +1 -3
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/testing/index.mjs +5 -5
- package/dist/lib/browser/testing/index.mjs.map +3 -3
- package/dist/lib/node/{chunk-C6GFWBRK.cjs → chunk-PDU65RAS.cjs} +260 -77
- package/dist/lib/node/chunk-PDU65RAS.cjs.map +7 -0
- package/dist/lib/node/index.cjs +26 -28
- package/dist/lib/node/index.cjs.map +2 -2
- package/dist/lib/node/meta.json +1 -1
- package/dist/lib/node/testing/index.cjs +20 -20
- package/dist/lib/node/testing/index.cjs.map +3 -3
- package/dist/types/src/automerge/automerge-host.d.ts +27 -2
- package/dist/types/src/automerge/automerge-host.d.ts.map +1 -1
- package/dist/types/src/automerge/index.d.ts +1 -1
- package/dist/types/src/automerge/index.d.ts.map +1 -1
- package/dist/types/src/space/data-pipeline.d.ts.map +1 -1
- package/dist/types/src/space/space-manager.d.ts +2 -2
- package/dist/types/src/space/space-manager.d.ts.map +1 -1
- package/dist/types/src/space/space-protocol.d.ts.map +1 -1
- package/dist/types/src/space/space.d.ts +1 -1
- package/dist/types/src/space/space.d.ts.map +1 -1
- package/dist/types/src/testing/database-test-rig.d.ts.map +1 -1
- package/package.json +33 -33
- package/src/automerge/automerge-host.test.ts +353 -35
- package/src/automerge/automerge-host.ts +138 -21
- package/src/automerge/index.ts +1 -1
- package/src/pipeline/pipeline-stress.test.ts +9 -2
- package/src/space/data-pipeline.ts +4 -3
- package/src/space/space-manager.ts +3 -3
- package/src/space/space-protocol.ts +4 -0
- package/src/space/space.ts +8 -3
- package/src/testing/database-test-rig.ts +4 -1
- package/src/testing/test-agent-builder.ts +1 -1
- package/dist/lib/browser/chunk-WDT56L4E.mjs.map +0 -7
- package/dist/lib/node/chunk-C6GFWBRK.cjs.map +0 -7
|
@@ -26,12 +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_PDU65RAS_exports = {};
|
|
30
|
+
__export(chunk_PDU65RAS_exports, {
|
|
31
31
|
AuthExtension: () => AuthExtension,
|
|
32
32
|
AuthStatus: () => AuthStatus,
|
|
33
33
|
AutomergeHost: () => AutomergeHost,
|
|
34
|
-
AutomergeStorageAdapter: () => AutomergeStorageAdapter,
|
|
35
34
|
DataPipeline: () => DataPipeline,
|
|
36
35
|
DataServiceHost: () => DataServiceHost,
|
|
37
36
|
DataServiceImpl: () => DataServiceImpl,
|
|
@@ -55,7 +54,7 @@ __export(chunk_C6GFWBRK_exports, {
|
|
|
55
54
|
startAfter: () => startAfter,
|
|
56
55
|
valueEncoding: () => valueEncoding
|
|
57
56
|
});
|
|
58
|
-
module.exports = __toCommonJS(
|
|
57
|
+
module.exports = __toCommonJS(chunk_PDU65RAS_exports);
|
|
59
58
|
var import_hypercore = require("@dxos/hypercore");
|
|
60
59
|
var import_protocols = require("@dxos/protocols");
|
|
61
60
|
var import_invariant = require("@dxos/invariant");
|
|
@@ -141,6 +140,7 @@ var import_network_manager = require("@dxos/network-manager");
|
|
|
141
140
|
var import_teleport2 = require("@dxos/teleport");
|
|
142
141
|
var import_teleport_extension_object_sync = require("@dxos/teleport-extension-object-sync");
|
|
143
142
|
var import_teleport_extension_replicator = require("@dxos/teleport-extension-replicator");
|
|
143
|
+
var import_tracing4 = require("@dxos/tracing");
|
|
144
144
|
var import_util8 = require("@dxos/util");
|
|
145
145
|
var import_async9 = require("@dxos/async");
|
|
146
146
|
var import_debug4 = require("@dxos/debug");
|
|
@@ -148,13 +148,17 @@ var import_keys7 = require("@dxos/keys");
|
|
|
148
148
|
var import_log12 = require("@dxos/log");
|
|
149
149
|
var import_protocols7 = require("@dxos/protocols");
|
|
150
150
|
var import_util9 = require("@dxos/util");
|
|
151
|
+
var import_async10 = require("@dxos/async");
|
|
152
|
+
var import_automerge = require("@dxos/automerge/automerge");
|
|
151
153
|
var import_automerge_repo = require("@dxos/automerge/automerge-repo");
|
|
152
154
|
var import_automerge_repo_storage_indexeddb = require("@dxos/automerge/automerge-repo-storage-indexeddb");
|
|
153
155
|
var import_codec_protobuf2 = require("@dxos/codec-protobuf");
|
|
154
156
|
var import_invariant10 = require("@dxos/invariant");
|
|
157
|
+
var import_keys8 = require("@dxos/keys");
|
|
155
158
|
var import_log13 = require("@dxos/log");
|
|
156
159
|
var import_random_access_storage = require("@dxos/random-access-storage");
|
|
157
160
|
var import_teleport_extension_automerge_replicator = require("@dxos/teleport-extension-automerge-replicator");
|
|
161
|
+
var import_tracing5 = require("@dxos/tracing");
|
|
158
162
|
var import_util10 = require("@dxos/util");
|
|
159
163
|
var codec = import_protocols.schema.getCodecForType("dxos.echo.feed.FeedMessage");
|
|
160
164
|
var valueEncoding = (0, import_hypercore.createCodecEncoding)(codec);
|
|
@@ -1537,7 +1541,7 @@ var __dxlog_file9 = "/home/runner/work/dxos/dxos/packages/core/echo/echo-pipelin
|
|
|
1537
1541
|
var MESSAGES_PER_SNAPSHOT = 10;
|
|
1538
1542
|
var AUTOMATIC_SNAPSHOT_DEBOUNCE_INTERVAL = 5e3;
|
|
1539
1543
|
var TIMEFRAME_SAVE_DEBOUNCE_INTERVAL = 5e3;
|
|
1540
|
-
var DataPipeline = class
|
|
1544
|
+
var DataPipeline = class {
|
|
1541
1545
|
constructor(_params) {
|
|
1542
1546
|
this._params = _params;
|
|
1543
1547
|
this._ctx = new import_context5.Context();
|
|
@@ -1658,22 +1662,23 @@ var DataPipeline = class DataPipeline2 {
|
|
|
1658
1662
|
this._epochCtx = void 0;
|
|
1659
1663
|
}
|
|
1660
1664
|
async _consumePipeline() {
|
|
1665
|
+
const pipeline = this._pipeline;
|
|
1661
1666
|
if (this.currentEpoch) {
|
|
1662
1667
|
const waitForOneEpoch = this.onNewEpoch.waitForCount(1);
|
|
1663
1668
|
await this._processEpochInSeparateTask(this.currentEpoch);
|
|
1664
1669
|
await waitForOneEpoch;
|
|
1665
1670
|
}
|
|
1666
1671
|
let messageCounter = 0;
|
|
1667
|
-
(0, import_invariant8.invariant)(
|
|
1672
|
+
(0, import_invariant8.invariant)(pipeline, "Pipeline is not initialized.", {
|
|
1668
1673
|
F: __dxlog_file9,
|
|
1669
|
-
L:
|
|
1674
|
+
L: 229,
|
|
1670
1675
|
S: this,
|
|
1671
1676
|
A: [
|
|
1672
|
-
"
|
|
1677
|
+
"pipeline",
|
|
1673
1678
|
"'Pipeline is not initialized.'"
|
|
1674
1679
|
]
|
|
1675
1680
|
});
|
|
1676
|
-
for await (const msg of
|
|
1681
|
+
for await (const msg of pipeline.consume()) {
|
|
1677
1682
|
const span = this._usage.beginRecording();
|
|
1678
1683
|
this._mutations.inc();
|
|
1679
1684
|
const { feedKey, seq, data } = msg;
|
|
@@ -1682,7 +1687,7 @@ var DataPipeline = class DataPipeline2 {
|
|
|
1682
1687
|
seq
|
|
1683
1688
|
}, {
|
|
1684
1689
|
F: __dxlog_file9,
|
|
1685
|
-
L:
|
|
1690
|
+
L: 235,
|
|
1686
1691
|
S: this,
|
|
1687
1692
|
C: (f, a) => f(...a)
|
|
1688
1693
|
});
|
|
@@ -1694,7 +1699,7 @@ var DataPipeline = class DataPipeline2 {
|
|
|
1694
1699
|
feedKey
|
|
1695
1700
|
}, {
|
|
1696
1701
|
F: __dxlog_file9,
|
|
1697
|
-
L:
|
|
1702
|
+
L: 241,
|
|
1698
1703
|
S: this,
|
|
1699
1704
|
C: (f, a) => f(...a)
|
|
1700
1705
|
});
|
|
@@ -1717,16 +1722,16 @@ var DataPipeline = class DataPipeline2 {
|
|
|
1717
1722
|
spaceKey: this._params.spaceKey.toHex()
|
|
1718
1723
|
}, {
|
|
1719
1724
|
F: __dxlog_file9,
|
|
1720
|
-
L:
|
|
1725
|
+
L: 258,
|
|
1721
1726
|
S: this,
|
|
1722
1727
|
C: (f, a) => f(...a)
|
|
1723
1728
|
});
|
|
1724
|
-
await this._noteTargetStateIfNeeded(
|
|
1729
|
+
await this._noteTargetStateIfNeeded(pipeline.state.pendingTimeframe);
|
|
1725
1730
|
}
|
|
1726
1731
|
} catch (err) {
|
|
1727
1732
|
import_log8.log.catch(err, void 0, {
|
|
1728
1733
|
F: __dxlog_file9,
|
|
1729
|
-
L:
|
|
1734
|
+
L: 268,
|
|
1730
1735
|
S: this,
|
|
1731
1736
|
C: (f, a) => f(...a)
|
|
1732
1737
|
});
|
|
@@ -1741,7 +1746,7 @@ var DataPipeline = class DataPipeline2 {
|
|
|
1741
1746
|
_createSnapshot() {
|
|
1742
1747
|
(0, import_invariant8.invariant)(this.databaseHost, "Database backend is not initialized.", {
|
|
1743
1748
|
F: __dxlog_file9,
|
|
1744
|
-
L:
|
|
1749
|
+
L: 282,
|
|
1745
1750
|
S: this,
|
|
1746
1751
|
A: [
|
|
1747
1752
|
"this.databaseHost",
|
|
@@ -1770,7 +1775,7 @@ var DataPipeline = class DataPipeline2 {
|
|
|
1770
1775
|
} catch (err) {
|
|
1771
1776
|
import_log8.log.warn("Failed to cache properties", err, {
|
|
1772
1777
|
F: __dxlog_file9,
|
|
1773
|
-
L:
|
|
1778
|
+
L: 311,
|
|
1774
1779
|
S: this,
|
|
1775
1780
|
C: (f, a) => f(...a)
|
|
1776
1781
|
});
|
|
@@ -1799,14 +1804,14 @@ var DataPipeline = class DataPipeline2 {
|
|
|
1799
1804
|
if (err instanceof import_protocols6.CancelledError) {
|
|
1800
1805
|
(0, import_log8.log)("Epoch processing cancelled.", void 0, {
|
|
1801
1806
|
F: __dxlog_file9,
|
|
1802
|
-
L:
|
|
1807
|
+
L: 347,
|
|
1803
1808
|
S: this,
|
|
1804
1809
|
C: (f, a) => f(...a)
|
|
1805
1810
|
});
|
|
1806
1811
|
} else {
|
|
1807
1812
|
import_log8.log.catch(err, void 0, {
|
|
1808
1813
|
F: __dxlog_file9,
|
|
1809
|
-
L:
|
|
1814
|
+
L: 349,
|
|
1810
1815
|
S: this,
|
|
1811
1816
|
C: (f, a) => f(...a)
|
|
1812
1817
|
});
|
|
@@ -1829,7 +1834,7 @@ var DataPipeline = class DataPipeline2 {
|
|
|
1829
1834
|
async _processEpoch(ctx, epoch) {
|
|
1830
1835
|
(0, import_invariant8.invariant)(this._isOpen, "Space is closed.", {
|
|
1831
1836
|
F: __dxlog_file9,
|
|
1832
|
-
L:
|
|
1837
|
+
L: 373,
|
|
1833
1838
|
S: this,
|
|
1834
1839
|
A: [
|
|
1835
1840
|
"this._isOpen",
|
|
@@ -1838,7 +1843,7 @@ var DataPipeline = class DataPipeline2 {
|
|
|
1838
1843
|
});
|
|
1839
1844
|
(0, import_invariant8.invariant)(this._pipeline, void 0, {
|
|
1840
1845
|
F: __dxlog_file9,
|
|
1841
|
-
L:
|
|
1846
|
+
L: 374,
|
|
1842
1847
|
S: this,
|
|
1843
1848
|
A: [
|
|
1844
1849
|
"this._pipeline",
|
|
@@ -1850,7 +1855,7 @@ var DataPipeline = class DataPipeline2 {
|
|
|
1850
1855
|
epoch: (0, import_log8.omit)(epoch, "proof")
|
|
1851
1856
|
}, {
|
|
1852
1857
|
F: __dxlog_file9,
|
|
1853
|
-
L:
|
|
1858
|
+
L: 377,
|
|
1854
1859
|
S: this,
|
|
1855
1860
|
C: (f, a) => f(...a)
|
|
1856
1861
|
});
|
|
@@ -1860,7 +1865,7 @@ var DataPipeline = class DataPipeline2 {
|
|
|
1860
1865
|
}
|
|
1861
1866
|
(0, import_log8.log)("restarting pipeline from epoch", void 0, {
|
|
1862
1867
|
F: __dxlog_file9,
|
|
1863
|
-
L:
|
|
1868
|
+
L: 383,
|
|
1864
1869
|
S: this,
|
|
1865
1870
|
C: (f, a) => f(...a)
|
|
1866
1871
|
});
|
|
@@ -1871,7 +1876,7 @@ var DataPipeline = class DataPipeline2 {
|
|
|
1871
1876
|
async waitUntilTimeframe(timeframe) {
|
|
1872
1877
|
(0, import_invariant8.invariant)(this._pipeline, "Pipeline is not initialized.", {
|
|
1873
1878
|
F: __dxlog_file9,
|
|
1874
|
-
L:
|
|
1879
|
+
L: 390,
|
|
1875
1880
|
S: this,
|
|
1876
1881
|
A: [
|
|
1877
1882
|
"this._pipeline",
|
|
@@ -1883,7 +1888,7 @@ var DataPipeline = class DataPipeline2 {
|
|
|
1883
1888
|
async createEpoch() {
|
|
1884
1889
|
(0, import_invariant8.invariant)(this._pipeline, void 0, {
|
|
1885
1890
|
F: __dxlog_file9,
|
|
1886
|
-
L:
|
|
1891
|
+
L: 396,
|
|
1887
1892
|
S: this,
|
|
1888
1893
|
A: [
|
|
1889
1894
|
"this._pipeline",
|
|
@@ -1892,7 +1897,7 @@ var DataPipeline = class DataPipeline2 {
|
|
|
1892
1897
|
});
|
|
1893
1898
|
(0, import_invariant8.invariant)(this.currentEpoch, void 0, {
|
|
1894
1899
|
F: __dxlog_file9,
|
|
1895
|
-
L:
|
|
1900
|
+
L: 397,
|
|
1896
1901
|
S: this,
|
|
1897
1902
|
A: [
|
|
1898
1903
|
"this.currentEpoch",
|
|
@@ -1923,7 +1928,7 @@ var DataPipeline = class DataPipeline2 {
|
|
|
1923
1928
|
} catch (err) {
|
|
1924
1929
|
import_log8.log.catch(err, void 0, {
|
|
1925
1930
|
F: __dxlog_file9,
|
|
1926
|
-
L:
|
|
1931
|
+
L: 427,
|
|
1927
1932
|
S: this,
|
|
1928
1933
|
C: (f, a) => f(...a)
|
|
1929
1934
|
});
|
|
@@ -1992,7 +1997,7 @@ var __dxlog_file10 = "/home/runner/work/dxos/dxos/packages/core/echo/echo-pipeli
|
|
|
1992
1997
|
var TIMEFRAME_SAVE_DEBOUNCE_INTERVAL2 = 500;
|
|
1993
1998
|
var CONTROL_PIPELINE_SNAPSHOT_DELAY = 1e4;
|
|
1994
1999
|
var USE_SNAPSHOTS = true;
|
|
1995
|
-
var ControlPipeline = class
|
|
2000
|
+
var ControlPipeline = class {
|
|
1996
2001
|
constructor({ spaceKey, genesisFeed, feedProvider, metadataStore }) {
|
|
1997
2002
|
this._ctx = new import_context6.Context();
|
|
1998
2003
|
this._lastTimeframeSaveTime = Date.now();
|
|
@@ -2236,15 +2241,15 @@ function _ts_decorate6(decorators, target, key, desc) {
|
|
|
2236
2241
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
2237
2242
|
}
|
|
2238
2243
|
var __dxlog_file11 = "/home/runner/work/dxos/dxos/packages/core/echo/echo-pipeline/src/space/space.ts";
|
|
2239
|
-
var Space = class
|
|
2244
|
+
var Space = class {
|
|
2240
2245
|
constructor(params) {
|
|
2241
|
-
this.
|
|
2246
|
+
this._addFeedMutex = new import_async7.Mutex();
|
|
2242
2247
|
this.onCredentialProcessed = new import_util6.Callback();
|
|
2243
2248
|
this.stateUpdate = new import_async7.Event();
|
|
2244
2249
|
this._isOpen = false;
|
|
2245
2250
|
(0, import_invariant9.invariant)(params.spaceKey && params.feedProvider, void 0, {
|
|
2246
2251
|
F: __dxlog_file11,
|
|
2247
|
-
L:
|
|
2252
|
+
L: 78,
|
|
2248
2253
|
S: this,
|
|
2249
2254
|
A: [
|
|
2250
2255
|
"params.spaceKey && params.feedProvider",
|
|
@@ -2288,7 +2293,7 @@ var Space = class Space2 {
|
|
|
2288
2293
|
credential
|
|
2289
2294
|
}, {
|
|
2290
2295
|
F: __dxlog_file11,
|
|
2291
|
-
L:
|
|
2296
|
+
L: 116,
|
|
2292
2297
|
S: this,
|
|
2293
2298
|
C: (f, a) => f(...a)
|
|
2294
2299
|
});
|
|
@@ -2308,7 +2313,7 @@ var Space = class Space2 {
|
|
|
2308
2313
|
if (this._dataFeed) {
|
|
2309
2314
|
pipeline.setWriteFeed(this._dataFeed);
|
|
2310
2315
|
}
|
|
2311
|
-
await this.
|
|
2316
|
+
await this._addFeedMutex.executeSynchronized(async () => {
|
|
2312
2317
|
for (const feed of this._controlPipeline.spaceState.feeds.values()) {
|
|
2313
2318
|
if (feed.assertion.designation === import_credentials2.AdmittedFeed.Designation.DATA && !pipeline.hasFeed(feed.key)) {
|
|
2314
2319
|
await pipeline.addFeed(await this._feedProvider(feed.key, {
|
|
@@ -2353,7 +2358,7 @@ var Space = class Space2 {
|
|
|
2353
2358
|
setControlFeed(feed) {
|
|
2354
2359
|
(0, import_invariant9.invariant)(!this._controlFeed, "Control feed already set.", {
|
|
2355
2360
|
F: __dxlog_file11,
|
|
2356
|
-
L:
|
|
2361
|
+
L: 191,
|
|
2357
2362
|
S: this,
|
|
2358
2363
|
A: [
|
|
2359
2364
|
"!this._controlFeed",
|
|
@@ -2367,7 +2372,7 @@ var Space = class Space2 {
|
|
|
2367
2372
|
setDataFeed(feed) {
|
|
2368
2373
|
(0, import_invariant9.invariant)(!this._dataFeed, "Data feed already set.", {
|
|
2369
2374
|
F: __dxlog_file11,
|
|
2370
|
-
L:
|
|
2375
|
+
L: 198,
|
|
2371
2376
|
S: this,
|
|
2372
2377
|
A: [
|
|
2373
2378
|
"!this._dataFeed",
|
|
@@ -2393,7 +2398,7 @@ var Space = class Space2 {
|
|
|
2393
2398
|
async open(ctx) {
|
|
2394
2399
|
(0, import_log9.log)("opening...", void 0, {
|
|
2395
2400
|
F: __dxlog_file11,
|
|
2396
|
-
L:
|
|
2401
|
+
L: 220,
|
|
2397
2402
|
S: this,
|
|
2398
2403
|
C: (f, a) => f(...a)
|
|
2399
2404
|
});
|
|
@@ -2406,7 +2411,7 @@ var Space = class Space2 {
|
|
|
2406
2411
|
this._isOpen = true;
|
|
2407
2412
|
(0, import_log9.log)("opened", void 0, {
|
|
2408
2413
|
F: __dxlog_file11,
|
|
2409
|
-
L:
|
|
2414
|
+
L: 231,
|
|
2410
2415
|
S: this,
|
|
2411
2416
|
C: (f, a) => f(...a)
|
|
2412
2417
|
});
|
|
@@ -2416,7 +2421,7 @@ var Space = class Space2 {
|
|
|
2416
2421
|
key: this._key
|
|
2417
2422
|
}, {
|
|
2418
2423
|
F: __dxlog_file11,
|
|
2419
|
-
L:
|
|
2424
|
+
L: 236,
|
|
2420
2425
|
S: this,
|
|
2421
2426
|
C: (f, a) => f(...a)
|
|
2422
2427
|
});
|
|
@@ -2430,7 +2435,7 @@ var Space = class Space2 {
|
|
|
2430
2435
|
this._isOpen = false;
|
|
2431
2436
|
(0, import_log9.log)("closed", void 0, {
|
|
2432
2437
|
F: __dxlog_file11,
|
|
2433
|
-
L:
|
|
2438
|
+
L: 249,
|
|
2434
2439
|
S: this,
|
|
2435
2440
|
C: (f, a) => f(...a)
|
|
2436
2441
|
});
|
|
@@ -2438,13 +2443,13 @@ var Space = class Space2 {
|
|
|
2438
2443
|
async initializeDataPipeline() {
|
|
2439
2444
|
(0, import_log9.log)("initializeDataPipeline", void 0, {
|
|
2440
2445
|
F: __dxlog_file11,
|
|
2441
|
-
L:
|
|
2446
|
+
L: 254,
|
|
2442
2447
|
S: this,
|
|
2443
2448
|
C: (f, a) => f(...a)
|
|
2444
2449
|
});
|
|
2445
2450
|
(0, import_invariant9.invariant)(this._isOpen, "Space must be open to initialize data pipeline.", {
|
|
2446
2451
|
F: __dxlog_file11,
|
|
2447
|
-
L:
|
|
2452
|
+
L: 255,
|
|
2448
2453
|
S: this,
|
|
2449
2454
|
A: [
|
|
2450
2455
|
"this._isOpen",
|
|
@@ -2454,6 +2459,15 @@ var Space = class Space2 {
|
|
|
2454
2459
|
await this._dataPipeline.open();
|
|
2455
2460
|
}
|
|
2456
2461
|
};
|
|
2462
|
+
_ts_decorate6([
|
|
2463
|
+
import_tracing2.trace.info()
|
|
2464
|
+
], Space.prototype, "protocol", void 0);
|
|
2465
|
+
_ts_decorate6([
|
|
2466
|
+
import_tracing2.trace.info()
|
|
2467
|
+
], Space.prototype, "_controlPipeline", void 0);
|
|
2468
|
+
_ts_decorate6([
|
|
2469
|
+
import_tracing2.trace.info()
|
|
2470
|
+
], Space.prototype, "_dataPipeline", void 0);
|
|
2457
2471
|
_ts_decorate6([
|
|
2458
2472
|
import_log9.logInfo,
|
|
2459
2473
|
import_tracing2.trace.info()
|
|
@@ -2514,7 +2528,7 @@ var SpaceProtocol = class {
|
|
|
2514
2528
|
key: feed.key
|
|
2515
2529
|
}, {
|
|
2516
2530
|
F: __dxlog_file12,
|
|
2517
|
-
L:
|
|
2531
|
+
L: 103,
|
|
2518
2532
|
S: this,
|
|
2519
2533
|
C: (f, a) => f(...a)
|
|
2520
2534
|
});
|
|
@@ -2537,7 +2551,7 @@ var SpaceProtocol = class {
|
|
|
2537
2551
|
await this.blobSync.open();
|
|
2538
2552
|
(0, import_log11.log)("starting...", void 0, {
|
|
2539
2553
|
F: __dxlog_file12,
|
|
2540
|
-
L:
|
|
2554
|
+
L: 129,
|
|
2541
2555
|
S: this,
|
|
2542
2556
|
C: (f, a) => f(...a)
|
|
2543
2557
|
});
|
|
@@ -2551,7 +2565,7 @@ var SpaceProtocol = class {
|
|
|
2551
2565
|
});
|
|
2552
2566
|
(0, import_log11.log)("started", void 0, {
|
|
2553
2567
|
F: __dxlog_file12,
|
|
2554
|
-
L:
|
|
2568
|
+
L: 139,
|
|
2555
2569
|
S: this,
|
|
2556
2570
|
C: (f, a) => f(...a)
|
|
2557
2571
|
});
|
|
@@ -2561,14 +2575,14 @@ var SpaceProtocol = class {
|
|
|
2561
2575
|
if (this._connection) {
|
|
2562
2576
|
(0, import_log11.log)("stopping...", void 0, {
|
|
2563
2577
|
F: __dxlog_file12,
|
|
2564
|
-
L:
|
|
2578
|
+
L: 146,
|
|
2565
2579
|
S: this,
|
|
2566
2580
|
C: (f, a) => f(...a)
|
|
2567
2581
|
});
|
|
2568
2582
|
await this._connection.close();
|
|
2569
2583
|
(0, import_log11.log)("stopped", void 0, {
|
|
2570
2584
|
F: __dxlog_file12,
|
|
2571
|
-
L:
|
|
2585
|
+
L: 148,
|
|
2572
2586
|
S: this,
|
|
2573
2587
|
C: (f, a) => f(...a)
|
|
2574
2588
|
});
|
|
@@ -2592,11 +2606,18 @@ var SpaceProtocol = class {
|
|
|
2592
2606
|
}
|
|
2593
2607
|
};
|
|
2594
2608
|
_ts_decorate7([
|
|
2595
|
-
import_log11.logInfo
|
|
2609
|
+
import_log11.logInfo,
|
|
2610
|
+
import_tracing4.trace.info()
|
|
2596
2611
|
], SpaceProtocol.prototype, "_topic", void 0);
|
|
2612
|
+
_ts_decorate7([
|
|
2613
|
+
import_tracing4.trace.info()
|
|
2614
|
+
], SpaceProtocol.prototype, "_spaceKey", void 0);
|
|
2597
2615
|
_ts_decorate7([
|
|
2598
2616
|
import_log11.logInfo
|
|
2599
2617
|
], SpaceProtocol.prototype, "_ownPeerKey", null);
|
|
2618
|
+
SpaceProtocol = _ts_decorate7([
|
|
2619
|
+
import_tracing4.trace.resource()
|
|
2620
|
+
], SpaceProtocol);
|
|
2600
2621
|
var AuthStatus;
|
|
2601
2622
|
(function(AuthStatus2) {
|
|
2602
2623
|
AuthStatus2["INITIAL"] = "INITIAL";
|
|
@@ -2609,7 +2630,7 @@ var SpaceProtocolSession = class {
|
|
|
2609
2630
|
this.replicator = new import_teleport_extension_replicator.ReplicatorExtension().setOptions({
|
|
2610
2631
|
upload: true
|
|
2611
2632
|
});
|
|
2612
|
-
this._authStatus =
|
|
2633
|
+
this._authStatus = "INITIAL";
|
|
2613
2634
|
this._wireParams = wireParams;
|
|
2614
2635
|
this._swarmIdentity = swarmIdentity;
|
|
2615
2636
|
this._onSessionAuth = onSessionAuth;
|
|
@@ -2634,15 +2655,15 @@ var SpaceProtocolSession = class {
|
|
|
2634
2655
|
onAuthSuccess: () => {
|
|
2635
2656
|
(0, import_log11.log)("Peer authenticated", void 0, {
|
|
2636
2657
|
F: __dxlog_file12,
|
|
2637
|
-
L:
|
|
2658
|
+
L: 245,
|
|
2638
2659
|
S: this,
|
|
2639
2660
|
C: (f, a) => f(...a)
|
|
2640
2661
|
});
|
|
2641
|
-
this._authStatus =
|
|
2662
|
+
this._authStatus = "SUCCESS";
|
|
2642
2663
|
this._onSessionAuth?.(this._teleport);
|
|
2643
2664
|
},
|
|
2644
2665
|
onAuthFailure: () => {
|
|
2645
|
-
this._authStatus =
|
|
2666
|
+
this._authStatus = "FAILURE";
|
|
2646
2667
|
this._onAuthFailure?.(this._teleport);
|
|
2647
2668
|
}
|
|
2648
2669
|
}));
|
|
@@ -2652,7 +2673,7 @@ var SpaceProtocolSession = class {
|
|
|
2652
2673
|
async close() {
|
|
2653
2674
|
(0, import_log11.log)("close", void 0, {
|
|
2654
2675
|
F: __dxlog_file12,
|
|
2655
|
-
L:
|
|
2676
|
+
L: 261,
|
|
2656
2677
|
S: this,
|
|
2657
2678
|
C: (f, a) => f(...a)
|
|
2658
2679
|
});
|
|
@@ -2679,7 +2700,7 @@ function _ts_decorate8(decorators, target, key, desc) {
|
|
|
2679
2700
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
2680
2701
|
}
|
|
2681
2702
|
var __dxlog_file13 = "/home/runner/work/dxos/dxos/packages/core/echo/echo-pipeline/src/space/space-manager.ts";
|
|
2682
|
-
var SpaceManager = class
|
|
2703
|
+
var SpaceManager = class {
|
|
2683
2704
|
constructor({ feedStore, networkManager, modelFactory, metadataStore, snapshotStore, blobStore }) {
|
|
2684
2705
|
this._spaces = new import_util9.ComplexMap(import_keys7.PublicKey.hash);
|
|
2685
2706
|
this._instanceId = import_keys7.PublicKey.random().toHex();
|
|
@@ -2701,7 +2722,7 @@ var SpaceManager = class SpaceManager2 {
|
|
|
2701
2722
|
...this._spaces.values()
|
|
2702
2723
|
].map((space) => space.close()));
|
|
2703
2724
|
}
|
|
2704
|
-
async constructSpace({ metadata, swarmIdentity,
|
|
2725
|
+
async constructSpace({ metadata, swarmIdentity, onAuthorizedConnection, onAuthFailure, memberKey }) {
|
|
2705
2726
|
import_log12.log.trace("dxos.echo.space-manager.construct-space", import_protocols7.trace.begin({
|
|
2706
2727
|
id: this._instanceId
|
|
2707
2728
|
}), {
|
|
@@ -2724,7 +2745,7 @@ var SpaceManager = class SpaceManager2 {
|
|
|
2724
2745
|
topic: spaceKey,
|
|
2725
2746
|
swarmIdentity,
|
|
2726
2747
|
networkManager: this._networkManager,
|
|
2727
|
-
onSessionAuth:
|
|
2748
|
+
onSessionAuth: onAuthorizedConnection,
|
|
2728
2749
|
onAuthFailure,
|
|
2729
2750
|
blobStore: this._blobStore
|
|
2730
2751
|
});
|
|
@@ -2760,20 +2781,105 @@ _ts_decorate8([
|
|
|
2760
2781
|
SpaceManager = _ts_decorate8([
|
|
2761
2782
|
(0, import_async9.trackLeaks)("open", "close")
|
|
2762
2783
|
], SpaceManager);
|
|
2784
|
+
function _ts_decorate9(decorators, target, key, desc) {
|
|
2785
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
2786
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
|
|
2787
|
+
r = Reflect.decorate(decorators, target, key, desc);
|
|
2788
|
+
else
|
|
2789
|
+
for (var i = decorators.length - 1; i >= 0; i--)
|
|
2790
|
+
if (d = decorators[i])
|
|
2791
|
+
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
2792
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
2793
|
+
}
|
|
2763
2794
|
var __dxlog_file14 = "/home/runner/work/dxos/dxos/packages/core/echo/echo-pipeline/src/automerge/automerge-host.ts";
|
|
2764
2795
|
var AutomergeHost = class {
|
|
2765
2796
|
constructor(storageDirectory) {
|
|
2797
|
+
this._authorizedDevices = new import_util10.ComplexMap(import_keys8.PublicKey.hash);
|
|
2766
2798
|
this._meshNetwork = new MeshNetworkAdapter();
|
|
2767
2799
|
this._clientNetwork = new LocalHostNetworkAdapter();
|
|
2768
2800
|
this._storage = storageDirectory.type === import_random_access_storage.StorageType.IDB ? new import_automerge_repo_storage_indexeddb.IndexedDBStorageAdapter(storageDirectory.path, "data") : new AutomergeStorageAdapter(storageDirectory);
|
|
2769
2801
|
this._repo = new import_automerge_repo.Repo({
|
|
2802
|
+
peerId: `host-${import_keys8.PublicKey.random().toHex()}`,
|
|
2770
2803
|
network: [
|
|
2771
2804
|
this._clientNetwork,
|
|
2772
2805
|
this._meshNetwork
|
|
2773
2806
|
],
|
|
2774
2807
|
storage: this._storage,
|
|
2775
2808
|
// TODO(dmaretskyi): Share based on HALO permissions and space affinity.
|
|
2776
|
-
|
|
2809
|
+
// Hosts, running in the worker, don't share documents unless requested by other peers.
|
|
2810
|
+
sharePolicy: async (peerId, documentId) => {
|
|
2811
|
+
if (peerId.startsWith("client-")) {
|
|
2812
|
+
return true;
|
|
2813
|
+
}
|
|
2814
|
+
if (!documentId) {
|
|
2815
|
+
return false;
|
|
2816
|
+
}
|
|
2817
|
+
const doc = this._repo.handles[documentId]?.docSync();
|
|
2818
|
+
if (!doc) {
|
|
2819
|
+
(0, import_log13.log)("doc not found for share policy check", {
|
|
2820
|
+
peerId,
|
|
2821
|
+
documentId
|
|
2822
|
+
}, {
|
|
2823
|
+
F: __dxlog_file14,
|
|
2824
|
+
L: 68,
|
|
2825
|
+
S: this,
|
|
2826
|
+
C: (f, a) => f(...a)
|
|
2827
|
+
});
|
|
2828
|
+
return false;
|
|
2829
|
+
}
|
|
2830
|
+
try {
|
|
2831
|
+
if (!doc.experimental_spaceKey) {
|
|
2832
|
+
(0, import_log13.log)("space key not found for share policy check", {
|
|
2833
|
+
peerId,
|
|
2834
|
+
documentId
|
|
2835
|
+
}, {
|
|
2836
|
+
F: __dxlog_file14,
|
|
2837
|
+
L: 74,
|
|
2838
|
+
S: this,
|
|
2839
|
+
C: (f, a) => f(...a)
|
|
2840
|
+
});
|
|
2841
|
+
return false;
|
|
2842
|
+
}
|
|
2843
|
+
const spaceKey = import_keys8.PublicKey.from(doc.experimental_spaceKey);
|
|
2844
|
+
const authorizedDevices = this._authorizedDevices.get(spaceKey);
|
|
2845
|
+
const deviceKeyHex = this.repo.peerMetadataByPeerId[peerId]?.dxos_deviceKey;
|
|
2846
|
+
if (!deviceKeyHex) {
|
|
2847
|
+
(0, import_log13.log)("device key not found for share policy check", {
|
|
2848
|
+
peerId,
|
|
2849
|
+
documentId
|
|
2850
|
+
}, {
|
|
2851
|
+
F: __dxlog_file14,
|
|
2852
|
+
L: 84,
|
|
2853
|
+
S: this,
|
|
2854
|
+
C: (f, a) => f(...a)
|
|
2855
|
+
});
|
|
2856
|
+
return false;
|
|
2857
|
+
}
|
|
2858
|
+
const deviceKey = import_keys8.PublicKey.from(deviceKeyHex);
|
|
2859
|
+
const isAuthorized = authorizedDevices?.has(deviceKey) ?? false;
|
|
2860
|
+
(0, import_log13.log)("share policy check", {
|
|
2861
|
+
peerId,
|
|
2862
|
+
documentId,
|
|
2863
|
+
deviceKey,
|
|
2864
|
+
spaceKey,
|
|
2865
|
+
isAuthorized
|
|
2866
|
+
}, {
|
|
2867
|
+
F: __dxlog_file14,
|
|
2868
|
+
L: 90,
|
|
2869
|
+
S: this,
|
|
2870
|
+
C: (f, a) => f(...a)
|
|
2871
|
+
});
|
|
2872
|
+
return isAuthorized;
|
|
2873
|
+
} catch (err) {
|
|
2874
|
+
import_log13.log.catch(err, void 0, {
|
|
2875
|
+
F: __dxlog_file14,
|
|
2876
|
+
L: 93,
|
|
2877
|
+
S: this,
|
|
2878
|
+
C: (f, a) => f(...a)
|
|
2879
|
+
});
|
|
2880
|
+
return false;
|
|
2881
|
+
}
|
|
2882
|
+
}
|
|
2777
2883
|
});
|
|
2778
2884
|
this._clientNetwork.ready();
|
|
2779
2885
|
this._meshNetwork.ready();
|
|
@@ -2781,7 +2887,18 @@ var AutomergeHost = class {
|
|
|
2781
2887
|
get repo() {
|
|
2782
2888
|
return this._repo;
|
|
2783
2889
|
}
|
|
2890
|
+
_automergeDocs() {
|
|
2891
|
+
return (0, import_util10.mapValues)(this._repo.handles, (handle) => ({
|
|
2892
|
+
state: handle.state,
|
|
2893
|
+
hasDoc: !!handle.docSync(),
|
|
2894
|
+
heads: handle.docSync() ? import_automerge.next.getHeads(handle.docSync()) : null
|
|
2895
|
+
}));
|
|
2896
|
+
}
|
|
2897
|
+
_automergePeers() {
|
|
2898
|
+
return this._repo.peers;
|
|
2899
|
+
}
|
|
2784
2900
|
async close() {
|
|
2901
|
+
this._storage instanceof AutomergeStorageAdapter && await this._storage.close();
|
|
2785
2902
|
await this._clientNetwork.close();
|
|
2786
2903
|
}
|
|
2787
2904
|
//
|
|
@@ -2793,7 +2910,7 @@ var AutomergeHost = class {
|
|
|
2793
2910
|
sendSyncMessage(request) {
|
|
2794
2911
|
return this._clientNetwork.sendSyncMessage(request);
|
|
2795
2912
|
}
|
|
2796
|
-
getHostInfo() {
|
|
2913
|
+
async getHostInfo() {
|
|
2797
2914
|
return this._clientNetwork.getHostInfo();
|
|
2798
2915
|
}
|
|
2799
2916
|
//
|
|
@@ -2802,11 +2919,28 @@ var AutomergeHost = class {
|
|
|
2802
2919
|
createExtension() {
|
|
2803
2920
|
return this._meshNetwork.createExtension();
|
|
2804
2921
|
}
|
|
2922
|
+
authorizeDevice(spaceKey, deviceKey) {
|
|
2923
|
+
(0, import_util10.defaultMap)(this._authorizedDevices, spaceKey, () => new import_util10.ComplexSet(import_keys8.PublicKey.hash)).add(deviceKey);
|
|
2924
|
+
}
|
|
2805
2925
|
};
|
|
2926
|
+
_ts_decorate9([
|
|
2927
|
+
import_tracing5.trace.info({
|
|
2928
|
+
depth: null
|
|
2929
|
+
})
|
|
2930
|
+
], AutomergeHost.prototype, "_automergeDocs", null);
|
|
2931
|
+
_ts_decorate9([
|
|
2932
|
+
import_tracing5.trace.info({
|
|
2933
|
+
depth: null
|
|
2934
|
+
})
|
|
2935
|
+
], AutomergeHost.prototype, "_automergePeers", null);
|
|
2936
|
+
AutomergeHost = _ts_decorate9([
|
|
2937
|
+
import_tracing5.trace.resource()
|
|
2938
|
+
], AutomergeHost);
|
|
2806
2939
|
var LocalHostNetworkAdapter = class extends import_automerge_repo.NetworkAdapter {
|
|
2807
2940
|
constructor() {
|
|
2808
2941
|
super(...arguments);
|
|
2809
2942
|
this._peers = /* @__PURE__ */ new Map();
|
|
2943
|
+
this._connected = new import_async10.Trigger();
|
|
2810
2944
|
}
|
|
2811
2945
|
/**
|
|
2812
2946
|
* Emits `ready` event. That signals to `Repo` that it can start using the adapter.
|
|
@@ -2818,12 +2952,13 @@ var LocalHostNetworkAdapter = class extends import_automerge_repo.NetworkAdapter
|
|
|
2818
2952
|
}
|
|
2819
2953
|
connect(peerId) {
|
|
2820
2954
|
this.peerId = peerId;
|
|
2955
|
+
this._connected.wake();
|
|
2821
2956
|
}
|
|
2822
2957
|
send(message) {
|
|
2823
2958
|
const peer = this._peers.get(message.targetId);
|
|
2824
2959
|
(0, import_invariant10.invariant)(peer, "Peer not found.", {
|
|
2825
2960
|
F: __dxlog_file14,
|
|
2826
|
-
L:
|
|
2961
|
+
L: 187,
|
|
2827
2962
|
S: this,
|
|
2828
2963
|
A: [
|
|
2829
2964
|
"peer",
|
|
@@ -2843,7 +2978,7 @@ var LocalHostNetworkAdapter = class extends import_automerge_repo.NetworkAdapter
|
|
|
2843
2978
|
return new import_codec_protobuf2.Stream(({ next, close }) => {
|
|
2844
2979
|
(0, import_invariant10.invariant)(!this._peers.has(peerId), "Peer already connected.", {
|
|
2845
2980
|
F: __dxlog_file14,
|
|
2846
|
-
L:
|
|
2981
|
+
L: 205,
|
|
2847
2982
|
S: this,
|
|
2848
2983
|
A: [
|
|
2849
2984
|
"!this._peers.has(peerId)",
|
|
@@ -2865,19 +3000,35 @@ var LocalHostNetworkAdapter = class extends import_automerge_repo.NetworkAdapter
|
|
|
2865
3000
|
});
|
|
2866
3001
|
}
|
|
2867
3002
|
});
|
|
2868
|
-
this.
|
|
2869
|
-
|
|
2870
|
-
})
|
|
3003
|
+
this._connected.wait({
|
|
3004
|
+
timeout: 1e3
|
|
3005
|
+
}).then(() => {
|
|
3006
|
+
this.emit("peer-candidate", {
|
|
3007
|
+
peerMetadata: {},
|
|
3008
|
+
peerId
|
|
3009
|
+
});
|
|
3010
|
+
}).catch((err) => import_log13.log.catch(err, void 0, {
|
|
3011
|
+
F: __dxlog_file14,
|
|
3012
|
+
L: 230,
|
|
3013
|
+
S: this,
|
|
3014
|
+
C: (f, a) => f(...a)
|
|
3015
|
+
}));
|
|
2871
3016
|
});
|
|
2872
3017
|
}
|
|
2873
3018
|
async sendSyncMessage({ id, syncMessage }) {
|
|
3019
|
+
await this._connected.wait({
|
|
3020
|
+
timeout: 1e3
|
|
3021
|
+
});
|
|
2874
3022
|
const message = import_automerge_repo.cbor.decode(syncMessage);
|
|
2875
3023
|
this.emit("message", message);
|
|
2876
3024
|
}
|
|
2877
|
-
getHostInfo() {
|
|
3025
|
+
async getHostInfo() {
|
|
3026
|
+
await this._connected.wait({
|
|
3027
|
+
timeout: 1e3
|
|
3028
|
+
});
|
|
2878
3029
|
(0, import_invariant10.invariant)(this.peerId, "Peer id not set.", {
|
|
2879
3030
|
F: __dxlog_file14,
|
|
2880
|
-
L:
|
|
3031
|
+
L: 242,
|
|
2881
3032
|
S: this,
|
|
2882
3033
|
A: [
|
|
2883
3034
|
"this.peerId",
|
|
@@ -2896,6 +3047,7 @@ var MeshNetworkAdapter = class extends import_automerge_repo.NetworkAdapter {
|
|
|
2896
3047
|
constructor() {
|
|
2897
3048
|
super(...arguments);
|
|
2898
3049
|
this._extensions = /* @__PURE__ */ new Map();
|
|
3050
|
+
this._connected = new import_async10.Trigger();
|
|
2899
3051
|
}
|
|
2900
3052
|
/**
|
|
2901
3053
|
* Emits `ready` event. That signals to `Repo` that it can start using the adapter.
|
|
@@ -2907,13 +3059,14 @@ var MeshNetworkAdapter = class extends import_automerge_repo.NetworkAdapter {
|
|
|
2907
3059
|
}
|
|
2908
3060
|
connect(peerId) {
|
|
2909
3061
|
this.peerId = peerId;
|
|
3062
|
+
this._connected.wake();
|
|
2910
3063
|
}
|
|
2911
3064
|
send(message) {
|
|
2912
3065
|
const receiverId = message.targetId;
|
|
2913
3066
|
const extension = this._extensions.get(receiverId);
|
|
2914
3067
|
(0, import_invariant10.invariant)(extension, "Extension not found.", {
|
|
2915
3068
|
F: __dxlog_file14,
|
|
2916
|
-
L:
|
|
3069
|
+
L: 279,
|
|
2917
3070
|
S: this,
|
|
2918
3071
|
A: [
|
|
2919
3072
|
"extension",
|
|
@@ -2924,7 +3077,7 @@ var MeshNetworkAdapter = class extends import_automerge_repo.NetworkAdapter {
|
|
|
2924
3077
|
payload: import_automerge_repo.cbor.encode(message)
|
|
2925
3078
|
}).catch((err) => import_log13.log.catch(err, void 0, {
|
|
2926
3079
|
F: __dxlog_file14,
|
|
2927
|
-
L:
|
|
3080
|
+
L: 280,
|
|
2928
3081
|
S: this,
|
|
2929
3082
|
C: (f, a) => f(...a)
|
|
2930
3083
|
}));
|
|
@@ -2934,7 +3087,7 @@ var MeshNetworkAdapter = class extends import_automerge_repo.NetworkAdapter {
|
|
|
2934
3087
|
createExtension() {
|
|
2935
3088
|
(0, import_invariant10.invariant)(this.peerId, "Peer id not set.", {
|
|
2936
3089
|
F: __dxlog_file14,
|
|
2937
|
-
L:
|
|
3090
|
+
L: 288,
|
|
2938
3091
|
S: this,
|
|
2939
3092
|
A: [
|
|
2940
3093
|
"this.peerId",
|
|
@@ -2945,13 +3098,21 @@ var MeshNetworkAdapter = class extends import_automerge_repo.NetworkAdapter {
|
|
|
2945
3098
|
const extension = new import_teleport_extension_automerge_replicator.AutomergeReplicator({
|
|
2946
3099
|
peerId: this.peerId
|
|
2947
3100
|
}, {
|
|
2948
|
-
onStartReplication: async (info) => {
|
|
2949
|
-
|
|
2950
|
-
|
|
3101
|
+
onStartReplication: async (info, remotePeerId) => {
|
|
3102
|
+
await this._connected.wait();
|
|
3103
|
+
if (!this._extensions.has(info.id)) {
|
|
3104
|
+
peerInfo = info;
|
|
3105
|
+
this._extensions.set(info.id, extension);
|
|
3106
|
+
} else {
|
|
3107
|
+
this.emit("peer-disconnected", {
|
|
3108
|
+
peerId: info.id
|
|
3109
|
+
});
|
|
2951
3110
|
}
|
|
2952
|
-
peerInfo = info;
|
|
2953
|
-
this._extensions.set(info.id, extension);
|
|
2954
3111
|
this.emit("peer-candidate", {
|
|
3112
|
+
// TODO(mykola): Hack, stop abusing `peerMetadata` field.
|
|
3113
|
+
peerMetadata: {
|
|
3114
|
+
dxos_deviceKey: remotePeerId.toHex()
|
|
3115
|
+
},
|
|
2955
3116
|
peerId: info.id
|
|
2956
3117
|
});
|
|
2957
3118
|
},
|
|
@@ -2960,9 +3121,13 @@ var MeshNetworkAdapter = class extends import_automerge_repo.NetworkAdapter {
|
|
|
2960
3121
|
this.emit("message", message);
|
|
2961
3122
|
},
|
|
2962
3123
|
onClose: async () => {
|
|
2963
|
-
|
|
3124
|
+
if (!peerInfo) {
|
|
3125
|
+
return;
|
|
3126
|
+
}
|
|
3127
|
+
this.emit("peer-disconnected", {
|
|
2964
3128
|
peerId: peerInfo.id
|
|
2965
3129
|
});
|
|
3130
|
+
this._extensions.delete(peerInfo.id);
|
|
2966
3131
|
}
|
|
2967
3132
|
});
|
|
2968
3133
|
return extension;
|
|
@@ -2972,8 +3137,12 @@ var AutomergeStorageAdapter = class extends import_automerge_repo.StorageAdapter
|
|
|
2972
3137
|
constructor(_directory) {
|
|
2973
3138
|
super();
|
|
2974
3139
|
this._directory = _directory;
|
|
3140
|
+
this._state = "opened";
|
|
2975
3141
|
}
|
|
2976
3142
|
async load(key) {
|
|
3143
|
+
if (this._state !== "opened") {
|
|
3144
|
+
return void 0;
|
|
3145
|
+
}
|
|
2977
3146
|
const filename = this._getFilename(key);
|
|
2978
3147
|
const file = this._directory.getOrCreateFile(filename);
|
|
2979
3148
|
const { size } = await file.stat();
|
|
@@ -2984,6 +3153,9 @@ var AutomergeStorageAdapter = class extends import_automerge_repo.StorageAdapter
|
|
|
2984
3153
|
return (0, import_util10.bufferToArray)(buffer);
|
|
2985
3154
|
}
|
|
2986
3155
|
async save(key, data) {
|
|
3156
|
+
if (this._state !== "opened") {
|
|
3157
|
+
return void 0;
|
|
3158
|
+
}
|
|
2987
3159
|
const filename = this._getFilename(key);
|
|
2988
3160
|
const file = this._directory.getOrCreateFile(filename);
|
|
2989
3161
|
await file.write(0, (0, import_util10.arrayToBuffer)(data));
|
|
@@ -2991,11 +3163,17 @@ var AutomergeStorageAdapter = class extends import_automerge_repo.StorageAdapter
|
|
|
2991
3163
|
await file.flush?.();
|
|
2992
3164
|
}
|
|
2993
3165
|
async remove(key) {
|
|
3166
|
+
if (this._state !== "opened") {
|
|
3167
|
+
return void 0;
|
|
3168
|
+
}
|
|
2994
3169
|
const filename = this._getFilename(key);
|
|
2995
3170
|
const file = this._directory.getOrCreateFile(filename);
|
|
2996
|
-
await file.
|
|
3171
|
+
await file.destroy();
|
|
2997
3172
|
}
|
|
2998
3173
|
async loadRange(keyPrefix) {
|
|
3174
|
+
if (this._state !== "opened") {
|
|
3175
|
+
return [];
|
|
3176
|
+
}
|
|
2999
3177
|
const filename = this._getFilename(keyPrefix);
|
|
3000
3178
|
const entries = await this._directory.list();
|
|
3001
3179
|
return Promise.all(entries.filter((entry) => entry.startsWith(filename)).map(async (entry) => {
|
|
@@ -3009,13 +3187,19 @@ var AutomergeStorageAdapter = class extends import_automerge_repo.StorageAdapter
|
|
|
3009
3187
|
}));
|
|
3010
3188
|
}
|
|
3011
3189
|
async removeRange(keyPrefix) {
|
|
3190
|
+
if (this._state !== "opened") {
|
|
3191
|
+
return void 0;
|
|
3192
|
+
}
|
|
3012
3193
|
const filename = this._getFilename(keyPrefix);
|
|
3013
3194
|
const entries = await this._directory.list();
|
|
3014
3195
|
await Promise.all(entries.filter((entry) => entry.startsWith(filename)).map(async (entry) => {
|
|
3015
|
-
const file = this._directory.getOrCreateFile(
|
|
3016
|
-
await file.
|
|
3196
|
+
const file = this._directory.getOrCreateFile(entry);
|
|
3197
|
+
await file.destroy();
|
|
3017
3198
|
}));
|
|
3018
3199
|
}
|
|
3200
|
+
async close() {
|
|
3201
|
+
this._state = "closed";
|
|
3202
|
+
}
|
|
3019
3203
|
_getFilename(key) {
|
|
3020
3204
|
return key.map((k) => k.replaceAll("%", "%25").replaceAll("-", "%2D")).join("-");
|
|
3021
3205
|
}
|
|
@@ -3028,7 +3212,6 @@ var AutomergeStorageAdapter = class extends import_automerge_repo.StorageAdapter
|
|
|
3028
3212
|
AuthExtension,
|
|
3029
3213
|
AuthStatus,
|
|
3030
3214
|
AutomergeHost,
|
|
3031
|
-
AutomergeStorageAdapter,
|
|
3032
3215
|
DataPipeline,
|
|
3033
3216
|
DataServiceHost,
|
|
3034
3217
|
DataServiceImpl,
|
|
@@ -3052,4 +3235,4 @@ var AutomergeStorageAdapter = class extends import_automerge_repo.StorageAdapter
|
|
|
3052
3235
|
startAfter,
|
|
3053
3236
|
valueEncoding
|
|
3054
3237
|
});
|
|
3055
|
-
//# sourceMappingURL=chunk-
|
|
3238
|
+
//# sourceMappingURL=chunk-PDU65RAS.cjs.map
|