@arcanejs/toolkit 0.2.1 → 0.2.2
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.js +10 -188
- package/dist/backend/components/button.js +5 -165
- package/dist/backend/components/group.js +7 -281
- package/dist/backend/components/label.js +5 -102
- package/dist/backend/components/rect.js +5 -102
- package/dist/backend/components/slider-button.js +5 -158
- package/dist/backend/components/switch.js +5 -141
- package/dist/backend/components/tabs.js +7 -206
- package/dist/backend/components/text-input.js +5 -143
- package/dist/backend/components/timeline.js +5 -106
- package/dist/backend/util/index.js +5 -41
- package/dist/chunk-3RG5ZIWI.js +10 -0
- package/dist/chunk-EABM5X65.js +17 -0
- package/dist/chunk-K24YPCR5.js +104 -0
- package/dist/chunk-KVJU3EAD.js +66 -0
- package/dist/chunk-M6EFK4GP.js +42 -0
- package/dist/chunk-MDFDWKGW.js +44 -0
- package/dist/chunk-OEIGZ3NQ.js +33 -0
- package/dist/chunk-P43QUQ4T.js +29 -0
- package/dist/chunk-RGIB65TI.js +29 -0
- package/dist/chunk-RJS32OOA.js +55 -0
- package/dist/chunk-T2PJEXYO.js +59 -0
- package/dist/chunk-UBWCVW2U.js +163 -0
- package/dist/index.js +83 -657
- package/package.json +5 -5
package/dist/index.js
CHANGED
|
@@ -1,53 +1,43 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
var
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
var
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
var
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
Rect: () => Rect,
|
|
38
|
-
SliderButton: () => SliderButton,
|
|
39
|
-
Switch: () => Switch,
|
|
40
|
-
Tab: () => Tab,
|
|
41
|
-
Tabs: () => Tabs,
|
|
42
|
-
TextInput: () => TextInput,
|
|
43
|
-
Timeline: () => Timeline,
|
|
44
|
-
Toolkit: () => Toolkit
|
|
45
|
-
});
|
|
46
|
-
module.exports = __toCommonJS(src_exports);
|
|
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
|
+
|
|
3
|
+
|
|
4
|
+
var _chunkRJS32OOAjs = require('./chunk-RJS32OOA.js');
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
var _chunkMDFDWKGWjs = require('./chunk-MDFDWKGW.js');
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
var _chunkOEIGZ3NQjs = require('./chunk-OEIGZ3NQ.js');
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
var _chunkEABM5X65js = require('./chunk-EABM5X65.js');
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
var _chunkKVJU3EADjs = require('./chunk-KVJU3EAD.js');
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
var _chunkK24YPCR5js = require('./chunk-K24YPCR5.js');
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
var _chunkP43QUQ4Tjs = require('./chunk-P43QUQ4T.js');
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
var _chunkRGIB65TIjs = require('./chunk-RGIB65TI.js');
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
var _chunkT2PJEXYOjs = require('./chunk-T2PJEXYO.js');
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
var _chunkM6EFK4GPjs = require('./chunk-M6EFK4GP.js');
|
|
33
|
+
require('./chunk-UBWCVW2U.js');
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
var _chunk3RG5ZIWIjs = require('./chunk-3RG5ZIWI.js');
|
|
47
37
|
|
|
48
38
|
// src/backend/toolkit.ts
|
|
49
|
-
var
|
|
50
|
-
var
|
|
39
|
+
var _lodash = require('lodash'); var _lodash2 = _interopRequireDefault(_lodash);
|
|
40
|
+
var _diff = require('@arcanejs/diff/diff');
|
|
51
41
|
|
|
52
42
|
// src/backend/options.ts
|
|
53
43
|
var DEFAULT_LIGHT_DESK_OPTIONS = {
|
|
@@ -55,8 +45,8 @@ var DEFAULT_LIGHT_DESK_OPTIONS = {
|
|
|
55
45
|
};
|
|
56
46
|
|
|
57
47
|
// src/backend/server.ts
|
|
58
|
-
var
|
|
59
|
-
var
|
|
48
|
+
var _fs = require('fs'); var fs = _interopRequireWildcard(_fs);
|
|
49
|
+
var _path = require('path'); var path = _interopRequireWildcard(_path);
|
|
60
50
|
|
|
61
51
|
// src/shared/static.ts
|
|
62
52
|
var FONTS = {
|
|
@@ -85,19 +75,19 @@ var STATIC_FILES = {
|
|
|
85
75
|
contentType: "text/plain"
|
|
86
76
|
},
|
|
87
77
|
[`/${FONTS.materialSymbolsOutlined}`]: {
|
|
88
|
-
path:
|
|
78
|
+
path: _chunk3RG5ZIWIjs.__require.resolve("material-symbols/material-symbols-outlined.woff2"),
|
|
89
79
|
contentType: "font/woff2"
|
|
90
80
|
}
|
|
91
81
|
};
|
|
92
82
|
console.log("STATIC_FILES", STATIC_FILES);
|
|
93
|
-
var Server = class {
|
|
94
|
-
constructor(options, onNewConnection, onClosedConnection, onMessage) {
|
|
83
|
+
var Server = (_class = class {
|
|
84
|
+
constructor(options, onNewConnection, onClosedConnection, onMessage) {;_class.prototype.__init.call(this);_class.prototype.__init2.call(this);_class.prototype.__init3.call(this);
|
|
95
85
|
this.options = options;
|
|
96
86
|
this.onNewConnection = onNewConnection;
|
|
97
87
|
this.onClosedConnection = onClosedConnection;
|
|
98
88
|
this.onMessage = onMessage;
|
|
99
89
|
}
|
|
100
|
-
handleHttpRequest = async (req, res) => {
|
|
90
|
+
__init() {this.handleHttpRequest = async (req, res) => {
|
|
101
91
|
console.log("handleHttpRequest", req.url);
|
|
102
92
|
if (req.url === this.options.path) {
|
|
103
93
|
const content = `
|
|
@@ -133,8 +123,8 @@ var Server = class {
|
|
|
133
123
|
}
|
|
134
124
|
res.writeHead(404, { "Content-Type": "text/plain" });
|
|
135
125
|
res.end("not found", "utf-8");
|
|
136
|
-
}
|
|
137
|
-
sendStaticFile = (file, response, contentType) => {
|
|
126
|
+
}}
|
|
127
|
+
__init2() {this.sendStaticFile = (file, response, contentType) => {
|
|
138
128
|
fs.readFile(file, function(error, content) {
|
|
139
129
|
if (error) {
|
|
140
130
|
if (error.code === "ENOENT") {
|
|
@@ -150,8 +140,8 @@ var Server = class {
|
|
|
150
140
|
response.end(content, "utf-8");
|
|
151
141
|
}
|
|
152
142
|
});
|
|
153
|
-
}
|
|
154
|
-
handleWsConnection = (ws) => {
|
|
143
|
+
}}
|
|
144
|
+
__init3() {this.handleWsConnection = (ws) => {
|
|
155
145
|
const connection = {
|
|
156
146
|
sendMessage: (msg) => ws.send(JSON.stringify(msg))
|
|
157
147
|
};
|
|
@@ -162,36 +152,22 @@ var Server = class {
|
|
|
162
152
|
(msg) => this.onMessage(connection, JSON.parse(msg.toString()))
|
|
163
153
|
);
|
|
164
154
|
ws.on("close", () => this.onClosedConnection(connection));
|
|
165
|
-
}
|
|
166
|
-
};
|
|
167
|
-
|
|
168
|
-
// src/backend/util/id-map.ts
|
|
169
|
-
var IDMap = class {
|
|
170
|
-
idMap = /* @__PURE__ */ new WeakMap();
|
|
171
|
-
nextId = 0;
|
|
172
|
-
getId(object) {
|
|
173
|
-
let i = this.idMap.get(object);
|
|
174
|
-
if (i === void 0) {
|
|
175
|
-
i = this.nextId++;
|
|
176
|
-
this.idMap.set(object, i);
|
|
177
|
-
}
|
|
178
|
-
return i;
|
|
179
|
-
}
|
|
180
|
-
};
|
|
155
|
+
}}
|
|
156
|
+
}, _class);
|
|
181
157
|
|
|
182
158
|
// src/backend/toolkit.ts
|
|
183
|
-
var
|
|
184
|
-
var
|
|
185
|
-
console.log(
|
|
186
|
-
var Toolkit = class {
|
|
187
|
-
|
|
159
|
+
var _ws = require('ws');
|
|
160
|
+
var _http = require('http');
|
|
161
|
+
console.log(_diff.diffJson);
|
|
162
|
+
var Toolkit = (_class2 = class {
|
|
163
|
+
|
|
188
164
|
/**
|
|
189
165
|
* Mapping from components to unique IDs that identify them
|
|
190
166
|
*/
|
|
191
|
-
componentIDMap = new IDMap()
|
|
192
|
-
connections = /* @__PURE__ */ new Map()
|
|
193
|
-
rootGroup = null
|
|
194
|
-
constructor(options = {}) {
|
|
167
|
+
__init4() {this.componentIDMap = new (0, _chunkEABM5X65js.IDMap)()}
|
|
168
|
+
__init5() {this.connections = /* @__PURE__ */ new Map()}
|
|
169
|
+
__init6() {this.rootGroup = null}
|
|
170
|
+
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);
|
|
195
171
|
this.options = {
|
|
196
172
|
...DEFAULT_LIGHT_DESK_OPTIONS,
|
|
197
173
|
...options
|
|
@@ -202,7 +178,7 @@ var Toolkit = class {
|
|
|
202
178
|
);
|
|
203
179
|
}
|
|
204
180
|
}
|
|
205
|
-
start = (opts) => {
|
|
181
|
+
__init7() {this.start = (opts) => {
|
|
206
182
|
const server = new Server(
|
|
207
183
|
this.options,
|
|
208
184
|
this.onNewConnection,
|
|
@@ -210,8 +186,8 @@ var Toolkit = class {
|
|
|
210
186
|
this.onMessage
|
|
211
187
|
);
|
|
212
188
|
if (opts.mode === "automatic") {
|
|
213
|
-
const httpServer = (0,
|
|
214
|
-
const wss = new
|
|
189
|
+
const httpServer = _http.createServer.call(void 0, server.handleHttpRequest);
|
|
190
|
+
const wss = new (0, _ws.WebSocketServer)({
|
|
215
191
|
server: httpServer
|
|
216
192
|
});
|
|
217
193
|
wss.on("connection", server.handleWsConnection);
|
|
@@ -221,7 +197,7 @@ var Toolkit = class {
|
|
|
221
197
|
);
|
|
222
198
|
});
|
|
223
199
|
} else if (opts.mode === "express") {
|
|
224
|
-
const wss = new
|
|
200
|
+
const wss = new (0, _ws.WebSocketServer)({
|
|
225
201
|
server: opts.server
|
|
226
202
|
});
|
|
227
203
|
wss.on("connection", server.handleWsConnection);
|
|
@@ -231,15 +207,15 @@ var Toolkit = class {
|
|
|
231
207
|
} else {
|
|
232
208
|
throw new Error(`Unsupported mode`);
|
|
233
209
|
}
|
|
234
|
-
}
|
|
235
|
-
setRoot = (group) => {
|
|
210
|
+
}}
|
|
211
|
+
__init8() {this.setRoot = (group) => {
|
|
236
212
|
if (this.rootGroup) {
|
|
237
213
|
throw new Error("Can only set root group once");
|
|
238
214
|
}
|
|
239
215
|
this.rootGroup = group;
|
|
240
216
|
this.rootGroup.setParent(this);
|
|
241
|
-
}
|
|
242
|
-
updateTree =
|
|
217
|
+
}}
|
|
218
|
+
__init9() {this.updateTree = _lodash2.default.throttle(
|
|
243
219
|
() => {
|
|
244
220
|
setImmediate(() => {
|
|
245
221
|
if (!this.rootGroup) return;
|
|
@@ -247,7 +223,7 @@ var Toolkit = class {
|
|
|
247
223
|
for (const [connection, meta] of this.connections.entries()) {
|
|
248
224
|
connection.sendMessage({
|
|
249
225
|
type: "tree-diff",
|
|
250
|
-
diff: (0,
|
|
226
|
+
diff: _diff.diffJson.call(void 0, meta.lastTreeSent, root)
|
|
251
227
|
});
|
|
252
228
|
meta.lastTreeSent = root;
|
|
253
229
|
}
|
|
@@ -255,15 +231,15 @@ var Toolkit = class {
|
|
|
255
231
|
},
|
|
256
232
|
10,
|
|
257
233
|
{ leading: true, trailing: true }
|
|
258
|
-
)
|
|
259
|
-
removeChild = (component) => {
|
|
234
|
+
)}
|
|
235
|
+
__init10() {this.removeChild = (component) => {
|
|
260
236
|
if (this.rootGroup === component) {
|
|
261
237
|
this.rootGroup = null;
|
|
262
238
|
component.setParent(null);
|
|
263
239
|
}
|
|
264
|
-
}
|
|
265
|
-
onNewConnection = (connection) => {
|
|
266
|
-
const lastTreeSent = this.rootGroup
|
|
240
|
+
}}
|
|
241
|
+
__init11() {this.onNewConnection = (connection) => {
|
|
242
|
+
const lastTreeSent = _nullishCoalesce(_optionalChain([this, 'access', _5 => _5.rootGroup, 'optionalAccess', _6 => _6.getProtoInfo, 'call', _7 => _7(this.componentIDMap)]), () => ( void 0));
|
|
267
243
|
this.connections.set(connection, { lastTreeSent });
|
|
268
244
|
if (lastTreeSent) {
|
|
269
245
|
connection.sendMessage({
|
|
@@ -271,12 +247,12 @@ var Toolkit = class {
|
|
|
271
247
|
root: lastTreeSent
|
|
272
248
|
});
|
|
273
249
|
}
|
|
274
|
-
}
|
|
275
|
-
onClosedConnection = (connection) => {
|
|
250
|
+
}}
|
|
251
|
+
__init12() {this.onClosedConnection = (connection) => {
|
|
276
252
|
console.log("removing connection");
|
|
277
253
|
this.connections.delete(connection);
|
|
278
|
-
}
|
|
279
|
-
onMessage = (_connection, message) => {
|
|
254
|
+
}}
|
|
255
|
+
__init13() {this.onMessage = (_connection, message) => {
|
|
280
256
|
console.log("got message", message);
|
|
281
257
|
switch (message.type) {
|
|
282
258
|
case "component-message":
|
|
@@ -284,569 +260,19 @@ var Toolkit = class {
|
|
|
284
260
|
this.rootGroup.routeMessage(this.componentIDMap, message);
|
|
285
261
|
break;
|
|
286
262
|
}
|
|
287
|
-
}
|
|
288
|
-
};
|
|
263
|
+
}}
|
|
264
|
+
}, _class2);
|
|
289
265
|
|
|
290
|
-
// src/backend/components/base.ts
|
|
291
|
-
var Base = class {
|
|
292
|
-
/** @hidden */
|
|
293
|
-
parent = null;
|
|
294
|
-
/** @hidden */
|
|
295
|
-
defaultProps;
|
|
296
|
-
/** @hidden */
|
|
297
|
-
_props;
|
|
298
|
-
constructor(defaultProps, props) {
|
|
299
|
-
this.defaultProps = defaultProps;
|
|
300
|
-
this._props = Object.freeze({
|
|
301
|
-
...defaultProps,
|
|
302
|
-
...props
|
|
303
|
-
});
|
|
304
|
-
}
|
|
305
|
-
get props() {
|
|
306
|
-
return this._props;
|
|
307
|
-
}
|
|
308
|
-
set props(props) {
|
|
309
|
-
this.setProps(props);
|
|
310
|
-
}
|
|
311
|
-
setProps = (props) => {
|
|
312
|
-
this._props = Object.freeze({
|
|
313
|
-
...this.defaultProps,
|
|
314
|
-
...props
|
|
315
|
-
});
|
|
316
|
-
this.updateTree();
|
|
317
|
-
};
|
|
318
|
-
updateProps = (updates) => {
|
|
319
|
-
this._props = Object.freeze({
|
|
320
|
-
...this._props,
|
|
321
|
-
...updates
|
|
322
|
-
});
|
|
323
|
-
this.updateTree();
|
|
324
|
-
};
|
|
325
|
-
/** @hidden */
|
|
326
|
-
setParent(parent) {
|
|
327
|
-
if (this.parent && this.parent !== parent) {
|
|
328
|
-
this.parent.removeChild(this);
|
|
329
|
-
}
|
|
330
|
-
this.parent = parent;
|
|
331
|
-
}
|
|
332
|
-
/** @hidden */
|
|
333
|
-
updateTree() {
|
|
334
|
-
if (this.parent) this.parent.updateTree();
|
|
335
|
-
}
|
|
336
|
-
/** @hidden */
|
|
337
|
-
handleMessage(message) {
|
|
338
|
-
console.log("Component Received Message:", message);
|
|
339
|
-
}
|
|
340
|
-
routeMessage(_idMap, _message) {
|
|
341
|
-
}
|
|
342
|
-
};
|
|
343
|
-
var BaseParent = class extends Base {
|
|
344
|
-
/** @hidden */
|
|
345
|
-
children = [];
|
|
346
|
-
appendChildren = (...children) => {
|
|
347
|
-
for (const c of children) {
|
|
348
|
-
const newChildren = [...this.children.filter((ch) => ch !== c), c];
|
|
349
|
-
this.validateChildren(newChildren);
|
|
350
|
-
this.children = Object.freeze(newChildren);
|
|
351
|
-
c.setParent(this);
|
|
352
|
-
}
|
|
353
|
-
this.updateTree();
|
|
354
|
-
return children;
|
|
355
|
-
};
|
|
356
|
-
appendChild = (child) => {
|
|
357
|
-
this.appendChildren(child);
|
|
358
|
-
return child;
|
|
359
|
-
};
|
|
360
|
-
removeChild = (component) => {
|
|
361
|
-
const match = this.children.findIndex((c) => c === component);
|
|
362
|
-
if (match >= 0) {
|
|
363
|
-
const removingChild = this.children[match];
|
|
364
|
-
const newChildren = [
|
|
365
|
-
...this.children.slice(0, match),
|
|
366
|
-
...this.children.slice(match + 1)
|
|
367
|
-
];
|
|
368
|
-
this.validateChildren(newChildren);
|
|
369
|
-
this.children = Object.freeze(newChildren);
|
|
370
|
-
removingChild?.setParent(null);
|
|
371
|
-
this.updateTree();
|
|
372
|
-
}
|
|
373
|
-
};
|
|
374
|
-
removeAllChildren = () => {
|
|
375
|
-
this.children.map((c) => c.setParent(null));
|
|
376
|
-
this.children = Object.freeze([]);
|
|
377
|
-
this.updateTree();
|
|
378
|
-
};
|
|
379
|
-
/**
|
|
380
|
-
* Return all children components that messages need to be routed to
|
|
381
|
-
*/
|
|
382
|
-
getChildren = () => this.children;
|
|
383
|
-
/**
|
|
384
|
-
* TODO: we can do this better, right now it broadcasts the message to all
|
|
385
|
-
* components of the tree
|
|
386
|
-
*
|
|
387
|
-
* @hidden
|
|
388
|
-
*/
|
|
389
|
-
routeMessage(idMap, message) {
|
|
390
|
-
if (idMap.getId(this) === message.componentKey) {
|
|
391
|
-
this.handleMessage(message);
|
|
392
|
-
} else {
|
|
393
|
-
for (const c of this.children) {
|
|
394
|
-
if (idMap.getId(c) === message.componentKey) {
|
|
395
|
-
c.handleMessage(message);
|
|
396
|
-
} else {
|
|
397
|
-
c.routeMessage(idMap, message);
|
|
398
|
-
}
|
|
399
|
-
}
|
|
400
|
-
}
|
|
401
|
-
}
|
|
402
|
-
insertBefore(child, beforeChild) {
|
|
403
|
-
const filteredChildren = this.children.filter((c) => c !== child);
|
|
404
|
-
let match = filteredChildren.findIndex((c) => c === beforeChild);
|
|
405
|
-
console.log("match", match);
|
|
406
|
-
if (match === -1) {
|
|
407
|
-
match = filteredChildren.length;
|
|
408
|
-
}
|
|
409
|
-
const newChildren = [
|
|
410
|
-
...filteredChildren.slice(0, match),
|
|
411
|
-
child,
|
|
412
|
-
...filteredChildren.slice(match)
|
|
413
|
-
];
|
|
414
|
-
this.validateChildren(newChildren);
|
|
415
|
-
this.children = Object.freeze(newChildren);
|
|
416
|
-
child.setParent(this);
|
|
417
|
-
this.updateTree();
|
|
418
|
-
}
|
|
419
|
-
};
|
|
420
|
-
var EventEmitter = class {
|
|
421
|
-
listeners = /* @__PURE__ */ new Map();
|
|
422
|
-
addListener = (type, listener) => {
|
|
423
|
-
let set = this.listeners.get(type);
|
|
424
|
-
if (!set) {
|
|
425
|
-
set = /* @__PURE__ */ new Set();
|
|
426
|
-
this.listeners.set(type, set);
|
|
427
|
-
}
|
|
428
|
-
set.add(listener);
|
|
429
|
-
};
|
|
430
|
-
removeListener = (type, listener) => {
|
|
431
|
-
this.listeners.get(type)?.delete(listener);
|
|
432
|
-
};
|
|
433
|
-
emit = (type, ...args) => {
|
|
434
|
-
return Promise.all(
|
|
435
|
-
[...this.listeners.get(type) || []].map(
|
|
436
|
-
(l) => new Promise((resolve2, reject) => {
|
|
437
|
-
try {
|
|
438
|
-
resolve2(l(...args));
|
|
439
|
-
} catch (e) {
|
|
440
|
-
reject(e);
|
|
441
|
-
}
|
|
442
|
-
})
|
|
443
|
-
)
|
|
444
|
-
);
|
|
445
|
-
};
|
|
446
|
-
};
|
|
447
266
|
|
|
448
|
-
// src/backend/components/button.ts
|
|
449
|
-
var DEFAULT_PROPS = {
|
|
450
|
-
text: null,
|
|
451
|
-
icon: null,
|
|
452
|
-
mode: "normal",
|
|
453
|
-
error: null
|
|
454
|
-
};
|
|
455
|
-
var Button = class extends Base {
|
|
456
|
-
/** @hidden */
|
|
457
|
-
events = new EventEmitter();
|
|
458
|
-
constructor(props) {
|
|
459
|
-
super(DEFAULT_PROPS, props);
|
|
460
|
-
}
|
|
461
|
-
addListener = this.events.addListener;
|
|
462
|
-
removeListener = this.events.removeListener;
|
|
463
|
-
setText = (text) => {
|
|
464
|
-
this.updateProps({ text });
|
|
465
|
-
return this;
|
|
466
|
-
};
|
|
467
|
-
setIcon = (icon) => {
|
|
468
|
-
this.updateProps({ icon: icon ?? null });
|
|
469
|
-
return this;
|
|
470
|
-
};
|
|
471
|
-
setMode = (mode) => {
|
|
472
|
-
this.updateProps({
|
|
473
|
-
mode,
|
|
474
|
-
error: null
|
|
475
|
-
});
|
|
476
|
-
return this;
|
|
477
|
-
};
|
|
478
|
-
/** @hidden */
|
|
479
|
-
getProtoInfo = (idMap) => {
|
|
480
|
-
return {
|
|
481
|
-
component: "button",
|
|
482
|
-
key: idMap.getId(this),
|
|
483
|
-
text: this.props.text || "",
|
|
484
|
-
state: this.props.error ? { state: "error", error: this.props.error } : { state: this.props.mode },
|
|
485
|
-
icon: this.props.icon ?? void 0
|
|
486
|
-
};
|
|
487
|
-
};
|
|
488
|
-
/** @hidden */
|
|
489
|
-
handleMessage = (message) => {
|
|
490
|
-
if (message.component === "button") {
|
|
491
|
-
this.events.emit("click").then(() => {
|
|
492
|
-
if (this.props.error) {
|
|
493
|
-
this.updateProps({
|
|
494
|
-
error: null
|
|
495
|
-
});
|
|
496
|
-
}
|
|
497
|
-
}).catch((e) => {
|
|
498
|
-
this.updateProps({
|
|
499
|
-
error: `${e}`
|
|
500
|
-
});
|
|
501
|
-
});
|
|
502
|
-
}
|
|
503
|
-
};
|
|
504
|
-
};
|
|
505
267
|
|
|
506
|
-
// src/backend/components/group.ts
|
|
507
|
-
var GROUP_DEFAULT_STYLE = {
|
|
508
|
-
direction: "horizontal"
|
|
509
|
-
};
|
|
510
|
-
var DEFAULT_PROPS2 = {
|
|
511
|
-
...GROUP_DEFAULT_STYLE,
|
|
512
|
-
title: null,
|
|
513
|
-
labels: null
|
|
514
|
-
};
|
|
515
|
-
var GroupHeader = class extends BaseParent {
|
|
516
|
-
validateChildren = () => {
|
|
517
|
-
};
|
|
518
|
-
/** @hidden */
|
|
519
|
-
getProtoInfo = (idMap) => ({
|
|
520
|
-
component: "group-header",
|
|
521
|
-
key: idMap.getId(this),
|
|
522
|
-
children: this.getChildren().map((c) => c.getProtoInfo(idMap))
|
|
523
|
-
});
|
|
524
|
-
};
|
|
525
|
-
var Group = class extends BaseParent {
|
|
526
|
-
/** @hidden */
|
|
527
|
-
events = new EventEmitter();
|
|
528
|
-
constructor(props) {
|
|
529
|
-
super(DEFAULT_PROPS2, props);
|
|
530
|
-
}
|
|
531
|
-
addListener = this.events.addListener;
|
|
532
|
-
removeListener = this.events.removeListener;
|
|
533
|
-
validateChildren = () => {
|
|
534
|
-
};
|
|
535
|
-
setOptions = (options) => {
|
|
536
|
-
this.updateProps(options);
|
|
537
|
-
};
|
|
538
|
-
setTitle = (title) => {
|
|
539
|
-
this.updateProps({ title });
|
|
540
|
-
};
|
|
541
|
-
addLabel = (label) => {
|
|
542
|
-
this.updateProps({ labels: [...this.props.labels || [], label] });
|
|
543
|
-
};
|
|
544
|
-
setLabels = (labels) => {
|
|
545
|
-
this.updateProps({ labels });
|
|
546
|
-
};
|
|
547
|
-
addHeaderChild = (child) => {
|
|
548
|
-
const header = new GroupHeader({});
|
|
549
|
-
header.appendChild(child);
|
|
550
|
-
this.appendChild(header);
|
|
551
|
-
return child;
|
|
552
|
-
};
|
|
553
|
-
removeHeaderChild = (child) => {
|
|
554
|
-
for (const c of this.getChildren()) {
|
|
555
|
-
if (c instanceof GroupHeader) {
|
|
556
|
-
c.removeChild(child);
|
|
557
|
-
}
|
|
558
|
-
}
|
|
559
|
-
};
|
|
560
|
-
removeAllHeaderChildren = () => {
|
|
561
|
-
for (const child of this.getChildren()) {
|
|
562
|
-
if (child instanceof GroupHeader) {
|
|
563
|
-
child.removeAllChildren();
|
|
564
|
-
}
|
|
565
|
-
}
|
|
566
|
-
};
|
|
567
|
-
/** @hidden */
|
|
568
|
-
getProtoInfo = (idMap) => {
|
|
569
|
-
const children = [];
|
|
570
|
-
const headers = [];
|
|
571
|
-
for (const c of this.getChildren()) {
|
|
572
|
-
const childProto = c.getProtoInfo(idMap);
|
|
573
|
-
if (childProto.component === "group-header") {
|
|
574
|
-
headers.push(childProto);
|
|
575
|
-
} else {
|
|
576
|
-
children.push(childProto);
|
|
577
|
-
}
|
|
578
|
-
}
|
|
579
|
-
return {
|
|
580
|
-
component: "group",
|
|
581
|
-
key: idMap.getId(this),
|
|
582
|
-
title: this.props.title ?? void 0,
|
|
583
|
-
direction: this.props.direction,
|
|
584
|
-
border: this.props.border,
|
|
585
|
-
wrap: this.props.wrap,
|
|
586
|
-
children,
|
|
587
|
-
headers: headers.length > 0 ? headers : void 0,
|
|
588
|
-
labels: this.props.labels ?? void 0,
|
|
589
|
-
editableTitle: this.props.editableTitle || false,
|
|
590
|
-
defaultCollapsibleState: this.props.defaultCollapsibleState
|
|
591
|
-
};
|
|
592
|
-
};
|
|
593
|
-
/** @hidden */
|
|
594
|
-
handleMessage = (message) => {
|
|
595
|
-
if (message.component === "group") {
|
|
596
|
-
this.events.emit("title-changed", message.title);
|
|
597
|
-
}
|
|
598
|
-
};
|
|
599
|
-
};
|
|
600
268
|
|
|
601
|
-
// src/backend/components/label.ts
|
|
602
|
-
var Label = class extends Base {
|
|
603
|
-
constructor(props) {
|
|
604
|
-
super({ text: null }, props);
|
|
605
|
-
}
|
|
606
|
-
/** @hidden */
|
|
607
|
-
getProtoInfo(idMap) {
|
|
608
|
-
return {
|
|
609
|
-
component: "label",
|
|
610
|
-
key: idMap.getId(this),
|
|
611
|
-
bold: this.props.bold,
|
|
612
|
-
text: this.props.text ?? ""
|
|
613
|
-
};
|
|
614
|
-
}
|
|
615
|
-
setText(text) {
|
|
616
|
-
this.updateProps({
|
|
617
|
-
text
|
|
618
|
-
});
|
|
619
|
-
return this;
|
|
620
|
-
}
|
|
621
|
-
};
|
|
622
269
|
|
|
623
|
-
// src/backend/components/rect.ts
|
|
624
|
-
var DEFAULT_PROPS3 = {
|
|
625
|
-
color: "rgba(0, 0, 0, 0)"
|
|
626
|
-
};
|
|
627
|
-
var Rect = class extends Base {
|
|
628
|
-
constructor(props) {
|
|
629
|
-
super(DEFAULT_PROPS3, props);
|
|
630
|
-
}
|
|
631
|
-
/** @hidden */
|
|
632
|
-
getProtoInfo(idMap) {
|
|
633
|
-
return {
|
|
634
|
-
component: "rect",
|
|
635
|
-
key: idMap.getId(this),
|
|
636
|
-
color: this.props.color
|
|
637
|
-
};
|
|
638
|
-
}
|
|
639
|
-
setColor(color) {
|
|
640
|
-
this.updateProps({ color });
|
|
641
|
-
return this;
|
|
642
|
-
}
|
|
643
|
-
};
|
|
644
270
|
|
|
645
|
-
// src/backend/components/slider-button.ts
|
|
646
|
-
var DEFAULT_PROPS4 = {
|
|
647
|
-
value: null,
|
|
648
|
-
min: 0,
|
|
649
|
-
max: 255,
|
|
650
|
-
step: 5,
|
|
651
|
-
mode: "writeBack"
|
|
652
|
-
};
|
|
653
|
-
var SliderButton = class extends Base {
|
|
654
|
-
/** @hidden */
|
|
655
|
-
events = new EventEmitter();
|
|
656
|
-
constructor(props) {
|
|
657
|
-
super(DEFAULT_PROPS4, props);
|
|
658
|
-
}
|
|
659
|
-
addListener = this.events.addListener;
|
|
660
|
-
removeListener = this.events.removeListener;
|
|
661
|
-
/** @hidden */
|
|
662
|
-
getProtoInfo(idMap) {
|
|
663
|
-
return {
|
|
664
|
-
component: "slider_button",
|
|
665
|
-
key: idMap.getId(this),
|
|
666
|
-
min: this.props.min,
|
|
667
|
-
max: this.props.max,
|
|
668
|
-
step: this.props.step,
|
|
669
|
-
value: this.props.value
|
|
670
|
-
};
|
|
671
|
-
}
|
|
672
|
-
/** @hidden */
|
|
673
|
-
handleMessage(message) {
|
|
674
|
-
if (message.component !== "slider_button") return;
|
|
675
|
-
const newValue = this.sanitizeNumber(message.value);
|
|
676
|
-
if (this.props.value === newValue) return;
|
|
677
|
-
if (this.props.mode === "writeBack") {
|
|
678
|
-
this.updateProps({ value: newValue });
|
|
679
|
-
}
|
|
680
|
-
this.events.emit("change", newValue);
|
|
681
|
-
}
|
|
682
|
-
setValue(value) {
|
|
683
|
-
const newValue = this.sanitizeNumber(value);
|
|
684
|
-
if (newValue === this.props.value) return;
|
|
685
|
-
this.updateProps({ value });
|
|
686
|
-
this.updateTree();
|
|
687
|
-
}
|
|
688
|
-
sanitizeNumber(value) {
|
|
689
|
-
const i = Math.round((value - this.props.min) / this.props.step);
|
|
690
|
-
const v = i * this.props.step + this.props.min;
|
|
691
|
-
const clampedValue = Math.max(this.props.min, Math.min(this.props.max, v));
|
|
692
|
-
return clampedValue;
|
|
693
|
-
}
|
|
694
|
-
};
|
|
695
271
|
|
|
696
|
-
// src/backend/components/switch.ts
|
|
697
|
-
var DEFAULT_PROPS5 = {
|
|
698
|
-
state: "off"
|
|
699
|
-
};
|
|
700
|
-
var Switch = class extends Base {
|
|
701
|
-
/** @hidden */
|
|
702
|
-
events = new EventEmitter();
|
|
703
|
-
constructor(props) {
|
|
704
|
-
super(DEFAULT_PROPS5, props);
|
|
705
|
-
}
|
|
706
|
-
addListener = this.events.addListener;
|
|
707
|
-
removeListener = this.events.removeListener;
|
|
708
|
-
/** @hidden */
|
|
709
|
-
getProtoInfo(idMap) {
|
|
710
|
-
return {
|
|
711
|
-
component: "switch",
|
|
712
|
-
key: idMap.getId(this),
|
|
713
|
-
state: this.props.state
|
|
714
|
-
};
|
|
715
|
-
}
|
|
716
|
-
/** @hidden */
|
|
717
|
-
handleMessage(message) {
|
|
718
|
-
if (message.component === "switch") {
|
|
719
|
-
const state = this.props.state === "on" ? "off" : "on";
|
|
720
|
-
this.updateProps({ state });
|
|
721
|
-
this.events.emit("change", state);
|
|
722
|
-
}
|
|
723
|
-
}
|
|
724
|
-
setValue(state) {
|
|
725
|
-
if (state === this.props.state) return;
|
|
726
|
-
this.updateProps({ state });
|
|
727
|
-
}
|
|
728
|
-
};
|
|
729
272
|
|
|
730
|
-
// src/backend/components/tabs.ts
|
|
731
|
-
var Tab = class extends BaseParent {
|
|
732
|
-
validateChildren = (children) => {
|
|
733
|
-
if (children.length > 1) {
|
|
734
|
-
throw new Error("Tab can only have one child");
|
|
735
|
-
}
|
|
736
|
-
};
|
|
737
|
-
/** @hidden */
|
|
738
|
-
getProtoInfo = (idMap) => ({
|
|
739
|
-
component: "tab",
|
|
740
|
-
key: idMap.getId(this),
|
|
741
|
-
name: this.props.name,
|
|
742
|
-
child: this.getChildren().slice(0, 1).map((c) => c.getProtoInfo(idMap))[0]
|
|
743
|
-
});
|
|
744
|
-
};
|
|
745
|
-
var Tabs = class extends BaseParent {
|
|
746
|
-
validateChildren = (children) => {
|
|
747
|
-
for (const child of children) {
|
|
748
|
-
if (!(child instanceof Tab)) {
|
|
749
|
-
throw new Error("Tabs can only have Tab children");
|
|
750
|
-
}
|
|
751
|
-
}
|
|
752
|
-
};
|
|
753
|
-
constructor(props) {
|
|
754
|
-
super({}, { ...props });
|
|
755
|
-
}
|
|
756
|
-
addTabs(...tabs) {
|
|
757
|
-
for (const t of tabs) {
|
|
758
|
-
const tab = new Tab({ name: t.name });
|
|
759
|
-
tab.appendChildren(t.component);
|
|
760
|
-
this.appendChild(tab);
|
|
761
|
-
}
|
|
762
|
-
}
|
|
763
|
-
addTab(name, component) {
|
|
764
|
-
this.addTabs({ name, component });
|
|
765
|
-
return component;
|
|
766
|
-
}
|
|
767
|
-
/** @hidden */
|
|
768
|
-
getProtoInfo(idMap) {
|
|
769
|
-
return {
|
|
770
|
-
component: "tabs",
|
|
771
|
-
key: idMap.getId(this),
|
|
772
|
-
tabs: this.getChildren().map((c) => c.getProtoInfo(idMap))
|
|
773
|
-
};
|
|
774
|
-
}
|
|
775
|
-
};
|
|
776
273
|
|
|
777
|
-
// src/backend/components/text-input.ts
|
|
778
|
-
var DEFAULT_PROPS6 = {
|
|
779
|
-
value: null
|
|
780
|
-
};
|
|
781
|
-
var TextInput = class extends Base {
|
|
782
|
-
/** @hidden */
|
|
783
|
-
events = new EventEmitter();
|
|
784
|
-
constructor(props) {
|
|
785
|
-
super(DEFAULT_PROPS6, props);
|
|
786
|
-
}
|
|
787
|
-
addListener = this.events.addListener;
|
|
788
|
-
removeListener = this.events.removeListener;
|
|
789
|
-
/** @hidden */
|
|
790
|
-
getProtoInfo = (idMap) => {
|
|
791
|
-
return {
|
|
792
|
-
component: "text-input",
|
|
793
|
-
key: idMap.getId(this),
|
|
794
|
-
value: this.props.value ?? ""
|
|
795
|
-
};
|
|
796
|
-
};
|
|
797
|
-
/** @hidden */
|
|
798
|
-
handleMessage = (message) => {
|
|
799
|
-
if (message.component === "text-input") {
|
|
800
|
-
if (this.props.value !== message.value) {
|
|
801
|
-
this.updateProps({ value: message.value });
|
|
802
|
-
this.events.emit("change", message.value);
|
|
803
|
-
}
|
|
804
|
-
}
|
|
805
|
-
};
|
|
806
|
-
getValue = () => this.props.value;
|
|
807
|
-
getValidatedValue = (validator) => this.props.value === "" ? null : validator(this.props.value || "");
|
|
808
|
-
setValue = (value) => {
|
|
809
|
-
this.updateProps({ value });
|
|
810
|
-
};
|
|
811
|
-
};
|
|
812
274
|
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
totalTimeMillis: 0,
|
|
818
|
-
currentTimeMillis: 0
|
|
819
|
-
},
|
|
820
|
-
title: null,
|
|
821
|
-
subtitles: null,
|
|
822
|
-
source: null
|
|
823
|
-
};
|
|
824
|
-
var Timeline = class extends Base {
|
|
825
|
-
constructor(props) {
|
|
826
|
-
super(DEFAULT_PROPS7, props);
|
|
827
|
-
}
|
|
828
|
-
/** @hidden */
|
|
829
|
-
getProtoInfo = (idMap) => ({
|
|
830
|
-
component: "timeline",
|
|
831
|
-
key: idMap.getId(this),
|
|
832
|
-
state: this.props.state,
|
|
833
|
-
title: this.props.title ?? void 0,
|
|
834
|
-
subtitles: this.props.subtitles ?? void 0,
|
|
835
|
-
source: this.props.source ?? void 0
|
|
836
|
-
});
|
|
837
|
-
};
|
|
838
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
839
|
-
0 && (module.exports = {
|
|
840
|
-
Button,
|
|
841
|
-
Group,
|
|
842
|
-
GroupHeader,
|
|
843
|
-
Label,
|
|
844
|
-
Rect,
|
|
845
|
-
SliderButton,
|
|
846
|
-
Switch,
|
|
847
|
-
Tab,
|
|
848
|
-
Tabs,
|
|
849
|
-
TextInput,
|
|
850
|
-
Timeline,
|
|
851
|
-
Toolkit
|
|
852
|
-
});
|
|
275
|
+
|
|
276
|
+
|
|
277
|
+
|
|
278
|
+
exports.Button = _chunkKVJU3EADjs.Button; exports.Group = _chunkK24YPCR5js.Group; exports.GroupHeader = _chunkK24YPCR5js.GroupHeader; exports.Label = _chunkP43QUQ4Tjs.Label; exports.Rect = _chunkRGIB65TIjs.Rect; exports.SliderButton = _chunkT2PJEXYOjs.SliderButton; exports.Switch = _chunkM6EFK4GPjs.Switch; exports.Tab = _chunkRJS32OOAjs.Tab; exports.Tabs = _chunkRJS32OOAjs.Tabs; exports.TextInput = _chunkMDFDWKGWjs.TextInput; exports.Timeline = _chunkOEIGZ3NQjs.Timeline; exports.Toolkit = Toolkit;
|