mol_wire_dom 0.0.1613 → 0.0.1615

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.mjs CHANGED
@@ -2062,13 +2062,7 @@ var $node = new Proxy({ require }, {
2062
2062
  target.require.resolve(name);
2063
2063
  }
2064
2064
  catch {
2065
- try {
2066
- $$.$mol_exec('.', 'npm', 'install', '--omit=dev', name);
2067
- }
2068
- catch (e) {
2069
- if ($$.$mol_promise_like(e))
2070
- $$.$mol_fail_hidden(e);
2071
- }
2065
+ $$.$mol_exec('.', 'npm', 'install', '--omit=dev', name);
2072
2066
  try {
2073
2067
  $$.$mol_exec('.', 'npm', 'install', '--omit=dev', '@types/' + name);
2074
2068
  }
package/node.test.js CHANGED
@@ -2053,13 +2053,7 @@ var $node = new Proxy({ require }, {
2053
2053
  target.require.resolve(name);
2054
2054
  }
2055
2055
  catch {
2056
- try {
2057
- $$.$mol_exec('.', 'npm', 'install', '--omit=dev', name);
2058
- }
2059
- catch (e) {
2060
- if ($$.$mol_promise_like(e))
2061
- $$.$mol_fail_hidden(e);
2062
- }
2056
+ $$.$mol_exec('.', 'npm', 'install', '--omit=dev', name);
2063
2057
  try {
2064
2058
  $$.$mol_exec('.', 'npm', 'install', '--omit=dev', '@types/' + name);
2065
2059
  }
@@ -2691,12 +2685,215 @@ var $;
2691
2685
 
2692
2686
  ;
2693
2687
  "use strict";
2688
+ var $;
2689
+ (function ($_1) {
2690
+ $mol_test({
2691
+ 'FQN of anon function'($) {
2692
+ const $$ = Object.assign($, { $mol_func_name_test: (() => () => { })() });
2693
+ $mol_assert_equal($$.$mol_func_name_test.name, '');
2694
+ $mol_assert_equal($$.$mol_func_name($$.$mol_func_name_test), '$mol_func_name_test');
2695
+ $mol_assert_equal($$.$mol_func_name_test.name, '$mol_func_name_test');
2696
+ },
2697
+ });
2698
+ })($ || ($ = {}));
2699
+
2700
+ ;
2701
+ "use strict";
2702
+ var $;
2703
+ (function ($) {
2704
+ $mol_test({
2705
+ 'auto name'() {
2706
+ class Invalid extends $mol_error_mix {
2707
+ }
2708
+ const mix = new Invalid('foo');
2709
+ $mol_assert_equal(mix.name, 'Invalid_Error');
2710
+ },
2711
+ 'simpe mix'() {
2712
+ const mix = new $mol_error_mix('foo', {}, new Error('bar'), new Error('lol'));
2713
+ $mol_assert_equal(mix.message, 'foo');
2714
+ $mol_assert_equal(mix.errors.map(e => e.message), ['bar', 'lol']);
2715
+ },
2716
+ 'provide additional info'() {
2717
+ class Invalid extends $mol_error_mix {
2718
+ }
2719
+ const mix = new $mol_error_mix('Wrong password', {}, new Invalid('Too short', { value: 'p@ssw0rd', hint: '> 8 letters' }), new Invalid('Too simple', { value: 'p@ssw0rd', hint: 'need capital letter' }));
2720
+ const hints = [];
2721
+ if (mix instanceof $mol_error_mix) {
2722
+ for (const er of mix.errors) {
2723
+ if (er instanceof Invalid) {
2724
+ hints.push(er.cause?.hint ?? '');
2725
+ }
2726
+ }
2727
+ }
2728
+ $mol_assert_equal(hints, ['> 8 letters', 'need capital letter']);
2729
+ },
2730
+ });
2731
+ })($ || ($ = {}));
2732
+
2733
+ ;
2734
+ "use strict";
2735
+
2736
+ ;
2737
+ "use strict";
2738
+
2739
+ ;
2740
+ "use strict";
2741
+
2742
+ ;
2743
+ "use strict";
2744
+
2745
+ ;
2746
+ "use strict";
2747
+
2748
+ ;
2749
+ "use strict";
2750
+
2751
+ ;
2752
+ "use strict";
2753
+ var $;
2754
+ (function ($_1) {
2755
+ $mol_test({
2756
+ 'init with overload'() {
2757
+ class X extends $mol_object {
2758
+ foo() {
2759
+ return 1;
2760
+ }
2761
+ }
2762
+ var x = X.make({
2763
+ foo: () => 2,
2764
+ });
2765
+ $mol_assert_equal(x.foo(), 2);
2766
+ },
2767
+ 'Context in instance inherits from class'($) {
2768
+ const custom = $.$mol_ambient({});
2769
+ class X extends $.$mol_object {
2770
+ static $ = custom;
2771
+ }
2772
+ $mol_assert_equal(new X().$, custom);
2773
+ },
2774
+ });
2775
+ })($ || ($ = {}));
2776
+
2777
+ ;
2778
+ "use strict";
2779
+ var $;
2780
+ (function ($_1) {
2781
+ $mol_test({
2782
+ 'test types'($) {
2783
+ class A {
2784
+ static a() {
2785
+ return Promise.resolve('');
2786
+ }
2787
+ static b() {
2788
+ return $mol_wire_sync(this).a();
2789
+ }
2790
+ }
2791
+ },
2792
+ async 'test method from host'($) {
2793
+ let count = 0;
2794
+ class A {
2795
+ static a() {
2796
+ return $mol_wire_sync(this).b();
2797
+ }
2798
+ static b() { return Promise.resolve(++count); }
2799
+ }
2800
+ $mol_assert_equal(await $mol_wire_async(A).a(), 1, count);
2801
+ },
2802
+ async 'test function'($) {
2803
+ let count = 0;
2804
+ class A {
2805
+ static a() {
2806
+ return $mol_wire_sync(this.b)();
2807
+ }
2808
+ static b() { return Promise.resolve(++count); }
2809
+ }
2810
+ $mol_assert_equal(await $mol_wire_async(A).a(), 1, count);
2811
+ },
2812
+ async 'test construct itself'($) {
2813
+ class A {
2814
+ static instances = [];
2815
+ static a() {
2816
+ const a = new ($mol_wire_sync(A))();
2817
+ this.instances.push(a);
2818
+ $mol_wire_sync(this).b();
2819
+ }
2820
+ static b() { return Promise.resolve(); }
2821
+ }
2822
+ await $mol_wire_async(A).a();
2823
+ $mol_assert_equal(A.instances.length, 2);
2824
+ $mol_assert_equal(A.instances[0] instanceof A, true);
2825
+ $mol_assert_equal(A.instances[0], A.instances[1]);
2826
+ }
2827
+ });
2828
+ })($ || ($ = {}));
2694
2829
 
2695
2830
  ;
2696
2831
  "use strict";
2832
+ var $;
2833
+ (function ($_1) {
2834
+ $mol_test_mocks.push($ => {
2835
+ $.$mol_log3_come = () => { };
2836
+ $.$mol_log3_done = () => { };
2837
+ $.$mol_log3_fail = () => { };
2838
+ $.$mol_log3_warn = () => { };
2839
+ $.$mol_log3_rise = () => { };
2840
+ $.$mol_log3_area = () => () => { };
2841
+ });
2842
+ })($ || ($ = {}));
2697
2843
 
2698
2844
  ;
2699
2845
  "use strict";
2846
+ var $;
2847
+ (function ($_1) {
2848
+ $mol_test({
2849
+ async 'exec timeout auto kill child process'($) {
2850
+ let close_mock = () => { };
2851
+ const error_message = 'Run error, timeout';
2852
+ function mol_run_spawn_sync_mock() {
2853
+ return {
2854
+ output: [],
2855
+ stdout: error_message,
2856
+ stderr: '',
2857
+ status: 0,
2858
+ signal: null,
2859
+ pid: 123,
2860
+ };
2861
+ }
2862
+ function mol_run_spawn_mock() {
2863
+ return {
2864
+ on(name, cb) {
2865
+ if (name === 'exit')
2866
+ close_mock = cb;
2867
+ },
2868
+ kill() { close_mock(); }
2869
+ };
2870
+ }
2871
+ const context_mock = $.$mol_ambient({
2872
+ $mol_run_spawn_sync: mol_run_spawn_sync_mock,
2873
+ $mol_run_spawn: mol_run_spawn_mock
2874
+ });
2875
+ class $mol_run_mock extends $mol_run {
2876
+ static get $() { return context_mock; }
2877
+ static async_enabled() {
2878
+ return true;
2879
+ }
2880
+ }
2881
+ let message = '';
2882
+ try {
2883
+ const res = await $mol_wire_async($mol_run_mock).spawn({
2884
+ command: 'sleep 10',
2885
+ dir: '.',
2886
+ timeout: 10,
2887
+ env: { 'MOL_RUN_ASYNC': '1' }
2888
+ });
2889
+ }
2890
+ catch (e) {
2891
+ message = e.message;
2892
+ }
2893
+ $mol_assert_equal(message, error_message);
2894
+ }
2895
+ });
2896
+ })($ || ($ = {}));
2700
2897
 
2701
2898
  ;
2702
2899
  "use strict";
@@ -3457,43 +3654,6 @@ var $;
3457
3654
  });
3458
3655
  })($ || ($ = {}));
3459
3656
 
3460
- ;
3461
- "use strict";
3462
- var $;
3463
- (function ($_1) {
3464
- $mol_test_mocks.push($ => {
3465
- $.$mol_log3_come = () => { };
3466
- $.$mol_log3_done = () => { };
3467
- $.$mol_log3_fail = () => { };
3468
- $.$mol_log3_warn = () => { };
3469
- $.$mol_log3_rise = () => { };
3470
- $.$mol_log3_area = () => () => { };
3471
- });
3472
- })($ || ($ = {}));
3473
-
3474
- ;
3475
- "use strict";
3476
-
3477
- ;
3478
- "use strict";
3479
-
3480
- ;
3481
- "use strict";
3482
-
3483
- ;
3484
- "use strict";
3485
- var $;
3486
- (function ($_1) {
3487
- $mol_test({
3488
- 'FQN of anon function'($) {
3489
- const $$ = Object.assign($, { $mol_func_name_test: (() => () => { })() });
3490
- $mol_assert_equal($$.$mol_func_name_test.name, '');
3491
- $mol_assert_equal($$.$mol_func_name($$.$mol_func_name_test), '$mol_func_name_test');
3492
- $mol_assert_equal($$.$mol_func_name_test.name, '$mol_func_name_test');
3493
- },
3494
- });
3495
- })($ || ($ = {}));
3496
-
3497
3657
  ;
3498
3658
  "use strict";
3499
3659
  var $;
@@ -4114,142 +4274,6 @@ var $;
4114
4274
  $.$mol_promise = $mol_promise;
4115
4275
  })($ || ($ = {}));
4116
4276
 
4117
- ;
4118
- "use strict";
4119
- var $;
4120
- (function ($) {
4121
- function $mol_wire_async(obj) {
4122
- let fiber;
4123
- const temp = $mol_wire_task.getter(obj);
4124
- return new Proxy(obj, {
4125
- get(obj, field) {
4126
- const val = obj[field];
4127
- if (typeof val !== 'function')
4128
- return val;
4129
- let fiber;
4130
- const temp = $mol_wire_task.getter(val);
4131
- return function $mol_wire_async(...args) {
4132
- fiber?.destructor();
4133
- fiber = temp(obj, args);
4134
- return fiber.async();
4135
- };
4136
- },
4137
- apply(obj, self, args) {
4138
- fiber?.destructor();
4139
- fiber = temp(self, args);
4140
- return fiber.async();
4141
- },
4142
- });
4143
- }
4144
- $.$mol_wire_async = $mol_wire_async;
4145
- })($ || ($ = {}));
4146
-
4147
- ;
4148
- "use strict";
4149
- var $;
4150
- (function ($_1) {
4151
- $mol_test({
4152
- 'test types'($) {
4153
- class A {
4154
- static a() {
4155
- return '';
4156
- }
4157
- static b() {
4158
- return $mol_wire_async(this).a();
4159
- }
4160
- }
4161
- },
4162
- async 'Latest method calls wins'($) {
4163
- class NameLogger extends $mol_object2 {
4164
- static $ = $;
4165
- static first = [];
4166
- static last = [];
4167
- static send(next) {
4168
- $mol_wire_sync(this.first).push(next);
4169
- $$.$mol_wait_timeout(0);
4170
- this.last.push(next);
4171
- }
4172
- }
4173
- const name = $mol_wire_async(NameLogger).send;
4174
- name('john');
4175
- const promise = name('jin');
4176
- $.$mol_after_mock_warp();
4177
- await promise;
4178
- $mol_assert_equal(NameLogger.first, ['john', 'jin']);
4179
- $mol_assert_equal(NameLogger.last, ['jin']);
4180
- },
4181
- async 'Latest function calls wins'($) {
4182
- const first = [];
4183
- const last = [];
4184
- function send_name(next) {
4185
- $mol_wire_sync(first).push(next);
4186
- $$.$mol_wait_timeout(0);
4187
- last.push(next);
4188
- }
4189
- const name = $mol_wire_async(send_name);
4190
- name('john');
4191
- const promise = name('jin');
4192
- $.$mol_after_mock_warp();
4193
- await promise;
4194
- $mol_assert_equal(first, ['john', 'jin']);
4195
- $mol_assert_equal(last, ['jin']);
4196
- },
4197
- });
4198
- })($ || ($ = {}));
4199
-
4200
- ;
4201
- "use strict";
4202
- var $;
4203
- (function ($_1) {
4204
- $mol_test({
4205
- 'test types'($) {
4206
- class A {
4207
- static a() {
4208
- return Promise.resolve('');
4209
- }
4210
- static b() {
4211
- return $mol_wire_sync(this).a();
4212
- }
4213
- }
4214
- },
4215
- async 'test method from host'($) {
4216
- let count = 0;
4217
- class A {
4218
- static a() {
4219
- return $mol_wire_sync(this).b();
4220
- }
4221
- static b() { return Promise.resolve(++count); }
4222
- }
4223
- $mol_assert_equal(await $mol_wire_async(A).a(), 1, count);
4224
- },
4225
- async 'test function'($) {
4226
- let count = 0;
4227
- class A {
4228
- static a() {
4229
- return $mol_wire_sync(this.b)();
4230
- }
4231
- static b() { return Promise.resolve(++count); }
4232
- }
4233
- $mol_assert_equal(await $mol_wire_async(A).a(), 1, count);
4234
- },
4235
- async 'test construct itself'($) {
4236
- class A {
4237
- static instances = [];
4238
- static a() {
4239
- const a = new ($mol_wire_sync(A))();
4240
- this.instances.push(a);
4241
- $mol_wire_sync(this).b();
4242
- }
4243
- static b() { return Promise.resolve(); }
4244
- }
4245
- await $mol_wire_async(A).a();
4246
- $mol_assert_equal(A.instances.length, 2);
4247
- $mol_assert_equal(A.instances[0] instanceof A, true);
4248
- $mol_assert_equal(A.instances[0], A.instances[1]);
4249
- }
4250
- });
4251
- })($ || ($ = {}));
4252
-
4253
4277
  ;
4254
4278
  "use strict";
4255
4279
  var $;
@@ -4343,6 +4367,89 @@ var $;
4343
4367
  })($$ = $_1.$$ || ($_1.$$ = {}));
4344
4368
  })($ || ($ = {}));
4345
4369
 
4370
+ ;
4371
+ "use strict";
4372
+ var $;
4373
+ (function ($) {
4374
+ function $mol_wire_async(obj) {
4375
+ let fiber;
4376
+ const temp = $mol_wire_task.getter(obj);
4377
+ return new Proxy(obj, {
4378
+ get(obj, field) {
4379
+ const val = obj[field];
4380
+ if (typeof val !== 'function')
4381
+ return val;
4382
+ let fiber;
4383
+ const temp = $mol_wire_task.getter(val);
4384
+ return function $mol_wire_async(...args) {
4385
+ fiber?.destructor();
4386
+ fiber = temp(obj, args);
4387
+ return fiber.async();
4388
+ };
4389
+ },
4390
+ apply(obj, self, args) {
4391
+ fiber?.destructor();
4392
+ fiber = temp(self, args);
4393
+ return fiber.async();
4394
+ },
4395
+ });
4396
+ }
4397
+ $.$mol_wire_async = $mol_wire_async;
4398
+ })($ || ($ = {}));
4399
+
4400
+ ;
4401
+ "use strict";
4402
+ var $;
4403
+ (function ($_1) {
4404
+ $mol_test({
4405
+ 'test types'($) {
4406
+ class A {
4407
+ static a() {
4408
+ return '';
4409
+ }
4410
+ static b() {
4411
+ return $mol_wire_async(this).a();
4412
+ }
4413
+ }
4414
+ },
4415
+ async 'Latest method calls wins'($) {
4416
+ class NameLogger extends $mol_object2 {
4417
+ static $ = $;
4418
+ static first = [];
4419
+ static last = [];
4420
+ static send(next) {
4421
+ $mol_wire_sync(this.first).push(next);
4422
+ $$.$mol_wait_timeout(0);
4423
+ this.last.push(next);
4424
+ }
4425
+ }
4426
+ const name = $mol_wire_async(NameLogger).send;
4427
+ name('john');
4428
+ const promise = name('jin');
4429
+ $.$mol_after_mock_warp();
4430
+ await promise;
4431
+ $mol_assert_equal(NameLogger.first, ['john', 'jin']);
4432
+ $mol_assert_equal(NameLogger.last, ['jin']);
4433
+ },
4434
+ async 'Latest function calls wins'($) {
4435
+ const first = [];
4436
+ const last = [];
4437
+ function send_name(next) {
4438
+ $mol_wire_sync(first).push(next);
4439
+ $$.$mol_wait_timeout(0);
4440
+ last.push(next);
4441
+ }
4442
+ const name = $mol_wire_async(send_name);
4443
+ name('john');
4444
+ const promise = name('jin');
4445
+ $.$mol_after_mock_warp();
4446
+ await promise;
4447
+ $mol_assert_equal(first, ['john', 'jin']);
4448
+ $mol_assert_equal(last, ['jin']);
4449
+ },
4450
+ });
4451
+ })($ || ($ = {}));
4452
+
4346
4453
  ;
4347
4454
  "use strict";
4348
4455
  var $;
@@ -5122,119 +5229,6 @@ var $;
5122
5229
  $.$mol_wire_log = $mol_wire_log;
5123
5230
  })($ || ($ = {}));
5124
5231
 
5125
- ;
5126
- "use strict";
5127
- var $;
5128
- (function ($) {
5129
- $mol_test({
5130
- 'auto name'() {
5131
- class Invalid extends $mol_error_mix {
5132
- }
5133
- const mix = new Invalid('foo');
5134
- $mol_assert_equal(mix.name, 'Invalid_Error');
5135
- },
5136
- 'simpe mix'() {
5137
- const mix = new $mol_error_mix('foo', {}, new Error('bar'), new Error('lol'));
5138
- $mol_assert_equal(mix.message, 'foo');
5139
- $mol_assert_equal(mix.errors.map(e => e.message), ['bar', 'lol']);
5140
- },
5141
- 'provide additional info'() {
5142
- class Invalid extends $mol_error_mix {
5143
- }
5144
- const mix = new $mol_error_mix('Wrong password', {}, new Invalid('Too short', { value: 'p@ssw0rd', hint: '> 8 letters' }), new Invalid('Too simple', { value: 'p@ssw0rd', hint: 'need capital letter' }));
5145
- const hints = [];
5146
- if (mix instanceof $mol_error_mix) {
5147
- for (const er of mix.errors) {
5148
- if (er instanceof Invalid) {
5149
- hints.push(er.cause?.hint ?? '');
5150
- }
5151
- }
5152
- }
5153
- $mol_assert_equal(hints, ['> 8 letters', 'need capital letter']);
5154
- },
5155
- });
5156
- })($ || ($ = {}));
5157
-
5158
- ;
5159
- "use strict";
5160
- var $;
5161
- (function ($_1) {
5162
- $mol_test({
5163
- 'init with overload'() {
5164
- class X extends $mol_object {
5165
- foo() {
5166
- return 1;
5167
- }
5168
- }
5169
- var x = X.make({
5170
- foo: () => 2,
5171
- });
5172
- $mol_assert_equal(x.foo(), 2);
5173
- },
5174
- 'Context in instance inherits from class'($) {
5175
- const custom = $.$mol_ambient({});
5176
- class X extends $.$mol_object {
5177
- static $ = custom;
5178
- }
5179
- $mol_assert_equal(new X().$, custom);
5180
- },
5181
- });
5182
- })($ || ($ = {}));
5183
-
5184
- ;
5185
- "use strict";
5186
- var $;
5187
- (function ($_1) {
5188
- $mol_test({
5189
- async 'exec timeout auto kill child process'($) {
5190
- let close_mock = () => { };
5191
- const error_message = 'Run error, timeout';
5192
- function mol_run_spawn_sync_mock() {
5193
- return {
5194
- output: [],
5195
- stdout: error_message,
5196
- stderr: '',
5197
- status: 0,
5198
- signal: null,
5199
- pid: 123,
5200
- };
5201
- }
5202
- function mol_run_spawn_mock() {
5203
- return {
5204
- on(name, cb) {
5205
- if (name === 'exit')
5206
- close_mock = cb;
5207
- },
5208
- kill() { close_mock(); }
5209
- };
5210
- }
5211
- const context_mock = $.$mol_ambient({
5212
- $mol_run_spawn_sync: mol_run_spawn_sync_mock,
5213
- $mol_run_spawn: mol_run_spawn_mock
5214
- });
5215
- class $mol_run_mock extends $mol_run {
5216
- static get $() { return context_mock; }
5217
- static async_enabled() {
5218
- return true;
5219
- }
5220
- }
5221
- let message = '';
5222
- try {
5223
- const res = await $mol_wire_async($mol_run_mock).spawn({
5224
- command: 'sleep 10',
5225
- dir: '.',
5226
- timeout: 10,
5227
- env: { 'MOL_RUN_ASYNC': '1' }
5228
- });
5229
- }
5230
- catch (e) {
5231
- message = e.message;
5232
- }
5233
- $mol_assert_equal(message, error_message);
5234
- }
5235
- });
5236
- })($ || ($ = {}));
5237
-
5238
5232
  ;
5239
5233
  "use strict";
5240
5234
  var $;