mol_wire_dom 0.0.1600 → 0.0.1602
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 +4 -0
- package/node.d.ts.map +1 -1
- package/node.deps.json +1 -1
- package/node.js +30 -11
- package/node.js.map +1 -1
- package/node.mjs +30 -11
- package/node.test.js +323 -306
- package/node.test.js.map +1 -1
- package/package.json +4 -1
- package/web.test.js +0 -2
- package/web.test.js.map +1 -1
package/node.test.js
CHANGED
|
@@ -2024,45 +2024,64 @@ var $;
|
|
|
2024
2024
|
;
|
|
2025
2025
|
"use strict";
|
|
2026
2026
|
|
|
2027
|
+
;
|
|
2028
|
+
"use strict";
|
|
2029
|
+
var $;
|
|
2030
|
+
(function ($) {
|
|
2031
|
+
const mod = require('module');
|
|
2032
|
+
const internals = mod.builtinModules;
|
|
2033
|
+
function $node_internal_check(name) {
|
|
2034
|
+
if (name.startsWith('node:'))
|
|
2035
|
+
return true;
|
|
2036
|
+
return internals.includes(name);
|
|
2037
|
+
}
|
|
2038
|
+
$.$node_internal_check = $node_internal_check;
|
|
2039
|
+
})($ || ($ = {}));
|
|
2040
|
+
|
|
2027
2041
|
;
|
|
2028
2042
|
"use strict";
|
|
2029
2043
|
var $node = new Proxy({ require }, {
|
|
2030
2044
|
get(target, name, wrapper) {
|
|
2031
2045
|
if (target[name])
|
|
2032
2046
|
return target[name];
|
|
2033
|
-
|
|
2047
|
+
const $$ = $;
|
|
2048
|
+
if ($$.$node_internal_check(name, target))
|
|
2034
2049
|
return target.require(name);
|
|
2035
2050
|
if (name[0] === '.')
|
|
2036
2051
|
return target.require(name);
|
|
2037
|
-
const mod = target.require('module');
|
|
2038
|
-
if (mod.builtinModules.indexOf(name) >= 0)
|
|
2039
|
-
return target.require(name);
|
|
2040
2052
|
try {
|
|
2041
2053
|
target.require.resolve(name);
|
|
2042
2054
|
}
|
|
2043
2055
|
catch {
|
|
2044
|
-
|
|
2045
|
-
|
|
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
|
+
}
|
|
2046
2063
|
try {
|
|
2047
2064
|
$$.$mol_exec('.', 'npm', 'install', '--omit=dev', '@types/' + name);
|
|
2048
2065
|
}
|
|
2049
2066
|
catch (e) {
|
|
2050
|
-
if ($$.$
|
|
2051
|
-
$$.$
|
|
2052
|
-
|
|
2067
|
+
if ($$.$mol_promise_like(e))
|
|
2068
|
+
$$.$mol_fail_hidden(e);
|
|
2069
|
+
$$.$mol_fail_log(e);
|
|
2053
2070
|
}
|
|
2054
2071
|
}
|
|
2055
2072
|
try {
|
|
2056
2073
|
return target.require(name);
|
|
2057
2074
|
}
|
|
2058
2075
|
catch (error) {
|
|
2059
|
-
if (
|
|
2076
|
+
if ($$.$mol_promise_like(error))
|
|
2077
|
+
$$.$mol_fail_hidden(error);
|
|
2078
|
+
if (error && typeof error === 'object' && error.code === 'ERR_REQUIRE_ESM') {
|
|
2060
2079
|
const module = cache.get(name);
|
|
2061
2080
|
if (module)
|
|
2062
2081
|
return module;
|
|
2063
2082
|
throw Object.assign(import(name).then(module => cache.set(name, module)), { cause: error });
|
|
2064
2083
|
}
|
|
2065
|
-
|
|
2084
|
+
$$.$mol_fail_log(error);
|
|
2066
2085
|
return null;
|
|
2067
2086
|
}
|
|
2068
2087
|
},
|
|
@@ -2704,215 +2723,12 @@ var $;
|
|
|
2704
2723
|
|
|
2705
2724
|
;
|
|
2706
2725
|
"use strict";
|
|
2707
|
-
var $;
|
|
2708
|
-
(function ($_1) {
|
|
2709
|
-
$mol_test({
|
|
2710
|
-
'FQN of anon function'($) {
|
|
2711
|
-
const $$ = Object.assign($, { $mol_func_name_test: (() => () => { })() });
|
|
2712
|
-
$mol_assert_equal($$.$mol_func_name_test.name, '');
|
|
2713
|
-
$mol_assert_equal($$.$mol_func_name($$.$mol_func_name_test), '$mol_func_name_test');
|
|
2714
|
-
$mol_assert_equal($$.$mol_func_name_test.name, '$mol_func_name_test');
|
|
2715
|
-
},
|
|
2716
|
-
});
|
|
2717
|
-
})($ || ($ = {}));
|
|
2718
|
-
|
|
2719
|
-
;
|
|
2720
|
-
"use strict";
|
|
2721
|
-
var $;
|
|
2722
|
-
(function ($) {
|
|
2723
|
-
$mol_test({
|
|
2724
|
-
'auto name'() {
|
|
2725
|
-
class Invalid extends $mol_error_mix {
|
|
2726
|
-
}
|
|
2727
|
-
const mix = new Invalid('foo');
|
|
2728
|
-
$mol_assert_equal(mix.name, 'Invalid_Error');
|
|
2729
|
-
},
|
|
2730
|
-
'simpe mix'() {
|
|
2731
|
-
const mix = new $mol_error_mix('foo', {}, new Error('bar'), new Error('lol'));
|
|
2732
|
-
$mol_assert_equal(mix.message, 'foo');
|
|
2733
|
-
$mol_assert_equal(mix.errors.map(e => e.message), ['bar', 'lol']);
|
|
2734
|
-
},
|
|
2735
|
-
'provide additional info'() {
|
|
2736
|
-
class Invalid extends $mol_error_mix {
|
|
2737
|
-
}
|
|
2738
|
-
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' }));
|
|
2739
|
-
const hints = [];
|
|
2740
|
-
if (mix instanceof $mol_error_mix) {
|
|
2741
|
-
for (const er of mix.errors) {
|
|
2742
|
-
if (er instanceof Invalid) {
|
|
2743
|
-
hints.push(er.cause?.hint ?? '');
|
|
2744
|
-
}
|
|
2745
|
-
}
|
|
2746
|
-
}
|
|
2747
|
-
$mol_assert_equal(hints, ['> 8 letters', 'need capital letter']);
|
|
2748
|
-
},
|
|
2749
|
-
});
|
|
2750
|
-
})($ || ($ = {}));
|
|
2751
|
-
|
|
2752
|
-
;
|
|
2753
|
-
"use strict";
|
|
2754
|
-
|
|
2755
|
-
;
|
|
2756
|
-
"use strict";
|
|
2757
|
-
|
|
2758
|
-
;
|
|
2759
|
-
"use strict";
|
|
2760
|
-
|
|
2761
|
-
;
|
|
2762
|
-
"use strict";
|
|
2763
|
-
|
|
2764
|
-
;
|
|
2765
|
-
"use strict";
|
|
2766
|
-
|
|
2767
|
-
;
|
|
2768
|
-
"use strict";
|
|
2769
|
-
|
|
2770
|
-
;
|
|
2771
|
-
"use strict";
|
|
2772
|
-
var $;
|
|
2773
|
-
(function ($_1) {
|
|
2774
|
-
$mol_test({
|
|
2775
|
-
'init with overload'() {
|
|
2776
|
-
class X extends $mol_object {
|
|
2777
|
-
foo() {
|
|
2778
|
-
return 1;
|
|
2779
|
-
}
|
|
2780
|
-
}
|
|
2781
|
-
var x = X.make({
|
|
2782
|
-
foo: () => 2,
|
|
2783
|
-
});
|
|
2784
|
-
$mol_assert_equal(x.foo(), 2);
|
|
2785
|
-
},
|
|
2786
|
-
'Context in instance inherits from class'($) {
|
|
2787
|
-
const custom = $.$mol_ambient({});
|
|
2788
|
-
class X extends $.$mol_object {
|
|
2789
|
-
static $ = custom;
|
|
2790
|
-
}
|
|
2791
|
-
$mol_assert_equal(new X().$, custom);
|
|
2792
|
-
},
|
|
2793
|
-
});
|
|
2794
|
-
})($ || ($ = {}));
|
|
2795
|
-
|
|
2796
|
-
;
|
|
2797
|
-
"use strict";
|
|
2798
|
-
var $;
|
|
2799
|
-
(function ($_1) {
|
|
2800
|
-
$mol_test({
|
|
2801
|
-
'test types'($) {
|
|
2802
|
-
class A {
|
|
2803
|
-
static a() {
|
|
2804
|
-
return Promise.resolve('');
|
|
2805
|
-
}
|
|
2806
|
-
static b() {
|
|
2807
|
-
return $mol_wire_sync(this).a();
|
|
2808
|
-
}
|
|
2809
|
-
}
|
|
2810
|
-
},
|
|
2811
|
-
async 'test method from host'($) {
|
|
2812
|
-
let count = 0;
|
|
2813
|
-
class A {
|
|
2814
|
-
static a() {
|
|
2815
|
-
return $mol_wire_sync(this).b();
|
|
2816
|
-
}
|
|
2817
|
-
static b() { return Promise.resolve(++count); }
|
|
2818
|
-
}
|
|
2819
|
-
$mol_assert_equal(await $mol_wire_async(A).a(), 1, count);
|
|
2820
|
-
},
|
|
2821
|
-
async 'test function'($) {
|
|
2822
|
-
let count = 0;
|
|
2823
|
-
class A {
|
|
2824
|
-
static a() {
|
|
2825
|
-
return $mol_wire_sync(this.b)();
|
|
2826
|
-
}
|
|
2827
|
-
static b() { return Promise.resolve(++count); }
|
|
2828
|
-
}
|
|
2829
|
-
$mol_assert_equal(await $mol_wire_async(A).a(), 1, count);
|
|
2830
|
-
},
|
|
2831
|
-
async 'test construct itself'($) {
|
|
2832
|
-
class A {
|
|
2833
|
-
static instances = [];
|
|
2834
|
-
static a() {
|
|
2835
|
-
const a = new ($mol_wire_sync(A))();
|
|
2836
|
-
this.instances.push(a);
|
|
2837
|
-
$mol_wire_sync(this).b();
|
|
2838
|
-
}
|
|
2839
|
-
static b() { return Promise.resolve(); }
|
|
2840
|
-
}
|
|
2841
|
-
await $mol_wire_async(A).a();
|
|
2842
|
-
$mol_assert_equal(A.instances.length, 2);
|
|
2843
|
-
$mol_assert_equal(A.instances[0] instanceof A, true);
|
|
2844
|
-
$mol_assert_equal(A.instances[0], A.instances[1]);
|
|
2845
|
-
}
|
|
2846
|
-
});
|
|
2847
|
-
})($ || ($ = {}));
|
|
2848
2726
|
|
|
2849
2727
|
;
|
|
2850
2728
|
"use strict";
|
|
2851
|
-
var $;
|
|
2852
|
-
(function ($_1) {
|
|
2853
|
-
$mol_test_mocks.push($ => {
|
|
2854
|
-
$.$mol_log3_come = () => { };
|
|
2855
|
-
$.$mol_log3_done = () => { };
|
|
2856
|
-
$.$mol_log3_fail = () => { };
|
|
2857
|
-
$.$mol_log3_warn = () => { };
|
|
2858
|
-
$.$mol_log3_rise = () => { };
|
|
2859
|
-
$.$mol_log3_area = () => () => { };
|
|
2860
|
-
});
|
|
2861
|
-
})($ || ($ = {}));
|
|
2862
2729
|
|
|
2863
2730
|
;
|
|
2864
2731
|
"use strict";
|
|
2865
|
-
var $;
|
|
2866
|
-
(function ($_1) {
|
|
2867
|
-
$mol_test({
|
|
2868
|
-
async 'exec timeout auto kill child process'($) {
|
|
2869
|
-
let close_mock = () => { };
|
|
2870
|
-
const error_message = 'Run error, timeout';
|
|
2871
|
-
function mol_run_spawn_sync_mock() {
|
|
2872
|
-
return {
|
|
2873
|
-
output: [],
|
|
2874
|
-
stdout: error_message,
|
|
2875
|
-
stderr: '',
|
|
2876
|
-
status: 0,
|
|
2877
|
-
signal: null,
|
|
2878
|
-
pid: 123,
|
|
2879
|
-
};
|
|
2880
|
-
}
|
|
2881
|
-
function mol_run_spawn_mock() {
|
|
2882
|
-
return {
|
|
2883
|
-
on(name, cb) {
|
|
2884
|
-
if (name === 'exit')
|
|
2885
|
-
close_mock = cb;
|
|
2886
|
-
},
|
|
2887
|
-
kill() { close_mock(); }
|
|
2888
|
-
};
|
|
2889
|
-
}
|
|
2890
|
-
const context_mock = $.$mol_ambient({
|
|
2891
|
-
$mol_run_spawn_sync: mol_run_spawn_sync_mock,
|
|
2892
|
-
$mol_run_spawn: mol_run_spawn_mock
|
|
2893
|
-
});
|
|
2894
|
-
class $mol_run_mock extends $mol_run {
|
|
2895
|
-
static get $() { return context_mock; }
|
|
2896
|
-
static async_enabled() {
|
|
2897
|
-
return true;
|
|
2898
|
-
}
|
|
2899
|
-
}
|
|
2900
|
-
let message = '';
|
|
2901
|
-
try {
|
|
2902
|
-
const res = await $mol_wire_async($mol_run_mock).spawn({
|
|
2903
|
-
command: 'sleep 10',
|
|
2904
|
-
dir: '.',
|
|
2905
|
-
timeout: 10,
|
|
2906
|
-
env: { 'MOL_RUN_ASYNC': '1' }
|
|
2907
|
-
});
|
|
2908
|
-
}
|
|
2909
|
-
catch (e) {
|
|
2910
|
-
message = e.message;
|
|
2911
|
-
}
|
|
2912
|
-
$mol_assert_equal(message, error_message);
|
|
2913
|
-
}
|
|
2914
|
-
});
|
|
2915
|
-
})($ || ($ = {}));
|
|
2916
2732
|
|
|
2917
2733
|
;
|
|
2918
2734
|
"use strict";
|
|
@@ -3629,8 +3445,6 @@ var $;
|
|
|
3629
3445
|
for (let i = 1; i < args.length; ++i) {
|
|
3630
3446
|
if ($mol_compare_deep(args[0], args[i]))
|
|
3631
3447
|
continue;
|
|
3632
|
-
if (args[0] instanceof $mol_dom_context.Element && args[i] instanceof $mol_dom_context.Element && args[0].outerHTML === args[i].outerHTML)
|
|
3633
|
-
continue;
|
|
3634
3448
|
return $mol_fail(new Error(`Equality assertion failure`, { cause: { 0: args[0], [i]: args[i] } }));
|
|
3635
3449
|
}
|
|
3636
3450
|
}
|
|
@@ -3678,15 +3492,52 @@ var $;
|
|
|
3678
3492
|
;
|
|
3679
3493
|
"use strict";
|
|
3680
3494
|
var $;
|
|
3681
|
-
(function ($) {
|
|
3495
|
+
(function ($_1) {
|
|
3496
|
+
$mol_test_mocks.push($ => {
|
|
3497
|
+
$.$mol_log3_come = () => { };
|
|
3498
|
+
$.$mol_log3_done = () => { };
|
|
3499
|
+
$.$mol_log3_fail = () => { };
|
|
3500
|
+
$.$mol_log3_warn = () => { };
|
|
3501
|
+
$.$mol_log3_rise = () => { };
|
|
3502
|
+
$.$mol_log3_area = () => () => { };
|
|
3503
|
+
});
|
|
3504
|
+
})($ || ($ = {}));
|
|
3505
|
+
|
|
3506
|
+
;
|
|
3507
|
+
"use strict";
|
|
3508
|
+
|
|
3509
|
+
;
|
|
3510
|
+
"use strict";
|
|
3511
|
+
|
|
3512
|
+
;
|
|
3513
|
+
"use strict";
|
|
3514
|
+
|
|
3515
|
+
;
|
|
3516
|
+
"use strict";
|
|
3517
|
+
var $;
|
|
3518
|
+
(function ($_1) {
|
|
3682
3519
|
$mol_test({
|
|
3683
|
-
'
|
|
3684
|
-
const
|
|
3685
|
-
$mol_assert_equal(
|
|
3520
|
+
'FQN of anon function'($) {
|
|
3521
|
+
const $$ = Object.assign($, { $mol_func_name_test: (() => () => { })() });
|
|
3522
|
+
$mol_assert_equal($$.$mol_func_name_test.name, '');
|
|
3523
|
+
$mol_assert_equal($$.$mol_func_name($$.$mol_func_name_test), '$mol_func_name_test');
|
|
3524
|
+
$mol_assert_equal($$.$mol_func_name_test.name, '$mol_func_name_test');
|
|
3686
3525
|
},
|
|
3687
|
-
|
|
3688
|
-
|
|
3689
|
-
|
|
3526
|
+
});
|
|
3527
|
+
})($ || ($ = {}));
|
|
3528
|
+
|
|
3529
|
+
;
|
|
3530
|
+
"use strict";
|
|
3531
|
+
var $;
|
|
3532
|
+
(function ($) {
|
|
3533
|
+
$mol_test({
|
|
3534
|
+
'get'() {
|
|
3535
|
+
const proxy = $mol_delegate({}, () => ({ foo: 777 }));
|
|
3536
|
+
$mol_assert_equal(proxy.foo, 777);
|
|
3537
|
+
},
|
|
3538
|
+
'has'() {
|
|
3539
|
+
const proxy = $mol_delegate({}, () => ({ foo: 777 }));
|
|
3540
|
+
$mol_assert_equal('foo' in proxy, true);
|
|
3690
3541
|
},
|
|
3691
3542
|
'set'() {
|
|
3692
3543
|
const target = { foo: 777 };
|
|
@@ -4277,6 +4128,142 @@ var $;
|
|
|
4277
4128
|
$.$mol_promise = $mol_promise;
|
|
4278
4129
|
})($ || ($ = {}));
|
|
4279
4130
|
|
|
4131
|
+
;
|
|
4132
|
+
"use strict";
|
|
4133
|
+
var $;
|
|
4134
|
+
(function ($) {
|
|
4135
|
+
function $mol_wire_async(obj) {
|
|
4136
|
+
let fiber;
|
|
4137
|
+
const temp = $mol_wire_task.getter(obj);
|
|
4138
|
+
return new Proxy(obj, {
|
|
4139
|
+
get(obj, field) {
|
|
4140
|
+
const val = obj[field];
|
|
4141
|
+
if (typeof val !== 'function')
|
|
4142
|
+
return val;
|
|
4143
|
+
let fiber;
|
|
4144
|
+
const temp = $mol_wire_task.getter(val);
|
|
4145
|
+
return function $mol_wire_async(...args) {
|
|
4146
|
+
fiber?.destructor();
|
|
4147
|
+
fiber = temp(obj, args);
|
|
4148
|
+
return fiber.async();
|
|
4149
|
+
};
|
|
4150
|
+
},
|
|
4151
|
+
apply(obj, self, args) {
|
|
4152
|
+
fiber?.destructor();
|
|
4153
|
+
fiber = temp(self, args);
|
|
4154
|
+
return fiber.async();
|
|
4155
|
+
},
|
|
4156
|
+
});
|
|
4157
|
+
}
|
|
4158
|
+
$.$mol_wire_async = $mol_wire_async;
|
|
4159
|
+
})($ || ($ = {}));
|
|
4160
|
+
|
|
4161
|
+
;
|
|
4162
|
+
"use strict";
|
|
4163
|
+
var $;
|
|
4164
|
+
(function ($_1) {
|
|
4165
|
+
$mol_test({
|
|
4166
|
+
'test types'($) {
|
|
4167
|
+
class A {
|
|
4168
|
+
static a() {
|
|
4169
|
+
return '';
|
|
4170
|
+
}
|
|
4171
|
+
static b() {
|
|
4172
|
+
return $mol_wire_async(this).a();
|
|
4173
|
+
}
|
|
4174
|
+
}
|
|
4175
|
+
},
|
|
4176
|
+
async 'Latest method calls wins'($) {
|
|
4177
|
+
class NameLogger extends $mol_object2 {
|
|
4178
|
+
static $ = $;
|
|
4179
|
+
static first = [];
|
|
4180
|
+
static last = [];
|
|
4181
|
+
static send(next) {
|
|
4182
|
+
$mol_wire_sync(this.first).push(next);
|
|
4183
|
+
$$.$mol_wait_timeout(0);
|
|
4184
|
+
this.last.push(next);
|
|
4185
|
+
}
|
|
4186
|
+
}
|
|
4187
|
+
const name = $mol_wire_async(NameLogger).send;
|
|
4188
|
+
name('john');
|
|
4189
|
+
const promise = name('jin');
|
|
4190
|
+
$.$mol_after_mock_warp();
|
|
4191
|
+
await promise;
|
|
4192
|
+
$mol_assert_equal(NameLogger.first, ['john', 'jin']);
|
|
4193
|
+
$mol_assert_equal(NameLogger.last, ['jin']);
|
|
4194
|
+
},
|
|
4195
|
+
async 'Latest function calls wins'($) {
|
|
4196
|
+
const first = [];
|
|
4197
|
+
const last = [];
|
|
4198
|
+
function send_name(next) {
|
|
4199
|
+
$mol_wire_sync(first).push(next);
|
|
4200
|
+
$$.$mol_wait_timeout(0);
|
|
4201
|
+
last.push(next);
|
|
4202
|
+
}
|
|
4203
|
+
const name = $mol_wire_async(send_name);
|
|
4204
|
+
name('john');
|
|
4205
|
+
const promise = name('jin');
|
|
4206
|
+
$.$mol_after_mock_warp();
|
|
4207
|
+
await promise;
|
|
4208
|
+
$mol_assert_equal(first, ['john', 'jin']);
|
|
4209
|
+
$mol_assert_equal(last, ['jin']);
|
|
4210
|
+
},
|
|
4211
|
+
});
|
|
4212
|
+
})($ || ($ = {}));
|
|
4213
|
+
|
|
4214
|
+
;
|
|
4215
|
+
"use strict";
|
|
4216
|
+
var $;
|
|
4217
|
+
(function ($_1) {
|
|
4218
|
+
$mol_test({
|
|
4219
|
+
'test types'($) {
|
|
4220
|
+
class A {
|
|
4221
|
+
static a() {
|
|
4222
|
+
return Promise.resolve('');
|
|
4223
|
+
}
|
|
4224
|
+
static b() {
|
|
4225
|
+
return $mol_wire_sync(this).a();
|
|
4226
|
+
}
|
|
4227
|
+
}
|
|
4228
|
+
},
|
|
4229
|
+
async 'test method from host'($) {
|
|
4230
|
+
let count = 0;
|
|
4231
|
+
class A {
|
|
4232
|
+
static a() {
|
|
4233
|
+
return $mol_wire_sync(this).b();
|
|
4234
|
+
}
|
|
4235
|
+
static b() { return Promise.resolve(++count); }
|
|
4236
|
+
}
|
|
4237
|
+
$mol_assert_equal(await $mol_wire_async(A).a(), 1, count);
|
|
4238
|
+
},
|
|
4239
|
+
async 'test function'($) {
|
|
4240
|
+
let count = 0;
|
|
4241
|
+
class A {
|
|
4242
|
+
static a() {
|
|
4243
|
+
return $mol_wire_sync(this.b)();
|
|
4244
|
+
}
|
|
4245
|
+
static b() { return Promise.resolve(++count); }
|
|
4246
|
+
}
|
|
4247
|
+
$mol_assert_equal(await $mol_wire_async(A).a(), 1, count);
|
|
4248
|
+
},
|
|
4249
|
+
async 'test construct itself'($) {
|
|
4250
|
+
class A {
|
|
4251
|
+
static instances = [];
|
|
4252
|
+
static a() {
|
|
4253
|
+
const a = new ($mol_wire_sync(A))();
|
|
4254
|
+
this.instances.push(a);
|
|
4255
|
+
$mol_wire_sync(this).b();
|
|
4256
|
+
}
|
|
4257
|
+
static b() { return Promise.resolve(); }
|
|
4258
|
+
}
|
|
4259
|
+
await $mol_wire_async(A).a();
|
|
4260
|
+
$mol_assert_equal(A.instances.length, 2);
|
|
4261
|
+
$mol_assert_equal(A.instances[0] instanceof A, true);
|
|
4262
|
+
$mol_assert_equal(A.instances[0], A.instances[1]);
|
|
4263
|
+
}
|
|
4264
|
+
});
|
|
4265
|
+
})($ || ($ = {}));
|
|
4266
|
+
|
|
4280
4267
|
;
|
|
4281
4268
|
"use strict";
|
|
4282
4269
|
var $;
|
|
@@ -4370,89 +4357,6 @@ var $;
|
|
|
4370
4357
|
})($$ = $_1.$$ || ($_1.$$ = {}));
|
|
4371
4358
|
})($ || ($ = {}));
|
|
4372
4359
|
|
|
4373
|
-
;
|
|
4374
|
-
"use strict";
|
|
4375
|
-
var $;
|
|
4376
|
-
(function ($) {
|
|
4377
|
-
function $mol_wire_async(obj) {
|
|
4378
|
-
let fiber;
|
|
4379
|
-
const temp = $mol_wire_task.getter(obj);
|
|
4380
|
-
return new Proxy(obj, {
|
|
4381
|
-
get(obj, field) {
|
|
4382
|
-
const val = obj[field];
|
|
4383
|
-
if (typeof val !== 'function')
|
|
4384
|
-
return val;
|
|
4385
|
-
let fiber;
|
|
4386
|
-
const temp = $mol_wire_task.getter(val);
|
|
4387
|
-
return function $mol_wire_async(...args) {
|
|
4388
|
-
fiber?.destructor();
|
|
4389
|
-
fiber = temp(obj, args);
|
|
4390
|
-
return fiber.async();
|
|
4391
|
-
};
|
|
4392
|
-
},
|
|
4393
|
-
apply(obj, self, args) {
|
|
4394
|
-
fiber?.destructor();
|
|
4395
|
-
fiber = temp(self, args);
|
|
4396
|
-
return fiber.async();
|
|
4397
|
-
},
|
|
4398
|
-
});
|
|
4399
|
-
}
|
|
4400
|
-
$.$mol_wire_async = $mol_wire_async;
|
|
4401
|
-
})($ || ($ = {}));
|
|
4402
|
-
|
|
4403
|
-
;
|
|
4404
|
-
"use strict";
|
|
4405
|
-
var $;
|
|
4406
|
-
(function ($_1) {
|
|
4407
|
-
$mol_test({
|
|
4408
|
-
'test types'($) {
|
|
4409
|
-
class A {
|
|
4410
|
-
static a() {
|
|
4411
|
-
return '';
|
|
4412
|
-
}
|
|
4413
|
-
static b() {
|
|
4414
|
-
return $mol_wire_async(this).a();
|
|
4415
|
-
}
|
|
4416
|
-
}
|
|
4417
|
-
},
|
|
4418
|
-
async 'Latest method calls wins'($) {
|
|
4419
|
-
class NameLogger extends $mol_object2 {
|
|
4420
|
-
static $ = $;
|
|
4421
|
-
static first = [];
|
|
4422
|
-
static last = [];
|
|
4423
|
-
static send(next) {
|
|
4424
|
-
$mol_wire_sync(this.first).push(next);
|
|
4425
|
-
$$.$mol_wait_timeout(0);
|
|
4426
|
-
this.last.push(next);
|
|
4427
|
-
}
|
|
4428
|
-
}
|
|
4429
|
-
const name = $mol_wire_async(NameLogger).send;
|
|
4430
|
-
name('john');
|
|
4431
|
-
const promise = name('jin');
|
|
4432
|
-
$.$mol_after_mock_warp();
|
|
4433
|
-
await promise;
|
|
4434
|
-
$mol_assert_equal(NameLogger.first, ['john', 'jin']);
|
|
4435
|
-
$mol_assert_equal(NameLogger.last, ['jin']);
|
|
4436
|
-
},
|
|
4437
|
-
async 'Latest function calls wins'($) {
|
|
4438
|
-
const first = [];
|
|
4439
|
-
const last = [];
|
|
4440
|
-
function send_name(next) {
|
|
4441
|
-
$mol_wire_sync(first).push(next);
|
|
4442
|
-
$$.$mol_wait_timeout(0);
|
|
4443
|
-
last.push(next);
|
|
4444
|
-
}
|
|
4445
|
-
const name = $mol_wire_async(send_name);
|
|
4446
|
-
name('john');
|
|
4447
|
-
const promise = name('jin');
|
|
4448
|
-
$.$mol_after_mock_warp();
|
|
4449
|
-
await promise;
|
|
4450
|
-
$mol_assert_equal(first, ['john', 'jin']);
|
|
4451
|
-
$mol_assert_equal(last, ['jin']);
|
|
4452
|
-
},
|
|
4453
|
-
});
|
|
4454
|
-
})($ || ($ = {}));
|
|
4455
|
-
|
|
4456
4360
|
;
|
|
4457
4361
|
"use strict";
|
|
4458
4362
|
var $;
|
|
@@ -5232,6 +5136,119 @@ var $;
|
|
|
5232
5136
|
$.$mol_wire_log = $mol_wire_log;
|
|
5233
5137
|
})($ || ($ = {}));
|
|
5234
5138
|
|
|
5139
|
+
;
|
|
5140
|
+
"use strict";
|
|
5141
|
+
var $;
|
|
5142
|
+
(function ($) {
|
|
5143
|
+
$mol_test({
|
|
5144
|
+
'auto name'() {
|
|
5145
|
+
class Invalid extends $mol_error_mix {
|
|
5146
|
+
}
|
|
5147
|
+
const mix = new Invalid('foo');
|
|
5148
|
+
$mol_assert_equal(mix.name, 'Invalid_Error');
|
|
5149
|
+
},
|
|
5150
|
+
'simpe mix'() {
|
|
5151
|
+
const mix = new $mol_error_mix('foo', {}, new Error('bar'), new Error('lol'));
|
|
5152
|
+
$mol_assert_equal(mix.message, 'foo');
|
|
5153
|
+
$mol_assert_equal(mix.errors.map(e => e.message), ['bar', 'lol']);
|
|
5154
|
+
},
|
|
5155
|
+
'provide additional info'() {
|
|
5156
|
+
class Invalid extends $mol_error_mix {
|
|
5157
|
+
}
|
|
5158
|
+
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' }));
|
|
5159
|
+
const hints = [];
|
|
5160
|
+
if (mix instanceof $mol_error_mix) {
|
|
5161
|
+
for (const er of mix.errors) {
|
|
5162
|
+
if (er instanceof Invalid) {
|
|
5163
|
+
hints.push(er.cause?.hint ?? '');
|
|
5164
|
+
}
|
|
5165
|
+
}
|
|
5166
|
+
}
|
|
5167
|
+
$mol_assert_equal(hints, ['> 8 letters', 'need capital letter']);
|
|
5168
|
+
},
|
|
5169
|
+
});
|
|
5170
|
+
})($ || ($ = {}));
|
|
5171
|
+
|
|
5172
|
+
;
|
|
5173
|
+
"use strict";
|
|
5174
|
+
var $;
|
|
5175
|
+
(function ($_1) {
|
|
5176
|
+
$mol_test({
|
|
5177
|
+
'init with overload'() {
|
|
5178
|
+
class X extends $mol_object {
|
|
5179
|
+
foo() {
|
|
5180
|
+
return 1;
|
|
5181
|
+
}
|
|
5182
|
+
}
|
|
5183
|
+
var x = X.make({
|
|
5184
|
+
foo: () => 2,
|
|
5185
|
+
});
|
|
5186
|
+
$mol_assert_equal(x.foo(), 2);
|
|
5187
|
+
},
|
|
5188
|
+
'Context in instance inherits from class'($) {
|
|
5189
|
+
const custom = $.$mol_ambient({});
|
|
5190
|
+
class X extends $.$mol_object {
|
|
5191
|
+
static $ = custom;
|
|
5192
|
+
}
|
|
5193
|
+
$mol_assert_equal(new X().$, custom);
|
|
5194
|
+
},
|
|
5195
|
+
});
|
|
5196
|
+
})($ || ($ = {}));
|
|
5197
|
+
|
|
5198
|
+
;
|
|
5199
|
+
"use strict";
|
|
5200
|
+
var $;
|
|
5201
|
+
(function ($_1) {
|
|
5202
|
+
$mol_test({
|
|
5203
|
+
async 'exec timeout auto kill child process'($) {
|
|
5204
|
+
let close_mock = () => { };
|
|
5205
|
+
const error_message = 'Run error, timeout';
|
|
5206
|
+
function mol_run_spawn_sync_mock() {
|
|
5207
|
+
return {
|
|
5208
|
+
output: [],
|
|
5209
|
+
stdout: error_message,
|
|
5210
|
+
stderr: '',
|
|
5211
|
+
status: 0,
|
|
5212
|
+
signal: null,
|
|
5213
|
+
pid: 123,
|
|
5214
|
+
};
|
|
5215
|
+
}
|
|
5216
|
+
function mol_run_spawn_mock() {
|
|
5217
|
+
return {
|
|
5218
|
+
on(name, cb) {
|
|
5219
|
+
if (name === 'exit')
|
|
5220
|
+
close_mock = cb;
|
|
5221
|
+
},
|
|
5222
|
+
kill() { close_mock(); }
|
|
5223
|
+
};
|
|
5224
|
+
}
|
|
5225
|
+
const context_mock = $.$mol_ambient({
|
|
5226
|
+
$mol_run_spawn_sync: mol_run_spawn_sync_mock,
|
|
5227
|
+
$mol_run_spawn: mol_run_spawn_mock
|
|
5228
|
+
});
|
|
5229
|
+
class $mol_run_mock extends $mol_run {
|
|
5230
|
+
static get $() { return context_mock; }
|
|
5231
|
+
static async_enabled() {
|
|
5232
|
+
return true;
|
|
5233
|
+
}
|
|
5234
|
+
}
|
|
5235
|
+
let message = '';
|
|
5236
|
+
try {
|
|
5237
|
+
const res = await $mol_wire_async($mol_run_mock).spawn({
|
|
5238
|
+
command: 'sleep 10',
|
|
5239
|
+
dir: '.',
|
|
5240
|
+
timeout: 10,
|
|
5241
|
+
env: { 'MOL_RUN_ASYNC': '1' }
|
|
5242
|
+
});
|
|
5243
|
+
}
|
|
5244
|
+
catch (e) {
|
|
5245
|
+
message = e.message;
|
|
5246
|
+
}
|
|
5247
|
+
$mol_assert_equal(message, error_message);
|
|
5248
|
+
}
|
|
5249
|
+
});
|
|
5250
|
+
})($ || ($ = {}));
|
|
5251
|
+
|
|
5235
5252
|
;
|
|
5236
5253
|
"use strict";
|
|
5237
5254
|
var $;
|