@arcanejs/toolkit 8.0.0 → 9.0.1
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 +190 -64
- package/dist/index.mjs +161 -35
- package/dist/{toolkit-Bglbv3ix.d.ts → toolkit-0nxr5FpP.d.ts} +116 -93
- package/dist/{toolkit-BPqxbDbk.d.mts → toolkit-BYE-VOhF.d.mts} +116 -93
- package/package.json +16 -16
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,15 +69,26 @@ 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
|
}
|
|
85
|
+
|
|
86
|
+
|
|
87
|
+
|
|
88
|
+
|
|
89
|
+
|
|
90
|
+
|
|
91
|
+
|
|
81
92
|
__init() {this.staticFiles = null}
|
|
82
93
|
__init2() {this.htmlContext = null}
|
|
83
94
|
__init3() {this.staticFilesInitPromise = null}
|
|
@@ -197,7 +208,7 @@ var Server = (_class = class {
|
|
|
197
208
|
},
|
|
198
209
|
assetUrls: this.createAssetUrls(this.staticFiles)
|
|
199
210
|
};
|
|
200
|
-
_optionalChain([this, 'access',
|
|
211
|
+
_optionalChain([this, 'access', _40 => _40.log, 'optionalAccess', _41 => _41.debug, 'call', _42 => _42("Static Assets: %o", this.staticFiles)]);
|
|
201
212
|
})();
|
|
202
213
|
this.staticFilesInitPromise.catch(() => {
|
|
203
214
|
this.staticFilesInitPromise = null;
|
|
@@ -211,9 +222,9 @@ var Server = (_class = class {
|
|
|
211
222
|
await this.ensureStaticFilesInitialized();
|
|
212
223
|
} catch (err) {
|
|
213
224
|
if (err instanceof Error) {
|
|
214
|
-
_optionalChain([this, 'access',
|
|
225
|
+
_optionalChain([this, 'access', _43 => _43.log, 'optionalAccess', _44 => _44.error, 'call', _45 => _45(err)]);
|
|
215
226
|
} else {
|
|
216
|
-
_optionalChain([this, 'access',
|
|
227
|
+
_optionalChain([this, 'access', _46 => _46.log, 'optionalAccess', _47 => _47.error, 'call', _48 => _48("Error preparing static files: %o", err)]);
|
|
217
228
|
}
|
|
218
229
|
res.writeHead(500, { "Content-Type": "text/plain" });
|
|
219
230
|
res.end("Unable to prepare static files", "utf-8");
|
|
@@ -225,10 +236,10 @@ var Server = (_class = class {
|
|
|
225
236
|
throw new Error("Static assets were not initialized");
|
|
226
237
|
}
|
|
227
238
|
const requestUrl = _nullishCoalesce(req.originalUrl, () => ( req.url));
|
|
228
|
-
_optionalChain([this, 'access',
|
|
239
|
+
_optionalChain([this, 'access', _49 => _49.log, 'optionalAccess', _50 => _50.debug, 'call', _51 => _51("handleHttpRequest %s", requestUrl)]);
|
|
229
240
|
const pathname = this.parsePathname(requestUrl);
|
|
230
241
|
if (pathname === this.options.path) {
|
|
231
|
-
const content = await _asyncNullishCoalesce(await _optionalChain([this, 'access',
|
|
242
|
+
const content = await _asyncNullishCoalesce(await _optionalChain([this, 'access', _52 => _52.options, 'access', _53 => _53.htmlPage, 'optionalCall', _54 => _54(htmlContext)]), async () => ( `
|
|
232
243
|
<html>
|
|
233
244
|
<head>
|
|
234
245
|
<title>${_escapehtml2.default.call(void 0, htmlContext.title)}</title>
|
|
@@ -263,9 +274,9 @@ var Server = (_class = class {
|
|
|
263
274
|
return;
|
|
264
275
|
} catch (err) {
|
|
265
276
|
if (err instanceof Error) {
|
|
266
|
-
_optionalChain([this, 'access',
|
|
277
|
+
_optionalChain([this, 'access', _55 => _55.log, 'optionalAccess', _56 => _56.error, 'call', _57 => _57(err)]);
|
|
267
278
|
} else {
|
|
268
|
-
_optionalChain([this, 'access',
|
|
279
|
+
_optionalChain([this, 'access', _58 => _58.log, 'optionalAccess', _59 => _59.error, 'call', _60 => _60("Error loading static file: %o", err)]);
|
|
269
280
|
}
|
|
270
281
|
res.writeHead(500, { "Content-Type": "text/plain" });
|
|
271
282
|
res.end("Expected static file not found", "utf-8");
|
|
@@ -273,8 +284,45 @@ var Server = (_class = class {
|
|
|
273
284
|
}
|
|
274
285
|
}
|
|
275
286
|
}
|
|
276
|
-
|
|
277
|
-
|
|
287
|
+
const [uploadMatch, downloadMatch] = [
|
|
288
|
+
UPLOAD_URL.exec(pathname),
|
|
289
|
+
DOWNLOAD_URL.exec(pathname)
|
|
290
|
+
];
|
|
291
|
+
if (_optionalChain([uploadMatch, 'optionalAccess', _61 => _61[1]])) {
|
|
292
|
+
const id = uploadMatch[1];
|
|
293
|
+
_optionalChain([this, 'access', _62 => _62.log, 'optionalAccess', _63 => _63.debug, 'call', _64 => _64("Upload request for id: %s", id)]);
|
|
294
|
+
this.onUpload(id, req).then(() => {
|
|
295
|
+
res.writeHead(200, { "Content-Type": "text/plain" });
|
|
296
|
+
res.end("Upload successful", "utf-8");
|
|
297
|
+
}).catch((cause) => {
|
|
298
|
+
const error = new Error(`Error handling upload for id ${id}`, {
|
|
299
|
+
cause
|
|
300
|
+
});
|
|
301
|
+
_optionalChain([this, 'access', _65 => _65.log, 'optionalAccess', _66 => _66.error, 'call', _67 => _67(error)]);
|
|
302
|
+
res.writeHead(500, { "Content-Type": "text/plain" });
|
|
303
|
+
res.end("Error handling upload", "utf-8");
|
|
304
|
+
});
|
|
305
|
+
} else if (_optionalChain([downloadMatch, 'optionalAccess', _68 => _68[1]])) {
|
|
306
|
+
const id = downloadMatch[1];
|
|
307
|
+
_optionalChain([this, 'access', _69 => _69.log, 'optionalAccess', _70 => _70.debug, 'call', _71 => _71("Download request for id: %s", id)]);
|
|
308
|
+
this.onDownload(id).then((handler) => handler()).then(({ stream, headers }) => {
|
|
309
|
+
res.writeHead(200, {
|
|
310
|
+
"Content-Type": "application/octet-stream",
|
|
311
|
+
...headers
|
|
312
|
+
});
|
|
313
|
+
stream.pipe(res);
|
|
314
|
+
}).catch((cause) => {
|
|
315
|
+
const error = new Error(`Error handling download for id ${id}`, {
|
|
316
|
+
cause
|
|
317
|
+
});
|
|
318
|
+
_optionalChain([this, 'access', _72 => _72.log, 'optionalAccess', _73 => _73.error, 'call', _74 => _74(error)]);
|
|
319
|
+
res.writeHead(500, { "Content-Type": "text/plain" });
|
|
320
|
+
res.end("Error handling download", "utf-8");
|
|
321
|
+
});
|
|
322
|
+
} else {
|
|
323
|
+
res.writeHead(404, { "Content-Type": "text/plain" });
|
|
324
|
+
res.end("not found", "utf-8");
|
|
325
|
+
}
|
|
278
326
|
}}
|
|
279
327
|
__init8() {this.parsePathname = (url) => {
|
|
280
328
|
if (!url) return "";
|
|
@@ -314,7 +362,7 @@ var Server = (_class = class {
|
|
|
314
362
|
sendMessage: (msg) => ws.send(JSON.stringify(msg))
|
|
315
363
|
};
|
|
316
364
|
this.onNewConnection(connection);
|
|
317
|
-
_optionalChain([this, 'access',
|
|
365
|
+
_optionalChain([this, 'access', _75 => _75.log, 'optionalAccess', _76 => _76.debug, 'call', _77 => _77("new connection")]);
|
|
318
366
|
ws.on(
|
|
319
367
|
"message",
|
|
320
368
|
(msg) => this.onMessage(connection, JSON.parse(msg.toString()))
|
|
@@ -327,6 +375,7 @@ var Server = (_class = class {
|
|
|
327
375
|
var _ws = require('ws');
|
|
328
376
|
var _http = require('http');
|
|
329
377
|
var _uuid = require('uuid');
|
|
378
|
+
var _crypto = require('crypto');
|
|
330
379
|
var normalizeClockSyncOptions = (clockSync) => {
|
|
331
380
|
if (!clockSync) {
|
|
332
381
|
return null;
|
|
@@ -351,9 +400,11 @@ var Toolkit = (_class2 = class {
|
|
|
351
400
|
__init14() {this.connections = /* @__PURE__ */ new Map()}
|
|
352
401
|
__init15() {this.rootGroup = null}
|
|
353
402
|
/** @hidden */
|
|
354
|
-
__init16() {this.events = new (0,
|
|
403
|
+
__init16() {this.events = new (0, _chunkYNOJTE3Gjs.EventEmitter)()}
|
|
355
404
|
|
|
356
|
-
|
|
405
|
+
__init17() {this.uploads = /* @__PURE__ */ new Map()}
|
|
406
|
+
__init18() {this.downloads = /* @__PURE__ */ new Map()}
|
|
407
|
+
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
408
|
this.options = {
|
|
358
409
|
...DEFAULT_LIGHT_DESK_OPTIONS,
|
|
359
410
|
...options
|
|
@@ -369,17 +420,19 @@ var Toolkit = (_class2 = class {
|
|
|
369
420
|
this.onNewConnection,
|
|
370
421
|
this.onClosedConnection,
|
|
371
422
|
this.onMessage,
|
|
423
|
+
this.onUpload,
|
|
424
|
+
this.onDownload,
|
|
372
425
|
this.options.log
|
|
373
426
|
);
|
|
374
427
|
}
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
428
|
+
__init19() {this.addListener = this.events.addListener}
|
|
429
|
+
__init20() {this.removeListener = this.events.removeListener}
|
|
430
|
+
__init21() {this.start = (opts) => {
|
|
378
431
|
if (opts.mode === "automatic") {
|
|
379
432
|
this.listen({ port: opts.port }).then(() => {
|
|
380
433
|
const url = `http://localhost:${opts.port}${this.options.path}`;
|
|
381
|
-
_optionalChain([opts, 'access',
|
|
382
|
-
_optionalChain([this, 'access',
|
|
434
|
+
_optionalChain([opts, 'access', _111 => _111.onReady, 'optionalCall', _112 => _112(url)]);
|
|
435
|
+
_optionalChain([this, 'access', _113 => _113.options, 'access', _114 => _114.log, 'optionalAccess', _115 => _115.info, 'call', _116 => _116(`Light Desk Started: ${url}`)]);
|
|
383
436
|
});
|
|
384
437
|
} else if (opts.mode === "express") {
|
|
385
438
|
const wss = new (0, _ws.WebSocketServer)({
|
|
@@ -393,7 +446,7 @@ var Toolkit = (_class2 = class {
|
|
|
393
446
|
throw new Error(`Unsupported mode`);
|
|
394
447
|
}
|
|
395
448
|
}}
|
|
396
|
-
|
|
449
|
+
__init22() {this.listen = ({
|
|
397
450
|
port,
|
|
398
451
|
host
|
|
399
452
|
}) => {
|
|
@@ -428,7 +481,7 @@ var Toolkit = (_class2 = class {
|
|
|
428
481
|
}
|
|
429
482
|
});
|
|
430
483
|
}}
|
|
431
|
-
|
|
484
|
+
__init23() {this.setRoot = (group) => {
|
|
432
485
|
if (this.rootGroup) {
|
|
433
486
|
throw new Error("Can only set root group once");
|
|
434
487
|
}
|
|
@@ -438,10 +491,10 @@ var Toolkit = (_class2 = class {
|
|
|
438
491
|
log() {
|
|
439
492
|
return _nullishCoalesce(this.options.log, () => ( null));
|
|
440
493
|
}
|
|
441
|
-
|
|
494
|
+
__init24() {this.getConnections = () => {
|
|
442
495
|
return [...this.connections.values()].map((c) => c.publicConnection);
|
|
443
496
|
}}
|
|
444
|
-
|
|
497
|
+
__init25() {this.updateTree = _lodash2.default.throttle(
|
|
445
498
|
() => {
|
|
446
499
|
setImmediate(() => {
|
|
447
500
|
if (!this.rootGroup) return;
|
|
@@ -462,20 +515,20 @@ var Toolkit = (_class2 = class {
|
|
|
462
515
|
10,
|
|
463
516
|
{ leading: true, trailing: true }
|
|
464
517
|
)}
|
|
465
|
-
|
|
518
|
+
__init26() {this.removeChild = (component) => {
|
|
466
519
|
if (this.rootGroup === component) {
|
|
467
520
|
this.rootGroup = null;
|
|
468
521
|
component.setParent(null);
|
|
469
522
|
}
|
|
470
523
|
}}
|
|
471
|
-
|
|
524
|
+
__init27() {this.onNewConnection = (connection) => {
|
|
472
525
|
const uuid = _uuid.v4.call(void 0, );
|
|
473
526
|
const publicConnection = {
|
|
474
527
|
get uuid() {
|
|
475
528
|
return uuid;
|
|
476
529
|
}
|
|
477
530
|
};
|
|
478
|
-
const lastTreeSent = _nullishCoalesce(_optionalChain([this, 'access',
|
|
531
|
+
const lastTreeSent = _nullishCoalesce(_optionalChain([this, 'access', _117 => _117.rootGroup, 'optionalAccess', _118 => _118.getProtoInfo, 'call', _119 => _119(this.componentIDMap, {
|
|
479
532
|
connection: publicConnection
|
|
480
533
|
})]), () => ( void 0));
|
|
481
534
|
this.connections.set(connection, {
|
|
@@ -497,24 +550,63 @@ var Toolkit = (_class2 = class {
|
|
|
497
550
|
});
|
|
498
551
|
}
|
|
499
552
|
}}
|
|
500
|
-
|
|
501
|
-
_optionalChain([this, 'access',
|
|
553
|
+
__init28() {this.onClosedConnection = (connection) => {
|
|
554
|
+
_optionalChain([this, 'access', _120 => _120.log, 'call', _121 => _121(), 'optionalAccess', _122 => _122.debug, 'call', _123 => _123("removing connection")]);
|
|
502
555
|
const con = this.connections.get(connection);
|
|
503
556
|
this.connections.delete(connection);
|
|
504
557
|
if (con) {
|
|
558
|
+
let inProgressUploads = 0;
|
|
559
|
+
let inProgressDownloads = 0;
|
|
560
|
+
for (const [id, upload] of this.uploads.entries()) {
|
|
561
|
+
if (upload.connection === connection) {
|
|
562
|
+
this.uploads.delete(id);
|
|
563
|
+
inProgressUploads++;
|
|
564
|
+
}
|
|
565
|
+
}
|
|
566
|
+
for (const [id, download] of this.downloads.entries()) {
|
|
567
|
+
if (download.connection === connection) {
|
|
568
|
+
this.downloads.delete(id);
|
|
569
|
+
inProgressDownloads++;
|
|
570
|
+
}
|
|
571
|
+
}
|
|
572
|
+
if (inProgressUploads > 0 || inProgressDownloads > 0) {
|
|
573
|
+
_optionalChain([this, 'access', _124 => _124.log, 'call', _125 => _125(), 'optionalAccess', _126 => _126.info, 'call', _127 => _127(
|
|
574
|
+
`Connection closed with ${inProgressUploads} in-progress uploads and ${inProgressDownloads} in-progress downloads`
|
|
575
|
+
)]);
|
|
576
|
+
}
|
|
505
577
|
this.events.emit("closed-connection", con.publicConnection);
|
|
506
578
|
}
|
|
507
579
|
}}
|
|
508
|
-
|
|
580
|
+
__init29() {this.handleCall = async (connection, publicConnection, call) => {
|
|
509
581
|
try {
|
|
510
582
|
const rg = this.rootGroup;
|
|
511
583
|
if (rg) {
|
|
512
|
-
const
|
|
584
|
+
const handlerValue = await new Promise(
|
|
513
585
|
(resolve2, reject) => rg.routeCall(this.componentIDMap, call, publicConnection, {
|
|
514
586
|
resolve: resolve2,
|
|
515
587
|
reject
|
|
516
588
|
})
|
|
517
589
|
);
|
|
590
|
+
let returnValue;
|
|
591
|
+
if (call.type === "component-call") {
|
|
592
|
+
returnValue = handlerValue;
|
|
593
|
+
} else if (call.type === "component-call-upload") {
|
|
594
|
+
const uploadHandler = handlerValue;
|
|
595
|
+
const secureId = _crypto.randomBytes.call(void 0, 32).toString("hex");
|
|
596
|
+
this.uploads.set(secureId, {
|
|
597
|
+
connection,
|
|
598
|
+
handler: uploadHandler
|
|
599
|
+
});
|
|
600
|
+
returnValue = secureId;
|
|
601
|
+
} else if (call.type === "component-call-download") {
|
|
602
|
+
const downloadHandler = handlerValue;
|
|
603
|
+
const secureId = _crypto.randomBytes.call(void 0, 32).toString("hex");
|
|
604
|
+
this.downloads.set(secureId, {
|
|
605
|
+
connection,
|
|
606
|
+
handler: downloadHandler
|
|
607
|
+
});
|
|
608
|
+
returnValue = secureId;
|
|
609
|
+
}
|
|
518
610
|
connection.sendMessage({
|
|
519
611
|
type: "call-response",
|
|
520
612
|
namespace: call.namespace,
|
|
@@ -525,47 +617,81 @@ var Toolkit = (_class2 = class {
|
|
|
525
617
|
} else {
|
|
526
618
|
throw new Error("No root group set");
|
|
527
619
|
}
|
|
528
|
-
} catch (
|
|
620
|
+
} catch (cause) {
|
|
621
|
+
const error = new Error(`Error handling call`, { cause });
|
|
622
|
+
_optionalChain([this, 'access', _128 => _128.log, 'call', _129 => _129(), 'optionalAccess', _130 => _130.error, 'call', _131 => _131(error)]);
|
|
529
623
|
connection.sendMessage({
|
|
530
624
|
type: "call-response",
|
|
531
625
|
namespace: call.namespace,
|
|
532
626
|
requestId: call.requestId,
|
|
533
627
|
success: false,
|
|
534
|
-
errorMessage: `${
|
|
628
|
+
errorMessage: `${cause}`
|
|
535
629
|
});
|
|
536
630
|
}
|
|
537
631
|
}}
|
|
538
|
-
|
|
632
|
+
__init30() {this.onMessage = (connection, message) => {
|
|
539
633
|
const con = this.connections.get(connection);
|
|
540
634
|
if (!con) {
|
|
541
|
-
_optionalChain([this, 'access',
|
|
635
|
+
_optionalChain([this, 'access', _132 => _132.log, 'call', _133 => _133(), 'optionalAccess', _134 => _134.warn, 'call', _135 => _135(`got message from unknown connection`)]);
|
|
542
636
|
return;
|
|
543
637
|
}
|
|
544
638
|
const { publicConnection } = con;
|
|
545
|
-
_optionalChain([this, 'access',
|
|
639
|
+
_optionalChain([this, 'access', _136 => _136.log, 'call', _137 => _137(), 'optionalAccess', _138 => _138.debug, 'call', _139 => _139(
|
|
546
640
|
"got message: %o from %s",
|
|
547
641
|
message,
|
|
548
642
|
publicConnection.uuid
|
|
549
643
|
)]);
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
this.rootGroup
|
|
554
|
-
this.
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
644
|
+
try {
|
|
645
|
+
switch (message.type) {
|
|
646
|
+
case "component-message":
|
|
647
|
+
if (this.rootGroup)
|
|
648
|
+
this.rootGroup.routeMessage(
|
|
649
|
+
this.componentIDMap,
|
|
650
|
+
message,
|
|
651
|
+
publicConnection
|
|
652
|
+
);
|
|
653
|
+
break;
|
|
654
|
+
case "component-call":
|
|
655
|
+
case "component-call-upload":
|
|
656
|
+
case "component-call-download":
|
|
657
|
+
this.handleCall(connection, publicConnection, message);
|
|
658
|
+
break;
|
|
659
|
+
case "ping": {
|
|
660
|
+
connection.sendMessage({
|
|
661
|
+
type: "pong",
|
|
662
|
+
pingId: message.pingId,
|
|
663
|
+
serverTimeMillis: Date.now()
|
|
664
|
+
});
|
|
665
|
+
break;
|
|
666
|
+
}
|
|
667
|
+
}
|
|
668
|
+
} catch (cause) {
|
|
669
|
+
const error = new Error(
|
|
670
|
+
`Error handling message: ${JSON.stringify(message)}`,
|
|
671
|
+
{ cause }
|
|
672
|
+
);
|
|
673
|
+
_optionalChain([this, 'access', _140 => _140.log, 'call', _141 => _141(), 'optionalAccess', _142 => _142.error, 'call', _143 => _143(error)]);
|
|
674
|
+
}
|
|
675
|
+
}}
|
|
676
|
+
__init31() {this.onUpload = async (id, data) => {
|
|
677
|
+
const upload = this.uploads.get(id);
|
|
678
|
+
if (!upload) {
|
|
679
|
+
throw new Error(`No upload handler found for id: ${id}`);
|
|
680
|
+
}
|
|
681
|
+
await upload.handler(data);
|
|
682
|
+
this.uploads.delete(id);
|
|
683
|
+
}}
|
|
684
|
+
__init32() {this.onDownload = async (id) => {
|
|
685
|
+
const download = this.downloads.get(id);
|
|
686
|
+
if (!download) {
|
|
687
|
+
throw new Error(`No download handler found for id: ${id}`);
|
|
688
|
+
}
|
|
689
|
+
return download.handler;
|
|
690
|
+
}}
|
|
691
|
+
__init33() {this.sendNotification = (notification, filter) => {
|
|
692
|
+
for (const [connection, meta] of this.connections.entries()) {
|
|
693
|
+
if (!filter || filter(meta.publicConnection)) {
|
|
694
|
+
connection.sendMessage(notification);
|
|
569
695
|
}
|
|
570
696
|
}
|
|
571
697
|
}}
|
|
@@ -583,4 +709,4 @@ var Toolkit = (_class2 = class {
|
|
|
583
709
|
|
|
584
710
|
|
|
585
711
|
|
|
586
|
-
exports.Button =
|
|
712
|
+
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;
|