@dxos/echo-pipeline 0.5.8 → 0.5.9-main.07b4bad
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-GANAND63.mjs → chunk-I2J5TTHJ.mjs} +48 -23
- package/dist/lib/browser/{chunk-GANAND63.mjs.map → chunk-I2J5TTHJ.mjs.map} +3 -3
- package/dist/lib/browser/index.mjs +31 -26
- package/dist/lib/browser/index.mjs.map +3 -3
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/testing/index.mjs +99 -4
- package/dist/lib/browser/testing/index.mjs.map +4 -4
- package/dist/lib/node/{chunk-M475BGBI.cjs → chunk-QPCNQ4ZK.cjs} +51 -25
- package/dist/lib/node/chunk-QPCNQ4ZK.cjs.map +7 -0
- package/dist/lib/node/index.cjs +52 -47
- package/dist/lib/node/index.cjs.map +3 -3
- package/dist/lib/node/meta.json +1 -1
- package/dist/lib/node/testing/index.cjs +107 -13
- package/dist/lib/node/testing/index.cjs.map +4 -4
- package/dist/types/src/automerge/automerge-doc-loader.d.ts +7 -3
- package/dist/types/src/automerge/automerge-doc-loader.d.ts.map +1 -1
- package/dist/types/src/automerge/automerge-host.d.ts.map +1 -1
- package/dist/types/src/automerge/migrations.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 +2 -2
- package/dist/types/src/space/space-protocol.d.ts.map +1 -1
- package/dist/types/src/space/space.d.ts +9 -1
- package/dist/types/src/space/space.d.ts.map +1 -1
- package/dist/types/src/testing/index.d.ts +1 -0
- package/dist/types/src/testing/index.d.ts.map +1 -1
- package/dist/types/src/testing/test-agent-builder.d.ts +2 -2
- package/dist/types/src/testing/test-agent-builder.d.ts.map +1 -1
- package/dist/types/src/testing/test-network-adapter.d.ts +18 -0
- package/dist/types/src/testing/test-network-adapter.d.ts.map +1 -0
- package/package.json +33 -33
- package/src/automerge/automerge-doc-loader.test.ts +5 -2
- package/src/automerge/automerge-doc-loader.ts +6 -4
- package/src/automerge/automerge-host.test.ts +1 -553
- package/src/automerge/automerge-host.ts +12 -5
- package/src/automerge/automerge-repo.test.ts +450 -2
- package/src/automerge/migrations.ts +2 -1
- package/src/automerge/storage-adapter.test.ts +81 -15
- package/src/space/space-manager.ts +6 -4
- package/src/space/space-protocol.test.ts +3 -3
- package/src/space/space-protocol.ts +3 -3
- package/src/space/space.ts +32 -2
- package/src/testing/index.ts +1 -0
- package/src/testing/test-agent-builder.ts +4 -4
- package/src/testing/test-network-adapter.ts +62 -0
- package/dist/lib/node/chunk-M475BGBI.cjs.map +0 -7
|
@@ -1150,11 +1150,13 @@ var AuthExtension = class extends RpcExtension {
|
|
|
1150
1150
|
// packages/core/echo/echo-pipeline/src/space/space.ts
|
|
1151
1151
|
import { Event as Event4, Mutex, synchronized as synchronized3, trackLeaks as trackLeaks2 } from "@dxos/async";
|
|
1152
1152
|
import { LifecycleState, Resource } from "@dxos/context";
|
|
1153
|
+
import { subtleCrypto as subtleCrypto2 } from "@dxos/crypto";
|
|
1153
1154
|
import { invariant as invariant6 } from "@dxos/invariant";
|
|
1155
|
+
import { PublicKey as PublicKey5, SpaceId } from "@dxos/keys";
|
|
1154
1156
|
import { log as log7, logInfo } from "@dxos/log";
|
|
1155
1157
|
import { AdmittedFeed as AdmittedFeed2 } from "@dxos/protocols/proto/dxos/halo/credentials";
|
|
1156
1158
|
import { trace as trace2 } from "@dxos/tracing";
|
|
1157
|
-
import { Callback as Callback2 } from "@dxos/util";
|
|
1159
|
+
import { Callback as Callback2, ComplexMap as ComplexMap3 } from "@dxos/util";
|
|
1158
1160
|
|
|
1159
1161
|
// packages/core/echo/echo-pipeline/src/space/control-pipeline.ts
|
|
1160
1162
|
import { DeferredTask, sleepWithContext as sleepWithContext2, trackLeaks } from "@dxos/async";
|
|
@@ -1439,13 +1441,14 @@ var Space = class extends Resource {
|
|
|
1439
1441
|
this.stateUpdate = new Event4();
|
|
1440
1442
|
invariant6(params.spaceKey && params.feedProvider, void 0, {
|
|
1441
1443
|
F: __dxlog_file8,
|
|
1442
|
-
L:
|
|
1444
|
+
L: 78,
|
|
1443
1445
|
S: this,
|
|
1444
1446
|
A: [
|
|
1445
1447
|
"params.spaceKey && params.feedProvider",
|
|
1446
1448
|
""
|
|
1447
1449
|
]
|
|
1448
1450
|
});
|
|
1451
|
+
this._id = params.id;
|
|
1449
1452
|
this._key = params.spaceKey;
|
|
1450
1453
|
this._genesisFeedKey = params.genesisFeed.key;
|
|
1451
1454
|
this._feedProvider = params.feedProvider;
|
|
@@ -1472,7 +1475,7 @@ var Space = class extends Resource {
|
|
|
1472
1475
|
credential
|
|
1473
1476
|
}, {
|
|
1474
1477
|
F: __dxlog_file8,
|
|
1475
|
-
L:
|
|
1478
|
+
L: 106,
|
|
1476
1479
|
S: this,
|
|
1477
1480
|
C: (f, a) => f(...a)
|
|
1478
1481
|
});
|
|
@@ -1483,7 +1486,7 @@ var Space = class extends Resource {
|
|
|
1483
1486
|
invitation
|
|
1484
1487
|
}, {
|
|
1485
1488
|
F: __dxlog_file8,
|
|
1486
|
-
L:
|
|
1489
|
+
L: 110,
|
|
1487
1490
|
S: this,
|
|
1488
1491
|
C: (f, a) => f(...a)
|
|
1489
1492
|
});
|
|
@@ -1494,7 +1497,7 @@ var Space = class extends Resource {
|
|
|
1494
1497
|
invitation
|
|
1495
1498
|
}, {
|
|
1496
1499
|
F: __dxlog_file8,
|
|
1497
|
-
L:
|
|
1500
|
+
L: 114,
|
|
1498
1501
|
S: this,
|
|
1499
1502
|
C: (f, a) => f(...a)
|
|
1500
1503
|
});
|
|
@@ -1508,7 +1511,7 @@ var Space = class extends Resource {
|
|
|
1508
1511
|
])
|
|
1509
1512
|
}), {
|
|
1510
1513
|
F: __dxlog_file8,
|
|
1511
|
-
L:
|
|
1514
|
+
L: 118,
|
|
1512
1515
|
S: this,
|
|
1513
1516
|
C: (f, a) => f(...a)
|
|
1514
1517
|
});
|
|
@@ -1517,6 +1520,9 @@ var Space = class extends Resource {
|
|
|
1517
1520
|
this.protocol = params.protocol;
|
|
1518
1521
|
this.protocol.addFeed(params.genesisFeed);
|
|
1519
1522
|
}
|
|
1523
|
+
get id() {
|
|
1524
|
+
return this._id;
|
|
1525
|
+
}
|
|
1520
1526
|
get key() {
|
|
1521
1527
|
return this._key;
|
|
1522
1528
|
}
|
|
@@ -1547,7 +1553,7 @@ var Space = class extends Resource {
|
|
|
1547
1553
|
async setControlFeed(feed) {
|
|
1548
1554
|
invariant6(!this._controlFeed, "Control feed already set.", {
|
|
1549
1555
|
F: __dxlog_file8,
|
|
1550
|
-
L:
|
|
1556
|
+
L: 171,
|
|
1551
1557
|
S: this,
|
|
1552
1558
|
A: [
|
|
1553
1559
|
"!this._controlFeed",
|
|
@@ -1561,7 +1567,7 @@ var Space = class extends Resource {
|
|
|
1561
1567
|
async setDataFeed(feed) {
|
|
1562
1568
|
invariant6(!this._dataFeed, "Data feed already set.", {
|
|
1563
1569
|
F: __dxlog_file8,
|
|
1564
|
-
L:
|
|
1570
|
+
L: 178,
|
|
1565
1571
|
S: this,
|
|
1566
1572
|
A: [
|
|
1567
1573
|
"!this._dataFeed",
|
|
@@ -1580,7 +1586,7 @@ var Space = class extends Resource {
|
|
|
1580
1586
|
async _open(ctx) {
|
|
1581
1587
|
log7("opening...", void 0, {
|
|
1582
1588
|
F: __dxlog_file8,
|
|
1583
|
-
L:
|
|
1589
|
+
L: 192,
|
|
1584
1590
|
S: this,
|
|
1585
1591
|
C: (f, a) => f(...a)
|
|
1586
1592
|
});
|
|
@@ -1588,7 +1594,7 @@ var Space = class extends Resource {
|
|
|
1588
1594
|
await this.protocol.start();
|
|
1589
1595
|
log7("opened", void 0, {
|
|
1590
1596
|
F: __dxlog_file8,
|
|
1591
|
-
L:
|
|
1597
|
+
L: 198,
|
|
1592
1598
|
S: this,
|
|
1593
1599
|
C: (f, a) => f(...a)
|
|
1594
1600
|
});
|
|
@@ -1598,7 +1604,7 @@ var Space = class extends Resource {
|
|
|
1598
1604
|
key: this._key
|
|
1599
1605
|
}, {
|
|
1600
1606
|
F: __dxlog_file8,
|
|
1601
|
-
L:
|
|
1607
|
+
L: 203,
|
|
1602
1608
|
S: this,
|
|
1603
1609
|
C: (f, a) => f(...a)
|
|
1604
1610
|
});
|
|
@@ -1606,7 +1612,7 @@ var Space = class extends Resource {
|
|
|
1606
1612
|
await this._controlPipeline.stop();
|
|
1607
1613
|
log7("closed", void 0, {
|
|
1608
1614
|
F: __dxlog_file8,
|
|
1609
|
-
L:
|
|
1615
|
+
L: 209,
|
|
1610
1616
|
S: this,
|
|
1611
1617
|
C: (f, a) => f(...a)
|
|
1612
1618
|
});
|
|
@@ -1618,6 +1624,10 @@ _ts_decorate5([
|
|
|
1618
1624
|
_ts_decorate5([
|
|
1619
1625
|
trace2.info()
|
|
1620
1626
|
], Space.prototype, "_controlPipeline", void 0);
|
|
1627
|
+
_ts_decorate5([
|
|
1628
|
+
logInfo,
|
|
1629
|
+
trace2.info()
|
|
1630
|
+
], Space.prototype, "id", null);
|
|
1621
1631
|
_ts_decorate5([
|
|
1622
1632
|
logInfo,
|
|
1623
1633
|
trace2.info()
|
|
@@ -1632,17 +1642,29 @@ Space = _ts_decorate5([
|
|
|
1632
1642
|
trackLeaks2("open", "close"),
|
|
1633
1643
|
trace2.resource()
|
|
1634
1644
|
], Space);
|
|
1645
|
+
var SPACE_IDS_CACHE = new ComplexMap3(PublicKey5.hash);
|
|
1646
|
+
var createIdFromSpaceKey = async (spaceKey) => {
|
|
1647
|
+
const cachedValue = SPACE_IDS_CACHE.get(spaceKey);
|
|
1648
|
+
if (cachedValue !== void 0) {
|
|
1649
|
+
return cachedValue;
|
|
1650
|
+
}
|
|
1651
|
+
const digest = await subtleCrypto2.digest("SHA-256", spaceKey.asUint8Array());
|
|
1652
|
+
const bytes = new Uint8Array(digest).slice(0, SpaceId.byteLength);
|
|
1653
|
+
const spaceId = SpaceId.encode(bytes);
|
|
1654
|
+
SPACE_IDS_CACHE.set(spaceKey, spaceId);
|
|
1655
|
+
return spaceId;
|
|
1656
|
+
};
|
|
1635
1657
|
|
|
1636
1658
|
// packages/core/echo/echo-pipeline/src/space/space-protocol.ts
|
|
1637
|
-
import { discoveryKey, subtleCrypto as
|
|
1638
|
-
import { PublicKey as
|
|
1659
|
+
import { discoveryKey, subtleCrypto as subtleCrypto3 } from "@dxos/crypto";
|
|
1660
|
+
import { PublicKey as PublicKey6 } from "@dxos/keys";
|
|
1639
1661
|
import { log as log8, logInfo as logInfo2 } from "@dxos/log";
|
|
1640
1662
|
import { MMSTTopology } from "@dxos/network-manager";
|
|
1641
1663
|
import { Teleport } from "@dxos/teleport";
|
|
1642
1664
|
import { BlobSync } from "@dxos/teleport-extension-object-sync";
|
|
1643
1665
|
import { ReplicatorExtension } from "@dxos/teleport-extension-replicator";
|
|
1644
1666
|
import { trace as trace3 } from "@dxos/tracing";
|
|
1645
|
-
import { ComplexMap as
|
|
1667
|
+
import { ComplexMap as ComplexMap4 } from "@dxos/util";
|
|
1646
1668
|
function _ts_decorate6(decorators, target, key, desc) {
|
|
1647
1669
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
1648
1670
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
|
|
@@ -1659,7 +1681,7 @@ var MOCK_AUTH_VERIFIER = async (nonce, credential) => true;
|
|
|
1659
1681
|
var SpaceProtocol = class {
|
|
1660
1682
|
constructor({ topic, swarmIdentity, networkManager, onSessionAuth, onAuthFailure, blobStore }) {
|
|
1661
1683
|
this._feeds = /* @__PURE__ */ new Set();
|
|
1662
|
-
this._sessions = new
|
|
1684
|
+
this._sessions = new ComplexMap4(PublicKey6.hash);
|
|
1663
1685
|
// TODO(burdon): Move to config (with sensible defaults).
|
|
1664
1686
|
this._topology = new MMSTTopology({
|
|
1665
1687
|
originateConnections: 4,
|
|
@@ -1674,7 +1696,7 @@ var SpaceProtocol = class {
|
|
|
1674
1696
|
this.blobSync = new BlobSync({
|
|
1675
1697
|
blobStore
|
|
1676
1698
|
});
|
|
1677
|
-
this._topic =
|
|
1699
|
+
this._topic = subtleCrypto3.digest("SHA-256", topic.asBuffer()).then(discoveryKey).then(PublicKey6.from);
|
|
1678
1700
|
}
|
|
1679
1701
|
get sessions() {
|
|
1680
1702
|
return this._sessions;
|
|
@@ -1855,10 +1877,10 @@ _ts_decorate6([
|
|
|
1855
1877
|
// packages/core/echo/echo-pipeline/src/space/space-manager.ts
|
|
1856
1878
|
import { synchronized as synchronized4, trackLeaks as trackLeaks3 } from "@dxos/async";
|
|
1857
1879
|
import { failUndefined as failUndefined2 } from "@dxos/debug";
|
|
1858
|
-
import { PublicKey as
|
|
1880
|
+
import { PublicKey as PublicKey7 } from "@dxos/keys";
|
|
1859
1881
|
import { log as log9 } from "@dxos/log";
|
|
1860
1882
|
import { trace as trace4 } from "@dxos/protocols";
|
|
1861
|
-
import { ComplexMap as
|
|
1883
|
+
import { ComplexMap as ComplexMap5 } from "@dxos/util";
|
|
1862
1884
|
function _ts_decorate7(decorators, target, key, desc) {
|
|
1863
1885
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
1864
1886
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
|
|
@@ -1872,8 +1894,8 @@ function _ts_decorate7(decorators, target, key, desc) {
|
|
|
1872
1894
|
var __dxlog_file10 = "/home/runner/work/dxos/dxos/packages/core/echo/echo-pipeline/src/space/space-manager.ts";
|
|
1873
1895
|
var SpaceManager = class {
|
|
1874
1896
|
constructor({ feedStore, networkManager, metadataStore, snapshotStore, blobStore }) {
|
|
1875
|
-
this._spaces = new
|
|
1876
|
-
this._instanceId =
|
|
1897
|
+
this._spaces = new ComplexMap5(PublicKey7.hash);
|
|
1898
|
+
this._instanceId = PublicKey7.random().toHex();
|
|
1877
1899
|
this._feedStore = feedStore;
|
|
1878
1900
|
this._networkManager = networkManager;
|
|
1879
1901
|
this._metadataStore = metadataStore;
|
|
@@ -1910,6 +1932,7 @@ var SpaceManager = class {
|
|
|
1910
1932
|
});
|
|
1911
1933
|
const genesisFeed = await this._feedStore.openFeed(metadata.genesisFeedKey ?? failUndefined2());
|
|
1912
1934
|
const spaceKey = metadata.key;
|
|
1935
|
+
const spaceId = await createIdFromSpaceKey(spaceKey);
|
|
1913
1936
|
const protocol = new SpaceProtocol({
|
|
1914
1937
|
topic: spaceKey,
|
|
1915
1938
|
swarmIdentity,
|
|
@@ -1920,6 +1943,7 @@ var SpaceManager = class {
|
|
|
1920
1943
|
});
|
|
1921
1944
|
const snapshotManager = new SnapshotManager(this._snapshotStore, this._blobStore, protocol.blobSync);
|
|
1922
1945
|
const space = new Space({
|
|
1946
|
+
id: spaceId,
|
|
1923
1947
|
spaceKey,
|
|
1924
1948
|
protocol,
|
|
1925
1949
|
genesisFeed,
|
|
@@ -1935,7 +1959,7 @@ var SpaceManager = class {
|
|
|
1935
1959
|
id: this._instanceId
|
|
1936
1960
|
}), {
|
|
1937
1961
|
F: __dxlog_file10,
|
|
1938
|
-
L:
|
|
1962
|
+
L: 126,
|
|
1939
1963
|
S: this,
|
|
1940
1964
|
C: (f, a) => f(...a)
|
|
1941
1965
|
});
|
|
@@ -1969,6 +1993,7 @@ export {
|
|
|
1969
1993
|
Pipeline,
|
|
1970
1994
|
AuthExtension,
|
|
1971
1995
|
Space,
|
|
1996
|
+
createIdFromSpaceKey,
|
|
1972
1997
|
MOCK_AUTH_PROVIDER,
|
|
1973
1998
|
MOCK_AUTH_VERIFIER,
|
|
1974
1999
|
SpaceProtocol,
|
|
@@ -1976,4 +2001,4 @@ export {
|
|
|
1976
2001
|
SpaceProtocolSession,
|
|
1977
2002
|
SpaceManager
|
|
1978
2003
|
};
|
|
1979
|
-
//# sourceMappingURL=chunk-
|
|
2004
|
+
//# sourceMappingURL=chunk-I2J5TTHJ.mjs.map
|