mol_wire_dom 0.0.1612 → 0.0.1614
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.deps.json +1 -1
- package/node.js +6 -7
- package/node.js.map +1 -1
- package/node.mjs +6 -7
- package/node.test.js +292 -293
- package/node.test.js.map +1 -1
- package/package.json +1 -1
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
|
-
|
|
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
|
}
|
|
@@ -2077,6 +2071,11 @@ var $node = new Proxy({ require }, {
|
|
|
2077
2071
|
$$.$mol_fail_hidden(e);
|
|
2078
2072
|
$$.$mol_fail_log(e);
|
|
2079
2073
|
}
|
|
2074
|
+
const mam_node_modules = target.require('node:path').join(process.cwd(), 'node_modules');
|
|
2075
|
+
if (!process.env.NODE_PATH?.includes(mam_node_modules)) {
|
|
2076
|
+
process.env.NODE_PATH = `${mam_node_modules}${process.env.NODE_PATH ? `:${process.env.NODE_PATH}` : ''}`;
|
|
2077
|
+
target.require('node:module').Module._initPaths();
|
|
2078
|
+
}
|
|
2080
2079
|
}
|
|
2081
2080
|
return target.require(name);
|
|
2082
2081
|
},
|
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
|
-
|
|
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
|
}
|
|
@@ -2068,6 +2062,11 @@ var $node = new Proxy({ require }, {
|
|
|
2068
2062
|
$$.$mol_fail_hidden(e);
|
|
2069
2063
|
$$.$mol_fail_log(e);
|
|
2070
2064
|
}
|
|
2065
|
+
const mam_node_modules = target.require('node:path').join(process.cwd(), 'node_modules');
|
|
2066
|
+
if (!process.env.NODE_PATH?.includes(mam_node_modules)) {
|
|
2067
|
+
process.env.NODE_PATH = `${mam_node_modules}${process.env.NODE_PATH ? `:${process.env.NODE_PATH}` : ''}`;
|
|
2068
|
+
target.require('node:module').Module._initPaths();
|
|
2069
|
+
}
|
|
2071
2070
|
}
|
|
2072
2071
|
return target.require(name);
|
|
2073
2072
|
},
|
|
@@ -2691,12 +2690,215 @@ var $;
|
|
|
2691
2690
|
|
|
2692
2691
|
;
|
|
2693
2692
|
"use strict";
|
|
2693
|
+
var $;
|
|
2694
|
+
(function ($_1) {
|
|
2695
|
+
$mol_test({
|
|
2696
|
+
'FQN of anon function'($) {
|
|
2697
|
+
const $$ = Object.assign($, { $mol_func_name_test: (() => () => { })() });
|
|
2698
|
+
$mol_assert_equal($$.$mol_func_name_test.name, '');
|
|
2699
|
+
$mol_assert_equal($$.$mol_func_name($$.$mol_func_name_test), '$mol_func_name_test');
|
|
2700
|
+
$mol_assert_equal($$.$mol_func_name_test.name, '$mol_func_name_test');
|
|
2701
|
+
},
|
|
2702
|
+
});
|
|
2703
|
+
})($ || ($ = {}));
|
|
2704
|
+
|
|
2705
|
+
;
|
|
2706
|
+
"use strict";
|
|
2707
|
+
var $;
|
|
2708
|
+
(function ($) {
|
|
2709
|
+
$mol_test({
|
|
2710
|
+
'auto name'() {
|
|
2711
|
+
class Invalid extends $mol_error_mix {
|
|
2712
|
+
}
|
|
2713
|
+
const mix = new Invalid('foo');
|
|
2714
|
+
$mol_assert_equal(mix.name, 'Invalid_Error');
|
|
2715
|
+
},
|
|
2716
|
+
'simpe mix'() {
|
|
2717
|
+
const mix = new $mol_error_mix('foo', {}, new Error('bar'), new Error('lol'));
|
|
2718
|
+
$mol_assert_equal(mix.message, 'foo');
|
|
2719
|
+
$mol_assert_equal(mix.errors.map(e => e.message), ['bar', 'lol']);
|
|
2720
|
+
},
|
|
2721
|
+
'provide additional info'() {
|
|
2722
|
+
class Invalid extends $mol_error_mix {
|
|
2723
|
+
}
|
|
2724
|
+
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' }));
|
|
2725
|
+
const hints = [];
|
|
2726
|
+
if (mix instanceof $mol_error_mix) {
|
|
2727
|
+
for (const er of mix.errors) {
|
|
2728
|
+
if (er instanceof Invalid) {
|
|
2729
|
+
hints.push(er.cause?.hint ?? '');
|
|
2730
|
+
}
|
|
2731
|
+
}
|
|
2732
|
+
}
|
|
2733
|
+
$mol_assert_equal(hints, ['> 8 letters', 'need capital letter']);
|
|
2734
|
+
},
|
|
2735
|
+
});
|
|
2736
|
+
})($ || ($ = {}));
|
|
2737
|
+
|
|
2738
|
+
;
|
|
2739
|
+
"use strict";
|
|
2740
|
+
|
|
2741
|
+
;
|
|
2742
|
+
"use strict";
|
|
2743
|
+
|
|
2744
|
+
;
|
|
2745
|
+
"use strict";
|
|
2746
|
+
|
|
2747
|
+
;
|
|
2748
|
+
"use strict";
|
|
2749
|
+
|
|
2750
|
+
;
|
|
2751
|
+
"use strict";
|
|
2752
|
+
|
|
2753
|
+
;
|
|
2754
|
+
"use strict";
|
|
2755
|
+
|
|
2756
|
+
;
|
|
2757
|
+
"use strict";
|
|
2758
|
+
var $;
|
|
2759
|
+
(function ($_1) {
|
|
2760
|
+
$mol_test({
|
|
2761
|
+
'init with overload'() {
|
|
2762
|
+
class X extends $mol_object {
|
|
2763
|
+
foo() {
|
|
2764
|
+
return 1;
|
|
2765
|
+
}
|
|
2766
|
+
}
|
|
2767
|
+
var x = X.make({
|
|
2768
|
+
foo: () => 2,
|
|
2769
|
+
});
|
|
2770
|
+
$mol_assert_equal(x.foo(), 2);
|
|
2771
|
+
},
|
|
2772
|
+
'Context in instance inherits from class'($) {
|
|
2773
|
+
const custom = $.$mol_ambient({});
|
|
2774
|
+
class X extends $.$mol_object {
|
|
2775
|
+
static $ = custom;
|
|
2776
|
+
}
|
|
2777
|
+
$mol_assert_equal(new X().$, custom);
|
|
2778
|
+
},
|
|
2779
|
+
});
|
|
2780
|
+
})($ || ($ = {}));
|
|
2781
|
+
|
|
2782
|
+
;
|
|
2783
|
+
"use strict";
|
|
2784
|
+
var $;
|
|
2785
|
+
(function ($_1) {
|
|
2786
|
+
$mol_test({
|
|
2787
|
+
'test types'($) {
|
|
2788
|
+
class A {
|
|
2789
|
+
static a() {
|
|
2790
|
+
return Promise.resolve('');
|
|
2791
|
+
}
|
|
2792
|
+
static b() {
|
|
2793
|
+
return $mol_wire_sync(this).a();
|
|
2794
|
+
}
|
|
2795
|
+
}
|
|
2796
|
+
},
|
|
2797
|
+
async 'test method from host'($) {
|
|
2798
|
+
let count = 0;
|
|
2799
|
+
class A {
|
|
2800
|
+
static a() {
|
|
2801
|
+
return $mol_wire_sync(this).b();
|
|
2802
|
+
}
|
|
2803
|
+
static b() { return Promise.resolve(++count); }
|
|
2804
|
+
}
|
|
2805
|
+
$mol_assert_equal(await $mol_wire_async(A).a(), 1, count);
|
|
2806
|
+
},
|
|
2807
|
+
async 'test function'($) {
|
|
2808
|
+
let count = 0;
|
|
2809
|
+
class A {
|
|
2810
|
+
static a() {
|
|
2811
|
+
return $mol_wire_sync(this.b)();
|
|
2812
|
+
}
|
|
2813
|
+
static b() { return Promise.resolve(++count); }
|
|
2814
|
+
}
|
|
2815
|
+
$mol_assert_equal(await $mol_wire_async(A).a(), 1, count);
|
|
2816
|
+
},
|
|
2817
|
+
async 'test construct itself'($) {
|
|
2818
|
+
class A {
|
|
2819
|
+
static instances = [];
|
|
2820
|
+
static a() {
|
|
2821
|
+
const a = new ($mol_wire_sync(A))();
|
|
2822
|
+
this.instances.push(a);
|
|
2823
|
+
$mol_wire_sync(this).b();
|
|
2824
|
+
}
|
|
2825
|
+
static b() { return Promise.resolve(); }
|
|
2826
|
+
}
|
|
2827
|
+
await $mol_wire_async(A).a();
|
|
2828
|
+
$mol_assert_equal(A.instances.length, 2);
|
|
2829
|
+
$mol_assert_equal(A.instances[0] instanceof A, true);
|
|
2830
|
+
$mol_assert_equal(A.instances[0], A.instances[1]);
|
|
2831
|
+
}
|
|
2832
|
+
});
|
|
2833
|
+
})($ || ($ = {}));
|
|
2694
2834
|
|
|
2695
2835
|
;
|
|
2696
2836
|
"use strict";
|
|
2837
|
+
var $;
|
|
2838
|
+
(function ($_1) {
|
|
2839
|
+
$mol_test_mocks.push($ => {
|
|
2840
|
+
$.$mol_log3_come = () => { };
|
|
2841
|
+
$.$mol_log3_done = () => { };
|
|
2842
|
+
$.$mol_log3_fail = () => { };
|
|
2843
|
+
$.$mol_log3_warn = () => { };
|
|
2844
|
+
$.$mol_log3_rise = () => { };
|
|
2845
|
+
$.$mol_log3_area = () => () => { };
|
|
2846
|
+
});
|
|
2847
|
+
})($ || ($ = {}));
|
|
2697
2848
|
|
|
2698
2849
|
;
|
|
2699
2850
|
"use strict";
|
|
2851
|
+
var $;
|
|
2852
|
+
(function ($_1) {
|
|
2853
|
+
$mol_test({
|
|
2854
|
+
async 'exec timeout auto kill child process'($) {
|
|
2855
|
+
let close_mock = () => { };
|
|
2856
|
+
const error_message = 'Run error, timeout';
|
|
2857
|
+
function mol_run_spawn_sync_mock() {
|
|
2858
|
+
return {
|
|
2859
|
+
output: [],
|
|
2860
|
+
stdout: error_message,
|
|
2861
|
+
stderr: '',
|
|
2862
|
+
status: 0,
|
|
2863
|
+
signal: null,
|
|
2864
|
+
pid: 123,
|
|
2865
|
+
};
|
|
2866
|
+
}
|
|
2867
|
+
function mol_run_spawn_mock() {
|
|
2868
|
+
return {
|
|
2869
|
+
on(name, cb) {
|
|
2870
|
+
if (name === 'exit')
|
|
2871
|
+
close_mock = cb;
|
|
2872
|
+
},
|
|
2873
|
+
kill() { close_mock(); }
|
|
2874
|
+
};
|
|
2875
|
+
}
|
|
2876
|
+
const context_mock = $.$mol_ambient({
|
|
2877
|
+
$mol_run_spawn_sync: mol_run_spawn_sync_mock,
|
|
2878
|
+
$mol_run_spawn: mol_run_spawn_mock
|
|
2879
|
+
});
|
|
2880
|
+
class $mol_run_mock extends $mol_run {
|
|
2881
|
+
static get $() { return context_mock; }
|
|
2882
|
+
static async_enabled() {
|
|
2883
|
+
return true;
|
|
2884
|
+
}
|
|
2885
|
+
}
|
|
2886
|
+
let message = '';
|
|
2887
|
+
try {
|
|
2888
|
+
const res = await $mol_wire_async($mol_run_mock).spawn({
|
|
2889
|
+
command: 'sleep 10',
|
|
2890
|
+
dir: '.',
|
|
2891
|
+
timeout: 10,
|
|
2892
|
+
env: { 'MOL_RUN_ASYNC': '1' }
|
|
2893
|
+
});
|
|
2894
|
+
}
|
|
2895
|
+
catch (e) {
|
|
2896
|
+
message = e.message;
|
|
2897
|
+
}
|
|
2898
|
+
$mol_assert_equal(message, error_message);
|
|
2899
|
+
}
|
|
2900
|
+
});
|
|
2901
|
+
})($ || ($ = {}));
|
|
2700
2902
|
|
|
2701
2903
|
;
|
|
2702
2904
|
"use strict";
|
|
@@ -3457,43 +3659,6 @@ var $;
|
|
|
3457
3659
|
});
|
|
3458
3660
|
})($ || ($ = {}));
|
|
3459
3661
|
|
|
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
3662
|
;
|
|
3498
3663
|
"use strict";
|
|
3499
3664
|
var $;
|
|
@@ -4114,142 +4279,6 @@ var $;
|
|
|
4114
4279
|
$.$mol_promise = $mol_promise;
|
|
4115
4280
|
})($ || ($ = {}));
|
|
4116
4281
|
|
|
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
4282
|
;
|
|
4254
4283
|
"use strict";
|
|
4255
4284
|
var $;
|
|
@@ -4343,6 +4372,89 @@ var $;
|
|
|
4343
4372
|
})($$ = $_1.$$ || ($_1.$$ = {}));
|
|
4344
4373
|
})($ || ($ = {}));
|
|
4345
4374
|
|
|
4375
|
+
;
|
|
4376
|
+
"use strict";
|
|
4377
|
+
var $;
|
|
4378
|
+
(function ($) {
|
|
4379
|
+
function $mol_wire_async(obj) {
|
|
4380
|
+
let fiber;
|
|
4381
|
+
const temp = $mol_wire_task.getter(obj);
|
|
4382
|
+
return new Proxy(obj, {
|
|
4383
|
+
get(obj, field) {
|
|
4384
|
+
const val = obj[field];
|
|
4385
|
+
if (typeof val !== 'function')
|
|
4386
|
+
return val;
|
|
4387
|
+
let fiber;
|
|
4388
|
+
const temp = $mol_wire_task.getter(val);
|
|
4389
|
+
return function $mol_wire_async(...args) {
|
|
4390
|
+
fiber?.destructor();
|
|
4391
|
+
fiber = temp(obj, args);
|
|
4392
|
+
return fiber.async();
|
|
4393
|
+
};
|
|
4394
|
+
},
|
|
4395
|
+
apply(obj, self, args) {
|
|
4396
|
+
fiber?.destructor();
|
|
4397
|
+
fiber = temp(self, args);
|
|
4398
|
+
return fiber.async();
|
|
4399
|
+
},
|
|
4400
|
+
});
|
|
4401
|
+
}
|
|
4402
|
+
$.$mol_wire_async = $mol_wire_async;
|
|
4403
|
+
})($ || ($ = {}));
|
|
4404
|
+
|
|
4405
|
+
;
|
|
4406
|
+
"use strict";
|
|
4407
|
+
var $;
|
|
4408
|
+
(function ($_1) {
|
|
4409
|
+
$mol_test({
|
|
4410
|
+
'test types'($) {
|
|
4411
|
+
class A {
|
|
4412
|
+
static a() {
|
|
4413
|
+
return '';
|
|
4414
|
+
}
|
|
4415
|
+
static b() {
|
|
4416
|
+
return $mol_wire_async(this).a();
|
|
4417
|
+
}
|
|
4418
|
+
}
|
|
4419
|
+
},
|
|
4420
|
+
async 'Latest method calls wins'($) {
|
|
4421
|
+
class NameLogger extends $mol_object2 {
|
|
4422
|
+
static $ = $;
|
|
4423
|
+
static first = [];
|
|
4424
|
+
static last = [];
|
|
4425
|
+
static send(next) {
|
|
4426
|
+
$mol_wire_sync(this.first).push(next);
|
|
4427
|
+
$$.$mol_wait_timeout(0);
|
|
4428
|
+
this.last.push(next);
|
|
4429
|
+
}
|
|
4430
|
+
}
|
|
4431
|
+
const name = $mol_wire_async(NameLogger).send;
|
|
4432
|
+
name('john');
|
|
4433
|
+
const promise = name('jin');
|
|
4434
|
+
$.$mol_after_mock_warp();
|
|
4435
|
+
await promise;
|
|
4436
|
+
$mol_assert_equal(NameLogger.first, ['john', 'jin']);
|
|
4437
|
+
$mol_assert_equal(NameLogger.last, ['jin']);
|
|
4438
|
+
},
|
|
4439
|
+
async 'Latest function calls wins'($) {
|
|
4440
|
+
const first = [];
|
|
4441
|
+
const last = [];
|
|
4442
|
+
function send_name(next) {
|
|
4443
|
+
$mol_wire_sync(first).push(next);
|
|
4444
|
+
$$.$mol_wait_timeout(0);
|
|
4445
|
+
last.push(next);
|
|
4446
|
+
}
|
|
4447
|
+
const name = $mol_wire_async(send_name);
|
|
4448
|
+
name('john');
|
|
4449
|
+
const promise = name('jin');
|
|
4450
|
+
$.$mol_after_mock_warp();
|
|
4451
|
+
await promise;
|
|
4452
|
+
$mol_assert_equal(first, ['john', 'jin']);
|
|
4453
|
+
$mol_assert_equal(last, ['jin']);
|
|
4454
|
+
},
|
|
4455
|
+
});
|
|
4456
|
+
})($ || ($ = {}));
|
|
4457
|
+
|
|
4346
4458
|
;
|
|
4347
4459
|
"use strict";
|
|
4348
4460
|
var $;
|
|
@@ -5122,119 +5234,6 @@ var $;
|
|
|
5122
5234
|
$.$mol_wire_log = $mol_wire_log;
|
|
5123
5235
|
})($ || ($ = {}));
|
|
5124
5236
|
|
|
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
5237
|
;
|
|
5239
5238
|
"use strict";
|
|
5240
5239
|
var $;
|