@mulsense/xnew 0.1.2 → 0.1.4

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/xnew.js CHANGED
@@ -4,6 +4,23 @@
4
4
  (global = typeof globalThis !== 'undefined' ? globalThis : global || self, global.xnew = factory());
5
5
  })(this, (function () { 'use strict';
6
6
 
7
+ function ResizeEvent(resize) {
8
+ const observer = new ResizeObserver((entries) => {
9
+ for (const entry of entries) {
10
+ resize.emit('-resize');
11
+ break;
12
+ }
13
+ });
14
+ if (resize.element) {
15
+ observer.observe(resize.element);
16
+ }
17
+ resize.on('finalize', () => {
18
+ if (resize.element) {
19
+ observer.unobserve(resize.element);
20
+ }
21
+ });
22
+ }
23
+
7
24
  //----------------------------------------------------------------------------------------------------
8
25
  // ticker
9
26
  //----------------------------------------------------------------------------------------------------
@@ -206,22 +223,38 @@
206
223
  }
207
224
 
208
225
  //----------------------------------------------------------------------------------------------------
209
- // Definitions
226
+ // Utils
210
227
  //----------------------------------------------------------------------------------------------------
211
228
  const SYSTEM_EVENTS = ['start', 'update', 'stop', 'finalize'];
229
+ class UnitPromise {
230
+ constructor(promise) {
231
+ this.promise = promise;
232
+ }
233
+ then(callback) {
234
+ this.promise = this.promise.then(Unit.wrap(Unit.current, callback));
235
+ return this;
236
+ }
237
+ catch(callback) {
238
+ this.promise = this.promise.catch(Unit.wrap(Unit.current, callback));
239
+ return this;
240
+ }
241
+ finally(callback) {
242
+ this.promise = this.promise.finally(Unit.wrap(Unit.current, callback));
243
+ return this;
244
+ }
245
+ }
212
246
  //----------------------------------------------------------------------------------------------------
213
247
  // Unit
214
248
  //----------------------------------------------------------------------------------------------------
215
249
  class Unit {
216
- constructor(target, component, props) {
217
- var _a, _b, _c;
218
- const parent = UnitScope.current;
250
+ constructor(parent, target, component, props) {
251
+ var _a;
219
252
  let baseElement;
220
253
  if (target instanceof HTMLElement || target instanceof SVGElement) {
221
254
  baseElement = target;
222
255
  }
223
256
  else if (parent !== null) {
224
- baseElement = (_a = parent._.currentElement) !== null && _a !== void 0 ? _a : parent._.baseElement;
257
+ baseElement = parent._.currentElement;
225
258
  }
226
259
  else {
227
260
  baseElement = document.body;
@@ -236,20 +269,17 @@
236
269
  else {
237
270
  baseComponent = (self) => { };
238
271
  }
239
- this._ = {
240
- parent,
241
- target,
242
- baseContext: (_b = UnitScope.contexts.get(parent)) !== null && _b !== void 0 ? _b : null,
243
- baseElement,
244
- baseComponent,
245
- props,
246
- };
247
- ((_c = parent === null || parent === void 0 ? void 0 : parent._.children) !== null && _c !== void 0 ? _c : Unit.roots).push(this);
248
- Unit.initialize(this, { element: baseElement, position: 'beforeend' });
272
+ const baseContext = (_a = parent === null || parent === void 0 ? void 0 : parent._.currentContext) !== null && _a !== void 0 ? _a : { stack: null };
273
+ this._ = { parent, target, baseElement, baseContext, baseComponent, props };
274
+ parent === null || parent === void 0 ? void 0 : parent._.children.push(this);
275
+ Unit.initialize(this, null);
249
276
  }
250
277
  get element() {
251
278
  return this._.currentElement;
252
279
  }
280
+ get components() {
281
+ return this._.components;
282
+ }
253
283
  start() {
254
284
  this._.tostart = true;
255
285
  }
@@ -263,88 +293,66 @@
263
293
  if (this._.parent) {
264
294
  this._.parent._.children = this._.parent._.children.filter((unit) => unit !== this);
265
295
  }
266
- else {
267
- Unit.roots = Unit.roots.filter((unit) => unit !== this);
268
- }
269
296
  }
270
297
  reboot() {
298
+ var _a, _b;
271
299
  Unit.stop(this);
272
- let first = this._.currentElement;
273
- while (first.parentElement && first.parentElement !== this._.baseElement) {
274
- first = first.parentElement;
275
- }
276
- let nextNest;
277
- if (first.parentElement === this._.baseElement && first.nextElementSibling) {
278
- nextNest = { element: first.nextElementSibling, position: 'beforebegin' };
279
- }
280
- else {
281
- nextNest = { element: this._.baseElement, position: 'beforeend' };
282
- }
300
+ const anchorElement = (_b = (_a = this._.elements[0]) === null || _a === void 0 ? void 0 : _a.nextElementSibling) !== null && _b !== void 0 ? _b : null;
283
301
  Unit.finalize(this);
284
- Unit.initialize(this, nextNest);
302
+ Unit.initialize(this, anchorElement);
285
303
  }
286
- static initialize(unit, nextNest) {
287
- var _a;
304
+ static initialize(unit, anchor) {
305
+ const backup = Unit.current;
306
+ Unit.current = unit;
288
307
  unit._ = Object.assign(unit._, {
289
- nextNest,
290
- children: [],
291
- components: new Set(),
292
- listeners: new MapMap(),
293
- sublisteners: new MapMap(),
294
- captures: [],
308
+ currentElement: unit._.baseElement,
309
+ currentContext: unit._.baseContext,
310
+ anchor,
295
311
  state: 'invoked',
296
312
  tostart: true,
297
- currentElement: unit._.baseElement,
313
+ children: [],
314
+ elements: [],
315
+ promises: [],
316
+ captures: [],
317
+ components: [],
318
+ listeners1: new MapMap(),
319
+ listeners2: new MapMap(),
298
320
  defines: {},
299
- system: { start: [], update: [], stop: [], finalize: [] },
321
+ systems: { start: [], update: [], stop: [], finalize: [] },
300
322
  });
301
- UnitScope.initialize(unit, unit._.baseContext);
302
323
  // nest html element
303
324
  if (typeof unit._.target === 'string') {
304
325
  Unit.nest(unit, unit._.target);
305
326
  }
306
327
  // setup component
307
- if (typeof unit._.baseComponent === 'function') {
308
- UnitScope.execute({ unit, context: null, element: null }, () => Unit.extend(unit, unit._.baseComponent, unit._.props));
309
- }
328
+ Unit.extend(unit, unit._.baseComponent, unit._.props);
310
329
  // whether the unit promise was resolved
311
- (_a = UnitPromise.get(unit)) === null || _a === void 0 ? void 0 : _a.then(() => unit._.state = 'initialized');
330
+ Promise.all(unit._.promises).then(() => unit._.state = 'initialized');
312
331
  // setup capture
313
- let current = unit;
314
- while (1) {
315
- let captured = false;
332
+ let captured = false;
333
+ for (let current = unit; current !== null && captured === false; current = current._.parent) {
316
334
  for (const capture of current._.captures) {
317
335
  if (capture.checker(unit)) {
318
336
  capture.execute(unit);
319
337
  captured = true;
320
338
  }
321
339
  }
322
- if (captured === false && current._.parent !== null) {
323
- current = current._.parent;
324
- }
325
- else {
326
- break;
327
- }
328
340
  }
341
+ Unit.current = backup;
329
342
  }
330
343
  static finalize(unit) {
331
344
  if (unit._.state !== 'finalized' && unit._.state !== 'pre-finalized') {
332
345
  unit._.state = 'pre-finalized';
333
346
  unit._.children.forEach((child) => child.finalize());
334
- unit._.system.finalize.forEach((listener) => {
335
- UnitScope.execute(UnitScope.snapshot(unit), listener);
336
- });
347
+ unit._.systems.finalize.forEach((listener) => Unit.scope(Unit.snapshot(unit), listener));
337
348
  unit.off();
338
349
  Unit.suboff(unit, null);
339
350
  unit._.components.forEach((component) => {
340
351
  Unit.componentUnits.delete(component, unit);
341
352
  });
342
- UnitScope.finalize(unit);
343
- UnitPromise.finalize(unit);
344
- while (unit._.currentElement !== unit._.baseElement && unit._.currentElement.parentElement !== null) {
345
- const parent = unit._.currentElement.parentElement;
346
- parent.removeChild(unit._.currentElement);
347
- unit._.currentElement = parent;
353
+ if (unit._.elements.length > 0) {
354
+ unit._.baseElement.removeChild(unit._.elements[0]);
355
+ unit._.currentElement = unit._.baseElement;
348
356
  }
349
357
  // reset defines
350
358
  Object.keys(unit._.defines).forEach((key) => {
@@ -360,22 +368,26 @@
360
368
  const match = tag.match(/<((\w+)[^>]*?)\/?>/);
361
369
  if (match !== null) {
362
370
  let element;
363
- unit._.nextNest.element.insertAdjacentHTML(unit._.nextNest.position, `<${match[1]}></${match[2]}>`);
364
- if (unit._.nextNest.position === 'beforebegin') {
365
- element = unit._.nextNest.element.previousElementSibling;
371
+ if (unit._.anchor !== null) {
372
+ unit._.anchor.insertAdjacentHTML('beforebegin', `<${match[1]}></${match[2]}>`);
373
+ element = unit._.anchor.previousElementSibling;
374
+ unit._.anchor = null;
366
375
  }
367
376
  else {
368
- element = unit.element.children[unit.element.children.length - 1];
377
+ unit._.currentElement.insertAdjacentHTML('beforeend', `<${match[1]}></${match[2]}>`);
378
+ element = unit._.currentElement.children[unit._.currentElement.children.length - 1];
369
379
  }
370
- unit._.nextNest.element = element;
371
- unit._.nextNest.position = 'beforeend';
372
380
  unit._.currentElement = element;
381
+ unit._.elements.push(element);
382
+ return element;
383
+ }
384
+ else {
385
+ throw new Error(`Invalid tag: ${tag}`);
373
386
  }
374
- return unit.element;
375
387
  }
376
388
  static extend(unit, component, props) {
377
389
  var _a;
378
- unit._.components.add(component);
390
+ unit._.components.push(component);
379
391
  Unit.componentUnits.add(component, unit);
380
392
  const defines = (_a = component(unit, props)) !== null && _a !== void 0 ? _a : {};
381
393
  Object.keys(defines).forEach((key) => {
@@ -385,13 +397,13 @@
385
397
  const descriptor = Object.getOwnPropertyDescriptor(defines, key);
386
398
  const wrappedDesc = { configurable: true, enumerable: true };
387
399
  if (descriptor === null || descriptor === void 0 ? void 0 : descriptor.get) {
388
- wrappedDesc.get = UnitScope.wrap(descriptor.get);
400
+ wrappedDesc.get = Unit.wrap(unit, descriptor.get);
389
401
  }
390
402
  if (descriptor === null || descriptor === void 0 ? void 0 : descriptor.set) {
391
- wrappedDesc.set = UnitScope.wrap(descriptor.set);
403
+ wrappedDesc.set = Unit.wrap(unit, descriptor.set);
392
404
  }
393
405
  if (typeof (descriptor === null || descriptor === void 0 ? void 0 : descriptor.value) === 'function') {
394
- wrappedDesc.value = UnitScope.wrap(descriptor.value);
406
+ wrappedDesc.value = Unit.wrap(unit, descriptor.value);
395
407
  }
396
408
  else if ((descriptor === null || descriptor === void 0 ? void 0 : descriptor.value) !== undefined) {
397
409
  wrappedDesc.writable = true;
@@ -407,9 +419,7 @@
407
419
  if (unit._.state === 'initialized' || unit._.state === 'stopped') {
408
420
  unit._.state = 'started';
409
421
  unit._.children.forEach((child) => Unit.start(child, time));
410
- unit._.system.start.forEach((listener) => {
411
- UnitScope.execute(UnitScope.snapshot(unit), listener);
412
- });
422
+ unit._.systems.start.forEach((listener) => Unit.scope(Unit.snapshot(unit), listener));
413
423
  }
414
424
  else if (unit._.state === 'started') {
415
425
  unit._.children.forEach((child) => Unit.start(child, time));
@@ -419,33 +429,66 @@
419
429
  if (unit._.state === 'started') {
420
430
  unit._.state = 'stopped';
421
431
  unit._.children.forEach((child) => Unit.stop(child));
422
- unit._.system.stop.forEach((listener) => {
423
- UnitScope.execute(UnitScope.snapshot(unit), listener);
424
- });
432
+ unit._.systems.stop.forEach((listener) => Unit.scope(Unit.snapshot(unit), listener));
425
433
  }
426
434
  }
427
435
  static update(unit, time) {
428
436
  if (unit._.state === 'started') {
429
437
  unit._.children.forEach((child) => Unit.update(child, time));
430
- unit._.system.update.forEach((listener) => {
431
- UnitScope.execute(UnitScope.snapshot(unit), listener);
432
- });
438
+ unit._.systems.update.forEach((listener) => Unit.scope(Unit.snapshot(unit), listener));
433
439
  }
434
440
  }
435
441
  static ticker(time) {
436
- Unit.roots.forEach((unit) => {
437
- Unit.start(unit, time);
438
- Unit.update(unit, time);
439
- });
442
+ if (Unit.root !== null) {
443
+ Unit.start(Unit.root, time);
444
+ Unit.update(Unit.root, time);
445
+ }
440
446
  }
441
447
  static reset() {
442
- Unit.roots.forEach((unit) => unit.finalize());
443
- Unit.roots = [];
448
+ var _a;
449
+ (_a = Unit.root) === null || _a === void 0 ? void 0 : _a.finalize();
450
+ Unit.root = new Unit(null, null);
451
+ Unit.current = Unit.root;
444
452
  Ticker.clear(Unit.ticker);
445
453
  Ticker.set(Unit.ticker);
446
454
  }
447
- get components() {
448
- return this._.components;
455
+ //----------------------------------------------------------------------------------------------------
456
+ // scope
457
+ //----------------------------------------------------------------------------------------------------
458
+ static wrap(unit, listener) {
459
+ const snapshot = Unit.snapshot(unit);
460
+ return (...args) => Unit.scope(snapshot, listener, ...args);
461
+ }
462
+ static scope(snapshot, func, ...args) {
463
+ const current = Unit.current;
464
+ const backup = Unit.snapshot(snapshot.unit);
465
+ try {
466
+ Unit.current = snapshot.unit;
467
+ snapshot.unit._.currentContext = snapshot.context;
468
+ snapshot.unit._.currentElement = snapshot.element;
469
+ return func(...args);
470
+ }
471
+ catch (error) {
472
+ throw error;
473
+ }
474
+ finally {
475
+ Unit.current = current;
476
+ snapshot.unit._.currentContext = backup.context;
477
+ snapshot.unit._.currentElement = backup.element;
478
+ }
479
+ }
480
+ static snapshot(unit) {
481
+ return { unit, context: unit._.currentContext, element: unit._.currentElement };
482
+ }
483
+ static stack(unit, key, value) {
484
+ unit._.currentContext = { stack: unit._.currentContext, key, value };
485
+ }
486
+ static trace(unit, key) {
487
+ for (let context = unit._.currentContext; context !== null; context = context.stack) {
488
+ if (context.key === key) {
489
+ return context.value;
490
+ }
491
+ }
449
492
  }
450
493
  static find(component) {
451
494
  var _a;
@@ -456,11 +499,11 @@
456
499
  return;
457
500
  type.trim().split(/\s+/).forEach((type) => {
458
501
  if (SYSTEM_EVENTS.includes(type)) {
459
- this._.system[type].push(listener);
502
+ this._.systems[type].push(listener);
460
503
  }
461
- if (this._.listeners.has(type, listener) === false) {
462
- const execute = UnitScope.wrap(listener);
463
- this._.listeners.set(type, listener, [this.element, execute]);
504
+ if (this._.listeners1.has(type, listener) === false) {
505
+ const execute = Unit.wrap(this, listener);
506
+ this._.listeners1.set(type, listener, [this.element, execute]);
464
507
  Unit.typeUnits.add(type, this);
465
508
  if (/^[A-Za-z]/.test(type)) {
466
509
  this.element.addEventListener(type, execute, options);
@@ -469,22 +512,22 @@
469
512
  });
470
513
  }
471
514
  off(type, listener) {
472
- const types = typeof type === 'string' ? type.trim().split(/\s+/) : [...this._.listeners.keys()];
515
+ const types = typeof type === 'string' ? type.trim().split(/\s+/) : [...this._.listeners1.keys()];
473
516
  types.forEach((type) => {
474
517
  if (SYSTEM_EVENTS.includes(type)) {
475
- this._.system[type] = this._.system[type].filter((lis) => listener ? lis !== listener : false);
518
+ this._.systems[type] = this._.systems[type].filter((lis) => listener ? lis !== listener : false);
476
519
  }
477
- (listener ? [listener] : [...this._.listeners.keys(type)]).forEach((lis) => {
478
- const tuple = this._.listeners.get(type, lis);
520
+ (listener ? [listener] : [...this._.listeners1.keys(type)]).forEach((lis) => {
521
+ const tuple = this._.listeners1.get(type, lis);
479
522
  if (tuple !== undefined) {
480
523
  const [target, execute] = tuple;
481
- this._.listeners.delete(type, lis);
524
+ this._.listeners1.delete(type, lis);
482
525
  if (/^[A-Za-z]/.test(type)) {
483
526
  target.removeEventListener(type, execute);
484
527
  }
485
528
  }
486
529
  });
487
- if (this._.listeners.has(type) === false) {
530
+ if (this._.listeners1.has(type) === false) {
488
531
  Unit.typeUnits.delete(type, this);
489
532
  }
490
533
  });
@@ -496,31 +539,31 @@
496
539
  if (type[0] === '+') {
497
540
  (_a = Unit.typeUnits.get(type)) === null || _a === void 0 ? void 0 : _a.forEach((unit) => {
498
541
  var _a;
499
- (_a = unit._.listeners.get(type)) === null || _a === void 0 ? void 0 : _a.forEach(([_, execute]) => execute(...args));
542
+ (_a = unit._.listeners1.get(type)) === null || _a === void 0 ? void 0 : _a.forEach(([_, execute]) => execute(...args));
500
543
  });
501
544
  }
502
545
  else if (type[0] === '-') {
503
- (_b = this._.listeners.get(type)) === null || _b === void 0 ? void 0 : _b.forEach(([_, execute]) => execute(...args));
546
+ (_b = this._.listeners1.get(type)) === null || _b === void 0 ? void 0 : _b.forEach(([_, execute]) => execute(...args));
504
547
  }
505
548
  }
506
549
  static subon(unit, target, type, listener, options) {
507
550
  type.trim().split(/\s+/).forEach((type) => {
508
- if (unit._.sublisteners.has(type, listener) === false) {
509
- const execute = UnitScope.wrap(listener);
510
- unit._.sublisteners.set(type, listener, [target, execute]);
551
+ if (unit._.listeners2.has(type, listener) === false) {
552
+ const execute = Unit.wrap(unit, listener);
553
+ unit._.listeners2.set(type, listener, [target, execute]);
511
554
  target.addEventListener(type, execute, options);
512
555
  }
513
556
  });
514
557
  }
515
558
  static suboff(unit, target, type, listener) {
516
- const types = typeof type === 'string' ? type.trim().split(/\s+/) : [...unit._.sublisteners.keys()];
559
+ const types = typeof type === 'string' ? type.trim().split(/\s+/) : [...unit._.listeners2.keys()];
517
560
  types.forEach((type) => {
518
- (listener ? [listener] : [...unit._.sublisteners.keys(type)]).forEach((lis) => {
519
- const tuple = unit._.sublisteners.get(type, lis);
561
+ (listener ? [listener] : [...unit._.listeners2.keys(type)]).forEach((lis) => {
562
+ const tuple = unit._.listeners2.get(type, lis);
520
563
  if (tuple !== undefined) {
521
564
  const [element, execute] = tuple;
522
565
  if (target === null || target === element) {
523
- unit._.sublisteners.delete(type, lis);
566
+ unit._.listeners2.delete(type, lis);
524
567
  element.removeEventListener(type, execute);
525
568
  }
526
569
  }
@@ -528,406 +571,230 @@
528
571
  });
529
572
  }
530
573
  }
531
- Unit.roots = [];
532
- //----------------------------------------------------------------------------------------------------
533
- // component
534
- //----------------------------------------------------------------------------------------------------
574
+ Unit.root = null;
535
575
  Unit.componentUnits = new MapSet();
536
576
  //----------------------------------------------------------------------------------------------------
537
577
  // event
538
578
  //----------------------------------------------------------------------------------------------------
539
579
  Unit.typeUnits = new MapSet();
540
580
  Unit.reset();
541
- //----------------------------------------------------------------------------------------------------
542
- // unit scope
543
- //----------------------------------------------------------------------------------------------------
544
- class UnitScope {
545
- static initialize(unit, context) {
546
- if (context !== null) {
547
- UnitScope.contexts.set(unit, context);
581
+
582
+ const xnew$1 = function (...args) {
583
+ let target;
584
+ if (args[0] instanceof HTMLElement || args[0] instanceof SVGElement) {
585
+ target = args.shift(); // an existing html element
586
+ }
587
+ else if (typeof args[0] === 'string') {
588
+ const str = args.shift(); // a selector for an existing html element
589
+ if (str.match(/<([^>]*)\/?>/)) {
590
+ target = str;
591
+ }
592
+ else {
593
+ target = document.querySelector(str);
594
+ if (target == null) {
595
+ throw new Error(`'${str}' can not be found.`);
596
+ }
548
597
  }
549
598
  }
550
- static finalize(unit) {
551
- UnitScope.contexts.delete(unit);
599
+ else {
600
+ target = null;
552
601
  }
553
- static wrap(listener) {
554
- const snapshot = UnitScope.snapshot();
555
- return (...args) => UnitScope.execute(snapshot, listener, ...args);
602
+ return new Unit(Unit.current, target, ...args);
603
+ };
604
+ xnew$1.nest = (tag) => {
605
+ var _a;
606
+ if (((_a = Unit.current) === null || _a === void 0 ? void 0 : _a._.state) === 'invoked') {
607
+ return Unit.nest(Unit.current, tag);
556
608
  }
557
- static execute(snapshot, func, ...args) {
558
- var _a;
559
- if (snapshot === null)
560
- return;
561
- const current = UnitScope.current;
562
- let context = null;
563
- let element = null;
564
- try {
565
- UnitScope.current = snapshot.unit;
566
- if (snapshot.unit !== null) {
567
- if (snapshot.context !== null) {
568
- context = (_a = UnitScope.contexts.get(snapshot.unit)) !== null && _a !== void 0 ? _a : null;
569
- UnitScope.contexts.set(snapshot.unit, snapshot.context);
570
- }
571
- if (snapshot.element !== null) {
572
- element = snapshot.unit._.currentElement;
573
- snapshot.unit._.currentElement = snapshot.element;
574
- }
575
- }
576
- return func(...args);
577
- }
578
- catch (error) {
579
- throw error;
609
+ else {
610
+ throw new Error('This function can not be called after initialized.');
611
+ }
612
+ };
613
+ xnew$1.extend = (component, props) => {
614
+ var _a;
615
+ if (((_a = Unit.current) === null || _a === void 0 ? void 0 : _a._.state) === 'invoked') {
616
+ return Unit.extend(Unit.current, component, props);
617
+ }
618
+ else {
619
+ throw new Error('This function can not be called after initialized.');
620
+ }
621
+ };
622
+ xnew$1.context = (key, value = undefined) => {
623
+ try {
624
+ if (value !== undefined) {
625
+ Unit.stack(Unit.current, key, value);
580
626
  }
581
- finally {
582
- UnitScope.current = current;
583
- if (snapshot.unit !== null) {
584
- if (context !== null) {
585
- UnitScope.contexts.set(snapshot.unit, context);
586
- }
587
- if (element !== null) {
588
- snapshot.unit._.currentElement = element;
589
- }
590
- }
627
+ else {
628
+ return Unit.trace(Unit.current, key);
591
629
  }
592
630
  }
593
- static snapshot(unit = UnitScope.current) {
594
- var _a;
595
- if (unit !== null) {
596
- return { unit, context: (_a = UnitScope.contexts.get(unit)) !== null && _a !== void 0 ? _a : null, element: unit.element };
597
- }
598
- return null;
631
+ catch (error) {
632
+ console.error('xnew.context(key, value?): ', error);
599
633
  }
600
- static stack(unit, key, value) {
601
- var _a;
602
- UnitScope.contexts.set(unit, { stack: (_a = UnitScope.contexts.get(unit)) !== null && _a !== void 0 ? _a : null, key, value });
634
+ };
635
+ xnew$1.promise = (promise) => {
636
+ try {
637
+ Unit.current._.promises.push(promise);
638
+ return new UnitPromise(promise);
603
639
  }
604
- static trace(unit, key) {
605
- var _a;
606
- for (let context = (_a = UnitScope.contexts.get(unit)) !== null && _a !== void 0 ? _a : null; context !== null; context = context.stack) {
607
- if (context.key === key) {
608
- return context.value;
609
- }
610
- }
640
+ catch (error) {
641
+ console.error('xnew.promise(mix): ', error);
642
+ throw error;
611
643
  }
612
- }
613
- UnitScope.current = null;
614
- UnitScope.contexts = new Map();
615
- //----------------------------------------------------------------------------------------------------
616
- // unit promise
617
- //----------------------------------------------------------------------------------------------------
618
- class UnitPromise {
619
- constructor(executor) {
620
- this.promise = new Promise(executor);
644
+ };
645
+ xnew$1.then = (callback) => {
646
+ try {
647
+ return new UnitPromise(Promise.all(Unit.current._.promises)).then(callback);
621
648
  }
622
- then(callback) {
623
- this.promise = this.promise.then(UnitScope.wrap(callback));
624
- return this;
649
+ catch (error) {
650
+ console.error('xnew.then(mix): ', error);
651
+ throw error;
625
652
  }
626
- catch(callback) {
627
- this.promise = this.promise.catch(UnitScope.wrap(callback));
628
- return this;
653
+ };
654
+ xnew$1.catch = (callback) => {
655
+ try {
656
+ return new UnitPromise(Promise.all(Unit.current._.promises)).catch(callback);
629
657
  }
630
- finally(callback) {
631
- this.promise = this.promise.finally(UnitScope.wrap(callback));
632
- return this;
658
+ catch (error) {
659
+ console.error('xnew.catch(mix): ', error);
660
+ throw error;
633
661
  }
634
- static get(unit) {
635
- var _a;
636
- return Promise.all([...((_a = UnitPromise.promises.get(unit)) !== null && _a !== void 0 ? _a : [])].map((unitPromise) => unitPromise.promise));
662
+ };
663
+ xnew$1.finally = (callback) => {
664
+ try {
665
+ return new UnitPromise(Promise.all(Unit.current._.promises)).finally(callback);
637
666
  }
638
- static finalize(unit) {
639
- UnitPromise.promises.delete(unit);
667
+ catch (error) {
668
+ console.error('xnew.finally(mix): ', error);
669
+ throw error;
640
670
  }
641
- static execute(unit, promise) {
642
- const inner = promise !== null && promise !== void 0 ? promise : UnitPromise.get(unit);
643
- const unitPromise = new UnitPromise((resolve, reject) => {
644
- inner.then((...args) => resolve(...args)).catch((...args) => reject(...args));
645
- });
646
- if (promise !== undefined) {
647
- UnitPromise.promises.add(unit, unitPromise);
671
+ };
672
+ xnew$1.fetch = (url, options) => {
673
+ try {
674
+ const promise = fetch(url, options);
675
+ Unit.current._.promises.push(promise);
676
+ return new UnitPromise(promise);
677
+ }
678
+ catch (error) {
679
+ console.error('xnew.promise(mix): ', error);
680
+ throw error;
681
+ }
682
+ };
683
+ xnew$1.scope = (callback) => {
684
+ const snapshot = Unit.snapshot(Unit.current);
685
+ return (...args) => Unit.scope(snapshot, callback, ...args);
686
+ };
687
+ xnew$1.find = (component) => {
688
+ if (typeof component === 'function') {
689
+ return Unit.find(component);
690
+ }
691
+ else {
692
+ throw new Error(`The argument [component] is invalid.`);
693
+ }
694
+ };
695
+ xnew$1.append = (base, ...args) => {
696
+ if (typeof base === 'function') {
697
+ for (let unit of Unit.find(base)) {
698
+ Unit.scope(Unit.snapshot(unit), xnew$1, ...args);
648
699
  }
649
- return unitPromise;
650
700
  }
651
- }
652
- UnitPromise.promises = new MapSet();
653
-
654
- const xnew$1 = (() => {
655
- const fn = function (...args) {
656
- let target;
657
- if (args[0] instanceof HTMLElement || args[0] instanceof SVGElement) {
658
- target = args.shift(); // an existing html element
659
- }
660
- else if (typeof args[0] === 'string') {
661
- const str = args.shift(); // a selector for an existing html element
662
- if (str.match(/<([^>]*)\/?>/)) {
663
- target = str;
664
- }
665
- else {
666
- target = document.querySelector(str);
667
- if (target == null) {
668
- throw new Error(`'${str}' can not be found.`);
701
+ else if (base instanceof Unit) {
702
+ Unit.scope(Unit.snapshot(base), xnew$1, ...args);
703
+ }
704
+ else {
705
+ throw new Error(`The argument [component] is invalid.`);
706
+ }
707
+ };
708
+ xnew$1.timeout = (callback, delay) => {
709
+ const snapshot = Unit.snapshot(Unit.current);
710
+ const unit = xnew$1((self) => {
711
+ const timer = new Timer(() => {
712
+ Unit.scope(snapshot, callback);
713
+ self.finalize();
714
+ }, null, delay);
715
+ self.on('finalize', () => {
716
+ timer.clear();
717
+ });
718
+ });
719
+ return { clear: () => unit.finalize() };
720
+ };
721
+ xnew$1.interval = (callback, delay) => {
722
+ const snapshot = Unit.snapshot(Unit.current);
723
+ const unit = xnew$1((self) => {
724
+ const timer = new Timer(() => {
725
+ Unit.scope(snapshot, callback);
726
+ }, null, delay, true);
727
+ self.on('finalize', () => {
728
+ timer.clear();
729
+ });
730
+ });
731
+ return { clear: () => unit.finalize() };
732
+ };
733
+ xnew$1.transition = (callback, interval, easing = 'linear') => {
734
+ const snapshot = Unit.snapshot(Unit.current);
735
+ let stacks = [];
736
+ let unit = xnew$1(Local, { callback, interval, easing });
737
+ let isRunning = true;
738
+ function Local(self, { callback, interval, easing }) {
739
+ const timer = new Timer(() => {
740
+ Unit.scope(snapshot, callback, 1.0);
741
+ self.finalize();
742
+ }, (progress) => {
743
+ if (progress < 1.0) {
744
+ if (easing === 'ease-out') {
745
+ progress = Math.pow((1.0 - Math.pow((1.0 - progress), 2.0)), 0.5);
669
746
  }
670
- }
671
- }
672
- else {
673
- target = null;
674
- }
675
- const unit = new Unit(target, ...args);
676
- return unit;
677
- };
678
- fn.nest = (tag) => {
679
- const current = UnitScope.current;
680
- if ((current === null || current === void 0 ? void 0 : current._.state) === 'invoked') {
681
- const element = Unit.nest(current, tag);
682
- if (element instanceof HTMLElement || element instanceof SVGElement) {
683
- return element;
684
- }
685
- else {
686
- throw new Error('');
687
- }
688
- }
689
- else {
690
- throw new Error('This function can not be called after initialized.');
691
- }
692
- };
693
- fn.extend = (component, props) => {
694
- const current = UnitScope.current;
695
- if ((current === null || current === void 0 ? void 0 : current._.state) === 'invoked') {
696
- return Unit.extend(current, component, props);
697
- }
698
- else {
699
- throw new Error('This function can not be called after initialized.');
700
- }
701
- };
702
- fn.context = (key, value = undefined) => {
703
- try {
704
- const unit = UnitScope.current;
705
- if (typeof key !== 'string') {
706
- throw new Error('The argument [key] is invalid.');
707
- }
708
- else if (unit !== null) {
709
- if (value !== undefined) {
710
- UnitScope.stack(unit, key, value);
747
+ else if (easing === 'ease-in') {
748
+ progress = Math.pow((1.0 - Math.pow((1.0 - progress), 0.5)), 2.0);
711
749
  }
712
- else {
713
- return UnitScope.trace(unit, key);
750
+ else if (easing === 'ease') {
751
+ progress = (1.0 - Math.cos(progress * Math.PI)) / 2.0;
714
752
  }
715
- }
716
- else {
717
- return undefined;
718
- }
719
- }
720
- catch (error) {
721
- console.error('xnew.context(key, value?): ', error);
722
- }
723
- };
724
- fn.promise = (promise) => {
725
- try {
726
- if (UnitScope.current !== null) {
727
- return UnitPromise.execute(UnitScope.current, promise);
728
- }
729
- else {
730
- throw new Error('No current unit.');
731
- }
732
- }
733
- catch (error) {
734
- console.error('xnew.promise(mix): ', error);
735
- throw error;
736
- }
737
- };
738
- fn.then = (callback) => {
739
- try {
740
- if (UnitScope.current !== null) {
741
- return UnitPromise.execute(UnitScope.current).then(callback);
742
- }
743
- else {
744
- throw new Error('No current unit.');
745
- }
746
- }
747
- catch (error) {
748
- console.error('xnew.then(mix): ', error);
749
- throw error;
750
- }
751
- };
752
- fn.catch = (callback) => {
753
- try {
754
- if (UnitScope.current !== null) {
755
- return UnitPromise.execute(UnitScope.current).catch(callback);
756
- }
757
- else {
758
- throw new Error('No current unit.');
759
- }
760
- }
761
- catch (error) {
762
- console.error('xnew.catch(mix): ', error);
763
- throw error;
764
- }
765
- };
766
- fn.finally = (callback) => {
767
- try {
768
- if (UnitScope.current !== null) {
769
- return UnitPromise.execute(UnitScope.current).finally(callback);
770
- }
771
- else {
772
- throw new Error('No current unit.');
773
- }
774
- }
775
- catch (error) {
776
- console.error('xnew.finally(mix): ', error);
777
- throw error;
778
- }
779
- };
780
- fn.fetch = (url, options) => {
781
- try {
782
- const promise = fetch(url, options);
783
- if (UnitScope.current !== null) {
784
- return UnitPromise.execute(UnitScope.current, promise);
785
- }
786
- else {
787
- throw new Error('No current unit.');
788
- }
789
- }
790
- catch (error) {
791
- console.error('xnew.promise(mix): ', error);
792
- throw error;
793
- }
794
- };
795
- fn.scope = (callback) => {
796
- const snapshot = UnitScope.snapshot();
797
- return (...args) => UnitScope.execute(snapshot, callback, ...args);
798
- };
799
- fn.find = (component) => {
800
- if (typeof component === 'function') {
801
- return Unit.find(component);
802
- }
803
- else {
804
- throw new Error(`The argument [component] is invalid.`);
805
- }
806
- };
807
- fn.append = (base, ...args) => {
808
- if (typeof base === 'function') {
809
- for (let unit of Unit.find(base)) {
810
- UnitScope.execute(UnitScope.snapshot(unit), xnew$1, ...args);
811
- }
812
- }
813
- else if (base instanceof Unit) {
814
- UnitScope.execute(UnitScope.snapshot(base), xnew$1, ...args);
815
- }
816
- else {
817
- throw new Error(`The argument [component] is invalid.`);
818
- }
819
- };
820
- fn.timeout = (callback, delay) => {
821
- const snapshot = UnitScope.snapshot();
822
- const unit = xnew$1((self) => {
823
- const timer = new Timer(() => {
824
- UnitScope.execute(snapshot, callback);
825
- self.finalize();
826
- }, null, delay);
827
- self.on('finalize', () => {
828
- timer.clear();
829
- });
830
- });
831
- return { clear: () => unit.finalize() };
832
- };
833
- fn.interval = (callback, delay) => {
834
- const snapshot = UnitScope.snapshot();
835
- const unit = xnew$1((self) => {
836
- const timer = new Timer(() => {
837
- UnitScope.execute(snapshot, callback);
838
- }, null, delay, true);
839
- self.on('finalize', () => {
840
- timer.clear();
841
- });
842
- });
843
- return { clear: () => unit.finalize() };
844
- };
845
- fn.transition = (callback, interval, easing = 'linear') => {
846
- const snapshot = UnitScope.snapshot();
847
- let stacks = [];
848
- let unit = xnew$1(Local, { callback, interval, easing });
849
- let isRunning = true;
850
- function Local(self, { callback, interval, easing }) {
851
- const timer = new Timer(() => {
852
- UnitScope.execute(snapshot, callback, 1.0);
853
- self.finalize();
854
- }, (progress) => {
855
- if (progress < 1.0) {
856
- if (easing === 'ease-out') {
857
- progress = Math.pow((1.0 - Math.pow((1.0 - progress), 2.0)), 0.5);
858
- }
859
- else if (easing === 'ease-in') {
860
- progress = Math.pow((1.0 - Math.pow((1.0 - progress), 0.5)), 2.0);
861
- }
862
- else if (easing === 'ease') {
863
- progress = (1.0 - Math.cos(progress * Math.PI)) / 2.0;
864
- }
865
- else if (easing === 'ease-in-out') {
866
- progress = (1.0 - Math.cos(progress * Math.PI)) / 2.0;
867
- }
868
- UnitScope.execute(snapshot, callback, progress);
753
+ else if (easing === 'ease-in-out') {
754
+ progress = (1.0 - Math.cos(progress * Math.PI)) / 2.0;
869
755
  }
870
- }, interval);
871
- self.on('finalize', () => {
872
- timer.clear();
873
- isRunning = false;
874
- execute();
875
- });
876
- }
877
- let timer = null;
878
- function execute() {
879
- if (isRunning === false && stacks.length > 0) {
880
- const props = stacks.shift();
881
- unit = xnew$1(Local, props);
882
- isRunning = true;
756
+ Unit.scope(snapshot, callback, progress);
883
757
  }
884
- }
885
- function clear() {
886
- stacks = [];
887
- unit.finalize();
888
- }
889
- function next(callback, interval, easing = 'linear') {
890
- stacks.push({ callback, interval, easing });
758
+ }, interval);
759
+ self.on('finalize', () => {
760
+ timer.clear();
761
+ isRunning = false;
891
762
  execute();
892
- return timer;
763
+ });
764
+ }
765
+ let timer = null;
766
+ function execute() {
767
+ if (isRunning === false && stacks.length > 0) {
768
+ const props = stacks.shift();
769
+ unit = xnew$1(Local, props);
770
+ isRunning = true;
893
771
  }
894
- timer = { clear, next };
772
+ }
773
+ function clear() {
774
+ stacks = [];
775
+ unit.finalize();
776
+ }
777
+ function next(callback, interval, easing = 'linear') {
778
+ stacks.push({ callback, interval, easing });
779
+ execute();
895
780
  return timer;
896
- };
897
- fn.listener = function (target) {
898
- return {
899
- on(type, listener, options) {
900
- Unit.subon(UnitScope.current, target, type, listener, options);
901
- },
902
- off(type, listener) {
903
- Unit.suboff(UnitScope.current, target, type, listener);
904
- }
905
- };
906
- };
907
- fn.capture = function (checker, execute) {
908
- const current = UnitScope.current;
909
- const snapshot = UnitScope.snapshot();
910
- current._.captures.push({ checker, execute: (unit) => UnitScope.execute(snapshot, execute, unit) });
911
- };
912
- return fn;
913
- })();
914
-
915
- function ResizeEvent(self) {
916
- const observer = new ResizeObserver(xnew$1.scope((entries) => {
917
- for (const entry of entries) {
918
- self.emit('-resize');
919
- break;
920
- }
921
- }));
922
- if (self.element) {
923
- observer.observe(self.element);
924
781
  }
925
- self.on('finalize', () => {
926
- if (self.element) {
927
- observer.unobserve(self.element);
782
+ timer = { clear, next };
783
+ return timer;
784
+ };
785
+ xnew$1.listener = function (target) {
786
+ return {
787
+ on(type, listener, options) {
788
+ Unit.subon(Unit.current, target, type, listener, options);
789
+ },
790
+ off(type, listener) {
791
+ Unit.suboff(Unit.current, target, type, listener);
928
792
  }
929
- });
930
- }
793
+ };
794
+ };
795
+ xnew$1.capture = function (checker, execute) {
796
+ Unit.current._.captures.push({ checker, execute: Unit.wrap(Unit.current, (unit) => execute(unit)) });
797
+ };
931
798
 
932
799
  function UserEvent(self) {
933
800
  const unit = xnew$1();
@@ -1139,18 +1006,13 @@
1139
1006
 
1140
1007
  function ModalFrame(frame, {} = {}) {
1141
1008
  xnew$1.context('xnew.modalframe', frame);
1142
- xnew$1.nest('<div style="position: fixed; inset: 0;">');
1143
- let content = null;
1144
- xnew$1.capture((unit) => unit.components.has(ModalContent), (unit) => {
1145
- content = unit;
1146
- });
1147
- xnew$1().on('click', (event) => {
1148
- frame === null || frame === void 0 ? void 0 : frame.close();
1009
+ xnew$1.nest('<div style="position: fixed; inset: 0; z-index: 1000;">');
1010
+ xnew$1.capture((unit) => unit.components.includes(ModalContent), (unit) => {
1149
1011
  });
1012
+ xnew$1().on('click', (event) => frame === null || frame === void 0 ? void 0 : frame.close());
1150
1013
  return {
1151
1014
  close() {
1152
1015
  frame.emit('-close');
1153
- content === null || content === void 0 ? void 0 : content.deselect();
1154
1016
  }
1155
1017
  };
1156
1018
  }
@@ -1159,40 +1021,28 @@
1159
1021
  const div = xnew$1.nest('<div style="width: 100%; height: 100%; opacity: 0;">');
1160
1022
  div.style.background = background;
1161
1023
  xnew$1.nest('<div style="position: absolute; inset: 0; margin: auto; width: max-content; height: max-content;">');
1162
- xnew$1().on('click', (event) => {
1163
- event.stopPropagation();
1164
- });
1165
- let status = 0;
1024
+ xnew$1().on('click', (event) => event.stopPropagation());
1166
1025
  xnew$1.timeout(() => frame.emit('-open'));
1167
1026
  frame.on('-open', () => {
1168
1027
  xnew$1.transition((x) => {
1169
- status = x;
1170
- frame.emit('-transition', { status });
1171
- content.transition(status);
1028
+ div.style.opacity = x.toString();
1172
1029
  }, duration, easing);
1173
1030
  });
1174
1031
  frame.on('-close', () => {
1175
1032
  xnew$1.transition((x) => {
1176
- status = 1.0 - x;
1177
- frame.emit('-transition', { status });
1178
- content.transition(status);
1033
+ div.style.opacity = (1.0 - x).toString();
1179
1034
  }, duration, easing).next(() => frame.finalize());
1180
1035
  });
1181
- return {
1182
- transition(status) {
1183
- div.style.opacity = status.toString();
1184
- }
1185
- };
1186
1036
  }
1187
1037
 
1188
1038
  function TabFrame(frame, { select = 0 } = {}) {
1189
1039
  xnew$1.context('xnew.tabframe', frame);
1190
1040
  const buttons = [];
1191
1041
  const contents = [];
1192
- xnew$1.capture((unit) => unit.components.has(TabButton), (unit) => {
1042
+ xnew$1.capture((unit) => unit.components.includes(TabButton), (unit) => {
1193
1043
  buttons.push(unit);
1194
1044
  });
1195
- xnew$1.capture((unit) => unit.components.has(TabContent), (unit) => {
1045
+ xnew$1.capture((unit) => unit.components.includes(TabContent), (unit) => {
1196
1046
  contents.push(unit);
1197
1047
  });
1198
1048
  frame.on('-click', ({ unit }) => execute(buttons.indexOf(unit)));
@@ -1236,7 +1086,7 @@
1236
1086
  function AccordionFrame(frame, {} = {}) {
1237
1087
  xnew$1.context('xnew.accordionframe', frame);
1238
1088
  let content = null;
1239
- xnew$1.capture((unit) => unit.components.has(AccordionContent), (unit) => {
1089
+ xnew$1.capture((unit) => unit.components.includes(AccordionContent), (unit) => {
1240
1090
  content = unit;
1241
1091
  });
1242
1092
  return {
@@ -1260,10 +1110,10 @@
1260
1110
  }
1261
1111
  };
1262
1112
  }
1263
- function AccordionButton(button, {} = {}) {
1113
+ function AccordionHeader(header, {} = {}) {
1264
1114
  const frame = xnew$1.context('xnew.accordionframe');
1265
1115
  xnew$1.nest('<button style="display: flex; align-items: center; margin: 0; padding: 0; width: 100%; text-align: left; border: none; font: inherit; color: inherit; background: none; cursor: pointer;">');
1266
- button.on('click', () => frame.toggle());
1116
+ header.on('click', () => frame.toggle());
1267
1117
  }
1268
1118
  function AccordionBullet(bullet, { type = 'arrow' } = {}) {
1269
1119
  const frame = xnew$1.context('xnew.accordionframe');
@@ -1328,20 +1178,6 @@
1328
1178
  };
1329
1179
  }
1330
1180
 
1331
- function PanelFrame(frame) {
1332
- xnew$1.context('xnew.panelframe', frame);
1333
- }
1334
- function PanelGroup(group, { name, open = false } = {}) {
1335
- xnew$1.extend(AccordionFrame);
1336
- xnew$1((button) => {
1337
- xnew$1.nest('<div style="margin: 0.2em 0;">');
1338
- xnew$1.extend(AccordionButton);
1339
- xnew$1(AccordionBullet);
1340
- xnew$1('<div>', name);
1341
- });
1342
- xnew$1.extend(AccordionContent, { open });
1343
- }
1344
-
1345
1181
  function DragFrame(frame, { x = 0, y = 0 } = {}) {
1346
1182
  const absolute = xnew$1.nest(`<div style="position: absolute; top: ${y}px; left: ${x}px;">`);
1347
1183
  xnew$1.context('xnew.dragframe', { frame, absolute });
@@ -1374,7 +1210,7 @@
1374
1210
  ${stroke ? `stroke: ${stroke}; stroke-opacity: ${strokeOpacity}; stroke-width: ${strokeWidth}; stroke-linejoin: ${strokeLinejoin};` : ''}
1375
1211
  ">`);
1376
1212
  }
1377
- function VirtualStick(self, { size = 130, fill = '#FFF', fillOpacity = 0.8, stroke = '#000', strokeOpacity = 0.8, strokeWidth = 2, strokeLinejoin = 'round' } = {}) {
1213
+ function TouchStick(self, { size = 130, fill = '#FFF', fillOpacity = 0.8, stroke = '#000', strokeOpacity = 0.8, strokeWidth = 2, strokeLinejoin = 'round' } = {}) {
1378
1214
  strokeWidth /= (size / 100);
1379
1215
  xnew$1.nest(`<div style="position: relative; width: ${size}px; height: ${size}px; cursor: pointer; user-select: none; overflow: hidden;">`);
1380
1216
  xnew$1((self) => {
@@ -1418,7 +1254,7 @@
1418
1254
  return { x: Math.cos(a) * d, y: Math.sin(a) * d };
1419
1255
  }
1420
1256
  }
1421
- function VirtualDPad(self, { size = 130, fill = '#FFF', fillOpacity = 0.8, stroke = '#000', strokeOpacity = 0.8, strokeWidth = 2, strokeLinejoin = 'round' } = {}) {
1257
+ function TouchDPad(self, { size = 130, fill = '#FFF', fillOpacity = 0.8, stroke = '#000', strokeOpacity = 0.8, strokeWidth = 2, strokeLinejoin = 'round' } = {}) {
1422
1258
  strokeWidth /= (size / 100);
1423
1259
  xnew$1.nest(`<div style="position: relative; width: ${size}px; height: ${size}px; cursor: pointer; user-select: none; overflow: hidden;">`);
1424
1260
  const polygons = [
@@ -1480,7 +1316,7 @@
1480
1316
  return vector;
1481
1317
  }
1482
1318
  }
1483
- function VirtualButton(self, { size = 80, fill = '#FFF', fillOpacity = 0.8, stroke = '#000', strokeOpacity = 0.8, strokeWidth = 2, strokeLinejoin = 'round' } = {}) {
1319
+ function TouchButton(self, { size = 80, fill = '#FFF', fillOpacity = 0.8, stroke = '#000', strokeOpacity = 0.8, strokeWidth = 2, strokeLinejoin = 'round' } = {}) {
1484
1320
  strokeWidth /= (size / 100);
1485
1321
  xnew$1.nest(`<div style="position: relative; width: ${size}px; height: ${size}px; cursor: pointer; user-select: none; overflow: hidden;">`);
1486
1322
  const target = xnew$1((self) => {
@@ -1805,20 +1641,18 @@
1805
1641
  ModalFrame,
1806
1642
  ModalContent,
1807
1643
  AccordionFrame,
1808
- AccordionButton,
1644
+ AccordionHeader,
1809
1645
  AccordionBullet,
1810
1646
  AccordionContent,
1811
1647
  TabFrame,
1812
1648
  TabButton,
1813
1649
  TabContent,
1814
- PanelFrame,
1815
- PanelGroup,
1816
1650
  InputFrame,
1817
1651
  DragFrame,
1818
1652
  DragTarget,
1819
- VirtualStick,
1820
- VirtualDPad,
1821
- VirtualButton,
1653
+ TouchStick,
1654
+ TouchDPad,
1655
+ TouchButton,
1822
1656
  };
1823
1657
  const audio = {
1824
1658
  synthesizer