@arcanejs/toolkit 8.0.0 → 9.0.0
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/backend/components/base.d.mts +2 -1
- package/dist/backend/components/base.d.ts +2 -1
- package/dist/backend/components/base.js +2 -2
- package/dist/backend/components/base.mjs +1 -1
- package/dist/backend/components/button.d.mts +2 -1
- package/dist/backend/components/button.d.ts +2 -1
- package/dist/backend/components/button.js +3 -3
- package/dist/backend/components/button.mjs +2 -2
- package/dist/backend/components/group.d.mts +2 -1
- package/dist/backend/components/group.d.ts +2 -1
- package/dist/backend/components/group.js +3 -3
- package/dist/backend/components/group.mjs +2 -2
- package/dist/backend/components/label.d.mts +2 -1
- package/dist/backend/components/label.d.ts +2 -1
- package/dist/backend/components/label.js +3 -3
- package/dist/backend/components/label.mjs +2 -2
- package/dist/backend/components/rect.d.mts +2 -1
- package/dist/backend/components/rect.d.ts +2 -1
- package/dist/backend/components/rect.js +3 -3
- package/dist/backend/components/rect.mjs +2 -2
- package/dist/backend/components/slider-button.d.mts +2 -1
- package/dist/backend/components/slider-button.d.ts +2 -1
- package/dist/backend/components/slider-button.js +3 -3
- package/dist/backend/components/slider-button.mjs +2 -2
- package/dist/backend/components/switch.d.mts +2 -1
- package/dist/backend/components/switch.d.ts +2 -1
- package/dist/backend/components/switch.js +3 -3
- package/dist/backend/components/switch.mjs +2 -2
- package/dist/backend/components/tabs.d.mts +2 -1
- package/dist/backend/components/tabs.d.ts +2 -1
- package/dist/backend/components/tabs.js +3 -3
- package/dist/backend/components/tabs.mjs +2 -2
- package/dist/backend/components/text-input.d.mts +2 -1
- package/dist/backend/components/text-input.d.ts +2 -1
- package/dist/backend/components/text-input.js +3 -3
- package/dist/backend/components/text-input.mjs +2 -2
- package/dist/backend/components/timeline.d.mts +2 -1
- package/dist/backend/components/timeline.d.ts +2 -1
- package/dist/backend/components/timeline.js +3 -3
- package/dist/backend/components/timeline.mjs +2 -2
- package/dist/{chunk-IV3AE3CW.js → chunk-2R23ER4K.js} +3 -3
- package/dist/{chunk-R5OA7LLZ.mjs → chunk-5K7DK7CW.mjs} +1 -1
- package/dist/{chunk-RJLYYTZ6.mjs → chunk-7WTSYZOS.mjs} +1 -1
- package/dist/{chunk-2K4UT5QB.js → chunk-AYMITMVR.js} +3 -3
- package/dist/{chunk-K6V55JTG.mjs → chunk-KO24S32V.mjs} +1 -1
- package/dist/{chunk-XSKWLJOQ.js → chunk-KRGLXKY2.js} +4 -4
- package/dist/{chunk-JHWFQLLE.mjs → chunk-MNEFCU3M.mjs} +1 -1
- package/dist/{chunk-TF7N4O5G.js → chunk-NEFCI6N6.js} +2 -2
- package/dist/{chunk-TULW7CRV.mjs → chunk-NJW4ZG4X.mjs} +1 -1
- package/dist/{chunk-MHSAHTVN.mjs → chunk-QBZB56TQ.mjs} +1 -1
- package/dist/{chunk-UHEZQR2Q.js → chunk-QHCNKTKW.js} +2 -2
- package/dist/{chunk-4AGKM5NT.js → chunk-RELZ3VTJ.js} +3 -3
- package/dist/{chunk-7MQHRTBE.mjs → chunk-RGLKNCJ3.mjs} +1 -1
- package/dist/{chunk-A3RWE7HZ.js → chunk-SPYBETRJ.js} +3 -3
- package/dist/{chunk-GONHNB6V.mjs → chunk-UTTTCTUQ.mjs} +26 -5
- package/dist/{chunk-GXJ3JRRK.mjs → chunk-VD6S32ED.mjs} +1 -1
- package/dist/{chunk-5B65Q7RL.js → chunk-VTNAO4KC.js} +2 -2
- package/dist/{chunk-6PS3Q66F.mjs → chunk-Y3NPWW27.mjs} +1 -1
- package/dist/{chunk-CVY55KAR.js → chunk-Y5FC42KD.js} +3 -3
- package/dist/{chunk-WN3GXVUE.js → chunk-YNOJTE3G.js} +26 -5
- package/dist/frontend/entrypoint.js +42 -1
- package/dist/frontend/entrypoint.js.map +2 -2
- package/dist/frontend/index.js +69 -12
- package/dist/frontend/index.mjs +69 -12
- package/dist/index.d.mts +3 -2
- package/dist/index.d.ts +3 -2
- package/dist/index.js +183 -64
- package/dist/index.mjs +154 -35
- package/dist/{toolkit-Bglbv3ix.d.ts → toolkit-CKA9A4r-.d.ts} +116 -93
- package/dist/{toolkit-BPqxbDbk.d.mts → toolkit-GNytD78y.d.mts} +116 -93
- package/package.json +8 -8
package/dist/index.js
CHANGED
|
@@ -1,38 +1,38 @@
|
|
|
1
1
|
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { newObj[key] = obj[key]; } } } newObj.default = obj; return newObj; } } function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } async function _asyncNullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return await rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; } var _class; var _class2;
|
|
2
2
|
|
|
3
3
|
|
|
4
|
-
var
|
|
4
|
+
var _chunkSPYBETRJjs = require('./chunk-SPYBETRJ.js');
|
|
5
5
|
|
|
6
6
|
|
|
7
|
-
var
|
|
7
|
+
var _chunk2R23ER4Kjs = require('./chunk-2R23ER4K.js');
|
|
8
8
|
|
|
9
9
|
|
|
10
|
-
var
|
|
10
|
+
var _chunkQHCNKTKWjs = require('./chunk-QHCNKTKW.js');
|
|
11
11
|
|
|
12
12
|
|
|
13
13
|
var _chunkEABM5X65js = require('./chunk-EABM5X65.js');
|
|
14
14
|
|
|
15
15
|
|
|
16
|
-
var
|
|
16
|
+
var _chunkRELZ3VTJjs = require('./chunk-RELZ3VTJ.js');
|
|
17
17
|
|
|
18
18
|
|
|
19
19
|
|
|
20
|
-
var
|
|
20
|
+
var _chunkKRGLXKY2js = require('./chunk-KRGLXKY2.js');
|
|
21
21
|
|
|
22
22
|
|
|
23
|
-
var
|
|
23
|
+
var _chunkNEFCI6N6js = require('./chunk-NEFCI6N6.js');
|
|
24
24
|
|
|
25
25
|
|
|
26
|
-
var
|
|
26
|
+
var _chunkVTNAO4KCjs = require('./chunk-VTNAO4KC.js');
|
|
27
27
|
|
|
28
28
|
|
|
29
|
-
var
|
|
29
|
+
var _chunkY5FC42KDjs = require('./chunk-Y5FC42KD.js');
|
|
30
30
|
|
|
31
31
|
|
|
32
|
-
var
|
|
32
|
+
var _chunkAYMITMVRjs = require('./chunk-AYMITMVR.js');
|
|
33
33
|
|
|
34
34
|
|
|
35
|
-
var
|
|
35
|
+
var _chunkYNOJTE3Gjs = require('./chunk-YNOJTE3G.js');
|
|
36
36
|
|
|
37
37
|
|
|
38
38
|
var _chunk3RG5ZIWIjs = require('./chunk-3RG5ZIWI.js');
|
|
@@ -69,12 +69,16 @@ var distDir = () => {
|
|
|
69
69
|
throw new Error(`Server running from unknown location: ${__dirname}`);
|
|
70
70
|
}
|
|
71
71
|
};
|
|
72
|
+
var UPLOAD_URL = /^\/upload\/([0-9a-f]+)$/;
|
|
73
|
+
var DOWNLOAD_URL = /^\/download\/([0-9a-f]+)$/;
|
|
72
74
|
var Server = (_class = class {
|
|
73
|
-
constructor(options, onNewConnection, onClosedConnection, onMessage, log) {;_class.prototype.__init.call(this);_class.prototype.__init2.call(this);_class.prototype.__init3.call(this);_class.prototype.__init4.call(this);_class.prototype.__init5.call(this);_class.prototype.__init6.call(this);_class.prototype.__init7.call(this);_class.prototype.__init8.call(this);_class.prototype.__init9.call(this);_class.prototype.__init10.call(this);_class.prototype.__init11.call(this);_class.prototype.__init12.call(this);
|
|
75
|
+
constructor(options, onNewConnection, onClosedConnection, onMessage, onUpload, onDownload, log) {;_class.prototype.__init.call(this);_class.prototype.__init2.call(this);_class.prototype.__init3.call(this);_class.prototype.__init4.call(this);_class.prototype.__init5.call(this);_class.prototype.__init6.call(this);_class.prototype.__init7.call(this);_class.prototype.__init8.call(this);_class.prototype.__init9.call(this);_class.prototype.__init10.call(this);_class.prototype.__init11.call(this);_class.prototype.__init12.call(this);
|
|
74
76
|
this.options = options;
|
|
75
77
|
this.onNewConnection = onNewConnection;
|
|
76
78
|
this.onClosedConnection = onClosedConnection;
|
|
77
79
|
this.onMessage = onMessage;
|
|
80
|
+
this.onUpload = onUpload;
|
|
81
|
+
this.onDownload = onDownload;
|
|
78
82
|
this.log = log;
|
|
79
83
|
this.title = _nullishCoalesce(options.title, () => ( "@arcanejs"));
|
|
80
84
|
}
|
|
@@ -197,7 +201,7 @@ var Server = (_class = class {
|
|
|
197
201
|
},
|
|
198
202
|
assetUrls: this.createAssetUrls(this.staticFiles)
|
|
199
203
|
};
|
|
200
|
-
_optionalChain([this, 'access',
|
|
204
|
+
_optionalChain([this, 'access', _40 => _40.log, 'optionalAccess', _41 => _41.debug, 'call', _42 => _42("Static Assets: %o", this.staticFiles)]);
|
|
201
205
|
})();
|
|
202
206
|
this.staticFilesInitPromise.catch(() => {
|
|
203
207
|
this.staticFilesInitPromise = null;
|
|
@@ -211,9 +215,9 @@ var Server = (_class = class {
|
|
|
211
215
|
await this.ensureStaticFilesInitialized();
|
|
212
216
|
} catch (err) {
|
|
213
217
|
if (err instanceof Error) {
|
|
214
|
-
_optionalChain([this, 'access',
|
|
218
|
+
_optionalChain([this, 'access', _43 => _43.log, 'optionalAccess', _44 => _44.error, 'call', _45 => _45(err)]);
|
|
215
219
|
} else {
|
|
216
|
-
_optionalChain([this, 'access',
|
|
220
|
+
_optionalChain([this, 'access', _46 => _46.log, 'optionalAccess', _47 => _47.error, 'call', _48 => _48("Error preparing static files: %o", err)]);
|
|
217
221
|
}
|
|
218
222
|
res.writeHead(500, { "Content-Type": "text/plain" });
|
|
219
223
|
res.end("Unable to prepare static files", "utf-8");
|
|
@@ -225,10 +229,10 @@ var Server = (_class = class {
|
|
|
225
229
|
throw new Error("Static assets were not initialized");
|
|
226
230
|
}
|
|
227
231
|
const requestUrl = _nullishCoalesce(req.originalUrl, () => ( req.url));
|
|
228
|
-
_optionalChain([this, 'access',
|
|
232
|
+
_optionalChain([this, 'access', _49 => _49.log, 'optionalAccess', _50 => _50.debug, 'call', _51 => _51("handleHttpRequest %s", requestUrl)]);
|
|
229
233
|
const pathname = this.parsePathname(requestUrl);
|
|
230
234
|
if (pathname === this.options.path) {
|
|
231
|
-
const content = await _asyncNullishCoalesce(await _optionalChain([this, 'access',
|
|
235
|
+
const content = await _asyncNullishCoalesce(await _optionalChain([this, 'access', _52 => _52.options, 'access', _53 => _53.htmlPage, 'optionalCall', _54 => _54(htmlContext)]), async () => ( `
|
|
232
236
|
<html>
|
|
233
237
|
<head>
|
|
234
238
|
<title>${_escapehtml2.default.call(void 0, htmlContext.title)}</title>
|
|
@@ -263,9 +267,9 @@ var Server = (_class = class {
|
|
|
263
267
|
return;
|
|
264
268
|
} catch (err) {
|
|
265
269
|
if (err instanceof Error) {
|
|
266
|
-
_optionalChain([this, 'access',
|
|
270
|
+
_optionalChain([this, 'access', _55 => _55.log, 'optionalAccess', _56 => _56.error, 'call', _57 => _57(err)]);
|
|
267
271
|
} else {
|
|
268
|
-
_optionalChain([this, 'access',
|
|
272
|
+
_optionalChain([this, 'access', _58 => _58.log, 'optionalAccess', _59 => _59.error, 'call', _60 => _60("Error loading static file: %o", err)]);
|
|
269
273
|
}
|
|
270
274
|
res.writeHead(500, { "Content-Type": "text/plain" });
|
|
271
275
|
res.end("Expected static file not found", "utf-8");
|
|
@@ -273,8 +277,45 @@ var Server = (_class = class {
|
|
|
273
277
|
}
|
|
274
278
|
}
|
|
275
279
|
}
|
|
276
|
-
|
|
277
|
-
|
|
280
|
+
const [uploadMatch, downloadMatch] = [
|
|
281
|
+
UPLOAD_URL.exec(pathname),
|
|
282
|
+
DOWNLOAD_URL.exec(pathname)
|
|
283
|
+
];
|
|
284
|
+
if (_optionalChain([uploadMatch, 'optionalAccess', _61 => _61[1]])) {
|
|
285
|
+
const id = uploadMatch[1];
|
|
286
|
+
_optionalChain([this, 'access', _62 => _62.log, 'optionalAccess', _63 => _63.debug, 'call', _64 => _64("Upload request for id: %s", id)]);
|
|
287
|
+
this.onUpload(id, req).then(() => {
|
|
288
|
+
res.writeHead(200, { "Content-Type": "text/plain" });
|
|
289
|
+
res.end("Upload successful", "utf-8");
|
|
290
|
+
}).catch((cause) => {
|
|
291
|
+
const error = new Error(`Error handling upload for id ${id}`, {
|
|
292
|
+
cause
|
|
293
|
+
});
|
|
294
|
+
_optionalChain([this, 'access', _65 => _65.log, 'optionalAccess', _66 => _66.error, 'call', _67 => _67(error)]);
|
|
295
|
+
res.writeHead(500, { "Content-Type": "text/plain" });
|
|
296
|
+
res.end("Error handling upload", "utf-8");
|
|
297
|
+
});
|
|
298
|
+
} else if (_optionalChain([downloadMatch, 'optionalAccess', _68 => _68[1]])) {
|
|
299
|
+
const id = downloadMatch[1];
|
|
300
|
+
_optionalChain([this, 'access', _69 => _69.log, 'optionalAccess', _70 => _70.debug, 'call', _71 => _71("Download request for id: %s", id)]);
|
|
301
|
+
this.onDownload(id).then((handler) => handler()).then(({ stream, headers }) => {
|
|
302
|
+
res.writeHead(200, {
|
|
303
|
+
"Content-Type": "application/octet-stream",
|
|
304
|
+
...headers
|
|
305
|
+
});
|
|
306
|
+
stream.pipe(res);
|
|
307
|
+
}).catch((cause) => {
|
|
308
|
+
const error = new Error(`Error handling download for id ${id}`, {
|
|
309
|
+
cause
|
|
310
|
+
});
|
|
311
|
+
_optionalChain([this, 'access', _72 => _72.log, 'optionalAccess', _73 => _73.error, 'call', _74 => _74(error)]);
|
|
312
|
+
res.writeHead(500, { "Content-Type": "text/plain" });
|
|
313
|
+
res.end("Error handling download", "utf-8");
|
|
314
|
+
});
|
|
315
|
+
} else {
|
|
316
|
+
res.writeHead(404, { "Content-Type": "text/plain" });
|
|
317
|
+
res.end("not found", "utf-8");
|
|
318
|
+
}
|
|
278
319
|
}}
|
|
279
320
|
__init8() {this.parsePathname = (url) => {
|
|
280
321
|
if (!url) return "";
|
|
@@ -314,7 +355,7 @@ var Server = (_class = class {
|
|
|
314
355
|
sendMessage: (msg) => ws.send(JSON.stringify(msg))
|
|
315
356
|
};
|
|
316
357
|
this.onNewConnection(connection);
|
|
317
|
-
_optionalChain([this, 'access',
|
|
358
|
+
_optionalChain([this, 'access', _75 => _75.log, 'optionalAccess', _76 => _76.debug, 'call', _77 => _77("new connection")]);
|
|
318
359
|
ws.on(
|
|
319
360
|
"message",
|
|
320
361
|
(msg) => this.onMessage(connection, JSON.parse(msg.toString()))
|
|
@@ -327,6 +368,7 @@ var Server = (_class = class {
|
|
|
327
368
|
var _ws = require('ws');
|
|
328
369
|
var _http = require('http');
|
|
329
370
|
var _uuid = require('uuid');
|
|
371
|
+
var _crypto = require('crypto');
|
|
330
372
|
var normalizeClockSyncOptions = (clockSync) => {
|
|
331
373
|
if (!clockSync) {
|
|
332
374
|
return null;
|
|
@@ -351,9 +393,11 @@ var Toolkit = (_class2 = class {
|
|
|
351
393
|
__init14() {this.connections = /* @__PURE__ */ new Map()}
|
|
352
394
|
__init15() {this.rootGroup = null}
|
|
353
395
|
/** @hidden */
|
|
354
|
-
__init16() {this.events = new (0,
|
|
396
|
+
__init16() {this.events = new (0, _chunkYNOJTE3Gjs.EventEmitter)()}
|
|
355
397
|
|
|
356
|
-
|
|
398
|
+
__init17() {this.uploads = /* @__PURE__ */ new Map()}
|
|
399
|
+
__init18() {this.downloads = /* @__PURE__ */ new Map()}
|
|
400
|
+
constructor(options = {}) {;_class2.prototype.__init13.call(this);_class2.prototype.__init14.call(this);_class2.prototype.__init15.call(this);_class2.prototype.__init16.call(this);_class2.prototype.__init17.call(this);_class2.prototype.__init18.call(this);_class2.prototype.__init19.call(this);_class2.prototype.__init20.call(this);_class2.prototype.__init21.call(this);_class2.prototype.__init22.call(this);_class2.prototype.__init23.call(this);_class2.prototype.__init24.call(this);_class2.prototype.__init25.call(this);_class2.prototype.__init26.call(this);_class2.prototype.__init27.call(this);_class2.prototype.__init28.call(this);_class2.prototype.__init29.call(this);_class2.prototype.__init30.call(this);_class2.prototype.__init31.call(this);_class2.prototype.__init32.call(this);_class2.prototype.__init33.call(this);
|
|
357
401
|
this.options = {
|
|
358
402
|
...DEFAULT_LIGHT_DESK_OPTIONS,
|
|
359
403
|
...options
|
|
@@ -369,17 +413,19 @@ var Toolkit = (_class2 = class {
|
|
|
369
413
|
this.onNewConnection,
|
|
370
414
|
this.onClosedConnection,
|
|
371
415
|
this.onMessage,
|
|
416
|
+
this.onUpload,
|
|
417
|
+
this.onDownload,
|
|
372
418
|
this.options.log
|
|
373
419
|
);
|
|
374
420
|
}
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
421
|
+
__init19() {this.addListener = this.events.addListener}
|
|
422
|
+
__init20() {this.removeListener = this.events.removeListener}
|
|
423
|
+
__init21() {this.start = (opts) => {
|
|
378
424
|
if (opts.mode === "automatic") {
|
|
379
425
|
this.listen({ port: opts.port }).then(() => {
|
|
380
426
|
const url = `http://localhost:${opts.port}${this.options.path}`;
|
|
381
|
-
_optionalChain([opts, 'access',
|
|
382
|
-
_optionalChain([this, 'access',
|
|
427
|
+
_optionalChain([opts, 'access', _111 => _111.onReady, 'optionalCall', _112 => _112(url)]);
|
|
428
|
+
_optionalChain([this, 'access', _113 => _113.options, 'access', _114 => _114.log, 'optionalAccess', _115 => _115.info, 'call', _116 => _116(`Light Desk Started: ${url}`)]);
|
|
383
429
|
});
|
|
384
430
|
} else if (opts.mode === "express") {
|
|
385
431
|
const wss = new (0, _ws.WebSocketServer)({
|
|
@@ -393,7 +439,7 @@ var Toolkit = (_class2 = class {
|
|
|
393
439
|
throw new Error(`Unsupported mode`);
|
|
394
440
|
}
|
|
395
441
|
}}
|
|
396
|
-
|
|
442
|
+
__init22() {this.listen = ({
|
|
397
443
|
port,
|
|
398
444
|
host
|
|
399
445
|
}) => {
|
|
@@ -428,7 +474,7 @@ var Toolkit = (_class2 = class {
|
|
|
428
474
|
}
|
|
429
475
|
});
|
|
430
476
|
}}
|
|
431
|
-
|
|
477
|
+
__init23() {this.setRoot = (group) => {
|
|
432
478
|
if (this.rootGroup) {
|
|
433
479
|
throw new Error("Can only set root group once");
|
|
434
480
|
}
|
|
@@ -438,10 +484,10 @@ var Toolkit = (_class2 = class {
|
|
|
438
484
|
log() {
|
|
439
485
|
return _nullishCoalesce(this.options.log, () => ( null));
|
|
440
486
|
}
|
|
441
|
-
|
|
487
|
+
__init24() {this.getConnections = () => {
|
|
442
488
|
return [...this.connections.values()].map((c) => c.publicConnection);
|
|
443
489
|
}}
|
|
444
|
-
|
|
490
|
+
__init25() {this.updateTree = _lodash2.default.throttle(
|
|
445
491
|
() => {
|
|
446
492
|
setImmediate(() => {
|
|
447
493
|
if (!this.rootGroup) return;
|
|
@@ -462,20 +508,20 @@ var Toolkit = (_class2 = class {
|
|
|
462
508
|
10,
|
|
463
509
|
{ leading: true, trailing: true }
|
|
464
510
|
)}
|
|
465
|
-
|
|
511
|
+
__init26() {this.removeChild = (component) => {
|
|
466
512
|
if (this.rootGroup === component) {
|
|
467
513
|
this.rootGroup = null;
|
|
468
514
|
component.setParent(null);
|
|
469
515
|
}
|
|
470
516
|
}}
|
|
471
|
-
|
|
517
|
+
__init27() {this.onNewConnection = (connection) => {
|
|
472
518
|
const uuid = _uuid.v4.call(void 0, );
|
|
473
519
|
const publicConnection = {
|
|
474
520
|
get uuid() {
|
|
475
521
|
return uuid;
|
|
476
522
|
}
|
|
477
523
|
};
|
|
478
|
-
const lastTreeSent = _nullishCoalesce(_optionalChain([this, 'access',
|
|
524
|
+
const lastTreeSent = _nullishCoalesce(_optionalChain([this, 'access', _117 => _117.rootGroup, 'optionalAccess', _118 => _118.getProtoInfo, 'call', _119 => _119(this.componentIDMap, {
|
|
479
525
|
connection: publicConnection
|
|
480
526
|
})]), () => ( void 0));
|
|
481
527
|
this.connections.set(connection, {
|
|
@@ -497,24 +543,63 @@ var Toolkit = (_class2 = class {
|
|
|
497
543
|
});
|
|
498
544
|
}
|
|
499
545
|
}}
|
|
500
|
-
|
|
501
|
-
_optionalChain([this, 'access',
|
|
546
|
+
__init28() {this.onClosedConnection = (connection) => {
|
|
547
|
+
_optionalChain([this, 'access', _120 => _120.log, 'call', _121 => _121(), 'optionalAccess', _122 => _122.debug, 'call', _123 => _123("removing connection")]);
|
|
502
548
|
const con = this.connections.get(connection);
|
|
503
549
|
this.connections.delete(connection);
|
|
504
550
|
if (con) {
|
|
551
|
+
let inProgressUploads = 0;
|
|
552
|
+
let inProgressDownloads = 0;
|
|
553
|
+
for (const [id, upload] of this.uploads.entries()) {
|
|
554
|
+
if (upload.connection === connection) {
|
|
555
|
+
this.uploads.delete(id);
|
|
556
|
+
inProgressUploads++;
|
|
557
|
+
}
|
|
558
|
+
}
|
|
559
|
+
for (const [id, download] of this.downloads.entries()) {
|
|
560
|
+
if (download.connection === connection) {
|
|
561
|
+
this.downloads.delete(id);
|
|
562
|
+
inProgressDownloads++;
|
|
563
|
+
}
|
|
564
|
+
}
|
|
565
|
+
if (inProgressUploads > 0 || inProgressDownloads > 0) {
|
|
566
|
+
_optionalChain([this, 'access', _124 => _124.log, 'call', _125 => _125(), 'optionalAccess', _126 => _126.info, 'call', _127 => _127(
|
|
567
|
+
`Connection closed with ${inProgressUploads} in-progress uploads and ${inProgressDownloads} in-progress downloads`
|
|
568
|
+
)]);
|
|
569
|
+
}
|
|
505
570
|
this.events.emit("closed-connection", con.publicConnection);
|
|
506
571
|
}
|
|
507
572
|
}}
|
|
508
|
-
|
|
573
|
+
__init29() {this.handleCall = async (connection, publicConnection, call) => {
|
|
509
574
|
try {
|
|
510
575
|
const rg = this.rootGroup;
|
|
511
576
|
if (rg) {
|
|
512
|
-
const
|
|
577
|
+
const handlerValue = await new Promise(
|
|
513
578
|
(resolve2, reject) => rg.routeCall(this.componentIDMap, call, publicConnection, {
|
|
514
579
|
resolve: resolve2,
|
|
515
580
|
reject
|
|
516
581
|
})
|
|
517
582
|
);
|
|
583
|
+
let returnValue;
|
|
584
|
+
if (call.type === "component-call") {
|
|
585
|
+
returnValue = handlerValue;
|
|
586
|
+
} else if (call.type === "component-call-upload") {
|
|
587
|
+
const uploadHandler = handlerValue;
|
|
588
|
+
const secureId = _crypto.randomBytes.call(void 0, 32).toString("hex");
|
|
589
|
+
this.uploads.set(secureId, {
|
|
590
|
+
connection,
|
|
591
|
+
handler: uploadHandler
|
|
592
|
+
});
|
|
593
|
+
returnValue = secureId;
|
|
594
|
+
} else if (call.type === "component-call-download") {
|
|
595
|
+
const downloadHandler = handlerValue;
|
|
596
|
+
const secureId = _crypto.randomBytes.call(void 0, 32).toString("hex");
|
|
597
|
+
this.downloads.set(secureId, {
|
|
598
|
+
connection,
|
|
599
|
+
handler: downloadHandler
|
|
600
|
+
});
|
|
601
|
+
returnValue = secureId;
|
|
602
|
+
}
|
|
518
603
|
connection.sendMessage({
|
|
519
604
|
type: "call-response",
|
|
520
605
|
namespace: call.namespace,
|
|
@@ -525,47 +610,81 @@ var Toolkit = (_class2 = class {
|
|
|
525
610
|
} else {
|
|
526
611
|
throw new Error("No root group set");
|
|
527
612
|
}
|
|
528
|
-
} catch (
|
|
613
|
+
} catch (cause) {
|
|
614
|
+
const error = new Error(`Error handling call`, { cause });
|
|
615
|
+
_optionalChain([this, 'access', _128 => _128.log, 'call', _129 => _129(), 'optionalAccess', _130 => _130.error, 'call', _131 => _131(error)]);
|
|
529
616
|
connection.sendMessage({
|
|
530
617
|
type: "call-response",
|
|
531
618
|
namespace: call.namespace,
|
|
532
619
|
requestId: call.requestId,
|
|
533
620
|
success: false,
|
|
534
|
-
errorMessage: `${
|
|
621
|
+
errorMessage: `${cause}`
|
|
535
622
|
});
|
|
536
623
|
}
|
|
537
624
|
}}
|
|
538
|
-
|
|
625
|
+
__init30() {this.onMessage = (connection, message) => {
|
|
539
626
|
const con = this.connections.get(connection);
|
|
540
627
|
if (!con) {
|
|
541
|
-
_optionalChain([this, 'access',
|
|
628
|
+
_optionalChain([this, 'access', _132 => _132.log, 'call', _133 => _133(), 'optionalAccess', _134 => _134.warn, 'call', _135 => _135(`got message from unknown connection`)]);
|
|
542
629
|
return;
|
|
543
630
|
}
|
|
544
631
|
const { publicConnection } = con;
|
|
545
|
-
_optionalChain([this, 'access',
|
|
632
|
+
_optionalChain([this, 'access', _136 => _136.log, 'call', _137 => _137(), 'optionalAccess', _138 => _138.debug, 'call', _139 => _139(
|
|
546
633
|
"got message: %o from %s",
|
|
547
634
|
message,
|
|
548
635
|
publicConnection.uuid
|
|
549
636
|
)]);
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
this.rootGroup
|
|
554
|
-
this.
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
637
|
+
try {
|
|
638
|
+
switch (message.type) {
|
|
639
|
+
case "component-message":
|
|
640
|
+
if (this.rootGroup)
|
|
641
|
+
this.rootGroup.routeMessage(
|
|
642
|
+
this.componentIDMap,
|
|
643
|
+
message,
|
|
644
|
+
publicConnection
|
|
645
|
+
);
|
|
646
|
+
break;
|
|
647
|
+
case "component-call":
|
|
648
|
+
case "component-call-upload":
|
|
649
|
+
case "component-call-download":
|
|
650
|
+
this.handleCall(connection, publicConnection, message);
|
|
651
|
+
break;
|
|
652
|
+
case "ping": {
|
|
653
|
+
connection.sendMessage({
|
|
654
|
+
type: "pong",
|
|
655
|
+
pingId: message.pingId,
|
|
656
|
+
serverTimeMillis: Date.now()
|
|
657
|
+
});
|
|
658
|
+
break;
|
|
659
|
+
}
|
|
660
|
+
}
|
|
661
|
+
} catch (cause) {
|
|
662
|
+
const error = new Error(
|
|
663
|
+
`Error handling message: ${JSON.stringify(message)}`,
|
|
664
|
+
{ cause }
|
|
665
|
+
);
|
|
666
|
+
_optionalChain([this, 'access', _140 => _140.log, 'call', _141 => _141(), 'optionalAccess', _142 => _142.error, 'call', _143 => _143(error)]);
|
|
667
|
+
}
|
|
668
|
+
}}
|
|
669
|
+
__init31() {this.onUpload = async (id, data) => {
|
|
670
|
+
const upload = this.uploads.get(id);
|
|
671
|
+
if (!upload) {
|
|
672
|
+
throw new Error(`No upload handler found for id: ${id}`);
|
|
673
|
+
}
|
|
674
|
+
await upload.handler(data);
|
|
675
|
+
this.uploads.delete(id);
|
|
676
|
+
}}
|
|
677
|
+
__init32() {this.onDownload = async (id) => {
|
|
678
|
+
const download = this.downloads.get(id);
|
|
679
|
+
if (!download) {
|
|
680
|
+
throw new Error(`No download handler found for id: ${id}`);
|
|
681
|
+
}
|
|
682
|
+
return download.handler;
|
|
683
|
+
}}
|
|
684
|
+
__init33() {this.sendNotification = (notification, filter) => {
|
|
685
|
+
for (const [connection, meta] of this.connections.entries()) {
|
|
686
|
+
if (!filter || filter(meta.publicConnection)) {
|
|
687
|
+
connection.sendMessage(notification);
|
|
569
688
|
}
|
|
570
689
|
}
|
|
571
690
|
}}
|
|
@@ -583,4 +702,4 @@ var Toolkit = (_class2 = class {
|
|
|
583
702
|
|
|
584
703
|
|
|
585
704
|
|
|
586
|
-
exports.Button =
|
|
705
|
+
exports.Button = _chunkRELZ3VTJjs.Button; exports.Group = _chunkKRGLXKY2js.Group; exports.GroupHeader = _chunkKRGLXKY2js.GroupHeader; exports.Label = _chunkNEFCI6N6js.Label; exports.Rect = _chunkVTNAO4KCjs.Rect; exports.SliderButton = _chunkY5FC42KDjs.SliderButton; exports.Switch = _chunkAYMITMVRjs.Switch; exports.Tab = _chunkSPYBETRJjs.Tab; exports.Tabs = _chunkSPYBETRJjs.Tabs; exports.TextInput = _chunk2R23ER4Kjs.TextInput; exports.Timeline = _chunkQHCNKTKWjs.Timeline; exports.Toolkit = Toolkit;
|