@dxos/messaging 0.8.4-main.ef1bc66f44 → 0.8.4-main.f466a3d56e
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/LICENSE +102 -5
- package/dist/lib/neutral/{chunk-5MOQVHHI.mjs → chunk-EC4H56J5.mjs} +49 -246
- package/dist/lib/neutral/chunk-EC4H56J5.mjs.map +7 -0
- package/dist/lib/neutral/index.mjs +112 -566
- package/dist/lib/neutral/index.mjs.map +3 -3
- package/dist/lib/neutral/meta.json +1 -1
- package/dist/lib/neutral/testing/index.mjs +4 -9
- package/dist/lib/neutral/testing/index.mjs.map +3 -3
- package/dist/types/src/messenger-monitor.d.ts.map +1 -1
- package/dist/types/src/messenger.blueprint-test.d.ts +1 -1
- package/dist/types/src/messenger.blueprint-test.d.ts.map +1 -1
- package/dist/types/src/messenger.d.ts +3 -2
- package/dist/types/src/messenger.d.ts.map +1 -1
- package/dist/types/src/signal-client/signal-client-monitor.d.ts.map +1 -1
- package/dist/types/src/signal-client/signal-client.d.ts +5 -6
- package/dist/types/src/signal-client/signal-client.d.ts.map +1 -1
- package/dist/types/src/signal-client/signal-local-state.d.ts.map +1 -1
- package/dist/types/src/signal-client/signal-rpc-client-monitor.d.ts.map +1 -1
- package/dist/types/src/signal-client/signal-rpc-client.d.ts +1 -1
- package/dist/types/src/signal-client/signal-rpc-client.d.ts.map +1 -1
- package/dist/types/src/signal-manager/edge-signal-manager.d.ts +5 -5
- 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 +5 -4
- package/dist/types/src/signal-manager/memory-signal-manager.d.ts.map +1 -1
- package/dist/types/src/signal-manager/utils.d.ts.map +1 -1
- package/dist/types/src/signal-manager/websocket-signal-manager-monitor.d.ts.map +1 -1
- package/dist/types/src/signal-manager/websocket-signal-manager.d.ts +5 -6
- package/dist/types/src/signal-manager/websocket-signal-manager.d.ts.map +1 -1
- package/dist/types/src/signal-methods.d.ts +5 -5
- package/dist/types/src/signal-methods.d.ts.map +1 -1
- package/dist/types/src/testing/test-builder.d.ts.map +1 -1
- package/dist/types/src/testing/test-peer.d.ts.map +1 -1
- package/dist/types/src/testing/utils.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +18 -25
- package/src/messenger.blueprint-test.ts +13 -12
- package/src/messenger.ts +33 -28
- package/src/signal-client/signal-client.node.test.ts +9 -9
- package/src/signal-client/signal-client.ts +6 -10
- package/src/signal-client/signal-local-state.ts +0 -1
- package/src/signal-client/signal-rpc-client.ts +2 -4
- package/src/signal-manager/edge-signal-manager.ts +10 -7
- package/src/signal-manager/memory-signal-manager.ts +17 -15
- package/src/signal-manager/websocket-signal-manager.node.test.ts +13 -13
- package/src/signal-manager/websocket-signal-manager.ts +9 -16
- package/src/signal-methods.ts +5 -5
- package/src/testing/test-builder.ts +4 -3
- package/src/testing/test-peer.ts +0 -1
- package/src/testing/utils.ts +0 -1
- package/dist/lib/neutral/chunk-5MOQVHHI.mjs.map +0 -7
package/LICENSE
CHANGED
|
@@ -1,8 +1,105 @@
|
|
|
1
|
-
|
|
2
|
-
Copyright (c) 2022 DXOS
|
|
1
|
+
# Functional Source License, Version 1.1, ALv2 Future License
|
|
3
2
|
|
|
4
|
-
|
|
3
|
+
## Abbreviation
|
|
5
4
|
|
|
6
|
-
|
|
5
|
+
FSL-1.1-Apache-2.0
|
|
7
6
|
|
|
8
|
-
|
|
7
|
+
## Notice
|
|
8
|
+
|
|
9
|
+
Copyright 2026 DXOS
|
|
10
|
+
|
|
11
|
+
## Terms and Conditions
|
|
12
|
+
|
|
13
|
+
### Licensor ("We")
|
|
14
|
+
|
|
15
|
+
The party offering the Software under these Terms and Conditions.
|
|
16
|
+
|
|
17
|
+
### The Software
|
|
18
|
+
|
|
19
|
+
The "Software" is each version of the software that we make available under
|
|
20
|
+
these Terms and Conditions, as indicated by our inclusion of these Terms and
|
|
21
|
+
Conditions with the Software.
|
|
22
|
+
|
|
23
|
+
### License Grant
|
|
24
|
+
|
|
25
|
+
Subject to your compliance with this License Grant and the Patents,
|
|
26
|
+
Redistribution and Trademark clauses below, we hereby grant you the right to
|
|
27
|
+
use, copy, modify, create derivative works, publicly perform, publicly display
|
|
28
|
+
and redistribute the Software for any Permitted Purpose identified below.
|
|
29
|
+
|
|
30
|
+
### Permitted Purpose
|
|
31
|
+
|
|
32
|
+
A Permitted Purpose is any purpose other than a Competing Use. A Competing Use
|
|
33
|
+
means making the Software available to others in a commercial product or
|
|
34
|
+
service that:
|
|
35
|
+
|
|
36
|
+
1. substitutes for the Software;
|
|
37
|
+
|
|
38
|
+
2. substitutes for any other product or service we offer using the Software
|
|
39
|
+
that exists as of the date we make the Software available; or
|
|
40
|
+
|
|
41
|
+
3. offers the same or substantially similar functionality as the Software.
|
|
42
|
+
|
|
43
|
+
Permitted Purposes specifically include using the Software:
|
|
44
|
+
|
|
45
|
+
1. for your internal use and access;
|
|
46
|
+
|
|
47
|
+
2. for non-commercial education;
|
|
48
|
+
|
|
49
|
+
3. for non-commercial research; and
|
|
50
|
+
|
|
51
|
+
4. in connection with professional services that you provide to a licensee
|
|
52
|
+
using the Software in accordance with these Terms and Conditions.
|
|
53
|
+
|
|
54
|
+
### Patents
|
|
55
|
+
|
|
56
|
+
To the extent your use for a Permitted Purpose would necessarily infringe our
|
|
57
|
+
patents, the license grant above includes a license under our patents. If you
|
|
58
|
+
make a claim against any party that the Software infringes or contributes to
|
|
59
|
+
the infringement of any patent, then your patent license to the Software ends
|
|
60
|
+
immediately.
|
|
61
|
+
|
|
62
|
+
### Redistribution
|
|
63
|
+
|
|
64
|
+
The Terms and Conditions apply to all copies, modifications and derivatives of
|
|
65
|
+
the Software.
|
|
66
|
+
|
|
67
|
+
If you redistribute any copies, modifications or derivatives of the Software,
|
|
68
|
+
you must include a copy of or a link to these Terms and Conditions and not
|
|
69
|
+
remove any copyright notices provided in or with the Software.
|
|
70
|
+
|
|
71
|
+
### Disclaimer
|
|
72
|
+
|
|
73
|
+
THE SOFTWARE IS PROVIDED "AS IS" AND WITHOUT WARRANTIES OF ANY KIND, EXPRESS OR
|
|
74
|
+
IMPLIED, INCLUDING WITHOUT LIMITATION WARRANTIES OF FITNESS FOR A PARTICULAR
|
|
75
|
+
PURPOSE, MERCHANTABILITY, TITLE OR NON-INFRINGEMENT.
|
|
76
|
+
|
|
77
|
+
IN NO EVENT WILL WE HAVE ANY LIABILITY TO YOU ARISING OUT OF OR RELATED TO THE
|
|
78
|
+
SOFTWARE, INCLUDING INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES,
|
|
79
|
+
EVEN IF WE HAVE BEEN INFORMED OF THEIR POSSIBILITY IN ADVANCE.
|
|
80
|
+
|
|
81
|
+
### Trademarks
|
|
82
|
+
|
|
83
|
+
Except for displaying the License Details and identifying us as the origin of
|
|
84
|
+
the Software, you have no right under these Terms and Conditions to use our
|
|
85
|
+
trademarks, trade names, service marks or product names.
|
|
86
|
+
|
|
87
|
+
## Grant of Future License
|
|
88
|
+
|
|
89
|
+
We hereby irrevocably grant you an additional license to use the Software under
|
|
90
|
+
the Apache License, Version 2.0 that is effective on the second anniversary of
|
|
91
|
+
the date we make the Software available. On or after that date, you may use the
|
|
92
|
+
Software under the Apache License, Version 2.0, in which case the following
|
|
93
|
+
will apply:
|
|
94
|
+
|
|
95
|
+
Licensed under the Apache License, Version 2.0 (the "License"); you may not use
|
|
96
|
+
this file except in compliance with the License.
|
|
97
|
+
|
|
98
|
+
You may obtain a copy of the License at
|
|
99
|
+
|
|
100
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
101
|
+
|
|
102
|
+
Unless required by applicable law or agreed to in writing, software distributed
|
|
103
|
+
under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
|
|
104
|
+
CONDITIONS OF ANY KIND, either express or implied. See the License for the
|
|
105
|
+
specific language governing permissions and limitations under the License.
|
|
@@ -6,7 +6,7 @@ import { Context } from "@dxos/context";
|
|
|
6
6
|
import { invariant } from "@dxos/invariant";
|
|
7
7
|
import { PublicKey } from "@dxos/keys";
|
|
8
8
|
import { log } from "@dxos/log";
|
|
9
|
-
import { TimeoutError as ProtocolTimeoutError
|
|
9
|
+
import { TimeoutError as ProtocolTimeoutError } from "@dxos/protocols";
|
|
10
10
|
import { schema } from "@dxos/protocols/proto";
|
|
11
11
|
import { ComplexMap, ComplexSet } from "@dxos/util";
|
|
12
12
|
|
|
@@ -59,49 +59,21 @@ var Messenger = class {
|
|
|
59
59
|
if (!this._closed) {
|
|
60
60
|
return;
|
|
61
61
|
}
|
|
62
|
-
|
|
63
|
-
log.trace("dxos.mesh.messenger.open", trace2.begin({
|
|
64
|
-
id: traceId
|
|
65
|
-
}), {
|
|
66
|
-
F: __dxlog_file,
|
|
67
|
-
L: 72,
|
|
68
|
-
S: this,
|
|
69
|
-
C: (f, a) => f(...a)
|
|
70
|
-
});
|
|
62
|
+
log("opening messenger", void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file, L: 43, S: this });
|
|
71
63
|
this._ctx = new Context({
|
|
72
|
-
onError: (err) => log.catch(err, void 0, {
|
|
73
|
-
|
|
74
|
-
L: 74,
|
|
75
|
-
S: this,
|
|
76
|
-
C: (f, a) => f(...a)
|
|
77
|
-
})
|
|
78
|
-
}, {
|
|
79
|
-
F: __dxlog_file,
|
|
80
|
-
L: 73
|
|
81
|
-
});
|
|
64
|
+
onError: (err) => log.catch(err, void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file, L: 45, S: this })
|
|
65
|
+
}, { "~LogMeta": "~LogMeta", F: __dxlog_file, L: 44 });
|
|
82
66
|
this._ctx.onDispose(this._signalManager.onMessage.on(async (message) => {
|
|
83
67
|
log("received message", {
|
|
84
68
|
from: message.author
|
|
85
|
-
}, {
|
|
86
|
-
F: __dxlog_file,
|
|
87
|
-
L: 78,
|
|
88
|
-
S: this,
|
|
89
|
-
C: (f, a) => f(...a)
|
|
90
|
-
});
|
|
69
|
+
}, { "~LogMeta": "~LogMeta", F: __dxlog_file, L: 48, S: this });
|
|
91
70
|
await this._handleMessage(message);
|
|
92
71
|
}));
|
|
93
72
|
scheduleTaskInterval(this._ctx, async () => {
|
|
94
73
|
this._performGc();
|
|
95
74
|
}, RECEIVED_MESSAGES_GC_INTERVAL);
|
|
96
75
|
this._closed = false;
|
|
97
|
-
log
|
|
98
|
-
id: traceId
|
|
99
|
-
}), {
|
|
100
|
-
F: __dxlog_file,
|
|
101
|
-
L: 93,
|
|
102
|
-
S: this,
|
|
103
|
-
C: (f, a) => f(...a)
|
|
104
|
-
});
|
|
76
|
+
log("opened messenger", void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file, L: 58, S: this });
|
|
105
77
|
}
|
|
106
78
|
async close() {
|
|
107
79
|
if (this._closed) {
|
|
@@ -110,40 +82,19 @@ var Messenger = class {
|
|
|
110
82
|
this._closed = true;
|
|
111
83
|
await this._ctx.dispose();
|
|
112
84
|
}
|
|
113
|
-
async sendMessage({ author, recipient, payload }) {
|
|
114
|
-
invariant(!this._closed, "Closed", {
|
|
115
|
-
F: __dxlog_file,
|
|
116
|
-
L: 105,
|
|
117
|
-
S: this,
|
|
118
|
-
A: [
|
|
119
|
-
"!this._closed",
|
|
120
|
-
"'Closed'"
|
|
121
|
-
]
|
|
122
|
-
});
|
|
85
|
+
async sendMessage(ctx, { author, recipient, payload }) {
|
|
86
|
+
invariant(!this._closed, "Closed", { "~LogMeta": "~LogMeta", F: __dxlog_file, L: 68, S: this, A: ["!this._closed", "'Closed'"] });
|
|
123
87
|
const messageContext = this._ctx.derive();
|
|
124
88
|
const reliablePayload = {
|
|
125
89
|
messageId: PublicKey.random(),
|
|
126
90
|
payload
|
|
127
91
|
};
|
|
128
|
-
invariant(!this._onAckCallbacks.has(reliablePayload.messageId), void 0, {
|
|
129
|
-
F: __dxlog_file,
|
|
130
|
-
L: 112,
|
|
131
|
-
S: this,
|
|
132
|
-
A: [
|
|
133
|
-
"!this._onAckCallbacks.has(reliablePayload.messageId!)",
|
|
134
|
-
""
|
|
135
|
-
]
|
|
136
|
-
});
|
|
92
|
+
invariant(!this._onAckCallbacks.has(reliablePayload.messageId), void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file, L: 74, S: this, A: ["!this._onAckCallbacks.has(reliablePayload.messageId)", ""] });
|
|
137
93
|
log("send message", {
|
|
138
94
|
messageId: reliablePayload.messageId,
|
|
139
95
|
author,
|
|
140
96
|
recipient
|
|
141
|
-
}, {
|
|
142
|
-
F: __dxlog_file,
|
|
143
|
-
L: 113,
|
|
144
|
-
S: this,
|
|
145
|
-
C: (f, a) => f(...a)
|
|
146
|
-
});
|
|
97
|
+
}, { "~LogMeta": "~LogMeta", F: __dxlog_file, L: 75, S: this });
|
|
147
98
|
let messageReceived;
|
|
148
99
|
let timeoutHit;
|
|
149
100
|
let sendAttempts = 0;
|
|
@@ -154,35 +105,20 @@ var Messenger = class {
|
|
|
154
105
|
scheduleExponentialBackoffTaskInterval(messageContext, async () => {
|
|
155
106
|
log("retrying message", {
|
|
156
107
|
messageId: reliablePayload.messageId
|
|
157
|
-
}, {
|
|
158
|
-
F: __dxlog_file,
|
|
159
|
-
L: 128,
|
|
160
|
-
S: this,
|
|
161
|
-
C: (f, a) => f(...a)
|
|
162
|
-
});
|
|
108
|
+
}, { "~LogMeta": "~LogMeta", F: __dxlog_file, L: 89, S: this });
|
|
163
109
|
sendAttempts++;
|
|
164
|
-
await this._encodeAndSend({
|
|
110
|
+
await this._encodeAndSend(ctx, {
|
|
165
111
|
author,
|
|
166
112
|
recipient,
|
|
167
113
|
reliablePayload
|
|
168
114
|
}).catch((err) => log("failed to send message", {
|
|
169
115
|
err
|
|
170
|
-
}, {
|
|
171
|
-
F: __dxlog_file,
|
|
172
|
-
L: 131,
|
|
173
|
-
S: this,
|
|
174
|
-
C: (f, a) => f(...a)
|
|
175
|
-
}));
|
|
116
|
+
}, { "~LogMeta": "~LogMeta", F: __dxlog_file, L: 97, S: this }));
|
|
176
117
|
}, this._retryDelay);
|
|
177
118
|
scheduleTask(messageContext, () => {
|
|
178
119
|
log("message not delivered", {
|
|
179
120
|
messageId: reliablePayload.messageId
|
|
180
|
-
}, {
|
|
181
|
-
F: __dxlog_file,
|
|
182
|
-
L: 140,
|
|
183
|
-
S: this,
|
|
184
|
-
C: (f, a) => f(...a)
|
|
185
|
-
});
|
|
121
|
+
}, { "~LogMeta": "~LogMeta", F: __dxlog_file, L: 102, S: this });
|
|
186
122
|
this._onAckCallbacks.delete(reliablePayload.messageId);
|
|
187
123
|
timeoutHit(new ProtocolTimeoutError({
|
|
188
124
|
message: "signaling message not delivered",
|
|
@@ -203,7 +139,7 @@ var Messenger = class {
|
|
|
203
139
|
sent: true
|
|
204
140
|
});
|
|
205
141
|
});
|
|
206
|
-
await this._encodeAndSend({
|
|
142
|
+
await this._encodeAndSend(ctx, {
|
|
207
143
|
author,
|
|
208
144
|
recipient,
|
|
209
145
|
reliablePayload
|
|
@@ -215,26 +151,10 @@ var Messenger = class {
|
|
|
215
151
|
* @param payloadType if not specified, onMessage will be subscribed to all types of messages.
|
|
216
152
|
*/
|
|
217
153
|
async listen({ peer, payloadType, onMessage }) {
|
|
218
|
-
invariant(!this._closed, "Closed", {
|
|
219
|
-
F: __dxlog_file,
|
|
220
|
-
L: 178,
|
|
221
|
-
S: this,
|
|
222
|
-
A: [
|
|
223
|
-
"!this._closed",
|
|
224
|
-
"'Closed'"
|
|
225
|
-
]
|
|
226
|
-
});
|
|
154
|
+
invariant(!this._closed, "Closed", { "~LogMeta": "~LogMeta", F: __dxlog_file, L: 136, S: this, A: ["!this._closed", "'Closed'"] });
|
|
227
155
|
await this._signalManager.subscribeMessages(peer);
|
|
228
156
|
let listeners;
|
|
229
|
-
invariant(peer.peerKey, "Peer key is required", {
|
|
230
|
-
F: __dxlog_file,
|
|
231
|
-
L: 182,
|
|
232
|
-
S: this,
|
|
233
|
-
A: [
|
|
234
|
-
"peer.peerKey",
|
|
235
|
-
"'Peer key is required'"
|
|
236
|
-
]
|
|
237
|
-
});
|
|
157
|
+
invariant(peer.peerKey, "Peer key is required", { "~LogMeta": "~LogMeta", F: __dxlog_file, L: 139, S: this, A: ["peer.peerKey", "'Peer key is required'"] });
|
|
238
158
|
if (!payloadType) {
|
|
239
159
|
listeners = this._defaultListeners.get(peer.peerKey);
|
|
240
160
|
if (!listeners) {
|
|
@@ -261,8 +181,8 @@ var Messenger = class {
|
|
|
261
181
|
}
|
|
262
182
|
};
|
|
263
183
|
}
|
|
264
|
-
async _encodeAndSend({ author, recipient, reliablePayload }) {
|
|
265
|
-
await this._signalManager.sendMessage({
|
|
184
|
+
async _encodeAndSend(ctx, { author, recipient, reliablePayload }) {
|
|
185
|
+
await this._signalManager.sendMessage(ctx, {
|
|
266
186
|
author,
|
|
267
187
|
recipient,
|
|
268
188
|
payload: {
|
|
@@ -288,28 +208,15 @@ var Messenger = class {
|
|
|
288
208
|
}
|
|
289
209
|
}
|
|
290
210
|
async _handleReliablePayload({ author, recipient, payload }) {
|
|
291
|
-
invariant(payload.type_url === "dxos.mesh.messaging.ReliablePayload", void 0, {
|
|
292
|
-
F: __dxlog_file,
|
|
293
|
-
L: 240,
|
|
294
|
-
S: this,
|
|
295
|
-
A: [
|
|
296
|
-
"payload.type_url === 'dxos.mesh.messaging.ReliablePayload'",
|
|
297
|
-
""
|
|
298
|
-
]
|
|
299
|
-
});
|
|
211
|
+
invariant(payload.type_url === "dxos.mesh.messaging.ReliablePayload", void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file, L: 195, S: this, A: ["payload.type_url === 'dxos.mesh.messaging.ReliablePayload'", ""] });
|
|
300
212
|
const reliablePayload = ReliablePayload.decode(payload.value, {
|
|
301
213
|
preserveAny: true
|
|
302
214
|
});
|
|
303
215
|
log("handling message", {
|
|
304
216
|
messageId: reliablePayload.messageId
|
|
305
|
-
}, {
|
|
306
|
-
F: __dxlog_file,
|
|
307
|
-
L: 243,
|
|
308
|
-
S: this,
|
|
309
|
-
C: (f, a) => f(...a)
|
|
310
|
-
});
|
|
217
|
+
}, { "~LogMeta": "~LogMeta", F: __dxlog_file, L: 199, S: this });
|
|
311
218
|
try {
|
|
312
|
-
await this._sendAcknowledgement({
|
|
219
|
+
await this._sendAcknowledgement(this._ctx, {
|
|
313
220
|
author,
|
|
314
221
|
recipient,
|
|
315
222
|
messageId: reliablePayload.messageId
|
|
@@ -329,29 +236,16 @@ var Messenger = class {
|
|
|
329
236
|
});
|
|
330
237
|
}
|
|
331
238
|
async _handleAcknowledgement({ payload }) {
|
|
332
|
-
invariant(payload.type_url === "dxos.mesh.messaging.Acknowledgement", void 0, {
|
|
333
|
-
F: __dxlog_file,
|
|
334
|
-
L: 271,
|
|
335
|
-
S: this,
|
|
336
|
-
A: [
|
|
337
|
-
"payload.type_url === 'dxos.mesh.messaging.Acknowledgement'",
|
|
338
|
-
""
|
|
339
|
-
]
|
|
340
|
-
});
|
|
239
|
+
invariant(payload.type_url === "dxos.mesh.messaging.Acknowledgement", void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file, L: 224, S: this, A: ["payload.type_url === 'dxos.mesh.messaging.Acknowledgement'", ""] });
|
|
341
240
|
this._onAckCallbacks.get(Acknowledgement.decode(payload.value).messageId)?.();
|
|
342
241
|
}
|
|
343
|
-
async _sendAcknowledgement({ author, recipient, messageId }) {
|
|
242
|
+
async _sendAcknowledgement(ctx, { author, recipient, messageId }) {
|
|
344
243
|
log("sending ACK", {
|
|
345
244
|
messageId,
|
|
346
245
|
from: recipient,
|
|
347
246
|
to: author
|
|
348
|
-
}, {
|
|
349
|
-
|
|
350
|
-
L: 284,
|
|
351
|
-
S: this,
|
|
352
|
-
C: (f, a) => f(...a)
|
|
353
|
-
});
|
|
354
|
-
await this._signalManager.sendMessage({
|
|
247
|
+
}, { "~LogMeta": "~LogMeta", F: __dxlog_file, L: 228, S: this });
|
|
248
|
+
await this._signalManager.sendMessage(ctx, {
|
|
355
249
|
author: recipient,
|
|
356
250
|
recipient: author,
|
|
357
251
|
payload: {
|
|
@@ -364,15 +258,7 @@ var Messenger = class {
|
|
|
364
258
|
}
|
|
365
259
|
async _callListeners(message) {
|
|
366
260
|
{
|
|
367
|
-
invariant(message.recipient.peerKey, "Peer key is required", {
|
|
368
|
-
F: __dxlog_file,
|
|
369
|
-
L: 298,
|
|
370
|
-
S: this,
|
|
371
|
-
A: [
|
|
372
|
-
"message.recipient.peerKey",
|
|
373
|
-
"'Peer key is required'"
|
|
374
|
-
]
|
|
375
|
-
});
|
|
261
|
+
invariant(message.recipient.peerKey, "Peer key is required", { "~LogMeta": "~LogMeta", F: __dxlog_file, L: 246, S: this, A: ["message.recipient.peerKey", "'Peer key is required'"] });
|
|
376
262
|
const defaultListenerMap = this._defaultListeners.get(message.recipient.peerKey);
|
|
377
263
|
if (defaultListenerMap) {
|
|
378
264
|
for (const listener of defaultListenerMap) {
|
|
@@ -405,12 +291,7 @@ var Messenger = class {
|
|
|
405
291
|
if (elapsed > 100) {
|
|
406
292
|
log.warn("GC took too long", {
|
|
407
293
|
elapsed
|
|
408
|
-
}, {
|
|
409
|
-
F: __dxlog_file,
|
|
410
|
-
L: 333,
|
|
411
|
-
S: this,
|
|
412
|
-
C: (f, a) => f(...a)
|
|
413
|
-
});
|
|
294
|
+
}, { "~LogMeta": "~LogMeta", F: __dxlog_file, L: 277, S: this });
|
|
414
295
|
}
|
|
415
296
|
}
|
|
416
297
|
};
|
|
@@ -447,24 +328,18 @@ var MemorySignalManager = class {
|
|
|
447
328
|
_freezeTrigger = new Trigger().wake();
|
|
448
329
|
constructor(_context) {
|
|
449
330
|
this._context = _context;
|
|
450
|
-
this._ctx = new Context2(void 0, {
|
|
451
|
-
F: __dxlog_file2,
|
|
452
|
-
L: 54
|
|
453
|
-
});
|
|
331
|
+
this._ctx = new Context2(void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file2, L: 35 });
|
|
454
332
|
this._ctx.onDispose(this._context.swarmEvent.on((data) => this.swarmEvent.emit(data)));
|
|
455
333
|
}
|
|
456
334
|
async open() {
|
|
457
335
|
if (!this._ctx.disposed) {
|
|
458
336
|
return;
|
|
459
337
|
}
|
|
460
|
-
this._ctx = new Context2(void 0, {
|
|
461
|
-
F: __dxlog_file2,
|
|
462
|
-
L: 63
|
|
463
|
-
});
|
|
338
|
+
this._ctx = new Context2(void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file2, L: 42 });
|
|
464
339
|
this._ctx.onDispose(this._context.swarmEvent.on((data) => this.swarmEvent.emit(data)));
|
|
465
340
|
await Promise.all([
|
|
466
341
|
...this._joinedSwarms.values()
|
|
467
|
-
].map((value) => this.join(value)));
|
|
342
|
+
].map((value) => this.join(this._ctx, value)));
|
|
468
343
|
}
|
|
469
344
|
async close() {
|
|
470
345
|
if (this._ctx.disposed) {
|
|
@@ -475,23 +350,15 @@ var MemorySignalManager = class {
|
|
|
475
350
|
]);
|
|
476
351
|
await Promise.all([
|
|
477
352
|
...this._joinedSwarms.values()
|
|
478
|
-
].map((value) => this.leave(value)));
|
|
353
|
+
].map((value) => this.leave(this._ctx, value)));
|
|
479
354
|
this._joinedSwarms = joinedSwarmsCopy;
|
|
480
355
|
await this._ctx.dispose();
|
|
481
356
|
}
|
|
482
357
|
getStatus() {
|
|
483
358
|
return [];
|
|
484
359
|
}
|
|
485
|
-
async join({ topic, peer }) {
|
|
486
|
-
invariant2(!this._ctx.disposed, "Closed", {
|
|
487
|
-
F: __dxlog_file2,
|
|
488
|
-
L: 92,
|
|
489
|
-
S: this,
|
|
490
|
-
A: [
|
|
491
|
-
"!this._ctx.disposed",
|
|
492
|
-
"'Closed'"
|
|
493
|
-
]
|
|
494
|
-
});
|
|
360
|
+
async join(_ctx, { topic, peer }) {
|
|
361
|
+
invariant2(!this._ctx.disposed, "Closed", { "~LogMeta": "~LogMeta", F: __dxlog_file2, L: 67, S: this, A: ["!this._ctx.disposed", "'Closed'"] });
|
|
495
362
|
this._joinedSwarms.add({
|
|
496
363
|
topic,
|
|
497
364
|
peer
|
|
@@ -519,16 +386,8 @@ var MemorySignalManager = class {
|
|
|
519
386
|
});
|
|
520
387
|
}
|
|
521
388
|
}
|
|
522
|
-
async leave({ topic, peer }) {
|
|
523
|
-
invariant2(!this._ctx.disposed, "Closed", {
|
|
524
|
-
F: __dxlog_file2,
|
|
525
|
-
L: 124,
|
|
526
|
-
S: this,
|
|
527
|
-
A: [
|
|
528
|
-
"!this._ctx.disposed",
|
|
529
|
-
"'Closed'"
|
|
530
|
-
]
|
|
531
|
-
});
|
|
389
|
+
async leave(_ctx, { topic, peer }) {
|
|
390
|
+
invariant2(!this._ctx.disposed, "Closed", { "~LogMeta": "~LogMeta", F: __dxlog_file2, L: 97, S: this, A: ["!this._ctx.disposed", "'Closed'"] });
|
|
532
391
|
this._joinedSwarms.delete({
|
|
533
392
|
topic,
|
|
534
393
|
peer
|
|
@@ -545,62 +404,31 @@ var MemorySignalManager = class {
|
|
|
545
404
|
};
|
|
546
405
|
this._context.swarmEvent.emit(swarmEvent);
|
|
547
406
|
}
|
|
548
|
-
async query(request) {
|
|
407
|
+
async query(_ctx, request) {
|
|
549
408
|
throw new Error("Not implemented");
|
|
550
409
|
}
|
|
551
|
-
async sendMessage({ author, recipient, payload }) {
|
|
410
|
+
async sendMessage(_ctx, { author, recipient, payload }) {
|
|
552
411
|
log2("send message", {
|
|
553
412
|
author,
|
|
554
413
|
recipient,
|
|
555
414
|
...dec(payload)
|
|
556
|
-
}, {
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
S: this,
|
|
560
|
-
C: (f, a) => f(...a)
|
|
561
|
-
});
|
|
562
|
-
invariant2(recipient, void 0, {
|
|
563
|
-
F: __dxlog_file2,
|
|
564
|
-
L: 159,
|
|
565
|
-
S: this,
|
|
566
|
-
A: [
|
|
567
|
-
"recipient",
|
|
568
|
-
""
|
|
569
|
-
]
|
|
570
|
-
});
|
|
571
|
-
invariant2(!this._ctx.disposed, "Closed", {
|
|
572
|
-
F: __dxlog_file2,
|
|
573
|
-
L: 160,
|
|
574
|
-
S: this,
|
|
575
|
-
A: [
|
|
576
|
-
"!this._ctx.disposed",
|
|
577
|
-
"'Closed'"
|
|
578
|
-
]
|
|
579
|
-
});
|
|
415
|
+
}, { "~LogMeta": "~LogMeta", F: __dxlog_file2, L: 118, S: this });
|
|
416
|
+
invariant2(recipient, void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file2, L: 123, S: this, A: ["recipient", ""] });
|
|
417
|
+
invariant2(!this._ctx.disposed, "Closed", { "~LogMeta": "~LogMeta", F: __dxlog_file2, L: 124, S: this, A: ["!this._ctx.disposed", "'Closed'"] });
|
|
580
418
|
await this._freezeTrigger.wait();
|
|
581
419
|
const remote = this._context.connections.get(recipient);
|
|
582
420
|
if (!remote) {
|
|
583
421
|
log2.warn("recipient is not subscribed for messages", {
|
|
584
422
|
author,
|
|
585
423
|
recipient
|
|
586
|
-
}, {
|
|
587
|
-
F: __dxlog_file2,
|
|
588
|
-
L: 166,
|
|
589
|
-
S: this,
|
|
590
|
-
C: (f, a) => f(...a)
|
|
591
|
-
});
|
|
424
|
+
}, { "~LogMeta": "~LogMeta", F: __dxlog_file2, L: 128, S: this });
|
|
592
425
|
return;
|
|
593
426
|
}
|
|
594
427
|
if (remote._ctx.disposed) {
|
|
595
428
|
log2.warn("recipient is disposed", {
|
|
596
429
|
author,
|
|
597
430
|
recipient
|
|
598
|
-
}, {
|
|
599
|
-
F: __dxlog_file2,
|
|
600
|
-
L: 171,
|
|
601
|
-
S: this,
|
|
602
|
-
C: (f, a) => f(...a)
|
|
603
|
-
});
|
|
431
|
+
}, { "~LogMeta": "~LogMeta", F: __dxlog_file2, L: 135, S: this });
|
|
604
432
|
return;
|
|
605
433
|
}
|
|
606
434
|
remote._freezeTrigger.wait().then(() => {
|
|
@@ -608,24 +436,14 @@ var MemorySignalManager = class {
|
|
|
608
436
|
log2.warn("recipient is disposed", {
|
|
609
437
|
author,
|
|
610
438
|
recipient
|
|
611
|
-
}, {
|
|
612
|
-
F: __dxlog_file2,
|
|
613
|
-
L: 179,
|
|
614
|
-
S: this,
|
|
615
|
-
C: (f, a) => f(...a)
|
|
616
|
-
});
|
|
439
|
+
}, { "~LogMeta": "~LogMeta", F: __dxlog_file2, L: 143, S: this });
|
|
617
440
|
return;
|
|
618
441
|
}
|
|
619
442
|
log2("receive message", {
|
|
620
443
|
author,
|
|
621
444
|
recipient,
|
|
622
445
|
...dec(payload)
|
|
623
|
-
}, {
|
|
624
|
-
F: __dxlog_file2,
|
|
625
|
-
L: 183,
|
|
626
|
-
S: this,
|
|
627
|
-
C: (f, a) => f(...a)
|
|
628
|
-
});
|
|
446
|
+
}, { "~LogMeta": "~LogMeta", F: __dxlog_file2, L: 149, S: this });
|
|
629
447
|
remote.onMessage.emit({
|
|
630
448
|
author,
|
|
631
449
|
recipient,
|
|
@@ -634,34 +452,19 @@ var MemorySignalManager = class {
|
|
|
634
452
|
}).catch((err) => {
|
|
635
453
|
log2.error("error while waiting for freeze", {
|
|
636
454
|
err
|
|
637
|
-
}, {
|
|
638
|
-
F: __dxlog_file2,
|
|
639
|
-
L: 188,
|
|
640
|
-
S: this,
|
|
641
|
-
C: (f, a) => f(...a)
|
|
642
|
-
});
|
|
455
|
+
}, { "~LogMeta": "~LogMeta", F: __dxlog_file2, L: 160, S: this });
|
|
643
456
|
});
|
|
644
457
|
}
|
|
645
458
|
async subscribeMessages(peerInfo) {
|
|
646
459
|
log2("subscribing", {
|
|
647
460
|
peerInfo
|
|
648
|
-
}, {
|
|
649
|
-
F: __dxlog_file2,
|
|
650
|
-
L: 193,
|
|
651
|
-
S: this,
|
|
652
|
-
C: (f, a) => f(...a)
|
|
653
|
-
});
|
|
461
|
+
}, { "~LogMeta": "~LogMeta", F: __dxlog_file2, L: 166, S: this });
|
|
654
462
|
this._context.connections.set(peerInfo, this);
|
|
655
463
|
}
|
|
656
464
|
async unsubscribeMessages(peerInfo) {
|
|
657
465
|
log2("unsubscribing", {
|
|
658
466
|
peerInfo
|
|
659
|
-
}, {
|
|
660
|
-
F: __dxlog_file2,
|
|
661
|
-
L: 198,
|
|
662
|
-
S: this,
|
|
663
|
-
C: (f, a) => f(...a)
|
|
664
|
-
});
|
|
467
|
+
}, { "~LogMeta": "~LogMeta", F: __dxlog_file2, L: 172, S: this });
|
|
665
468
|
this._context.connections.delete(peerInfo);
|
|
666
469
|
}
|
|
667
470
|
freeze() {
|
|
@@ -691,4 +494,4 @@ export {
|
|
|
691
494
|
MemorySignalManagerContext,
|
|
692
495
|
MemorySignalManager
|
|
693
496
|
};
|
|
694
|
-
//# sourceMappingURL=chunk-
|
|
497
|
+
//# sourceMappingURL=chunk-EC4H56J5.mjs.map
|