@dxos/echo-pipeline 0.4.8-main.2d8e727 → 0.4.8-main.2e7285f
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-M7BOB47J.mjs → chunk-3PPSCHNN.mjs} +40 -68
- package/dist/lib/browser/chunk-3PPSCHNN.mjs.map +7 -0
- package/dist/lib/browser/index.mjs +1 -1
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/testing/index.mjs +1 -1
- package/dist/lib/node/{chunk-B5LDK2PA.cjs → chunk-EVKDEZDX.cjs} +41 -69
- package/dist/lib/node/chunk-EVKDEZDX.cjs.map +7 -0
- package/dist/lib/node/index.cjs +30 -30
- package/dist/lib/node/index.cjs.map +1 -1
- package/dist/lib/node/meta.json +1 -1
- package/dist/lib/node/testing/index.cjs +16 -16
- package/dist/types/src/automerge/automerge-host.d.ts +2 -2
- package/dist/types/src/automerge/automerge-host.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/package.json +33 -33
- package/src/automerge/automerge-host.ts +13 -26
- package/src/space/data-pipeline.ts +1 -44
- package/dist/lib/browser/chunk-M7BOB47J.mjs.map +0 -7
- package/dist/lib/node/chunk-B5LDK2PA.cjs.map +0 -7
|
@@ -26,8 +26,8 @@ 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_EVKDEZDX_exports = {};
|
|
30
|
+
__export(chunk_EVKDEZDX_exports, {
|
|
31
31
|
AuthExtension: () => AuthExtension,
|
|
32
32
|
AuthStatus: () => AuthStatus,
|
|
33
33
|
AutomergeHost: () => AutomergeHost,
|
|
@@ -58,7 +58,7 @@ __export(chunk_B5LDK2PA_exports, {
|
|
|
58
58
|
startAfter: () => startAfter,
|
|
59
59
|
valueEncoding: () => valueEncoding
|
|
60
60
|
});
|
|
61
|
-
module.exports = __toCommonJS(
|
|
61
|
+
module.exports = __toCommonJS(chunk_EVKDEZDX_exports);
|
|
62
62
|
var import_hypercore = require("@dxos/hypercore");
|
|
63
63
|
var import_protocols = require("@dxos/protocols");
|
|
64
64
|
var import_invariant = require("@dxos/invariant");
|
|
@@ -1578,8 +1578,6 @@ function _ts_decorate4(decorators, target, key, desc) {
|
|
|
1578
1578
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
1579
1579
|
}
|
|
1580
1580
|
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
1581
|
var TIMEFRAME_SAVE_DEBOUNCE_INTERVAL = 5e3;
|
|
1584
1582
|
var DataPipeline = class {
|
|
1585
1583
|
constructor(_params) {
|
|
@@ -1635,7 +1633,7 @@ var DataPipeline = class {
|
|
|
1635
1633
|
write: (data, options) => {
|
|
1636
1634
|
(0, import_invariant8.invariant)(this._pipeline, "Pipeline is not initialized.", {
|
|
1637
1635
|
F: __dxlog_file9,
|
|
1638
|
-
L:
|
|
1636
|
+
L: 152,
|
|
1639
1637
|
S: this,
|
|
1640
1638
|
A: [
|
|
1641
1639
|
"this._pipeline",
|
|
@@ -1644,7 +1642,7 @@ var DataPipeline = class {
|
|
|
1644
1642
|
});
|
|
1645
1643
|
(0, import_invariant8.invariant)(this.currentEpoch, "Epoch is not initialized.", {
|
|
1646
1644
|
F: __dxlog_file9,
|
|
1647
|
-
L:
|
|
1645
|
+
L: 153,
|
|
1648
1646
|
S: this,
|
|
1649
1647
|
A: [
|
|
1650
1648
|
"this.currentEpoch",
|
|
@@ -1670,7 +1668,7 @@ var DataPipeline = class {
|
|
|
1670
1668
|
}
|
|
1671
1669
|
(0, import_log8.log)("close", void 0, {
|
|
1672
1670
|
F: __dxlog_file9,
|
|
1673
|
-
L:
|
|
1671
|
+
L: 177,
|
|
1674
1672
|
S: this,
|
|
1675
1673
|
C: (f, a) => f(...a)
|
|
1676
1674
|
});
|
|
@@ -1678,14 +1676,13 @@ var DataPipeline = class {
|
|
|
1678
1676
|
await this._ctx.dispose();
|
|
1679
1677
|
await this._pipeline?.stop();
|
|
1680
1678
|
try {
|
|
1681
|
-
await this._saveCache();
|
|
1682
1679
|
if (this._pipeline) {
|
|
1683
1680
|
await this._saveTargetTimeframe(this._pipeline.state.timeframe);
|
|
1684
1681
|
}
|
|
1685
1682
|
} catch (err) {
|
|
1686
1683
|
import_log8.log.catch(err, void 0, {
|
|
1687
1684
|
F: __dxlog_file9,
|
|
1688
|
-
L:
|
|
1685
|
+
L: 189,
|
|
1689
1686
|
S: this,
|
|
1690
1687
|
C: (f, a) => f(...a)
|
|
1691
1688
|
});
|
|
@@ -1711,7 +1708,7 @@ var DataPipeline = class {
|
|
|
1711
1708
|
let messageCounter = 0;
|
|
1712
1709
|
(0, import_invariant8.invariant)(pipeline, "Pipeline is not initialized.", {
|
|
1713
1710
|
F: __dxlog_file9,
|
|
1714
|
-
L:
|
|
1711
|
+
L: 216,
|
|
1715
1712
|
S: this,
|
|
1716
1713
|
A: [
|
|
1717
1714
|
"pipeline",
|
|
@@ -1727,7 +1724,7 @@ var DataPipeline = class {
|
|
|
1727
1724
|
seq
|
|
1728
1725
|
}, {
|
|
1729
1726
|
F: __dxlog_file9,
|
|
1730
|
-
L:
|
|
1727
|
+
L: 222,
|
|
1731
1728
|
S: this,
|
|
1732
1729
|
C: (f, a) => f(...a)
|
|
1733
1730
|
});
|
|
@@ -1739,7 +1736,7 @@ var DataPipeline = class {
|
|
|
1739
1736
|
feedKey
|
|
1740
1737
|
}, {
|
|
1741
1738
|
F: __dxlog_file9,
|
|
1742
|
-
L:
|
|
1739
|
+
L: 228,
|
|
1743
1740
|
S: this,
|
|
1744
1741
|
C: (f, a) => f(...a)
|
|
1745
1742
|
});
|
|
@@ -1762,7 +1759,7 @@ var DataPipeline = class {
|
|
|
1762
1759
|
spaceKey: this._params.spaceKey.toHex()
|
|
1763
1760
|
}, {
|
|
1764
1761
|
F: __dxlog_file9,
|
|
1765
|
-
L:
|
|
1762
|
+
L: 245,
|
|
1766
1763
|
S: this,
|
|
1767
1764
|
C: (f, a) => f(...a)
|
|
1768
1765
|
});
|
|
@@ -1771,7 +1768,7 @@ var DataPipeline = class {
|
|
|
1771
1768
|
} catch (err) {
|
|
1772
1769
|
import_log8.log.catch(err, void 0, {
|
|
1773
1770
|
F: __dxlog_file9,
|
|
1774
|
-
L:
|
|
1771
|
+
L: 255,
|
|
1775
1772
|
S: this,
|
|
1776
1773
|
C: (f, a) => f(...a)
|
|
1777
1774
|
});
|
|
@@ -1786,7 +1783,7 @@ var DataPipeline = class {
|
|
|
1786
1783
|
_createSnapshot() {
|
|
1787
1784
|
(0, import_invariant8.invariant)(this.databaseHost, "Database backend is not initialized.", {
|
|
1788
1785
|
F: __dxlog_file9,
|
|
1789
|
-
L:
|
|
1786
|
+
L: 269,
|
|
1790
1787
|
S: this,
|
|
1791
1788
|
A: [
|
|
1792
1789
|
"this.databaseHost",
|
|
@@ -1804,24 +1801,6 @@ var DataPipeline = class {
|
|
|
1804
1801
|
await this._params.metadataStore.setSpaceDataLatestTimeframe(this._params.spaceKey, newTimeframe);
|
|
1805
1802
|
this._targetTimeframe = newTimeframe;
|
|
1806
1803
|
}
|
|
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
1804
|
async _noteTargetStateIfNeeded(timeframe) {
|
|
1826
1805
|
if (!this._pipeline?.state.reachedTarget) {
|
|
1827
1806
|
return;
|
|
@@ -1830,9 +1809,6 @@ var DataPipeline = class {
|
|
|
1830
1809
|
this._lastTimeframeSaveTime = Date.now();
|
|
1831
1810
|
await this._saveTargetTimeframe(timeframe);
|
|
1832
1811
|
}
|
|
1833
|
-
if (Date.now() - this._lastSnapshotSaveTime > AUTOMATIC_SNAPSHOT_DEBOUNCE_INTERVAL && timeframe.totalMessages() - this._lastAutomaticSnapshotTimeframe.totalMessages() > MESSAGES_PER_SNAPSHOT) {
|
|
1834
|
-
await this._saveCache();
|
|
1835
|
-
}
|
|
1836
1812
|
}
|
|
1837
1813
|
async _processEpochInSeparateTask(epoch) {
|
|
1838
1814
|
if (epoch.subject.assertion.number <= this._lastProcessedEpoch) {
|
|
@@ -1844,14 +1820,14 @@ var DataPipeline = class {
|
|
|
1844
1820
|
if (err instanceof import_protocols6.CancelledError) {
|
|
1845
1821
|
(0, import_log8.log)("Epoch processing cancelled.", void 0, {
|
|
1846
1822
|
F: __dxlog_file9,
|
|
1847
|
-
L:
|
|
1823
|
+
L: 305,
|
|
1848
1824
|
S: this,
|
|
1849
1825
|
C: (f, a) => f(...a)
|
|
1850
1826
|
});
|
|
1851
1827
|
} else {
|
|
1852
1828
|
import_log8.log.catch(err, void 0, {
|
|
1853
1829
|
F: __dxlog_file9,
|
|
1854
|
-
L:
|
|
1830
|
+
L: 307,
|
|
1855
1831
|
S: this,
|
|
1856
1832
|
C: (f, a) => f(...a)
|
|
1857
1833
|
});
|
|
@@ -1874,7 +1850,7 @@ var DataPipeline = class {
|
|
|
1874
1850
|
async _processEpoch(ctx, epoch) {
|
|
1875
1851
|
(0, import_invariant8.invariant)(this._isOpen, "Space is closed.", {
|
|
1876
1852
|
F: __dxlog_file9,
|
|
1877
|
-
L:
|
|
1853
|
+
L: 331,
|
|
1878
1854
|
S: this,
|
|
1879
1855
|
A: [
|
|
1880
1856
|
"this._isOpen",
|
|
@@ -1883,7 +1859,7 @@ var DataPipeline = class {
|
|
|
1883
1859
|
});
|
|
1884
1860
|
(0, import_invariant8.invariant)(this._pipeline, void 0, {
|
|
1885
1861
|
F: __dxlog_file9,
|
|
1886
|
-
L:
|
|
1862
|
+
L: 332,
|
|
1887
1863
|
S: this,
|
|
1888
1864
|
A: [
|
|
1889
1865
|
"this._pipeline",
|
|
@@ -1895,7 +1871,7 @@ var DataPipeline = class {
|
|
|
1895
1871
|
epoch: (0, import_log8.omit)(epoch, "proof")
|
|
1896
1872
|
}, {
|
|
1897
1873
|
F: __dxlog_file9,
|
|
1898
|
-
L:
|
|
1874
|
+
L: 335,
|
|
1899
1875
|
S: this,
|
|
1900
1876
|
C: (f, a) => f(...a)
|
|
1901
1877
|
});
|
|
@@ -1905,7 +1881,7 @@ var DataPipeline = class {
|
|
|
1905
1881
|
}
|
|
1906
1882
|
(0, import_log8.log)("restarting pipeline from epoch", void 0, {
|
|
1907
1883
|
F: __dxlog_file9,
|
|
1908
|
-
L:
|
|
1884
|
+
L: 341,
|
|
1909
1885
|
S: this,
|
|
1910
1886
|
C: (f, a) => f(...a)
|
|
1911
1887
|
});
|
|
@@ -1916,7 +1892,7 @@ var DataPipeline = class {
|
|
|
1916
1892
|
async waitUntilTimeframe(timeframe) {
|
|
1917
1893
|
(0, import_invariant8.invariant)(this._pipeline, "Pipeline is not initialized.", {
|
|
1918
1894
|
F: __dxlog_file9,
|
|
1919
|
-
L:
|
|
1895
|
+
L: 348,
|
|
1920
1896
|
S: this,
|
|
1921
1897
|
A: [
|
|
1922
1898
|
"this._pipeline",
|
|
@@ -1928,7 +1904,7 @@ var DataPipeline = class {
|
|
|
1928
1904
|
async createEpoch() {
|
|
1929
1905
|
(0, import_invariant8.invariant)(this._pipeline, void 0, {
|
|
1930
1906
|
F: __dxlog_file9,
|
|
1931
|
-
L:
|
|
1907
|
+
L: 354,
|
|
1932
1908
|
S: this,
|
|
1933
1909
|
A: [
|
|
1934
1910
|
"this._pipeline",
|
|
@@ -1937,7 +1913,7 @@ var DataPipeline = class {
|
|
|
1937
1913
|
});
|
|
1938
1914
|
(0, import_invariant8.invariant)(this.currentEpoch, void 0, {
|
|
1939
1915
|
F: __dxlog_file9,
|
|
1940
|
-
L:
|
|
1916
|
+
L: 355,
|
|
1941
1917
|
S: this,
|
|
1942
1918
|
A: [
|
|
1943
1919
|
"this.currentEpoch",
|
|
@@ -1961,14 +1937,13 @@ var DataPipeline = class {
|
|
|
1961
1937
|
}
|
|
1962
1938
|
async _flush() {
|
|
1963
1939
|
try {
|
|
1964
|
-
await this._saveCache();
|
|
1965
1940
|
if (this._pipeline) {
|
|
1966
1941
|
await this._saveTargetTimeframe(this._pipeline.state.timeframe);
|
|
1967
1942
|
}
|
|
1968
1943
|
} catch (err) {
|
|
1969
1944
|
import_log8.log.catch(err, void 0, {
|
|
1970
1945
|
F: __dxlog_file9,
|
|
1971
|
-
L:
|
|
1946
|
+
L: 384,
|
|
1972
1947
|
S: this,
|
|
1973
1948
|
C: (f, a) => f(...a)
|
|
1974
1949
|
});
|
|
@@ -3217,7 +3192,7 @@ var AutomergeHost = class {
|
|
|
3217
3192
|
});
|
|
3218
3193
|
return false;
|
|
3219
3194
|
}
|
|
3220
|
-
const authorizedDevices = this._authorizedDevices.get(spaceKey);
|
|
3195
|
+
const authorizedDevices = this._authorizedDevices.get(import_keys8.PublicKey.from(spaceKey));
|
|
3221
3196
|
const deviceKeyHex = this.repo.peerMetadataByPeerId[peerId]?.dxos_deviceKey;
|
|
3222
3197
|
if (!deviceKeyHex) {
|
|
3223
3198
|
(0, import_log15.log)("device key not found for share policy check", {
|
|
@@ -3285,8 +3260,7 @@ var AutomergeHost = class {
|
|
|
3285
3260
|
});
|
|
3286
3261
|
}
|
|
3287
3262
|
_onUpdate(event) {
|
|
3288
|
-
|
|
3289
|
-
if (!spaceKey) {
|
|
3263
|
+
if (this._metadata == null) {
|
|
3290
3264
|
return;
|
|
3291
3265
|
}
|
|
3292
3266
|
const objectIds = getInlineChanges(event);
|
|
@@ -3298,22 +3272,20 @@ var AutomergeHost = class {
|
|
|
3298
3272
|
if (!lastAvailableHash) {
|
|
3299
3273
|
return;
|
|
3300
3274
|
}
|
|
3301
|
-
const
|
|
3302
|
-
|
|
3303
|
-
|
|
3304
|
-
|
|
3305
|
-
|
|
3306
|
-
|
|
3307
|
-
|
|
3308
|
-
|
|
3309
|
-
|
|
3310
|
-
}), lastAvailableHash));
|
|
3311
|
-
})).then(() => {
|
|
3275
|
+
const encodedIds = objectIds.map((objectId) => import_protocols8.idCodec.encode({
|
|
3276
|
+
documentId: event.handle.documentId,
|
|
3277
|
+
objectId
|
|
3278
|
+
}));
|
|
3279
|
+
const idToLastHash = new Map(encodedIds.map((id) => [
|
|
3280
|
+
id,
|
|
3281
|
+
lastAvailableHash
|
|
3282
|
+
]));
|
|
3283
|
+
const markingDirtyPromise = this._metadata.markDirty(idToLastHash).then(() => {
|
|
3312
3284
|
this._updatingMetadata.delete(event.handle.documentId);
|
|
3313
3285
|
}).catch((err) => {
|
|
3314
|
-
|
|
3286
|
+
this._ctx.disposed && import_log15.log.catch(err, void 0, {
|
|
3315
3287
|
F: __dxlog_file16,
|
|
3316
|
-
L:
|
|
3288
|
+
L: 188,
|
|
3317
3289
|
S: this,
|
|
3318
3290
|
C: (f, a) => f(...a)
|
|
3319
3291
|
});
|
|
@@ -3374,7 +3346,7 @@ var AutomergeHost = class {
|
|
|
3374
3346
|
deviceKey
|
|
3375
3347
|
}, {
|
|
3376
3348
|
F: __dxlog_file16,
|
|
3377
|
-
L:
|
|
3349
|
+
L: 255,
|
|
3378
3350
|
S: this,
|
|
3379
3351
|
C: (f, a) => f(...a)
|
|
3380
3352
|
});
|
|
@@ -3417,10 +3389,10 @@ var getInlineChanges = (event) => {
|
|
|
3417
3389
|
};
|
|
3418
3390
|
var getSpaceKeyFromDoc = (doc) => {
|
|
3419
3391
|
const rawSpaceKey = doc.access?.spaceKey ?? doc.experimental_spaceKey;
|
|
3420
|
-
if (
|
|
3421
|
-
return;
|
|
3392
|
+
if (rawSpaceKey == null) {
|
|
3393
|
+
return null;
|
|
3422
3394
|
}
|
|
3423
|
-
return rawSpaceKey;
|
|
3395
|
+
return String(rawSpaceKey);
|
|
3424
3396
|
};
|
|
3425
3397
|
// Annotate the CommonJS export names for ESM import in node:
|
|
3426
3398
|
0 && (module.exports = {
|
|
@@ -3454,4 +3426,4 @@ var getSpaceKeyFromDoc = (doc) => {
|
|
|
3454
3426
|
startAfter,
|
|
3455
3427
|
valueEncoding
|
|
3456
3428
|
});
|
|
3457
|
-
//# sourceMappingURL=chunk-
|
|
3429
|
+
//# sourceMappingURL=chunk-EVKDEZDX.cjs.map
|