mol_regexp 0.0.1309 → 0.0.1310
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 +93 -32
- package/node.test.js.map +1 -1
- package/package.json +1 -1
package/node.test.js
CHANGED
|
@@ -531,7 +531,11 @@ var $node = new Proxy({ require }, {
|
|
|
531
531
|
try {
|
|
532
532
|
$$.$mol_exec('.', 'npm', 'install', '--omit=dev', '@types/' + name);
|
|
533
533
|
}
|
|
534
|
-
catch {
|
|
534
|
+
catch (e) {
|
|
535
|
+
if ($$.$mol_fail_catch(e)) {
|
|
536
|
+
$$.$mol_fail_log(e);
|
|
537
|
+
}
|
|
538
|
+
}
|
|
535
539
|
break;
|
|
536
540
|
}
|
|
537
541
|
else {
|
|
@@ -542,7 +546,7 @@ var $node = new Proxy({ require }, {
|
|
|
542
546
|
return target.require(name);
|
|
543
547
|
}
|
|
544
548
|
catch (error) {
|
|
545
|
-
if (error.code === 'ERR_REQUIRE_ESM') {
|
|
549
|
+
if ($.$mol_fail_catch(error) && error.code === 'ERR_REQUIRE_ESM') {
|
|
546
550
|
const module = cache.get(name);
|
|
547
551
|
if (module)
|
|
548
552
|
return module;
|
|
@@ -3433,32 +3437,6 @@ var $;
|
|
|
3433
3437
|
$.$mol_wire_task = $mol_wire_task;
|
|
3434
3438
|
})($ || ($ = {}));
|
|
3435
3439
|
|
|
3436
|
-
;
|
|
3437
|
-
"use strict";
|
|
3438
|
-
var $;
|
|
3439
|
-
(function ($) {
|
|
3440
|
-
function $mol_wire_method(host, field, descr) {
|
|
3441
|
-
if (!descr)
|
|
3442
|
-
descr = Reflect.getOwnPropertyDescriptor(host, field);
|
|
3443
|
-
const orig = descr?.value ?? host[field];
|
|
3444
|
-
const sup = Reflect.getPrototypeOf(host);
|
|
3445
|
-
if (typeof sup[field] === 'function') {
|
|
3446
|
-
Object.defineProperty(orig, 'name', { value: sup[field].name });
|
|
3447
|
-
}
|
|
3448
|
-
const temp = $mol_wire_task.getter(orig);
|
|
3449
|
-
const value = function (...args) {
|
|
3450
|
-
const fiber = temp(this ?? null, args);
|
|
3451
|
-
return fiber.sync();
|
|
3452
|
-
};
|
|
3453
|
-
Object.defineProperty(value, 'name', { value: orig.name + ' ' });
|
|
3454
|
-
Object.assign(value, { orig });
|
|
3455
|
-
const descr2 = { ...descr, value };
|
|
3456
|
-
Reflect.defineProperty(host, field, descr2);
|
|
3457
|
-
return descr2;
|
|
3458
|
-
}
|
|
3459
|
-
$.$mol_wire_method = $mol_wire_method;
|
|
3460
|
-
})($ || ($ = {}));
|
|
3461
|
-
|
|
3462
3440
|
;
|
|
3463
3441
|
"use strict";
|
|
3464
3442
|
var $;
|
|
@@ -3546,10 +3524,45 @@ var $;
|
|
|
3546
3524
|
"use strict";
|
|
3547
3525
|
var $;
|
|
3548
3526
|
(function ($) {
|
|
3527
|
+
function $mol_wire_method(host, field, descr) {
|
|
3528
|
+
if (!descr)
|
|
3529
|
+
descr = Reflect.getOwnPropertyDescriptor(host, field);
|
|
3530
|
+
const orig = descr?.value ?? host[field];
|
|
3531
|
+
const sup = Reflect.getPrototypeOf(host);
|
|
3532
|
+
if (typeof sup[field] === 'function') {
|
|
3533
|
+
Object.defineProperty(orig, 'name', { value: sup[field].name });
|
|
3534
|
+
}
|
|
3535
|
+
const temp = $mol_wire_task.getter(orig);
|
|
3536
|
+
const value = function (...args) {
|
|
3537
|
+
const fiber = temp(this ?? null, args);
|
|
3538
|
+
return fiber.sync();
|
|
3539
|
+
};
|
|
3540
|
+
Object.defineProperty(value, 'name', { value: orig.name + ' ' });
|
|
3541
|
+
Object.assign(value, { orig });
|
|
3542
|
+
const descr2 = { ...descr, value };
|
|
3543
|
+
Reflect.defineProperty(host, field, descr2);
|
|
3544
|
+
return descr2;
|
|
3545
|
+
}
|
|
3546
|
+
$.$mol_wire_method = $mol_wire_method;
|
|
3547
|
+
})($ || ($ = {}));
|
|
3548
|
+
|
|
3549
|
+
;
|
|
3550
|
+
"use strict";
|
|
3551
|
+
var $;
|
|
3552
|
+
(function ($) {
|
|
3553
|
+
const factories = new WeakMap();
|
|
3554
|
+
function factory(val) {
|
|
3555
|
+
let make = factories.get(val);
|
|
3556
|
+
if (make)
|
|
3557
|
+
return make;
|
|
3558
|
+
make = $mol_func_name_from((...args) => new val(...args), val);
|
|
3559
|
+
factories.set(val, make);
|
|
3560
|
+
return make;
|
|
3561
|
+
}
|
|
3549
3562
|
function $mol_wire_sync(obj) {
|
|
3550
3563
|
return new Proxy(obj, {
|
|
3551
3564
|
get(obj, field) {
|
|
3552
|
-
|
|
3565
|
+
let val = obj[field];
|
|
3553
3566
|
if (typeof val !== 'function')
|
|
3554
3567
|
return val;
|
|
3555
3568
|
const temp = $mol_wire_task.getter(val);
|
|
@@ -3558,10 +3571,13 @@ var $;
|
|
|
3558
3571
|
return fiber.sync();
|
|
3559
3572
|
};
|
|
3560
3573
|
},
|
|
3574
|
+
construct(obj, args) {
|
|
3575
|
+
const temp = $mol_wire_task.getter(factory(obj));
|
|
3576
|
+
return temp(obj, args).sync();
|
|
3577
|
+
},
|
|
3561
3578
|
apply(obj, self, args) {
|
|
3562
3579
|
const temp = $mol_wire_task.getter(obj);
|
|
3563
|
-
|
|
3564
|
-
return fiber.sync();
|
|
3580
|
+
return temp(self, args).sync();
|
|
3565
3581
|
},
|
|
3566
3582
|
});
|
|
3567
3583
|
}
|
|
@@ -3583,6 +3599,41 @@ var $;
|
|
|
3583
3599
|
}
|
|
3584
3600
|
}
|
|
3585
3601
|
},
|
|
3602
|
+
async 'test method from host'($) {
|
|
3603
|
+
let count = 0;
|
|
3604
|
+
class A {
|
|
3605
|
+
static a() {
|
|
3606
|
+
return $mol_wire_sync(this).b();
|
|
3607
|
+
}
|
|
3608
|
+
static b() { return Promise.resolve(++count); }
|
|
3609
|
+
}
|
|
3610
|
+
$mol_assert_equal(await $mol_wire_async(A).a(), 1, count);
|
|
3611
|
+
},
|
|
3612
|
+
async 'test function'($) {
|
|
3613
|
+
let count = 0;
|
|
3614
|
+
class A {
|
|
3615
|
+
static a() {
|
|
3616
|
+
return $mol_wire_sync(this.b)();
|
|
3617
|
+
}
|
|
3618
|
+
static b() { return Promise.resolve(++count); }
|
|
3619
|
+
}
|
|
3620
|
+
$mol_assert_equal(await $mol_wire_async(A).a(), 1, count);
|
|
3621
|
+
},
|
|
3622
|
+
async 'test construct itself'($) {
|
|
3623
|
+
class A {
|
|
3624
|
+
static instances = [];
|
|
3625
|
+
static a() {
|
|
3626
|
+
const a = new ($mol_wire_sync(A))();
|
|
3627
|
+
this.instances.push(a);
|
|
3628
|
+
$mol_wire_sync(this).b();
|
|
3629
|
+
}
|
|
3630
|
+
static b() { return Promise.resolve(); }
|
|
3631
|
+
}
|
|
3632
|
+
await $mol_wire_async(A).a();
|
|
3633
|
+
$mol_assert_equal(A.instances.length, 2);
|
|
3634
|
+
$mol_assert_equal(A.instances[0] instanceof A);
|
|
3635
|
+
$mol_assert_equal(A.instances[0], A.instances[1]);
|
|
3636
|
+
}
|
|
3586
3637
|
});
|
|
3587
3638
|
})($ || ($ = {}));
|
|
3588
3639
|
|
|
@@ -3662,9 +3713,19 @@ var $;
|
|
|
3662
3713
|
$.$mol_run_error = $mol_run_error;
|
|
3663
3714
|
const child_process = $node['child_process'];
|
|
3664
3715
|
$.$mol_run_spawn = child_process.spawn.bind(child_process);
|
|
3716
|
+
$.$mol_run_spawn_sync = child_process.spawnSync.bind(child_process);
|
|
3665
3717
|
function $mol_run_async({ dir, timeout, command, env }) {
|
|
3666
3718
|
const args_raw = typeof command === 'string' ? command.split(' ') : command;
|
|
3667
3719
|
const [app, ...args] = args_raw;
|
|
3720
|
+
if (!env?.MOL_RUN_ASYNC) {
|
|
3721
|
+
this.$mol_log3_come({
|
|
3722
|
+
place: '$mol_run_sync',
|
|
3723
|
+
message: 'Run',
|
|
3724
|
+
command: args_raw.join(' '),
|
|
3725
|
+
dir: $node.path.relative('', dir),
|
|
3726
|
+
});
|
|
3727
|
+
return this.$mol_run_spawn_sync(app, args, { shell: true, cwd: dir, env });
|
|
3728
|
+
}
|
|
3668
3729
|
const sub = this.$mol_run_spawn(app, args, {
|
|
3669
3730
|
shell: true,
|
|
3670
3731
|
cwd: dir,
|
|
@@ -3760,7 +3821,7 @@ var $;
|
|
|
3760
3821
|
});
|
|
3761
3822
|
let message = '';
|
|
3762
3823
|
try {
|
|
3763
|
-
const res = await $mol_wire_async(context_mock).$mol_run({ command: 'sleep 10', dir: '.', timeout: 10 });
|
|
3824
|
+
const res = await $mol_wire_async(context_mock).$mol_run({ command: 'sleep 10', dir: '.', timeout: 10, env: { 'MOL_RUN_ASYNC': '1' } });
|
|
3764
3825
|
}
|
|
3765
3826
|
catch (e) {
|
|
3766
3827
|
message = e.message;
|