@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
package/dist/lib/node/index.cjs
CHANGED
|
@@ -30,34 +30,129 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
30
30
|
var node_exports = {};
|
|
31
31
|
__export(node_exports, {
|
|
32
32
|
EdgeClient: () => EdgeClient,
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
protocol: () => import_chunk_ANV2HBEH.protocol,
|
|
38
|
-
toUint8Array: () => import_chunk_ANV2HBEH.toUint8Array
|
|
33
|
+
Protocol: () => Protocol,
|
|
34
|
+
getTypename: () => getTypename,
|
|
35
|
+
protocol: () => protocol,
|
|
36
|
+
toUint8Array: () => toUint8Array
|
|
39
37
|
});
|
|
40
38
|
module.exports = __toCommonJS(node_exports);
|
|
41
|
-
var import_chunk_ANV2HBEH = require("./chunk-ANV2HBEH.cjs");
|
|
42
39
|
__reExport(node_exports, require("@dxos/protocols/buf/dxos/edge/messenger_pb"), module.exports);
|
|
43
40
|
var import_isomorphic_ws = __toESM(require("isomorphic-ws"));
|
|
44
41
|
var import_async = require("@dxos/async");
|
|
45
42
|
var import_context = require("@dxos/context");
|
|
43
|
+
var import_invariant = require("@dxos/invariant");
|
|
46
44
|
var import_log = require("@dxos/log");
|
|
47
45
|
var import_buf = require("@dxos/protocols/buf");
|
|
48
46
|
var import_messenger_pb = require("@dxos/protocols/buf/dxos/edge/messenger_pb");
|
|
47
|
+
var import_wkt = require("@bufbuild/protobuf/wkt");
|
|
48
|
+
var import_messenger_pb2 = require("@dxos/protocols/buf/dxos/edge/messenger_pb");
|
|
49
|
+
var import_invariant2 = require("@dxos/invariant");
|
|
50
|
+
var import_buf2 = require("@dxos/protocols/buf");
|
|
51
|
+
var import_messenger_pb3 = require("@dxos/protocols/buf/dxos/edge/messenger_pb");
|
|
52
|
+
var import_util = require("@dxos/util");
|
|
49
53
|
var import_async2 = require("@dxos/async");
|
|
50
54
|
var import_context2 = require("@dxos/context");
|
|
51
55
|
var import_debug = require("@dxos/debug");
|
|
52
56
|
var import_log2 = require("@dxos/log");
|
|
53
|
-
var
|
|
54
|
-
|
|
55
|
-
|
|
57
|
+
var __dxlog_file = "/home/runner/work/dxos/dxos/packages/core/mesh/edge-client/src/protocol.ts";
|
|
58
|
+
var getTypename = (typeName) => `type.googleapis.com/${typeName}`;
|
|
59
|
+
var Protocol = class {
|
|
60
|
+
constructor(types) {
|
|
61
|
+
this._typeRegistry = import_buf2.buf.createRegistry(...types);
|
|
62
|
+
}
|
|
63
|
+
get typeRegistry() {
|
|
64
|
+
return this._typeRegistry;
|
|
65
|
+
}
|
|
66
|
+
toJson(message) {
|
|
67
|
+
try {
|
|
68
|
+
return import_buf2.buf.toJson(import_messenger_pb3.MessageSchema, message, {
|
|
69
|
+
registry: this.typeRegistry
|
|
70
|
+
});
|
|
71
|
+
} catch (err) {
|
|
72
|
+
return {
|
|
73
|
+
type: this.getPayloadType(message)
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* Return the payload with the given type.
|
|
79
|
+
*/
|
|
80
|
+
getPayload(message, type) {
|
|
81
|
+
(0, import_invariant2.invariant)(message.payload, void 0, {
|
|
82
|
+
F: __dxlog_file,
|
|
83
|
+
L: 40,
|
|
84
|
+
S: this,
|
|
85
|
+
A: [
|
|
86
|
+
"message.payload",
|
|
87
|
+
""
|
|
88
|
+
]
|
|
89
|
+
});
|
|
90
|
+
const payloadTypename = this.getPayloadType(message);
|
|
91
|
+
if (type && type.typeName !== payloadTypename) {
|
|
92
|
+
throw new Error(`Unexpected payload type: ${payloadTypename}; expected ${type.typeName}`);
|
|
93
|
+
}
|
|
94
|
+
(0, import_invariant2.invariant)(import_buf2.bufWkt.anyIs(message.payload, type), `Unexpected payload type: ${payloadTypename}}`, {
|
|
95
|
+
F: __dxlog_file,
|
|
96
|
+
L: 46,
|
|
97
|
+
S: this,
|
|
98
|
+
A: [
|
|
99
|
+
"bufWkt.anyIs(message.payload, type)",
|
|
100
|
+
"`Unexpected payload type: ${payloadTypename}}`"
|
|
101
|
+
]
|
|
102
|
+
});
|
|
103
|
+
const payload = import_buf2.bufWkt.anyUnpack(message.payload, this.typeRegistry);
|
|
104
|
+
(0, import_invariant2.invariant)(payload, `Empty payload: ${payloadTypename}}`, {
|
|
105
|
+
F: __dxlog_file,
|
|
106
|
+
L: 48,
|
|
107
|
+
S: this,
|
|
108
|
+
A: [
|
|
109
|
+
"payload",
|
|
110
|
+
"`Empty payload: ${payloadTypename}}`"
|
|
111
|
+
]
|
|
112
|
+
});
|
|
113
|
+
return payload;
|
|
114
|
+
}
|
|
115
|
+
/**
|
|
116
|
+
* Get the payload type.
|
|
117
|
+
*/
|
|
118
|
+
getPayloadType(message) {
|
|
119
|
+
if (!message.payload) {
|
|
120
|
+
return void 0;
|
|
121
|
+
}
|
|
122
|
+
const [, type] = message.payload.typeUrl.split("/");
|
|
123
|
+
return type;
|
|
124
|
+
}
|
|
125
|
+
/**
|
|
126
|
+
* Create a packed message.
|
|
127
|
+
*/
|
|
128
|
+
createMessage(type, { source, target, payload, serviceId }) {
|
|
129
|
+
return import_buf2.buf.create(import_messenger_pb3.MessageSchema, {
|
|
130
|
+
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
131
|
+
source,
|
|
132
|
+
target,
|
|
133
|
+
serviceId,
|
|
134
|
+
payload: payload ? import_buf2.bufWkt.anyPack(type, import_buf2.buf.create(type, payload)) : void 0
|
|
135
|
+
});
|
|
56
136
|
}
|
|
57
137
|
};
|
|
58
|
-
var
|
|
138
|
+
var toUint8Array = async (data) => {
|
|
139
|
+
if (data instanceof Buffer) {
|
|
140
|
+
return (0, import_util.bufferToArray)(data);
|
|
141
|
+
}
|
|
142
|
+
if (data instanceof Blob) {
|
|
143
|
+
return new Uint8Array(await data.arrayBuffer());
|
|
144
|
+
}
|
|
145
|
+
throw new Error(`Unexpected datatype: ${data}`);
|
|
146
|
+
};
|
|
147
|
+
var protocol = new Protocol([
|
|
148
|
+
import_messenger_pb2.SwarmRequestSchema,
|
|
149
|
+
import_messenger_pb2.SwarmResponseSchema,
|
|
150
|
+
import_messenger_pb2.TextMessageSchema,
|
|
151
|
+
import_wkt.AnySchema
|
|
152
|
+
]);
|
|
153
|
+
var WebsocketClosedError = class extends Error {
|
|
59
154
|
constructor() {
|
|
60
|
-
super("
|
|
155
|
+
super("WebSocket connection closed");
|
|
61
156
|
}
|
|
62
157
|
};
|
|
63
158
|
function _ts_decorate(decorators, target, key, desc) {
|
|
@@ -66,7 +161,7 @@ function _ts_decorate(decorators, target, key, desc) {
|
|
|
66
161
|
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;
|
|
67
162
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
68
163
|
}
|
|
69
|
-
var
|
|
164
|
+
var __dxlog_file2 = "/home/runner/work/dxos/dxos/packages/core/mesh/edge-client/src/persistent-lifecycle.ts";
|
|
70
165
|
var INIT_RESTART_DELAY = 100;
|
|
71
166
|
var DEFAULT_MAX_RESTART_DELAY = 5e3;
|
|
72
167
|
var PersistentLifecycle = class extends import_context2.Resource {
|
|
@@ -87,7 +182,7 @@ var PersistentLifecycle = class extends import_context2.Resource {
|
|
|
87
182
|
import_log2.log.warn("Restart failed", {
|
|
88
183
|
err
|
|
89
184
|
}, {
|
|
90
|
-
F:
|
|
185
|
+
F: __dxlog_file2,
|
|
91
186
|
L: 64,
|
|
92
187
|
S: this,
|
|
93
188
|
C: (f, a) => f(...a)
|
|
@@ -99,7 +194,7 @@ var PersistentLifecycle = class extends import_context2.Resource {
|
|
|
99
194
|
import_log2.log.warn("Start failed", {
|
|
100
195
|
err
|
|
101
196
|
}, {
|
|
102
|
-
F:
|
|
197
|
+
F: __dxlog_file2,
|
|
103
198
|
L: 69,
|
|
104
199
|
S: this,
|
|
105
200
|
C: (f, a) => f(...a)
|
|
@@ -116,7 +211,7 @@ var PersistentLifecycle = class extends import_context2.Resource {
|
|
|
116
211
|
(0, import_log2.log)(`restarting in ${this._restartAfter}ms`, {
|
|
117
212
|
state: this._lifecycleState
|
|
118
213
|
}, {
|
|
119
|
-
F:
|
|
214
|
+
F: __dxlog_file2,
|
|
120
215
|
L: 81,
|
|
121
216
|
S: this,
|
|
122
217
|
C: (f, a) => f(...a)
|
|
@@ -147,7 +242,7 @@ _ts_decorate([
|
|
|
147
242
|
_ts_decorate([
|
|
148
243
|
import_async2.synchronized
|
|
149
244
|
], PersistentLifecycle.prototype, "scheduleRestart", null);
|
|
150
|
-
var
|
|
245
|
+
var __dxlog_file3 = "/home/runner/work/dxos/dxos/packages/core/mesh/edge-client/src/edge-client.ts";
|
|
151
246
|
var DEFAULT_TIMEOUT = 1e4;
|
|
152
247
|
var SIGNAL_KEEPALIVE_INTERVAL = 5e3;
|
|
153
248
|
var EdgeClient = class extends import_context.Resource {
|
|
@@ -157,7 +252,6 @@ var EdgeClient = class extends import_context.Resource {
|
|
|
157
252
|
this._peerKey = _peerKey;
|
|
158
253
|
this._config = _config;
|
|
159
254
|
this.reconnect = new import_async.Event();
|
|
160
|
-
this.connected = new import_async.Event();
|
|
161
255
|
this._persistentLifecycle = new PersistentLifecycle({
|
|
162
256
|
start: async () => this._openWebSocket(),
|
|
163
257
|
stop: async () => this._closeWebSocket(),
|
|
@@ -168,6 +262,7 @@ var EdgeClient = class extends import_context.Resource {
|
|
|
168
262
|
this._ws = void 0;
|
|
169
263
|
this._keepaliveCtx = void 0;
|
|
170
264
|
this._heartBeatContext = void 0;
|
|
265
|
+
this._protocol = this._config.protocol ?? protocol;
|
|
171
266
|
}
|
|
172
267
|
// TODO(burdon): Attach logging.
|
|
173
268
|
get info() {
|
|
@@ -199,8 +294,8 @@ var EdgeClient = class extends import_context.Resource {
|
|
|
199
294
|
(0, import_log.log)("opening...", {
|
|
200
295
|
info: this.info
|
|
201
296
|
}, {
|
|
202
|
-
F:
|
|
203
|
-
L:
|
|
297
|
+
F: __dxlog_file3,
|
|
298
|
+
L: 101,
|
|
204
299
|
S: this,
|
|
205
300
|
C: (f, a) => f(...a)
|
|
206
301
|
});
|
|
@@ -208,8 +303,8 @@ var EdgeClient = class extends import_context.Resource {
|
|
|
208
303
|
import_log.log.warn("Error while opening connection", {
|
|
209
304
|
err
|
|
210
305
|
}, {
|
|
211
|
-
F:
|
|
212
|
-
L:
|
|
306
|
+
F: __dxlog_file3,
|
|
307
|
+
L: 103,
|
|
213
308
|
S: this,
|
|
214
309
|
C: (f, a) => f(...a)
|
|
215
310
|
});
|
|
@@ -222,8 +317,8 @@ var EdgeClient = class extends import_context.Resource {
|
|
|
222
317
|
(0, import_log.log)("closing...", {
|
|
223
318
|
peerKey: this._peerKey
|
|
224
319
|
}, {
|
|
225
|
-
F:
|
|
226
|
-
L:
|
|
320
|
+
F: __dxlog_file3,
|
|
321
|
+
L: 111,
|
|
227
322
|
S: this,
|
|
228
323
|
C: (f, a) => f(...a)
|
|
229
324
|
});
|
|
@@ -234,17 +329,16 @@ var EdgeClient = class extends import_context.Resource {
|
|
|
234
329
|
this._ws = new import_isomorphic_ws.default(url);
|
|
235
330
|
this._ws.onopen = () => {
|
|
236
331
|
(0, import_log.log)("opened", this.info, {
|
|
237
|
-
F:
|
|
238
|
-
L:
|
|
332
|
+
F: __dxlog_file3,
|
|
333
|
+
L: 120,
|
|
239
334
|
S: this,
|
|
240
335
|
C: (f, a) => f(...a)
|
|
241
336
|
});
|
|
242
337
|
this._ready.wake();
|
|
243
|
-
this.connected.emit();
|
|
244
338
|
};
|
|
245
339
|
this._ws.onclose = () => {
|
|
246
340
|
(0, import_log.log)("closed", this.info, {
|
|
247
|
-
F:
|
|
341
|
+
F: __dxlog_file3,
|
|
248
342
|
L: 124,
|
|
249
343
|
S: this,
|
|
250
344
|
C: (f, a) => f(...a)
|
|
@@ -256,7 +350,7 @@ var EdgeClient = class extends import_context.Resource {
|
|
|
256
350
|
error: event.error,
|
|
257
351
|
info: event.message
|
|
258
352
|
}, {
|
|
259
|
-
F:
|
|
353
|
+
F: __dxlog_file3,
|
|
260
354
|
L: 128,
|
|
261
355
|
S: this,
|
|
262
356
|
C: (f, a) => f(...a)
|
|
@@ -268,13 +362,13 @@ var EdgeClient = class extends import_context.Resource {
|
|
|
268
362
|
this._onHeartbeat();
|
|
269
363
|
return;
|
|
270
364
|
}
|
|
271
|
-
const data = await
|
|
365
|
+
const data = await toUint8Array(event.data);
|
|
272
366
|
const message = import_buf.buf.fromBinary(import_messenger_pb.MessageSchema, data);
|
|
273
367
|
(0, import_log.log)("received", {
|
|
274
368
|
peerKey: this._peerKey,
|
|
275
|
-
payload:
|
|
369
|
+
payload: protocol.getPayloadType(message)
|
|
276
370
|
}, {
|
|
277
|
-
F:
|
|
371
|
+
F: __dxlog_file3,
|
|
278
372
|
L: 141,
|
|
279
373
|
S: this,
|
|
280
374
|
C: (f, a) => f(...a)
|
|
@@ -286,9 +380,9 @@ var EdgeClient = class extends import_context.Resource {
|
|
|
286
380
|
} catch (err) {
|
|
287
381
|
import_log.log.error("processing", {
|
|
288
382
|
err,
|
|
289
|
-
payload:
|
|
383
|
+
payload: protocol.getPayloadType(message)
|
|
290
384
|
}, {
|
|
291
|
-
F:
|
|
385
|
+
F: __dxlog_file3,
|
|
292
386
|
L: 147,
|
|
293
387
|
S: this,
|
|
294
388
|
C: (f, a) => f(...a)
|
|
@@ -301,7 +395,7 @@ var EdgeClient = class extends import_context.Resource {
|
|
|
301
395
|
timeout: this._config.timeout ?? DEFAULT_TIMEOUT
|
|
302
396
|
});
|
|
303
397
|
this._keepaliveCtx = new import_context.Context(void 0, {
|
|
304
|
-
F:
|
|
398
|
+
F: __dxlog_file3,
|
|
305
399
|
L: 154
|
|
306
400
|
});
|
|
307
401
|
(0, import_async.scheduleTaskInterval)(this._keepaliveCtx, async () => {
|
|
@@ -315,7 +409,7 @@ var EdgeClient = class extends import_context.Resource {
|
|
|
315
409
|
return;
|
|
316
410
|
}
|
|
317
411
|
try {
|
|
318
|
-
this._ready.throw(
|
|
412
|
+
this._ready.throw(new WebsocketClosedError());
|
|
319
413
|
this._ready.reset();
|
|
320
414
|
void this._keepaliveCtx?.dispose();
|
|
321
415
|
this._keepaliveCtx = void 0;
|
|
@@ -336,7 +430,7 @@ var EdgeClient = class extends import_context.Resource {
|
|
|
336
430
|
import_log.log.warn("Error closing websocket", {
|
|
337
431
|
err
|
|
338
432
|
}, {
|
|
339
|
-
F:
|
|
433
|
+
F: __dxlog_file3,
|
|
340
434
|
L: 190,
|
|
341
435
|
S: this,
|
|
342
436
|
C: (f, a) => f(...a)
|
|
@@ -349,28 +443,34 @@ var EdgeClient = class extends import_context.Resource {
|
|
|
349
443
|
*/
|
|
350
444
|
async send(message) {
|
|
351
445
|
if (this._ready.state !== import_async.TriggerState.RESOLVED) {
|
|
352
|
-
(0, import_log.log)("waiting for websocket to become ready", void 0, {
|
|
353
|
-
F: __dxlog_file2,
|
|
354
|
-
L: 200,
|
|
355
|
-
S: this,
|
|
356
|
-
C: (f, a) => f(...a)
|
|
357
|
-
});
|
|
358
446
|
await this._ready.wait({
|
|
359
447
|
timeout: this._config.timeout ?? DEFAULT_TIMEOUT
|
|
360
448
|
});
|
|
361
449
|
}
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
450
|
+
(0, import_invariant.invariant)(this._ws, void 0, {
|
|
451
|
+
F: __dxlog_file3,
|
|
452
|
+
L: 202,
|
|
453
|
+
S: this,
|
|
454
|
+
A: [
|
|
455
|
+
"this._ws",
|
|
456
|
+
""
|
|
457
|
+
]
|
|
458
|
+
});
|
|
459
|
+
(0, import_invariant.invariant)(!message.source || message.source.peerKey === this._peerKey, void 0, {
|
|
460
|
+
F: __dxlog_file3,
|
|
461
|
+
L: 203,
|
|
462
|
+
S: this,
|
|
463
|
+
A: [
|
|
464
|
+
"!message.source || message.source.peerKey === this._peerKey",
|
|
465
|
+
""
|
|
466
|
+
]
|
|
467
|
+
});
|
|
368
468
|
(0, import_log.log)("sending...", {
|
|
369
469
|
peerKey: this._peerKey,
|
|
370
|
-
payload:
|
|
470
|
+
payload: protocol.getPayloadType(message)
|
|
371
471
|
}, {
|
|
372
|
-
F:
|
|
373
|
-
L:
|
|
472
|
+
F: __dxlog_file3,
|
|
473
|
+
L: 204,
|
|
374
474
|
S: this,
|
|
375
475
|
C: (f, a) => f(...a)
|
|
376
476
|
});
|
|
@@ -382,8 +482,8 @@ var EdgeClient = class extends import_context.Resource {
|
|
|
382
482
|
}
|
|
383
483
|
void this._heartBeatContext?.dispose();
|
|
384
484
|
this._heartBeatContext = new import_context.Context(void 0, {
|
|
385
|
-
F:
|
|
386
|
-
L:
|
|
485
|
+
F: __dxlog_file3,
|
|
486
|
+
L: 213
|
|
387
487
|
});
|
|
388
488
|
(0, import_async.scheduleTask)(this._heartBeatContext, () => {
|
|
389
489
|
this._persistentLifecycle.scheduleRestart();
|
|
@@ -393,8 +493,6 @@ var EdgeClient = class extends import_context.Resource {
|
|
|
393
493
|
// Annotate the CommonJS export names for ESM import in node:
|
|
394
494
|
0 && (module.exports = {
|
|
395
495
|
EdgeClient,
|
|
396
|
-
EdgeConnectionClosedError,
|
|
397
|
-
EdgeIdentityChangedError,
|
|
398
496
|
Protocol,
|
|
399
497
|
getTypename,
|
|
400
498
|
protocol,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
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": "
|
|
6
|
-
"names": ["import_async", "import_context", "import_log", "
|
|
3
|
+
"sources": ["../../../src/index.ts", "../../../src/edge-client.ts", "../../../src/defs.ts", "../../../src/protocol.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';\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 { invariant } from '@dxos/invariant';\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 { WebsocketClosedError } 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 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 reconnect = 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 readonly _protocol: Protocol;\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 this._protocol = this._config.protocol ?? protocol;\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 };\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(new WebsocketClosedError());\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 await this._ready.wait({ timeout: this._config.timeout ?? DEFAULT_TIMEOUT });\n }\n invariant(this._ws);\n invariant(!message.source || message.source.peerKey === this._peerKey);\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\nimport { AnySchema } from '@bufbuild/protobuf/wkt';\n\nimport { SwarmRequestSchema, SwarmResponseSchema, TextMessageSchema } from '@dxos/protocols/buf/dxos/edge/messenger_pb';\n\nimport { Protocol } from './protocol';\n\nexport const protocol = new Protocol([SwarmRequestSchema, SwarmResponseSchema, TextMessageSchema, AnySchema]);\n", "//\n// Copyright 2024 DXOS.org\n//\n\nimport { invariant } from '@dxos/invariant';\nimport { buf, bufWkt } from '@dxos/protocols/buf';\nimport { type Message, MessageSchema, type Peer as PeerProto } from '@dxos/protocols/buf/dxos/edge/messenger_pb';\nimport { bufferToArray } from '@dxos/util';\n\nexport type PeerData = Partial<PeerProto>;\n\nexport const getTypename = (typeName: string) => `type.googleapis.com/${typeName}`;\n\n/**\n * NOTE: The type registry should be extended with all message types.\n */\nexport class Protocol {\n private readonly _typeRegistry: buf.Registry;\n\n constructor(types: buf.DescMessage[]) {\n this._typeRegistry = buf.createRegistry(...types);\n }\n\n get typeRegistry(): buf.Registry {\n return this._typeRegistry;\n }\n\n toJson(message: Message): any {\n try {\n return buf.toJson(MessageSchema, message, { registry: this.typeRegistry });\n } catch (err) {\n return { type: this.getPayloadType(message) };\n }\n }\n\n /**\n * Return the payload with the given type.\n */\n getPayload<Desc extends buf.DescMessage>(message: Message, type: Desc): buf.MessageShape<Desc> {\n invariant(message.payload);\n const payloadTypename = this.getPayloadType(message);\n if (type && type.typeName !== payloadTypename) {\n throw new Error(`Unexpected payload type: ${payloadTypename}; expected ${type.typeName}`);\n }\n\n invariant(bufWkt.anyIs(message.payload, type), `Unexpected payload type: ${payloadTypename}}`);\n const payload = bufWkt.anyUnpack(message.payload, this.typeRegistry) as buf.MessageShape<Desc>;\n invariant(payload, `Empty payload: ${payloadTypename}}`);\n return payload;\n }\n\n /**\n * Get the payload type.\n */\n getPayloadType(message: Message): string | undefined {\n if (!message.payload) {\n return undefined;\n }\n\n const [, type] = message.payload.typeUrl.split('/');\n return type;\n }\n\n /**\n * Create a packed message.\n */\n createMessage<Desc extends buf.DescMessage>(\n type: Desc,\n {\n source,\n target,\n payload,\n serviceId,\n }: {\n source?: PeerData;\n target?: PeerData[];\n payload?: buf.MessageInitShape<Desc>;\n serviceId?: string;\n },\n ) {\n return buf.create(MessageSchema, {\n timestamp: new Date().toISOString(),\n source,\n target,\n serviceId,\n payload: payload ? bufWkt.anyPack(type, buf.create(type, payload)) : undefined,\n });\n }\n}\n\n/**\n * Convert websocket data to Uint8Array.\n */\nexport const toUint8Array = async (data: any): Promise<Uint8Array> => {\n // Node.\n if (data instanceof Buffer) {\n return bufferToArray(data);\n }\n\n // Browser.\n if (data instanceof Blob) {\n return new Uint8Array(await (data as Blob).arrayBuffer());\n }\n\n throw new Error(`Unexpected datatype: ${data}`);\n};\n", "//\n// Copyright 2024 DXOS.org\n//\n\nexport class WebsocketClosedError extends Error {\n constructor() {\n super('WebSocket connection closed');\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,yBAAc;ACAd,2BAAsB;AAEtB,mBAAiF;AACjF,qBAAkE;AAClE,uBAA0B;AAC1B,iBAAoB;AACpB,iBAAoB;AACpB,0BAA4C;ACP5C,iBAA0B;AAE1B,IAAAA,uBAA2E;ACF3E,IAAAC,oBAA0B;AAC1B,IAAAC,cAA4B;AAC5B,IAAAF,uBAAoE;AACpE,kBAA8B;AEH9B,IAAAG,gBAAkD;AAClD,IAAAC,kBAA4D;AAC5D,mBAAiC;AACjC,IAAAC,cAAoB;;AFIb,IAAMC,cAAc,CAACC,aAAqB,uBAAuBA,QAAAA;AAKjE,IAAMC,WAAN,MAAMA;EAGXC,YAAYC,OAA0B;AACpC,SAAKC,gBAAgBC,gBAAIC,eAAc,GAAIH,KAAAA;EAC7C;EAEA,IAAII,eAA6B;AAC/B,WAAO,KAAKH;EACd;EAEAI,OAAOC,SAAuB;AAC5B,QAAI;AACF,aAAOJ,gBAAIG,OAAOE,oCAAeD,SAAS;QAAEE,UAAU,KAAKJ;MAAa,CAAA;IAC1E,SAASK,KAAK;AACZ,aAAO;QAAEC,MAAM,KAAKC,eAAeL,OAAAA;MAAS;IAC9C;EACF;;;;EAKAM,WAAyCN,SAAkBI,MAAoC;AAC7FG,qCAAUP,QAAQQ,SAAO,QAAA;;;;;;;;;AACzB,UAAMC,kBAAkB,KAAKJ,eAAeL,OAAAA;AAC5C,QAAII,QAAQA,KAAKb,aAAakB,iBAAiB;AAC7C,YAAM,IAAIC,MAAM,4BAA4BD,eAAAA,cAA6BL,KAAKb,QAAQ,EAAE;IAC1F;AAEAgB,qCAAUI,mBAAOC,M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A;IAC5E;AACApE,yBAAAA,WAAU,KAAKoF,KAAG,QAAA;;;;;;;;;AAClBpF,yBAAAA,WAAU,CAACP,QAAQkB,UAAUlB,QAAQkB,OAAOmF,YAAY,KAAKtB,UAAQ,QAAA;;;;;;;;;AACrEtB,mBAAAA,KAAI,cAAc;MAAE4C,SAAS,KAAKtB;MAAUvE,SAASyB,SAAS5B,eAAeL,OAAAA;IAAS,GAAA;;;;;;AACtF,SAAK2F,IAAIkC,KAAKjI,WAAAA,IAAIwI,SAASnI,oBAAAA,eAAeD,OAAAA,CAAAA;EAC5C;EAEQuH,eAAe;AACrB,QAAI,KAAKvD,oBAAoBC,eAAAA,eAAeC,MAAM;AAChD;IACF;AACA,SAAK,KAAK2B,mBAAmBmC,QAAAA;AAC7B,SAAKnC,oBAAoB,IAAI8B,uBAAAA,QAAAA;;;;AAC7BU,mCACE,KAAKxC,mBACL,MAAA;AACE,WAAKV,qBAAqBV,gBAAe;IAC3C,GACA,IAAIG,yBAAAA;EAER;AACF;",
|
|
6
|
+
"names": ["import_messenger_pb", "import_invariant", "import_buf", "import_async", "import_context", "import_log", "getTypename", "typeName", "Protocol", "constructor", "types", "_typeRegistry", "buf", "createRegistry", "typeRegistry", "toJson", "message", "MessageSchema", "registry", "err", "type", "getPayloadType", "getPayload", "invariant", "payload", "payloadTypename", "Error", "bufWkt", "anyIs", "anyUnpack", "undefined", "typeUrl", "split", "createMessage", "source", "target", "serviceId", "create", "timestamp", "Date", "toISOString", "anyPack", "toUint8Array", "data", "Buffer", "bufferToArray", "Blob", "Uint8Array", "arrayBuffer", "protocol", "SwarmRequestSchema", "SwarmResponseSchema", "TextMessageSchema", "AnySchema", "WebsocketClosedError", "INIT_RESTART_DELAY", "DEFAULT_MAX_RESTART_DELAY", "PersistentLifecycle", "Resource", "start", "stop", "onRestart", "maxRestartDelay", "_restartTask", "_restartAfter", "_start", "_stop", "_onRestart", "_maxRestartDelay", "_open", "DeferredTask", "_ctx", "_restart", "log", "warn", "schedule", "catch", "_close", "join", "state", "_lifecycleState", "LifecycleState", "OPEN", "cancelWithContext", "sleep", "Math", "min", "max", "warnAfterTimeout", "scheduleRestart", "synchronized", "DEFAULT_TIMEOUT", "SIGNAL_KEEPALIVE_INTERVAL", "EdgeClient", "_identityKey", "_peerKey", "_config", "reconnect", "Event", "_persistentLifecycle", "_openWebSocket", "_closeWebSocket", "emit", "_listeners", "Set", "_ready", "Trigger", "_ws", "_keepaliveCtx", "_heartBeatContext", "_protocol", "info", "open", "isOpen", "identity", "device", "identityKey", "peerKey", "setIdentity", "addListener", "listener", "add", "delete", "close", "url", "URL", "socketEndpoint", "WebSocket", "onopen", "wake", "onclose", "onerror", "event", "error", "onmessage", "_onHeartbeat", "fromBinary", "wait", "timeout", "Context", "scheduleTaskInterval", "send", "throw", "reset", "dispose", "includes", "TriggerState", "RESOLVED", "toBinary", "scheduleTask"]
|
|
7
7
|
}
|
package/dist/lib/node/meta.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"inputs":{"packages/core/mesh/edge-client/src/protocol.ts":{"bytes":
|
|
1
|
+
{"inputs":{"packages/core/mesh/edge-client/src/protocol.ts":{"bytes":10314,"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":1578,"imports":[{"path":"@bufbuild/protobuf/wkt","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":846,"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":26527,"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/invariant","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":849,"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"}],"format":"esm"}},"outputs":{"packages/core/mesh/edge-client/dist/lib/node/index.cjs.map":{"imports":[],"exports":[],"inputs":{},"bytes":23169},"packages/core/mesh/edge-client/dist/lib/node/index.cjs":{"imports":[{"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/invariant","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":"@bufbuild/protobuf/wkt","kind":"import-statement","external":true},{"path":"@dxos/protocols/buf/dxos/edge/messenger_pb","kind":"import-statement","external":true},{"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/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","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":6962},"packages/core/mesh/edge-client/src/defs.ts":{"bytesInOutput":285},"packages/core/mesh/edge-client/src/protocol.ts":{"bytesInOutput":2600},"packages/core/mesh/edge-client/src/errors.ts":{"bytesInOutput":116},"packages/core/mesh/edge-client/src/persistent-lifecycle.ts":{"bytesInOutput":3019}},"bytes":13569}}}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"defs.d.ts","sourceRoot":"","sources":["../../../src/defs.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"defs.d.ts","sourceRoot":"","sources":["../../../src/defs.ts"],"names":[],"mappings":"AAQA,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAEtC,eAAO,MAAM,QAAQ,UAAwF,CAAC"}
|
|
@@ -4,7 +4,6 @@ import { type Message } from '@dxos/protocols/buf/dxos/edge/messenger_pb';
|
|
|
4
4
|
import { type Protocol } from './protocol';
|
|
5
5
|
export type MessageListener = (message: Message) => void | Promise<void>;
|
|
6
6
|
export interface EdgeConnection extends Required<Lifecycle> {
|
|
7
|
-
connected: Event;
|
|
8
7
|
reconnect: Event;
|
|
9
8
|
get info(): any;
|
|
10
9
|
get identityKey(): string;
|
|
@@ -29,10 +28,10 @@ export declare class EdgeClient extends Resource implements EdgeConnection {
|
|
|
29
28
|
private _identityKey;
|
|
30
29
|
private _peerKey;
|
|
31
30
|
private readonly _config;
|
|
32
|
-
|
|
33
|
-
readonly connected: Event<void>;
|
|
31
|
+
reconnect: Event<void>;
|
|
34
32
|
private readonly _persistentLifecycle;
|
|
35
33
|
private readonly _listeners;
|
|
34
|
+
private readonly _protocol;
|
|
36
35
|
private _ready;
|
|
37
36
|
private _ws?;
|
|
38
37
|
private _keepaliveCtx?;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"edge-client.d.ts","sourceRoot":"","sources":["../../../src/edge-client.ts"],"names":[],"mappings":"AAMA,OAAO,EAAW,KAAK,EAAoD,MAAM,aAAa,CAAC;AAC/F,OAAO,EAA2B,QAAQ,EAAE,KAAK,SAAS,EAAE,MAAM,eAAe,CAAC;
|
|
1
|
+
{"version":3,"file":"edge-client.d.ts","sourceRoot":"","sources":["../../../src/edge-client.ts"],"names":[],"mappings":"AAMA,OAAO,EAAW,KAAK,EAAoD,MAAM,aAAa,CAAC;AAC/F,OAAO,EAA2B,QAAQ,EAAE,KAAK,SAAS,EAAE,MAAM,eAAe,CAAC;AAIlF,OAAO,EAAE,KAAK,OAAO,EAAiB,MAAM,4CAA4C,CAAC;AAKzF,OAAO,EAAE,KAAK,QAAQ,EAAgB,MAAM,YAAY,CAAC;AAKzD,MAAM,MAAM,eAAe,GAAG,CAAC,OAAO,EAAE,OAAO,KAAK,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;AAEzE,MAAM,WAAW,cAAe,SAAQ,QAAQ,CAAC,SAAS,CAAC;IACzD,SAAS,EAAE,KAAK,CAAC;IAEjB,IAAI,IAAI,IAAI,GAAG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AE;IAMvE,WAAW,CAAC,QAAQ,EAAE,eAAe,GAAG,MAAM,IAAI;IAKzD;;OAEG;cACsB,KAAK;IAO9B;;OAEG;cACsB,MAAM;YAKjB,cAAc;YAqDd,eAAe;IA0B7B;;;OAGG;IACU,IAAI,CAAC,OAAO,EAAE,OAAO,GAAG,OAAO,CAAC,IAAI,CAAC;IAUlD,OAAO,CAAC,YAAY;CAcrB"}
|
|
@@ -1,7 +1,4 @@
|
|
|
1
|
-
export declare class
|
|
2
|
-
constructor();
|
|
3
|
-
}
|
|
4
|
-
export declare class EdgeIdentityChangedError extends Error {
|
|
1
|
+
export declare class WebsocketClosedError extends Error {
|
|
5
2
|
constructor();
|
|
6
3
|
}
|
|
7
4
|
//# sourceMappingURL=errors.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../../src/errors.ts"],"names":[],"mappings":"AAIA,qBAAa,
|
|
1
|
+
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../../src/errors.ts"],"names":[],"mappings":"AAIA,qBAAa,oBAAqB,SAAQ,KAAK;;CAI9C"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/index.ts"],"names":[],"mappings":"AAIA,cAAc,4CAA4C,CAAC;AAE3D,cAAc,eAAe,CAAC;AAC9B,cAAc,QAAQ,CAAC;AACvB,cAAc,YAAY,CAAC
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/index.ts"],"names":[],"mappings":"AAIA,cAAc,4CAA4C,CAAC;AAE3D,cAAc,eAAe,CAAC;AAC9B,cAAc,QAAQ,CAAC;AACvB,cAAc,YAAY,CAAC"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { buf } from '@dxos/protocols/buf';
|
|
2
|
-
import { type Message, type
|
|
3
|
-
export type PeerData =
|
|
2
|
+
import { type Message, type Peer as PeerProto } from '@dxos/protocols/buf/dxos/edge/messenger_pb';
|
|
3
|
+
export type PeerData = Partial<PeerProto>;
|
|
4
4
|
export declare const getTypename: (typeName: string) => string;
|
|
5
5
|
/**
|
|
6
6
|
* NOTE: The type registry should be extended with all message types.
|