@dxos/edge-client 0.6.12-main.ed7cda7 → 0.6.12-staging.0b4bb48
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/index.mjs +157 -57
- package/dist/lib/browser/index.mjs.map +4 -4
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/node/index.cjs +154 -56
- package/dist/lib/node/index.cjs.map +4 -4
- package/dist/lib/node/meta.json +1 -1
- package/dist/types/src/defs.d.ts.map +1 -1
- package/dist/types/src/edge-client.d.ts +2 -3
- package/dist/types/src/edge-client.d.ts.map +1 -1
- package/dist/types/src/errors.d.ts +1 -4
- package/dist/types/src/errors.d.ts.map +1 -1
- package/dist/types/src/index.d.ts +0 -1
- package/dist/types/src/index.d.ts.map +1 -1
- package/dist/types/src/protocol.d.ts +2 -2
- package/dist/types/src/protocol.d.ts.map +1 -1
- package/dist/types/src/test-utils.d.ts +11 -0
- package/dist/types/src/test-utils.d.ts.map +1 -0
- package/package.json +14 -26
- package/src/defs.ts +3 -2
- package/src/edge-client.test.ts +11 -11
- package/src/edge-client.ts +8 -17
- package/src/errors.ts +2 -8
- package/src/index.ts +0 -1
- package/src/persistent-lifecycle.test.ts +2 -2
- package/src/protocol.test.ts +2 -1
- package/src/protocol.ts +2 -2
- package/src/test-utils.ts +49 -0
- package/src/websocket.test.ts +4 -5
- package/dist/lib/browser/chunk-ZWJXA37R.mjs +0 -113
- package/dist/lib/browser/chunk-ZWJXA37R.mjs.map +0 -7
- package/dist/lib/browser/testing/index.mjs +0 -122
- package/dist/lib/browser/testing/index.mjs.map +0 -7
- package/dist/lib/node/chunk-ANV2HBEH.cjs +0 -136
- package/dist/lib/node/chunk-ANV2HBEH.cjs.map +0 -7
- package/dist/lib/node/testing/index.cjs +0 -152
- package/dist/lib/node/testing/index.cjs.map +0 -7
- package/dist/lib/node-esm/chunk-HNVT57AU.mjs +0 -115
- package/dist/lib/node-esm/chunk-HNVT57AU.mjs.map +0 -7
- package/dist/lib/node-esm/index.mjs +0 -378
- package/dist/lib/node-esm/index.mjs.map +0 -7
- package/dist/lib/node-esm/meta.json +0 -1
- package/dist/lib/node-esm/testing/index.mjs +0 -123
- package/dist/lib/node-esm/testing/index.mjs.map +0 -7
- package/dist/types/src/testing/index.d.ts +0 -2
- package/dist/types/src/testing/index.d.ts.map +0 -1
- package/dist/types/src/testing/test-utils.d.ts +0 -20
- package/dist/types/src/testing/test-utils.d.ts.map +0 -1
- package/src/testing/index.ts +0 -5
- package/src/testing/test-utils.ts +0 -111
|
@@ -1,378 +0,0 @@
|
|
|
1
|
-
import { createRequire } from 'node:module';const require = createRequire(import.meta.url);
|
|
2
|
-
import {
|
|
3
|
-
Protocol,
|
|
4
|
-
getTypename,
|
|
5
|
-
protocol,
|
|
6
|
-
toUint8Array
|
|
7
|
-
} from "./chunk-HNVT57AU.mjs";
|
|
8
|
-
|
|
9
|
-
// packages/core/mesh/edge-client/src/index.ts
|
|
10
|
-
export * from "@dxos/protocols/buf/dxos/edge/messenger_pb";
|
|
11
|
-
|
|
12
|
-
// packages/core/mesh/edge-client/src/edge-client.ts
|
|
13
|
-
import WebSocket from "isomorphic-ws";
|
|
14
|
-
import { Trigger, Event, scheduleTaskInterval, scheduleTask, TriggerState } from "@dxos/async";
|
|
15
|
-
import { Context, LifecycleState as LifecycleState2, Resource as Resource2 } from "@dxos/context";
|
|
16
|
-
import { log as log2 } from "@dxos/log";
|
|
17
|
-
import { buf } from "@dxos/protocols/buf";
|
|
18
|
-
import { MessageSchema } from "@dxos/protocols/buf/dxos/edge/messenger_pb";
|
|
19
|
-
|
|
20
|
-
// packages/core/mesh/edge-client/src/errors.ts
|
|
21
|
-
var EdgeConnectionClosedError = class extends Error {
|
|
22
|
-
constructor() {
|
|
23
|
-
super("Edge connection closed.");
|
|
24
|
-
}
|
|
25
|
-
};
|
|
26
|
-
var EdgeIdentityChangedError = class extends Error {
|
|
27
|
-
constructor() {
|
|
28
|
-
super("Edge identity changed.");
|
|
29
|
-
}
|
|
30
|
-
};
|
|
31
|
-
|
|
32
|
-
// packages/core/mesh/edge-client/src/persistent-lifecycle.ts
|
|
33
|
-
import { DeferredTask, sleep, synchronized } from "@dxos/async";
|
|
34
|
-
import { cancelWithContext, LifecycleState, Resource } from "@dxos/context";
|
|
35
|
-
import { warnAfterTimeout } from "@dxos/debug";
|
|
36
|
-
import { log } from "@dxos/log";
|
|
37
|
-
function _ts_decorate(decorators, target, key, desc) {
|
|
38
|
-
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
39
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
40
|
-
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
41
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
42
|
-
}
|
|
43
|
-
var __dxlog_file = "/home/runner/work/dxos/dxos/packages/core/mesh/edge-client/src/persistent-lifecycle.ts";
|
|
44
|
-
var INIT_RESTART_DELAY = 100;
|
|
45
|
-
var DEFAULT_MAX_RESTART_DELAY = 5e3;
|
|
46
|
-
var PersistentLifecycle = class extends Resource {
|
|
47
|
-
constructor({ start, stop, onRestart, maxRestartDelay = DEFAULT_MAX_RESTART_DELAY }) {
|
|
48
|
-
super();
|
|
49
|
-
this._restartTask = void 0;
|
|
50
|
-
this._restartAfter = 0;
|
|
51
|
-
this._start = start;
|
|
52
|
-
this._stop = stop;
|
|
53
|
-
this._onRestart = onRestart;
|
|
54
|
-
this._maxRestartDelay = maxRestartDelay;
|
|
55
|
-
}
|
|
56
|
-
async _open() {
|
|
57
|
-
this._restartTask = new DeferredTask(this._ctx, async () => {
|
|
58
|
-
try {
|
|
59
|
-
await this._restart();
|
|
60
|
-
} catch (err) {
|
|
61
|
-
log.warn("Restart failed", {
|
|
62
|
-
err
|
|
63
|
-
}, {
|
|
64
|
-
F: __dxlog_file,
|
|
65
|
-
L: 64,
|
|
66
|
-
S: this,
|
|
67
|
-
C: (f, a) => f(...a)
|
|
68
|
-
});
|
|
69
|
-
this._restartTask?.schedule();
|
|
70
|
-
}
|
|
71
|
-
});
|
|
72
|
-
await this._start().catch((err) => {
|
|
73
|
-
log.warn("Start failed", {
|
|
74
|
-
err
|
|
75
|
-
}, {
|
|
76
|
-
F: __dxlog_file,
|
|
77
|
-
L: 69,
|
|
78
|
-
S: this,
|
|
79
|
-
C: (f, a) => f(...a)
|
|
80
|
-
});
|
|
81
|
-
this._restartTask?.schedule();
|
|
82
|
-
});
|
|
83
|
-
}
|
|
84
|
-
async _close() {
|
|
85
|
-
await this._restartTask?.join();
|
|
86
|
-
await this._stop();
|
|
87
|
-
this._restartTask = void 0;
|
|
88
|
-
}
|
|
89
|
-
async _restart() {
|
|
90
|
-
log(`restarting in ${this._restartAfter}ms`, {
|
|
91
|
-
state: this._lifecycleState
|
|
92
|
-
}, {
|
|
93
|
-
F: __dxlog_file,
|
|
94
|
-
L: 81,
|
|
95
|
-
S: this,
|
|
96
|
-
C: (f, a) => f(...a)
|
|
97
|
-
});
|
|
98
|
-
await this._stop();
|
|
99
|
-
if (this._lifecycleState !== LifecycleState.OPEN) {
|
|
100
|
-
return;
|
|
101
|
-
}
|
|
102
|
-
await cancelWithContext(this._ctx, sleep(this._restartAfter));
|
|
103
|
-
this._restartAfter = Math.min(Math.max(this._restartAfter * 2, INIT_RESTART_DELAY), this._maxRestartDelay);
|
|
104
|
-
await warnAfterTimeout(5e3, "Connection establishment takes too long", () => this._start());
|
|
105
|
-
this._restartAfter = 0;
|
|
106
|
-
await this._onRestart?.();
|
|
107
|
-
}
|
|
108
|
-
/**
|
|
109
|
-
* Scheduling restart should be done from outside.
|
|
110
|
-
*/
|
|
111
|
-
scheduleRestart() {
|
|
112
|
-
if (this._lifecycleState !== LifecycleState.OPEN) {
|
|
113
|
-
return;
|
|
114
|
-
}
|
|
115
|
-
this._restartTask.schedule();
|
|
116
|
-
}
|
|
117
|
-
};
|
|
118
|
-
_ts_decorate([
|
|
119
|
-
synchronized
|
|
120
|
-
], PersistentLifecycle.prototype, "_open", null);
|
|
121
|
-
_ts_decorate([
|
|
122
|
-
synchronized
|
|
123
|
-
], PersistentLifecycle.prototype, "scheduleRestart", null);
|
|
124
|
-
|
|
125
|
-
// packages/core/mesh/edge-client/src/edge-client.ts
|
|
126
|
-
var __dxlog_file2 = "/home/runner/work/dxos/dxos/packages/core/mesh/edge-client/src/edge-client.ts";
|
|
127
|
-
var DEFAULT_TIMEOUT = 1e4;
|
|
128
|
-
var SIGNAL_KEEPALIVE_INTERVAL = 5e3;
|
|
129
|
-
var EdgeClient = class extends Resource2 {
|
|
130
|
-
constructor(_identityKey, _peerKey, _config) {
|
|
131
|
-
super();
|
|
132
|
-
this._identityKey = _identityKey;
|
|
133
|
-
this._peerKey = _peerKey;
|
|
134
|
-
this._config = _config;
|
|
135
|
-
this.reconnect = new Event();
|
|
136
|
-
this.connected = new Event();
|
|
137
|
-
this._persistentLifecycle = new PersistentLifecycle({
|
|
138
|
-
start: async () => this._openWebSocket(),
|
|
139
|
-
stop: async () => this._closeWebSocket(),
|
|
140
|
-
onRestart: async () => this.reconnect.emit()
|
|
141
|
-
});
|
|
142
|
-
this._listeners = /* @__PURE__ */ new Set();
|
|
143
|
-
this._ready = new Trigger();
|
|
144
|
-
this._ws = void 0;
|
|
145
|
-
this._keepaliveCtx = void 0;
|
|
146
|
-
this._heartBeatContext = void 0;
|
|
147
|
-
}
|
|
148
|
-
// TODO(burdon): Attach logging.
|
|
149
|
-
get info() {
|
|
150
|
-
return {
|
|
151
|
-
open: this.isOpen,
|
|
152
|
-
identity: this._identityKey,
|
|
153
|
-
device: this._peerKey
|
|
154
|
-
};
|
|
155
|
-
}
|
|
156
|
-
get identityKey() {
|
|
157
|
-
return this._identityKey;
|
|
158
|
-
}
|
|
159
|
-
get peerKey() {
|
|
160
|
-
return this._peerKey;
|
|
161
|
-
}
|
|
162
|
-
setIdentity({ peerKey, identityKey }) {
|
|
163
|
-
this._peerKey = peerKey;
|
|
164
|
-
this._identityKey = identityKey;
|
|
165
|
-
this._persistentLifecycle.scheduleRestart();
|
|
166
|
-
}
|
|
167
|
-
addListener(listener) {
|
|
168
|
-
this._listeners.add(listener);
|
|
169
|
-
return () => this._listeners.delete(listener);
|
|
170
|
-
}
|
|
171
|
-
/**
|
|
172
|
-
* Open connection to messaging service.
|
|
173
|
-
*/
|
|
174
|
-
async _open() {
|
|
175
|
-
log2("opening...", {
|
|
176
|
-
info: this.info
|
|
177
|
-
}, {
|
|
178
|
-
F: __dxlog_file2,
|
|
179
|
-
L: 100,
|
|
180
|
-
S: this,
|
|
181
|
-
C: (f, a) => f(...a)
|
|
182
|
-
});
|
|
183
|
-
this._persistentLifecycle.open().catch((err) => {
|
|
184
|
-
log2.warn("Error while opening connection", {
|
|
185
|
-
err
|
|
186
|
-
}, {
|
|
187
|
-
F: __dxlog_file2,
|
|
188
|
-
L: 102,
|
|
189
|
-
S: this,
|
|
190
|
-
C: (f, a) => f(...a)
|
|
191
|
-
});
|
|
192
|
-
});
|
|
193
|
-
}
|
|
194
|
-
/**
|
|
195
|
-
* Close connection and free resources.
|
|
196
|
-
*/
|
|
197
|
-
async _close() {
|
|
198
|
-
log2("closing...", {
|
|
199
|
-
peerKey: this._peerKey
|
|
200
|
-
}, {
|
|
201
|
-
F: __dxlog_file2,
|
|
202
|
-
L: 110,
|
|
203
|
-
S: this,
|
|
204
|
-
C: (f, a) => f(...a)
|
|
205
|
-
});
|
|
206
|
-
await this._persistentLifecycle.close();
|
|
207
|
-
}
|
|
208
|
-
async _openWebSocket() {
|
|
209
|
-
const url = new URL(`/ws/${this._identityKey}/${this._peerKey}`, this._config.socketEndpoint);
|
|
210
|
-
this._ws = new WebSocket(url);
|
|
211
|
-
this._ws.onopen = () => {
|
|
212
|
-
log2("opened", this.info, {
|
|
213
|
-
F: __dxlog_file2,
|
|
214
|
-
L: 119,
|
|
215
|
-
S: this,
|
|
216
|
-
C: (f, a) => f(...a)
|
|
217
|
-
});
|
|
218
|
-
this._ready.wake();
|
|
219
|
-
this.connected.emit();
|
|
220
|
-
};
|
|
221
|
-
this._ws.onclose = () => {
|
|
222
|
-
log2("closed", this.info, {
|
|
223
|
-
F: __dxlog_file2,
|
|
224
|
-
L: 124,
|
|
225
|
-
S: this,
|
|
226
|
-
C: (f, a) => f(...a)
|
|
227
|
-
});
|
|
228
|
-
this._persistentLifecycle.scheduleRestart();
|
|
229
|
-
};
|
|
230
|
-
this._ws.onerror = (event) => {
|
|
231
|
-
log2.warn("EdgeClient socket error", {
|
|
232
|
-
error: event.error,
|
|
233
|
-
info: event.message
|
|
234
|
-
}, {
|
|
235
|
-
F: __dxlog_file2,
|
|
236
|
-
L: 128,
|
|
237
|
-
S: this,
|
|
238
|
-
C: (f, a) => f(...a)
|
|
239
|
-
});
|
|
240
|
-
this._persistentLifecycle.scheduleRestart();
|
|
241
|
-
};
|
|
242
|
-
this._ws.onmessage = async (event) => {
|
|
243
|
-
if (event.data === "__pong__") {
|
|
244
|
-
this._onHeartbeat();
|
|
245
|
-
return;
|
|
246
|
-
}
|
|
247
|
-
const data = await toUint8Array(event.data);
|
|
248
|
-
const message = buf.fromBinary(MessageSchema, data);
|
|
249
|
-
log2("received", {
|
|
250
|
-
peerKey: this._peerKey,
|
|
251
|
-
payload: protocol.getPayloadType(message)
|
|
252
|
-
}, {
|
|
253
|
-
F: __dxlog_file2,
|
|
254
|
-
L: 141,
|
|
255
|
-
S: this,
|
|
256
|
-
C: (f, a) => f(...a)
|
|
257
|
-
});
|
|
258
|
-
if (message) {
|
|
259
|
-
for (const listener of this._listeners) {
|
|
260
|
-
try {
|
|
261
|
-
await listener(message);
|
|
262
|
-
} catch (err) {
|
|
263
|
-
log2.error("processing", {
|
|
264
|
-
err,
|
|
265
|
-
payload: protocol.getPayloadType(message)
|
|
266
|
-
}, {
|
|
267
|
-
F: __dxlog_file2,
|
|
268
|
-
L: 147,
|
|
269
|
-
S: this,
|
|
270
|
-
C: (f, a) => f(...a)
|
|
271
|
-
});
|
|
272
|
-
}
|
|
273
|
-
}
|
|
274
|
-
}
|
|
275
|
-
};
|
|
276
|
-
await this._ready.wait({
|
|
277
|
-
timeout: this._config.timeout ?? DEFAULT_TIMEOUT
|
|
278
|
-
});
|
|
279
|
-
this._keepaliveCtx = new Context(void 0, {
|
|
280
|
-
F: __dxlog_file2,
|
|
281
|
-
L: 154
|
|
282
|
-
});
|
|
283
|
-
scheduleTaskInterval(this._keepaliveCtx, async () => {
|
|
284
|
-
this._ws?.send("__ping__");
|
|
285
|
-
}, SIGNAL_KEEPALIVE_INTERVAL);
|
|
286
|
-
this._ws.send("__ping__");
|
|
287
|
-
this._onHeartbeat();
|
|
288
|
-
}
|
|
289
|
-
async _closeWebSocket() {
|
|
290
|
-
if (!this._ws) {
|
|
291
|
-
return;
|
|
292
|
-
}
|
|
293
|
-
try {
|
|
294
|
-
this._ready.throw(this.isOpen ? new EdgeIdentityChangedError() : new EdgeConnectionClosedError());
|
|
295
|
-
this._ready.reset();
|
|
296
|
-
void this._keepaliveCtx?.dispose();
|
|
297
|
-
this._keepaliveCtx = void 0;
|
|
298
|
-
void this._heartBeatContext?.dispose();
|
|
299
|
-
this._heartBeatContext = void 0;
|
|
300
|
-
this._ws.onopen = () => {
|
|
301
|
-
};
|
|
302
|
-
this._ws.onclose = () => {
|
|
303
|
-
};
|
|
304
|
-
this._ws.onerror = () => {
|
|
305
|
-
};
|
|
306
|
-
this._ws.close();
|
|
307
|
-
this._ws = void 0;
|
|
308
|
-
} catch (err) {
|
|
309
|
-
if (err instanceof Error && err.message.includes("WebSocket is closed before the connection is established.")) {
|
|
310
|
-
return;
|
|
311
|
-
}
|
|
312
|
-
log2.warn("Error closing websocket", {
|
|
313
|
-
err
|
|
314
|
-
}, {
|
|
315
|
-
F: __dxlog_file2,
|
|
316
|
-
L: 190,
|
|
317
|
-
S: this,
|
|
318
|
-
C: (f, a) => f(...a)
|
|
319
|
-
});
|
|
320
|
-
}
|
|
321
|
-
}
|
|
322
|
-
/**
|
|
323
|
-
* Send message.
|
|
324
|
-
* NOTE: The message is guaranteed to be delivered but the service must respond with a message to confirm processing.
|
|
325
|
-
*/
|
|
326
|
-
async send(message) {
|
|
327
|
-
if (this._ready.state !== TriggerState.RESOLVED) {
|
|
328
|
-
log2("waiting for websocket to become ready", void 0, {
|
|
329
|
-
F: __dxlog_file2,
|
|
330
|
-
L: 200,
|
|
331
|
-
S: this,
|
|
332
|
-
C: (f, a) => f(...a)
|
|
333
|
-
});
|
|
334
|
-
await this._ready.wait({
|
|
335
|
-
timeout: this._config.timeout ?? DEFAULT_TIMEOUT
|
|
336
|
-
});
|
|
337
|
-
}
|
|
338
|
-
if (!this._ws) {
|
|
339
|
-
throw new EdgeConnectionClosedError();
|
|
340
|
-
}
|
|
341
|
-
if (message.source && (message.source.peerKey !== this._peerKey || message.source.identityKey !== this.identityKey)) {
|
|
342
|
-
throw new EdgeIdentityChangedError();
|
|
343
|
-
}
|
|
344
|
-
log2("sending...", {
|
|
345
|
-
peerKey: this._peerKey,
|
|
346
|
-
payload: protocol.getPayloadType(message)
|
|
347
|
-
}, {
|
|
348
|
-
F: __dxlog_file2,
|
|
349
|
-
L: 213,
|
|
350
|
-
S: this,
|
|
351
|
-
C: (f, a) => f(...a)
|
|
352
|
-
});
|
|
353
|
-
this._ws.send(buf.toBinary(MessageSchema, message));
|
|
354
|
-
}
|
|
355
|
-
_onHeartbeat() {
|
|
356
|
-
if (this._lifecycleState !== LifecycleState2.OPEN) {
|
|
357
|
-
return;
|
|
358
|
-
}
|
|
359
|
-
void this._heartBeatContext?.dispose();
|
|
360
|
-
this._heartBeatContext = new Context(void 0, {
|
|
361
|
-
F: __dxlog_file2,
|
|
362
|
-
L: 222
|
|
363
|
-
});
|
|
364
|
-
scheduleTask(this._heartBeatContext, () => {
|
|
365
|
-
this._persistentLifecycle.scheduleRestart();
|
|
366
|
-
}, 2 * SIGNAL_KEEPALIVE_INTERVAL);
|
|
367
|
-
}
|
|
368
|
-
};
|
|
369
|
-
export {
|
|
370
|
-
EdgeClient,
|
|
371
|
-
EdgeConnectionClosedError,
|
|
372
|
-
EdgeIdentityChangedError,
|
|
373
|
-
Protocol,
|
|
374
|
-
getTypename,
|
|
375
|
-
protocol,
|
|
376
|
-
toUint8Array
|
|
377
|
-
};
|
|
378
|
-
//# sourceMappingURL=index.mjs.map
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../../src/index.ts", "../../../src/edge-client.ts", "../../../src/errors.ts", "../../../src/persistent-lifecycle.ts"],
|
|
4
|
-
"sourcesContent": ["//\n// Copyright 2024 DXOS.org\n//\n\nexport * from '@dxos/protocols/buf/dxos/edge/messenger_pb';\n\nexport * from './edge-client';\nexport * from './defs';\nexport * from './protocol';\nexport * from './errors';\n", "//\n// Copyright 2024 DXOS.org\n//\n\nimport WebSocket from 'isomorphic-ws';\n\nimport { Trigger, Event, scheduleTaskInterval, scheduleTask, TriggerState } from '@dxos/async';\nimport { Context, LifecycleState, Resource, type Lifecycle } from '@dxos/context';\nimport { log } from '@dxos/log';\nimport { buf } from '@dxos/protocols/buf';\nimport { type Message, MessageSchema } from '@dxos/protocols/buf/dxos/edge/messenger_pb';\n\nimport { protocol } from './defs';\nimport { EdgeConnectionClosedError, EdgeIdentityChangedError } from './errors';\nimport { PersistentLifecycle } from './persistent-lifecycle';\nimport { type Protocol, toUint8Array } from './protocol';\n\nconst DEFAULT_TIMEOUT = 10_000;\nconst SIGNAL_KEEPALIVE_INTERVAL = 5_000;\n\nexport type MessageListener = (message: Message) => void | Promise<void>;\n\nexport interface EdgeConnection extends Required<Lifecycle> {\n connected: Event;\n reconnect: Event;\n\n get info(): any;\n get identityKey(): string;\n get peerKey(): string;\n get isOpen(): boolean;\n setIdentity(params: { peerKey: string; identityKey: string }): void;\n addListener(listener: MessageListener): () => void;\n send(message: Message): Promise<void>;\n}\n\nexport type MessengerConfig = {\n socketEndpoint: string;\n timeout?: number;\n protocol?: Protocol;\n};\n\n/**\n * Messenger client.\n */\nexport class EdgeClient extends Resource implements EdgeConnection {\n public readonly reconnect = new Event();\n public readonly connected = new Event();\n private readonly _persistentLifecycle = new PersistentLifecycle({\n start: async () => this._openWebSocket(),\n stop: async () => this._closeWebSocket(),\n onRestart: async () => this.reconnect.emit(),\n });\n\n private readonly _listeners = new Set<MessageListener>();\n private _ready = new Trigger();\n private _ws?: WebSocket = undefined;\n private _keepaliveCtx?: Context = undefined;\n private _heartBeatContext?: Context = undefined;\n\n constructor(\n private _identityKey: string,\n private _peerKey: string,\n private readonly _config: MessengerConfig,\n ) {\n super();\n }\n\n // TODO(burdon): Attach logging.\n public get info() {\n return {\n open: this.isOpen,\n identity: this._identityKey,\n device: this._peerKey,\n };\n }\n\n get identityKey() {\n return this._identityKey;\n }\n\n get peerKey() {\n return this._peerKey;\n }\n\n setIdentity({ peerKey, identityKey }: { peerKey: string; identityKey: string }) {\n this._peerKey = peerKey;\n this._identityKey = identityKey;\n this._persistentLifecycle.scheduleRestart();\n }\n\n public addListener(listener: MessageListener): () => void {\n this._listeners.add(listener);\n return () => this._listeners.delete(listener);\n }\n\n /**\n * Open connection to messaging service.\n */\n protected override async _open() {\n log('opening...', { info: this.info });\n this._persistentLifecycle.open().catch((err) => {\n log.warn('Error while opening connection', { err });\n });\n }\n\n /**\n * Close connection and free resources.\n */\n protected override async _close() {\n log('closing...', { peerKey: this._peerKey });\n await this._persistentLifecycle.close();\n }\n\n private async _openWebSocket() {\n const url = new URL(`/ws/${this._identityKey}/${this._peerKey}`, this._config.socketEndpoint);\n this._ws = new WebSocket(url);\n\n this._ws.onopen = () => {\n log('opened', this.info);\n this._ready.wake();\n this.connected.emit();\n };\n this._ws.onclose = () => {\n log('closed', this.info);\n this._persistentLifecycle.scheduleRestart();\n };\n this._ws.onerror = (event) => {\n log.warn('EdgeClient socket error', { error: event.error, info: event.message });\n this._persistentLifecycle.scheduleRestart();\n };\n /**\n * https://developer.mozilla.org/en-US/docs/Web/API/MessageEvent/data\n */\n this._ws.onmessage = async (event) => {\n if (event.data === '__pong__') {\n this._onHeartbeat();\n return;\n }\n const data = await toUint8Array(event.data);\n const message = buf.fromBinary(MessageSchema, data);\n log('received', { peerKey: this._peerKey, payload: protocol.getPayloadType(message) });\n if (message) {\n for (const listener of this._listeners) {\n try {\n await listener(message);\n } catch (err) {\n log.error('processing', { err, payload: protocol.getPayloadType(message) });\n }\n }\n }\n };\n\n await this._ready.wait({ timeout: this._config.timeout ?? DEFAULT_TIMEOUT });\n this._keepaliveCtx = new Context();\n scheduleTaskInterval(\n this._keepaliveCtx,\n async () => {\n // TODO(mykola): use RFC6455 ping/pong once implemented in the browser?\n // Cloudflare's worker responds to this `without interrupting hibernation`. https://developers.cloudflare.com/durable-objects/api/websockets/#setwebsocketautoresponse\n this._ws?.send('__ping__');\n },\n SIGNAL_KEEPALIVE_INTERVAL,\n );\n this._ws.send('__ping__');\n this._onHeartbeat();\n }\n\n private async _closeWebSocket() {\n if (!this._ws) {\n return;\n }\n try {\n this._ready.throw(this.isOpen ? new EdgeIdentityChangedError() : new EdgeConnectionClosedError());\n this._ready.reset();\n void this._keepaliveCtx?.dispose();\n this._keepaliveCtx = undefined;\n void this._heartBeatContext?.dispose();\n this._heartBeatContext = undefined;\n\n // NOTE: Remove event handlers to avoid scheduling restart.\n this._ws.onopen = () => {};\n this._ws.onclose = () => {};\n this._ws.onerror = () => {};\n this._ws.close();\n this._ws = undefined;\n } catch (err) {\n if (err instanceof Error && err.message.includes('WebSocket is closed before the connection is established.')) {\n return;\n }\n log.warn('Error closing websocket', { err });\n }\n }\n\n /**\n * Send message.\n * NOTE: The message is guaranteed to be delivered but the service must respond with a message to confirm processing.\n */\n public async send(message: Message): Promise<void> {\n if (this._ready.state !== TriggerState.RESOLVED) {\n log('waiting for websocket to become ready');\n await this._ready.wait({ timeout: this._config.timeout ?? DEFAULT_TIMEOUT });\n }\n if (!this._ws) {\n throw new EdgeConnectionClosedError();\n }\n if (\n message.source &&\n (message.source.peerKey !== this._peerKey || message.source.identityKey !== this.identityKey)\n ) {\n throw new EdgeIdentityChangedError();\n }\n\n log('sending...', { peerKey: this._peerKey, payload: protocol.getPayloadType(message) });\n this._ws.send(buf.toBinary(MessageSchema, message));\n }\n\n private _onHeartbeat() {\n if (this._lifecycleState !== LifecycleState.OPEN) {\n return;\n }\n void this._heartBeatContext?.dispose();\n this._heartBeatContext = new Context();\n scheduleTask(\n this._heartBeatContext,\n () => {\n this._persistentLifecycle.scheduleRestart();\n },\n 2 * SIGNAL_KEEPALIVE_INTERVAL,\n );\n }\n}\n", "//\n// Copyright 2024 DXOS.org\n//\n\nexport class EdgeConnectionClosedError extends Error {\n constructor() {\n super('Edge connection closed.');\n }\n}\n\nexport class EdgeIdentityChangedError extends Error {\n constructor() {\n super('Edge identity changed.');\n }\n}\n", "//\n// Copyright 2024 DXOS.org\n//\n\nimport { DeferredTask, sleep, synchronized } from '@dxos/async';\nimport { cancelWithContext, LifecycleState, Resource } from '@dxos/context';\nimport { warnAfterTimeout } from '@dxos/debug';\nimport { log } from '@dxos/log';\n\nconst INIT_RESTART_DELAY = 100;\nconst DEFAULT_MAX_RESTART_DELAY = 5000;\n\nexport type PersistentLifecycleParams = {\n /**\n * Create connection.\n * If promise resolves successfully, connection is considered established.\n */\n start: () => Promise<void>;\n\n /**\n * Reset connection to initial state.\n */\n stop: () => Promise<void>;\n\n /**\n * Called after successful start.\n */\n onRestart?: () => Promise<void>;\n\n /**\n * Maximum delay between restartion attempts.\n * Default: 5000ms\n */\n maxRestartDelay?: number;\n};\n\n/**\n * Handles restarts (e.g. persists connection).\n * Restarts are scheduled with exponential backoff.\n */\nexport class PersistentLifecycle extends Resource {\n private readonly _start: () => Promise<void>;\n private readonly _stop: () => Promise<void>;\n private readonly _onRestart?: () => Promise<void>;\n private readonly _maxRestartDelay: number;\n\n private _restartTask?: DeferredTask = undefined;\n private _restartAfter = 0;\n\n constructor({ start, stop, onRestart, maxRestartDelay = DEFAULT_MAX_RESTART_DELAY }: PersistentLifecycleParams) {\n super();\n this._start = start;\n this._stop = stop;\n this._onRestart = onRestart;\n this._maxRestartDelay = maxRestartDelay;\n }\n\n @synchronized\n protected override async _open() {\n this._restartTask = new DeferredTask(this._ctx, async () => {\n try {\n await this._restart();\n } catch (err) {\n log.warn('Restart failed', { err });\n this._restartTask?.schedule();\n }\n });\n await this._start().catch((err) => {\n log.warn('Start failed', { err });\n this._restartTask?.schedule();\n });\n }\n\n protected override async _close() {\n await this._restartTask?.join();\n await this._stop();\n this._restartTask = undefined;\n }\n\n private async _restart() {\n log(`restarting in ${this._restartAfter}ms`, { state: this._lifecycleState });\n await this._stop();\n if (this._lifecycleState !== LifecycleState.OPEN) {\n return;\n }\n await cancelWithContext(this._ctx!, sleep(this._restartAfter));\n this._restartAfter = Math.min(Math.max(this._restartAfter * 2, INIT_RESTART_DELAY), this._maxRestartDelay);\n\n // May fail if the connection is not established.\n await warnAfterTimeout(5_000, 'Connection establishment takes too long', () => this._start());\n\n this._restartAfter = 0;\n await this._onRestart?.();\n }\n\n /**\n * Scheduling restart should be done from outside.\n */\n @synchronized\n scheduleRestart() {\n if (this._lifecycleState !== LifecycleState.OPEN) {\n return;\n }\n this._restartTask!.schedule();\n }\n}\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;AAIA,cAAc;;;ACAd,OAAOA,eAAe;AAEtB,SAASC,SAASC,OAAOC,sBAAsBC,cAAcC,oBAAoB;AACjF,SAASC,SAASC,kBAAAA,iBAAgBC,YAAAA,iBAAgC;AAClE,SAASC,OAAAA,YAAW;AACpB,SAASC,WAAW;AACpB,SAAuBC,qBAAqB;;;ACNrC,IAAMC,4BAAN,cAAwCC,MAAAA;EAC7CC,cAAc;AACZ,UAAM,yBAAA;EACR;AACF;AAEO,IAAMC,2BAAN,cAAuCF,MAA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GAA8D;AAC7G;MACF;AACAtC,MAAAA,KAAIG,KAAK,2BAA2B;QAAED;MAAI,GAAA;;;;;;IAC5C;EACF;;;;;EAMA,MAAa6B,KAAKf,SAAiC;AACjD,QAAI,KAAKpC,OAAO2D,UAAUC,aAAaC,UAAU;AAC/CzC,MAAAA,KAAI,yCAAA,QAAA;;;;;;AACJ,YAAM,KAAKpB,OAAO+C,KAAK;QAAEC,SAAS,KAAK9D,QAAQ8D,WAAWrE;MAAgB,CAAA;IAC5E;AACA,QAAI,CAAC,KAAKuB,KAAK;AACb,YAAM,IAAIoD,0BAAAA;IACZ;AACA,QACElB,QAAQ0B,WACP1B,QAAQ0B,OAAOlD,YAAY,KAAK3B,YAAYmD,QAAQ0B,OAAOnD,gBAAgB,KAAKA,cACjF;AACA,YAAM,IAAI0C,yBAAAA;IACZ;AAEAjC,IAAAA,KAAI,cAAc;MAAER,SAAS,KAAK3B;MAAU2D,SAASC,SAASC,eAAeV,OAAAA;IAAS,GAAA;;;;;;AACtF,SAAKlC,IAAIiD,KAAKV,IAAIsB,SAASpB,eAAeP,OAAAA,CAAAA;EAC5C;EAEQG,eAAe;AACrB,QAAI,KAAKyB,oBAAoBC,gBAAeC,MAAM;AAChD;IACF;AACA,SAAK,KAAK7D,mBAAmBmD,QAAAA;AAC7B,SAAKnD,oBAAoB,IAAI4C,QAAAA,QAAAA;;;;AAC7BkB,iBACE,KAAK9D,mBACL,MAAA;AACE,WAAKf,qBAAqBwB,gBAAe;IAC3C,GACA,IAAIlC,yBAAAA;EAER;AACF;",
|
|
6
|
-
"names": ["WebSocket", "Trigger", "Event", "scheduleTaskInterval", "scheduleTask", "TriggerState", "Context", "LifecycleState", "Resource", "log", "buf", "MessageSchema", "EdgeConnectionClosedError", "Error", "constructor", "EdgeIdentityChangedError", "DeferredTask", "sleep", "synchronized", "cancelWithContext", "LifecycleState", "Resource", "warnAfterTimeout", "log", "INIT_RESTART_DELAY", "DEFAULT_MAX_RESTART_DELAY", "PersistentLifecycle", "constructor", "start", "stop", "onRestart", "maxRestartDelay", "_restartTask", "undefined", "_restartAfter", "_start", "_stop", "_onRestart", "_maxRestartDelay", "_open", "_ctx", "_restart", "err", "warn", "schedule", "catch", "_close", "join", "state", "_lifecycleState", "OPEN", "Math", "min", "max", "scheduleRestart", "DEFAULT_TIMEOUT", "SIGNAL_KEEPALIVE_INTERVAL", "EdgeClient", "Resource", "constructor", "_identityKey", "_peerKey", "_config", "reconnect", "Event", "connected", "_persistentLifecycle", "PersistentLifecycle", "start", "_openWebSocket", "stop", "_closeWebSocket", "onRestart", "emit", "_listeners", "Set", "_ready", "Trigger", "_ws", "undefined", "_keepaliveCtx", "_heartBeatContext", "info", "open", "isOpen", "identity", "device", "identityKey", "peerKey", "setIdentity", "scheduleRestart", "addListener", "listener", "add", "delete", "_open", "log", "catch", "err", "warn", "_close", "close", "url", "URL", "socketEndpoint", "WebSocket", "onopen", "wake", "onclose", "onerror", "event", "error", "message", "onmessage", "data", "_onHeartbeat", "toUint8Array", "buf", "fromBinary", "MessageSchema", "payload", "protocol", "getPayloadType", "wait", "timeout", "Context", "scheduleTaskInterval", "send", "throw", "EdgeIdentityChangedError", "EdgeConnectionClosedError", "reset", "dispose", "Error", "includes", "state", "TriggerState", "RESOLVED", "source", "toBinary", "_lifecycleState", "LifecycleState", "OPEN", "scheduleTask"]
|
|
7
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"inputs":{"packages/core/mesh/edge-client/src/protocol.ts":{"bytes":10334,"imports":[{"path":"@dxos/invariant","kind":"import-statement","external":true},{"path":"@dxos/protocols/buf","kind":"import-statement","external":true},{"path":"@dxos/protocols/buf/dxos/edge/messenger_pb","kind":"import-statement","external":true},{"path":"@dxos/util","kind":"import-statement","external":true}],"format":"esm"},"packages/core/mesh/edge-client/src/defs.ts":{"bytes":1607,"imports":[{"path":"@dxos/protocols/buf","kind":"import-statement","external":true},{"path":"@dxos/protocols/buf/dxos/edge/messenger_pb","kind":"import-statement","external":true},{"path":"packages/core/mesh/edge-client/src/protocol.ts","kind":"import-statement","original":"./protocol"}],"format":"esm"},"packages/core/mesh/edge-client/src/errors.ts":{"bytes":1265,"imports":[],"format":"esm"},"packages/core/mesh/edge-client/src/persistent-lifecycle.ts":{"bytes":10868,"imports":[{"path":"@dxos/async","kind":"import-statement","external":true},{"path":"@dxos/context","kind":"import-statement","external":true},{"path":"@dxos/debug","kind":"import-statement","external":true},{"path":"@dxos/log","kind":"import-statement","external":true}],"format":"esm"},"packages/core/mesh/edge-client/src/edge-client.ts":{"bytes":27085,"imports":[{"path":"isomorphic-ws","kind":"import-statement","external":true},{"path":"@dxos/async","kind":"import-statement","external":true},{"path":"@dxos/context","kind":"import-statement","external":true},{"path":"@dxos/log","kind":"import-statement","external":true},{"path":"@dxos/protocols/buf","kind":"import-statement","external":true},{"path":"@dxos/protocols/buf/dxos/edge/messenger_pb","kind":"import-statement","external":true},{"path":"packages/core/mesh/edge-client/src/defs.ts","kind":"import-statement","original":"./defs"},{"path":"packages/core/mesh/edge-client/src/errors.ts","kind":"import-statement","original":"./errors"},{"path":"packages/core/mesh/edge-client/src/persistent-lifecycle.ts","kind":"import-statement","original":"./persistent-lifecycle"},{"path":"packages/core/mesh/edge-client/src/protocol.ts","kind":"import-statement","original":"./protocol"}],"format":"esm"},"packages/core/mesh/edge-client/src/index.ts":{"bytes":935,"imports":[{"path":"@dxos/protocols/buf/dxos/edge/messenger_pb","kind":"import-statement","external":true},{"path":"packages/core/mesh/edge-client/src/edge-client.ts","kind":"import-statement","original":"./edge-client"},{"path":"packages/core/mesh/edge-client/src/defs.ts","kind":"import-statement","original":"./defs"},{"path":"packages/core/mesh/edge-client/src/protocol.ts","kind":"import-statement","original":"./protocol"},{"path":"packages/core/mesh/edge-client/src/errors.ts","kind":"import-statement","original":"./errors"}],"format":"esm"},"packages/core/mesh/edge-client/src/testing/test-utils.ts":{"bytes":12455,"imports":[{"path":"isomorphic-ws","kind":"import-statement","external":true},{"path":"@dxos/async","kind":"import-statement","external":true},{"path":"@dxos/log","kind":"import-statement","external":true},{"path":"@dxos/protocols/buf","kind":"import-statement","external":true},{"path":"@dxos/protocols/buf/dxos/edge/messenger_pb","kind":"import-statement","external":true},{"path":"packages/core/mesh/edge-client/src/defs.ts","kind":"import-statement","original":"../defs"},{"path":"packages/core/mesh/edge-client/src/protocol.ts","kind":"import-statement","original":"../protocol"}],"format":"esm"},"packages/core/mesh/edge-client/src/testing/index.ts":{"bytes":516,"imports":[{"path":"packages/core/mesh/edge-client/src/testing/test-utils.ts","kind":"import-statement","original":"./test-utils"}],"format":"esm"}},"outputs":{"packages/core/mesh/edge-client/dist/lib/node-esm/index.mjs.map":{"imports":[],"exports":[],"inputs":{},"bytes":18218},"packages/core/mesh/edge-client/dist/lib/node-esm/index.mjs":{"imports":[{"path":"packages/core/mesh/edge-client/dist/lib/node-esm/chunk-HNVT57AU.mjs","kind":"import-statement"},{"path":"@dxos/protocols/buf/dxos/edge/messenger_pb","kind":"import-statement","external":true},{"path":"isomorphic-ws","kind":"import-statement","external":true},{"path":"@dxos/async","kind":"import-statement","external":true},{"path":"@dxos/context","kind":"import-statement","external":true},{"path":"@dxos/log","kind":"import-statement","external":true},{"path":"@dxos/protocols/buf","kind":"import-statement","external":true},{"path":"@dxos/protocols/buf/dxos/edge/messenger_pb","kind":"import-statement","external":true},{"path":"@dxos/async","kind":"import-statement","external":true},{"path":"@dxos/context","kind":"import-statement","external":true},{"path":"@dxos/debug","kind":"import-statement","external":true},{"path":"@dxos/log","kind":"import-statement","external":true}],"exports":["EdgeClient","EdgeConnectionClosedError","EdgeIdentityChangedError","Protocol","getTypename","protocol","toUint8Array"],"entryPoint":"packages/core/mesh/edge-client/src/index.ts","inputs":{"packages/core/mesh/edge-client/src/index.ts":{"bytesInOutput":60},"packages/core/mesh/edge-client/src/edge-client.ts":{"bytesInOutput":6943},"packages/core/mesh/edge-client/src/errors.ts":{"bytesInOutput":232},"packages/core/mesh/edge-client/src/persistent-lifecycle.ts":{"bytesInOutput":3015}},"bytes":10876},"packages/core/mesh/edge-client/dist/lib/node-esm/testing/index.mjs.map":{"imports":[],"exports":[],"inputs":{},"bytes":6342},"packages/core/mesh/edge-client/dist/lib/node-esm/testing/index.mjs":{"imports":[{"path":"packages/core/mesh/edge-client/dist/lib/node-esm/chunk-HNVT57AU.mjs","kind":"import-statement"},{"path":"isomorphic-ws","kind":"import-statement","external":true},{"path":"@dxos/async","kind":"import-statement","external":true},{"path":"@dxos/log","kind":"import-statement","external":true},{"path":"@dxos/protocols/buf","kind":"import-statement","external":true},{"path":"@dxos/protocols/buf/dxos/edge/messenger_pb","kind":"import-statement","external":true}],"exports":["DEFAULT_PORT","createTestEdgeWsServer"],"entryPoint":"packages/core/mesh/edge-client/src/testing/index.ts","inputs":{"packages/core/mesh/edge-client/src/testing/test-utils.ts":{"bytesInOutput":3276},"packages/core/mesh/edge-client/src/testing/index.ts":{"bytesInOutput":0}},"bytes":3585},"packages/core/mesh/edge-client/dist/lib/node-esm/chunk-HNVT57AU.mjs.map":{"imports":[],"exports":[],"inputs":{},"bytes":5678},"packages/core/mesh/edge-client/dist/lib/node-esm/chunk-HNVT57AU.mjs":{"imports":[{"path":"@dxos/invariant","kind":"import-statement","external":true},{"path":"@dxos/protocols/buf","kind":"import-statement","external":true},{"path":"@dxos/protocols/buf/dxos/edge/messenger_pb","kind":"import-statement","external":true},{"path":"@dxos/util","kind":"import-statement","external":true},{"path":"@dxos/protocols/buf","kind":"import-statement","external":true},{"path":"@dxos/protocols/buf/dxos/edge/messenger_pb","kind":"import-statement","external":true}],"exports":["Protocol","getTypename","protocol","toUint8Array"],"inputs":{"packages/core/mesh/edge-client/src/protocol.ts":{"bytesInOutput":2600},"packages/core/mesh/edge-client/src/defs.ts":{"bytesInOutput":298}},"bytes":3199}}}
|
|
@@ -1,123 +0,0 @@
|
|
|
1
|
-
import { createRequire } from 'node:module';const require = createRequire(import.meta.url);
|
|
2
|
-
import {
|
|
3
|
-
protocol,
|
|
4
|
-
toUint8Array
|
|
5
|
-
} from "../chunk-HNVT57AU.mjs";
|
|
6
|
-
|
|
7
|
-
// packages/core/mesh/edge-client/src/testing/test-utils.ts
|
|
8
|
-
import WebSocket from "isomorphic-ws";
|
|
9
|
-
import { Trigger } from "@dxos/async";
|
|
10
|
-
import { log } from "@dxos/log";
|
|
11
|
-
import { buf } from "@dxos/protocols/buf";
|
|
12
|
-
import { MessageSchema, TextMessageSchema } from "@dxos/protocols/buf/dxos/edge/messenger_pb";
|
|
13
|
-
var __dxlog_file = "/home/runner/work/dxos/dxos/packages/core/mesh/edge-client/src/testing/test-utils.ts";
|
|
14
|
-
var DEFAULT_PORT = 8080;
|
|
15
|
-
var createTestEdgeWsServer = async (port = DEFAULT_PORT, params) => {
|
|
16
|
-
const server = new WebSocket.Server({
|
|
17
|
-
port,
|
|
18
|
-
verifyClient: createConnectionDelayHandler(params)
|
|
19
|
-
});
|
|
20
|
-
let connection;
|
|
21
|
-
const messageSink = [];
|
|
22
|
-
const closeTrigger = new Trigger();
|
|
23
|
-
const sendResponseMessage = createResponseSender(() => connection);
|
|
24
|
-
server.on("connection", (ws) => {
|
|
25
|
-
connection = ws;
|
|
26
|
-
ws.on("error", (err) => log.catch(err, void 0, {
|
|
27
|
-
F: __dxlog_file,
|
|
28
|
-
L: 34,
|
|
29
|
-
S: void 0,
|
|
30
|
-
C: (f, a) => f(...a)
|
|
31
|
-
}));
|
|
32
|
-
ws.on("message", async (data) => {
|
|
33
|
-
if (String(data) === "__ping__") {
|
|
34
|
-
ws.send("__pong__");
|
|
35
|
-
return;
|
|
36
|
-
}
|
|
37
|
-
const { request, requestPayload } = await decodeRequest(params, data);
|
|
38
|
-
if (params?.messageHandler) {
|
|
39
|
-
const responsePayload = await params.messageHandler(requestPayload);
|
|
40
|
-
if (responsePayload && connection) {
|
|
41
|
-
sendResponseMessage(request, responsePayload);
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
log("message", {
|
|
45
|
-
payload: requestPayload
|
|
46
|
-
}, {
|
|
47
|
-
F: __dxlog_file,
|
|
48
|
-
L: 47,
|
|
49
|
-
S: void 0,
|
|
50
|
-
C: (f, a) => f(...a)
|
|
51
|
-
});
|
|
52
|
-
messageSink.push(requestPayload);
|
|
53
|
-
});
|
|
54
|
-
ws.on("close", () => {
|
|
55
|
-
connection = void 0;
|
|
56
|
-
closeTrigger.wake();
|
|
57
|
-
});
|
|
58
|
-
});
|
|
59
|
-
return {
|
|
60
|
-
server,
|
|
61
|
-
messageSink,
|
|
62
|
-
endpoint: `ws://localhost:${port}`,
|
|
63
|
-
cleanup: () => server.close(),
|
|
64
|
-
currentConnection: () => connection,
|
|
65
|
-
sendResponseMessage,
|
|
66
|
-
closeConnection: () => {
|
|
67
|
-
closeTrigger.reset();
|
|
68
|
-
connection.close(1011);
|
|
69
|
-
return closeTrigger.wait();
|
|
70
|
-
}
|
|
71
|
-
};
|
|
72
|
-
};
|
|
73
|
-
var createConnectionDelayHandler = (params) => {
|
|
74
|
-
return (_, callback) => {
|
|
75
|
-
if (params?.admitConnection) {
|
|
76
|
-
log("delaying edge connection admission", void 0, {
|
|
77
|
-
F: __dxlog_file,
|
|
78
|
-
L: 75,
|
|
79
|
-
S: void 0,
|
|
80
|
-
C: (f, a) => f(...a)
|
|
81
|
-
});
|
|
82
|
-
void params.admitConnection.wait().then(() => {
|
|
83
|
-
callback(true);
|
|
84
|
-
log("edge connection admitted", void 0, {
|
|
85
|
-
F: __dxlog_file,
|
|
86
|
-
L: 78,
|
|
87
|
-
S: void 0,
|
|
88
|
-
C: (f, a) => f(...a)
|
|
89
|
-
});
|
|
90
|
-
});
|
|
91
|
-
} else {
|
|
92
|
-
callback(true);
|
|
93
|
-
}
|
|
94
|
-
};
|
|
95
|
-
};
|
|
96
|
-
var createResponseSender = (connection) => {
|
|
97
|
-
return (request, responsePayload) => {
|
|
98
|
-
const recipient = request.source;
|
|
99
|
-
connection().send(buf.toBinary(MessageSchema, buf.create(MessageSchema, {
|
|
100
|
-
source: {
|
|
101
|
-
identityKey: recipient.identityKey,
|
|
102
|
-
peerKey: recipient.peerKey
|
|
103
|
-
},
|
|
104
|
-
serviceId: request.serviceId,
|
|
105
|
-
payload: {
|
|
106
|
-
value: responsePayload
|
|
107
|
-
}
|
|
108
|
-
})));
|
|
109
|
-
};
|
|
110
|
-
};
|
|
111
|
-
var decodeRequest = async (params, data) => {
|
|
112
|
-
const request = buf.fromBinary(MessageSchema, await toUint8Array(data));
|
|
113
|
-
const requestPayload = params?.payloadDecoder ? params.payloadDecoder(request.payload.value) : protocol.getPayload(request, TextMessageSchema);
|
|
114
|
-
return {
|
|
115
|
-
request,
|
|
116
|
-
requestPayload
|
|
117
|
-
};
|
|
118
|
-
};
|
|
119
|
-
export {
|
|
120
|
-
DEFAULT_PORT,
|
|
121
|
-
createTestEdgeWsServer
|
|
122
|
-
};
|
|
123
|
-
//# sourceMappingURL=index.mjs.map
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../../../src/testing/test-utils.ts"],
|
|
4
|
-
"sourcesContent": ["//\n// Copyright 2024 DXOS.org\n//\n\nimport WebSocket from 'isomorphic-ws';\n\nimport { Trigger } from '@dxos/async';\nimport { log } from '@dxos/log';\nimport { buf } from '@dxos/protocols/buf';\nimport { MessageSchema, TextMessageSchema, type Message } from '@dxos/protocols/buf/dxos/edge/messenger_pb';\n\nimport { protocol } from '../defs';\nimport { toUint8Array } from '../protocol';\n\nexport const DEFAULT_PORT = 8080;\n\ntype TestEdgeWsServerParams = {\n admitConnection?: Trigger;\n payloadDecoder?: (payload: Uint8Array) => any;\n messageHandler?: (payload: any) => Promise<Uint8Array | undefined>;\n};\n\nexport const createTestEdgeWsServer = async (port = DEFAULT_PORT, params?: TestEdgeWsServerParams) => {\n const server = new WebSocket.Server({ port, verifyClient: createConnectionDelayHandler(params) });\n\n let connection: WebSocket | undefined;\n\n const messageSink: any[] = [];\n const closeTrigger = new Trigger();\n const sendResponseMessage = createResponseSender(() => connection!);\n\n server.on('connection', (ws) => {\n connection = ws;\n ws.on('error', (err) => log.catch(err));\n ws.on('message', async (data) => {\n if (String(data) === '__ping__') {\n ws.send('__pong__');\n return;\n }\n const { request, requestPayload } = await decodeRequest(params, data);\n if (params?.messageHandler) {\n const responsePayload = await params.messageHandler(requestPayload);\n if (responsePayload && connection) {\n sendResponseMessage(request, responsePayload);\n }\n }\n log('message', { payload: requestPayload });\n messageSink.push(requestPayload);\n });\n\n ws.on('close', () => {\n connection = undefined;\n closeTrigger.wake();\n });\n });\n\n return {\n server,\n messageSink,\n endpoint: `ws://localhost:${port}`,\n cleanup: () => server.close(),\n currentConnection: () => connection,\n sendResponseMessage,\n closeConnection: () => {\n closeTrigger.reset();\n connection!.close(1011);\n return closeTrigger.wait();\n },\n };\n};\n\nconst createConnectionDelayHandler = (params: TestEdgeWsServerParams | undefined) => {\n return (_: any, callback: (admit: boolean) => void) => {\n if (params?.admitConnection) {\n log('delaying edge connection admission');\n void params.admitConnection.wait().then(() => {\n callback(true);\n log('edge connection admitted');\n });\n } else {\n callback(true);\n }\n };\n};\n\nconst createResponseSender = (connection: () => WebSocket) => {\n return (request: Message, responsePayload: Uint8Array) => {\n const recipient = request.source!;\n connection().send(\n buf.toBinary(\n MessageSchema,\n buf.create(MessageSchema, {\n source: {\n identityKey: recipient.identityKey,\n peerKey: recipient.peerKey,\n },\n serviceId: request.serviceId!,\n payload: { value: responsePayload },\n }),\n ),\n );\n };\n};\n\nconst decodeRequest = async (params: TestEdgeWsServerParams | undefined, data: any) => {\n const request = buf.fromBinary(MessageSchema, await toUint8Array(data));\n const requestPayload = params?.payloadDecoder\n ? params.payloadDecoder(request.payload!.value!)\n : protocol.getPayload(request, TextMessageSchema);\n return { request, requestPayload };\n};\n"],
|
|
5
|
-
"mappings": ";;;;;;;AAIA,OAAOA,eAAe;AAEtB,SAASC,eAAe;AACxB,SAASC,WAAW;AACpB,SAASC,WAAW;AACpB,SAASC,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,CAACL,WAAAA;AACpC,SAAO,CAACoC,GAAQC,aAAAA;AACd,QAAIrC,QAAQsC,iBAAiB;AAC3BvB,UAAI,sCAAA,QAAA;;;;;;AACJ,WAAKf,OAAOsC,gBAAgBH,KAAI,EAAGI,KAAK,MAAA;AACtCF,iBAAS,IAAA;AACTtB,YAAI,4BAAA,QAAA;;;;;;MACN,CAAA;IACF,OAAO;AACLsB,eAAS,IAAA;IACX;EACF;AACF;AAEA,IAAM1B,uBAAuB,CAACL,eAAAA;AAC5B,SAAO,CAACc,SAAkBI,oBAAAA;AACxB,UAAMgB,YAAYpB,QAAQqB;AAC1BnC,eAAAA,EAAaa,KACXuB,IAAIC,SACFC,eACAF,IAAIG,OAAOD,eAAe;MACxBH,QAAQ;QACNK,aAAaN,UAAUM;QACvBC,SAASP,UAAUO;MACrB;MACAC,WAAW5B,QAAQ4B;MACnBvB,SAAS;QAAEwB,OAAOzB;MAAgB;IACpC,CAAA,CAAA,CAAA;EAGN;AACF;AAEA,IAAMF,gBAAgB,OAAOtB,QAA4CiB,SAAAA;AACvE,QAAMG,UAAUsB,IAAIQ,WAAWN,eAAe,MAAMO,aAAalC,IAAAA,CAAAA;AACjE,QAAMI,iBAAiBrB,QAAQoD,iBAC3BpD,OAAOoD,eAAehC,QAAQK,QAASwB,KAAK,IAC5CI,SAASC,WAAWlC,SAASmC,iBAAAA;AACjC,SAAO;IAAEnC;IAASC;EAAe;AACnC;",
|
|
6
|
-
"names": ["WebSocket", "Trigger", "log", "buf", "MessageSchema", "TextMessageSchema", "DEFAULT_PORT", "createTestEdgeWsServer", "port", "params", "server", "WebSocket", "Server", "verifyClient", "createConnectionDelayHandler", "connection", "messageSink", "closeTrigger", "Trigger", "sendResponseMessage", "createResponseSender", "on", "ws", "err", "log", "catch", "data", "String", "send", "request", "requestPayload", "decodeRequest", "messageHandler", "responsePayload", "payload", "push", "undefined", "wake", "endpoint", "cleanup", "close", "currentConnection", "closeConnection", "reset", "wait", "_", "callback", "admitConnection", "then", "recipient", "source", "buf", "toBinary", "MessageSchema", "create", "identityKey", "peerKey", "serviceId", "value", "fromBinary", "toUint8Array", "payloadDecoder", "protocol", "getPayload", "TextMessageSchema"]
|
|
7
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/testing/index.ts"],"names":[],"mappings":"AAIA,cAAc,cAAc,CAAC"}
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import WebSocket from 'isomorphic-ws';
|
|
2
|
-
import { Trigger } from '@dxos/async';
|
|
3
|
-
import { type Message } from '@dxos/protocols/buf/dxos/edge/messenger_pb';
|
|
4
|
-
export declare const DEFAULT_PORT = 8080;
|
|
5
|
-
type TestEdgeWsServerParams = {
|
|
6
|
-
admitConnection?: Trigger;
|
|
7
|
-
payloadDecoder?: (payload: Uint8Array) => any;
|
|
8
|
-
messageHandler?: (payload: any) => Promise<Uint8Array | undefined>;
|
|
9
|
-
};
|
|
10
|
-
export declare const createTestEdgeWsServer: (port?: number, params?: TestEdgeWsServerParams) => Promise<{
|
|
11
|
-
server: WebSocket.Server;
|
|
12
|
-
messageSink: any[];
|
|
13
|
-
endpoint: string;
|
|
14
|
-
cleanup: () => void;
|
|
15
|
-
currentConnection: () => WebSocket | undefined;
|
|
16
|
-
sendResponseMessage: (request: Message, responsePayload: Uint8Array) => void;
|
|
17
|
-
closeConnection: () => Promise<void>;
|
|
18
|
-
}>;
|
|
19
|
-
export {};
|
|
20
|
-
//# sourceMappingURL=test-utils.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"test-utils.d.ts","sourceRoot":"","sources":["../../../../src/testing/test-utils.ts"],"names":[],"mappings":"AAIA,OAAO,SAAS,MAAM,eAAe,CAAC;AAEtC,OAAO,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AAGtC,OAAO,EAAoC,KAAK,OAAO,EAAE,MAAM,4CAA4C,CAAC;AAK5G,eAAO,MAAM,YAAY,OAAO,CAAC;AAEjC,KAAK,sBAAsB,GAAG;IAC5B,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B,cAAc,CAAC,EAAE,CAAC,OAAO,EAAE,UAAU,KAAK,GAAG,CAAC;IAC9C,cAAc,CAAC,EAAE,CAAC,OAAO,EAAE,GAAG,KAAK,OAAO,CAAC,UAAU,GAAG,SAAS,CAAC,CAAC;CACpE,CAAC;AAEF,eAAO,MAAM,sBAAsB,2BAAwC,sBAAsB;;;;;;mCAgE9E,OAAO,mBAAmB,UAAU;;EAjBtD,CAAC"}
|