mol_key 0.0.1029 → 0.0.1031
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
|
@@ -285,7 +285,11 @@ var $node = new Proxy({ require }, {
|
|
|
285
285
|
try {
|
|
286
286
|
$$.$mol_exec('.', 'npm', 'install', '--omit=dev', '@types/' + name);
|
|
287
287
|
}
|
|
288
|
-
catch {
|
|
288
|
+
catch (e) {
|
|
289
|
+
if ($$.$mol_fail_catch(e)) {
|
|
290
|
+
$$.$mol_fail_log(e);
|
|
291
|
+
}
|
|
292
|
+
}
|
|
289
293
|
break;
|
|
290
294
|
}
|
|
291
295
|
else {
|
|
@@ -296,7 +300,7 @@ var $node = new Proxy({ require }, {
|
|
|
296
300
|
return target.require(name);
|
|
297
301
|
}
|
|
298
302
|
catch (error) {
|
|
299
|
-
if (error.code === 'ERR_REQUIRE_ESM') {
|
|
303
|
+
if ($.$mol_fail_catch(error) && error.code === 'ERR_REQUIRE_ESM') {
|
|
300
304
|
const module = cache.get(name);
|
|
301
305
|
if (module)
|
|
302
306
|
return module;
|
|
@@ -2423,32 +2427,6 @@ var $;
|
|
|
2423
2427
|
$.$mol_wire_task = $mol_wire_task;
|
|
2424
2428
|
})($ || ($ = {}));
|
|
2425
2429
|
|
|
2426
|
-
;
|
|
2427
|
-
"use strict";
|
|
2428
|
-
var $;
|
|
2429
|
-
(function ($) {
|
|
2430
|
-
function $mol_wire_method(host, field, descr) {
|
|
2431
|
-
if (!descr)
|
|
2432
|
-
descr = Reflect.getOwnPropertyDescriptor(host, field);
|
|
2433
|
-
const orig = descr?.value ?? host[field];
|
|
2434
|
-
const sup = Reflect.getPrototypeOf(host);
|
|
2435
|
-
if (typeof sup[field] === 'function') {
|
|
2436
|
-
Object.defineProperty(orig, 'name', { value: sup[field].name });
|
|
2437
|
-
}
|
|
2438
|
-
const temp = $mol_wire_task.getter(orig);
|
|
2439
|
-
const value = function (...args) {
|
|
2440
|
-
const fiber = temp(this ?? null, args);
|
|
2441
|
-
return fiber.sync();
|
|
2442
|
-
};
|
|
2443
|
-
Object.defineProperty(value, 'name', { value: orig.name + ' ' });
|
|
2444
|
-
Object.assign(value, { orig });
|
|
2445
|
-
const descr2 = { ...descr, value };
|
|
2446
|
-
Reflect.defineProperty(host, field, descr2);
|
|
2447
|
-
return descr2;
|
|
2448
|
-
}
|
|
2449
|
-
$.$mol_wire_method = $mol_wire_method;
|
|
2450
|
-
})($ || ($ = {}));
|
|
2451
|
-
|
|
2452
2430
|
;
|
|
2453
2431
|
"use strict";
|
|
2454
2432
|
var $;
|
|
@@ -2536,10 +2514,45 @@ var $;
|
|
|
2536
2514
|
"use strict";
|
|
2537
2515
|
var $;
|
|
2538
2516
|
(function ($) {
|
|
2517
|
+
function $mol_wire_method(host, field, descr) {
|
|
2518
|
+
if (!descr)
|
|
2519
|
+
descr = Reflect.getOwnPropertyDescriptor(host, field);
|
|
2520
|
+
const orig = descr?.value ?? host[field];
|
|
2521
|
+
const sup = Reflect.getPrototypeOf(host);
|
|
2522
|
+
if (typeof sup[field] === 'function') {
|
|
2523
|
+
Object.defineProperty(orig, 'name', { value: sup[field].name });
|
|
2524
|
+
}
|
|
2525
|
+
const temp = $mol_wire_task.getter(orig);
|
|
2526
|
+
const value = function (...args) {
|
|
2527
|
+
const fiber = temp(this ?? null, args);
|
|
2528
|
+
return fiber.sync();
|
|
2529
|
+
};
|
|
2530
|
+
Object.defineProperty(value, 'name', { value: orig.name + ' ' });
|
|
2531
|
+
Object.assign(value, { orig });
|
|
2532
|
+
const descr2 = { ...descr, value };
|
|
2533
|
+
Reflect.defineProperty(host, field, descr2);
|
|
2534
|
+
return descr2;
|
|
2535
|
+
}
|
|
2536
|
+
$.$mol_wire_method = $mol_wire_method;
|
|
2537
|
+
})($ || ($ = {}));
|
|
2538
|
+
|
|
2539
|
+
;
|
|
2540
|
+
"use strict";
|
|
2541
|
+
var $;
|
|
2542
|
+
(function ($) {
|
|
2543
|
+
const factories = new WeakMap();
|
|
2544
|
+
function factory(val) {
|
|
2545
|
+
let make = factories.get(val);
|
|
2546
|
+
if (make)
|
|
2547
|
+
return make;
|
|
2548
|
+
make = $mol_func_name_from((...args) => new val(...args), val);
|
|
2549
|
+
factories.set(val, make);
|
|
2550
|
+
return make;
|
|
2551
|
+
}
|
|
2539
2552
|
function $mol_wire_sync(obj) {
|
|
2540
2553
|
return new Proxy(obj, {
|
|
2541
2554
|
get(obj, field) {
|
|
2542
|
-
|
|
2555
|
+
let val = obj[field];
|
|
2543
2556
|
if (typeof val !== 'function')
|
|
2544
2557
|
return val;
|
|
2545
2558
|
const temp = $mol_wire_task.getter(val);
|
|
@@ -2548,10 +2561,13 @@ var $;
|
|
|
2548
2561
|
return fiber.sync();
|
|
2549
2562
|
};
|
|
2550
2563
|
},
|
|
2564
|
+
construct(obj, args) {
|
|
2565
|
+
const temp = $mol_wire_task.getter(factory(obj));
|
|
2566
|
+
return temp(obj, args).sync();
|
|
2567
|
+
},
|
|
2551
2568
|
apply(obj, self, args) {
|
|
2552
2569
|
const temp = $mol_wire_task.getter(obj);
|
|
2553
|
-
|
|
2554
|
-
return fiber.sync();
|
|
2570
|
+
return temp(self, args).sync();
|
|
2555
2571
|
},
|
|
2556
2572
|
});
|
|
2557
2573
|
}
|
|
@@ -2573,6 +2589,41 @@ var $;
|
|
|
2573
2589
|
}
|
|
2574
2590
|
}
|
|
2575
2591
|
},
|
|
2592
|
+
async 'test method from host'($) {
|
|
2593
|
+
let count = 0;
|
|
2594
|
+
class A {
|
|
2595
|
+
static a() {
|
|
2596
|
+
return $mol_wire_sync(this).b();
|
|
2597
|
+
}
|
|
2598
|
+
static b() { return Promise.resolve(++count); }
|
|
2599
|
+
}
|
|
2600
|
+
$mol_assert_equal(await $mol_wire_async(A).a(), 1, count);
|
|
2601
|
+
},
|
|
2602
|
+
async 'test function'($) {
|
|
2603
|
+
let count = 0;
|
|
2604
|
+
class A {
|
|
2605
|
+
static a() {
|
|
2606
|
+
return $mol_wire_sync(this.b)();
|
|
2607
|
+
}
|
|
2608
|
+
static b() { return Promise.resolve(++count); }
|
|
2609
|
+
}
|
|
2610
|
+
$mol_assert_equal(await $mol_wire_async(A).a(), 1, count);
|
|
2611
|
+
},
|
|
2612
|
+
async 'test construct itself'($) {
|
|
2613
|
+
class A {
|
|
2614
|
+
static instances = [];
|
|
2615
|
+
static a() {
|
|
2616
|
+
const a = new ($mol_wire_sync(A))();
|
|
2617
|
+
this.instances.push(a);
|
|
2618
|
+
$mol_wire_sync(this).b();
|
|
2619
|
+
}
|
|
2620
|
+
static b() { return Promise.resolve(); }
|
|
2621
|
+
}
|
|
2622
|
+
await $mol_wire_async(A).a();
|
|
2623
|
+
$mol_assert_equal(A.instances.length, 2);
|
|
2624
|
+
$mol_assert_equal(A.instances[0] instanceof A);
|
|
2625
|
+
$mol_assert_equal(A.instances[0], A.instances[1]);
|
|
2626
|
+
}
|
|
2576
2627
|
});
|
|
2577
2628
|
})($ || ($ = {}));
|
|
2578
2629
|
|
|
@@ -2652,9 +2703,19 @@ var $;
|
|
|
2652
2703
|
$.$mol_run_error = $mol_run_error;
|
|
2653
2704
|
const child_process = $node['child_process'];
|
|
2654
2705
|
$.$mol_run_spawn = child_process.spawn.bind(child_process);
|
|
2706
|
+
$.$mol_run_spawn_sync = child_process.spawnSync.bind(child_process);
|
|
2655
2707
|
function $mol_run_async({ dir, timeout, command, env }) {
|
|
2656
2708
|
const args_raw = typeof command === 'string' ? command.split(' ') : command;
|
|
2657
2709
|
const [app, ...args] = args_raw;
|
|
2710
|
+
if (!env?.MOL_RUN_ASYNC) {
|
|
2711
|
+
this.$mol_log3_come({
|
|
2712
|
+
place: '$mol_run_sync',
|
|
2713
|
+
message: 'Run',
|
|
2714
|
+
command: args_raw.join(' '),
|
|
2715
|
+
dir: $node.path.relative('', dir),
|
|
2716
|
+
});
|
|
2717
|
+
return this.$mol_run_spawn_sync(app, args, { shell: true, cwd: dir, env });
|
|
2718
|
+
}
|
|
2658
2719
|
const sub = this.$mol_run_spawn(app, args, {
|
|
2659
2720
|
shell: true,
|
|
2660
2721
|
cwd: dir,
|
|
@@ -2750,7 +2811,7 @@ var $;
|
|
|
2750
2811
|
});
|
|
2751
2812
|
let message = '';
|
|
2752
2813
|
try {
|
|
2753
|
-
const res = await $mol_wire_async(context_mock).$mol_run({ command: 'sleep 10', dir: '.', timeout: 10 });
|
|
2814
|
+
const res = await $mol_wire_async(context_mock).$mol_run({ command: 'sleep 10', dir: '.', timeout: 10, env: { 'MOL_RUN_ASYNC': '1' } });
|
|
2754
2815
|
}
|
|
2755
2816
|
catch (e) {
|
|
2756
2817
|
message = e.message;
|