lecodes-cli 0.1.3 → 0.1.6
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/index.js +740 -267
- package/package.json +4 -3
- package/runtime/inject.js +4629 -0
- package/runtime/gl-matrix/common.js +0 -54
- package/runtime/gl-matrix/header.js +0 -12
- package/runtime/gl-matrix/index.js +0 -11
- package/runtime/gl-matrix/mat2.js +0 -425
- package/runtime/gl-matrix/mat2d.js +0 -476
- package/runtime/gl-matrix/mat3.js +0 -765
- package/runtime/gl-matrix/mat4.js +0 -1947
- package/runtime/gl-matrix/quat.js +0 -737
- package/runtime/gl-matrix/quat2.js +0 -822
- package/runtime/gl-matrix/vec2.js +0 -620
- package/runtime/gl-matrix/vec3.js +0 -791
- package/runtime/gl-matrix/vec4.js +0 -652
- package/runtime/worker/animate.js +0 -304
- package/runtime/worker/chunk-4ZN32GYS.js +0 -34
- package/runtime/worker/chunk-G5ZA3LKB.js +0 -52
- package/runtime/worker/chunk-MI3UXE5H.js +0 -1395
- package/runtime/worker/creator.js +0 -930
- package/runtime/worker/globals.js +0 -208
- package/runtime/worker/ui.js +0 -763
- package/runtime/worker/utils.js +0 -16
package/runtime/worker/ui.js
DELETED
|
@@ -1,763 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
TouchStartEvent as TouchStartEvent2
|
|
3
|
-
} from "./chunk-4ZN32GYS.js";
|
|
4
|
-
|
|
5
|
-
// ../worker/src/UI/UINode.ts
|
|
6
|
-
function styleFunction(newStyle) {
|
|
7
|
-
Object.assign(this._style, newStyle);
|
|
8
|
-
if (this._id !== 0) {
|
|
9
|
-
_creatorUI.mergeStyle(this._id, newStyle);
|
|
10
|
-
}
|
|
11
|
-
return this;
|
|
12
|
-
}
|
|
13
|
-
var handler = {
|
|
14
|
-
get(target, key, receiver) {
|
|
15
|
-
if (key === "_raw") {
|
|
16
|
-
return target._el._style;
|
|
17
|
-
}
|
|
18
|
-
return target._el._style[key];
|
|
19
|
-
},
|
|
20
|
-
set(target, key, value) {
|
|
21
|
-
if (target._el._id !== 0) {
|
|
22
|
-
_creatorUI.updateStyle(target._el._id, key, value);
|
|
23
|
-
}
|
|
24
|
-
target._el._style[key] = value;
|
|
25
|
-
return true;
|
|
26
|
-
},
|
|
27
|
-
getOwnPropertyDescriptor(target, p) {
|
|
28
|
-
return Object.getOwnPropertyDescriptor(target._el._style, p);
|
|
29
|
-
},
|
|
30
|
-
ownKeys(target) {
|
|
31
|
-
return Object.keys(target._el._style);
|
|
32
|
-
}
|
|
33
|
-
};
|
|
34
|
-
var Element = class {
|
|
35
|
-
type;
|
|
36
|
-
/** Author-given semantic name (LeCodes `name`) — see BaseStyle.name. Extracted from the options
|
|
37
|
-
* object so it never reaches the layout engine; the renderer reads it off the node. */
|
|
38
|
-
name;
|
|
39
|
-
_style;
|
|
40
|
-
_id = 0;
|
|
41
|
-
_styleProxy;
|
|
42
|
-
_appear;
|
|
43
|
-
_disappear;
|
|
44
|
-
constructor(type, style) {
|
|
45
|
-
this.type = type;
|
|
46
|
-
if (style && typeof style.name === "string" && style.name.length > 0) {
|
|
47
|
-
this.name = style.name;
|
|
48
|
-
delete style.name;
|
|
49
|
-
}
|
|
50
|
-
this._style = style;
|
|
51
|
-
}
|
|
52
|
-
get style() {
|
|
53
|
-
if (this._styleProxy) return this._styleProxy;
|
|
54
|
-
const obj = styleFunction.bind(this);
|
|
55
|
-
obj._el = this;
|
|
56
|
-
const proxy = new Proxy(obj, handler);
|
|
57
|
-
this._styleProxy = proxy;
|
|
58
|
-
return proxy;
|
|
59
|
-
}
|
|
60
|
-
animateTo(style) {
|
|
61
|
-
_creatorUI.animateTo(this._id, style);
|
|
62
|
-
if (style.commit !== false) {
|
|
63
|
-
Object.assign(this._style, style);
|
|
64
|
-
}
|
|
65
|
-
return this;
|
|
66
|
-
}
|
|
67
|
-
animateFrom(style) {
|
|
68
|
-
_creatorUI.animateFrom(this._id, style);
|
|
69
|
-
return this;
|
|
70
|
-
}
|
|
71
|
-
ll;
|
|
72
|
-
onLayout(onLayout) {
|
|
73
|
-
if (this.ll) {
|
|
74
|
-
this.ll.push(onLayout);
|
|
75
|
-
} else {
|
|
76
|
-
this.ll = [onLayout];
|
|
77
|
-
}
|
|
78
|
-
return this;
|
|
79
|
-
}
|
|
80
|
-
};
|
|
81
|
-
var ContainerElement = class extends Element {
|
|
82
|
-
children = [];
|
|
83
|
-
constructor(type, style, children) {
|
|
84
|
-
super(type, style);
|
|
85
|
-
this.children = children;
|
|
86
|
-
}
|
|
87
|
-
append(...nodes) {
|
|
88
|
-
if (this._id === 0) {
|
|
89
|
-
this.children.push(...nodes);
|
|
90
|
-
return this;
|
|
91
|
-
}
|
|
92
|
-
let index = 0;
|
|
93
|
-
for (let child of this.children) {
|
|
94
|
-
if (child) {
|
|
95
|
-
index++;
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
|
-
for (let node of nodes) {
|
|
99
|
-
if (!node) continue;
|
|
100
|
-
_creatorUI.insertNode(index, this._id, node);
|
|
101
|
-
index++;
|
|
102
|
-
}
|
|
103
|
-
this.children.push(...nodes);
|
|
104
|
-
return this;
|
|
105
|
-
}
|
|
106
|
-
insert(index, ...nodes) {
|
|
107
|
-
if (this._id === 0) {
|
|
108
|
-
this.children.splice(index, 0, ...nodes);
|
|
109
|
-
return this;
|
|
110
|
-
}
|
|
111
|
-
let _index = 0;
|
|
112
|
-
for (let i = 0; i < index; i++) {
|
|
113
|
-
if (this.children[i]) {
|
|
114
|
-
_index++;
|
|
115
|
-
}
|
|
116
|
-
}
|
|
117
|
-
for (let node of nodes) {
|
|
118
|
-
if (!node) continue;
|
|
119
|
-
_creatorUI.insertNode(_index, this._id, node);
|
|
120
|
-
_index++;
|
|
121
|
-
}
|
|
122
|
-
this.children.splice(index, 0, ...nodes);
|
|
123
|
-
return this;
|
|
124
|
-
}
|
|
125
|
-
remove(...nodesToDelete) {
|
|
126
|
-
const set = new Set(nodesToDelete);
|
|
127
|
-
for (let i = 0; i < this.children.length; i++) {
|
|
128
|
-
if (set.has(this.children[i])) {
|
|
129
|
-
set.delete(this.children[i]);
|
|
130
|
-
this.children.splice(i, 1);
|
|
131
|
-
i--;
|
|
132
|
-
if (set.size === 0) {
|
|
133
|
-
break;
|
|
134
|
-
}
|
|
135
|
-
}
|
|
136
|
-
}
|
|
137
|
-
if (this._id === 0) {
|
|
138
|
-
return this;
|
|
139
|
-
}
|
|
140
|
-
for (let node of nodesToDelete) {
|
|
141
|
-
_creatorUI.removeNode(this._id, node);
|
|
142
|
-
}
|
|
143
|
-
return this;
|
|
144
|
-
}
|
|
145
|
-
setContent(children) {
|
|
146
|
-
if (this._id !== 0) {
|
|
147
|
-
_creatorUI.setContent(this._id, this.children, children);
|
|
148
|
-
}
|
|
149
|
-
this.children.length = 0;
|
|
150
|
-
this.children.push(...children);
|
|
151
|
-
return this;
|
|
152
|
-
}
|
|
153
|
-
};
|
|
154
|
-
|
|
155
|
-
// ../worker/src/UI/UIButton.ts
|
|
156
|
-
var ButtonElement = class extends ContainerElement {
|
|
157
|
-
clickListeners = [];
|
|
158
|
-
touchStartListeners = [];
|
|
159
|
-
onClick(callback) {
|
|
160
|
-
this.clickListeners.push(callback);
|
|
161
|
-
return this;
|
|
162
|
-
}
|
|
163
|
-
_emitClick(pointerId, clientX, clientY) {
|
|
164
|
-
const touchEvent = new ClickEvent(clientX, clientY, pointerId);
|
|
165
|
-
touchEvent.target = this;
|
|
166
|
-
for (let callback of this.clickListeners) {
|
|
167
|
-
callback(touchEvent);
|
|
168
|
-
}
|
|
169
|
-
return null;
|
|
170
|
-
}
|
|
171
|
-
onTouchStart(callback) {
|
|
172
|
-
this.touchStartListeners.push(callback);
|
|
173
|
-
return this;
|
|
174
|
-
}
|
|
175
|
-
_emitTouchStart(pointerId, clientX, clientY) {
|
|
176
|
-
const touchEvent = new TouchStartEvent(clientX, clientY, pointerId);
|
|
177
|
-
touchEvent.target = this;
|
|
178
|
-
for (let callback of this.touchStartListeners) {
|
|
179
|
-
callback(touchEvent);
|
|
180
|
-
if (touchEvent._trackHandler) {
|
|
181
|
-
return touchEvent._trackHandler;
|
|
182
|
-
}
|
|
183
|
-
}
|
|
184
|
-
return null;
|
|
185
|
-
}
|
|
186
|
-
isPressed() {
|
|
187
|
-
if (!this._id) return false;
|
|
188
|
-
return _creatorUI.isButtonPressed(this._id);
|
|
189
|
-
}
|
|
190
|
-
};
|
|
191
|
-
function UIButton(...args) {
|
|
192
|
-
if (args.length === 0) {
|
|
193
|
-
return new ButtonElement("button", {}, []);
|
|
194
|
-
} else if (args.length === 1) {
|
|
195
|
-
if (Array.isArray(args[0])) {
|
|
196
|
-
return new ButtonElement("button", {}, args[0]);
|
|
197
|
-
} else {
|
|
198
|
-
return new ButtonElement("button", args[0], []);
|
|
199
|
-
}
|
|
200
|
-
} else {
|
|
201
|
-
return new ButtonElement("button", args[0], args[1]);
|
|
202
|
-
}
|
|
203
|
-
}
|
|
204
|
-
|
|
205
|
-
// ../worker/src/UI/UIScreen.ts
|
|
206
|
-
var ScreenElement = class extends ContainerElement {
|
|
207
|
-
scrollable = false;
|
|
208
|
-
open() {
|
|
209
|
-
_creatorUI.openScreen(this);
|
|
210
|
-
}
|
|
211
|
-
close() {
|
|
212
|
-
_creatorUI.closeScreen();
|
|
213
|
-
}
|
|
214
|
-
ol = [];
|
|
215
|
-
onOpen(callback) {
|
|
216
|
-
this.ol.push(callback);
|
|
217
|
-
return this;
|
|
218
|
-
}
|
|
219
|
-
cl = [];
|
|
220
|
-
onClose(callback) {
|
|
221
|
-
this.cl.push(callback);
|
|
222
|
-
return this;
|
|
223
|
-
}
|
|
224
|
-
touchStartListeners = [];
|
|
225
|
-
_interactive = false;
|
|
226
|
-
onTouchStart(callback) {
|
|
227
|
-
this._interactive = true;
|
|
228
|
-
this.touchStartListeners.push(callback);
|
|
229
|
-
return this;
|
|
230
|
-
}
|
|
231
|
-
_emitTouchStart(pointerId, clientX, clientY) {
|
|
232
|
-
const touchEvent = new TouchStartEvent2(clientX, clientY, pointerId);
|
|
233
|
-
touchEvent.target = this;
|
|
234
|
-
for (let callback of this.touchStartListeners) {
|
|
235
|
-
callback(touchEvent);
|
|
236
|
-
if (touchEvent._trackHandler) {
|
|
237
|
-
return touchEvent._trackHandler;
|
|
238
|
-
}
|
|
239
|
-
}
|
|
240
|
-
return null;
|
|
241
|
-
}
|
|
242
|
-
makeScrollable() {
|
|
243
|
-
this.scrollable = true;
|
|
244
|
-
Object.assign(this, {
|
|
245
|
-
sl: [],
|
|
246
|
-
osl: [],
|
|
247
|
-
onScroll(callback) {
|
|
248
|
-
this.sl.push(callback);
|
|
249
|
-
return this;
|
|
250
|
-
},
|
|
251
|
-
onOverscroll(callback) {
|
|
252
|
-
this.osl.push(callback);
|
|
253
|
-
return this;
|
|
254
|
-
},
|
|
255
|
-
onRefresh(callback) {
|
|
256
|
-
this._refreshCallback = callback;
|
|
257
|
-
return this;
|
|
258
|
-
}
|
|
259
|
-
});
|
|
260
|
-
return this;
|
|
261
|
-
}
|
|
262
|
-
_backButtonCallback;
|
|
263
|
-
onBackPressed(callback) {
|
|
264
|
-
this._backButtonCallback = callback;
|
|
265
|
-
return this;
|
|
266
|
-
}
|
|
267
|
-
};
|
|
268
|
-
function UIScreen(...args) {
|
|
269
|
-
if (args.length === 0) {
|
|
270
|
-
return new ScreenElement("screen", {}, []);
|
|
271
|
-
} else if (args.length === 1) {
|
|
272
|
-
if (Array.isArray(args[0])) {
|
|
273
|
-
return new ScreenElement("screen", {}, args[0]);
|
|
274
|
-
} else {
|
|
275
|
-
return new ScreenElement("screen", args[0], []);
|
|
276
|
-
}
|
|
277
|
-
} else {
|
|
278
|
-
return new ScreenElement("screen", args[0], args[1]);
|
|
279
|
-
}
|
|
280
|
-
}
|
|
281
|
-
|
|
282
|
-
// ../worker/src/UI/UISpacer.ts
|
|
283
|
-
function UISpacer(style) {
|
|
284
|
-
return new Element("spacer", style ?? {});
|
|
285
|
-
}
|
|
286
|
-
|
|
287
|
-
// ../worker/src/UI/UIText.ts
|
|
288
|
-
var TextElement = class extends Element {
|
|
289
|
-
_text;
|
|
290
|
-
constructor(style, text) {
|
|
291
|
-
super("text", style);
|
|
292
|
-
this._text = text;
|
|
293
|
-
}
|
|
294
|
-
get text() {
|
|
295
|
-
return this._text;
|
|
296
|
-
}
|
|
297
|
-
set text(value) {
|
|
298
|
-
this._text = value;
|
|
299
|
-
if (this._id !== 0) {
|
|
300
|
-
_creatorUI.updateNode(this._id, "text", value);
|
|
301
|
-
}
|
|
302
|
-
}
|
|
303
|
-
};
|
|
304
|
-
function UIText(...args) {
|
|
305
|
-
if (args.length === 1) {
|
|
306
|
-
return new TextElement({}, args[0]);
|
|
307
|
-
} else {
|
|
308
|
-
return new TextElement(args[0], args[1]);
|
|
309
|
-
}
|
|
310
|
-
}
|
|
311
|
-
|
|
312
|
-
// ../worker/src/UI/fonts.ts
|
|
313
|
-
async function registerFont(fontFamily, url, options = {}) {
|
|
314
|
-
return new Promise((res, rej) => {
|
|
315
|
-
_creatorUI.registerFont(fontFamily, url, options, res, rej);
|
|
316
|
-
});
|
|
317
|
-
}
|
|
318
|
-
|
|
319
|
-
// ../worker/src/UI/UIImage.ts
|
|
320
|
-
var ImageElement = class extends Element {
|
|
321
|
-
_src;
|
|
322
|
-
// Current source sub-rect; undefined until the first setSourceRect. Kept on the node (not
|
|
323
|
-
// just sent as a command) so a crop set while detached (_id == 0) is reapplied at mount —
|
|
324
|
-
// the viewer reads it when it creates the element.
|
|
325
|
-
_sourceRect;
|
|
326
|
-
constructor(style, src) {
|
|
327
|
-
super("image", style);
|
|
328
|
-
this._src = src;
|
|
329
|
-
}
|
|
330
|
-
get src() {
|
|
331
|
-
return this._src;
|
|
332
|
-
}
|
|
333
|
-
set src(value) {
|
|
334
|
-
this._src = value;
|
|
335
|
-
if (this._id !== 0) {
|
|
336
|
-
_creatorUI.updateNode(this._id, "src", value);
|
|
337
|
-
}
|
|
338
|
-
}
|
|
339
|
-
setSourceRect(x, y, w, h) {
|
|
340
|
-
this._sourceRect = [x, y, w, h];
|
|
341
|
-
if (this._id !== 0) {
|
|
342
|
-
_creatorUI.setSourceRect(this._id, x, y, w, h);
|
|
343
|
-
}
|
|
344
|
-
return this;
|
|
345
|
-
}
|
|
346
|
-
};
|
|
347
|
-
function UIImage(...args) {
|
|
348
|
-
if (args.length === 1) {
|
|
349
|
-
return new ImageElement({}, args[0]);
|
|
350
|
-
} else {
|
|
351
|
-
return new ImageElement(args[0], args[1]);
|
|
352
|
-
}
|
|
353
|
-
}
|
|
354
|
-
|
|
355
|
-
// ../worker/src/UI/UIVideo.ts
|
|
356
|
-
var VideoElement = class extends Element {
|
|
357
|
-
_playerId;
|
|
358
|
-
_player;
|
|
359
|
-
constructor(style, player) {
|
|
360
|
-
super("video", style);
|
|
361
|
-
this._player = player;
|
|
362
|
-
this._playerId = player._id;
|
|
363
|
-
}
|
|
364
|
-
get player() {
|
|
365
|
-
return this._player;
|
|
366
|
-
}
|
|
367
|
-
};
|
|
368
|
-
function UIVideo(...args) {
|
|
369
|
-
if (args.length === 1) {
|
|
370
|
-
return new VideoElement({}, args[0]);
|
|
371
|
-
} else {
|
|
372
|
-
return new VideoElement(args[0], args[1]);
|
|
373
|
-
}
|
|
374
|
-
}
|
|
375
|
-
|
|
376
|
-
// ../worker/src/UI/UIInput.ts
|
|
377
|
-
var InputElement = class extends Element {
|
|
378
|
-
cl = [];
|
|
379
|
-
fl = [];
|
|
380
|
-
bl = [];
|
|
381
|
-
get value() {
|
|
382
|
-
return _creatorUI.getTextValue(this._id);
|
|
383
|
-
}
|
|
384
|
-
set value(value) {
|
|
385
|
-
if (this._id !== 0) {
|
|
386
|
-
_creatorUI.updateNode(this._id, "value", value);
|
|
387
|
-
}
|
|
388
|
-
}
|
|
389
|
-
onChange(callback) {
|
|
390
|
-
this.cl.push(callback);
|
|
391
|
-
return this;
|
|
392
|
-
}
|
|
393
|
-
onFocus(callback) {
|
|
394
|
-
this.fl.push(callback);
|
|
395
|
-
return this;
|
|
396
|
-
}
|
|
397
|
-
onBlur(callback) {
|
|
398
|
-
this.bl.push(callback);
|
|
399
|
-
return this;
|
|
400
|
-
}
|
|
401
|
-
};
|
|
402
|
-
function UIInput(style) {
|
|
403
|
-
return new InputElement("input", style ?? {});
|
|
404
|
-
}
|
|
405
|
-
function UITextArea(style) {
|
|
406
|
-
return new InputElement("textarea", style ?? {});
|
|
407
|
-
}
|
|
408
|
-
|
|
409
|
-
// ../worker/src/UI/UIWidget.ts
|
|
410
|
-
var WidgetElement = class extends ContainerElement {
|
|
411
|
-
scrollable = false;
|
|
412
|
-
show() {
|
|
413
|
-
_creatorUI.showWidget(this);
|
|
414
|
-
}
|
|
415
|
-
hide() {
|
|
416
|
-
_creatorUI.hideWidget(this);
|
|
417
|
-
}
|
|
418
|
-
get isShow() {
|
|
419
|
-
return this._id != 0;
|
|
420
|
-
}
|
|
421
|
-
_interactive = false;
|
|
422
|
-
touchStartListeners = [];
|
|
423
|
-
onTouchStart(callback) {
|
|
424
|
-
this._interactive = true;
|
|
425
|
-
this.touchStartListeners.push(callback);
|
|
426
|
-
return this;
|
|
427
|
-
}
|
|
428
|
-
_emitTouchStart(pointerId, clientX, clientY) {
|
|
429
|
-
const touchEvent = new TouchStartEvent2(clientX, clientY, pointerId);
|
|
430
|
-
touchEvent.target = this;
|
|
431
|
-
for (let callback of this.touchStartListeners) {
|
|
432
|
-
callback(touchEvent);
|
|
433
|
-
if (touchEvent._trackHandler) {
|
|
434
|
-
return touchEvent._trackHandler;
|
|
435
|
-
}
|
|
436
|
-
}
|
|
437
|
-
return null;
|
|
438
|
-
}
|
|
439
|
-
otl = [];
|
|
440
|
-
onOverlayTap(callback) {
|
|
441
|
-
this.otl.push(callback);
|
|
442
|
-
return this;
|
|
443
|
-
}
|
|
444
|
-
_backButtonCallback;
|
|
445
|
-
onBackPressed(callback) {
|
|
446
|
-
this._backButtonCallback = callback;
|
|
447
|
-
return this;
|
|
448
|
-
}
|
|
449
|
-
};
|
|
450
|
-
function UIWidget(...args) {
|
|
451
|
-
if (args.length === 0) {
|
|
452
|
-
return new WidgetElement("widget", {}, []);
|
|
453
|
-
} else if (args.length === 1) {
|
|
454
|
-
if (Array.isArray(args[0])) {
|
|
455
|
-
return new WidgetElement("widget", {}, args[0]);
|
|
456
|
-
} else {
|
|
457
|
-
return new WidgetElement("widget", args[0], []);
|
|
458
|
-
}
|
|
459
|
-
} else {
|
|
460
|
-
return new WidgetElement("widget", args[0], args[1]);
|
|
461
|
-
}
|
|
462
|
-
}
|
|
463
|
-
|
|
464
|
-
// ../worker/src/UI/UIContainer.ts
|
|
465
|
-
function UIColumn(...args) {
|
|
466
|
-
if (args.length === 0) {
|
|
467
|
-
return new ContainerElement("column", {}, []);
|
|
468
|
-
} else if (args.length === 1) {
|
|
469
|
-
if (Array.isArray(args[0])) {
|
|
470
|
-
return new ContainerElement("column", {}, args[0]);
|
|
471
|
-
} else {
|
|
472
|
-
return new ContainerElement("column", args[0], []);
|
|
473
|
-
}
|
|
474
|
-
} else {
|
|
475
|
-
return new ContainerElement("column", args[0], args[1]);
|
|
476
|
-
}
|
|
477
|
-
}
|
|
478
|
-
function UIRow(...args) {
|
|
479
|
-
if (args.length === 0) {
|
|
480
|
-
return new ContainerElement("row", {}, []);
|
|
481
|
-
} else if (args.length === 1) {
|
|
482
|
-
if (Array.isArray(args[0])) {
|
|
483
|
-
return new ContainerElement("row", {}, args[0]);
|
|
484
|
-
} else {
|
|
485
|
-
return new ContainerElement("row", args[0], []);
|
|
486
|
-
}
|
|
487
|
-
} else {
|
|
488
|
-
return new ContainerElement("row", args[0], args[1]);
|
|
489
|
-
}
|
|
490
|
-
}
|
|
491
|
-
function UIBox(...args) {
|
|
492
|
-
if (args.length === 0) {
|
|
493
|
-
return new ContainerElement("box", {}, []);
|
|
494
|
-
} else if (args.length === 1) {
|
|
495
|
-
if (Array.isArray(args[0])) {
|
|
496
|
-
return new ContainerElement("box", {}, args[0]);
|
|
497
|
-
} else {
|
|
498
|
-
return new ContainerElement("box", args[0], []);
|
|
499
|
-
}
|
|
500
|
-
} else {
|
|
501
|
-
return new ContainerElement("box", args[0], args[1]);
|
|
502
|
-
}
|
|
503
|
-
}
|
|
504
|
-
|
|
505
|
-
// ../worker/src/UI/UIScrollable.ts
|
|
506
|
-
var ScrollableElement = class extends ContainerElement {
|
|
507
|
-
osl = [];
|
|
508
|
-
sl = [];
|
|
509
|
-
srl = [];
|
|
510
|
-
get scrollListeners() {
|
|
511
|
-
return this.sl;
|
|
512
|
-
}
|
|
513
|
-
onScroll(callback) {
|
|
514
|
-
this.sl.push(callback);
|
|
515
|
-
return this;
|
|
516
|
-
}
|
|
517
|
-
onScrollRelease(callback) {
|
|
518
|
-
this.srl.push(callback);
|
|
519
|
-
return this;
|
|
520
|
-
}
|
|
521
|
-
onOverscroll(callback) {
|
|
522
|
-
this.osl.push(callback);
|
|
523
|
-
return this;
|
|
524
|
-
}
|
|
525
|
-
};
|
|
526
|
-
function UIScrollable(...args) {
|
|
527
|
-
if (args.length === 0) {
|
|
528
|
-
return new ScrollableElement("scrollable", {}, []);
|
|
529
|
-
} else if (args.length === 1) {
|
|
530
|
-
if (Array.isArray(args[0])) {
|
|
531
|
-
return new ScrollableElement("scrollable", {}, args[0]);
|
|
532
|
-
} else {
|
|
533
|
-
return new ScrollableElement("scrollable", args[0], []);
|
|
534
|
-
}
|
|
535
|
-
} else {
|
|
536
|
-
return new ScrollableElement("scrollable", args[0], args[1]);
|
|
537
|
-
}
|
|
538
|
-
}
|
|
539
|
-
|
|
540
|
-
// ../worker/src/UI/UIVirtualizedList.ts
|
|
541
|
-
var VListElement = class extends Element {
|
|
542
|
-
// --- читается нативкой в createUINode (copyProperty / copyNodePtr) ---
|
|
543
|
-
_overscan;
|
|
544
|
-
// -1 = "высота вьюпорта", резолвится в нативке
|
|
545
|
-
_inverted;
|
|
546
|
-
_keys = [];
|
|
547
|
-
// начальное состояние до маунта ноды
|
|
548
|
-
_estimates = [];
|
|
549
|
-
// параллельно _keys
|
|
550
|
-
_endThreshold = 0;
|
|
551
|
-
_startThreshold = 0;
|
|
552
|
-
// --- списки слушателей, нативка забирает через copyPropertyListPtr ---
|
|
553
|
-
sl = [];
|
|
554
|
-
// scroll
|
|
555
|
-
erl = [];
|
|
556
|
-
// endReached
|
|
557
|
-
strl = [];
|
|
558
|
-
// startReached
|
|
559
|
-
// --- приватное состояние JS-стороны ---
|
|
560
|
-
items = /* @__PURE__ */ new Map();
|
|
561
|
-
mounted = /* @__PURE__ */ new Map();
|
|
562
|
-
keyOf;
|
|
563
|
-
renderItem;
|
|
564
|
-
estimate;
|
|
565
|
-
constructor(config) {
|
|
566
|
-
super("vlist", {});
|
|
567
|
-
this.keyOf = config.keyOf;
|
|
568
|
-
this.renderItem = config.render;
|
|
569
|
-
this.estimate = typeof config.estimatedHeight === "function" ? config.estimatedHeight : () => config.estimatedHeight;
|
|
570
|
-
this._overscan = config.overscan ?? -1;
|
|
571
|
-
this._inverted = config.inverted ?? false;
|
|
572
|
-
}
|
|
573
|
-
get isAttached() {
|
|
574
|
-
return !!this._id && this._id !== 0;
|
|
575
|
-
}
|
|
576
|
-
register(items) {
|
|
577
|
-
const keys = [];
|
|
578
|
-
const estimates = [];
|
|
579
|
-
for (const item of items) {
|
|
580
|
-
const k = this.keyOf(item);
|
|
581
|
-
this.items.set(k, item);
|
|
582
|
-
keys.push(k);
|
|
583
|
-
estimates.push(this.estimate(item));
|
|
584
|
-
}
|
|
585
|
-
return [keys, estimates];
|
|
586
|
-
}
|
|
587
|
-
setData(items) {
|
|
588
|
-
const prevItems = new Map(this.items);
|
|
589
|
-
const prevMounted = [...this.mounted.keys()];
|
|
590
|
-
this.items.clear();
|
|
591
|
-
const [keys, estimates] = this.register(items);
|
|
592
|
-
this._keys = keys;
|
|
593
|
-
this._estimates = estimates;
|
|
594
|
-
if (this.isAttached) {
|
|
595
|
-
_creatorUI.vlistSetKeys(this, keys, estimates);
|
|
596
|
-
for (const k of prevMounted) {
|
|
597
|
-
if (this.mounted.has(k) && this.items.get(k) !== prevItems.get(k)) {
|
|
598
|
-
_creatorUI.vlistInvalidate(this, k);
|
|
599
|
-
}
|
|
600
|
-
}
|
|
601
|
-
}
|
|
602
|
-
return this;
|
|
603
|
-
}
|
|
604
|
-
append(...items) {
|
|
605
|
-
const [keys, estimates] = this.register(items);
|
|
606
|
-
this._keys.push(...keys);
|
|
607
|
-
this._estimates.push(...estimates);
|
|
608
|
-
if (this.isAttached) {
|
|
609
|
-
_creatorUI.vlistInsertKeys(this, -1, keys, estimates);
|
|
610
|
-
}
|
|
611
|
-
return this;
|
|
612
|
-
}
|
|
613
|
-
prepend(...items) {
|
|
614
|
-
const [keys, estimates] = this.register(items);
|
|
615
|
-
this._keys.unshift(...keys);
|
|
616
|
-
this._estimates.unshift(...estimates);
|
|
617
|
-
if (this.isAttached) {
|
|
618
|
-
_creatorUI.vlistInsertKeys(this, 0, keys, estimates);
|
|
619
|
-
}
|
|
620
|
-
return this;
|
|
621
|
-
}
|
|
622
|
-
update(...items) {
|
|
623
|
-
for (const item of items) {
|
|
624
|
-
const k = this.keyOf(item);
|
|
625
|
-
if (!this.items.has(k)) continue;
|
|
626
|
-
this.items.set(k, item);
|
|
627
|
-
if (this.isAttached && this.mounted.has(k)) {
|
|
628
|
-
_creatorUI.vlistInvalidate(this, k);
|
|
629
|
-
}
|
|
630
|
-
}
|
|
631
|
-
return this;
|
|
632
|
-
}
|
|
633
|
-
removeByKey(...keys) {
|
|
634
|
-
for (const k of keys) {
|
|
635
|
-
if (!this.items.delete(k)) continue;
|
|
636
|
-
const i = this._keys.indexOf(k);
|
|
637
|
-
if (i >= 0) {
|
|
638
|
-
this._keys.splice(i, 1);
|
|
639
|
-
this._estimates.splice(i, 1);
|
|
640
|
-
}
|
|
641
|
-
}
|
|
642
|
-
if (this.isAttached) {
|
|
643
|
-
_creatorUI.vlistRemoveKeys(this, keys);
|
|
644
|
-
}
|
|
645
|
-
return this;
|
|
646
|
-
}
|
|
647
|
-
get itemCount() {
|
|
648
|
-
return this.items.size;
|
|
649
|
-
}
|
|
650
|
-
getItem(key) {
|
|
651
|
-
return this.items.get(key);
|
|
652
|
-
}
|
|
653
|
-
// --- команды: офсеты и позиции знает только нативка (префикс-суммы) ---
|
|
654
|
-
scrollTo(offset, animated = true) {
|
|
655
|
-
_creatorUI.command(this, "scrollTo", offset, animated);
|
|
656
|
-
}
|
|
657
|
-
scrollToKey(key, animated = true) {
|
|
658
|
-
_creatorUI.command(this, "scrollToKey", key, animated);
|
|
659
|
-
}
|
|
660
|
-
scrollToEnd(animated = true) {
|
|
661
|
-
_creatorUI.command(this, "scrollToEnd", animated);
|
|
662
|
-
}
|
|
663
|
-
onScroll(callback) {
|
|
664
|
-
this.sl.push(callback);
|
|
665
|
-
return this;
|
|
666
|
-
}
|
|
667
|
-
onEndReached(thresholdPx, callback) {
|
|
668
|
-
this._endThreshold = thresholdPx;
|
|
669
|
-
this.erl.push(callback);
|
|
670
|
-
return this;
|
|
671
|
-
}
|
|
672
|
-
onStartReached(thresholdPx, callback) {
|
|
673
|
-
this._startThreshold = thresholdPx;
|
|
674
|
-
this.strl.push(callback);
|
|
675
|
-
return this;
|
|
676
|
-
}
|
|
677
|
-
/**
|
|
678
|
-
* Единственный колбэк из нативки (через jsPtr, как у button).
|
|
679
|
-
* Вызывается ТОЛЬКО когда окно пересекло границу — не на каждый кадр скролла.
|
|
680
|
-
* Порядок: сначала unmount (нативка уже снесла поддеревья и обнулила _id,
|
|
681
|
-
* здесь только чистим JS-ссылки), потом mount.
|
|
682
|
-
*/
|
|
683
|
-
_syncWindow(unmountKeys, mountKeys) {
|
|
684
|
-
for (const k of unmountKeys) {
|
|
685
|
-
this.mounted.delete(k);
|
|
686
|
-
}
|
|
687
|
-
for (const k of mountKeys) {
|
|
688
|
-
const item = this.items.get(k);
|
|
689
|
-
if (item === void 0) continue;
|
|
690
|
-
const node = this.renderItem(item);
|
|
691
|
-
this.mounted.set(k, node);
|
|
692
|
-
_creatorUI.vlistMount(this, k, node);
|
|
693
|
-
}
|
|
694
|
-
}
|
|
695
|
-
};
|
|
696
|
-
function UIVirtualizedList(config) {
|
|
697
|
-
return new VListElement(config);
|
|
698
|
-
}
|
|
699
|
-
|
|
700
|
-
// ../worker/src/UI/router.ts
|
|
701
|
-
var currentScreen = null;
|
|
702
|
-
var onChange = (screen) => {
|
|
703
|
-
currentScreen = screen;
|
|
704
|
-
for (let callback of Router._changeListeners) {
|
|
705
|
-
callback(screen);
|
|
706
|
-
}
|
|
707
|
-
};
|
|
708
|
-
var Router = /* @__PURE__ */ Object.freeze({
|
|
709
|
-
init(homePage, opts = {}) {
|
|
710
|
-
_creatorUI.routerOpen(homePage, onChange, opts.showDefaultBackButton ?? false);
|
|
711
|
-
currentScreen = homePage;
|
|
712
|
-
},
|
|
713
|
-
push(screen) {
|
|
714
|
-
_creatorUI.routerPush(screen);
|
|
715
|
-
},
|
|
716
|
-
replace(screen) {
|
|
717
|
-
_creatorUI.routerReplace(screen);
|
|
718
|
-
},
|
|
719
|
-
pop(to) {
|
|
720
|
-
_creatorUI.routerPop(to ?? -1);
|
|
721
|
-
},
|
|
722
|
-
hide() {
|
|
723
|
-
_creatorUI.routerHide();
|
|
724
|
-
},
|
|
725
|
-
restore() {
|
|
726
|
-
_creatorUI.routerRestore();
|
|
727
|
-
},
|
|
728
|
-
get current() {
|
|
729
|
-
return currentScreen;
|
|
730
|
-
},
|
|
731
|
-
_changeListeners: [],
|
|
732
|
-
addEventListener(channel, callback) {
|
|
733
|
-
if (channel === "change") {
|
|
734
|
-
this._changeListeners.push(callback);
|
|
735
|
-
}
|
|
736
|
-
},
|
|
737
|
-
removeEventListener(channel, callback) {
|
|
738
|
-
if (channel === "change") {
|
|
739
|
-
let index = this._changeListeners.indexOf(callback);
|
|
740
|
-
if (index >= 0) {
|
|
741
|
-
this._changeListeners.splice(index, 1);
|
|
742
|
-
}
|
|
743
|
-
}
|
|
744
|
-
}
|
|
745
|
-
});
|
|
746
|
-
export {
|
|
747
|
-
Router,
|
|
748
|
-
UIBox,
|
|
749
|
-
UIButton,
|
|
750
|
-
UIColumn,
|
|
751
|
-
UIImage,
|
|
752
|
-
UIInput,
|
|
753
|
-
UIRow,
|
|
754
|
-
UIScreen,
|
|
755
|
-
UIScrollable,
|
|
756
|
-
UISpacer,
|
|
757
|
-
UIText,
|
|
758
|
-
UITextArea,
|
|
759
|
-
UIVideo,
|
|
760
|
-
UIVirtualizedList,
|
|
761
|
-
UIWidget,
|
|
762
|
-
registerFont
|
|
763
|
-
};
|