@arcanejs/toolkit 3.1.0 → 4.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/README.md +1 -1
- package/dist/backend/components/base.d.mts +1 -1
- package/dist/backend/components/base.d.ts +1 -1
- package/dist/backend/components/base.js +2 -2
- package/dist/backend/components/base.mjs +1 -1
- package/dist/backend/components/button.d.mts +1 -1
- package/dist/backend/components/button.d.ts +1 -1
- package/dist/backend/components/button.js +3 -3
- package/dist/backend/components/button.mjs +2 -2
- package/dist/backend/components/group.d.mts +1 -1
- package/dist/backend/components/group.d.ts +1 -1
- package/dist/backend/components/group.js +3 -3
- package/dist/backend/components/group.mjs +2 -2
- package/dist/backend/components/label.d.mts +1 -1
- package/dist/backend/components/label.d.ts +1 -1
- package/dist/backend/components/label.js +3 -3
- package/dist/backend/components/label.mjs +2 -2
- package/dist/backend/components/rect.d.mts +1 -1
- package/dist/backend/components/rect.d.ts +1 -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 +1 -1
- package/dist/backend/components/slider-button.d.ts +1 -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 +1 -1
- package/dist/backend/components/switch.d.ts +1 -1
- package/dist/backend/components/switch.js +3 -3
- package/dist/backend/components/switch.mjs +2 -2
- package/dist/backend/components/tabs.d.mts +1 -1
- package/dist/backend/components/tabs.d.ts +1 -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 +1 -1
- package/dist/backend/components/text-input.d.ts +1 -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 +1 -1
- package/dist/backend/components/timeline.d.ts +1 -1
- package/dist/backend/components/timeline.js +3 -3
- package/dist/backend/components/timeline.mjs +2 -2
- package/dist/{chunk-VEZGD2PG.js → chunk-3VAHVFJ3.js} +3 -3
- package/dist/{chunk-4OZ22IQU.js → chunk-4EOCJT6W.js} +3 -3
- package/dist/{chunk-W42AOMM6.mjs → chunk-6BVEU2NV.mjs} +5 -14
- package/dist/{chunk-CME7HZZK.js → chunk-6KPK5YOL.js} +3 -3
- package/dist/{chunk-NEQRLPXK.mjs → chunk-GIXAFIEY.mjs} +1 -1
- package/dist/{chunk-SGACFY53.js → chunk-HTM2L3DT.js} +19 -0
- package/dist/{chunk-RYR5I5FT.mjs → chunk-JKTEVA75.mjs} +19 -0
- package/dist/{chunk-7OX2FB6C.js → chunk-JSZMJCCH.js} +2 -2
- package/dist/{chunk-GMDJYFHD.js → chunk-LGIWNJQA.js} +3 -3
- package/dist/{chunk-7TTY7CBH.mjs → chunk-MMK3PCSS.mjs} +1 -1
- package/dist/{chunk-5D7OSUZ6.mjs → chunk-PIVARHCZ.mjs} +1 -1
- package/dist/{chunk-JFZXSCGK.mjs → chunk-PYJC5BFZ.mjs} +1 -1
- package/dist/{chunk-O5ZW6JYG.js → chunk-QT43ONN5.js} +4 -4
- package/dist/{chunk-YBBUC3QC.mjs → chunk-VJ3Q2HZJ.mjs} +1 -1
- package/dist/{chunk-6CWEURJP.js → chunk-VXNNW2KH.js} +2 -2
- package/dist/{chunk-N6IHYBZH.mjs → chunk-XMP5XJWR.mjs} +1 -1
- package/dist/{chunk-CUZSHFDP.mjs → chunk-XYFDH3E7.mjs} +1 -1
- package/dist/{chunk-K37TZB75.mjs → chunk-YN7LHBRI.mjs} +1 -1
- package/dist/{chunk-DRQVYGTI.js → chunk-Z3HEU534.js} +2 -2
- package/dist/{chunk-DG75CS7F.js → chunk-ZWYJEKZP.js} +7 -16
- package/dist/frontend/entrypoint.js +84 -31
- package/dist/frontend/entrypoint.js.map +3 -3
- package/dist/frontend/index.js +62 -19
- package/dist/frontend/index.mjs +62 -19
- package/dist/index.d.mts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +47 -14
- package/dist/index.mjs +43 -10
- package/dist/{toolkit-2w2SWHlT.d.ts → toolkit-BjYBFkG8.d.ts} +17 -6
- package/dist/{toolkit-DB8G2TaA.d.mts → toolkit-k-CCIw3V.d.mts} +17 -6
- package/package.json +5 -5
package/dist/frontend/index.js
CHANGED
|
@@ -251,6 +251,10 @@ var Stage = ({ className, renderers }) => {
|
|
|
251
251
|
);
|
|
252
252
|
const socket = _react.useRef.call(void 0, null);
|
|
253
253
|
const uuid = _react.useRef.call(void 0, null);
|
|
254
|
+
const calls = _react.useRef.call(void 0, {
|
|
255
|
+
nextId: 1,
|
|
256
|
+
calls: /* @__PURE__ */ new Map()
|
|
257
|
+
});
|
|
254
258
|
const preparedRenderers = _react.useMemo.call(void 0, () => {
|
|
255
259
|
const prepared = {};
|
|
256
260
|
for (const renderer of renderers) {
|
|
@@ -268,10 +272,36 @@ var Stage = ({ className, renderers }) => {
|
|
|
268
272
|
},
|
|
269
273
|
[preparedRenderers]
|
|
270
274
|
);
|
|
271
|
-
_react.
|
|
272
|
-
|
|
275
|
+
const handleMessage = _react.useCallback.call(void 0, (msg) => {
|
|
276
|
+
switch (msg.type) {
|
|
277
|
+
case "metadata":
|
|
278
|
+
uuid.current = msg.connectionUuid;
|
|
279
|
+
return;
|
|
280
|
+
case "tree-full":
|
|
281
|
+
setRoot(msg.root);
|
|
282
|
+
return;
|
|
283
|
+
case "tree-diff":
|
|
284
|
+
setRoot((prevRoot) => _diff.patchJson.call(void 0, prevRoot, msg.diff));
|
|
285
|
+
return;
|
|
286
|
+
case "call-response": {
|
|
287
|
+
const call2 = calls.current.calls.get(msg.requestId);
|
|
288
|
+
if (call2) {
|
|
289
|
+
calls.current.calls.delete(msg.requestId);
|
|
290
|
+
if (msg.success) {
|
|
291
|
+
call2.resolve(msg.returnValue);
|
|
292
|
+
} else {
|
|
293
|
+
call2.reject(msg.errorMessage);
|
|
294
|
+
}
|
|
295
|
+
} else {
|
|
296
|
+
console.warn(
|
|
297
|
+
`Received response for unknown call request ID ${msg.requestId}`
|
|
298
|
+
);
|
|
299
|
+
}
|
|
300
|
+
return;
|
|
301
|
+
}
|
|
302
|
+
}
|
|
273
303
|
}, []);
|
|
274
|
-
const initializeWebsocket = async () => {
|
|
304
|
+
const initializeWebsocket = _react.useCallback.call(void 0, async () => {
|
|
275
305
|
console.log("initializing websocket");
|
|
276
306
|
const wsUrl = new URL(window.location.href);
|
|
277
307
|
wsUrl.protocol = wsUrl.protocol === "https:" ? "wss:" : "ws:";
|
|
@@ -295,29 +325,42 @@ var Stage = ({ className, renderers }) => {
|
|
|
295
325
|
};
|
|
296
326
|
});
|
|
297
327
|
return ws;
|
|
298
|
-
};
|
|
299
|
-
const sendMessage = async (msg) => {
|
|
328
|
+
}, []);
|
|
329
|
+
const sendMessage = _react.useCallback.call(void 0, async (msg) => {
|
|
300
330
|
(await (socket.current || initializeWebsocket())).send(JSON.stringify(msg));
|
|
301
|
-
};
|
|
302
|
-
const
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
331
|
+
}, []);
|
|
332
|
+
const call = _react.useCallback.call(void 0,
|
|
333
|
+
async (msg) => {
|
|
334
|
+
const requestId = calls.current.nextId++;
|
|
335
|
+
const sendMsg = {
|
|
336
|
+
...msg,
|
|
337
|
+
requestId
|
|
338
|
+
};
|
|
339
|
+
const promise = new Promise(
|
|
340
|
+
(resolve, reject) => {
|
|
341
|
+
calls.current.calls.set(requestId, {
|
|
342
|
+
resolve,
|
|
343
|
+
reject
|
|
344
|
+
});
|
|
345
|
+
(socket.current || initializeWebsocket()).then(
|
|
346
|
+
(s) => s.send(JSON.stringify(sendMsg))
|
|
347
|
+
);
|
|
348
|
+
}
|
|
349
|
+
);
|
|
350
|
+
return promise;
|
|
351
|
+
},
|
|
352
|
+
[]
|
|
353
|
+
);
|
|
354
|
+
_react.useEffect.call(void 0, () => {
|
|
355
|
+
initializeWebsocket();
|
|
356
|
+
}, [initializeWebsocket]);
|
|
315
357
|
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
316
358
|
_toolkitfrontend.StageContext.Provider,
|
|
317
359
|
{
|
|
318
360
|
value: {
|
|
319
361
|
sendMessage,
|
|
320
362
|
renderComponent,
|
|
363
|
+
call,
|
|
321
364
|
get connectionUuid() {
|
|
322
365
|
if (!uuid.current) {
|
|
323
366
|
throw new Error("Unexpected missing UUID");
|
package/dist/frontend/index.mjs
CHANGED
|
@@ -251,6 +251,10 @@ var Stage = ({ className, renderers }) => {
|
|
|
251
251
|
);
|
|
252
252
|
const socket = useRef(null);
|
|
253
253
|
const uuid = useRef(null);
|
|
254
|
+
const calls = useRef({
|
|
255
|
+
nextId: 1,
|
|
256
|
+
calls: /* @__PURE__ */ new Map()
|
|
257
|
+
});
|
|
254
258
|
const preparedRenderers = useMemo(() => {
|
|
255
259
|
const prepared = {};
|
|
256
260
|
for (const renderer of renderers) {
|
|
@@ -268,10 +272,36 @@ var Stage = ({ className, renderers }) => {
|
|
|
268
272
|
},
|
|
269
273
|
[preparedRenderers]
|
|
270
274
|
);
|
|
271
|
-
|
|
272
|
-
|
|
275
|
+
const handleMessage = useCallback((msg) => {
|
|
276
|
+
switch (msg.type) {
|
|
277
|
+
case "metadata":
|
|
278
|
+
uuid.current = msg.connectionUuid;
|
|
279
|
+
return;
|
|
280
|
+
case "tree-full":
|
|
281
|
+
setRoot(msg.root);
|
|
282
|
+
return;
|
|
283
|
+
case "tree-diff":
|
|
284
|
+
setRoot((prevRoot) => patchJson(prevRoot, msg.diff));
|
|
285
|
+
return;
|
|
286
|
+
case "call-response": {
|
|
287
|
+
const call2 = calls.current.calls.get(msg.requestId);
|
|
288
|
+
if (call2) {
|
|
289
|
+
calls.current.calls.delete(msg.requestId);
|
|
290
|
+
if (msg.success) {
|
|
291
|
+
call2.resolve(msg.returnValue);
|
|
292
|
+
} else {
|
|
293
|
+
call2.reject(msg.errorMessage);
|
|
294
|
+
}
|
|
295
|
+
} else {
|
|
296
|
+
console.warn(
|
|
297
|
+
`Received response for unknown call request ID ${msg.requestId}`
|
|
298
|
+
);
|
|
299
|
+
}
|
|
300
|
+
return;
|
|
301
|
+
}
|
|
302
|
+
}
|
|
273
303
|
}, []);
|
|
274
|
-
const initializeWebsocket = async () => {
|
|
304
|
+
const initializeWebsocket = useCallback(async () => {
|
|
275
305
|
console.log("initializing websocket");
|
|
276
306
|
const wsUrl = new URL(window.location.href);
|
|
277
307
|
wsUrl.protocol = wsUrl.protocol === "https:" ? "wss:" : "ws:";
|
|
@@ -295,29 +325,42 @@ var Stage = ({ className, renderers }) => {
|
|
|
295
325
|
};
|
|
296
326
|
});
|
|
297
327
|
return ws;
|
|
298
|
-
};
|
|
299
|
-
const sendMessage = async (msg) => {
|
|
328
|
+
}, []);
|
|
329
|
+
const sendMessage = useCallback(async (msg) => {
|
|
300
330
|
(await (socket.current || initializeWebsocket())).send(JSON.stringify(msg));
|
|
301
|
-
};
|
|
302
|
-
const
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
331
|
+
}, []);
|
|
332
|
+
const call = useCallback(
|
|
333
|
+
async (msg) => {
|
|
334
|
+
const requestId = calls.current.nextId++;
|
|
335
|
+
const sendMsg = {
|
|
336
|
+
...msg,
|
|
337
|
+
requestId
|
|
338
|
+
};
|
|
339
|
+
const promise = new Promise(
|
|
340
|
+
(resolve, reject) => {
|
|
341
|
+
calls.current.calls.set(requestId, {
|
|
342
|
+
resolve,
|
|
343
|
+
reject
|
|
344
|
+
});
|
|
345
|
+
(socket.current || initializeWebsocket()).then(
|
|
346
|
+
(s) => s.send(JSON.stringify(sendMsg))
|
|
347
|
+
);
|
|
348
|
+
}
|
|
349
|
+
);
|
|
350
|
+
return promise;
|
|
351
|
+
},
|
|
352
|
+
[]
|
|
353
|
+
);
|
|
354
|
+
useEffect2(() => {
|
|
355
|
+
initializeWebsocket();
|
|
356
|
+
}, [initializeWebsocket]);
|
|
315
357
|
return /* @__PURE__ */ jsx2(
|
|
316
358
|
StageContext.Provider,
|
|
317
359
|
{
|
|
318
360
|
value: {
|
|
319
361
|
sendMessage,
|
|
320
362
|
renderComponent,
|
|
363
|
+
call,
|
|
321
364
|
get connectionUuid() {
|
|
322
365
|
if (!uuid.current) {
|
|
323
366
|
throw new Error("Unexpected missing UUID");
|
package/dist/index.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { A as AnyComponent, B as Button, G as Group, c as GroupHeader, T as Toolkit, a as ToolkitConnection, b as ToolkitOptions } from './toolkit-
|
|
1
|
+
export { A as AnyComponent, B as Button, G as Group, c as GroupHeader, T as Toolkit, a as ToolkitConnection, b as ToolkitOptions } from './toolkit-k-CCIw3V.mjs';
|
|
2
2
|
export { Label } from './backend/components/label.mjs';
|
|
3
3
|
export { Rect } from './backend/components/rect.mjs';
|
|
4
4
|
export { SliderButton } from './backend/components/slider-button.mjs';
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { A as AnyComponent, B as Button, G as Group, c as GroupHeader, T as Toolkit, a as ToolkitConnection, b as ToolkitOptions } from './toolkit-
|
|
1
|
+
export { A as AnyComponent, B as Button, G as Group, c as GroupHeader, T as Toolkit, a as ToolkitConnection, b as ToolkitOptions } from './toolkit-BjYBFkG8.js';
|
|
2
2
|
export { Label } from './backend/components/label.js';
|
|
3
3
|
export { Rect } from './backend/components/rect.js';
|
|
4
4
|
export { SliderButton } from './backend/components/slider-button.js';
|
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(); } } 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 _chunkLGIWNJQAjs = require('./chunk-LGIWNJQA.js');
|
|
5
5
|
|
|
6
6
|
|
|
7
|
-
var
|
|
7
|
+
var _chunk4EOCJT6Wjs = require('./chunk-4EOCJT6W.js');
|
|
8
8
|
|
|
9
9
|
|
|
10
|
-
var
|
|
10
|
+
var _chunkVXNNW2KHjs = require('./chunk-VXNNW2KH.js');
|
|
11
11
|
|
|
12
12
|
|
|
13
13
|
var _chunkEABM5X65js = require('./chunk-EABM5X65.js');
|
|
14
14
|
|
|
15
15
|
|
|
16
|
-
var
|
|
16
|
+
var _chunkZWYJEKZPjs = require('./chunk-ZWYJEKZP.js');
|
|
17
17
|
|
|
18
18
|
|
|
19
19
|
|
|
20
|
-
var
|
|
20
|
+
var _chunkQT43ONN5js = require('./chunk-QT43ONN5.js');
|
|
21
21
|
|
|
22
22
|
|
|
23
|
-
var
|
|
23
|
+
var _chunkZ3HEU534js = require('./chunk-Z3HEU534.js');
|
|
24
24
|
|
|
25
25
|
|
|
26
|
-
var
|
|
26
|
+
var _chunkJSZMJCCHjs = require('./chunk-JSZMJCCH.js');
|
|
27
27
|
|
|
28
28
|
|
|
29
|
-
var
|
|
29
|
+
var _chunk6KPK5YOLjs = require('./chunk-6KPK5YOL.js');
|
|
30
30
|
|
|
31
31
|
|
|
32
|
-
var
|
|
32
|
+
var _chunk3VAHVFJ3js = require('./chunk-3VAHVFJ3.js');
|
|
33
33
|
|
|
34
34
|
|
|
35
|
-
var
|
|
35
|
+
var _chunkHTM2L3DTjs = require('./chunk-HTM2L3DT.js');
|
|
36
36
|
|
|
37
37
|
|
|
38
38
|
var _chunk3RG5ZIWIjs = require('./chunk-3RG5ZIWI.js');
|
|
@@ -189,8 +189,8 @@ var Toolkit = (_class2 = class {
|
|
|
189
189
|
__init5() {this.connections = /* @__PURE__ */ new Map()}
|
|
190
190
|
__init6() {this.rootGroup = null}
|
|
191
191
|
/** @hidden */
|
|
192
|
-
__init7() {this.events = new (0,
|
|
193
|
-
constructor(options = {}) {;_class2.prototype.__init4.call(this);_class2.prototype.__init5.call(this);_class2.prototype.__init6.call(this);_class2.prototype.__init7.call(this);_class2.prototype.__init8.call(this);_class2.prototype.__init9.call(this);_class2.prototype.__init10.call(this);_class2.prototype.__init11.call(this);_class2.prototype.__init12.call(this);_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);
|
|
192
|
+
__init7() {this.events = new (0, _chunkHTM2L3DTjs.EventEmitter)()}
|
|
193
|
+
constructor(options = {}) {;_class2.prototype.__init4.call(this);_class2.prototype.__init5.call(this);_class2.prototype.__init6.call(this);_class2.prototype.__init7.call(this);_class2.prototype.__init8.call(this);_class2.prototype.__init9.call(this);_class2.prototype.__init10.call(this);_class2.prototype.__init11.call(this);_class2.prototype.__init12.call(this);_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);
|
|
194
194
|
this.options = {
|
|
195
195
|
...DEFAULT_LIGHT_DESK_OPTIONS,
|
|
196
196
|
...options
|
|
@@ -299,7 +299,37 @@ var Toolkit = (_class2 = class {
|
|
|
299
299
|
this.events.emit("closed-connection", con.publicConnection);
|
|
300
300
|
}
|
|
301
301
|
}}
|
|
302
|
-
__init17() {this.
|
|
302
|
+
__init17() {this.handleCall = async (connection, publicConnection, call) => {
|
|
303
|
+
try {
|
|
304
|
+
const rg = this.rootGroup;
|
|
305
|
+
if (rg) {
|
|
306
|
+
const returnValue = await new Promise(
|
|
307
|
+
(resolve2, reject) => rg.routeCall(this.componentIDMap, call, publicConnection, {
|
|
308
|
+
resolve: resolve2,
|
|
309
|
+
reject
|
|
310
|
+
})
|
|
311
|
+
);
|
|
312
|
+
connection.sendMessage({
|
|
313
|
+
type: "call-response",
|
|
314
|
+
namespace: call.namespace,
|
|
315
|
+
requestId: call.requestId,
|
|
316
|
+
success: true,
|
|
317
|
+
returnValue
|
|
318
|
+
});
|
|
319
|
+
} else {
|
|
320
|
+
throw new Error("No root group set");
|
|
321
|
+
}
|
|
322
|
+
} catch (err) {
|
|
323
|
+
connection.sendMessage({
|
|
324
|
+
type: "call-response",
|
|
325
|
+
namespace: call.namespace,
|
|
326
|
+
requestId: call.requestId,
|
|
327
|
+
success: false,
|
|
328
|
+
errorMessage: `${err}`
|
|
329
|
+
});
|
|
330
|
+
}
|
|
331
|
+
}}
|
|
332
|
+
__init18() {this.onMessage = (connection, message) => {
|
|
303
333
|
const con = this.connections.get(connection);
|
|
304
334
|
if (!con) {
|
|
305
335
|
_optionalChain([this, 'access', _62 => _62.log, 'call', _63 => _63(), 'optionalAccess', _64 => _64.warn, 'call', _65 => _65(`got message from unknown connection`)]);
|
|
@@ -320,6 +350,9 @@ var Toolkit = (_class2 = class {
|
|
|
320
350
|
publicConnection
|
|
321
351
|
);
|
|
322
352
|
break;
|
|
353
|
+
case "component-call":
|
|
354
|
+
this.handleCall(connection, publicConnection, message);
|
|
355
|
+
break;
|
|
323
356
|
}
|
|
324
357
|
}}
|
|
325
358
|
}, _class2);
|
|
@@ -336,4 +369,4 @@ var Toolkit = (_class2 = class {
|
|
|
336
369
|
|
|
337
370
|
|
|
338
371
|
|
|
339
|
-
exports.Button =
|
|
372
|
+
exports.Button = _chunkZWYJEKZPjs.Button; exports.Group = _chunkQT43ONN5js.Group; exports.GroupHeader = _chunkQT43ONN5js.GroupHeader; exports.Label = _chunkZ3HEU534js.Label; exports.Rect = _chunkJSZMJCCHjs.Rect; exports.SliderButton = _chunk6KPK5YOLjs.SliderButton; exports.Switch = _chunk3VAHVFJ3js.Switch; exports.Tab = _chunkLGIWNJQAjs.Tab; exports.Tabs = _chunkLGIWNJQAjs.Tabs; exports.TextInput = _chunk4EOCJT6Wjs.TextInput; exports.Timeline = _chunkVXNNW2KHjs.Timeline; exports.Toolkit = Toolkit;
|
package/dist/index.mjs
CHANGED
|
@@ -1,38 +1,38 @@
|
|
|
1
1
|
import {
|
|
2
2
|
Tab,
|
|
3
3
|
Tabs
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-MMK3PCSS.mjs";
|
|
5
5
|
import {
|
|
6
6
|
TextInput
|
|
7
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-VJ3Q2HZJ.mjs";
|
|
8
8
|
import {
|
|
9
9
|
Timeline
|
|
10
|
-
} from "./chunk-
|
|
10
|
+
} from "./chunk-YN7LHBRI.mjs";
|
|
11
11
|
import {
|
|
12
12
|
IDMap
|
|
13
13
|
} from "./chunk-RGHJEMWG.mjs";
|
|
14
14
|
import {
|
|
15
15
|
Button
|
|
16
|
-
} from "./chunk-
|
|
16
|
+
} from "./chunk-6BVEU2NV.mjs";
|
|
17
17
|
import {
|
|
18
18
|
Group,
|
|
19
19
|
GroupHeader
|
|
20
|
-
} from "./chunk-
|
|
20
|
+
} from "./chunk-PIVARHCZ.mjs";
|
|
21
21
|
import {
|
|
22
22
|
Label
|
|
23
|
-
} from "./chunk-
|
|
23
|
+
} from "./chunk-XYFDH3E7.mjs";
|
|
24
24
|
import {
|
|
25
25
|
Rect
|
|
26
|
-
} from "./chunk-
|
|
26
|
+
} from "./chunk-XMP5XJWR.mjs";
|
|
27
27
|
import {
|
|
28
28
|
SliderButton
|
|
29
|
-
} from "./chunk-
|
|
29
|
+
} from "./chunk-PYJC5BFZ.mjs";
|
|
30
30
|
import {
|
|
31
31
|
Switch
|
|
32
|
-
} from "./chunk-
|
|
32
|
+
} from "./chunk-GIXAFIEY.mjs";
|
|
33
33
|
import {
|
|
34
34
|
EventEmitter
|
|
35
|
-
} from "./chunk-
|
|
35
|
+
} from "./chunk-JKTEVA75.mjs";
|
|
36
36
|
import {
|
|
37
37
|
__require
|
|
38
38
|
} from "./chunk-Y6FXYEAI.mjs";
|
|
@@ -299,6 +299,36 @@ var Toolkit = class {
|
|
|
299
299
|
this.events.emit("closed-connection", con.publicConnection);
|
|
300
300
|
}
|
|
301
301
|
};
|
|
302
|
+
handleCall = async (connection, publicConnection, call) => {
|
|
303
|
+
try {
|
|
304
|
+
const rg = this.rootGroup;
|
|
305
|
+
if (rg) {
|
|
306
|
+
const returnValue = await new Promise(
|
|
307
|
+
(resolve2, reject) => rg.routeCall(this.componentIDMap, call, publicConnection, {
|
|
308
|
+
resolve: resolve2,
|
|
309
|
+
reject
|
|
310
|
+
})
|
|
311
|
+
);
|
|
312
|
+
connection.sendMessage({
|
|
313
|
+
type: "call-response",
|
|
314
|
+
namespace: call.namespace,
|
|
315
|
+
requestId: call.requestId,
|
|
316
|
+
success: true,
|
|
317
|
+
returnValue
|
|
318
|
+
});
|
|
319
|
+
} else {
|
|
320
|
+
throw new Error("No root group set");
|
|
321
|
+
}
|
|
322
|
+
} catch (err) {
|
|
323
|
+
connection.sendMessage({
|
|
324
|
+
type: "call-response",
|
|
325
|
+
namespace: call.namespace,
|
|
326
|
+
requestId: call.requestId,
|
|
327
|
+
success: false,
|
|
328
|
+
errorMessage: `${err}`
|
|
329
|
+
});
|
|
330
|
+
}
|
|
331
|
+
};
|
|
302
332
|
onMessage = (connection, message) => {
|
|
303
333
|
const con = this.connections.get(connection);
|
|
304
334
|
if (!con) {
|
|
@@ -320,6 +350,9 @@ var Toolkit = class {
|
|
|
320
350
|
publicConnection
|
|
321
351
|
);
|
|
322
352
|
break;
|
|
353
|
+
case "component-call":
|
|
354
|
+
this.handleCall(connection, publicConnection, message);
|
|
355
|
+
break;
|
|
323
356
|
}
|
|
324
357
|
};
|
|
325
358
|
};
|
|
@@ -4,7 +4,7 @@ import _ from 'lodash';
|
|
|
4
4
|
import * as http from 'http';
|
|
5
5
|
import { Application } from 'express';
|
|
6
6
|
import { WebSocket } from 'ws';
|
|
7
|
-
import { ClientMessage, ServerMessage, BaseComponentProto, AnyClientComponentMessage } from '@arcanejs/protocol';
|
|
7
|
+
import { ClientMessage, ServerMessage, BaseComponentProto, AnyClientComponentMessage, AnyClientComponentCall, ReturnForPair } from '@arcanejs/protocol';
|
|
8
8
|
import * as proto from '@arcanejs/protocol/core';
|
|
9
9
|
import { GroupComponentStyle } from '@arcanejs/protocol/styles';
|
|
10
10
|
import { I as IDMap } from './id-map-DxQ3_gyA.js';
|
|
@@ -88,7 +88,7 @@ type InitializationOptions =
|
|
|
88
88
|
setup: (server: Server) => void;
|
|
89
89
|
};
|
|
90
90
|
|
|
91
|
-
declare abstract class Base<Namespace extends string, Proto extends BaseComponentProto<Namespace>, Props> {
|
|
91
|
+
declare abstract class Base<Namespace extends string, Proto extends BaseComponentProto<Namespace, string>, Props, CallPairs = any, CallActions extends string & keyof CallPairs = any> {
|
|
92
92
|
/** @hidden */
|
|
93
93
|
private parent;
|
|
94
94
|
/** @hidden */
|
|
@@ -117,16 +117,22 @@ declare abstract class Base<Namespace extends string, Proto extends BaseComponen
|
|
|
117
117
|
abstract getProtoInfo(idMap: IDMap): Proto;
|
|
118
118
|
/** @hidden */
|
|
119
119
|
handleMessage(_message: AnyClientComponentMessage, _connection: ToolkitConnection): void;
|
|
120
|
+
/** @hidden */
|
|
121
|
+
handleCall(_call: AnyClientComponentCall, _connection: ToolkitConnection): Promise<ReturnForPair<CallPairs, CallActions>>;
|
|
120
122
|
routeMessage(_idMap: IDMap, _message: AnyClientComponentMessage, _connection: ToolkitConnection): void;
|
|
123
|
+
routeCall(_idMap: IDMap, _call: AnyClientComponentCall, _connection: ToolkitConnection, _callbacks: {
|
|
124
|
+
resolve: (result: unknown) => void;
|
|
125
|
+
reject: (error: unknown) => void;
|
|
126
|
+
}): void;
|
|
121
127
|
}
|
|
122
|
-
type AnyComponent = Base<string, BaseComponentProto<string>, any>;
|
|
128
|
+
type AnyComponent = Base<string, BaseComponentProto<string, string>, any>;
|
|
123
129
|
/** @hidden */
|
|
124
130
|
interface Parent {
|
|
125
131
|
updateTree(): void;
|
|
126
132
|
removeChild(component: AnyComponent): void;
|
|
127
133
|
log(): Logger | null;
|
|
128
134
|
}
|
|
129
|
-
declare abstract class BaseParent<Namespace extends string, Proto extends BaseComponentProto<Namespace>, T> extends Base<Namespace, Proto, T> implements Parent {
|
|
135
|
+
declare abstract class BaseParent<Namespace extends string, Proto extends BaseComponentProto<Namespace, string>, T, CallPairs = any, CallActions extends string & keyof CallPairs = any> extends Base<Namespace, Proto, T, CallPairs, CallActions> implements Parent {
|
|
130
136
|
/** @hidden */
|
|
131
137
|
private children;
|
|
132
138
|
abstract validateChildren(children: AnyComponent[]): void;
|
|
@@ -145,6 +151,10 @@ declare abstract class BaseParent<Namespace extends string, Proto extends BaseCo
|
|
|
145
151
|
* @hidden
|
|
146
152
|
*/
|
|
147
153
|
routeMessage(idMap: IDMap, message: AnyClientComponentMessage, connection: ToolkitConnection): void;
|
|
154
|
+
routeCall(idMap: IDMap, call: AnyClientComponentCall, connection: ToolkitConnection, callbacks: {
|
|
155
|
+
resolve: (result: unknown) => void;
|
|
156
|
+
reject: (error: unknown) => void;
|
|
157
|
+
}): Promise<void>;
|
|
148
158
|
insertBefore(child: AnyComponent, beforeChild: AnyComponent): void;
|
|
149
159
|
}
|
|
150
160
|
interface Listenable<Map extends Record<string, (...args: any[]) => void>> {
|
|
@@ -174,7 +184,7 @@ type InternalProps$1 = {
|
|
|
174
184
|
onClick?: Events$2['click'] | null;
|
|
175
185
|
};
|
|
176
186
|
type Props$1 = Partial<InternalProps$1>;
|
|
177
|
-
declare class Button extends Base<proto.CoreNamespace, proto.
|
|
187
|
+
declare class Button extends Base<proto.CoreNamespace, proto.ButtonComponent, InternalProps$1, proto.CoreComponentCalls, 'press'> implements Listenable<Events$2> {
|
|
178
188
|
/** @hidden */
|
|
179
189
|
private readonly events;
|
|
180
190
|
constructor(props?: Props$1);
|
|
@@ -186,7 +196,7 @@ declare class Button extends Base<proto.CoreNamespace, proto.CoreComponent, Inte
|
|
|
186
196
|
/** @hidden */
|
|
187
197
|
getProtoInfo: (idMap: IDMap) => proto.ButtonComponent;
|
|
188
198
|
/** @hidden */
|
|
189
|
-
|
|
199
|
+
handleCall: (call: AnyClientComponentCall, connection: ToolkitConnection) => Promise<true>;
|
|
190
200
|
}
|
|
191
201
|
|
|
192
202
|
type Label = (proto.GroupComponent['labels'] & Array<unknown>)[number];
|
|
@@ -263,6 +273,7 @@ declare class Toolkit implements Parent, Listenable<Events> {
|
|
|
263
273
|
removeChild: (component: AnyComponent) => void;
|
|
264
274
|
private onNewConnection;
|
|
265
275
|
private onClosedConnection;
|
|
276
|
+
private handleCall;
|
|
266
277
|
private onMessage;
|
|
267
278
|
}
|
|
268
279
|
|
|
@@ -4,7 +4,7 @@ import _ from 'lodash';
|
|
|
4
4
|
import * as http from 'http';
|
|
5
5
|
import { Application } from 'express';
|
|
6
6
|
import { WebSocket } from 'ws';
|
|
7
|
-
import { ClientMessage, ServerMessage, BaseComponentProto, AnyClientComponentMessage } from '@arcanejs/protocol';
|
|
7
|
+
import { ClientMessage, ServerMessage, BaseComponentProto, AnyClientComponentMessage, AnyClientComponentCall, ReturnForPair } from '@arcanejs/protocol';
|
|
8
8
|
import * as proto from '@arcanejs/protocol/core';
|
|
9
9
|
import { GroupComponentStyle } from '@arcanejs/protocol/styles';
|
|
10
10
|
import { I as IDMap } from './id-map-DxQ3_gyA.mjs';
|
|
@@ -88,7 +88,7 @@ type InitializationOptions =
|
|
|
88
88
|
setup: (server: Server) => void;
|
|
89
89
|
};
|
|
90
90
|
|
|
91
|
-
declare abstract class Base<Namespace extends string, Proto extends BaseComponentProto<Namespace>, Props> {
|
|
91
|
+
declare abstract class Base<Namespace extends string, Proto extends BaseComponentProto<Namespace, string>, Props, CallPairs = any, CallActions extends string & keyof CallPairs = any> {
|
|
92
92
|
/** @hidden */
|
|
93
93
|
private parent;
|
|
94
94
|
/** @hidden */
|
|
@@ -117,16 +117,22 @@ declare abstract class Base<Namespace extends string, Proto extends BaseComponen
|
|
|
117
117
|
abstract getProtoInfo(idMap: IDMap): Proto;
|
|
118
118
|
/** @hidden */
|
|
119
119
|
handleMessage(_message: AnyClientComponentMessage, _connection: ToolkitConnection): void;
|
|
120
|
+
/** @hidden */
|
|
121
|
+
handleCall(_call: AnyClientComponentCall, _connection: ToolkitConnection): Promise<ReturnForPair<CallPairs, CallActions>>;
|
|
120
122
|
routeMessage(_idMap: IDMap, _message: AnyClientComponentMessage, _connection: ToolkitConnection): void;
|
|
123
|
+
routeCall(_idMap: IDMap, _call: AnyClientComponentCall, _connection: ToolkitConnection, _callbacks: {
|
|
124
|
+
resolve: (result: unknown) => void;
|
|
125
|
+
reject: (error: unknown) => void;
|
|
126
|
+
}): void;
|
|
121
127
|
}
|
|
122
|
-
type AnyComponent = Base<string, BaseComponentProto<string>, any>;
|
|
128
|
+
type AnyComponent = Base<string, BaseComponentProto<string, string>, any>;
|
|
123
129
|
/** @hidden */
|
|
124
130
|
interface Parent {
|
|
125
131
|
updateTree(): void;
|
|
126
132
|
removeChild(component: AnyComponent): void;
|
|
127
133
|
log(): Logger | null;
|
|
128
134
|
}
|
|
129
|
-
declare abstract class BaseParent<Namespace extends string, Proto extends BaseComponentProto<Namespace>, T> extends Base<Namespace, Proto, T> implements Parent {
|
|
135
|
+
declare abstract class BaseParent<Namespace extends string, Proto extends BaseComponentProto<Namespace, string>, T, CallPairs = any, CallActions extends string & keyof CallPairs = any> extends Base<Namespace, Proto, T, CallPairs, CallActions> implements Parent {
|
|
130
136
|
/** @hidden */
|
|
131
137
|
private children;
|
|
132
138
|
abstract validateChildren(children: AnyComponent[]): void;
|
|
@@ -145,6 +151,10 @@ declare abstract class BaseParent<Namespace extends string, Proto extends BaseCo
|
|
|
145
151
|
* @hidden
|
|
146
152
|
*/
|
|
147
153
|
routeMessage(idMap: IDMap, message: AnyClientComponentMessage, connection: ToolkitConnection): void;
|
|
154
|
+
routeCall(idMap: IDMap, call: AnyClientComponentCall, connection: ToolkitConnection, callbacks: {
|
|
155
|
+
resolve: (result: unknown) => void;
|
|
156
|
+
reject: (error: unknown) => void;
|
|
157
|
+
}): Promise<void>;
|
|
148
158
|
insertBefore(child: AnyComponent, beforeChild: AnyComponent): void;
|
|
149
159
|
}
|
|
150
160
|
interface Listenable<Map extends Record<string, (...args: any[]) => void>> {
|
|
@@ -174,7 +184,7 @@ type InternalProps$1 = {
|
|
|
174
184
|
onClick?: Events$2['click'] | null;
|
|
175
185
|
};
|
|
176
186
|
type Props$1 = Partial<InternalProps$1>;
|
|
177
|
-
declare class Button extends Base<proto.CoreNamespace, proto.
|
|
187
|
+
declare class Button extends Base<proto.CoreNamespace, proto.ButtonComponent, InternalProps$1, proto.CoreComponentCalls, 'press'> implements Listenable<Events$2> {
|
|
178
188
|
/** @hidden */
|
|
179
189
|
private readonly events;
|
|
180
190
|
constructor(props?: Props$1);
|
|
@@ -186,7 +196,7 @@ declare class Button extends Base<proto.CoreNamespace, proto.CoreComponent, Inte
|
|
|
186
196
|
/** @hidden */
|
|
187
197
|
getProtoInfo: (idMap: IDMap) => proto.ButtonComponent;
|
|
188
198
|
/** @hidden */
|
|
189
|
-
|
|
199
|
+
handleCall: (call: AnyClientComponentCall, connection: ToolkitConnection) => Promise<true>;
|
|
190
200
|
}
|
|
191
201
|
|
|
192
202
|
type Label = (proto.GroupComponent['labels'] & Array<unknown>)[number];
|
|
@@ -263,6 +273,7 @@ declare class Toolkit implements Parent, Listenable<Events> {
|
|
|
263
273
|
removeChild: (component: AnyComponent) => void;
|
|
264
274
|
private onNewConnection;
|
|
265
275
|
private onClosedConnection;
|
|
276
|
+
private handleCall;
|
|
266
277
|
private onMessage;
|
|
267
278
|
}
|
|
268
279
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@arcanejs/toolkit",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "4.0.0",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "Build web-accessible control interfaces for your long-running Node.js processes",
|
|
6
6
|
"keywords": [
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
},
|
|
15
15
|
"repository": {
|
|
16
16
|
"type": "git",
|
|
17
|
-
"url": "https://github.com/
|
|
17
|
+
"url": "https://github.com/ArcaneWizards/arcanejs.git"
|
|
18
18
|
},
|
|
19
19
|
"exports": {
|
|
20
20
|
".": {
|
|
@@ -115,7 +115,7 @@
|
|
|
115
115
|
"tsup": "^8.1.0",
|
|
116
116
|
"typescript": "^5.3.3",
|
|
117
117
|
"@arcanejs/eslint-config": "^0.0.0",
|
|
118
|
-
"@arcanejs/toolkit-frontend": "^0.
|
|
118
|
+
"@arcanejs/toolkit-frontend": "^0.7.0",
|
|
119
119
|
"@arcanejs/typescript-config": "^0.0.0"
|
|
120
120
|
},
|
|
121
121
|
"dependencies": {
|
|
@@ -126,13 +126,13 @@
|
|
|
126
126
|
"uuid": "^11.0.3",
|
|
127
127
|
"ws": "^8.18.0",
|
|
128
128
|
"@arcanejs/diff": "^0.5.1",
|
|
129
|
-
"@arcanejs/protocol": "^0.
|
|
129
|
+
"@arcanejs/protocol": "^0.7.0"
|
|
130
130
|
},
|
|
131
131
|
"peerDependencies": {
|
|
132
132
|
"react": "^18",
|
|
133
133
|
"react-dom": "18.3.1",
|
|
134
134
|
"styled-components": "^6.1.13",
|
|
135
|
-
"@arcanejs/toolkit-frontend": "^0.
|
|
135
|
+
"@arcanejs/toolkit-frontend": "^0.7.0"
|
|
136
136
|
},
|
|
137
137
|
"peerDependenciesMeta": {
|
|
138
138
|
"@arcanejs/toolkit-frontend": {
|