mol_wire_lib 1.0.111 → 1.0.114

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.test.js CHANGED
@@ -873,7 +873,7 @@ var $;
873
873
  (function ($) {
874
874
  class $mol_wire_task extends $mol_wire_fiber {
875
875
  static getter(task) {
876
- return function $mol_wire_fiber_temp_get(host, args) {
876
+ return function $mol_wire_task_get(host, args) {
877
877
  const existen = $mol_wire_auto()?.track_next();
878
878
  reuse: if (existen) {
879
879
  if (!(existen instanceof $mol_wire_task))
@@ -998,7 +998,7 @@ var $;
998
998
  static getter(task, keys) {
999
999
  const field = task.name + '()';
1000
1000
  if (keys) {
1001
- return function $mol_wire_fiber_persist_get(host, args) {
1001
+ return function $mol_wire_atom_get(host, args) {
1002
1002
  let dict, key, fiber;
1003
1003
  key = `${host?.[Symbol.toStringTag] ?? host}.${task.name}(${args.map(v => $mol_key(v)).join(',')})`;
1004
1004
  dict = Object.getOwnPropertyDescriptor(host ?? task, field)?.value;
@@ -1016,7 +1016,7 @@ var $;
1016
1016
  };
1017
1017
  }
1018
1018
  else {
1019
- return function $mol_wire_fiber_persist_get(host, args) {
1019
+ return function $mol_wire_atom_get(host, args) {
1020
1020
  const existen = Object.getOwnPropertyDescriptor(host ?? task, field)?.value;
1021
1021
  if (existen)
1022
1022
  return existen;
@@ -2646,68 +2646,63 @@ var $;
2646
2646
  ;
2647
2647
  "use strict";
2648
2648
  var $;
2649
- (function ($) {
2650
- $.$mol_after_mock_queue = [];
2651
- function $mol_after_mock_warp() {
2652
- const queue = $.$mol_after_mock_queue.splice(0);
2653
- for (const task of queue)
2654
- task();
2655
- }
2656
- $.$mol_after_mock_warp = $mol_after_mock_warp;
2657
- class $mol_after_mock_commmon extends $mol_object2 {
2658
- task;
2659
- promise = Promise.resolve();
2660
- cancelled = false;
2661
- id;
2662
- constructor(task) {
2663
- super();
2664
- this.task = task;
2665
- $.$mol_after_mock_queue.push(task);
2666
- }
2667
- destructor() {
2668
- const index = $.$mol_after_mock_queue.indexOf(this.task);
2669
- if (index >= 0)
2670
- $.$mol_after_mock_queue.splice(index, 1);
2671
- }
2672
- }
2673
- $.$mol_after_mock_commmon = $mol_after_mock_commmon;
2674
- class $mol_after_mock_timeout extends $mol_after_mock_commmon {
2675
- delay;
2676
- constructor(delay, task) {
2677
- super(task);
2678
- this.delay = delay;
2679
- }
2680
- }
2681
- $.$mol_after_mock_timeout = $mol_after_mock_timeout;
2682
- })($ || ($ = {}));
2683
- //mol/after/mock/mock.test.ts
2684
- ;
2685
- "use strict";
2686
- var $;
2687
2649
  (function ($_1) {
2688
2650
  $mol_test({
2689
- async 'Latest Calls Wins on Concurrency'($) {
2690
- class NameLogger extends $mol_object2 {
2691
- static $ = $;
2692
- static first = [];
2693
- static last = [];
2694
- static send(next) {
2695
- $mol_wire_sync(this.first).push(next);
2696
- this.$.$mol_wait_timeout(0);
2697
- this.last.push(next);
2698
- }
2651
+ 'tree parsing'() {
2652
+ $mol_assert_equal($mol_tree.fromString("foo\nbar\n").sub.length, 2);
2653
+ $mol_assert_equal($mol_tree.fromString("foo\nbar\n").sub[1].type, "bar");
2654
+ $mol_assert_equal($mol_tree.fromString("foo\n\n\n").sub.length, 1);
2655
+ $mol_assert_equal($mol_tree.fromString("=foo\n\\bar\n").sub.length, 2);
2656
+ $mol_assert_equal($mol_tree.fromString("=foo\n\\bar\n").sub[1].data, "bar");
2657
+ $mol_assert_equal($mol_tree.fromString("foo bar \\pol").sub[0].sub[0].sub[0].data, "pol");
2658
+ $mol_assert_equal($mol_tree.fromString("foo bar\n\t\\pol\n\t\\men").sub[0].sub[0].sub[1].data, "men");
2659
+ $mol_assert_equal($mol_tree.fromString('foo bar \\text\n').toString(), 'foo bar \\text\n');
2660
+ },
2661
+ 'inserting'() {
2662
+ $mol_assert_equal($mol_tree.fromString('a b c d').insert(new $mol_tree, 'a', 'b', 'c').toString(), 'a b \\\n');
2663
+ $mol_assert_equal($mol_tree.fromString('a b').insert(new $mol_tree, 'a', 'b', 'c', 'd').toString(), 'a b c \\\n');
2664
+ $mol_assert_equal($mol_tree.fromString('a b c d').insert(new $mol_tree, 0, 0, 0).toString(), 'a b \\\n');
2665
+ $mol_assert_equal($mol_tree.fromString('a b').insert(new $mol_tree, 0, 0, 0, 0).toString(), 'a b \\\n\t\\\n');
2666
+ $mol_assert_equal($mol_tree.fromString('a b c d').insert(new $mol_tree, null, null, null).toString(), 'a b \\\n');
2667
+ $mol_assert_equal($mol_tree.fromString('a b').insert(new $mol_tree, null, null, null, null).toString(), 'a b \\\n\t\\\n');
2668
+ },
2669
+ 'fromJSON'() {
2670
+ $mol_assert_equal($mol_tree.fromJSON([]).toString(), '/\n');
2671
+ $mol_assert_equal($mol_tree.fromJSON([false, true]).toString(), '/\n\tfalse\n\ttrue\n');
2672
+ $mol_assert_equal($mol_tree.fromJSON([0, 1, 2.3]).toString(), '/\n\t0\n\t1\n\t2.3\n');
2673
+ $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');
2674
+ $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');
2675
+ },
2676
+ 'toJSON'() {
2677
+ $mol_assert_equal(JSON.stringify($mol_tree.fromString('/\n').sub[0]), '[]');
2678
+ $mol_assert_equal(JSON.stringify($mol_tree.fromString('/\n\tfalse\n\ttrue\n').sub[0]), '[false,true]');
2679
+ $mol_assert_equal(JSON.stringify($mol_tree.fromString('/\n\t0\n\t1\n\t2.3\n').sub[0]), '[0,1,2.3]');
2680
+ $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"]');
2681
+ $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"}');
2682
+ },
2683
+ 'hack'() {
2684
+ const res = $mol_tree.fromString(`foo bar xxx`).hack({
2685
+ '': (tree, context) => [tree.hack(context)],
2686
+ 'bar': (tree, context) => [tree.hack(context).clone({ type: '777' })],
2687
+ });
2688
+ $mol_assert_equal(res.toString(), new $mol_tree({ type: 'foo 777 xxx' }).toString());
2689
+ },
2690
+ 'errors handling'($) {
2691
+ const errors = [];
2692
+ class Tree extends $mol_tree {
2693
+ static $ = $.$mol_ambient({
2694
+ $mol_fail: error => errors.push(error.message)
2695
+ });
2699
2696
  }
2700
- const name = $mol_wire_async(NameLogger).send;
2701
- name('john');
2702
- const promise = name('jin');
2703
- $.$mol_after_mock_warp();
2704
- await promise;
2705
- $mol_assert_like(NameLogger.first, ['john', 'jin']);
2706
- $mol_assert_like(NameLogger.last, ['jin']);
2697
+ Tree.fromString(`
2698
+ \t \tfoo
2699
+ bar \\data
2700
+ `, 'test');
2701
+ $mol_assert_like(errors, ['Syntax error at test:2\n \tfoo']);
2707
2702
  },
2708
2703
  });
2709
2704
  })($ || ($ = {}));
2710
- //mol/wire/async/async.test.ts
2705
+ //mol/tree/tree.test.ts
2711
2706
  ;
2712
2707
  "use strict";
2713
2708
  var $;
@@ -2769,6 +2764,71 @@ var $;
2769
2764
  ;
2770
2765
  "use strict";
2771
2766
  var $;
2767
+ (function ($) {
2768
+ $.$mol_after_mock_queue = [];
2769
+ function $mol_after_mock_warp() {
2770
+ const queue = $.$mol_after_mock_queue.splice(0);
2771
+ for (const task of queue)
2772
+ task();
2773
+ }
2774
+ $.$mol_after_mock_warp = $mol_after_mock_warp;
2775
+ class $mol_after_mock_commmon extends $mol_object2 {
2776
+ task;
2777
+ promise = Promise.resolve();
2778
+ cancelled = false;
2779
+ id;
2780
+ constructor(task) {
2781
+ super();
2782
+ this.task = task;
2783
+ $.$mol_after_mock_queue.push(task);
2784
+ }
2785
+ destructor() {
2786
+ const index = $.$mol_after_mock_queue.indexOf(this.task);
2787
+ if (index >= 0)
2788
+ $.$mol_after_mock_queue.splice(index, 1);
2789
+ }
2790
+ }
2791
+ $.$mol_after_mock_commmon = $mol_after_mock_commmon;
2792
+ class $mol_after_mock_timeout extends $mol_after_mock_commmon {
2793
+ delay;
2794
+ constructor(delay, task) {
2795
+ super(task);
2796
+ this.delay = delay;
2797
+ }
2798
+ }
2799
+ $.$mol_after_mock_timeout = $mol_after_mock_timeout;
2800
+ })($ || ($ = {}));
2801
+ //mol/after/mock/mock.test.ts
2802
+ ;
2803
+ "use strict";
2804
+ var $;
2805
+ (function ($_1) {
2806
+ $mol_test({
2807
+ async 'Latest Calls Wins on Concurrency'($) {
2808
+ class NameLogger extends $mol_object2 {
2809
+ static $ = $;
2810
+ static first = [];
2811
+ static last = [];
2812
+ static send(next) {
2813
+ $mol_wire_sync(this.first).push(next);
2814
+ this.$.$mol_wait_timeout(0);
2815
+ this.last.push(next);
2816
+ }
2817
+ }
2818
+ const name = $mol_wire_async(NameLogger).send;
2819
+ name('john');
2820
+ const promise = name('jin');
2821
+ $.$mol_after_mock_warp();
2822
+ await promise;
2823
+ $mol_assert_like(NameLogger.first, ['john', 'jin']);
2824
+ $mol_assert_like(NameLogger.last, ['jin']);
2825
+ },
2826
+ });
2827
+ })($ || ($ = {}));
2828
+ //mol/wire/async/async.test.ts
2829
+ ;
2830
+ "use strict";
2831
+ var $;
2772
2832
  (function ($_1) {
2773
2833
  $mol_test_mocks.push($ => {
2774
2834
  $.$mol_after_timeout = $mol_after_mock_timeout;
@@ -2869,61 +2929,6 @@ var $;
2869
2929
  ;
2870
2930
  "use strict";
2871
2931
  var $;
2872
- (function ($) {
2873
- $mol_test({
2874
- 'Primitives'() {
2875
- $mol_assert_equal($mol_key(null), 'null');
2876
- $mol_assert_equal($mol_key(false), 'false');
2877
- $mol_assert_equal($mol_key(true), 'true');
2878
- $mol_assert_equal($mol_key(0), '0');
2879
- $mol_assert_equal($mol_key(''), '""');
2880
- },
2881
- 'Array & POJO'() {
2882
- $mol_assert_equal($mol_key([null]), '[null]');
2883
- $mol_assert_equal($mol_key({ foo: 0 }), '{"foo":0}');
2884
- $mol_assert_equal($mol_key({ foo: [false] }), '{"foo":[false]}');
2885
- },
2886
- 'Function'() {
2887
- const func = () => { };
2888
- $mol_assert_equal($mol_key(func), $mol_key(func));
2889
- $mol_assert_unique($mol_key(func), $mol_key(() => { }));
2890
- },
2891
- 'Objects'() {
2892
- class User {
2893
- }
2894
- const jin = new User();
2895
- $mol_assert_equal($mol_key(jin), $mol_key(jin));
2896
- $mol_assert_unique($mol_key(jin), $mol_key(new User()));
2897
- },
2898
- 'Elements'() {
2899
- const foo = $mol_jsx("div", null, "bar");
2900
- $mol_assert_equal($mol_key(foo), $mol_key(foo));
2901
- $mol_assert_unique($mol_key(foo), $mol_key($mol_jsx("div", null, "bar")));
2902
- },
2903
- 'Custom JSON representation'() {
2904
- class User {
2905
- name;
2906
- age;
2907
- constructor(name, age) {
2908
- this.name = name;
2909
- this.age = age;
2910
- }
2911
- toJSON() { return { name: this.name }; }
2912
- }
2913
- $mol_assert_equal($mol_key(new User('jin', 18)), '{"name":"jin"}');
2914
- },
2915
- 'Special native classes'() {
2916
- $mol_assert_equal($mol_key(new Date('xyz')), 'null');
2917
- $mol_assert_equal($mol_key(new Date('2001-01-02T03:04:05.678Z')), '"2001-01-02T03:04:05.678Z"');
2918
- $mol_assert_equal($mol_key(/./), '"/./"');
2919
- $mol_assert_equal($mol_key(/\./gimsu), '"/\\\\./gimsu"');
2920
- },
2921
- });
2922
- })($ || ($ = {}));
2923
- //mol/key/key.test.tsx
2924
- ;
2925
- "use strict";
2926
- var $;
2927
2932
  (function ($_1) {
2928
2933
  $mol_test({
2929
2934
  'Cached channel'($) {
@@ -3479,70 +3484,65 @@ var $;
3479
3484
  ;
3480
3485
  "use strict";
3481
3486
  var $;
3482
- (function ($_1) {
3487
+ (function ($) {
3483
3488
  $mol_test({
3484
- 'tree parsing'() {
3485
- $mol_assert_equal($mol_tree.fromString("foo\nbar\n").sub.length, 2);
3486
- $mol_assert_equal($mol_tree.fromString("foo\nbar\n").sub[1].type, "bar");
3487
- $mol_assert_equal($mol_tree.fromString("foo\n\n\n").sub.length, 1);
3488
- $mol_assert_equal($mol_tree.fromString("=foo\n\\bar\n").sub.length, 2);
3489
- $mol_assert_equal($mol_tree.fromString("=foo\n\\bar\n").sub[1].data, "bar");
3490
- $mol_assert_equal($mol_tree.fromString("foo bar \\pol").sub[0].sub[0].sub[0].data, "pol");
3491
- $mol_assert_equal($mol_tree.fromString("foo bar\n\t\\pol\n\t\\men").sub[0].sub[0].sub[1].data, "men");
3492
- $mol_assert_equal($mol_tree.fromString('foo bar \\text\n').toString(), 'foo bar \\text\n');
3489
+ 'Primitives'() {
3490
+ $mol_assert_equal($mol_key(null), 'null');
3491
+ $mol_assert_equal($mol_key(false), 'false');
3492
+ $mol_assert_equal($mol_key(true), 'true');
3493
+ $mol_assert_equal($mol_key(0), '0');
3494
+ $mol_assert_equal($mol_key(''), '""');
3493
3495
  },
3494
- 'inserting'() {
3495
- $mol_assert_equal($mol_tree.fromString('a b c d').insert(new $mol_tree, 'a', 'b', 'c').toString(), 'a b \\\n');
3496
- $mol_assert_equal($mol_tree.fromString('a b').insert(new $mol_tree, 'a', 'b', 'c', 'd').toString(), 'a b c \\\n');
3497
- $mol_assert_equal($mol_tree.fromString('a b c d').insert(new $mol_tree, 0, 0, 0).toString(), 'a b \\\n');
3498
- $mol_assert_equal($mol_tree.fromString('a b').insert(new $mol_tree, 0, 0, 0, 0).toString(), 'a b \\\n\t\\\n');
3499
- $mol_assert_equal($mol_tree.fromString('a b c d').insert(new $mol_tree, null, null, null).toString(), 'a b \\\n');
3500
- $mol_assert_equal($mol_tree.fromString('a b').insert(new $mol_tree, null, null, null, null).toString(), 'a b \\\n\t\\\n');
3496
+ 'Array & POJO'() {
3497
+ $mol_assert_equal($mol_key([null]), '[null]');
3498
+ $mol_assert_equal($mol_key({ foo: 0 }), '{"foo":0}');
3499
+ $mol_assert_equal($mol_key({ foo: [false] }), '{"foo":[false]}');
3501
3500
  },
3502
- 'fromJSON'() {
3503
- $mol_assert_equal($mol_tree.fromJSON([]).toString(), '/\n');
3504
- $mol_assert_equal($mol_tree.fromJSON([false, true]).toString(), '/\n\tfalse\n\ttrue\n');
3505
- $mol_assert_equal($mol_tree.fromJSON([0, 1, 2.3]).toString(), '/\n\t0\n\t1\n\t2.3\n');
3506
- $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');
3507
- $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');
3501
+ 'Function'() {
3502
+ const func = () => { };
3503
+ $mol_assert_equal($mol_key(func), $mol_key(func));
3504
+ $mol_assert_unique($mol_key(func), $mol_key(() => { }));
3508
3505
  },
3509
- 'toJSON'() {
3510
- $mol_assert_equal(JSON.stringify($mol_tree.fromString('/\n').sub[0]), '[]');
3511
- $mol_assert_equal(JSON.stringify($mol_tree.fromString('/\n\tfalse\n\ttrue\n').sub[0]), '[false,true]');
3512
- $mol_assert_equal(JSON.stringify($mol_tree.fromString('/\n\t0\n\t1\n\t2.3\n').sub[0]), '[0,1,2.3]');
3513
- $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"]');
3514
- $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"}');
3506
+ 'Objects'() {
3507
+ class User {
3508
+ }
3509
+ const jin = new User();
3510
+ $mol_assert_equal($mol_key(jin), $mol_key(jin));
3511
+ $mol_assert_unique($mol_key(jin), $mol_key(new User()));
3515
3512
  },
3516
- 'hack'() {
3517
- const res = $mol_tree.fromString(`foo bar xxx`).hack({
3518
- '': (tree, context) => [tree.hack(context)],
3519
- 'bar': (tree, context) => [tree.hack(context).clone({ type: '777' })],
3520
- });
3521
- $mol_assert_equal(res.toString(), new $mol_tree({ type: 'foo 777 xxx' }).toString());
3513
+ 'Elements'() {
3514
+ const foo = $mol_jsx("div", null, "bar");
3515
+ $mol_assert_equal($mol_key(foo), $mol_key(foo));
3516
+ $mol_assert_unique($mol_key(foo), $mol_key($mol_jsx("div", null, "bar")));
3522
3517
  },
3523
- 'errors handling'($) {
3524
- const errors = [];
3525
- class Tree extends $mol_tree {
3526
- static $ = $.$mol_ambient({
3527
- $mol_fail: error => errors.push(error.message)
3528
- });
3518
+ 'Custom JSON representation'() {
3519
+ class User {
3520
+ name;
3521
+ age;
3522
+ constructor(name, age) {
3523
+ this.name = name;
3524
+ this.age = age;
3525
+ }
3526
+ toJSON() { return { name: this.name }; }
3529
3527
  }
3530
- Tree.fromString(`
3531
- \t \tfoo
3532
- bar \\data
3533
- `, 'test');
3534
- $mol_assert_like(errors, ['Syntax error at test:2\n \tfoo']);
3528
+ $mol_assert_equal($mol_key(new User('jin', 18)), '{"name":"jin"}');
3529
+ },
3530
+ 'Special native classes'() {
3531
+ $mol_assert_equal($mol_key(new Date('xyz')), 'null');
3532
+ $mol_assert_equal($mol_key(new Date('2001-01-02T03:04:05.678Z')), '"2001-01-02T03:04:05.678Z"');
3533
+ $mol_assert_equal($mol_key(/./), '"/./"');
3534
+ $mol_assert_equal($mol_key(/\./gimsu), '"/\\\\./gimsu"');
3535
3535
  },
3536
3536
  });
3537
3537
  })($ || ($ = {}));
3538
- //mol/tree/tree.test.ts
3538
+ //mol/key/key.test.tsx
3539
3539
  ;
3540
3540
  "use strict";
3541
3541
  var $;
3542
3542
  (function ($) {
3543
3543
  $mol_wire_log.active();
3544
3544
  })($ || ($ = {}));
3545
- //mol/wire/wire.test.ts
3545
+ //mol/wire/atom/atom.test.ts
3546
3546
  ;
3547
3547
  "use strict";
3548
3548
  var $;