mam 1.11.795 → 1.11.797
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 +35 -14
- package/node.js.map +1 -1
- package/node.mjs +35 -14
- package/node.test.js +321 -300
- package/node.test.js.map +1 -1
- package/package.json +4 -2
package/node.test.js
CHANGED
|
@@ -2410,45 +2410,64 @@ var $;
|
|
|
2410
2410
|
;
|
|
2411
2411
|
"use strict";
|
|
2412
2412
|
|
|
2413
|
+
;
|
|
2414
|
+
"use strict";
|
|
2415
|
+
var $;
|
|
2416
|
+
(function ($) {
|
|
2417
|
+
const mod = require('module');
|
|
2418
|
+
const internals = mod.builtinModules;
|
|
2419
|
+
function $node_internal_check(name) {
|
|
2420
|
+
if (name.startsWith('node:'))
|
|
2421
|
+
return true;
|
|
2422
|
+
return internals.includes(name);
|
|
2423
|
+
}
|
|
2424
|
+
$.$node_internal_check = $node_internal_check;
|
|
2425
|
+
})($ || ($ = {}));
|
|
2426
|
+
|
|
2413
2427
|
;
|
|
2414
2428
|
"use strict";
|
|
2415
2429
|
var $node = new Proxy({ require }, {
|
|
2416
2430
|
get(target, name, wrapper) {
|
|
2417
2431
|
if (target[name])
|
|
2418
2432
|
return target[name];
|
|
2419
|
-
|
|
2433
|
+
const $$ = $;
|
|
2434
|
+
if ($$.$node_internal_check(name, target))
|
|
2420
2435
|
return target.require(name);
|
|
2421
2436
|
if (name[0] === '.')
|
|
2422
2437
|
return target.require(name);
|
|
2423
|
-
const mod = target.require('module');
|
|
2424
|
-
if (mod.builtinModules.indexOf(name) >= 0)
|
|
2425
|
-
return target.require(name);
|
|
2426
2438
|
try {
|
|
2427
2439
|
target.require.resolve(name);
|
|
2428
2440
|
}
|
|
2429
2441
|
catch {
|
|
2430
|
-
|
|
2431
|
-
|
|
2442
|
+
try {
|
|
2443
|
+
$$.$mol_exec('.', 'npm', 'install', '--omit=dev', name);
|
|
2444
|
+
}
|
|
2445
|
+
catch (e) {
|
|
2446
|
+
if ($$.$mol_promise_like(e))
|
|
2447
|
+
$$.$mol_fail_hidden(e);
|
|
2448
|
+
}
|
|
2432
2449
|
try {
|
|
2433
2450
|
$$.$mol_exec('.', 'npm', 'install', '--omit=dev', '@types/' + name);
|
|
2434
2451
|
}
|
|
2435
2452
|
catch (e) {
|
|
2436
|
-
if ($$.$
|
|
2437
|
-
$$.$
|
|
2438
|
-
|
|
2453
|
+
if ($$.$mol_promise_like(e))
|
|
2454
|
+
$$.$mol_fail_hidden(e);
|
|
2455
|
+
$$.$mol_fail_log(e);
|
|
2439
2456
|
}
|
|
2440
2457
|
}
|
|
2441
2458
|
try {
|
|
2442
2459
|
return target.require(name);
|
|
2443
2460
|
}
|
|
2444
2461
|
catch (error) {
|
|
2445
|
-
if (
|
|
2462
|
+
if ($$.$mol_promise_like(error))
|
|
2463
|
+
$$.$mol_fail_hidden(error);
|
|
2464
|
+
if (error && typeof error === 'object' && error.code === 'ERR_REQUIRE_ESM') {
|
|
2446
2465
|
const module = cache.get(name);
|
|
2447
2466
|
if (module)
|
|
2448
2467
|
return module;
|
|
2449
2468
|
throw Object.assign(import(name).then(module => cache.set(name, module)), { cause: error });
|
|
2450
2469
|
}
|
|
2451
|
-
|
|
2470
|
+
$$.$mol_fail_log(error);
|
|
2452
2471
|
return null;
|
|
2453
2472
|
}
|
|
2454
2473
|
},
|
|
@@ -6216,7 +6235,7 @@ var $;
|
|
|
6216
6235
|
types.push('\t' + JSON.stringify(dep) + ' : typeof import\( ' + JSON.stringify(dep) + ' ) // ' + src);
|
|
6217
6236
|
}
|
|
6218
6237
|
const node_types = $mol_file.absolute(path).resolve(`-node/deps.d.ts`);
|
|
6219
|
-
node_types.text('
|
|
6238
|
+
node_types.text('// @ts-nocheck\ninterface $node {\n ' + types.join('\n') + '\n}');
|
|
6220
6239
|
sources.push(node_types);
|
|
6221
6240
|
}
|
|
6222
6241
|
return sources.map(src => src.path());
|
|
@@ -6866,7 +6885,7 @@ var $;
|
|
|
6866
6885
|
++version[2];
|
|
6867
6886
|
json.version = version.join('.');
|
|
6868
6887
|
for (let dep of this.nodeDeps([path, exclude]).keys()) {
|
|
6869
|
-
if (
|
|
6888
|
+
if ($node_internal_check(dep))
|
|
6870
6889
|
continue;
|
|
6871
6890
|
json.dependencies[dep] ??= `*`;
|
|
6872
6891
|
}
|
|
@@ -7249,6 +7268,8 @@ var $;
|
|
|
7249
7268
|
var indent = /^([\s\t]*)/.exec(line);
|
|
7250
7269
|
var priority = -indent[0].replace(/\t/g, ' ').length / 4;
|
|
7251
7270
|
line.replace(/\b(?:require|import)\(\s*['"]([^"'()]*?)['"]\s*\)/ig, (str, path) => {
|
|
7271
|
+
if ($node_internal_check(path))
|
|
7272
|
+
return str;
|
|
7252
7273
|
path = path.replace(/(\/[^\/.]+)$/, '$1.js').replace(/\/$/, '/index.js');
|
|
7253
7274
|
if (path[0] === '.')
|
|
7254
7275
|
path = '../' + path;
|
|
@@ -7277,7 +7298,7 @@ var $;
|
|
|
7277
7298
|
return str;
|
|
7278
7299
|
});
|
|
7279
7300
|
line.replace(/\b(?:require|import)\(\s*['"]([^"'()]*?)['"]\s*\)/ig, (str, path) => {
|
|
7280
|
-
if (path
|
|
7301
|
+
if ($node_internal_check(path))
|
|
7281
7302
|
return str;
|
|
7282
7303
|
$mol_build_depsMerge(depends, { [path]: priority });
|
|
7283
7304
|
return str;
|
|
@@ -7975,215 +7996,6 @@ var $;
|
|
|
7975
7996
|
$mol_test_mocks.push($ => $.$mol_fail_log = () => false);
|
|
7976
7997
|
})($ || ($ = {}));
|
|
7977
7998
|
|
|
7978
|
-
;
|
|
7979
|
-
"use strict";
|
|
7980
|
-
var $;
|
|
7981
|
-
(function ($_1) {
|
|
7982
|
-
$mol_test({
|
|
7983
|
-
'FQN of anon function'($) {
|
|
7984
|
-
const $$ = Object.assign($, { $mol_func_name_test: (() => () => { })() });
|
|
7985
|
-
$mol_assert_equal($$.$mol_func_name_test.name, '');
|
|
7986
|
-
$mol_assert_equal($$.$mol_func_name($$.$mol_func_name_test), '$mol_func_name_test');
|
|
7987
|
-
$mol_assert_equal($$.$mol_func_name_test.name, '$mol_func_name_test');
|
|
7988
|
-
},
|
|
7989
|
-
});
|
|
7990
|
-
})($ || ($ = {}));
|
|
7991
|
-
|
|
7992
|
-
;
|
|
7993
|
-
"use strict";
|
|
7994
|
-
var $;
|
|
7995
|
-
(function ($) {
|
|
7996
|
-
$mol_test({
|
|
7997
|
-
'auto name'() {
|
|
7998
|
-
class Invalid extends $mol_error_mix {
|
|
7999
|
-
}
|
|
8000
|
-
const mix = new Invalid('foo');
|
|
8001
|
-
$mol_assert_equal(mix.name, 'Invalid_Error');
|
|
8002
|
-
},
|
|
8003
|
-
'simpe mix'() {
|
|
8004
|
-
const mix = new $mol_error_mix('foo', {}, new Error('bar'), new Error('lol'));
|
|
8005
|
-
$mol_assert_equal(mix.message, 'foo');
|
|
8006
|
-
$mol_assert_equal(mix.errors.map(e => e.message), ['bar', 'lol']);
|
|
8007
|
-
},
|
|
8008
|
-
'provide additional info'() {
|
|
8009
|
-
class Invalid extends $mol_error_mix {
|
|
8010
|
-
}
|
|
8011
|
-
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' }));
|
|
8012
|
-
const hints = [];
|
|
8013
|
-
if (mix instanceof $mol_error_mix) {
|
|
8014
|
-
for (const er of mix.errors) {
|
|
8015
|
-
if (er instanceof Invalid) {
|
|
8016
|
-
hints.push(er.cause?.hint ?? '');
|
|
8017
|
-
}
|
|
8018
|
-
}
|
|
8019
|
-
}
|
|
8020
|
-
$mol_assert_equal(hints, ['> 8 letters', 'need capital letter']);
|
|
8021
|
-
},
|
|
8022
|
-
});
|
|
8023
|
-
})($ || ($ = {}));
|
|
8024
|
-
|
|
8025
|
-
;
|
|
8026
|
-
"use strict";
|
|
8027
|
-
|
|
8028
|
-
;
|
|
8029
|
-
"use strict";
|
|
8030
|
-
|
|
8031
|
-
;
|
|
8032
|
-
"use strict";
|
|
8033
|
-
|
|
8034
|
-
;
|
|
8035
|
-
"use strict";
|
|
8036
|
-
|
|
8037
|
-
;
|
|
8038
|
-
"use strict";
|
|
8039
|
-
|
|
8040
|
-
;
|
|
8041
|
-
"use strict";
|
|
8042
|
-
var $;
|
|
8043
|
-
(function ($_1) {
|
|
8044
|
-
$mol_test({
|
|
8045
|
-
'init with overload'() {
|
|
8046
|
-
class X extends $mol_object {
|
|
8047
|
-
foo() {
|
|
8048
|
-
return 1;
|
|
8049
|
-
}
|
|
8050
|
-
}
|
|
8051
|
-
var x = X.make({
|
|
8052
|
-
foo: () => 2,
|
|
8053
|
-
});
|
|
8054
|
-
$mol_assert_equal(x.foo(), 2);
|
|
8055
|
-
},
|
|
8056
|
-
'Context in instance inherits from class'($) {
|
|
8057
|
-
const custom = $.$mol_ambient({});
|
|
8058
|
-
class X extends $.$mol_object {
|
|
8059
|
-
static $ = custom;
|
|
8060
|
-
}
|
|
8061
|
-
$mol_assert_equal(new X().$, custom);
|
|
8062
|
-
},
|
|
8063
|
-
});
|
|
8064
|
-
})($ || ($ = {}));
|
|
8065
|
-
|
|
8066
|
-
;
|
|
8067
|
-
"use strict";
|
|
8068
|
-
var $;
|
|
8069
|
-
(function ($_1) {
|
|
8070
|
-
$mol_test({
|
|
8071
|
-
'test types'($) {
|
|
8072
|
-
class A {
|
|
8073
|
-
static a() {
|
|
8074
|
-
return Promise.resolve('');
|
|
8075
|
-
}
|
|
8076
|
-
static b() {
|
|
8077
|
-
return $mol_wire_sync(this).a();
|
|
8078
|
-
}
|
|
8079
|
-
}
|
|
8080
|
-
},
|
|
8081
|
-
async 'test method from host'($) {
|
|
8082
|
-
let count = 0;
|
|
8083
|
-
class A {
|
|
8084
|
-
static a() {
|
|
8085
|
-
return $mol_wire_sync(this).b();
|
|
8086
|
-
}
|
|
8087
|
-
static b() { return Promise.resolve(++count); }
|
|
8088
|
-
}
|
|
8089
|
-
$mol_assert_equal(await $mol_wire_async(A).a(), 1, count);
|
|
8090
|
-
},
|
|
8091
|
-
async 'test function'($) {
|
|
8092
|
-
let count = 0;
|
|
8093
|
-
class A {
|
|
8094
|
-
static a() {
|
|
8095
|
-
return $mol_wire_sync(this.b)();
|
|
8096
|
-
}
|
|
8097
|
-
static b() { return Promise.resolve(++count); }
|
|
8098
|
-
}
|
|
8099
|
-
$mol_assert_equal(await $mol_wire_async(A).a(), 1, count);
|
|
8100
|
-
},
|
|
8101
|
-
async 'test construct itself'($) {
|
|
8102
|
-
class A {
|
|
8103
|
-
static instances = [];
|
|
8104
|
-
static a() {
|
|
8105
|
-
const a = new ($mol_wire_sync(A))();
|
|
8106
|
-
this.instances.push(a);
|
|
8107
|
-
$mol_wire_sync(this).b();
|
|
8108
|
-
}
|
|
8109
|
-
static b() { return Promise.resolve(); }
|
|
8110
|
-
}
|
|
8111
|
-
await $mol_wire_async(A).a();
|
|
8112
|
-
$mol_assert_equal(A.instances.length, 2);
|
|
8113
|
-
$mol_assert_equal(A.instances[0] instanceof A, true);
|
|
8114
|
-
$mol_assert_equal(A.instances[0], A.instances[1]);
|
|
8115
|
-
}
|
|
8116
|
-
});
|
|
8117
|
-
})($ || ($ = {}));
|
|
8118
|
-
|
|
8119
|
-
;
|
|
8120
|
-
"use strict";
|
|
8121
|
-
var $;
|
|
8122
|
-
(function ($_1) {
|
|
8123
|
-
$mol_test_mocks.push($ => {
|
|
8124
|
-
$.$mol_log3_come = () => { };
|
|
8125
|
-
$.$mol_log3_done = () => { };
|
|
8126
|
-
$.$mol_log3_fail = () => { };
|
|
8127
|
-
$.$mol_log3_warn = () => { };
|
|
8128
|
-
$.$mol_log3_rise = () => { };
|
|
8129
|
-
$.$mol_log3_area = () => () => { };
|
|
8130
|
-
});
|
|
8131
|
-
})($ || ($ = {}));
|
|
8132
|
-
|
|
8133
|
-
;
|
|
8134
|
-
"use strict";
|
|
8135
|
-
var $;
|
|
8136
|
-
(function ($_1) {
|
|
8137
|
-
$mol_test({
|
|
8138
|
-
async 'exec timeout auto kill child process'($) {
|
|
8139
|
-
let close_mock = () => { };
|
|
8140
|
-
const error_message = 'Run error, timeout';
|
|
8141
|
-
function mol_run_spawn_sync_mock() {
|
|
8142
|
-
return {
|
|
8143
|
-
output: [],
|
|
8144
|
-
stdout: error_message,
|
|
8145
|
-
stderr: '',
|
|
8146
|
-
status: 0,
|
|
8147
|
-
signal: null,
|
|
8148
|
-
pid: 123,
|
|
8149
|
-
};
|
|
8150
|
-
}
|
|
8151
|
-
function mol_run_spawn_mock() {
|
|
8152
|
-
return {
|
|
8153
|
-
on(name, cb) {
|
|
8154
|
-
if (name === 'exit')
|
|
8155
|
-
close_mock = cb;
|
|
8156
|
-
},
|
|
8157
|
-
kill() { close_mock(); }
|
|
8158
|
-
};
|
|
8159
|
-
}
|
|
8160
|
-
const context_mock = $.$mol_ambient({
|
|
8161
|
-
$mol_run_spawn_sync: mol_run_spawn_sync_mock,
|
|
8162
|
-
$mol_run_spawn: mol_run_spawn_mock
|
|
8163
|
-
});
|
|
8164
|
-
class $mol_run_mock extends $mol_run {
|
|
8165
|
-
static get $() { return context_mock; }
|
|
8166
|
-
static async_enabled() {
|
|
8167
|
-
return true;
|
|
8168
|
-
}
|
|
8169
|
-
}
|
|
8170
|
-
let message = '';
|
|
8171
|
-
try {
|
|
8172
|
-
const res = await $mol_wire_async($mol_run_mock).spawn({
|
|
8173
|
-
command: 'sleep 10',
|
|
8174
|
-
dir: '.',
|
|
8175
|
-
timeout: 10,
|
|
8176
|
-
env: { 'MOL_RUN_ASYNC': '1' }
|
|
8177
|
-
});
|
|
8178
|
-
}
|
|
8179
|
-
catch (e) {
|
|
8180
|
-
message = e.message;
|
|
8181
|
-
}
|
|
8182
|
-
$mol_assert_equal(message, error_message);
|
|
8183
|
-
}
|
|
8184
|
-
});
|
|
8185
|
-
})($ || ($ = {}));
|
|
8186
|
-
|
|
8187
7999
|
;
|
|
8188
8000
|
"use strict";
|
|
8189
8001
|
var $;
|
|
@@ -8245,6 +8057,15 @@ var $;
|
|
|
8245
8057
|
;
|
|
8246
8058
|
"use strict";
|
|
8247
8059
|
|
|
8060
|
+
;
|
|
8061
|
+
"use strict";
|
|
8062
|
+
|
|
8063
|
+
;
|
|
8064
|
+
"use strict";
|
|
8065
|
+
|
|
8066
|
+
;
|
|
8067
|
+
"use strict";
|
|
8068
|
+
|
|
8248
8069
|
;
|
|
8249
8070
|
"use strict";
|
|
8250
8071
|
var $;
|
|
@@ -9003,27 +8824,61 @@ var $;
|
|
|
9003
8824
|
;
|
|
9004
8825
|
"use strict";
|
|
9005
8826
|
var $;
|
|
9006
|
-
(function ($) {
|
|
9007
|
-
$
|
|
9008
|
-
|
|
9009
|
-
|
|
9010
|
-
|
|
9011
|
-
}
|
|
9012
|
-
|
|
9013
|
-
|
|
9014
|
-
|
|
9015
|
-
|
|
9016
|
-
|
|
9017
|
-
|
|
9018
|
-
|
|
9019
|
-
|
|
9020
|
-
|
|
9021
|
-
|
|
9022
|
-
|
|
9023
|
-
|
|
9024
|
-
|
|
9025
|
-
|
|
9026
|
-
|
|
8827
|
+
(function ($_1) {
|
|
8828
|
+
$mol_test_mocks.push($ => {
|
|
8829
|
+
$.$mol_log3_come = () => { };
|
|
8830
|
+
$.$mol_log3_done = () => { };
|
|
8831
|
+
$.$mol_log3_fail = () => { };
|
|
8832
|
+
$.$mol_log3_warn = () => { };
|
|
8833
|
+
$.$mol_log3_rise = () => { };
|
|
8834
|
+
$.$mol_log3_area = () => () => { };
|
|
8835
|
+
});
|
|
8836
|
+
})($ || ($ = {}));
|
|
8837
|
+
|
|
8838
|
+
;
|
|
8839
|
+
"use strict";
|
|
8840
|
+
|
|
8841
|
+
;
|
|
8842
|
+
"use strict";
|
|
8843
|
+
|
|
8844
|
+
;
|
|
8845
|
+
"use strict";
|
|
8846
|
+
var $;
|
|
8847
|
+
(function ($_1) {
|
|
8848
|
+
$mol_test({
|
|
8849
|
+
'FQN of anon function'($) {
|
|
8850
|
+
const $$ = Object.assign($, { $mol_func_name_test: (() => () => { })() });
|
|
8851
|
+
$mol_assert_equal($$.$mol_func_name_test.name, '');
|
|
8852
|
+
$mol_assert_equal($$.$mol_func_name($$.$mol_func_name_test), '$mol_func_name_test');
|
|
8853
|
+
$mol_assert_equal($$.$mol_func_name_test.name, '$mol_func_name_test');
|
|
8854
|
+
},
|
|
8855
|
+
});
|
|
8856
|
+
})($ || ($ = {}));
|
|
8857
|
+
|
|
8858
|
+
;
|
|
8859
|
+
"use strict";
|
|
8860
|
+
var $;
|
|
8861
|
+
(function ($) {
|
|
8862
|
+
$mol_test({
|
|
8863
|
+
'get'() {
|
|
8864
|
+
const proxy = $mol_delegate({}, () => ({ foo: 777 }));
|
|
8865
|
+
$mol_assert_equal(proxy.foo, 777);
|
|
8866
|
+
},
|
|
8867
|
+
'has'() {
|
|
8868
|
+
const proxy = $mol_delegate({}, () => ({ foo: 777 }));
|
|
8869
|
+
$mol_assert_equal('foo' in proxy, true);
|
|
8870
|
+
},
|
|
8871
|
+
'set'() {
|
|
8872
|
+
const target = { foo: 777 };
|
|
8873
|
+
const proxy = $mol_delegate({}, () => target);
|
|
8874
|
+
proxy.foo = 123;
|
|
8875
|
+
$mol_assert_equal(target.foo, 123);
|
|
8876
|
+
},
|
|
8877
|
+
'getOwnPropertyDescriptor'() {
|
|
8878
|
+
const proxy = $mol_delegate({}, () => ({ foo: 777 }));
|
|
8879
|
+
$mol_assert_like(Object.getOwnPropertyDescriptor(proxy, 'foo'), {
|
|
8880
|
+
value: 777,
|
|
8881
|
+
writable: true,
|
|
9027
8882
|
enumerable: true,
|
|
9028
8883
|
configurable: true,
|
|
9029
8884
|
});
|
|
@@ -9495,6 +9350,88 @@ var $;
|
|
|
9495
9350
|
});
|
|
9496
9351
|
})($ || ($ = {}));
|
|
9497
9352
|
|
|
9353
|
+
;
|
|
9354
|
+
"use strict";
|
|
9355
|
+
var $;
|
|
9356
|
+
(function ($_1) {
|
|
9357
|
+
$mol_test({
|
|
9358
|
+
'test types'($) {
|
|
9359
|
+
class A {
|
|
9360
|
+
static a() {
|
|
9361
|
+
return '';
|
|
9362
|
+
}
|
|
9363
|
+
static b() {
|
|
9364
|
+
return $mol_wire_async(this).a();
|
|
9365
|
+
}
|
|
9366
|
+
}
|
|
9367
|
+
},
|
|
9368
|
+
async 'Latest method calls wins'($) {
|
|
9369
|
+
class NameLogger extends $mol_object2 {
|
|
9370
|
+
static $ = $;
|
|
9371
|
+
static first = [];
|
|
9372
|
+
static last = [];
|
|
9373
|
+
static send(next) {
|
|
9374
|
+
$mol_wire_sync(this.first).push(next);
|
|
9375
|
+
$$.$mol_wait_timeout(0);
|
|
9376
|
+
this.last.push(next);
|
|
9377
|
+
}
|
|
9378
|
+
}
|
|
9379
|
+
const name = $mol_wire_async(NameLogger).send;
|
|
9380
|
+
name('john');
|
|
9381
|
+
const promise = name('jin');
|
|
9382
|
+
$.$mol_after_mock_warp();
|
|
9383
|
+
await promise;
|
|
9384
|
+
$mol_assert_equal(NameLogger.first, ['john', 'jin']);
|
|
9385
|
+
$mol_assert_equal(NameLogger.last, ['jin']);
|
|
9386
|
+
},
|
|
9387
|
+
async 'Latest function calls wins'($) {
|
|
9388
|
+
const first = [];
|
|
9389
|
+
const last = [];
|
|
9390
|
+
function send_name(next) {
|
|
9391
|
+
$mol_wire_sync(first).push(next);
|
|
9392
|
+
$$.$mol_wait_timeout(0);
|
|
9393
|
+
last.push(next);
|
|
9394
|
+
}
|
|
9395
|
+
const name = $mol_wire_async(send_name);
|
|
9396
|
+
name('john');
|
|
9397
|
+
const promise = name('jin');
|
|
9398
|
+
$.$mol_after_mock_warp();
|
|
9399
|
+
await promise;
|
|
9400
|
+
$mol_assert_equal(first, ['john', 'jin']);
|
|
9401
|
+
$mol_assert_equal(last, ['jin']);
|
|
9402
|
+
},
|
|
9403
|
+
});
|
|
9404
|
+
})($ || ($ = {}));
|
|
9405
|
+
|
|
9406
|
+
;
|
|
9407
|
+
"use strict";
|
|
9408
|
+
var $;
|
|
9409
|
+
(function ($_1) {
|
|
9410
|
+
$mol_test({
|
|
9411
|
+
'init with overload'() {
|
|
9412
|
+
class X extends $mol_object {
|
|
9413
|
+
foo() {
|
|
9414
|
+
return 1;
|
|
9415
|
+
}
|
|
9416
|
+
}
|
|
9417
|
+
var x = X.make({
|
|
9418
|
+
foo: () => 2,
|
|
9419
|
+
});
|
|
9420
|
+
$mol_assert_equal(x.foo(), 2);
|
|
9421
|
+
},
|
|
9422
|
+
'Context in instance inherits from class'($) {
|
|
9423
|
+
const custom = $.$mol_ambient({});
|
|
9424
|
+
class X extends $.$mol_object {
|
|
9425
|
+
static $ = custom;
|
|
9426
|
+
}
|
|
9427
|
+
$mol_assert_equal(new X().$, custom);
|
|
9428
|
+
},
|
|
9429
|
+
});
|
|
9430
|
+
})($ || ($ = {}));
|
|
9431
|
+
|
|
9432
|
+
;
|
|
9433
|
+
"use strict";
|
|
9434
|
+
|
|
9498
9435
|
;
|
|
9499
9436
|
"use strict";
|
|
9500
9437
|
var $;
|
|
@@ -9526,6 +9463,59 @@ var $;
|
|
|
9526
9463
|
});
|
|
9527
9464
|
})($ || ($ = {}));
|
|
9528
9465
|
|
|
9466
|
+
;
|
|
9467
|
+
"use strict";
|
|
9468
|
+
var $;
|
|
9469
|
+
(function ($_1) {
|
|
9470
|
+
$mol_test({
|
|
9471
|
+
'test types'($) {
|
|
9472
|
+
class A {
|
|
9473
|
+
static a() {
|
|
9474
|
+
return Promise.resolve('');
|
|
9475
|
+
}
|
|
9476
|
+
static b() {
|
|
9477
|
+
return $mol_wire_sync(this).a();
|
|
9478
|
+
}
|
|
9479
|
+
}
|
|
9480
|
+
},
|
|
9481
|
+
async 'test method from host'($) {
|
|
9482
|
+
let count = 0;
|
|
9483
|
+
class A {
|
|
9484
|
+
static a() {
|
|
9485
|
+
return $mol_wire_sync(this).b();
|
|
9486
|
+
}
|
|
9487
|
+
static b() { return Promise.resolve(++count); }
|
|
9488
|
+
}
|
|
9489
|
+
$mol_assert_equal(await $mol_wire_async(A).a(), 1, count);
|
|
9490
|
+
},
|
|
9491
|
+
async 'test function'($) {
|
|
9492
|
+
let count = 0;
|
|
9493
|
+
class A {
|
|
9494
|
+
static a() {
|
|
9495
|
+
return $mol_wire_sync(this.b)();
|
|
9496
|
+
}
|
|
9497
|
+
static b() { return Promise.resolve(++count); }
|
|
9498
|
+
}
|
|
9499
|
+
$mol_assert_equal(await $mol_wire_async(A).a(), 1, count);
|
|
9500
|
+
},
|
|
9501
|
+
async 'test construct itself'($) {
|
|
9502
|
+
class A {
|
|
9503
|
+
static instances = [];
|
|
9504
|
+
static a() {
|
|
9505
|
+
const a = new ($mol_wire_sync(A))();
|
|
9506
|
+
this.instances.push(a);
|
|
9507
|
+
$mol_wire_sync(this).b();
|
|
9508
|
+
}
|
|
9509
|
+
static b() { return Promise.resolve(); }
|
|
9510
|
+
}
|
|
9511
|
+
await $mol_wire_async(A).a();
|
|
9512
|
+
$mol_assert_equal(A.instances.length, 2);
|
|
9513
|
+
$mol_assert_equal(A.instances[0] instanceof A, true);
|
|
9514
|
+
$mol_assert_equal(A.instances[0], A.instances[1]);
|
|
9515
|
+
}
|
|
9516
|
+
});
|
|
9517
|
+
})($ || ($ = {}));
|
|
9518
|
+
|
|
9529
9519
|
;
|
|
9530
9520
|
"use strict";
|
|
9531
9521
|
var $;
|
|
@@ -9619,62 +9609,6 @@ var $;
|
|
|
9619
9609
|
})($$ = $_1.$$ || ($_1.$$ = {}));
|
|
9620
9610
|
})($ || ($ = {}));
|
|
9621
9611
|
|
|
9622
|
-
;
|
|
9623
|
-
"use strict";
|
|
9624
|
-
var $;
|
|
9625
|
-
(function ($_1) {
|
|
9626
|
-
$mol_test({
|
|
9627
|
-
'test types'($) {
|
|
9628
|
-
class A {
|
|
9629
|
-
static a() {
|
|
9630
|
-
return '';
|
|
9631
|
-
}
|
|
9632
|
-
static b() {
|
|
9633
|
-
return $mol_wire_async(this).a();
|
|
9634
|
-
}
|
|
9635
|
-
}
|
|
9636
|
-
},
|
|
9637
|
-
async 'Latest method calls wins'($) {
|
|
9638
|
-
class NameLogger extends $mol_object2 {
|
|
9639
|
-
static $ = $;
|
|
9640
|
-
static first = [];
|
|
9641
|
-
static last = [];
|
|
9642
|
-
static send(next) {
|
|
9643
|
-
$mol_wire_sync(this.first).push(next);
|
|
9644
|
-
$$.$mol_wait_timeout(0);
|
|
9645
|
-
this.last.push(next);
|
|
9646
|
-
}
|
|
9647
|
-
}
|
|
9648
|
-
const name = $mol_wire_async(NameLogger).send;
|
|
9649
|
-
name('john');
|
|
9650
|
-
const promise = name('jin');
|
|
9651
|
-
$.$mol_after_mock_warp();
|
|
9652
|
-
await promise;
|
|
9653
|
-
$mol_assert_equal(NameLogger.first, ['john', 'jin']);
|
|
9654
|
-
$mol_assert_equal(NameLogger.last, ['jin']);
|
|
9655
|
-
},
|
|
9656
|
-
async 'Latest function calls wins'($) {
|
|
9657
|
-
const first = [];
|
|
9658
|
-
const last = [];
|
|
9659
|
-
function send_name(next) {
|
|
9660
|
-
$mol_wire_sync(first).push(next);
|
|
9661
|
-
$$.$mol_wait_timeout(0);
|
|
9662
|
-
last.push(next);
|
|
9663
|
-
}
|
|
9664
|
-
const name = $mol_wire_async(send_name);
|
|
9665
|
-
name('john');
|
|
9666
|
-
const promise = name('jin');
|
|
9667
|
-
$.$mol_after_mock_warp();
|
|
9668
|
-
await promise;
|
|
9669
|
-
$mol_assert_equal(first, ['john', 'jin']);
|
|
9670
|
-
$mol_assert_equal(last, ['jin']);
|
|
9671
|
-
},
|
|
9672
|
-
});
|
|
9673
|
-
})($ || ($ = {}));
|
|
9674
|
-
|
|
9675
|
-
;
|
|
9676
|
-
"use strict";
|
|
9677
|
-
|
|
9678
9612
|
;
|
|
9679
9613
|
"use strict";
|
|
9680
9614
|
var $;
|
|
@@ -10359,6 +10293,93 @@ var $;
|
|
|
10359
10293
|
});
|
|
10360
10294
|
})($ || ($ = {}));
|
|
10361
10295
|
|
|
10296
|
+
;
|
|
10297
|
+
"use strict";
|
|
10298
|
+
var $;
|
|
10299
|
+
(function ($) {
|
|
10300
|
+
$mol_test({
|
|
10301
|
+
'auto name'() {
|
|
10302
|
+
class Invalid extends $mol_error_mix {
|
|
10303
|
+
}
|
|
10304
|
+
const mix = new Invalid('foo');
|
|
10305
|
+
$mol_assert_equal(mix.name, 'Invalid_Error');
|
|
10306
|
+
},
|
|
10307
|
+
'simpe mix'() {
|
|
10308
|
+
const mix = new $mol_error_mix('foo', {}, new Error('bar'), new Error('lol'));
|
|
10309
|
+
$mol_assert_equal(mix.message, 'foo');
|
|
10310
|
+
$mol_assert_equal(mix.errors.map(e => e.message), ['bar', 'lol']);
|
|
10311
|
+
},
|
|
10312
|
+
'provide additional info'() {
|
|
10313
|
+
class Invalid extends $mol_error_mix {
|
|
10314
|
+
}
|
|
10315
|
+
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' }));
|
|
10316
|
+
const hints = [];
|
|
10317
|
+
if (mix instanceof $mol_error_mix) {
|
|
10318
|
+
for (const er of mix.errors) {
|
|
10319
|
+
if (er instanceof Invalid) {
|
|
10320
|
+
hints.push(er.cause?.hint ?? '');
|
|
10321
|
+
}
|
|
10322
|
+
}
|
|
10323
|
+
}
|
|
10324
|
+
$mol_assert_equal(hints, ['> 8 letters', 'need capital letter']);
|
|
10325
|
+
},
|
|
10326
|
+
});
|
|
10327
|
+
})($ || ($ = {}));
|
|
10328
|
+
|
|
10329
|
+
;
|
|
10330
|
+
"use strict";
|
|
10331
|
+
var $;
|
|
10332
|
+
(function ($_1) {
|
|
10333
|
+
$mol_test({
|
|
10334
|
+
async 'exec timeout auto kill child process'($) {
|
|
10335
|
+
let close_mock = () => { };
|
|
10336
|
+
const error_message = 'Run error, timeout';
|
|
10337
|
+
function mol_run_spawn_sync_mock() {
|
|
10338
|
+
return {
|
|
10339
|
+
output: [],
|
|
10340
|
+
stdout: error_message,
|
|
10341
|
+
stderr: '',
|
|
10342
|
+
status: 0,
|
|
10343
|
+
signal: null,
|
|
10344
|
+
pid: 123,
|
|
10345
|
+
};
|
|
10346
|
+
}
|
|
10347
|
+
function mol_run_spawn_mock() {
|
|
10348
|
+
return {
|
|
10349
|
+
on(name, cb) {
|
|
10350
|
+
if (name === 'exit')
|
|
10351
|
+
close_mock = cb;
|
|
10352
|
+
},
|
|
10353
|
+
kill() { close_mock(); }
|
|
10354
|
+
};
|
|
10355
|
+
}
|
|
10356
|
+
const context_mock = $.$mol_ambient({
|
|
10357
|
+
$mol_run_spawn_sync: mol_run_spawn_sync_mock,
|
|
10358
|
+
$mol_run_spawn: mol_run_spawn_mock
|
|
10359
|
+
});
|
|
10360
|
+
class $mol_run_mock extends $mol_run {
|
|
10361
|
+
static get $() { return context_mock; }
|
|
10362
|
+
static async_enabled() {
|
|
10363
|
+
return true;
|
|
10364
|
+
}
|
|
10365
|
+
}
|
|
10366
|
+
let message = '';
|
|
10367
|
+
try {
|
|
10368
|
+
const res = await $mol_wire_async($mol_run_mock).spawn({
|
|
10369
|
+
command: 'sleep 10',
|
|
10370
|
+
dir: '.',
|
|
10371
|
+
timeout: 10,
|
|
10372
|
+
env: { 'MOL_RUN_ASYNC': '1' }
|
|
10373
|
+
});
|
|
10374
|
+
}
|
|
10375
|
+
catch (e) {
|
|
10376
|
+
message = e.message;
|
|
10377
|
+
}
|
|
10378
|
+
$mol_assert_equal(message, error_message);
|
|
10379
|
+
}
|
|
10380
|
+
});
|
|
10381
|
+
})($ || ($ = {}));
|
|
10382
|
+
|
|
10362
10383
|
;
|
|
10363
10384
|
"use strict";
|
|
10364
10385
|
|