mol_wire_lib 1.0.1619 → 1.0.1621
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 +646 -629
- package/node.test.js.map +1 -1
- package/package.json +1 -1
- package/web.test.js +0 -2
- package/web.test.js.map +1 -1
package/node.test.js
CHANGED
|
@@ -2855,6 +2855,20 @@ var $;
|
|
|
2855
2855
|
;
|
|
2856
2856
|
"use strict";
|
|
2857
2857
|
|
|
2858
|
+
;
|
|
2859
|
+
"use strict";
|
|
2860
|
+
var $;
|
|
2861
|
+
(function ($) {
|
|
2862
|
+
const mod = require('module');
|
|
2863
|
+
const internals = mod.builtinModules;
|
|
2864
|
+
function $node_internal_check(name) {
|
|
2865
|
+
if (name.startsWith('node:'))
|
|
2866
|
+
return true;
|
|
2867
|
+
return internals.includes(name);
|
|
2868
|
+
}
|
|
2869
|
+
$.$node_internal_check = $node_internal_check;
|
|
2870
|
+
})($ || ($ = {}));
|
|
2871
|
+
|
|
2858
2872
|
;
|
|
2859
2873
|
"use strict";
|
|
2860
2874
|
var $;
|
|
@@ -2879,39 +2893,44 @@ var $node = new Proxy({ require }, {
|
|
|
2879
2893
|
get(target, name, wrapper) {
|
|
2880
2894
|
if (target[name])
|
|
2881
2895
|
return target[name];
|
|
2882
|
-
|
|
2896
|
+
const $$ = $;
|
|
2897
|
+
if ($$.$node_internal_check(name, target))
|
|
2883
2898
|
return target.require(name);
|
|
2884
2899
|
if (name[0] === '.')
|
|
2885
2900
|
return target.require(name);
|
|
2886
|
-
const mod = target.require('module');
|
|
2887
|
-
if (mod.builtinModules.indexOf(name) >= 0)
|
|
2888
|
-
return target.require(name);
|
|
2889
2901
|
try {
|
|
2890
2902
|
target.require.resolve(name);
|
|
2891
2903
|
}
|
|
2892
2904
|
catch {
|
|
2893
|
-
|
|
2894
|
-
|
|
2905
|
+
try {
|
|
2906
|
+
$$.$mol_exec('.', 'npm', 'install', '--omit=dev', name);
|
|
2907
|
+
}
|
|
2908
|
+
catch (e) {
|
|
2909
|
+
if ($$.$mol_promise_like(e))
|
|
2910
|
+
$$.$mol_fail_hidden(e);
|
|
2911
|
+
}
|
|
2895
2912
|
try {
|
|
2896
2913
|
$$.$mol_exec('.', 'npm', 'install', '--omit=dev', '@types/' + name);
|
|
2897
2914
|
}
|
|
2898
2915
|
catch (e) {
|
|
2899
|
-
if ($$.$
|
|
2900
|
-
$$.$
|
|
2901
|
-
|
|
2916
|
+
if ($$.$mol_promise_like(e))
|
|
2917
|
+
$$.$mol_fail_hidden(e);
|
|
2918
|
+
$$.$mol_fail_log(e);
|
|
2902
2919
|
}
|
|
2903
2920
|
}
|
|
2904
2921
|
try {
|
|
2905
2922
|
return target.require(name);
|
|
2906
2923
|
}
|
|
2907
2924
|
catch (error) {
|
|
2908
|
-
if (
|
|
2925
|
+
if ($$.$mol_promise_like(error))
|
|
2926
|
+
$$.$mol_fail_hidden(error);
|
|
2927
|
+
if (error && typeof error === 'object' && error.code === 'ERR_REQUIRE_ESM') {
|
|
2909
2928
|
const module = cache.get(name);
|
|
2910
2929
|
if (module)
|
|
2911
2930
|
return module;
|
|
2912
2931
|
throw Object.assign(import(name).then(module => cache.set(name, module)), { cause: error });
|
|
2913
2932
|
}
|
|
2914
|
-
|
|
2933
|
+
$$.$mol_fail_log(error);
|
|
2915
2934
|
return null;
|
|
2916
2935
|
}
|
|
2917
2936
|
},
|
|
@@ -2928,97 +2947,70 @@ require = (req => Object.assign(function require(name) {
|
|
|
2928
2947
|
;
|
|
2929
2948
|
"use strict";
|
|
2930
2949
|
var $;
|
|
2931
|
-
(function ($
|
|
2932
|
-
$
|
|
2933
|
-
'FQN of anon function'($) {
|
|
2934
|
-
const $$ = Object.assign($, { $mol_func_name_test: (() => () => { })() });
|
|
2935
|
-
$mol_assert_equal($$.$mol_func_name_test.name, '');
|
|
2936
|
-
$mol_assert_equal($$.$mol_func_name($$.$mol_func_name_test), '$mol_func_name_test');
|
|
2937
|
-
$mol_assert_equal($$.$mol_func_name_test.name, '$mol_func_name_test');
|
|
2938
|
-
},
|
|
2939
|
-
});
|
|
2950
|
+
(function ($) {
|
|
2951
|
+
$.$mol_dom_context = new $node.jsdom.JSDOM('', { url: 'https://localhost/' }).window;
|
|
2940
2952
|
})($ || ($ = {}));
|
|
2941
2953
|
|
|
2942
2954
|
;
|
|
2943
2955
|
"use strict";
|
|
2944
2956
|
var $;
|
|
2945
2957
|
(function ($) {
|
|
2946
|
-
|
|
2947
|
-
return JSON.stringify(cause, null, ' ')
|
|
2948
|
-
.replace(/\(/, '<')
|
|
2949
|
-
.replace(/\)/, ' >');
|
|
2950
|
-
}
|
|
2951
|
-
function frame_normalize(frame) {
|
|
2952
|
-
return (typeof frame === 'string' ? frame : cause_serialize(frame))
|
|
2953
|
-
.trim()
|
|
2954
|
-
.replace(/at /gm, ' at ')
|
|
2955
|
-
.replace(/^(?! +at )(.*)/gm, ' at | $1 (#)');
|
|
2956
|
-
}
|
|
2957
|
-
class $mol_error_mix extends AggregateError {
|
|
2958
|
-
cause;
|
|
2959
|
-
name = $$.$mol_func_name(this.constructor).replace(/^\$/, '') + '_Error';
|
|
2960
|
-
constructor(message, cause = {}, ...errors) {
|
|
2961
|
-
super(errors, message, { cause });
|
|
2962
|
-
this.cause = cause;
|
|
2963
|
-
const desc = Object.getOwnPropertyDescriptor(this, 'stack');
|
|
2964
|
-
const stack_get = () => desc?.get?.() ?? super.stack ?? desc?.value ?? this.message;
|
|
2965
|
-
Object.defineProperty(this, 'stack', {
|
|
2966
|
-
get: () => stack_get() + '\n' + [
|
|
2967
|
-
this.cause ?? 'no cause',
|
|
2968
|
-
...this.errors.flatMap(e => [
|
|
2969
|
-
String(e.stack),
|
|
2970
|
-
...e instanceof $mol_error_mix || !e.cause ? [] : [e.cause]
|
|
2971
|
-
])
|
|
2972
|
-
].map(frame_normalize).join('\n')
|
|
2973
|
-
});
|
|
2974
|
-
Object.defineProperty(this, 'cause', {
|
|
2975
|
-
get: () => cause
|
|
2976
|
-
});
|
|
2977
|
-
}
|
|
2978
|
-
static [Symbol.toPrimitive]() {
|
|
2979
|
-
return this.toString();
|
|
2980
|
-
}
|
|
2981
|
-
static toString() {
|
|
2982
|
-
return $$.$mol_func_name(this);
|
|
2983
|
-
}
|
|
2984
|
-
static make(...params) {
|
|
2985
|
-
return new this(...params);
|
|
2986
|
-
}
|
|
2987
|
-
}
|
|
2988
|
-
$.$mol_error_mix = $mol_error_mix;
|
|
2958
|
+
$.$mol_dom = $mol_dom_context;
|
|
2989
2959
|
})($ || ($ = {}));
|
|
2990
2960
|
|
|
2991
2961
|
;
|
|
2992
2962
|
"use strict";
|
|
2993
2963
|
var $;
|
|
2994
2964
|
(function ($) {
|
|
2995
|
-
$
|
|
2996
|
-
|
|
2997
|
-
|
|
2998
|
-
|
|
2999
|
-
|
|
3000
|
-
|
|
3001
|
-
|
|
3002
|
-
|
|
3003
|
-
|
|
3004
|
-
|
|
3005
|
-
|
|
3006
|
-
|
|
3007
|
-
|
|
3008
|
-
|
|
3009
|
-
|
|
3010
|
-
|
|
3011
|
-
|
|
3012
|
-
|
|
3013
|
-
|
|
3014
|
-
|
|
3015
|
-
|
|
2965
|
+
function $mol_dom_render_children(el, childNodes) {
|
|
2966
|
+
const node_set = new Set(childNodes);
|
|
2967
|
+
let nextNode = el.firstChild;
|
|
2968
|
+
for (let view of childNodes) {
|
|
2969
|
+
if (view == null)
|
|
2970
|
+
continue;
|
|
2971
|
+
if (view instanceof $mol_dom_context.Node) {
|
|
2972
|
+
while (true) {
|
|
2973
|
+
if (!nextNode) {
|
|
2974
|
+
el.appendChild(view);
|
|
2975
|
+
break;
|
|
2976
|
+
}
|
|
2977
|
+
if (nextNode == view) {
|
|
2978
|
+
nextNode = nextNode.nextSibling;
|
|
2979
|
+
break;
|
|
2980
|
+
}
|
|
2981
|
+
else {
|
|
2982
|
+
if (node_set.has(nextNode)) {
|
|
2983
|
+
el.insertBefore(view, nextNode);
|
|
2984
|
+
break;
|
|
2985
|
+
}
|
|
2986
|
+
else {
|
|
2987
|
+
const nn = nextNode.nextSibling;
|
|
2988
|
+
el.removeChild(nextNode);
|
|
2989
|
+
nextNode = nn;
|
|
2990
|
+
}
|
|
3016
2991
|
}
|
|
3017
2992
|
}
|
|
3018
2993
|
}
|
|
3019
|
-
|
|
3020
|
-
|
|
3021
|
-
|
|
2994
|
+
else {
|
|
2995
|
+
if (nextNode && nextNode.nodeName === '#text') {
|
|
2996
|
+
const str = String(view);
|
|
2997
|
+
if (nextNode.nodeValue !== str)
|
|
2998
|
+
nextNode.nodeValue = str;
|
|
2999
|
+
nextNode = nextNode.nextSibling;
|
|
3000
|
+
}
|
|
3001
|
+
else {
|
|
3002
|
+
const textNode = $mol_dom_context.document.createTextNode(String(view));
|
|
3003
|
+
el.insertBefore(textNode, nextNode);
|
|
3004
|
+
}
|
|
3005
|
+
}
|
|
3006
|
+
}
|
|
3007
|
+
while (nextNode) {
|
|
3008
|
+
const currNode = nextNode;
|
|
3009
|
+
nextNode = currNode.nextSibling;
|
|
3010
|
+
el.removeChild(currNode);
|
|
3011
|
+
}
|
|
3012
|
+
}
|
|
3013
|
+
$.$mol_dom_render_children = $mol_dom_render_children;
|
|
3022
3014
|
})($ || ($ = {}));
|
|
3023
3015
|
|
|
3024
3016
|
;
|
|
@@ -3036,510 +3028,136 @@ var $;
|
|
|
3036
3028
|
;
|
|
3037
3029
|
"use strict";
|
|
3038
3030
|
|
|
3039
|
-
;
|
|
3040
|
-
"use strict";
|
|
3041
|
-
|
|
3042
|
-
;
|
|
3043
|
-
"use strict";
|
|
3044
|
-
var $;
|
|
3045
|
-
(function ($_1) {
|
|
3046
|
-
$mol_test({
|
|
3047
|
-
'init with overload'() {
|
|
3048
|
-
class X extends $mol_object {
|
|
3049
|
-
foo() {
|
|
3050
|
-
return 1;
|
|
3051
|
-
}
|
|
3052
|
-
}
|
|
3053
|
-
var x = X.make({
|
|
3054
|
-
foo: () => 2,
|
|
3055
|
-
});
|
|
3056
|
-
$mol_assert_equal(x.foo(), 2);
|
|
3057
|
-
},
|
|
3058
|
-
'Context in instance inherits from class'($) {
|
|
3059
|
-
const custom = $.$mol_ambient({});
|
|
3060
|
-
class X extends $.$mol_object {
|
|
3061
|
-
static $ = custom;
|
|
3062
|
-
}
|
|
3063
|
-
$mol_assert_equal(new X().$, custom);
|
|
3064
|
-
},
|
|
3065
|
-
});
|
|
3066
|
-
})($ || ($ = {}));
|
|
3067
|
-
|
|
3068
3031
|
;
|
|
3069
3032
|
"use strict";
|
|
3070
3033
|
var $;
|
|
3071
3034
|
(function ($) {
|
|
3072
|
-
function $
|
|
3073
|
-
|
|
3035
|
+
function $mol_dom_serialize(node) {
|
|
3036
|
+
const serializer = new $mol_dom_context.XMLSerializer;
|
|
3037
|
+
return serializer.serializeToString(node);
|
|
3074
3038
|
}
|
|
3075
|
-
$.$
|
|
3039
|
+
$.$mol_dom_serialize = $mol_dom_serialize;
|
|
3076
3040
|
})($ || ($ = {}));
|
|
3077
3041
|
|
|
3078
3042
|
;
|
|
3079
3043
|
"use strict";
|
|
3080
3044
|
var $;
|
|
3081
3045
|
(function ($) {
|
|
3082
|
-
$.$
|
|
3083
|
-
|
|
3046
|
+
$.$mol_jsx_prefix = '';
|
|
3047
|
+
$.$mol_jsx_crumbs = '';
|
|
3048
|
+
$.$mol_jsx_booked = null;
|
|
3049
|
+
$.$mol_jsx_document = {
|
|
3050
|
+
getElementById: () => null,
|
|
3051
|
+
createElementNS: (space, name) => $mol_dom_context.document.createElementNS(space, name),
|
|
3052
|
+
createDocumentFragment: () => $mol_dom_context.document.createDocumentFragment(),
|
|
3084
3053
|
};
|
|
3085
|
-
|
|
3086
|
-
|
|
3087
|
-
;
|
|
3088
|
-
|
|
3089
|
-
|
|
3090
|
-
(
|
|
3091
|
-
|
|
3092
|
-
|
|
3093
|
-
class A {
|
|
3094
|
-
static a() {
|
|
3095
|
-
return Promise.resolve('');
|
|
3096
|
-
}
|
|
3097
|
-
static b() {
|
|
3098
|
-
return $mol_wire_sync(this).a();
|
|
3099
|
-
}
|
|
3100
|
-
}
|
|
3101
|
-
},
|
|
3102
|
-
async 'test method from host'($) {
|
|
3103
|
-
let count = 0;
|
|
3104
|
-
class A {
|
|
3105
|
-
static a() {
|
|
3106
|
-
return $mol_wire_sync(this).b();
|
|
3107
|
-
}
|
|
3108
|
-
static b() { return Promise.resolve(++count); }
|
|
3109
|
-
}
|
|
3110
|
-
$mol_assert_equal(await $mol_wire_async(A).a(), 1, count);
|
|
3111
|
-
},
|
|
3112
|
-
async 'test function'($) {
|
|
3113
|
-
let count = 0;
|
|
3114
|
-
class A {
|
|
3115
|
-
static a() {
|
|
3116
|
-
return $mol_wire_sync(this.b)();
|
|
3117
|
-
}
|
|
3118
|
-
static b() { return Promise.resolve(++count); }
|
|
3054
|
+
$.$mol_jsx_frag = '';
|
|
3055
|
+
function $mol_jsx(Elem, props, ...childNodes) {
|
|
3056
|
+
const id = props && props.id || '';
|
|
3057
|
+
const guid = id ? $.$mol_jsx_prefix ? $.$mol_jsx_prefix + '/' + id : id : $.$mol_jsx_prefix;
|
|
3058
|
+
const crumbs_self = id ? $.$mol_jsx_crumbs.replace(/(\S+)/g, `$1_${id.replace(/\/.*/i, '')}`) : $.$mol_jsx_crumbs;
|
|
3059
|
+
if (Elem && $.$mol_jsx_booked) {
|
|
3060
|
+
if ($.$mol_jsx_booked.has(id)) {
|
|
3061
|
+
$mol_fail(new Error(`JSX already has tag with id ${JSON.stringify(guid)}`));
|
|
3119
3062
|
}
|
|
3120
|
-
|
|
3121
|
-
|
|
3122
|
-
async 'test construct itself'($) {
|
|
3123
|
-
class A {
|
|
3124
|
-
static instances = [];
|
|
3125
|
-
static a() {
|
|
3126
|
-
const a = new ($mol_wire_sync(A))();
|
|
3127
|
-
this.instances.push(a);
|
|
3128
|
-
$mol_wire_sync(this).b();
|
|
3129
|
-
}
|
|
3130
|
-
static b() { return Promise.resolve(); }
|
|
3063
|
+
else {
|
|
3064
|
+
$.$mol_jsx_booked.add(id);
|
|
3131
3065
|
}
|
|
3132
|
-
await $mol_wire_async(A).a();
|
|
3133
|
-
$mol_assert_equal(A.instances.length, 2);
|
|
3134
|
-
$mol_assert_equal(A.instances[0] instanceof A, true);
|
|
3135
|
-
$mol_assert_equal(A.instances[0], A.instances[1]);
|
|
3136
3066
|
}
|
|
3137
|
-
|
|
3138
|
-
|
|
3139
|
-
|
|
3140
|
-
;
|
|
3141
|
-
|
|
3142
|
-
|
|
3143
|
-
|
|
3144
|
-
|
|
3145
|
-
|
|
3146
|
-
|
|
3147
|
-
|
|
3148
|
-
|
|
3149
|
-
|
|
3150
|
-
|
|
3151
|
-
|
|
3152
|
-
|
|
3153
|
-
|
|
3154
|
-
;
|
|
3155
|
-
|
|
3156
|
-
|
|
3157
|
-
|
|
3158
|
-
|
|
3159
|
-
|
|
3160
|
-
|
|
3161
|
-
|
|
3162
|
-
|
|
3163
|
-
|
|
3164
|
-
|
|
3165
|
-
return Boolean(this.$.$mol_env()['MOL_RUN_ASYNC']);
|
|
3166
|
-
}
|
|
3167
|
-
static spawn(options) {
|
|
3168
|
-
const sync = !this.async_enabled() || !Boolean($mol_wire_auto());
|
|
3169
|
-
const env = options.env ?? this.$.$mol_env();
|
|
3170
|
-
return $mol_wire_sync(this).spawn_async({ ...options, sync, env });
|
|
3067
|
+
let node = guid ? $.$mol_jsx_document.getElementById(guid) : null;
|
|
3068
|
+
if ($.$mol_jsx_prefix) {
|
|
3069
|
+
const prefix_ext = $.$mol_jsx_prefix;
|
|
3070
|
+
const booked_ext = $.$mol_jsx_booked;
|
|
3071
|
+
const crumbs_ext = $.$mol_jsx_crumbs;
|
|
3072
|
+
for (const field in props) {
|
|
3073
|
+
const func = props[field];
|
|
3074
|
+
if (typeof func !== 'function')
|
|
3075
|
+
continue;
|
|
3076
|
+
const wrapper = function (...args) {
|
|
3077
|
+
const prefix = $.$mol_jsx_prefix;
|
|
3078
|
+
const booked = $.$mol_jsx_booked;
|
|
3079
|
+
const crumbs = $.$mol_jsx_crumbs;
|
|
3080
|
+
try {
|
|
3081
|
+
$.$mol_jsx_prefix = prefix_ext;
|
|
3082
|
+
$.$mol_jsx_booked = booked_ext;
|
|
3083
|
+
$.$mol_jsx_crumbs = crumbs_ext;
|
|
3084
|
+
return func.call(this, ...args);
|
|
3085
|
+
}
|
|
3086
|
+
finally {
|
|
3087
|
+
$.$mol_jsx_prefix = prefix;
|
|
3088
|
+
$.$mol_jsx_booked = booked;
|
|
3089
|
+
$.$mol_jsx_crumbs = crumbs;
|
|
3090
|
+
}
|
|
3091
|
+
};
|
|
3092
|
+
$mol_func_name_from(wrapper, func);
|
|
3093
|
+
props[field] = wrapper;
|
|
3094
|
+
}
|
|
3171
3095
|
}
|
|
3172
|
-
|
|
3173
|
-
|
|
3174
|
-
|
|
3175
|
-
|
|
3176
|
-
|
|
3177
|
-
|
|
3178
|
-
|
|
3179
|
-
|
|
3180
|
-
|
|
3181
|
-
|
|
3182
|
-
|
|
3183
|
-
|
|
3184
|
-
|
|
3185
|
-
|
|
3186
|
-
|
|
3187
|
-
|
|
3188
|
-
|
|
3096
|
+
if (typeof Elem !== 'string') {
|
|
3097
|
+
if ('prototype' in Elem) {
|
|
3098
|
+
const view = node && node[String(Elem)] || new Elem;
|
|
3099
|
+
Object.assign(view, props);
|
|
3100
|
+
view[Symbol.toStringTag] = guid;
|
|
3101
|
+
view.childNodes = childNodes;
|
|
3102
|
+
if (!view.ownerDocument)
|
|
3103
|
+
view.ownerDocument = $.$mol_jsx_document;
|
|
3104
|
+
view.className = (crumbs_self ? crumbs_self + ' ' : '') + (Elem['name'] || Elem);
|
|
3105
|
+
node = view.valueOf();
|
|
3106
|
+
node[String(Elem)] = view;
|
|
3107
|
+
return node;
|
|
3108
|
+
}
|
|
3109
|
+
else {
|
|
3110
|
+
const prefix = $.$mol_jsx_prefix;
|
|
3111
|
+
const booked = $.$mol_jsx_booked;
|
|
3112
|
+
const crumbs = $.$mol_jsx_crumbs;
|
|
3189
3113
|
try {
|
|
3190
|
-
|
|
3191
|
-
|
|
3192
|
-
|
|
3193
|
-
|
|
3194
|
-
error = err;
|
|
3114
|
+
$.$mol_jsx_prefix = guid;
|
|
3115
|
+
$.$mol_jsx_booked = new Set;
|
|
3116
|
+
$.$mol_jsx_crumbs = (crumbs_self ? crumbs_self + ' ' : '') + (Elem['name'] || Elem);
|
|
3117
|
+
return Elem(props, ...childNodes);
|
|
3195
3118
|
}
|
|
3196
|
-
|
|
3197
|
-
|
|
3119
|
+
finally {
|
|
3120
|
+
$.$mol_jsx_prefix = prefix;
|
|
3121
|
+
$.$mol_jsx_booked = booked;
|
|
3122
|
+
$.$mol_jsx_crumbs = crumbs;
|
|
3198
3123
|
}
|
|
3199
|
-
return res;
|
|
3200
|
-
}
|
|
3201
|
-
let sub;
|
|
3202
|
-
try {
|
|
3203
|
-
sub = this.$.$mol_run_spawn(app, args, {
|
|
3204
|
-
...opts,
|
|
3205
|
-
stdio: ['pipe', 'inherit', 'inherit'],
|
|
3206
|
-
});
|
|
3207
3124
|
}
|
|
3208
|
-
catch (error) {
|
|
3209
|
-
throw new $mol_run_error(this.error_message(undefined), log_object, error);
|
|
3210
|
-
}
|
|
3211
|
-
const pid = sub.pid ?? 0;
|
|
3212
|
-
this.$.$mol_log3_come({
|
|
3213
|
-
...log_object,
|
|
3214
|
-
pid,
|
|
3215
|
-
});
|
|
3216
|
-
let timeout_kill = false;
|
|
3217
|
-
let timer;
|
|
3218
|
-
const std_data = [];
|
|
3219
|
-
const error_data = [];
|
|
3220
|
-
const add = (std_chunk, error_chunk) => {
|
|
3221
|
-
if (std_chunk)
|
|
3222
|
-
std_data.push(std_chunk);
|
|
3223
|
-
if (error_chunk)
|
|
3224
|
-
error_data.push(error_chunk);
|
|
3225
|
-
if (!timeout)
|
|
3226
|
-
return;
|
|
3227
|
-
clearTimeout(timer);
|
|
3228
|
-
timer = setTimeout(() => {
|
|
3229
|
-
const signal = timeout_kill ? 'SIGKILL' : 'SIGTERM';
|
|
3230
|
-
timeout_kill = true;
|
|
3231
|
-
add();
|
|
3232
|
-
sub.kill(signal);
|
|
3233
|
-
}, timeout);
|
|
3234
|
-
};
|
|
3235
|
-
add();
|
|
3236
|
-
sub.stdout?.on('data', data => add(data));
|
|
3237
|
-
sub.stderr?.on('data', data => add(undefined, data));
|
|
3238
|
-
const result_promise = new Promise((done, fail) => {
|
|
3239
|
-
const close = (error, status = null, signal = null) => {
|
|
3240
|
-
if (!timer && timeout)
|
|
3241
|
-
return;
|
|
3242
|
-
clearTimeout(timer);
|
|
3243
|
-
timer = undefined;
|
|
3244
|
-
const res = {
|
|
3245
|
-
pid,
|
|
3246
|
-
signal,
|
|
3247
|
-
get stdout() { return Buffer.concat(std_data); },
|
|
3248
|
-
get stderr() { return Buffer.concat(error_data); }
|
|
3249
|
-
};
|
|
3250
|
-
if (error || status || timeout_kill)
|
|
3251
|
-
return fail(new $mol_run_error(this.error_message(res) + (timeout_kill ? ', timeout' : ''), { ...log_object, pid, status, signal, timeout_kill }, ...error ? [error] : []));
|
|
3252
|
-
this.$.$mol_log3_done({
|
|
3253
|
-
...log_object,
|
|
3254
|
-
pid,
|
|
3255
|
-
});
|
|
3256
|
-
done(res);
|
|
3257
|
-
};
|
|
3258
|
-
sub.on('disconnect', () => close(new Error('Disconnected')));
|
|
3259
|
-
sub.on('error', err => close(err));
|
|
3260
|
-
sub.on('exit', (status, signal) => close(null, status, signal));
|
|
3261
|
-
});
|
|
3262
|
-
return Object.assign(result_promise, { destructor: () => {
|
|
3263
|
-
clearTimeout(timer);
|
|
3264
|
-
sub.kill('SIGKILL');
|
|
3265
|
-
} });
|
|
3266
3125
|
}
|
|
3267
|
-
|
|
3268
|
-
|
|
3126
|
+
if (!node) {
|
|
3127
|
+
node = Elem
|
|
3128
|
+
? $.$mol_jsx_document.createElementNS(props?.xmlns ?? 'http://www.w3.org/1999/xhtml', Elem)
|
|
3129
|
+
: $.$mol_jsx_document.createDocumentFragment();
|
|
3269
3130
|
}
|
|
3270
|
-
|
|
3271
|
-
|
|
3272
|
-
|
|
3273
|
-
|
|
3274
|
-
;
|
|
3275
|
-
|
|
3276
|
-
|
|
3277
|
-
|
|
3278
|
-
|
|
3279
|
-
|
|
3280
|
-
|
|
3281
|
-
|
|
3282
|
-
function mol_run_spawn_sync_mock() {
|
|
3283
|
-
return {
|
|
3284
|
-
output: [],
|
|
3285
|
-
stdout: error_message,
|
|
3286
|
-
stderr: '',
|
|
3287
|
-
status: 0,
|
|
3288
|
-
signal: null,
|
|
3289
|
-
pid: 123,
|
|
3290
|
-
};
|
|
3291
|
-
}
|
|
3292
|
-
function mol_run_spawn_mock() {
|
|
3293
|
-
return {
|
|
3294
|
-
on(name, cb) {
|
|
3295
|
-
if (name === 'exit')
|
|
3296
|
-
close_mock = cb;
|
|
3297
|
-
},
|
|
3298
|
-
kill() { close_mock(); }
|
|
3299
|
-
};
|
|
3131
|
+
$mol_dom_render_children(node, [].concat(...childNodes));
|
|
3132
|
+
if (!Elem)
|
|
3133
|
+
return node;
|
|
3134
|
+
if (guid)
|
|
3135
|
+
node.id = guid;
|
|
3136
|
+
for (const key in props) {
|
|
3137
|
+
if (key === 'id')
|
|
3138
|
+
continue;
|
|
3139
|
+
if (typeof props[key] === 'string') {
|
|
3140
|
+
if (typeof node[key] === 'string')
|
|
3141
|
+
node[key] = props[key];
|
|
3142
|
+
node.setAttribute(key, props[key]);
|
|
3300
3143
|
}
|
|
3301
|
-
|
|
3302
|
-
|
|
3303
|
-
|
|
3304
|
-
|
|
3305
|
-
|
|
3306
|
-
|
|
3307
|
-
static async_enabled() {
|
|
3308
|
-
return true;
|
|
3144
|
+
else if (props[key] &&
|
|
3145
|
+
typeof props[key] === 'object' &&
|
|
3146
|
+
Reflect.getPrototypeOf(props[key]) === Reflect.getPrototypeOf({})) {
|
|
3147
|
+
if (typeof node[key] === 'object') {
|
|
3148
|
+
Object.assign(node[key], props[key]);
|
|
3149
|
+
continue;
|
|
3309
3150
|
}
|
|
3310
3151
|
}
|
|
3311
|
-
|
|
3312
|
-
|
|
3313
|
-
const res = await $mol_wire_async($mol_run_mock).spawn({
|
|
3314
|
-
command: 'sleep 10',
|
|
3315
|
-
dir: '.',
|
|
3316
|
-
timeout: 10,
|
|
3317
|
-
env: { 'MOL_RUN_ASYNC': '1' }
|
|
3318
|
-
});
|
|
3319
|
-
}
|
|
3320
|
-
catch (e) {
|
|
3321
|
-
message = e.message;
|
|
3152
|
+
else {
|
|
3153
|
+
node[key] = props[key];
|
|
3322
3154
|
}
|
|
3323
|
-
$mol_assert_equal(message, error_message);
|
|
3324
3155
|
}
|
|
3325
|
-
|
|
3326
|
-
|
|
3327
|
-
|
|
3328
|
-
;
|
|
3329
|
-
"use strict";
|
|
3330
|
-
var $;
|
|
3331
|
-
(function ($) {
|
|
3332
|
-
function $mol_exec(dir, command, ...args) {
|
|
3333
|
-
return this.$mol_run.spawn({ command: [command, ...args], dir });
|
|
3156
|
+
if ($.$mol_jsx_crumbs)
|
|
3157
|
+
node.className = (props?.['class'] ? props['class'] + ' ' : '') + crumbs_self;
|
|
3158
|
+
return node;
|
|
3334
3159
|
}
|
|
3335
|
-
$.$
|
|
3336
|
-
})($ || ($ = {}));
|
|
3337
|
-
|
|
3338
|
-
;
|
|
3339
|
-
"use strict";
|
|
3340
|
-
var $;
|
|
3341
|
-
(function ($) {
|
|
3342
|
-
$.$mol_dom_context = new $node.jsdom.JSDOM('', { url: 'https://localhost/' }).window;
|
|
3343
|
-
})($ || ($ = {}));
|
|
3344
|
-
|
|
3345
|
-
;
|
|
3346
|
-
"use strict";
|
|
3347
|
-
var $;
|
|
3348
|
-
(function ($) {
|
|
3349
|
-
$.$mol_dom = $mol_dom_context;
|
|
3350
|
-
})($ || ($ = {}));
|
|
3351
|
-
|
|
3352
|
-
;
|
|
3353
|
-
"use strict";
|
|
3354
|
-
var $;
|
|
3355
|
-
(function ($) {
|
|
3356
|
-
function $mol_dom_render_children(el, childNodes) {
|
|
3357
|
-
const node_set = new Set(childNodes);
|
|
3358
|
-
let nextNode = el.firstChild;
|
|
3359
|
-
for (let view of childNodes) {
|
|
3360
|
-
if (view == null)
|
|
3361
|
-
continue;
|
|
3362
|
-
if (view instanceof $mol_dom_context.Node) {
|
|
3363
|
-
while (true) {
|
|
3364
|
-
if (!nextNode) {
|
|
3365
|
-
el.appendChild(view);
|
|
3366
|
-
break;
|
|
3367
|
-
}
|
|
3368
|
-
if (nextNode == view) {
|
|
3369
|
-
nextNode = nextNode.nextSibling;
|
|
3370
|
-
break;
|
|
3371
|
-
}
|
|
3372
|
-
else {
|
|
3373
|
-
if (node_set.has(nextNode)) {
|
|
3374
|
-
el.insertBefore(view, nextNode);
|
|
3375
|
-
break;
|
|
3376
|
-
}
|
|
3377
|
-
else {
|
|
3378
|
-
const nn = nextNode.nextSibling;
|
|
3379
|
-
el.removeChild(nextNode);
|
|
3380
|
-
nextNode = nn;
|
|
3381
|
-
}
|
|
3382
|
-
}
|
|
3383
|
-
}
|
|
3384
|
-
}
|
|
3385
|
-
else {
|
|
3386
|
-
if (nextNode && nextNode.nodeName === '#text') {
|
|
3387
|
-
const str = String(view);
|
|
3388
|
-
if (nextNode.nodeValue !== str)
|
|
3389
|
-
nextNode.nodeValue = str;
|
|
3390
|
-
nextNode = nextNode.nextSibling;
|
|
3391
|
-
}
|
|
3392
|
-
else {
|
|
3393
|
-
const textNode = $mol_dom_context.document.createTextNode(String(view));
|
|
3394
|
-
el.insertBefore(textNode, nextNode);
|
|
3395
|
-
}
|
|
3396
|
-
}
|
|
3397
|
-
}
|
|
3398
|
-
while (nextNode) {
|
|
3399
|
-
const currNode = nextNode;
|
|
3400
|
-
nextNode = currNode.nextSibling;
|
|
3401
|
-
el.removeChild(currNode);
|
|
3402
|
-
}
|
|
3403
|
-
}
|
|
3404
|
-
$.$mol_dom_render_children = $mol_dom_render_children;
|
|
3405
|
-
})($ || ($ = {}));
|
|
3406
|
-
|
|
3407
|
-
;
|
|
3408
|
-
"use strict";
|
|
3409
|
-
|
|
3410
|
-
;
|
|
3411
|
-
"use strict";
|
|
3412
|
-
|
|
3413
|
-
;
|
|
3414
|
-
"use strict";
|
|
3415
|
-
var $;
|
|
3416
|
-
(function ($) {
|
|
3417
|
-
function $mol_dom_serialize(node) {
|
|
3418
|
-
const serializer = new $mol_dom_context.XMLSerializer;
|
|
3419
|
-
return serializer.serializeToString(node);
|
|
3420
|
-
}
|
|
3421
|
-
$.$mol_dom_serialize = $mol_dom_serialize;
|
|
3422
|
-
})($ || ($ = {}));
|
|
3423
|
-
|
|
3424
|
-
;
|
|
3425
|
-
"use strict";
|
|
3426
|
-
var $;
|
|
3427
|
-
(function ($) {
|
|
3428
|
-
$.$mol_jsx_prefix = '';
|
|
3429
|
-
$.$mol_jsx_crumbs = '';
|
|
3430
|
-
$.$mol_jsx_booked = null;
|
|
3431
|
-
$.$mol_jsx_document = {
|
|
3432
|
-
getElementById: () => null,
|
|
3433
|
-
createElementNS: (space, name) => $mol_dom_context.document.createElementNS(space, name),
|
|
3434
|
-
createDocumentFragment: () => $mol_dom_context.document.createDocumentFragment(),
|
|
3435
|
-
};
|
|
3436
|
-
$.$mol_jsx_frag = '';
|
|
3437
|
-
function $mol_jsx(Elem, props, ...childNodes) {
|
|
3438
|
-
const id = props && props.id || '';
|
|
3439
|
-
const guid = id ? $.$mol_jsx_prefix ? $.$mol_jsx_prefix + '/' + id : id : $.$mol_jsx_prefix;
|
|
3440
|
-
const crumbs_self = id ? $.$mol_jsx_crumbs.replace(/(\S+)/g, `$1_${id.replace(/\/.*/i, '')}`) : $.$mol_jsx_crumbs;
|
|
3441
|
-
if (Elem && $.$mol_jsx_booked) {
|
|
3442
|
-
if ($.$mol_jsx_booked.has(id)) {
|
|
3443
|
-
$mol_fail(new Error(`JSX already has tag with id ${JSON.stringify(guid)}`));
|
|
3444
|
-
}
|
|
3445
|
-
else {
|
|
3446
|
-
$.$mol_jsx_booked.add(id);
|
|
3447
|
-
}
|
|
3448
|
-
}
|
|
3449
|
-
let node = guid ? $.$mol_jsx_document.getElementById(guid) : null;
|
|
3450
|
-
if ($.$mol_jsx_prefix) {
|
|
3451
|
-
const prefix_ext = $.$mol_jsx_prefix;
|
|
3452
|
-
const booked_ext = $.$mol_jsx_booked;
|
|
3453
|
-
const crumbs_ext = $.$mol_jsx_crumbs;
|
|
3454
|
-
for (const field in props) {
|
|
3455
|
-
const func = props[field];
|
|
3456
|
-
if (typeof func !== 'function')
|
|
3457
|
-
continue;
|
|
3458
|
-
const wrapper = function (...args) {
|
|
3459
|
-
const prefix = $.$mol_jsx_prefix;
|
|
3460
|
-
const booked = $.$mol_jsx_booked;
|
|
3461
|
-
const crumbs = $.$mol_jsx_crumbs;
|
|
3462
|
-
try {
|
|
3463
|
-
$.$mol_jsx_prefix = prefix_ext;
|
|
3464
|
-
$.$mol_jsx_booked = booked_ext;
|
|
3465
|
-
$.$mol_jsx_crumbs = crumbs_ext;
|
|
3466
|
-
return func.call(this, ...args);
|
|
3467
|
-
}
|
|
3468
|
-
finally {
|
|
3469
|
-
$.$mol_jsx_prefix = prefix;
|
|
3470
|
-
$.$mol_jsx_booked = booked;
|
|
3471
|
-
$.$mol_jsx_crumbs = crumbs;
|
|
3472
|
-
}
|
|
3473
|
-
};
|
|
3474
|
-
$mol_func_name_from(wrapper, func);
|
|
3475
|
-
props[field] = wrapper;
|
|
3476
|
-
}
|
|
3477
|
-
}
|
|
3478
|
-
if (typeof Elem !== 'string') {
|
|
3479
|
-
if ('prototype' in Elem) {
|
|
3480
|
-
const view = node && node[String(Elem)] || new Elem;
|
|
3481
|
-
Object.assign(view, props);
|
|
3482
|
-
view[Symbol.toStringTag] = guid;
|
|
3483
|
-
view.childNodes = childNodes;
|
|
3484
|
-
if (!view.ownerDocument)
|
|
3485
|
-
view.ownerDocument = $.$mol_jsx_document;
|
|
3486
|
-
view.className = (crumbs_self ? crumbs_self + ' ' : '') + (Elem['name'] || Elem);
|
|
3487
|
-
node = view.valueOf();
|
|
3488
|
-
node[String(Elem)] = view;
|
|
3489
|
-
return node;
|
|
3490
|
-
}
|
|
3491
|
-
else {
|
|
3492
|
-
const prefix = $.$mol_jsx_prefix;
|
|
3493
|
-
const booked = $.$mol_jsx_booked;
|
|
3494
|
-
const crumbs = $.$mol_jsx_crumbs;
|
|
3495
|
-
try {
|
|
3496
|
-
$.$mol_jsx_prefix = guid;
|
|
3497
|
-
$.$mol_jsx_booked = new Set;
|
|
3498
|
-
$.$mol_jsx_crumbs = (crumbs_self ? crumbs_self + ' ' : '') + (Elem['name'] || Elem);
|
|
3499
|
-
return Elem(props, ...childNodes);
|
|
3500
|
-
}
|
|
3501
|
-
finally {
|
|
3502
|
-
$.$mol_jsx_prefix = prefix;
|
|
3503
|
-
$.$mol_jsx_booked = booked;
|
|
3504
|
-
$.$mol_jsx_crumbs = crumbs;
|
|
3505
|
-
}
|
|
3506
|
-
}
|
|
3507
|
-
}
|
|
3508
|
-
if (!node) {
|
|
3509
|
-
node = Elem
|
|
3510
|
-
? $.$mol_jsx_document.createElementNS(props?.xmlns ?? 'http://www.w3.org/1999/xhtml', Elem)
|
|
3511
|
-
: $.$mol_jsx_document.createDocumentFragment();
|
|
3512
|
-
}
|
|
3513
|
-
$mol_dom_render_children(node, [].concat(...childNodes));
|
|
3514
|
-
if (!Elem)
|
|
3515
|
-
return node;
|
|
3516
|
-
if (guid)
|
|
3517
|
-
node.id = guid;
|
|
3518
|
-
for (const key in props) {
|
|
3519
|
-
if (key === 'id')
|
|
3520
|
-
continue;
|
|
3521
|
-
if (typeof props[key] === 'string') {
|
|
3522
|
-
if (typeof node[key] === 'string')
|
|
3523
|
-
node[key] = props[key];
|
|
3524
|
-
node.setAttribute(key, props[key]);
|
|
3525
|
-
}
|
|
3526
|
-
else if (props[key] &&
|
|
3527
|
-
typeof props[key] === 'object' &&
|
|
3528
|
-
Reflect.getPrototypeOf(props[key]) === Reflect.getPrototypeOf({})) {
|
|
3529
|
-
if (typeof node[key] === 'object') {
|
|
3530
|
-
Object.assign(node[key], props[key]);
|
|
3531
|
-
continue;
|
|
3532
|
-
}
|
|
3533
|
-
}
|
|
3534
|
-
else {
|
|
3535
|
-
node[key] = props[key];
|
|
3536
|
-
}
|
|
3537
|
-
}
|
|
3538
|
-
if ($.$mol_jsx_crumbs)
|
|
3539
|
-
node.className = (props?.['class'] ? props['class'] + ' ' : '') + crumbs_self;
|
|
3540
|
-
return node;
|
|
3541
|
-
}
|
|
3542
|
-
$.$mol_jsx = $mol_jsx;
|
|
3160
|
+
$.$mol_jsx = $mol_jsx;
|
|
3543
3161
|
})($ || ($ = {}));
|
|
3544
3162
|
|
|
3545
3163
|
;
|
|
@@ -4119,8 +3737,6 @@ var $;
|
|
|
4119
3737
|
for (let i = 1; i < args.length; ++i) {
|
|
4120
3738
|
if ($mol_compare_deep(args[0], args[i]))
|
|
4121
3739
|
continue;
|
|
4122
|
-
if (args[0] instanceof $mol_dom_context.Element && args[i] instanceof $mol_dom_context.Element && args[0].outerHTML === args[i].outerHTML)
|
|
4123
|
-
continue;
|
|
4124
3740
|
return $mol_fail(new Error(`Equality assertion failure`, { cause: { 0: args[0], [i]: args[i] } }));
|
|
4125
3741
|
}
|
|
4126
3742
|
}
|
|
@@ -4165,6 +3781,43 @@ var $;
|
|
|
4165
3781
|
});
|
|
4166
3782
|
})($ || ($ = {}));
|
|
4167
3783
|
|
|
3784
|
+
;
|
|
3785
|
+
"use strict";
|
|
3786
|
+
var $;
|
|
3787
|
+
(function ($_1) {
|
|
3788
|
+
$mol_test_mocks.push($ => {
|
|
3789
|
+
$.$mol_log3_come = () => { };
|
|
3790
|
+
$.$mol_log3_done = () => { };
|
|
3791
|
+
$.$mol_log3_fail = () => { };
|
|
3792
|
+
$.$mol_log3_warn = () => { };
|
|
3793
|
+
$.$mol_log3_rise = () => { };
|
|
3794
|
+
$.$mol_log3_area = () => () => { };
|
|
3795
|
+
});
|
|
3796
|
+
})($ || ($ = {}));
|
|
3797
|
+
|
|
3798
|
+
;
|
|
3799
|
+
"use strict";
|
|
3800
|
+
|
|
3801
|
+
;
|
|
3802
|
+
"use strict";
|
|
3803
|
+
|
|
3804
|
+
;
|
|
3805
|
+
"use strict";
|
|
3806
|
+
|
|
3807
|
+
;
|
|
3808
|
+
"use strict";
|
|
3809
|
+
var $;
|
|
3810
|
+
(function ($_1) {
|
|
3811
|
+
$mol_test({
|
|
3812
|
+
'FQN of anon function'($) {
|
|
3813
|
+
const $$ = Object.assign($, { $mol_func_name_test: (() => () => { })() });
|
|
3814
|
+
$mol_assert_equal($$.$mol_func_name_test.name, '');
|
|
3815
|
+
$mol_assert_equal($$.$mol_func_name($$.$mol_func_name_test), '$mol_func_name_test');
|
|
3816
|
+
$mol_assert_equal($$.$mol_func_name_test.name, '$mol_func_name_test');
|
|
3817
|
+
},
|
|
3818
|
+
});
|
|
3819
|
+
})($ || ($ = {}));
|
|
3820
|
+
|
|
4168
3821
|
;
|
|
4169
3822
|
"use strict";
|
|
4170
3823
|
var $;
|
|
@@ -4748,17 +4401,123 @@ var $;
|
|
|
4748
4401
|
;
|
|
4749
4402
|
"use strict";
|
|
4750
4403
|
var $;
|
|
4751
|
-
(function ($) {
|
|
4752
|
-
|
|
4753
|
-
|
|
4754
|
-
|
|
4755
|
-
|
|
4756
|
-
|
|
4757
|
-
|
|
4758
|
-
|
|
4759
|
-
|
|
4760
|
-
|
|
4761
|
-
|
|
4404
|
+
(function ($_1) {
|
|
4405
|
+
$mol_test({
|
|
4406
|
+
'test types'($) {
|
|
4407
|
+
class A {
|
|
4408
|
+
static a() {
|
|
4409
|
+
return '';
|
|
4410
|
+
}
|
|
4411
|
+
static b() {
|
|
4412
|
+
return $mol_wire_async(this).a();
|
|
4413
|
+
}
|
|
4414
|
+
}
|
|
4415
|
+
},
|
|
4416
|
+
async 'Latest method calls wins'($) {
|
|
4417
|
+
class NameLogger extends $mol_object2 {
|
|
4418
|
+
static $ = $;
|
|
4419
|
+
static first = [];
|
|
4420
|
+
static last = [];
|
|
4421
|
+
static send(next) {
|
|
4422
|
+
$mol_wire_sync(this.first).push(next);
|
|
4423
|
+
$$.$mol_wait_timeout(0);
|
|
4424
|
+
this.last.push(next);
|
|
4425
|
+
}
|
|
4426
|
+
}
|
|
4427
|
+
const name = $mol_wire_async(NameLogger).send;
|
|
4428
|
+
name('john');
|
|
4429
|
+
const promise = name('jin');
|
|
4430
|
+
$.$mol_after_mock_warp();
|
|
4431
|
+
await promise;
|
|
4432
|
+
$mol_assert_equal(NameLogger.first, ['john', 'jin']);
|
|
4433
|
+
$mol_assert_equal(NameLogger.last, ['jin']);
|
|
4434
|
+
},
|
|
4435
|
+
async 'Latest function calls wins'($) {
|
|
4436
|
+
const first = [];
|
|
4437
|
+
const last = [];
|
|
4438
|
+
function send_name(next) {
|
|
4439
|
+
$mol_wire_sync(first).push(next);
|
|
4440
|
+
$$.$mol_wait_timeout(0);
|
|
4441
|
+
last.push(next);
|
|
4442
|
+
}
|
|
4443
|
+
const name = $mol_wire_async(send_name);
|
|
4444
|
+
name('john');
|
|
4445
|
+
const promise = name('jin');
|
|
4446
|
+
$.$mol_after_mock_warp();
|
|
4447
|
+
await promise;
|
|
4448
|
+
$mol_assert_equal(first, ['john', 'jin']);
|
|
4449
|
+
$mol_assert_equal(last, ['jin']);
|
|
4450
|
+
},
|
|
4451
|
+
});
|
|
4452
|
+
})($ || ($ = {}));
|
|
4453
|
+
|
|
4454
|
+
;
|
|
4455
|
+
"use strict";
|
|
4456
|
+
var $;
|
|
4457
|
+
(function ($_1) {
|
|
4458
|
+
$mol_test({
|
|
4459
|
+
'test types'($) {
|
|
4460
|
+
class A {
|
|
4461
|
+
static a() {
|
|
4462
|
+
return Promise.resolve('');
|
|
4463
|
+
}
|
|
4464
|
+
static b() {
|
|
4465
|
+
return $mol_wire_sync(this).a();
|
|
4466
|
+
}
|
|
4467
|
+
}
|
|
4468
|
+
},
|
|
4469
|
+
async 'test method from host'($) {
|
|
4470
|
+
let count = 0;
|
|
4471
|
+
class A {
|
|
4472
|
+
static a() {
|
|
4473
|
+
return $mol_wire_sync(this).b();
|
|
4474
|
+
}
|
|
4475
|
+
static b() { return Promise.resolve(++count); }
|
|
4476
|
+
}
|
|
4477
|
+
$mol_assert_equal(await $mol_wire_async(A).a(), 1, count);
|
|
4478
|
+
},
|
|
4479
|
+
async 'test function'($) {
|
|
4480
|
+
let count = 0;
|
|
4481
|
+
class A {
|
|
4482
|
+
static a() {
|
|
4483
|
+
return $mol_wire_sync(this.b)();
|
|
4484
|
+
}
|
|
4485
|
+
static b() { return Promise.resolve(++count); }
|
|
4486
|
+
}
|
|
4487
|
+
$mol_assert_equal(await $mol_wire_async(A).a(), 1, count);
|
|
4488
|
+
},
|
|
4489
|
+
async 'test construct itself'($) {
|
|
4490
|
+
class A {
|
|
4491
|
+
static instances = [];
|
|
4492
|
+
static a() {
|
|
4493
|
+
const a = new ($mol_wire_sync(A))();
|
|
4494
|
+
this.instances.push(a);
|
|
4495
|
+
$mol_wire_sync(this).b();
|
|
4496
|
+
}
|
|
4497
|
+
static b() { return Promise.resolve(); }
|
|
4498
|
+
}
|
|
4499
|
+
await $mol_wire_async(A).a();
|
|
4500
|
+
$mol_assert_equal(A.instances.length, 2);
|
|
4501
|
+
$mol_assert_equal(A.instances[0] instanceof A, true);
|
|
4502
|
+
$mol_assert_equal(A.instances[0], A.instances[1]);
|
|
4503
|
+
}
|
|
4504
|
+
});
|
|
4505
|
+
})($ || ($ = {}));
|
|
4506
|
+
|
|
4507
|
+
;
|
|
4508
|
+
"use strict";
|
|
4509
|
+
var $;
|
|
4510
|
+
(function ($) {
|
|
4511
|
+
class $mol_after_work extends $mol_object2 {
|
|
4512
|
+
delay;
|
|
4513
|
+
task;
|
|
4514
|
+
id;
|
|
4515
|
+
constructor(delay, task) {
|
|
4516
|
+
super();
|
|
4517
|
+
this.delay = delay;
|
|
4518
|
+
this.task = task;
|
|
4519
|
+
this.id = requestIdleCallback(task, { timeout: delay });
|
|
4520
|
+
}
|
|
4762
4521
|
destructor() {
|
|
4763
4522
|
cancelIdleCallback(this.id);
|
|
4764
4523
|
}
|
|
@@ -4820,59 +4579,6 @@ var $;
|
|
|
4820
4579
|
})($$ = $_1.$$ || ($_1.$$ = {}));
|
|
4821
4580
|
})($ || ($ = {}));
|
|
4822
4581
|
|
|
4823
|
-
;
|
|
4824
|
-
"use strict";
|
|
4825
|
-
var $;
|
|
4826
|
-
(function ($_1) {
|
|
4827
|
-
$mol_test({
|
|
4828
|
-
'test types'($) {
|
|
4829
|
-
class A {
|
|
4830
|
-
static a() {
|
|
4831
|
-
return '';
|
|
4832
|
-
}
|
|
4833
|
-
static b() {
|
|
4834
|
-
return $mol_wire_async(this).a();
|
|
4835
|
-
}
|
|
4836
|
-
}
|
|
4837
|
-
},
|
|
4838
|
-
async 'Latest method calls wins'($) {
|
|
4839
|
-
class NameLogger extends $mol_object2 {
|
|
4840
|
-
static $ = $;
|
|
4841
|
-
static first = [];
|
|
4842
|
-
static last = [];
|
|
4843
|
-
static send(next) {
|
|
4844
|
-
$mol_wire_sync(this.first).push(next);
|
|
4845
|
-
$$.$mol_wait_timeout(0);
|
|
4846
|
-
this.last.push(next);
|
|
4847
|
-
}
|
|
4848
|
-
}
|
|
4849
|
-
const name = $mol_wire_async(NameLogger).send;
|
|
4850
|
-
name('john');
|
|
4851
|
-
const promise = name('jin');
|
|
4852
|
-
$.$mol_after_mock_warp();
|
|
4853
|
-
await promise;
|
|
4854
|
-
$mol_assert_equal(NameLogger.first, ['john', 'jin']);
|
|
4855
|
-
$mol_assert_equal(NameLogger.last, ['jin']);
|
|
4856
|
-
},
|
|
4857
|
-
async 'Latest function calls wins'($) {
|
|
4858
|
-
const first = [];
|
|
4859
|
-
const last = [];
|
|
4860
|
-
function send_name(next) {
|
|
4861
|
-
$mol_wire_sync(first).push(next);
|
|
4862
|
-
$$.$mol_wait_timeout(0);
|
|
4863
|
-
last.push(next);
|
|
4864
|
-
}
|
|
4865
|
-
const name = $mol_wire_async(send_name);
|
|
4866
|
-
name('john');
|
|
4867
|
-
const promise = name('jin');
|
|
4868
|
-
$.$mol_after_mock_warp();
|
|
4869
|
-
await promise;
|
|
4870
|
-
$mol_assert_equal(first, ['john', 'jin']);
|
|
4871
|
-
$mol_assert_equal(last, ['jin']);
|
|
4872
|
-
},
|
|
4873
|
-
});
|
|
4874
|
-
})($ || ($ = {}));
|
|
4875
|
-
|
|
4876
4582
|
;
|
|
4877
4583
|
"use strict";
|
|
4878
4584
|
var $;
|
|
@@ -5537,6 +5243,32 @@ var $;
|
|
|
5537
5243
|
});
|
|
5538
5244
|
})($ || ($ = {}));
|
|
5539
5245
|
|
|
5246
|
+
;
|
|
5247
|
+
"use strict";
|
|
5248
|
+
var $;
|
|
5249
|
+
(function ($_1) {
|
|
5250
|
+
$mol_test({
|
|
5251
|
+
'init with overload'() {
|
|
5252
|
+
class X extends $mol_object {
|
|
5253
|
+
foo() {
|
|
5254
|
+
return 1;
|
|
5255
|
+
}
|
|
5256
|
+
}
|
|
5257
|
+
var x = X.make({
|
|
5258
|
+
foo: () => 2,
|
|
5259
|
+
});
|
|
5260
|
+
$mol_assert_equal(x.foo(), 2);
|
|
5261
|
+
},
|
|
5262
|
+
'Context in instance inherits from class'($) {
|
|
5263
|
+
const custom = $.$mol_ambient({});
|
|
5264
|
+
class X extends $.$mol_object {
|
|
5265
|
+
static $ = custom;
|
|
5266
|
+
}
|
|
5267
|
+
$mol_assert_equal(new X().$, custom);
|
|
5268
|
+
},
|
|
5269
|
+
});
|
|
5270
|
+
})($ || ($ = {}));
|
|
5271
|
+
|
|
5540
5272
|
;
|
|
5541
5273
|
"use strict";
|
|
5542
5274
|
|
|
@@ -5865,5 +5597,290 @@ var $;
|
|
|
5865
5597
|
});
|
|
5866
5598
|
})($ || ($ = {}));
|
|
5867
5599
|
|
|
5600
|
+
;
|
|
5601
|
+
"use strict";
|
|
5602
|
+
var $;
|
|
5603
|
+
(function ($) {
|
|
5604
|
+
function cause_serialize(cause) {
|
|
5605
|
+
return JSON.stringify(cause, null, ' ')
|
|
5606
|
+
.replace(/\(/, '<')
|
|
5607
|
+
.replace(/\)/, ' >');
|
|
5608
|
+
}
|
|
5609
|
+
function frame_normalize(frame) {
|
|
5610
|
+
return (typeof frame === 'string' ? frame : cause_serialize(frame))
|
|
5611
|
+
.trim()
|
|
5612
|
+
.replace(/at /gm, ' at ')
|
|
5613
|
+
.replace(/^(?! +at )(.*)/gm, ' at | $1 (#)');
|
|
5614
|
+
}
|
|
5615
|
+
class $mol_error_mix extends AggregateError {
|
|
5616
|
+
cause;
|
|
5617
|
+
name = $$.$mol_func_name(this.constructor).replace(/^\$/, '') + '_Error';
|
|
5618
|
+
constructor(message, cause = {}, ...errors) {
|
|
5619
|
+
super(errors, message, { cause });
|
|
5620
|
+
this.cause = cause;
|
|
5621
|
+
const desc = Object.getOwnPropertyDescriptor(this, 'stack');
|
|
5622
|
+
const stack_get = () => desc?.get?.() ?? super.stack ?? desc?.value ?? this.message;
|
|
5623
|
+
Object.defineProperty(this, 'stack', {
|
|
5624
|
+
get: () => stack_get() + '\n' + [
|
|
5625
|
+
this.cause ?? 'no cause',
|
|
5626
|
+
...this.errors.flatMap(e => [
|
|
5627
|
+
String(e.stack),
|
|
5628
|
+
...e instanceof $mol_error_mix || !e.cause ? [] : [e.cause]
|
|
5629
|
+
])
|
|
5630
|
+
].map(frame_normalize).join('\n')
|
|
5631
|
+
});
|
|
5632
|
+
Object.defineProperty(this, 'cause', {
|
|
5633
|
+
get: () => cause
|
|
5634
|
+
});
|
|
5635
|
+
}
|
|
5636
|
+
static [Symbol.toPrimitive]() {
|
|
5637
|
+
return this.toString();
|
|
5638
|
+
}
|
|
5639
|
+
static toString() {
|
|
5640
|
+
return $$.$mol_func_name(this);
|
|
5641
|
+
}
|
|
5642
|
+
static make(...params) {
|
|
5643
|
+
return new this(...params);
|
|
5644
|
+
}
|
|
5645
|
+
}
|
|
5646
|
+
$.$mol_error_mix = $mol_error_mix;
|
|
5647
|
+
})($ || ($ = {}));
|
|
5648
|
+
|
|
5649
|
+
;
|
|
5650
|
+
"use strict";
|
|
5651
|
+
var $;
|
|
5652
|
+
(function ($) {
|
|
5653
|
+
$mol_test({
|
|
5654
|
+
'auto name'() {
|
|
5655
|
+
class Invalid extends $mol_error_mix {
|
|
5656
|
+
}
|
|
5657
|
+
const mix = new Invalid('foo');
|
|
5658
|
+
$mol_assert_equal(mix.name, 'Invalid_Error');
|
|
5659
|
+
},
|
|
5660
|
+
'simpe mix'() {
|
|
5661
|
+
const mix = new $mol_error_mix('foo', {}, new Error('bar'), new Error('lol'));
|
|
5662
|
+
$mol_assert_equal(mix.message, 'foo');
|
|
5663
|
+
$mol_assert_equal(mix.errors.map(e => e.message), ['bar', 'lol']);
|
|
5664
|
+
},
|
|
5665
|
+
'provide additional info'() {
|
|
5666
|
+
class Invalid extends $mol_error_mix {
|
|
5667
|
+
}
|
|
5668
|
+
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' }));
|
|
5669
|
+
const hints = [];
|
|
5670
|
+
if (mix instanceof $mol_error_mix) {
|
|
5671
|
+
for (const er of mix.errors) {
|
|
5672
|
+
if (er instanceof Invalid) {
|
|
5673
|
+
hints.push(er.cause?.hint ?? '');
|
|
5674
|
+
}
|
|
5675
|
+
}
|
|
5676
|
+
}
|
|
5677
|
+
$mol_assert_equal(hints, ['> 8 letters', 'need capital letter']);
|
|
5678
|
+
},
|
|
5679
|
+
});
|
|
5680
|
+
})($ || ($ = {}));
|
|
5681
|
+
|
|
5682
|
+
;
|
|
5683
|
+
"use strict";
|
|
5684
|
+
var $;
|
|
5685
|
+
(function ($) {
|
|
5686
|
+
function $mol_env() {
|
|
5687
|
+
return {};
|
|
5688
|
+
}
|
|
5689
|
+
$.$mol_env = $mol_env;
|
|
5690
|
+
})($ || ($ = {}));
|
|
5691
|
+
|
|
5692
|
+
;
|
|
5693
|
+
"use strict";
|
|
5694
|
+
var $;
|
|
5695
|
+
(function ($) {
|
|
5696
|
+
$.$mol_env = function $mol_env() {
|
|
5697
|
+
return this.process.env;
|
|
5698
|
+
};
|
|
5699
|
+
})($ || ($ = {}));
|
|
5700
|
+
|
|
5701
|
+
;
|
|
5702
|
+
"use strict";
|
|
5703
|
+
var $;
|
|
5704
|
+
(function ($) {
|
|
5705
|
+
class $mol_run_error extends $mol_error_mix {
|
|
5706
|
+
}
|
|
5707
|
+
$.$mol_run_error = $mol_run_error;
|
|
5708
|
+
$.$mol_run_spawn = (...args) => $node['child_process'].spawn(...args);
|
|
5709
|
+
$.$mol_run_spawn_sync = (...args) => $node['child_process'].spawnSync(...args);
|
|
5710
|
+
class $mol_run extends $mol_object {
|
|
5711
|
+
static async_enabled() {
|
|
5712
|
+
return Boolean(this.$.$mol_env()['MOL_RUN_ASYNC']);
|
|
5713
|
+
}
|
|
5714
|
+
static spawn(options) {
|
|
5715
|
+
const sync = !this.async_enabled() || !Boolean($mol_wire_auto());
|
|
5716
|
+
const env = options.env ?? this.$.$mol_env();
|
|
5717
|
+
return $mol_wire_sync(this).spawn_async({ ...options, sync, env });
|
|
5718
|
+
}
|
|
5719
|
+
static spawn_async({ dir, sync, timeout, command, env }) {
|
|
5720
|
+
const args_raw = typeof command === 'string' ? command.split(' ') : command;
|
|
5721
|
+
const [app, ...args] = args_raw;
|
|
5722
|
+
const opts = { shell: true, cwd: dir, env };
|
|
5723
|
+
const log_object = {
|
|
5724
|
+
place: `${this}.spawn()`,
|
|
5725
|
+
message: 'Run',
|
|
5726
|
+
command: args_raw.join(' '),
|
|
5727
|
+
dir: $node.path.relative('', dir),
|
|
5728
|
+
};
|
|
5729
|
+
if (sync) {
|
|
5730
|
+
this.$.$mol_log3_come({
|
|
5731
|
+
hint: 'Run inside fiber',
|
|
5732
|
+
...log_object
|
|
5733
|
+
});
|
|
5734
|
+
let error;
|
|
5735
|
+
let res;
|
|
5736
|
+
try {
|
|
5737
|
+
res = this.$.$mol_run_spawn_sync(app, args, opts);
|
|
5738
|
+
error = res.error;
|
|
5739
|
+
}
|
|
5740
|
+
catch (err) {
|
|
5741
|
+
error = err;
|
|
5742
|
+
}
|
|
5743
|
+
if (!res || error || res.status) {
|
|
5744
|
+
throw new $mol_run_error(this.error_message(res), { ...log_object, status: res?.status, signal: res?.signal }, ...(error ? [error] : []));
|
|
5745
|
+
}
|
|
5746
|
+
return res;
|
|
5747
|
+
}
|
|
5748
|
+
let sub;
|
|
5749
|
+
try {
|
|
5750
|
+
sub = this.$.$mol_run_spawn(app, args, {
|
|
5751
|
+
...opts,
|
|
5752
|
+
stdio: ['pipe', 'inherit', 'inherit'],
|
|
5753
|
+
});
|
|
5754
|
+
}
|
|
5755
|
+
catch (error) {
|
|
5756
|
+
throw new $mol_run_error(this.error_message(undefined), log_object, error);
|
|
5757
|
+
}
|
|
5758
|
+
const pid = sub.pid ?? 0;
|
|
5759
|
+
this.$.$mol_log3_come({
|
|
5760
|
+
...log_object,
|
|
5761
|
+
pid,
|
|
5762
|
+
});
|
|
5763
|
+
let timeout_kill = false;
|
|
5764
|
+
let timer;
|
|
5765
|
+
const std_data = [];
|
|
5766
|
+
const error_data = [];
|
|
5767
|
+
const add = (std_chunk, error_chunk) => {
|
|
5768
|
+
if (std_chunk)
|
|
5769
|
+
std_data.push(std_chunk);
|
|
5770
|
+
if (error_chunk)
|
|
5771
|
+
error_data.push(error_chunk);
|
|
5772
|
+
if (!timeout)
|
|
5773
|
+
return;
|
|
5774
|
+
clearTimeout(timer);
|
|
5775
|
+
timer = setTimeout(() => {
|
|
5776
|
+
const signal = timeout_kill ? 'SIGKILL' : 'SIGTERM';
|
|
5777
|
+
timeout_kill = true;
|
|
5778
|
+
add();
|
|
5779
|
+
sub.kill(signal);
|
|
5780
|
+
}, timeout);
|
|
5781
|
+
};
|
|
5782
|
+
add();
|
|
5783
|
+
sub.stdout?.on('data', data => add(data));
|
|
5784
|
+
sub.stderr?.on('data', data => add(undefined, data));
|
|
5785
|
+
const result_promise = new Promise((done, fail) => {
|
|
5786
|
+
const close = (error, status = null, signal = null) => {
|
|
5787
|
+
if (!timer && timeout)
|
|
5788
|
+
return;
|
|
5789
|
+
clearTimeout(timer);
|
|
5790
|
+
timer = undefined;
|
|
5791
|
+
const res = {
|
|
5792
|
+
pid,
|
|
5793
|
+
signal,
|
|
5794
|
+
get stdout() { return Buffer.concat(std_data); },
|
|
5795
|
+
get stderr() { return Buffer.concat(error_data); }
|
|
5796
|
+
};
|
|
5797
|
+
if (error || status || timeout_kill)
|
|
5798
|
+
return fail(new $mol_run_error(this.error_message(res) + (timeout_kill ? ', timeout' : ''), { ...log_object, pid, status, signal, timeout_kill }, ...error ? [error] : []));
|
|
5799
|
+
this.$.$mol_log3_done({
|
|
5800
|
+
...log_object,
|
|
5801
|
+
pid,
|
|
5802
|
+
});
|
|
5803
|
+
done(res);
|
|
5804
|
+
};
|
|
5805
|
+
sub.on('disconnect', () => close(new Error('Disconnected')));
|
|
5806
|
+
sub.on('error', err => close(err));
|
|
5807
|
+
sub.on('exit', (status, signal) => close(null, status, signal));
|
|
5808
|
+
});
|
|
5809
|
+
return Object.assign(result_promise, { destructor: () => {
|
|
5810
|
+
clearTimeout(timer);
|
|
5811
|
+
sub.kill('SIGKILL');
|
|
5812
|
+
} });
|
|
5813
|
+
}
|
|
5814
|
+
static error_message(res) {
|
|
5815
|
+
return res?.stderr.toString() || res?.stdout.toString() || 'Run error';
|
|
5816
|
+
}
|
|
5817
|
+
}
|
|
5818
|
+
$.$mol_run = $mol_run;
|
|
5819
|
+
})($ || ($ = {}));
|
|
5820
|
+
|
|
5821
|
+
;
|
|
5822
|
+
"use strict";
|
|
5823
|
+
var $;
|
|
5824
|
+
(function ($_1) {
|
|
5825
|
+
$mol_test({
|
|
5826
|
+
async 'exec timeout auto kill child process'($) {
|
|
5827
|
+
let close_mock = () => { };
|
|
5828
|
+
const error_message = 'Run error, timeout';
|
|
5829
|
+
function mol_run_spawn_sync_mock() {
|
|
5830
|
+
return {
|
|
5831
|
+
output: [],
|
|
5832
|
+
stdout: error_message,
|
|
5833
|
+
stderr: '',
|
|
5834
|
+
status: 0,
|
|
5835
|
+
signal: null,
|
|
5836
|
+
pid: 123,
|
|
5837
|
+
};
|
|
5838
|
+
}
|
|
5839
|
+
function mol_run_spawn_mock() {
|
|
5840
|
+
return {
|
|
5841
|
+
on(name, cb) {
|
|
5842
|
+
if (name === 'exit')
|
|
5843
|
+
close_mock = cb;
|
|
5844
|
+
},
|
|
5845
|
+
kill() { close_mock(); }
|
|
5846
|
+
};
|
|
5847
|
+
}
|
|
5848
|
+
const context_mock = $.$mol_ambient({
|
|
5849
|
+
$mol_run_spawn_sync: mol_run_spawn_sync_mock,
|
|
5850
|
+
$mol_run_spawn: mol_run_spawn_mock
|
|
5851
|
+
});
|
|
5852
|
+
class $mol_run_mock extends $mol_run {
|
|
5853
|
+
static get $() { return context_mock; }
|
|
5854
|
+
static async_enabled() {
|
|
5855
|
+
return true;
|
|
5856
|
+
}
|
|
5857
|
+
}
|
|
5858
|
+
let message = '';
|
|
5859
|
+
try {
|
|
5860
|
+
const res = await $mol_wire_async($mol_run_mock).spawn({
|
|
5861
|
+
command: 'sleep 10',
|
|
5862
|
+
dir: '.',
|
|
5863
|
+
timeout: 10,
|
|
5864
|
+
env: { 'MOL_RUN_ASYNC': '1' }
|
|
5865
|
+
});
|
|
5866
|
+
}
|
|
5867
|
+
catch (e) {
|
|
5868
|
+
message = e.message;
|
|
5869
|
+
}
|
|
5870
|
+
$mol_assert_equal(message, error_message);
|
|
5871
|
+
}
|
|
5872
|
+
});
|
|
5873
|
+
})($ || ($ = {}));
|
|
5874
|
+
|
|
5875
|
+
;
|
|
5876
|
+
"use strict";
|
|
5877
|
+
var $;
|
|
5878
|
+
(function ($) {
|
|
5879
|
+
function $mol_exec(dir, command, ...args) {
|
|
5880
|
+
return this.$mol_run.spawn({ command: [command, ...args], dir });
|
|
5881
|
+
}
|
|
5882
|
+
$.$mol_exec = $mol_exec;
|
|
5883
|
+
})($ || ($ = {}));
|
|
5884
|
+
|
|
5868
5885
|
|
|
5869
5886
|
//# sourceMappingURL=node.test.js.map
|