@dxos/messaging 0.7.4 → 0.7.5-main.9cb18ac
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-U5OG65N2.mjs → chunk-YYX7KDG4.mjs} +27 -24
- package/dist/lib/browser/{chunk-U5OG65N2.mjs.map → chunk-YYX7KDG4.mjs.map} +3 -3
- 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-ZWQVINAC.cjs → chunk-S7WTA6W2.cjs} +28 -25
- package/dist/lib/node/{chunk-ZWQVINAC.cjs.map → chunk-S7WTA6W2.cjs.map} +3 -3
- package/dist/lib/node/index.cjs +9 -9
- package/dist/lib/node/index.cjs.map +1 -1
- package/dist/lib/node/meta.json +1 -1
- package/dist/lib/node/testing/index.cjs +4 -4
- package/dist/lib/node-esm/{chunk-NCL2P63O.mjs → chunk-3QYQGVCL.mjs} +27 -24
- package/dist/lib/node-esm/{chunk-NCL2P63O.mjs.map → chunk-3QYQGVCL.mjs.map} +3 -3
- package/dist/lib/node-esm/index.mjs +1 -1
- package/dist/lib/node-esm/meta.json +1 -1
- package/dist/lib/node-esm/testing/index.mjs +1 -1
- package/dist/types/src/signal-manager/edge-signal-manager.d.ts +1 -1
- package/dist/types/src/signal-manager/edge-signal-manager.d.ts.map +1 -1
- package/dist/types/src/signal-manager/memory-signal-manager.d.ts +2 -2
- package/dist/types/src/signal-manager/memory-signal-manager.d.ts.map +1 -1
- package/dist/types/src/signal-methods.d.ts +2 -2
- package/dist/types/src/signal-methods.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -0
- package/package.json +16 -16
- package/src/signal-manager/edge-signal-manager.ts +22 -15
- package/src/signal-methods.ts +2 -2
|
@@ -2005,9 +2005,9 @@ var EdgeSignalManager = class extends Resource3 {
|
|
|
2005
2005
|
this.swarmEvent = new Event5();
|
|
2006
2006
|
this.onMessage = new Event5();
|
|
2007
2007
|
/**
|
|
2008
|
-
*
|
|
2008
|
+
* Swarm key -> { peer: <own peer info>, joinedPeers: <state of swarm> }.
|
|
2009
2009
|
*/
|
|
2010
|
-
// TODO(mykola): This class should not contain swarm state. Temporary before network-manager API changes to accept list of peers.
|
|
2010
|
+
// TODO(mykola): This class should not contain swarm state joinedPeers. Temporary before network-manager API changes to accept list of peers.
|
|
2011
2011
|
this._swarmPeers = new ComplexMap4(PublicKey7.hash);
|
|
2012
2012
|
this._edgeConnection = edgeConnection;
|
|
2013
2013
|
}
|
|
@@ -2030,14 +2030,17 @@ var EdgeSignalManager = class extends Resource3 {
|
|
|
2030
2030
|
}
|
|
2031
2031
|
}, {
|
|
2032
2032
|
F: __dxlog_file7,
|
|
2033
|
-
L:
|
|
2033
|
+
L: 60,
|
|
2034
2034
|
S: this,
|
|
2035
2035
|
C: (f, a) => f(...a)
|
|
2036
2036
|
});
|
|
2037
2037
|
}
|
|
2038
|
-
this._swarmPeers.set(topic,
|
|
2038
|
+
this._swarmPeers.set(topic, {
|
|
2039
|
+
lastState: peer.state,
|
|
2040
|
+
joinedPeers: new ComplexSet4(PeerInfoHash)
|
|
2041
|
+
});
|
|
2039
2042
|
await this._edgeConnection.send(protocol.createMessage(SwarmRequestSchema, {
|
|
2040
|
-
serviceId: EdgeService.
|
|
2043
|
+
serviceId: EdgeService.SWARM,
|
|
2041
2044
|
source: createMessageSource(topic, peer),
|
|
2042
2045
|
payload: {
|
|
2043
2046
|
action: SwarmRequestAction.JOIN,
|
|
@@ -2050,7 +2053,7 @@ var EdgeSignalManager = class extends Resource3 {
|
|
|
2050
2053
|
async leave({ topic, peer }) {
|
|
2051
2054
|
this._swarmPeers.delete(topic);
|
|
2052
2055
|
await this._edgeConnection.send(protocol.createMessage(SwarmRequestSchema, {
|
|
2053
|
-
serviceId: EdgeService.
|
|
2056
|
+
serviceId: EdgeService.SWARM,
|
|
2054
2057
|
source: createMessageSource(topic, peer),
|
|
2055
2058
|
payload: {
|
|
2056
2059
|
action: SwarmRequestAction.LEAVE,
|
|
@@ -2070,13 +2073,13 @@ var EdgeSignalManager = class extends Resource3 {
|
|
|
2070
2073
|
}
|
|
2071
2074
|
}, {
|
|
2072
2075
|
F: __dxlog_file7,
|
|
2073
|
-
L:
|
|
2076
|
+
L: 93,
|
|
2074
2077
|
S: this,
|
|
2075
2078
|
C: (f, a) => f(...a)
|
|
2076
2079
|
});
|
|
2077
2080
|
}
|
|
2078
2081
|
await this._edgeConnection.send(protocol.createMessage(bufWkt.AnySchema, {
|
|
2079
|
-
serviceId: EdgeService.
|
|
2082
|
+
serviceId: EdgeService.SIGNAL,
|
|
2080
2083
|
source: message.author,
|
|
2081
2084
|
target: [
|
|
2082
2085
|
message.recipient
|
|
@@ -2093,11 +2096,11 @@ var EdgeSignalManager = class extends Resource3 {
|
|
|
2093
2096
|
}
|
|
2094
2097
|
_onMessage(message) {
|
|
2095
2098
|
switch (message.serviceId) {
|
|
2096
|
-
case EdgeService.
|
|
2099
|
+
case EdgeService.SWARM: {
|
|
2097
2100
|
this._processSwarmResponse(message);
|
|
2098
2101
|
break;
|
|
2099
2102
|
}
|
|
2100
|
-
case EdgeService.
|
|
2103
|
+
case EdgeService.SIGNAL: {
|
|
2101
2104
|
this._processMessage(message);
|
|
2102
2105
|
}
|
|
2103
2106
|
}
|
|
@@ -2105,7 +2108,7 @@ var EdgeSignalManager = class extends Resource3 {
|
|
|
2105
2108
|
_processSwarmResponse(message) {
|
|
2106
2109
|
invariant6(protocol.getPayloadType(message) === SwarmResponseSchema.typeName, "Wrong payload type", {
|
|
2107
2110
|
F: __dxlog_file7,
|
|
2108
|
-
L:
|
|
2111
|
+
L: 130,
|
|
2109
2112
|
S: this,
|
|
2110
2113
|
A: [
|
|
2111
2114
|
"protocol.getPayloadType(message) === SwarmResponseSchema.typeName",
|
|
@@ -2119,13 +2122,13 @@ var EdgeSignalManager = class extends Resource3 {
|
|
|
2119
2122
|
topic
|
|
2120
2123
|
}, {
|
|
2121
2124
|
F: __dxlog_file7,
|
|
2122
|
-
L:
|
|
2125
|
+
L: 134,
|
|
2123
2126
|
S: this,
|
|
2124
2127
|
C: (f, a) => f(...a)
|
|
2125
2128
|
});
|
|
2126
2129
|
return;
|
|
2127
2130
|
}
|
|
2128
|
-
const oldPeers = this._swarmPeers.get(topic);
|
|
2131
|
+
const { joinedPeers: oldPeers } = this._swarmPeers.get(topic);
|
|
2129
2132
|
const timestamp = message.timestamp ? new Date(Date.parse(message.timestamp)) : /* @__PURE__ */ new Date();
|
|
2130
2133
|
const newPeers = new ComplexSet4(PeerInfoHash, payload.peers);
|
|
2131
2134
|
for (const peer of newPeers) {
|
|
@@ -2151,12 +2154,12 @@ var EdgeSignalManager = class extends Resource3 {
|
|
|
2151
2154
|
}
|
|
2152
2155
|
});
|
|
2153
2156
|
}
|
|
2154
|
-
this._swarmPeers.
|
|
2157
|
+
this._swarmPeers.get(topic).joinedPeers = newPeers;
|
|
2155
2158
|
}
|
|
2156
2159
|
_processMessage(message) {
|
|
2157
2160
|
invariant6(protocol.getPayloadType(message) === bufWkt.AnySchema.typeName, "Wrong payload type", {
|
|
2158
2161
|
F: __dxlog_file7,
|
|
2159
|
-
L:
|
|
2162
|
+
L: 167,
|
|
2160
2163
|
S: this,
|
|
2161
2164
|
A: [
|
|
2162
2165
|
"protocol.getPayloadType(message) === bufWkt.AnySchema.typeName",
|
|
@@ -2166,7 +2169,7 @@ var EdgeSignalManager = class extends Resource3 {
|
|
|
2166
2169
|
const payload = protocol.getPayload(message, bufWkt.AnySchema);
|
|
2167
2170
|
invariant6(message.source, "source is missing", {
|
|
2168
2171
|
F: __dxlog_file7,
|
|
2169
|
-
L:
|
|
2172
|
+
L: 169,
|
|
2170
2173
|
S: this,
|
|
2171
2174
|
A: [
|
|
2172
2175
|
"message.source",
|
|
@@ -2175,7 +2178,7 @@ var EdgeSignalManager = class extends Resource3 {
|
|
|
2175
2178
|
});
|
|
2176
2179
|
invariant6(message.target, "target is missing", {
|
|
2177
2180
|
F: __dxlog_file7,
|
|
2178
|
-
L:
|
|
2181
|
+
L: 170,
|
|
2179
2182
|
S: this,
|
|
2180
2183
|
A: [
|
|
2181
2184
|
"message.target",
|
|
@@ -2184,7 +2187,7 @@ var EdgeSignalManager = class extends Resource3 {
|
|
|
2184
2187
|
});
|
|
2185
2188
|
invariant6(message.target.length === 1, "target should have exactly one item", {
|
|
2186
2189
|
F: __dxlog_file7,
|
|
2187
|
-
L:
|
|
2190
|
+
L: 171,
|
|
2188
2191
|
S: this,
|
|
2189
2192
|
A: [
|
|
2190
2193
|
"message.target.length === 1",
|
|
@@ -2208,16 +2211,17 @@ var EdgeSignalManager = class extends Resource3 {
|
|
|
2208
2211
|
swarms: Array.from(this._swarmPeers.keys())
|
|
2209
2212
|
}, {
|
|
2210
2213
|
F: __dxlog_file7,
|
|
2211
|
-
L:
|
|
2214
|
+
L: 190,
|
|
2212
2215
|
S: this,
|
|
2213
2216
|
C: (f, a) => f(...a)
|
|
2214
2217
|
});
|
|
2215
|
-
for (const topic of this._swarmPeers.
|
|
2218
|
+
for (const [topic, { lastState }] of this._swarmPeers.entries()) {
|
|
2216
2219
|
await this.join({
|
|
2217
2220
|
topic,
|
|
2218
2221
|
peer: {
|
|
2219
2222
|
peerKey: this._edgeConnection.peerKey,
|
|
2220
|
-
identityKey: this._edgeConnection.identityKey
|
|
2223
|
+
identityKey: this._edgeConnection.identityKey,
|
|
2224
|
+
state: lastState
|
|
2221
2225
|
}
|
|
2222
2226
|
});
|
|
2223
2227
|
}
|
|
@@ -2226,8 +2230,7 @@ var EdgeSignalManager = class extends Resource3 {
|
|
|
2226
2230
|
var createMessageSource = (topic, peerInfo) => {
|
|
2227
2231
|
return {
|
|
2228
2232
|
swarmKey: topic.toHex(),
|
|
2229
|
-
|
|
2230
|
-
peerKey: peerInfo.peerKey
|
|
2233
|
+
...peerInfo
|
|
2231
2234
|
};
|
|
2232
2235
|
};
|
|
2233
2236
|
|
|
@@ -2298,4 +2301,4 @@ export {
|
|
|
2298
2301
|
EdgeSignalManager,
|
|
2299
2302
|
setIdentityTags
|
|
2300
2303
|
};
|
|
2301
|
-
//# sourceMappingURL=chunk-
|
|
2304
|
+
//# sourceMappingURL=chunk-YYX7KDG4.mjs.map
|