mol_wire_lib 1.0.90 → 1.0.93
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/node.d.ts +25 -21
- package/node.deps.json +1 -1
- package/node.esm.js +283 -268
- package/node.esm.js.map +1 -1
- package/node.js +283 -268
- package/node.js.map +1 -1
- package/node.test.js +837 -852
- package/node.test.js.map +1 -1
- package/package.json +5 -5
- package/web.d.ts +25 -21
- package/web.deps.json +1 -1
- package/web.esm.js +283 -268
- package/web.esm.js.map +1 -1
- package/web.js +283 -268
- package/web.js.map +1 -1
- package/web.test.js +97 -127
- package/web.test.js.map +1 -1
package/node.test.js
CHANGED
|
@@ -361,183 +361,6 @@ var $;
|
|
|
361
361
|
;
|
|
362
362
|
"use strict";
|
|
363
363
|
var $;
|
|
364
|
-
(function ($) {
|
|
365
|
-
$.$mol_compare_deep_cache = new WeakMap();
|
|
366
|
-
function $mol_compare_deep(left, right) {
|
|
367
|
-
if (Object.is(left, right))
|
|
368
|
-
return true;
|
|
369
|
-
if (left === null)
|
|
370
|
-
return false;
|
|
371
|
-
if (right === null)
|
|
372
|
-
return false;
|
|
373
|
-
if (typeof left !== 'object')
|
|
374
|
-
return false;
|
|
375
|
-
if (typeof right !== 'object')
|
|
376
|
-
return false;
|
|
377
|
-
const left_proto = Reflect.getPrototypeOf(left);
|
|
378
|
-
const right_proto = Reflect.getPrototypeOf(right);
|
|
379
|
-
if (left_proto !== right_proto)
|
|
380
|
-
return false;
|
|
381
|
-
if (left instanceof Boolean)
|
|
382
|
-
return Object.is(left.valueOf(), right['valueOf']());
|
|
383
|
-
if (left instanceof Number)
|
|
384
|
-
return Object.is(left.valueOf(), right['valueOf']());
|
|
385
|
-
if (left instanceof String)
|
|
386
|
-
return Object.is(left.valueOf(), right['valueOf']());
|
|
387
|
-
if (left instanceof Date)
|
|
388
|
-
return Object.is(left.valueOf(), right['valueOf']());
|
|
389
|
-
if (left instanceof RegExp)
|
|
390
|
-
return left.source === right['source'] && left.flags === right['flags'];
|
|
391
|
-
let left_cache = $.$mol_compare_deep_cache.get(left);
|
|
392
|
-
if (left_cache) {
|
|
393
|
-
const right_cache = left_cache.get(right);
|
|
394
|
-
if (typeof right_cache === 'boolean')
|
|
395
|
-
return right_cache;
|
|
396
|
-
}
|
|
397
|
-
else {
|
|
398
|
-
left_cache = new WeakMap([[right, true]]);
|
|
399
|
-
$.$mol_compare_deep_cache.set(left, left_cache);
|
|
400
|
-
}
|
|
401
|
-
let result;
|
|
402
|
-
try {
|
|
403
|
-
if (left_proto && !Reflect.getPrototypeOf(left_proto))
|
|
404
|
-
result = compare_pojo(left, right);
|
|
405
|
-
else if (Array.isArray(left))
|
|
406
|
-
result = compare_array(left, right);
|
|
407
|
-
else if (left instanceof Set)
|
|
408
|
-
result = compare_set(left, right);
|
|
409
|
-
else if (left instanceof Map)
|
|
410
|
-
result = compare_map(left, right);
|
|
411
|
-
else if (left instanceof Error)
|
|
412
|
-
result = left.stack === right.stack;
|
|
413
|
-
else if (ArrayBuffer.isView(left))
|
|
414
|
-
result = compare_buffer(left, right);
|
|
415
|
-
else if (Symbol.toPrimitive in left)
|
|
416
|
-
result = compare_primitive(left, right);
|
|
417
|
-
else
|
|
418
|
-
result = false;
|
|
419
|
-
}
|
|
420
|
-
finally {
|
|
421
|
-
left_cache.set(right, result);
|
|
422
|
-
}
|
|
423
|
-
return result;
|
|
424
|
-
}
|
|
425
|
-
$.$mol_compare_deep = $mol_compare_deep;
|
|
426
|
-
function compare_array(left, right) {
|
|
427
|
-
const len = left.length;
|
|
428
|
-
if (len !== right.length)
|
|
429
|
-
return false;
|
|
430
|
-
for (let i = 0; i < len; ++i) {
|
|
431
|
-
if (!$mol_compare_deep(left[i], right[i]))
|
|
432
|
-
return false;
|
|
433
|
-
}
|
|
434
|
-
return true;
|
|
435
|
-
}
|
|
436
|
-
function compare_buffer(left, right) {
|
|
437
|
-
const len = left.byteLength;
|
|
438
|
-
if (len !== right.byteLength)
|
|
439
|
-
return false;
|
|
440
|
-
for (let i = 0; i < len; ++i) {
|
|
441
|
-
if (left[i] !== right[i])
|
|
442
|
-
return false;
|
|
443
|
-
}
|
|
444
|
-
return true;
|
|
445
|
-
}
|
|
446
|
-
function compare_iterator(left, right, compare) {
|
|
447
|
-
while (true) {
|
|
448
|
-
const left_next = left.next();
|
|
449
|
-
const right_next = right.next();
|
|
450
|
-
if (left_next.done !== right_next.done)
|
|
451
|
-
return false;
|
|
452
|
-
if (left_next.done)
|
|
453
|
-
break;
|
|
454
|
-
if (!compare(left_next.value, right_next.value))
|
|
455
|
-
return false;
|
|
456
|
-
}
|
|
457
|
-
return true;
|
|
458
|
-
}
|
|
459
|
-
function compare_set(left, right) {
|
|
460
|
-
if (left.size !== right.size)
|
|
461
|
-
return false;
|
|
462
|
-
return compare_iterator(left.values(), right.values(), $mol_compare_deep);
|
|
463
|
-
}
|
|
464
|
-
function compare_map(left, right) {
|
|
465
|
-
if (left.size !== right.size)
|
|
466
|
-
return false;
|
|
467
|
-
return compare_iterator(left.keys(), right.keys(), Object.is)
|
|
468
|
-
&& compare_iterator(left.values(), right.values(), $mol_compare_deep);
|
|
469
|
-
}
|
|
470
|
-
function compare_pojo(left, right) {
|
|
471
|
-
const left_keys = Object.getOwnPropertyNames(left);
|
|
472
|
-
const right_keys = Object.getOwnPropertyNames(right);
|
|
473
|
-
if (left_keys.length !== right_keys.length)
|
|
474
|
-
return false;
|
|
475
|
-
for (let key of left_keys) {
|
|
476
|
-
if (!$mol_compare_deep(left[key], Reflect.get(right, key)))
|
|
477
|
-
return false;
|
|
478
|
-
}
|
|
479
|
-
return true;
|
|
480
|
-
}
|
|
481
|
-
function compare_primitive(left, right) {
|
|
482
|
-
return Object.is(left[Symbol.toPrimitive]('default'), right[Symbol.toPrimitive]('default'));
|
|
483
|
-
}
|
|
484
|
-
})($ || ($ = {}));
|
|
485
|
-
//mol/compare/deep/deep.ts
|
|
486
|
-
;
|
|
487
|
-
"use strict";
|
|
488
|
-
var $;
|
|
489
|
-
(function ($) {
|
|
490
|
-
function $mol_guid(length = 8, exists = () => false) {
|
|
491
|
-
for (;;) {
|
|
492
|
-
let id = Math.random().toString(36).substring(2, length + 2).toUpperCase();
|
|
493
|
-
if (exists(id))
|
|
494
|
-
continue;
|
|
495
|
-
return id;
|
|
496
|
-
}
|
|
497
|
-
}
|
|
498
|
-
$.$mol_guid = $mol_guid;
|
|
499
|
-
})($ || ($ = {}));
|
|
500
|
-
//mol/guid/guid.ts
|
|
501
|
-
;
|
|
502
|
-
"use strict";
|
|
503
|
-
var $;
|
|
504
|
-
(function ($) {
|
|
505
|
-
$.$mol_key_store = new WeakMap();
|
|
506
|
-
function $mol_key(value) {
|
|
507
|
-
if (!value)
|
|
508
|
-
return JSON.stringify(value);
|
|
509
|
-
if (typeof value !== 'object' && typeof value !== 'function')
|
|
510
|
-
return JSON.stringify(value);
|
|
511
|
-
return JSON.stringify(value, (field, value) => {
|
|
512
|
-
if (!value)
|
|
513
|
-
return value;
|
|
514
|
-
if (typeof value !== 'object' && typeof value !== 'function')
|
|
515
|
-
return value;
|
|
516
|
-
if (Array.isArray(value))
|
|
517
|
-
return value;
|
|
518
|
-
const proto = Reflect.getPrototypeOf(value);
|
|
519
|
-
if (!proto)
|
|
520
|
-
return value;
|
|
521
|
-
if (Reflect.getPrototypeOf(proto) === null)
|
|
522
|
-
return value;
|
|
523
|
-
if ('toJSON' in value)
|
|
524
|
-
return value;
|
|
525
|
-
if (value instanceof RegExp)
|
|
526
|
-
return value.toString();
|
|
527
|
-
let key = $.$mol_key_store.get(value);
|
|
528
|
-
if (key)
|
|
529
|
-
return key;
|
|
530
|
-
key = $mol_guid();
|
|
531
|
-
$.$mol_key_store.set(value, key);
|
|
532
|
-
return key;
|
|
533
|
-
});
|
|
534
|
-
}
|
|
535
|
-
$.$mol_key = $mol_key;
|
|
536
|
-
})($ || ($ = {}));
|
|
537
|
-
//mol/key/key.ts
|
|
538
|
-
;
|
|
539
|
-
"use strict";
|
|
540
|
-
var $;
|
|
541
364
|
(function ($) {
|
|
542
365
|
$.$mol_ambient_ref = Symbol('$mol_ambient_ref');
|
|
543
366
|
function $mol_ambient(overrides) {
|
|
@@ -734,82 +557,213 @@ var $;
|
|
|
734
557
|
"use strict";
|
|
735
558
|
var $;
|
|
736
559
|
(function ($) {
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
560
|
+
$.$mol_compare_deep_cache = new WeakMap();
|
|
561
|
+
function $mol_compare_deep(left, right) {
|
|
562
|
+
if (Object.is(left, right))
|
|
563
|
+
return true;
|
|
564
|
+
if (left === null)
|
|
565
|
+
return false;
|
|
566
|
+
if (right === null)
|
|
567
|
+
return false;
|
|
568
|
+
if (typeof left !== 'object')
|
|
569
|
+
return false;
|
|
570
|
+
if (typeof right !== 'object')
|
|
571
|
+
return false;
|
|
572
|
+
const left_proto = Reflect.getPrototypeOf(left);
|
|
573
|
+
const right_proto = Reflect.getPrototypeOf(right);
|
|
574
|
+
if (left_proto !== right_proto)
|
|
575
|
+
return false;
|
|
576
|
+
if (left instanceof Boolean)
|
|
577
|
+
return Object.is(left.valueOf(), right['valueOf']());
|
|
578
|
+
if (left instanceof Number)
|
|
579
|
+
return Object.is(left.valueOf(), right['valueOf']());
|
|
580
|
+
if (left instanceof String)
|
|
581
|
+
return Object.is(left.valueOf(), right['valueOf']());
|
|
582
|
+
if (left instanceof Date)
|
|
583
|
+
return Object.is(left.valueOf(), right['valueOf']());
|
|
584
|
+
if (left instanceof RegExp)
|
|
585
|
+
return left.source === right['source'] && left.flags === right['flags'];
|
|
586
|
+
let left_cache = $.$mol_compare_deep_cache.get(left);
|
|
587
|
+
if (left_cache) {
|
|
588
|
+
const right_cache = left_cache.get(right);
|
|
589
|
+
if (typeof right_cache === 'boolean')
|
|
590
|
+
return right_cache;
|
|
744
591
|
}
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
}
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
592
|
+
else {
|
|
593
|
+
left_cache = new WeakMap([[right, true]]);
|
|
594
|
+
$.$mol_compare_deep_cache.set(left, left_cache);
|
|
595
|
+
}
|
|
596
|
+
let result;
|
|
597
|
+
try {
|
|
598
|
+
if (left_proto && !Reflect.getPrototypeOf(left_proto))
|
|
599
|
+
result = compare_pojo(left, right);
|
|
600
|
+
else if (Array.isArray(left))
|
|
601
|
+
result = compare_array(left, right);
|
|
602
|
+
else if (left instanceof Set)
|
|
603
|
+
result = compare_set(left, right);
|
|
604
|
+
else if (left instanceof Map)
|
|
605
|
+
result = compare_map(left, right);
|
|
606
|
+
else if (left instanceof Error)
|
|
607
|
+
result = left.stack === right.stack;
|
|
608
|
+
else if (ArrayBuffer.isView(left))
|
|
609
|
+
result = compare_buffer(left, right);
|
|
610
|
+
else if (Symbol.toPrimitive in left)
|
|
611
|
+
result = compare_primitive(left, right);
|
|
612
|
+
else
|
|
613
|
+
result = false;
|
|
614
|
+
}
|
|
615
|
+
finally {
|
|
616
|
+
left_cache.set(right, result);
|
|
617
|
+
}
|
|
618
|
+
return result;
|
|
754
619
|
}
|
|
755
|
-
$.$
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
620
|
+
$.$mol_compare_deep = $mol_compare_deep;
|
|
621
|
+
function compare_array(left, right) {
|
|
622
|
+
const len = left.length;
|
|
623
|
+
if (len !== right.length)
|
|
624
|
+
return false;
|
|
625
|
+
for (let i = 0; i < len; ++i) {
|
|
626
|
+
if (!$mol_compare_deep(left[i], right[i]))
|
|
627
|
+
return false;
|
|
628
|
+
}
|
|
629
|
+
return true;
|
|
630
|
+
}
|
|
631
|
+
function compare_buffer(left, right) {
|
|
632
|
+
const len = left.byteLength;
|
|
633
|
+
if (len !== right.byteLength)
|
|
634
|
+
return false;
|
|
635
|
+
for (let i = 0; i < len; ++i) {
|
|
636
|
+
if (left[i] !== right[i])
|
|
637
|
+
return false;
|
|
638
|
+
}
|
|
639
|
+
return true;
|
|
640
|
+
}
|
|
641
|
+
function compare_iterator(left, right, compare) {
|
|
642
|
+
while (true) {
|
|
643
|
+
const left_next = left.next();
|
|
644
|
+
const right_next = right.next();
|
|
645
|
+
if (left_next.done !== right_next.done)
|
|
646
|
+
return false;
|
|
647
|
+
if (left_next.done)
|
|
648
|
+
break;
|
|
649
|
+
if (!compare(left_next.value, right_next.value))
|
|
650
|
+
return false;
|
|
651
|
+
}
|
|
652
|
+
return true;
|
|
653
|
+
}
|
|
654
|
+
function compare_set(left, right) {
|
|
655
|
+
if (left.size !== right.size)
|
|
656
|
+
return false;
|
|
657
|
+
return compare_iterator(left.values(), right.values(), $mol_compare_deep);
|
|
658
|
+
}
|
|
659
|
+
function compare_map(left, right) {
|
|
660
|
+
if (left.size !== right.size)
|
|
661
|
+
return false;
|
|
662
|
+
return compare_iterator(left.keys(), right.keys(), Object.is)
|
|
663
|
+
&& compare_iterator(left.values(), right.values(), $mol_compare_deep);
|
|
664
|
+
}
|
|
665
|
+
function compare_pojo(left, right) {
|
|
666
|
+
const left_keys = Object.getOwnPropertyNames(left);
|
|
667
|
+
const right_keys = Object.getOwnPropertyNames(right);
|
|
668
|
+
if (left_keys.length !== right_keys.length)
|
|
669
|
+
return false;
|
|
670
|
+
for (let key of left_keys) {
|
|
671
|
+
if (!$mol_compare_deep(left[key], Reflect.get(right, key)))
|
|
672
|
+
return false;
|
|
673
|
+
}
|
|
674
|
+
return true;
|
|
675
|
+
}
|
|
676
|
+
function compare_primitive(left, right) {
|
|
677
|
+
return Object.is(left[Symbol.toPrimitive]('default'), right[Symbol.toPrimitive]('default'));
|
|
678
|
+
}
|
|
679
|
+
})($ || ($ = {}));
|
|
680
|
+
//mol/compare/deep/deep.ts
|
|
681
|
+
;
|
|
682
|
+
"use strict";
|
|
683
|
+
var $;
|
|
684
|
+
(function ($) {
|
|
685
|
+
function $mol_guid(length = 8, exists = () => false) {
|
|
686
|
+
for (;;) {
|
|
687
|
+
let id = Math.random().toString(36).substring(2, length + 2).toUpperCase();
|
|
688
|
+
if (exists(id))
|
|
689
|
+
continue;
|
|
690
|
+
return id;
|
|
691
|
+
}
|
|
692
|
+
}
|
|
693
|
+
$.$mol_guid = $mol_guid;
|
|
694
|
+
})($ || ($ = {}));
|
|
695
|
+
//mol/guid/guid.ts
|
|
696
|
+
;
|
|
697
|
+
"use strict";
|
|
698
|
+
var $;
|
|
699
|
+
(function ($) {
|
|
700
|
+
$.$mol_key_store = new WeakMap();
|
|
701
|
+
function $mol_key(value) {
|
|
702
|
+
if (!value)
|
|
703
|
+
return JSON.stringify(value);
|
|
704
|
+
if (typeof value !== 'object' && typeof value !== 'function')
|
|
705
|
+
return JSON.stringify(value);
|
|
706
|
+
return JSON.stringify(value, (field, value) => {
|
|
707
|
+
if (!value)
|
|
708
|
+
return value;
|
|
709
|
+
if (typeof value !== 'object' && typeof value !== 'function')
|
|
710
|
+
return value;
|
|
711
|
+
if (Array.isArray(value))
|
|
712
|
+
return value;
|
|
713
|
+
const proto = Reflect.getPrototypeOf(value);
|
|
714
|
+
if (!proto)
|
|
715
|
+
return value;
|
|
716
|
+
if (Reflect.getPrototypeOf(proto) === null)
|
|
717
|
+
return value;
|
|
718
|
+
if ('toJSON' in value)
|
|
719
|
+
return value;
|
|
720
|
+
if (value instanceof RegExp)
|
|
721
|
+
return value.toString();
|
|
722
|
+
let key = $.$mol_key_store.get(value);
|
|
723
|
+
if (key)
|
|
724
|
+
return key;
|
|
725
|
+
key = $mol_guid();
|
|
726
|
+
$.$mol_key_store.set(value, key);
|
|
727
|
+
return key;
|
|
728
|
+
});
|
|
729
|
+
}
|
|
730
|
+
$.$mol_key = $mol_key;
|
|
731
|
+
})($ || ($ = {}));
|
|
732
|
+
//mol/key/key.ts
|
|
733
|
+
;
|
|
734
|
+
"use strict";
|
|
735
|
+
var $;
|
|
736
|
+
(function ($) {
|
|
737
|
+
function $mol_wire_method(host, field, descr) {
|
|
738
|
+
if (!descr)
|
|
739
|
+
descr = Reflect.getOwnPropertyDescriptor(host, field);
|
|
740
|
+
const orig = descr?.value ?? host[field];
|
|
741
|
+
const sup = Reflect.getPrototypeOf(host);
|
|
742
|
+
if (typeof sup[field] === 'function') {
|
|
743
|
+
Object.defineProperty(orig, 'name', { value: sup[field].name });
|
|
744
|
+
}
|
|
745
|
+
const temp = $mol_wire_fiber_temp.getter(orig);
|
|
746
|
+
const value = function (...args) {
|
|
747
|
+
const fiber = temp(this ?? null, args);
|
|
748
|
+
return fiber.sync();
|
|
749
|
+
};
|
|
750
|
+
Object.defineProperty(value, 'name', { value: orig.name + ' ' });
|
|
751
|
+
Object.assign(value, { orig });
|
|
752
|
+
const descr2 = { ...descr, value };
|
|
753
|
+
Reflect.defineProperty(host, field, descr2);
|
|
754
|
+
return descr2;
|
|
755
|
+
}
|
|
756
|
+
$.$mol_wire_method = $mol_wire_method;
|
|
757
|
+
})($ || ($ = {}));
|
|
758
|
+
//mol/wire/method/method.ts
|
|
759
|
+
;
|
|
760
|
+
"use strict";
|
|
761
|
+
var $;
|
|
761
762
|
(function ($) {
|
|
762
763
|
const handled = new WeakSet();
|
|
763
764
|
class $mol_wire_fiber extends $mol_wire_pub_sub {
|
|
764
765
|
task;
|
|
765
766
|
host;
|
|
766
|
-
static temp(host, task, ...args) {
|
|
767
|
-
const existen = $mol_wire_auto()?.track_next();
|
|
768
|
-
reuse: if (existen) {
|
|
769
|
-
if (!(existen instanceof $mol_wire_fiber))
|
|
770
|
-
break reuse;
|
|
771
|
-
if (existen.host !== host)
|
|
772
|
-
break reuse;
|
|
773
|
-
if (existen.task !== task)
|
|
774
|
-
break reuse;
|
|
775
|
-
if (!$mol_compare_deep(existen.args, args))
|
|
776
|
-
break reuse;
|
|
777
|
-
return existen;
|
|
778
|
-
}
|
|
779
|
-
return new this(`${host?.[Symbol.toStringTag] ?? host}.${task.name}(#)`, task, host, ...args);
|
|
780
|
-
}
|
|
781
|
-
static persist(task, keys) {
|
|
782
|
-
const field = task.name + '()';
|
|
783
|
-
if (keys) {
|
|
784
|
-
return function $mol_wire_fiber_persist(host, args) {
|
|
785
|
-
let dict, key, fiber;
|
|
786
|
-
key = `${host?.[Symbol.toStringTag] ?? host}.${task.name}(${args.map(v => $mol_key(v)).join(',')})`;
|
|
787
|
-
dict = Object.getOwnPropertyDescriptor(host ?? task, field)?.value;
|
|
788
|
-
if (dict) {
|
|
789
|
-
const existen = dict.get(key);
|
|
790
|
-
if (existen)
|
|
791
|
-
return existen;
|
|
792
|
-
}
|
|
793
|
-
else {
|
|
794
|
-
dict = (host ?? task)[field] = new Map();
|
|
795
|
-
}
|
|
796
|
-
fiber = new $mol_wire_fiber(key, task, host, ...args);
|
|
797
|
-
dict.set(key, fiber);
|
|
798
|
-
return fiber;
|
|
799
|
-
};
|
|
800
|
-
}
|
|
801
|
-
else {
|
|
802
|
-
return function $mol_wire_fiber_persist(host, args) {
|
|
803
|
-
const existen = Object.getOwnPropertyDescriptor(host ?? task, field)?.value;
|
|
804
|
-
if (existen)
|
|
805
|
-
return existen;
|
|
806
|
-
const key = `${host?.[Symbol.toStringTag] ?? host}.${field}`;
|
|
807
|
-
const fiber = new $mol_wire_fiber(key, task, host, ...args);
|
|
808
|
-
(host ?? task)[field] = fiber;
|
|
809
|
-
return fiber;
|
|
810
|
-
};
|
|
811
|
-
}
|
|
812
|
-
}
|
|
813
767
|
static warm = true;
|
|
814
768
|
static planning = [];
|
|
815
769
|
static reaping = [];
|
|
@@ -853,10 +807,6 @@ var $;
|
|
|
853
807
|
return;
|
|
854
808
|
return this.cache;
|
|
855
809
|
}
|
|
856
|
-
persistent() {
|
|
857
|
-
const id = this[Symbol.toStringTag];
|
|
858
|
-
return id[id.length - 2] !== '#';
|
|
859
|
-
}
|
|
860
810
|
field() {
|
|
861
811
|
return this.task.name + '()';
|
|
862
812
|
}
|
|
@@ -869,23 +819,6 @@ var $;
|
|
|
869
819
|
this.pub_from = this.sub_from = args.length;
|
|
870
820
|
this[Symbol.toStringTag] = id;
|
|
871
821
|
}
|
|
872
|
-
destructor() {
|
|
873
|
-
super.destructor();
|
|
874
|
-
const prev = this.cache;
|
|
875
|
-
if ($mol_owning_check(this, prev)) {
|
|
876
|
-
prev.destructor();
|
|
877
|
-
}
|
|
878
|
-
if (this.persistent()) {
|
|
879
|
-
if (this.pub_from === 0) {
|
|
880
|
-
;
|
|
881
|
-
(this.host ?? this.task)[this.field()] = null;
|
|
882
|
-
}
|
|
883
|
-
else {
|
|
884
|
-
;
|
|
885
|
-
(this.host ?? this.task)[this.field()].delete(this[Symbol.toStringTag]);
|
|
886
|
-
}
|
|
887
|
-
}
|
|
888
|
-
}
|
|
889
822
|
plan() {
|
|
890
823
|
$mol_wire_fiber.planning.push(this);
|
|
891
824
|
$mol_wire_fiber.plan();
|
|
@@ -918,15 +851,6 @@ var $;
|
|
|
918
851
|
else
|
|
919
852
|
super.emit(quant);
|
|
920
853
|
}
|
|
921
|
-
commit() {
|
|
922
|
-
if (this.persistent())
|
|
923
|
-
return;
|
|
924
|
-
super.commit();
|
|
925
|
-
if (this.host instanceof $mol_wire_fiber) {
|
|
926
|
-
this.host.put(this.cache);
|
|
927
|
-
}
|
|
928
|
-
this.destructor();
|
|
929
|
-
}
|
|
930
854
|
refresh() {
|
|
931
855
|
if (this.cursor === $mol_wire_cursor.fresh)
|
|
932
856
|
return;
|
|
@@ -945,7 +869,17 @@ var $;
|
|
|
945
869
|
const bu = this.track_on();
|
|
946
870
|
let result;
|
|
947
871
|
try {
|
|
948
|
-
|
|
872
|
+
switch (this.pub_from) {
|
|
873
|
+
case 0:
|
|
874
|
+
result = this.task.call(this.host);
|
|
875
|
+
break;
|
|
876
|
+
case 1:
|
|
877
|
+
result = this.task.call(this.host, this[0]);
|
|
878
|
+
break;
|
|
879
|
+
default:
|
|
880
|
+
result = this.task.call(this.host, ...this.slice(0, this.pub_from));
|
|
881
|
+
break;
|
|
882
|
+
}
|
|
949
883
|
if (result instanceof Promise) {
|
|
950
884
|
const put = (res) => {
|
|
951
885
|
if (this.cache === result)
|
|
@@ -983,7 +917,7 @@ var $;
|
|
|
983
917
|
prev.destructor();
|
|
984
918
|
}
|
|
985
919
|
this.cache = next;
|
|
986
|
-
if (this
|
|
920
|
+
if (this instanceof $mol_wire_fiber_persist && $mol_owning_catch(this, next)) {
|
|
987
921
|
try {
|
|
988
922
|
next[Symbol.toStringTag] = this[Symbol.toStringTag];
|
|
989
923
|
}
|
|
@@ -998,19 +932,19 @@ var $;
|
|
|
998
932
|
this.cursor = $mol_wire_cursor.fresh;
|
|
999
933
|
if (next instanceof Promise)
|
|
1000
934
|
return next;
|
|
1001
|
-
if (this
|
|
935
|
+
if (this instanceof $mol_wire_fiber_persist) {
|
|
1002
936
|
this.commit_pubs();
|
|
1003
937
|
}
|
|
1004
938
|
else {
|
|
1005
939
|
if (this.sub_empty) {
|
|
1006
940
|
this.commit();
|
|
1007
941
|
}
|
|
942
|
+
else {
|
|
943
|
+
this.commit_pubs();
|
|
944
|
+
}
|
|
1008
945
|
}
|
|
1009
946
|
return next;
|
|
1010
947
|
}
|
|
1011
|
-
recall(...args) {
|
|
1012
|
-
return this.task.call(this.host, ...args);
|
|
1013
|
-
}
|
|
1014
948
|
sync() {
|
|
1015
949
|
if (!$mol_wire_fiber.warm) {
|
|
1016
950
|
return this.result();
|
|
@@ -1040,10 +974,88 @@ var $;
|
|
|
1040
974
|
}
|
|
1041
975
|
}
|
|
1042
976
|
}
|
|
977
|
+
$.$mol_wire_fiber = $mol_wire_fiber;
|
|
978
|
+
class $mol_wire_fiber_temp extends $mol_wire_fiber {
|
|
979
|
+
static getter(task) {
|
|
980
|
+
return function $mol_wire_fiber_temp_get(host, args) {
|
|
981
|
+
const existen = $mol_wire_auto()?.track_next();
|
|
982
|
+
reuse: if (existen) {
|
|
983
|
+
if (!(existen instanceof $mol_wire_fiber_temp))
|
|
984
|
+
break reuse;
|
|
985
|
+
if (existen.host !== host)
|
|
986
|
+
break reuse;
|
|
987
|
+
if (existen.task !== task)
|
|
988
|
+
break reuse;
|
|
989
|
+
if (!$mol_compare_deep(existen.args, args))
|
|
990
|
+
break reuse;
|
|
991
|
+
return existen;
|
|
992
|
+
}
|
|
993
|
+
return new $mol_wire_fiber_temp(`${host?.[Symbol.toStringTag] ?? host}.${task.name}(#)`, task, host, ...args);
|
|
994
|
+
};
|
|
995
|
+
}
|
|
996
|
+
commit() {
|
|
997
|
+
super.commit();
|
|
998
|
+
this.destructor();
|
|
999
|
+
}
|
|
1000
|
+
}
|
|
1001
|
+
$.$mol_wire_fiber_temp = $mol_wire_fiber_temp;
|
|
1002
|
+
class $mol_wire_fiber_persist extends $mol_wire_fiber {
|
|
1003
|
+
static getter(task, keys) {
|
|
1004
|
+
const field = task.name + '()';
|
|
1005
|
+
if (keys) {
|
|
1006
|
+
return function $mol_wire_fiber_persist_get(host, args) {
|
|
1007
|
+
let dict, key, fiber;
|
|
1008
|
+
key = `${host?.[Symbol.toStringTag] ?? host}.${task.name}(${args.map(v => $mol_key(v)).join(',')})`;
|
|
1009
|
+
dict = Object.getOwnPropertyDescriptor(host ?? task, field)?.value;
|
|
1010
|
+
if (dict) {
|
|
1011
|
+
const existen = dict.get(key);
|
|
1012
|
+
if (existen)
|
|
1013
|
+
return existen;
|
|
1014
|
+
}
|
|
1015
|
+
else {
|
|
1016
|
+
dict = (host ?? task)[field] = new Map();
|
|
1017
|
+
}
|
|
1018
|
+
fiber = new $mol_wire_fiber_persist(key, task, host, ...args);
|
|
1019
|
+
dict.set(key, fiber);
|
|
1020
|
+
return fiber;
|
|
1021
|
+
};
|
|
1022
|
+
}
|
|
1023
|
+
else {
|
|
1024
|
+
return function $mol_wire_fiber_persist_get(host, args) {
|
|
1025
|
+
const existen = Object.getOwnPropertyDescriptor(host ?? task, field)?.value;
|
|
1026
|
+
if (existen)
|
|
1027
|
+
return existen;
|
|
1028
|
+
const key = `${host?.[Symbol.toStringTag] ?? host}.${field}`;
|
|
1029
|
+
const fiber = new $mol_wire_fiber_persist(key, task, host, ...args);
|
|
1030
|
+
(host ?? task)[field] = fiber;
|
|
1031
|
+
return fiber;
|
|
1032
|
+
};
|
|
1033
|
+
}
|
|
1034
|
+
}
|
|
1035
|
+
recall(...args) {
|
|
1036
|
+
return this.put(this.task.call(this.host, ...args));
|
|
1037
|
+
}
|
|
1038
|
+
commit() { }
|
|
1039
|
+
destructor() {
|
|
1040
|
+
super.destructor();
|
|
1041
|
+
const prev = this.cache;
|
|
1042
|
+
if ($mol_owning_check(this, prev)) {
|
|
1043
|
+
prev.destructor();
|
|
1044
|
+
}
|
|
1045
|
+
if (this.pub_from === 0) {
|
|
1046
|
+
;
|
|
1047
|
+
(this.host ?? this.task)[this.field()] = null;
|
|
1048
|
+
}
|
|
1049
|
+
else {
|
|
1050
|
+
;
|
|
1051
|
+
(this.host ?? this.task)[this.field()].delete(this[Symbol.toStringTag]);
|
|
1052
|
+
}
|
|
1053
|
+
}
|
|
1054
|
+
}
|
|
1043
1055
|
__decorate([
|
|
1044
1056
|
$mol_wire_method
|
|
1045
|
-
], $
|
|
1046
|
-
$.$
|
|
1057
|
+
], $mol_wire_fiber_persist.prototype, "recall", null);
|
|
1058
|
+
$.$mol_wire_fiber_persist = $mol_wire_fiber_persist;
|
|
1047
1059
|
})($ || ($ = {}));
|
|
1048
1060
|
//mol/wire/fiber/fiber.ts
|
|
1049
1061
|
;
|
|
@@ -1084,8 +1096,9 @@ var $;
|
|
|
1084
1096
|
const val = obj[field];
|
|
1085
1097
|
if (typeof val !== 'function')
|
|
1086
1098
|
return val;
|
|
1099
|
+
const temp = $mol_wire_fiber_temp.getter(val);
|
|
1087
1100
|
return function $mol_wire_sync(...args) {
|
|
1088
|
-
const fiber =
|
|
1101
|
+
const fiber = temp(obj, args);
|
|
1089
1102
|
return fiber.sync();
|
|
1090
1103
|
};
|
|
1091
1104
|
}
|
|
@@ -1105,9 +1118,10 @@ var $;
|
|
|
1105
1118
|
if (typeof val !== 'function')
|
|
1106
1119
|
return val;
|
|
1107
1120
|
let fiber;
|
|
1121
|
+
const temp = $mol_wire_fiber_temp.getter(val);
|
|
1108
1122
|
return function $mol_wire_async(...args) {
|
|
1109
1123
|
fiber?.destructor();
|
|
1110
|
-
fiber =
|
|
1124
|
+
fiber = temp(obj, args);
|
|
1111
1125
|
return fiber.async();
|
|
1112
1126
|
};
|
|
1113
1127
|
}
|
|
@@ -1172,7 +1186,7 @@ var $;
|
|
|
1172
1186
|
$.$mol_wire_mem = $mol_wire_mem;
|
|
1173
1187
|
function $mol_wire_mem_func(keys) {
|
|
1174
1188
|
return (func) => {
|
|
1175
|
-
const persist = $
|
|
1189
|
+
const persist = $mol_wire_fiber_persist.getter(func, keys);
|
|
1176
1190
|
const wrapper = function (...args) {
|
|
1177
1191
|
let atom = persist(this, args.slice(0, keys));
|
|
1178
1192
|
if (args.length <= keys || args[keys] === undefined)
|
|
@@ -1214,7 +1228,7 @@ var $;
|
|
|
1214
1228
|
if (!descr)
|
|
1215
1229
|
descr = Reflect.getOwnPropertyDescriptor(host, field);
|
|
1216
1230
|
const _get = descr?.get || $mol_const(descr?.value);
|
|
1217
|
-
const persist = $
|
|
1231
|
+
const persist = $mol_wire_fiber_persist.getter(_get, 0);
|
|
1218
1232
|
const _set = descr?.set || function (next) {
|
|
1219
1233
|
persist(this, []).put(next);
|
|
1220
1234
|
};
|
|
@@ -1225,8 +1239,9 @@ var $;
|
|
|
1225
1239
|
function get() {
|
|
1226
1240
|
return persist(this, []).sync();
|
|
1227
1241
|
}
|
|
1242
|
+
const temp = $mol_wire_fiber_temp.getter(_set);
|
|
1228
1243
|
function set(next) {
|
|
1229
|
-
|
|
1244
|
+
temp(this, [next]).sync();
|
|
1230
1245
|
}
|
|
1231
1246
|
Object.defineProperty(get, 'name', { value: _get.name + '$' });
|
|
1232
1247
|
Object.defineProperty(set, 'name', { value: _set.name + '@' });
|
|
@@ -1634,6 +1649,12 @@ var $;
|
|
|
1634
1649
|
//mol/type/assert/assert.ts
|
|
1635
1650
|
;
|
|
1636
1651
|
"use strict";
|
|
1652
|
+
//mol/type/equals/equals.test.ts
|
|
1653
|
+
;
|
|
1654
|
+
"use strict";
|
|
1655
|
+
//mol/type/equals/equals.ts
|
|
1656
|
+
;
|
|
1657
|
+
"use strict";
|
|
1637
1658
|
//mol/type/partial/deep/deep.test.ts
|
|
1638
1659
|
;
|
|
1639
1660
|
"use strict";
|
|
@@ -2022,9 +2043,121 @@ var $;
|
|
|
2022
2043
|
"use strict";
|
|
2023
2044
|
var $;
|
|
2024
2045
|
(function ($) {
|
|
2025
|
-
$
|
|
2026
|
-
|
|
2027
|
-
|
|
2046
|
+
function $mol_log3_area_lazy(event) {
|
|
2047
|
+
const self = this;
|
|
2048
|
+
const stack = self.$mol_log3_stack;
|
|
2049
|
+
const deep = stack.length;
|
|
2050
|
+
let logged = false;
|
|
2051
|
+
stack.push(() => {
|
|
2052
|
+
logged = true;
|
|
2053
|
+
self.$mol_log3_area.call(self, event);
|
|
2054
|
+
});
|
|
2055
|
+
return () => {
|
|
2056
|
+
if (logged)
|
|
2057
|
+
self.console.groupEnd();
|
|
2058
|
+
if (stack.length > deep)
|
|
2059
|
+
stack.length = deep;
|
|
2060
|
+
};
|
|
2061
|
+
}
|
|
2062
|
+
$.$mol_log3_area_lazy = $mol_log3_area_lazy;
|
|
2063
|
+
$.$mol_log3_stack = [];
|
|
2064
|
+
})($ || ($ = {}));
|
|
2065
|
+
//mol/log3/log3.ts
|
|
2066
|
+
;
|
|
2067
|
+
"use strict";
|
|
2068
|
+
var $;
|
|
2069
|
+
(function ($) {
|
|
2070
|
+
function $mol_log3_node_make(level, output, type, color) {
|
|
2071
|
+
return function $mol_log3_logger(event) {
|
|
2072
|
+
if (!event.time)
|
|
2073
|
+
event = { time: new Date().toISOString(), ...event };
|
|
2074
|
+
const tree = this.$mol_tree.fromJSON(event).clone({ type });
|
|
2075
|
+
let str = tree.toString();
|
|
2076
|
+
if (process[output].isTTY) {
|
|
2077
|
+
str = $node.colorette[color + 'Bright'](str);
|
|
2078
|
+
}
|
|
2079
|
+
;
|
|
2080
|
+
this.console[level](str);
|
|
2081
|
+
const self = this;
|
|
2082
|
+
return () => self.console.groupEnd();
|
|
2083
|
+
};
|
|
2084
|
+
}
|
|
2085
|
+
$.$mol_log3_node_make = $mol_log3_node_make;
|
|
2086
|
+
$.$mol_log3_come = $mol_log3_node_make('info', 'stdout', 'come', 'blue');
|
|
2087
|
+
$.$mol_log3_done = $mol_log3_node_make('info', 'stdout', 'done', 'green');
|
|
2088
|
+
$.$mol_log3_fail = $mol_log3_node_make('error', 'stderr', 'fail', 'red');
|
|
2089
|
+
$.$mol_log3_warn = $mol_log3_node_make('warn', 'stderr', 'warn', 'yellow');
|
|
2090
|
+
$.$mol_log3_rise = $mol_log3_node_make('log', 'stdout', 'rise', 'magenta');
|
|
2091
|
+
$.$mol_log3_area = $mol_log3_node_make('log', 'stdout', 'area', 'cyan');
|
|
2092
|
+
})($ || ($ = {}));
|
|
2093
|
+
//mol/log3/log3.node.ts
|
|
2094
|
+
;
|
|
2095
|
+
"use strict";
|
|
2096
|
+
var $;
|
|
2097
|
+
(function ($_1) {
|
|
2098
|
+
$mol_test_mocks.push($ => {
|
|
2099
|
+
$.$mol_log3_come = () => { };
|
|
2100
|
+
$.$mol_log3_done = () => { };
|
|
2101
|
+
$.$mol_log3_fail = () => { };
|
|
2102
|
+
$.$mol_log3_warn = () => { };
|
|
2103
|
+
$.$mol_log3_rise = () => { };
|
|
2104
|
+
$.$mol_log3_area = () => () => { };
|
|
2105
|
+
});
|
|
2106
|
+
})($ || ($ = {}));
|
|
2107
|
+
//mol/log3/log3.test.ts
|
|
2108
|
+
;
|
|
2109
|
+
"use strict";
|
|
2110
|
+
var $;
|
|
2111
|
+
(function ($) {
|
|
2112
|
+
function $mol_env() {
|
|
2113
|
+
return {};
|
|
2114
|
+
}
|
|
2115
|
+
$.$mol_env = $mol_env;
|
|
2116
|
+
})($ || ($ = {}));
|
|
2117
|
+
//mol/env/env.ts
|
|
2118
|
+
;
|
|
2119
|
+
"use strict";
|
|
2120
|
+
var $;
|
|
2121
|
+
(function ($) {
|
|
2122
|
+
$.$mol_env = function $mol_env() {
|
|
2123
|
+
return this.process.env;
|
|
2124
|
+
};
|
|
2125
|
+
})($ || ($ = {}));
|
|
2126
|
+
//mol/env/env.node.ts
|
|
2127
|
+
;
|
|
2128
|
+
"use strict";
|
|
2129
|
+
var $;
|
|
2130
|
+
(function ($) {
|
|
2131
|
+
function $mol_exec(dir, command, ...args) {
|
|
2132
|
+
let [app, ...args0] = command.split(' ');
|
|
2133
|
+
args = [...args0, ...args];
|
|
2134
|
+
this.$mol_log3_come({
|
|
2135
|
+
place: '$mol_exec',
|
|
2136
|
+
dir: $node.path.relative('', dir),
|
|
2137
|
+
message: 'Run',
|
|
2138
|
+
command: `${app} ${args.join(' ')}`,
|
|
2139
|
+
});
|
|
2140
|
+
var res = $node['child_process'].spawnSync(app, args, {
|
|
2141
|
+
cwd: $node.path.resolve(dir),
|
|
2142
|
+
shell: true,
|
|
2143
|
+
env: this.$mol_env(),
|
|
2144
|
+
});
|
|
2145
|
+
if (res.status || res.error)
|
|
2146
|
+
return $mol_fail(res.error || new Error(res.stderr.toString()));
|
|
2147
|
+
if (!res.stdout)
|
|
2148
|
+
res.stdout = Buffer.from([]);
|
|
2149
|
+
return res;
|
|
2150
|
+
}
|
|
2151
|
+
$.$mol_exec = $mol_exec;
|
|
2152
|
+
})($ || ($ = {}));
|
|
2153
|
+
//mol/exec/exec.node.ts
|
|
2154
|
+
;
|
|
2155
|
+
"use strict";
|
|
2156
|
+
var $;
|
|
2157
|
+
(function ($) {
|
|
2158
|
+
$mol_test({
|
|
2159
|
+
'get'() {
|
|
2160
|
+
const proxy = $mol_delegate({}, () => ({ foo: 777 }));
|
|
2028
2161
|
$mol_assert_equal(proxy.foo, 777);
|
|
2029
2162
|
},
|
|
2030
2163
|
'has'() {
|
|
@@ -2125,15 +2258,6 @@ var $;
|
|
|
2125
2258
|
;
|
|
2126
2259
|
"use strict";
|
|
2127
2260
|
var $;
|
|
2128
|
-
(function ($_1) {
|
|
2129
|
-
$mol_test_mocks.push($ => {
|
|
2130
|
-
$.$mol_after_timeout = $mol_after_mock_timeout;
|
|
2131
|
-
});
|
|
2132
|
-
})($ || ($ = {}));
|
|
2133
|
-
//mol/after/timeout/timeout.test.ts
|
|
2134
|
-
;
|
|
2135
|
-
"use strict";
|
|
2136
|
-
var $;
|
|
2137
2261
|
(function ($_1) {
|
|
2138
2262
|
$mol_test({
|
|
2139
2263
|
async 'Latest Calls Wins on Concurrency'($) {
|
|
@@ -2219,6 +2343,24 @@ var $;
|
|
|
2219
2343
|
;
|
|
2220
2344
|
"use strict";
|
|
2221
2345
|
var $;
|
|
2346
|
+
(function ($_1) {
|
|
2347
|
+
$mol_test_mocks.push($ => {
|
|
2348
|
+
$.$mol_after_timeout = $mol_after_mock_timeout;
|
|
2349
|
+
});
|
|
2350
|
+
})($ || ($ = {}));
|
|
2351
|
+
//mol/after/timeout/timeout.test.ts
|
|
2352
|
+
;
|
|
2353
|
+
"use strict";
|
|
2354
|
+
var $;
|
|
2355
|
+
(function ($_1) {
|
|
2356
|
+
$mol_test_mocks.push($ => {
|
|
2357
|
+
$.$mol_after_frame = $mol_after_mock_commmon;
|
|
2358
|
+
});
|
|
2359
|
+
})($ || ($ = {}));
|
|
2360
|
+
//mol/after/frame/frame.test.ts
|
|
2361
|
+
;
|
|
2362
|
+
"use strict";
|
|
2363
|
+
var $;
|
|
2222
2364
|
(function ($) {
|
|
2223
2365
|
$mol_test({
|
|
2224
2366
|
'Primitives'() {
|
|
@@ -2274,15 +2416,6 @@ var $;
|
|
|
2274
2416
|
;
|
|
2275
2417
|
"use strict";
|
|
2276
2418
|
var $;
|
|
2277
|
-
(function ($_1) {
|
|
2278
|
-
$mol_test_mocks.push($ => {
|
|
2279
|
-
$.$mol_after_frame = $mol_after_mock_commmon;
|
|
2280
|
-
});
|
|
2281
|
-
})($ || ($ = {}));
|
|
2282
|
-
//mol/after/frame/frame.test.ts
|
|
2283
|
-
;
|
|
2284
|
-
"use strict";
|
|
2285
|
-
var $;
|
|
2286
2419
|
(function ($) {
|
|
2287
2420
|
$mol_test({
|
|
2288
2421
|
'Sync execution'() {
|
|
@@ -2608,36 +2741,6 @@ var $;
|
|
|
2608
2741
|
App.count(5);
|
|
2609
2742
|
$mol_assert_like(App.res(), 6);
|
|
2610
2743
|
},
|
|
2611
|
-
async 'Toggle with async'($) {
|
|
2612
|
-
class App extends $mol_object2 {
|
|
2613
|
-
static $ = $;
|
|
2614
|
-
static checked(next = false) {
|
|
2615
|
-
$$.$mol_wait_timeout(0);
|
|
2616
|
-
return next;
|
|
2617
|
-
}
|
|
2618
|
-
static toggle() {
|
|
2619
|
-
const prev = this.checked();
|
|
2620
|
-
$mol_assert_unique(this.checked(!prev), prev);
|
|
2621
|
-
$mol_assert_equal(this.checked(), prev);
|
|
2622
|
-
}
|
|
2623
|
-
static res() {
|
|
2624
|
-
return this.checked();
|
|
2625
|
-
}
|
|
2626
|
-
}
|
|
2627
|
-
__decorate([
|
|
2628
|
-
$mol_wire_mem(0)
|
|
2629
|
-
], App, "checked", null);
|
|
2630
|
-
__decorate([
|
|
2631
|
-
$mol_wire_method
|
|
2632
|
-
], App, "toggle", null);
|
|
2633
|
-
__decorate([
|
|
2634
|
-
$mol_wire_mem(0)
|
|
2635
|
-
], App, "res", null);
|
|
2636
|
-
const app = $mol_wire_async(App);
|
|
2637
|
-
$mol_assert_equal(await app.res(), false);
|
|
2638
|
-
await app.toggle();
|
|
2639
|
-
$mol_assert_equal(await app.res(), true);
|
|
2640
|
-
},
|
|
2641
2744
|
'Restore after error'($) {
|
|
2642
2745
|
class App extends $mol_object2 {
|
|
2643
2746
|
static get $() { return $; }
|
|
@@ -2951,531 +3054,86 @@ var $;
|
|
|
2951
3054
|
"use strict";
|
|
2952
3055
|
var $;
|
|
2953
3056
|
(function ($) {
|
|
2954
|
-
function $
|
|
2955
|
-
|
|
2956
|
-
|
|
2957
|
-
|
|
2958
|
-
|
|
2959
|
-
|
|
2960
|
-
|
|
2961
|
-
|
|
2962
|
-
|
|
2963
|
-
|
|
2964
|
-
|
|
2965
|
-
|
|
2966
|
-
|
|
2967
|
-
|
|
2968
|
-
|
|
2969
|
-
}
|
|
2970
|
-
$.$mol_log3_area_lazy = $mol_log3_area_lazy;
|
|
2971
|
-
$.$mol_log3_stack = [];
|
|
2972
|
-
})($ || ($ = {}));
|
|
2973
|
-
//mol/log3/log3.ts
|
|
2974
|
-
;
|
|
2975
|
-
"use strict";
|
|
2976
|
-
var $;
|
|
2977
|
-
(function ($) {
|
|
2978
|
-
function $mol_log3_node_make(level, output, type, color) {
|
|
2979
|
-
return function $mol_log3_logger(event) {
|
|
2980
|
-
if (!event.time)
|
|
2981
|
-
event = { time: new Date().toISOString(), ...event };
|
|
2982
|
-
const tree = this.$mol_tree.fromJSON(event).clone({ type });
|
|
2983
|
-
let str = tree.toString();
|
|
2984
|
-
if (process[output].isTTY) {
|
|
2985
|
-
str = $node.colorette[color + 'Bright'](str);
|
|
2986
|
-
}
|
|
2987
|
-
;
|
|
2988
|
-
this.console[level](str);
|
|
2989
|
-
const self = this;
|
|
2990
|
-
return () => self.console.groupEnd();
|
|
3057
|
+
function $mol_deprecated(message) {
|
|
3058
|
+
return (host, field, descr) => {
|
|
3059
|
+
const value = descr.value;
|
|
3060
|
+
let warned = false;
|
|
3061
|
+
descr.value = function $mol_deprecated_wrapper(...args) {
|
|
3062
|
+
if (!warned) {
|
|
3063
|
+
$$.$mol_log3_warn({
|
|
3064
|
+
place: `${host.constructor.name}::${field}`,
|
|
3065
|
+
message: `Deprecated`,
|
|
3066
|
+
hint: message,
|
|
3067
|
+
});
|
|
3068
|
+
warned = true;
|
|
3069
|
+
}
|
|
3070
|
+
return value.call(this, ...args);
|
|
3071
|
+
};
|
|
2991
3072
|
};
|
|
2992
3073
|
}
|
|
2993
|
-
$.$
|
|
2994
|
-
$.$mol_log3_come = $mol_log3_node_make('info', 'stdout', 'come', 'blue');
|
|
2995
|
-
$.$mol_log3_done = $mol_log3_node_make('info', 'stdout', 'done', 'green');
|
|
2996
|
-
$.$mol_log3_fail = $mol_log3_node_make('error', 'stderr', 'fail', 'red');
|
|
2997
|
-
$.$mol_log3_warn = $mol_log3_node_make('warn', 'stderr', 'warn', 'yellow');
|
|
2998
|
-
$.$mol_log3_rise = $mol_log3_node_make('log', 'stdout', 'rise', 'magenta');
|
|
2999
|
-
$.$mol_log3_area = $mol_log3_node_make('log', 'stdout', 'area', 'cyan');
|
|
3074
|
+
$.$mol_deprecated = $mol_deprecated;
|
|
3000
3075
|
})($ || ($ = {}));
|
|
3001
|
-
//mol/
|
|
3076
|
+
//mol/deprecated/deprecated.ts
|
|
3002
3077
|
;
|
|
3003
3078
|
"use strict";
|
|
3004
3079
|
var $;
|
|
3005
3080
|
(function ($_1) {
|
|
3006
|
-
$mol_test_mocks.push($ => {
|
|
3007
|
-
$.$mol_log3_come = () => { };
|
|
3008
|
-
$.$mol_log3_done = () => { };
|
|
3009
|
-
$.$mol_log3_fail = () => { };
|
|
3010
|
-
$.$mol_log3_warn = () => { };
|
|
3011
|
-
$.$mol_log3_rise = () => { };
|
|
3012
|
-
$.$mol_log3_area = () => () => { };
|
|
3013
|
-
});
|
|
3014
|
-
})($ || ($ = {}));
|
|
3015
|
-
//mol/log3/log3.test.ts
|
|
3016
|
-
;
|
|
3017
|
-
"use strict";
|
|
3018
|
-
var $;
|
|
3019
|
-
(function ($) {
|
|
3020
|
-
class $mol_wire_log extends $mol_object2 {
|
|
3021
|
-
static watch(task) {
|
|
3022
|
-
return task;
|
|
3023
|
-
}
|
|
3024
|
-
static track(fiber) {
|
|
3025
|
-
const prev = $mol_wire_probe(() => this.track(fiber));
|
|
3026
|
-
let next;
|
|
3027
|
-
try {
|
|
3028
|
-
next = fiber.sync();
|
|
3029
|
-
}
|
|
3030
|
-
finally {
|
|
3031
|
-
for (const pub of fiber.pub_list) {
|
|
3032
|
-
if (pub instanceof $mol_wire_fiber) {
|
|
3033
|
-
this.track(pub);
|
|
3034
|
-
}
|
|
3035
|
-
}
|
|
3036
|
-
}
|
|
3037
|
-
if (prev !== undefined && !$mol_compare_deep(prev, next)) {
|
|
3038
|
-
this.$.$mol_log3_rise({
|
|
3039
|
-
message: 'Changed',
|
|
3040
|
-
place: fiber,
|
|
3041
|
-
});
|
|
3042
|
-
}
|
|
3043
|
-
return next;
|
|
3044
|
-
}
|
|
3045
|
-
static active() {
|
|
3046
|
-
try {
|
|
3047
|
-
this.watch()?.();
|
|
3048
|
-
}
|
|
3049
|
-
finally {
|
|
3050
|
-
for (const pub of $mol_wire_auto().pub_list) {
|
|
3051
|
-
if (pub instanceof $mol_wire_fiber) {
|
|
3052
|
-
this.track(pub);
|
|
3053
|
-
}
|
|
3054
|
-
}
|
|
3055
|
-
}
|
|
3056
|
-
}
|
|
3057
|
-
}
|
|
3058
|
-
__decorate([
|
|
3059
|
-
$mol_mem
|
|
3060
|
-
], $mol_wire_log, "watch", null);
|
|
3061
|
-
__decorate([
|
|
3062
|
-
$mol_mem_key
|
|
3063
|
-
], $mol_wire_log, "track", null);
|
|
3064
|
-
__decorate([
|
|
3065
|
-
$mol_mem
|
|
3066
|
-
], $mol_wire_log, "active", null);
|
|
3067
|
-
$.$mol_wire_log = $mol_wire_log;
|
|
3068
|
-
})($ || ($ = {}));
|
|
3069
|
-
//mol/wire/log/log.ts
|
|
3070
|
-
;
|
|
3071
|
-
"use strict";
|
|
3072
|
-
var $;
|
|
3073
|
-
(function ($) {
|
|
3074
|
-
$mol_wire_log.active();
|
|
3075
|
-
})($ || ($ = {}));
|
|
3076
|
-
//mol/wire/wire.test.ts
|
|
3077
|
-
;
|
|
3078
|
-
"use strict";
|
|
3079
|
-
var $;
|
|
3080
|
-
(function ($) {
|
|
3081
3081
|
$mol_test({
|
|
3082
|
-
'
|
|
3083
|
-
|
|
3084
|
-
$mol_assert_equal(
|
|
3085
|
-
$mol_assert_equal(
|
|
3086
|
-
|
|
3087
|
-
|
|
3088
|
-
|
|
3089
|
-
|
|
3090
|
-
;
|
|
3091
|
-
"use strict";
|
|
3092
|
-
var $;
|
|
3093
|
-
(function ($_1) {
|
|
3094
|
-
$mol_test({
|
|
3095
|
-
'Cached field'($) {
|
|
3096
|
-
class App extends $mol_object2 {
|
|
3097
|
-
static $ = $;
|
|
3098
|
-
static low = 1;
|
|
3099
|
-
static get high() {
|
|
3100
|
-
return this.low + 1;
|
|
3101
|
-
}
|
|
3102
|
-
static set high(next) {
|
|
3103
|
-
this.low = next - 1;
|
|
3104
|
-
}
|
|
3105
|
-
static test() {
|
|
3106
|
-
$mol_assert_equal(App.high, 2);
|
|
3107
|
-
App.high = 3;
|
|
3108
|
-
$mol_assert_equal(App.high, 3);
|
|
3109
|
-
}
|
|
3110
|
-
}
|
|
3111
|
-
__decorate([
|
|
3112
|
-
$mol_wire_field
|
|
3113
|
-
], App, "low", void 0);
|
|
3114
|
-
__decorate([
|
|
3115
|
-
$mol_wire_field
|
|
3116
|
-
], App, "high", null);
|
|
3117
|
-
__decorate([
|
|
3118
|
-
$mol_wire_method
|
|
3119
|
-
], App, "test", null);
|
|
3120
|
-
App.test();
|
|
3082
|
+
'tree parsing'() {
|
|
3083
|
+
$mol_assert_equal($mol_tree.fromString("foo\nbar\n").sub.length, 2);
|
|
3084
|
+
$mol_assert_equal($mol_tree.fromString("foo\nbar\n").sub[1].type, "bar");
|
|
3085
|
+
$mol_assert_equal($mol_tree.fromString("foo\n\n\n").sub.length, 1);
|
|
3086
|
+
$mol_assert_equal($mol_tree.fromString("=foo\n\\bar\n").sub.length, 2);
|
|
3087
|
+
$mol_assert_equal($mol_tree.fromString("=foo\n\\bar\n").sub[1].data, "bar");
|
|
3088
|
+
$mol_assert_equal($mol_tree.fromString("foo bar \\pol").sub[0].sub[0].sub[0].data, "pol");
|
|
3089
|
+
$mol_assert_equal($mol_tree.fromString("foo bar\n\t\\pol\n\t\\men").sub[0].sub[0].sub[1].data, "men");
|
|
3090
|
+
$mol_assert_equal($mol_tree.fromString('foo bar \\text\n').toString(), 'foo bar \\text\n');
|
|
3121
3091
|
},
|
|
3122
|
-
|
|
3123
|
-
|
|
3124
|
-
|
|
3125
|
-
;
|
|
3126
|
-
|
|
3127
|
-
|
|
3128
|
-
(
|
|
3129
|
-
$mol_test({
|
|
3130
|
-
'Watch one value'($) {
|
|
3131
|
-
class App extends $mol_object2 {
|
|
3132
|
-
static $ = $;
|
|
3133
|
-
static set = new $mol_wire_set();
|
|
3134
|
-
static lucky() {
|
|
3135
|
-
return this.set.has(777);
|
|
3136
|
-
}
|
|
3137
|
-
}
|
|
3138
|
-
__decorate([
|
|
3139
|
-
$mol_wire_mem(0)
|
|
3140
|
-
], App, "lucky", null);
|
|
3141
|
-
$mol_assert_equal(App.lucky(), false);
|
|
3142
|
-
App.set.add(666);
|
|
3143
|
-
$mol_assert_equal(App.lucky(), false);
|
|
3144
|
-
App.set.add(777);
|
|
3145
|
-
$mol_assert_equal(App.lucky(), true);
|
|
3146
|
-
App.set.delete(777);
|
|
3147
|
-
$mol_assert_equal(App.lucky(), false);
|
|
3092
|
+
'inserting'() {
|
|
3093
|
+
$mol_assert_equal($mol_tree.fromString('a b c d').insert(new $mol_tree, 'a', 'b', 'c').toString(), 'a b \\\n');
|
|
3094
|
+
$mol_assert_equal($mol_tree.fromString('a b').insert(new $mol_tree, 'a', 'b', 'c', 'd').toString(), 'a b c \\\n');
|
|
3095
|
+
$mol_assert_equal($mol_tree.fromString('a b c d').insert(new $mol_tree, 0, 0, 0).toString(), 'a b \\\n');
|
|
3096
|
+
$mol_assert_equal($mol_tree.fromString('a b').insert(new $mol_tree, 0, 0, 0, 0).toString(), 'a b \\\n\t\\\n');
|
|
3097
|
+
$mol_assert_equal($mol_tree.fromString('a b c d').insert(new $mol_tree, null, null, null).toString(), 'a b \\\n');
|
|
3098
|
+
$mol_assert_equal($mol_tree.fromString('a b').insert(new $mol_tree, null, null, null, null).toString(), 'a b \\\n\t\\\n');
|
|
3148
3099
|
},
|
|
3149
|
-
'
|
|
3150
|
-
|
|
3151
|
-
|
|
3152
|
-
|
|
3153
|
-
|
|
3154
|
-
|
|
3155
|
-
}
|
|
3156
|
-
}
|
|
3157
|
-
__decorate([
|
|
3158
|
-
$mol_wire_mem(0)
|
|
3159
|
-
], App, "lucky", null);
|
|
3160
|
-
$mol_assert_equal(App.lucky(), false);
|
|
3161
|
-
App.set.item(666, true);
|
|
3162
|
-
$mol_assert_equal(App.lucky(), false);
|
|
3163
|
-
App.set.item(777, true);
|
|
3164
|
-
$mol_assert_equal(App.lucky(), true);
|
|
3165
|
-
App.set.item(777, false);
|
|
3166
|
-
$mol_assert_equal(App.lucky(), false);
|
|
3100
|
+
'fromJSON'() {
|
|
3101
|
+
$mol_assert_equal($mol_tree.fromJSON([]).toString(), '/\n');
|
|
3102
|
+
$mol_assert_equal($mol_tree.fromJSON([false, true]).toString(), '/\n\tfalse\n\ttrue\n');
|
|
3103
|
+
$mol_assert_equal($mol_tree.fromJSON([0, 1, 2.3]).toString(), '/\n\t0\n\t1\n\t2.3\n');
|
|
3104
|
+
$mol_assert_equal($mol_tree.fromJSON(['', 'foo', 'bar\nbaz']).toString(), '/\n\t\\\n\t\\foo\n\t\\\n\t\t\\bar\n\t\t\\baz\n');
|
|
3105
|
+
$mol_assert_equal($mol_tree.fromJSON({ 'foo': false, 'bar\nbaz': 'lol' }).toString(), '*\n\tfoo false\n\t\\\n\t\t\\bar\n\t\t\\baz\n\t\t\\lol\n');
|
|
3167
3106
|
},
|
|
3168
|
-
'
|
|
3169
|
-
|
|
3170
|
-
|
|
3171
|
-
|
|
3172
|
-
|
|
3173
|
-
|
|
3174
|
-
}
|
|
3175
|
-
}
|
|
3176
|
-
__decorate([
|
|
3177
|
-
$mol_wire_mem(0)
|
|
3178
|
-
], App, "size", null);
|
|
3179
|
-
$mol_assert_equal(App.size(), 0);
|
|
3180
|
-
App.set.add(666);
|
|
3181
|
-
$mol_assert_equal(App.size(), 1);
|
|
3182
|
-
App.set.add(777);
|
|
3183
|
-
$mol_assert_equal(App.size(), 2);
|
|
3184
|
-
App.set.delete(777);
|
|
3185
|
-
$mol_assert_equal(App.size(), 1);
|
|
3107
|
+
'toJSON'() {
|
|
3108
|
+
$mol_assert_equal(JSON.stringify($mol_tree.fromString('/\n').sub[0]), '[]');
|
|
3109
|
+
$mol_assert_equal(JSON.stringify($mol_tree.fromString('/\n\tfalse\n\ttrue\n').sub[0]), '[false,true]');
|
|
3110
|
+
$mol_assert_equal(JSON.stringify($mol_tree.fromString('/\n\t0\n\t1\n\t2.3\n').sub[0]), '[0,1,2.3]');
|
|
3111
|
+
$mol_assert_equal(JSON.stringify($mol_tree.fromString('/\n\t\\\n\t\\foo\n\t\\\n\t\t\\bar\n\t\t\\baz\n').sub[0]), '["","foo","bar\\nbaz"]');
|
|
3112
|
+
$mol_assert_equal(JSON.stringify($mol_tree.fromString('*\n\tfoo false\n\t\\\n\t\t\\bar\n\t\t\\baz\n\t\t\\lol\n').sub[0]), '{"foo":false,"bar\\nbaz":"lol"}');
|
|
3186
3113
|
},
|
|
3187
|
-
'
|
|
3188
|
-
|
|
3189
|
-
|
|
3190
|
-
|
|
3191
|
-
|
|
3192
|
-
|
|
3193
|
-
for (const val of this.set) {
|
|
3194
|
-
res += val;
|
|
3195
|
-
}
|
|
3196
|
-
return res;
|
|
3197
|
-
}
|
|
3198
|
-
}
|
|
3199
|
-
__decorate([
|
|
3200
|
-
$mol_wire_mem(0)
|
|
3201
|
-
], App, "sum", null);
|
|
3202
|
-
$mol_assert_equal(App.sum(), 0);
|
|
3203
|
-
App.set.add(111);
|
|
3204
|
-
$mol_assert_equal(App.sum(), 111);
|
|
3205
|
-
App.set.add(222);
|
|
3206
|
-
$mol_assert_equal(App.sum(), 333);
|
|
3207
|
-
App.set.delete(111);
|
|
3208
|
-
$mol_assert_equal(App.sum(), 222);
|
|
3114
|
+
'hack'() {
|
|
3115
|
+
const res = $mol_tree.fromString(`foo bar xxx`).hack({
|
|
3116
|
+
'': (tree, context) => [tree.hack(context)],
|
|
3117
|
+
'bar': (tree, context) => [tree.hack(context).clone({ type: '777' })],
|
|
3118
|
+
});
|
|
3119
|
+
$mol_assert_equal(res.toString(), new $mol_tree({ type: 'foo 777 xxx' }).toString());
|
|
3209
3120
|
},
|
|
3210
|
-
'
|
|
3211
|
-
|
|
3212
|
-
|
|
3213
|
-
static
|
|
3214
|
-
|
|
3215
|
-
|
|
3216
|
-
this.set.forEach(val => res += val);
|
|
3217
|
-
return res;
|
|
3218
|
-
}
|
|
3121
|
+
'errors handling'($) {
|
|
3122
|
+
const errors = [];
|
|
3123
|
+
class Tree extends $mol_tree {
|
|
3124
|
+
static $ = $.$mol_ambient({
|
|
3125
|
+
$mol_fail: error => errors.push(error.message)
|
|
3126
|
+
});
|
|
3219
3127
|
}
|
|
3220
|
-
|
|
3221
|
-
|
|
3222
|
-
|
|
3223
|
-
|
|
3224
|
-
|
|
3225
|
-
$mol_assert_equal(App.sum(), 111);
|
|
3226
|
-
App.set.add(222);
|
|
3227
|
-
$mol_assert_equal(App.sum(), 333);
|
|
3228
|
-
App.set.delete(111);
|
|
3229
|
-
$mol_assert_equal(App.sum(), 222);
|
|
3128
|
+
Tree.fromString(`
|
|
3129
|
+
\t \tfoo
|
|
3130
|
+
bar \\data
|
|
3131
|
+
`, 'test');
|
|
3132
|
+
$mol_assert_like(errors, ['Syntax error at test:2\n \tfoo']);
|
|
3230
3133
|
},
|
|
3231
3134
|
});
|
|
3232
3135
|
})($ || ($ = {}));
|
|
3233
|
-
//mol/
|
|
3234
|
-
;
|
|
3235
|
-
"use strict";
|
|
3236
|
-
var $;
|
|
3237
|
-
(function ($_1) {
|
|
3238
|
-
$mol_test({
|
|
3239
|
-
'Watch one value'($) {
|
|
3240
|
-
class App extends $mol_object2 {
|
|
3241
|
-
static $ = $;
|
|
3242
|
-
static dict = new $mol_wire_dict();
|
|
3243
|
-
static lucky() {
|
|
3244
|
-
return this.dict.get(777);
|
|
3245
|
-
}
|
|
3246
|
-
}
|
|
3247
|
-
__decorate([
|
|
3248
|
-
$mol_wire_mem(0)
|
|
3249
|
-
], App, "lucky", null);
|
|
3250
|
-
$mol_assert_equal(App.lucky(), undefined);
|
|
3251
|
-
App.dict.set(666, 6666);
|
|
3252
|
-
$mol_assert_equal(App.lucky(), undefined);
|
|
3253
|
-
App.dict.set(777, 7777);
|
|
3254
|
-
$mol_assert_equal(App.lucky(), 7777);
|
|
3255
|
-
App.dict.delete(777);
|
|
3256
|
-
$mol_assert_equal(App.lucky(), undefined);
|
|
3257
|
-
},
|
|
3258
|
-
'Watch item channel'($) {
|
|
3259
|
-
class App extends $mol_object2 {
|
|
3260
|
-
static $ = $;
|
|
3261
|
-
static dict = new $mol_wire_dict();
|
|
3262
|
-
static lucky() {
|
|
3263
|
-
return this.dict.item(777);
|
|
3264
|
-
}
|
|
3265
|
-
}
|
|
3266
|
-
__decorate([
|
|
3267
|
-
$mol_wire_mem(0)
|
|
3268
|
-
], App, "lucky", null);
|
|
3269
|
-
$mol_assert_equal(App.lucky(), null);
|
|
3270
|
-
App.dict.item(666, 6666);
|
|
3271
|
-
$mol_assert_equal(App.lucky(), null);
|
|
3272
|
-
App.dict.item(777, 7777);
|
|
3273
|
-
$mol_assert_equal(App.lucky(), 7777);
|
|
3274
|
-
App.dict.item(777, null);
|
|
3275
|
-
$mol_assert_equal(App.lucky(), null);
|
|
3276
|
-
},
|
|
3277
|
-
'Watch size'($) {
|
|
3278
|
-
class App extends $mol_object2 {
|
|
3279
|
-
static $ = $;
|
|
3280
|
-
static dict = new $mol_wire_dict();
|
|
3281
|
-
static size() {
|
|
3282
|
-
return this.dict.size;
|
|
3283
|
-
}
|
|
3284
|
-
}
|
|
3285
|
-
__decorate([
|
|
3286
|
-
$mol_wire_mem(0)
|
|
3287
|
-
], App, "size", null);
|
|
3288
|
-
$mol_assert_equal(App.size(), 0);
|
|
3289
|
-
App.dict.set(666, 6666);
|
|
3290
|
-
$mol_assert_equal(App.size(), 1);
|
|
3291
|
-
App.dict.set(777, 7777);
|
|
3292
|
-
$mol_assert_equal(App.size(), 2);
|
|
3293
|
-
App.dict.delete(777);
|
|
3294
|
-
$mol_assert_equal(App.size(), 1);
|
|
3295
|
-
},
|
|
3296
|
-
'Watch for-of'($) {
|
|
3297
|
-
class App extends $mol_object2 {
|
|
3298
|
-
static $ = $;
|
|
3299
|
-
static dict = new $mol_wire_dict();
|
|
3300
|
-
static sum() {
|
|
3301
|
-
let keys = 0;
|
|
3302
|
-
let vals = 0;
|
|
3303
|
-
for (const [key, val] of this.dict) {
|
|
3304
|
-
keys += key;
|
|
3305
|
-
vals += val;
|
|
3306
|
-
}
|
|
3307
|
-
return [keys, vals];
|
|
3308
|
-
}
|
|
3309
|
-
}
|
|
3310
|
-
__decorate([
|
|
3311
|
-
$mol_wire_mem(0)
|
|
3312
|
-
], App, "sum", null);
|
|
3313
|
-
$mol_assert_like(App.sum(), [0, 0]);
|
|
3314
|
-
App.dict.set(111, 1111);
|
|
3315
|
-
$mol_assert_like(App.sum(), [111, 1111]);
|
|
3316
|
-
App.dict.set(222, 2222);
|
|
3317
|
-
$mol_assert_like(App.sum(), [333, 3333]);
|
|
3318
|
-
App.dict.delete(111);
|
|
3319
|
-
$mol_assert_like(App.sum(), [222, 2222]);
|
|
3320
|
-
},
|
|
3321
|
-
'Watch forEach'($) {
|
|
3322
|
-
class App extends $mol_object2 {
|
|
3323
|
-
static $ = $;
|
|
3324
|
-
static dict = new $mol_wire_dict();
|
|
3325
|
-
static sum() {
|
|
3326
|
-
let keys = 0;
|
|
3327
|
-
let vals = 0;
|
|
3328
|
-
this.dict.forEach((val, key) => {
|
|
3329
|
-
keys += key;
|
|
3330
|
-
vals += val;
|
|
3331
|
-
});
|
|
3332
|
-
return [keys, vals];
|
|
3333
|
-
}
|
|
3334
|
-
}
|
|
3335
|
-
__decorate([
|
|
3336
|
-
$mol_wire_mem(0)
|
|
3337
|
-
], App, "sum", null);
|
|
3338
|
-
$mol_assert_like(App.sum(), [0, 0]);
|
|
3339
|
-
App.dict.set(111, 1111);
|
|
3340
|
-
$mol_assert_like(App.sum(), [111, 1111]);
|
|
3341
|
-
App.dict.set(222, 2222);
|
|
3342
|
-
$mol_assert_like(App.sum(), [333, 3333]);
|
|
3343
|
-
App.dict.delete(111);
|
|
3344
|
-
$mol_assert_like(App.sum(), [222, 2222]);
|
|
3345
|
-
},
|
|
3346
|
-
});
|
|
3347
|
-
})($ || ($ = {}));
|
|
3348
|
-
//mol/wire/dict/dict.test.ts
|
|
3349
|
-
;
|
|
3350
|
-
"use strict";
|
|
3351
|
-
var $;
|
|
3352
|
-
(function ($) {
|
|
3353
|
-
function $mol_env() {
|
|
3354
|
-
return {};
|
|
3355
|
-
}
|
|
3356
|
-
$.$mol_env = $mol_env;
|
|
3357
|
-
})($ || ($ = {}));
|
|
3358
|
-
//mol/env/env.ts
|
|
3359
|
-
;
|
|
3360
|
-
"use strict";
|
|
3361
|
-
var $;
|
|
3362
|
-
(function ($) {
|
|
3363
|
-
$.$mol_env = function $mol_env() {
|
|
3364
|
-
return this.process.env;
|
|
3365
|
-
};
|
|
3366
|
-
})($ || ($ = {}));
|
|
3367
|
-
//mol/env/env.node.ts
|
|
3368
|
-
;
|
|
3369
|
-
"use strict";
|
|
3370
|
-
var $;
|
|
3371
|
-
(function ($) {
|
|
3372
|
-
function $mol_exec(dir, command, ...args) {
|
|
3373
|
-
let [app, ...args0] = command.split(' ');
|
|
3374
|
-
args = [...args0, ...args];
|
|
3375
|
-
this.$mol_log3_come({
|
|
3376
|
-
place: '$mol_exec',
|
|
3377
|
-
dir: $node.path.relative('', dir),
|
|
3378
|
-
message: 'Run',
|
|
3379
|
-
command: `${app} ${args.join(' ')}`,
|
|
3380
|
-
});
|
|
3381
|
-
var res = $node['child_process'].spawnSync(app, args, {
|
|
3382
|
-
cwd: $node.path.resolve(dir),
|
|
3383
|
-
shell: true,
|
|
3384
|
-
env: this.$mol_env(),
|
|
3385
|
-
});
|
|
3386
|
-
if (res.status || res.error)
|
|
3387
|
-
return $mol_fail(res.error || new Error(res.stderr.toString()));
|
|
3388
|
-
if (!res.stdout)
|
|
3389
|
-
res.stdout = Buffer.from([]);
|
|
3390
|
-
return res;
|
|
3391
|
-
}
|
|
3392
|
-
$.$mol_exec = $mol_exec;
|
|
3393
|
-
})($ || ($ = {}));
|
|
3394
|
-
//mol/exec/exec.node.ts
|
|
3395
|
-
;
|
|
3396
|
-
"use strict";
|
|
3397
|
-
var $;
|
|
3398
|
-
(function ($) {
|
|
3399
|
-
function $mol_deprecated(message) {
|
|
3400
|
-
return (host, field, descr) => {
|
|
3401
|
-
const value = descr.value;
|
|
3402
|
-
let warned = false;
|
|
3403
|
-
descr.value = function $mol_deprecated_wrapper(...args) {
|
|
3404
|
-
if (!warned) {
|
|
3405
|
-
$$.$mol_log3_warn({
|
|
3406
|
-
place: `${host.constructor.name}::${field}`,
|
|
3407
|
-
message: `Deprecated`,
|
|
3408
|
-
hint: message,
|
|
3409
|
-
});
|
|
3410
|
-
warned = true;
|
|
3411
|
-
}
|
|
3412
|
-
return value.call(this, ...args);
|
|
3413
|
-
};
|
|
3414
|
-
};
|
|
3415
|
-
}
|
|
3416
|
-
$.$mol_deprecated = $mol_deprecated;
|
|
3417
|
-
})($ || ($ = {}));
|
|
3418
|
-
//mol/deprecated/deprecated.ts
|
|
3419
|
-
;
|
|
3420
|
-
"use strict";
|
|
3421
|
-
var $;
|
|
3422
|
-
(function ($_1) {
|
|
3423
|
-
$mol_test({
|
|
3424
|
-
'tree parsing'() {
|
|
3425
|
-
$mol_assert_equal($mol_tree.fromString("foo\nbar\n").sub.length, 2);
|
|
3426
|
-
$mol_assert_equal($mol_tree.fromString("foo\nbar\n").sub[1].type, "bar");
|
|
3427
|
-
$mol_assert_equal($mol_tree.fromString("foo\n\n\n").sub.length, 1);
|
|
3428
|
-
$mol_assert_equal($mol_tree.fromString("=foo\n\\bar\n").sub.length, 2);
|
|
3429
|
-
$mol_assert_equal($mol_tree.fromString("=foo\n\\bar\n").sub[1].data, "bar");
|
|
3430
|
-
$mol_assert_equal($mol_tree.fromString("foo bar \\pol").sub[0].sub[0].sub[0].data, "pol");
|
|
3431
|
-
$mol_assert_equal($mol_tree.fromString("foo bar\n\t\\pol\n\t\\men").sub[0].sub[0].sub[1].data, "men");
|
|
3432
|
-
$mol_assert_equal($mol_tree.fromString('foo bar \\text\n').toString(), 'foo bar \\text\n');
|
|
3433
|
-
},
|
|
3434
|
-
'inserting'() {
|
|
3435
|
-
$mol_assert_equal($mol_tree.fromString('a b c d').insert(new $mol_tree, 'a', 'b', 'c').toString(), 'a b \\\n');
|
|
3436
|
-
$mol_assert_equal($mol_tree.fromString('a b').insert(new $mol_tree, 'a', 'b', 'c', 'd').toString(), 'a b c \\\n');
|
|
3437
|
-
$mol_assert_equal($mol_tree.fromString('a b c d').insert(new $mol_tree, 0, 0, 0).toString(), 'a b \\\n');
|
|
3438
|
-
$mol_assert_equal($mol_tree.fromString('a b').insert(new $mol_tree, 0, 0, 0, 0).toString(), 'a b \\\n\t\\\n');
|
|
3439
|
-
$mol_assert_equal($mol_tree.fromString('a b c d').insert(new $mol_tree, null, null, null).toString(), 'a b \\\n');
|
|
3440
|
-
$mol_assert_equal($mol_tree.fromString('a b').insert(new $mol_tree, null, null, null, null).toString(), 'a b \\\n\t\\\n');
|
|
3441
|
-
},
|
|
3442
|
-
'fromJSON'() {
|
|
3443
|
-
$mol_assert_equal($mol_tree.fromJSON([]).toString(), '/\n');
|
|
3444
|
-
$mol_assert_equal($mol_tree.fromJSON([false, true]).toString(), '/\n\tfalse\n\ttrue\n');
|
|
3445
|
-
$mol_assert_equal($mol_tree.fromJSON([0, 1, 2.3]).toString(), '/\n\t0\n\t1\n\t2.3\n');
|
|
3446
|
-
$mol_assert_equal($mol_tree.fromJSON(['', 'foo', 'bar\nbaz']).toString(), '/\n\t\\\n\t\\foo\n\t\\\n\t\t\\bar\n\t\t\\baz\n');
|
|
3447
|
-
$mol_assert_equal($mol_tree.fromJSON({ 'foo': false, 'bar\nbaz': 'lol' }).toString(), '*\n\tfoo false\n\t\\\n\t\t\\bar\n\t\t\\baz\n\t\t\\lol\n');
|
|
3448
|
-
},
|
|
3449
|
-
'toJSON'() {
|
|
3450
|
-
$mol_assert_equal(JSON.stringify($mol_tree.fromString('/\n').sub[0]), '[]');
|
|
3451
|
-
$mol_assert_equal(JSON.stringify($mol_tree.fromString('/\n\tfalse\n\ttrue\n').sub[0]), '[false,true]');
|
|
3452
|
-
$mol_assert_equal(JSON.stringify($mol_tree.fromString('/\n\t0\n\t1\n\t2.3\n').sub[0]), '[0,1,2.3]');
|
|
3453
|
-
$mol_assert_equal(JSON.stringify($mol_tree.fromString('/\n\t\\\n\t\\foo\n\t\\\n\t\t\\bar\n\t\t\\baz\n').sub[0]), '["","foo","bar\\nbaz"]');
|
|
3454
|
-
$mol_assert_equal(JSON.stringify($mol_tree.fromString('*\n\tfoo false\n\t\\\n\t\t\\bar\n\t\t\\baz\n\t\t\\lol\n').sub[0]), '{"foo":false,"bar\\nbaz":"lol"}');
|
|
3455
|
-
},
|
|
3456
|
-
'hack'() {
|
|
3457
|
-
const res = $mol_tree.fromString(`foo bar xxx`).hack({
|
|
3458
|
-
'': (tree, context) => [tree.hack(context)],
|
|
3459
|
-
'bar': (tree, context) => [tree.hack(context).clone({ type: '777' })],
|
|
3460
|
-
});
|
|
3461
|
-
$mol_assert_equal(res.toString(), new $mol_tree({ type: 'foo 777 xxx' }).toString());
|
|
3462
|
-
},
|
|
3463
|
-
'errors handling'($) {
|
|
3464
|
-
const errors = [];
|
|
3465
|
-
class Tree extends $mol_tree {
|
|
3466
|
-
static $ = $.$mol_ambient({
|
|
3467
|
-
$mol_fail: error => errors.push(error.message)
|
|
3468
|
-
});
|
|
3469
|
-
}
|
|
3470
|
-
Tree.fromString(`
|
|
3471
|
-
\t \tfoo
|
|
3472
|
-
bar \\data
|
|
3473
|
-
`, 'test');
|
|
3474
|
-
$mol_assert_like(errors, ['Syntax error at test:2\n \tfoo']);
|
|
3475
|
-
},
|
|
3476
|
-
});
|
|
3477
|
-
})($ || ($ = {}));
|
|
3478
|
-
//mol/tree/tree.test.ts
|
|
3136
|
+
//mol/tree/tree.test.ts
|
|
3479
3137
|
;
|
|
3480
3138
|
"use strict";
|
|
3481
3139
|
var $;
|
|
@@ -3811,9 +3469,336 @@ var $;
|
|
|
3811
3469
|
//mol/tree/tree.ts
|
|
3812
3470
|
;
|
|
3813
3471
|
"use strict";
|
|
3814
|
-
|
|
3815
|
-
|
|
3816
|
-
|
|
3817
|
-
|
|
3472
|
+
var $;
|
|
3473
|
+
(function ($) {
|
|
3474
|
+
class $mol_wire_log extends $mol_object2 {
|
|
3475
|
+
static watch(task) {
|
|
3476
|
+
return task;
|
|
3477
|
+
}
|
|
3478
|
+
static track(fiber) {
|
|
3479
|
+
const prev = $mol_wire_probe(() => this.track(fiber));
|
|
3480
|
+
let next;
|
|
3481
|
+
try {
|
|
3482
|
+
next = fiber.sync();
|
|
3483
|
+
}
|
|
3484
|
+
finally {
|
|
3485
|
+
for (const pub of fiber.pub_list) {
|
|
3486
|
+
if (pub instanceof $mol_wire_fiber) {
|
|
3487
|
+
this.track(pub);
|
|
3488
|
+
}
|
|
3489
|
+
}
|
|
3490
|
+
}
|
|
3491
|
+
if (prev !== undefined && !$mol_compare_deep(prev, next)) {
|
|
3492
|
+
this.$.$mol_log3_rise({
|
|
3493
|
+
message: 'Changed',
|
|
3494
|
+
place: fiber,
|
|
3495
|
+
});
|
|
3496
|
+
}
|
|
3497
|
+
return next;
|
|
3498
|
+
}
|
|
3499
|
+
static active() {
|
|
3500
|
+
try {
|
|
3501
|
+
this.watch()?.();
|
|
3502
|
+
}
|
|
3503
|
+
finally {
|
|
3504
|
+
for (const pub of $mol_wire_auto().pub_list) {
|
|
3505
|
+
if (pub instanceof $mol_wire_fiber) {
|
|
3506
|
+
this.track(pub);
|
|
3507
|
+
}
|
|
3508
|
+
}
|
|
3509
|
+
}
|
|
3510
|
+
}
|
|
3511
|
+
}
|
|
3512
|
+
__decorate([
|
|
3513
|
+
$mol_mem
|
|
3514
|
+
], $mol_wire_log, "watch", null);
|
|
3515
|
+
__decorate([
|
|
3516
|
+
$mol_mem_key
|
|
3517
|
+
], $mol_wire_log, "track", null);
|
|
3518
|
+
__decorate([
|
|
3519
|
+
$mol_mem
|
|
3520
|
+
], $mol_wire_log, "active", null);
|
|
3521
|
+
$.$mol_wire_log = $mol_wire_log;
|
|
3522
|
+
})($ || ($ = {}));
|
|
3523
|
+
//mol/wire/log/log.ts
|
|
3524
|
+
;
|
|
3525
|
+
"use strict";
|
|
3526
|
+
var $;
|
|
3527
|
+
(function ($) {
|
|
3528
|
+
$mol_wire_log.active();
|
|
3529
|
+
})($ || ($ = {}));
|
|
3530
|
+
//mol/wire/wire.test.ts
|
|
3531
|
+
;
|
|
3532
|
+
"use strict";
|
|
3533
|
+
var $;
|
|
3534
|
+
(function ($) {
|
|
3535
|
+
$mol_test({
|
|
3536
|
+
'const returns stored value'() {
|
|
3537
|
+
const foo = { bar: $mol_const(Math.random()) };
|
|
3538
|
+
$mol_assert_equal(foo.bar(), foo.bar());
|
|
3539
|
+
$mol_assert_equal(foo.bar(), foo.bar['()']);
|
|
3540
|
+
},
|
|
3541
|
+
});
|
|
3542
|
+
})($ || ($ = {}));
|
|
3543
|
+
//mol/const/const.test.ts
|
|
3544
|
+
;
|
|
3545
|
+
"use strict";
|
|
3546
|
+
var $;
|
|
3547
|
+
(function ($_1) {
|
|
3548
|
+
$mol_test({
|
|
3549
|
+
'Cached field'($) {
|
|
3550
|
+
class App extends $mol_object2 {
|
|
3551
|
+
static $ = $;
|
|
3552
|
+
static low = 1;
|
|
3553
|
+
static get high() {
|
|
3554
|
+
return this.low + 1;
|
|
3555
|
+
}
|
|
3556
|
+
static set high(next) {
|
|
3557
|
+
this.low = next - 1;
|
|
3558
|
+
}
|
|
3559
|
+
static test() {
|
|
3560
|
+
$mol_assert_equal(App.high, 2);
|
|
3561
|
+
App.high = 3;
|
|
3562
|
+
$mol_assert_equal(App.high, 3);
|
|
3563
|
+
}
|
|
3564
|
+
}
|
|
3565
|
+
__decorate([
|
|
3566
|
+
$mol_wire_field
|
|
3567
|
+
], App, "low", void 0);
|
|
3568
|
+
__decorate([
|
|
3569
|
+
$mol_wire_field
|
|
3570
|
+
], App, "high", null);
|
|
3571
|
+
__decorate([
|
|
3572
|
+
$mol_wire_method
|
|
3573
|
+
], App, "test", null);
|
|
3574
|
+
App.test();
|
|
3575
|
+
},
|
|
3576
|
+
});
|
|
3577
|
+
})($ || ($ = {}));
|
|
3578
|
+
//mol/wire/field/field.test.ts
|
|
3579
|
+
;
|
|
3580
|
+
"use strict";
|
|
3581
|
+
var $;
|
|
3582
|
+
(function ($_1) {
|
|
3583
|
+
$mol_test({
|
|
3584
|
+
'Watch one value'($) {
|
|
3585
|
+
class App extends $mol_object2 {
|
|
3586
|
+
static $ = $;
|
|
3587
|
+
static set = new $mol_wire_set();
|
|
3588
|
+
static lucky() {
|
|
3589
|
+
return this.set.has(777);
|
|
3590
|
+
}
|
|
3591
|
+
}
|
|
3592
|
+
__decorate([
|
|
3593
|
+
$mol_wire_mem(0)
|
|
3594
|
+
], App, "lucky", null);
|
|
3595
|
+
$mol_assert_equal(App.lucky(), false);
|
|
3596
|
+
App.set.add(666);
|
|
3597
|
+
$mol_assert_equal(App.lucky(), false);
|
|
3598
|
+
App.set.add(777);
|
|
3599
|
+
$mol_assert_equal(App.lucky(), true);
|
|
3600
|
+
App.set.delete(777);
|
|
3601
|
+
$mol_assert_equal(App.lucky(), false);
|
|
3602
|
+
},
|
|
3603
|
+
'Watch item channel'($) {
|
|
3604
|
+
class App extends $mol_object2 {
|
|
3605
|
+
static $ = $;
|
|
3606
|
+
static set = new $mol_wire_set();
|
|
3607
|
+
static lucky() {
|
|
3608
|
+
return this.set.item(777);
|
|
3609
|
+
}
|
|
3610
|
+
}
|
|
3611
|
+
__decorate([
|
|
3612
|
+
$mol_wire_mem(0)
|
|
3613
|
+
], App, "lucky", null);
|
|
3614
|
+
$mol_assert_equal(App.lucky(), false);
|
|
3615
|
+
App.set.item(666, true);
|
|
3616
|
+
$mol_assert_equal(App.lucky(), false);
|
|
3617
|
+
App.set.item(777, true);
|
|
3618
|
+
$mol_assert_equal(App.lucky(), true);
|
|
3619
|
+
App.set.item(777, false);
|
|
3620
|
+
$mol_assert_equal(App.lucky(), false);
|
|
3621
|
+
},
|
|
3622
|
+
'Watch size'($) {
|
|
3623
|
+
class App extends $mol_object2 {
|
|
3624
|
+
static $ = $;
|
|
3625
|
+
static set = new $mol_wire_set();
|
|
3626
|
+
static size() {
|
|
3627
|
+
return this.set.size;
|
|
3628
|
+
}
|
|
3629
|
+
}
|
|
3630
|
+
__decorate([
|
|
3631
|
+
$mol_wire_mem(0)
|
|
3632
|
+
], App, "size", null);
|
|
3633
|
+
$mol_assert_equal(App.size(), 0);
|
|
3634
|
+
App.set.add(666);
|
|
3635
|
+
$mol_assert_equal(App.size(), 1);
|
|
3636
|
+
App.set.add(777);
|
|
3637
|
+
$mol_assert_equal(App.size(), 2);
|
|
3638
|
+
App.set.delete(777);
|
|
3639
|
+
$mol_assert_equal(App.size(), 1);
|
|
3640
|
+
},
|
|
3641
|
+
'Watch for-of'($) {
|
|
3642
|
+
class App extends $mol_object2 {
|
|
3643
|
+
static $ = $;
|
|
3644
|
+
static set = new $mol_wire_set();
|
|
3645
|
+
static sum() {
|
|
3646
|
+
let res = 0;
|
|
3647
|
+
for (const val of this.set) {
|
|
3648
|
+
res += val;
|
|
3649
|
+
}
|
|
3650
|
+
return res;
|
|
3651
|
+
}
|
|
3652
|
+
}
|
|
3653
|
+
__decorate([
|
|
3654
|
+
$mol_wire_mem(0)
|
|
3655
|
+
], App, "sum", null);
|
|
3656
|
+
$mol_assert_equal(App.sum(), 0);
|
|
3657
|
+
App.set.add(111);
|
|
3658
|
+
$mol_assert_equal(App.sum(), 111);
|
|
3659
|
+
App.set.add(222);
|
|
3660
|
+
$mol_assert_equal(App.sum(), 333);
|
|
3661
|
+
App.set.delete(111);
|
|
3662
|
+
$mol_assert_equal(App.sum(), 222);
|
|
3663
|
+
},
|
|
3664
|
+
'Watch forEach'($) {
|
|
3665
|
+
class App extends $mol_object2 {
|
|
3666
|
+
static $ = $;
|
|
3667
|
+
static set = new $mol_wire_set();
|
|
3668
|
+
static sum() {
|
|
3669
|
+
let res = 0;
|
|
3670
|
+
this.set.forEach(val => res += val);
|
|
3671
|
+
return res;
|
|
3672
|
+
}
|
|
3673
|
+
}
|
|
3674
|
+
__decorate([
|
|
3675
|
+
$mol_wire_mem(0)
|
|
3676
|
+
], App, "sum", null);
|
|
3677
|
+
$mol_assert_equal(App.sum(), 0);
|
|
3678
|
+
App.set.add(111);
|
|
3679
|
+
$mol_assert_equal(App.sum(), 111);
|
|
3680
|
+
App.set.add(222);
|
|
3681
|
+
$mol_assert_equal(App.sum(), 333);
|
|
3682
|
+
App.set.delete(111);
|
|
3683
|
+
$mol_assert_equal(App.sum(), 222);
|
|
3684
|
+
},
|
|
3685
|
+
});
|
|
3686
|
+
})($ || ($ = {}));
|
|
3687
|
+
//mol/wire/set/set.test.ts
|
|
3688
|
+
;
|
|
3689
|
+
"use strict";
|
|
3690
|
+
var $;
|
|
3691
|
+
(function ($_1) {
|
|
3692
|
+
$mol_test({
|
|
3693
|
+
'Watch one value'($) {
|
|
3694
|
+
class App extends $mol_object2 {
|
|
3695
|
+
static $ = $;
|
|
3696
|
+
static dict = new $mol_wire_dict();
|
|
3697
|
+
static lucky() {
|
|
3698
|
+
return this.dict.get(777);
|
|
3699
|
+
}
|
|
3700
|
+
}
|
|
3701
|
+
__decorate([
|
|
3702
|
+
$mol_wire_mem(0)
|
|
3703
|
+
], App, "lucky", null);
|
|
3704
|
+
$mol_assert_equal(App.lucky(), undefined);
|
|
3705
|
+
App.dict.set(666, 6666);
|
|
3706
|
+
$mol_assert_equal(App.lucky(), undefined);
|
|
3707
|
+
App.dict.set(777, 7777);
|
|
3708
|
+
$mol_assert_equal(App.lucky(), 7777);
|
|
3709
|
+
App.dict.delete(777);
|
|
3710
|
+
$mol_assert_equal(App.lucky(), undefined);
|
|
3711
|
+
},
|
|
3712
|
+
'Watch item channel'($) {
|
|
3713
|
+
class App extends $mol_object2 {
|
|
3714
|
+
static $ = $;
|
|
3715
|
+
static dict = new $mol_wire_dict();
|
|
3716
|
+
static lucky() {
|
|
3717
|
+
return this.dict.item(777);
|
|
3718
|
+
}
|
|
3719
|
+
}
|
|
3720
|
+
__decorate([
|
|
3721
|
+
$mol_wire_mem(0)
|
|
3722
|
+
], App, "lucky", null);
|
|
3723
|
+
$mol_assert_equal(App.lucky(), null);
|
|
3724
|
+
App.dict.item(666, 6666);
|
|
3725
|
+
$mol_assert_equal(App.lucky(), null);
|
|
3726
|
+
App.dict.item(777, 7777);
|
|
3727
|
+
$mol_assert_equal(App.lucky(), 7777);
|
|
3728
|
+
App.dict.item(777, null);
|
|
3729
|
+
$mol_assert_equal(App.lucky(), null);
|
|
3730
|
+
},
|
|
3731
|
+
'Watch size'($) {
|
|
3732
|
+
class App extends $mol_object2 {
|
|
3733
|
+
static $ = $;
|
|
3734
|
+
static dict = new $mol_wire_dict();
|
|
3735
|
+
static size() {
|
|
3736
|
+
return this.dict.size;
|
|
3737
|
+
}
|
|
3738
|
+
}
|
|
3739
|
+
__decorate([
|
|
3740
|
+
$mol_wire_mem(0)
|
|
3741
|
+
], App, "size", null);
|
|
3742
|
+
$mol_assert_equal(App.size(), 0);
|
|
3743
|
+
App.dict.set(666, 6666);
|
|
3744
|
+
$mol_assert_equal(App.size(), 1);
|
|
3745
|
+
App.dict.set(777, 7777);
|
|
3746
|
+
$mol_assert_equal(App.size(), 2);
|
|
3747
|
+
App.dict.delete(777);
|
|
3748
|
+
$mol_assert_equal(App.size(), 1);
|
|
3749
|
+
},
|
|
3750
|
+
'Watch for-of'($) {
|
|
3751
|
+
class App extends $mol_object2 {
|
|
3752
|
+
static $ = $;
|
|
3753
|
+
static dict = new $mol_wire_dict();
|
|
3754
|
+
static sum() {
|
|
3755
|
+
let keys = 0;
|
|
3756
|
+
let vals = 0;
|
|
3757
|
+
for (const [key, val] of this.dict) {
|
|
3758
|
+
keys += key;
|
|
3759
|
+
vals += val;
|
|
3760
|
+
}
|
|
3761
|
+
return [keys, vals];
|
|
3762
|
+
}
|
|
3763
|
+
}
|
|
3764
|
+
__decorate([
|
|
3765
|
+
$mol_wire_mem(0)
|
|
3766
|
+
], App, "sum", null);
|
|
3767
|
+
$mol_assert_like(App.sum(), [0, 0]);
|
|
3768
|
+
App.dict.set(111, 1111);
|
|
3769
|
+
$mol_assert_like(App.sum(), [111, 1111]);
|
|
3770
|
+
App.dict.set(222, 2222);
|
|
3771
|
+
$mol_assert_like(App.sum(), [333, 3333]);
|
|
3772
|
+
App.dict.delete(111);
|
|
3773
|
+
$mol_assert_like(App.sum(), [222, 2222]);
|
|
3774
|
+
},
|
|
3775
|
+
'Watch forEach'($) {
|
|
3776
|
+
class App extends $mol_object2 {
|
|
3777
|
+
static $ = $;
|
|
3778
|
+
static dict = new $mol_wire_dict();
|
|
3779
|
+
static sum() {
|
|
3780
|
+
let keys = 0;
|
|
3781
|
+
let vals = 0;
|
|
3782
|
+
this.dict.forEach((val, key) => {
|
|
3783
|
+
keys += key;
|
|
3784
|
+
vals += val;
|
|
3785
|
+
});
|
|
3786
|
+
return [keys, vals];
|
|
3787
|
+
}
|
|
3788
|
+
}
|
|
3789
|
+
__decorate([
|
|
3790
|
+
$mol_wire_mem(0)
|
|
3791
|
+
], App, "sum", null);
|
|
3792
|
+
$mol_assert_like(App.sum(), [0, 0]);
|
|
3793
|
+
App.dict.set(111, 1111);
|
|
3794
|
+
$mol_assert_like(App.sum(), [111, 1111]);
|
|
3795
|
+
App.dict.set(222, 2222);
|
|
3796
|
+
$mol_assert_like(App.sum(), [333, 3333]);
|
|
3797
|
+
App.dict.delete(111);
|
|
3798
|
+
$mol_assert_like(App.sum(), [222, 2222]);
|
|
3799
|
+
},
|
|
3800
|
+
});
|
|
3801
|
+
})($ || ($ = {}));
|
|
3802
|
+
//mol/wire/dict/dict.test.ts
|
|
3818
3803
|
|
|
3819
3804
|
//# sourceMappingURL=node.test.js.map
|