mol_mutable 0.0.689 → 0.0.691
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
|
@@ -266,7 +266,11 @@ var $node = new Proxy({ require }, {
|
|
|
266
266
|
try {
|
|
267
267
|
$$.$mol_exec('.', 'npm', 'install', '--omit=dev', '@types/' + name);
|
|
268
268
|
}
|
|
269
|
-
catch {
|
|
269
|
+
catch (e) {
|
|
270
|
+
if ($$.$mol_fail_catch(e)) {
|
|
271
|
+
$$.$mol_fail_log(e);
|
|
272
|
+
}
|
|
273
|
+
}
|
|
270
274
|
break;
|
|
271
275
|
}
|
|
272
276
|
else {
|
|
@@ -277,7 +281,7 @@ var $node = new Proxy({ require }, {
|
|
|
277
281
|
return target.require(name);
|
|
278
282
|
}
|
|
279
283
|
catch (error) {
|
|
280
|
-
if (error.code === 'ERR_REQUIRE_ESM') {
|
|
284
|
+
if ($.$mol_fail_catch(error) && error.code === 'ERR_REQUIRE_ESM') {
|
|
281
285
|
const module = cache.get(name);
|
|
282
286
|
if (module)
|
|
283
287
|
return module;
|
|
@@ -3168,32 +3172,6 @@ var $;
|
|
|
3168
3172
|
$.$mol_wire_task = $mol_wire_task;
|
|
3169
3173
|
})($ || ($ = {}));
|
|
3170
3174
|
|
|
3171
|
-
;
|
|
3172
|
-
"use strict";
|
|
3173
|
-
var $;
|
|
3174
|
-
(function ($) {
|
|
3175
|
-
function $mol_wire_method(host, field, descr) {
|
|
3176
|
-
if (!descr)
|
|
3177
|
-
descr = Reflect.getOwnPropertyDescriptor(host, field);
|
|
3178
|
-
const orig = descr?.value ?? host[field];
|
|
3179
|
-
const sup = Reflect.getPrototypeOf(host);
|
|
3180
|
-
if (typeof sup[field] === 'function') {
|
|
3181
|
-
Object.defineProperty(orig, 'name', { value: sup[field].name });
|
|
3182
|
-
}
|
|
3183
|
-
const temp = $mol_wire_task.getter(orig);
|
|
3184
|
-
const value = function (...args) {
|
|
3185
|
-
const fiber = temp(this ?? null, args);
|
|
3186
|
-
return fiber.sync();
|
|
3187
|
-
};
|
|
3188
|
-
Object.defineProperty(value, 'name', { value: orig.name + ' ' });
|
|
3189
|
-
Object.assign(value, { orig });
|
|
3190
|
-
const descr2 = { ...descr, value };
|
|
3191
|
-
Reflect.defineProperty(host, field, descr2);
|
|
3192
|
-
return descr2;
|
|
3193
|
-
}
|
|
3194
|
-
$.$mol_wire_method = $mol_wire_method;
|
|
3195
|
-
})($ || ($ = {}));
|
|
3196
|
-
|
|
3197
3175
|
;
|
|
3198
3176
|
"use strict";
|
|
3199
3177
|
var $;
|
|
@@ -3281,10 +3259,45 @@ var $;
|
|
|
3281
3259
|
"use strict";
|
|
3282
3260
|
var $;
|
|
3283
3261
|
(function ($) {
|
|
3262
|
+
function $mol_wire_method(host, field, descr) {
|
|
3263
|
+
if (!descr)
|
|
3264
|
+
descr = Reflect.getOwnPropertyDescriptor(host, field);
|
|
3265
|
+
const orig = descr?.value ?? host[field];
|
|
3266
|
+
const sup = Reflect.getPrototypeOf(host);
|
|
3267
|
+
if (typeof sup[field] === 'function') {
|
|
3268
|
+
Object.defineProperty(orig, 'name', { value: sup[field].name });
|
|
3269
|
+
}
|
|
3270
|
+
const temp = $mol_wire_task.getter(orig);
|
|
3271
|
+
const value = function (...args) {
|
|
3272
|
+
const fiber = temp(this ?? null, args);
|
|
3273
|
+
return fiber.sync();
|
|
3274
|
+
};
|
|
3275
|
+
Object.defineProperty(value, 'name', { value: orig.name + ' ' });
|
|
3276
|
+
Object.assign(value, { orig });
|
|
3277
|
+
const descr2 = { ...descr, value };
|
|
3278
|
+
Reflect.defineProperty(host, field, descr2);
|
|
3279
|
+
return descr2;
|
|
3280
|
+
}
|
|
3281
|
+
$.$mol_wire_method = $mol_wire_method;
|
|
3282
|
+
})($ || ($ = {}));
|
|
3283
|
+
|
|
3284
|
+
;
|
|
3285
|
+
"use strict";
|
|
3286
|
+
var $;
|
|
3287
|
+
(function ($) {
|
|
3288
|
+
const factories = new WeakMap();
|
|
3289
|
+
function factory(val) {
|
|
3290
|
+
let make = factories.get(val);
|
|
3291
|
+
if (make)
|
|
3292
|
+
return make;
|
|
3293
|
+
make = $mol_func_name_from((...args) => new val(...args), val);
|
|
3294
|
+
factories.set(val, make);
|
|
3295
|
+
return make;
|
|
3296
|
+
}
|
|
3284
3297
|
function $mol_wire_sync(obj) {
|
|
3285
3298
|
return new Proxy(obj, {
|
|
3286
3299
|
get(obj, field) {
|
|
3287
|
-
|
|
3300
|
+
let val = obj[field];
|
|
3288
3301
|
if (typeof val !== 'function')
|
|
3289
3302
|
return val;
|
|
3290
3303
|
const temp = $mol_wire_task.getter(val);
|
|
@@ -3293,10 +3306,13 @@ var $;
|
|
|
3293
3306
|
return fiber.sync();
|
|
3294
3307
|
};
|
|
3295
3308
|
},
|
|
3309
|
+
construct(obj, args) {
|
|
3310
|
+
const temp = $mol_wire_task.getter(factory(obj));
|
|
3311
|
+
return temp(obj, args).sync();
|
|
3312
|
+
},
|
|
3296
3313
|
apply(obj, self, args) {
|
|
3297
3314
|
const temp = $mol_wire_task.getter(obj);
|
|
3298
|
-
|
|
3299
|
-
return fiber.sync();
|
|
3315
|
+
return temp(self, args).sync();
|
|
3300
3316
|
},
|
|
3301
3317
|
});
|
|
3302
3318
|
}
|
|
@@ -3318,6 +3334,41 @@ var $;
|
|
|
3318
3334
|
}
|
|
3319
3335
|
}
|
|
3320
3336
|
},
|
|
3337
|
+
async 'test method from host'($) {
|
|
3338
|
+
let count = 0;
|
|
3339
|
+
class A {
|
|
3340
|
+
static a() {
|
|
3341
|
+
return $mol_wire_sync(this).b();
|
|
3342
|
+
}
|
|
3343
|
+
static b() { return Promise.resolve(++count); }
|
|
3344
|
+
}
|
|
3345
|
+
$mol_assert_equal(await $mol_wire_async(A).a(), 1, count);
|
|
3346
|
+
},
|
|
3347
|
+
async 'test function'($) {
|
|
3348
|
+
let count = 0;
|
|
3349
|
+
class A {
|
|
3350
|
+
static a() {
|
|
3351
|
+
return $mol_wire_sync(this.b)();
|
|
3352
|
+
}
|
|
3353
|
+
static b() { return Promise.resolve(++count); }
|
|
3354
|
+
}
|
|
3355
|
+
$mol_assert_equal(await $mol_wire_async(A).a(), 1, count);
|
|
3356
|
+
},
|
|
3357
|
+
async 'test construct itself'($) {
|
|
3358
|
+
class A {
|
|
3359
|
+
static instances = [];
|
|
3360
|
+
static a() {
|
|
3361
|
+
const a = new ($mol_wire_sync(A))();
|
|
3362
|
+
this.instances.push(a);
|
|
3363
|
+
$mol_wire_sync(this).b();
|
|
3364
|
+
}
|
|
3365
|
+
static b() { return Promise.resolve(); }
|
|
3366
|
+
}
|
|
3367
|
+
await $mol_wire_async(A).a();
|
|
3368
|
+
$mol_assert_equal(A.instances.length, 2);
|
|
3369
|
+
$mol_assert_equal(A.instances[0] instanceof A);
|
|
3370
|
+
$mol_assert_equal(A.instances[0], A.instances[1]);
|
|
3371
|
+
}
|
|
3321
3372
|
});
|
|
3322
3373
|
})($ || ($ = {}));
|
|
3323
3374
|
|
|
@@ -3397,9 +3448,19 @@ var $;
|
|
|
3397
3448
|
$.$mol_run_error = $mol_run_error;
|
|
3398
3449
|
const child_process = $node['child_process'];
|
|
3399
3450
|
$.$mol_run_spawn = child_process.spawn.bind(child_process);
|
|
3451
|
+
$.$mol_run_spawn_sync = child_process.spawnSync.bind(child_process);
|
|
3400
3452
|
function $mol_run_async({ dir, timeout, command, env }) {
|
|
3401
3453
|
const args_raw = typeof command === 'string' ? command.split(' ') : command;
|
|
3402
3454
|
const [app, ...args] = args_raw;
|
|
3455
|
+
if (!env?.MOL_RUN_ASYNC) {
|
|
3456
|
+
this.$mol_log3_come({
|
|
3457
|
+
place: '$mol_run_sync',
|
|
3458
|
+
message: 'Run',
|
|
3459
|
+
command: args_raw.join(' '),
|
|
3460
|
+
dir: $node.path.relative('', dir),
|
|
3461
|
+
});
|
|
3462
|
+
return this.$mol_run_spawn_sync(app, args, { shell: true, cwd: dir, env });
|
|
3463
|
+
}
|
|
3403
3464
|
const sub = this.$mol_run_spawn(app, args, {
|
|
3404
3465
|
shell: true,
|
|
3405
3466
|
cwd: dir,
|
|
@@ -3495,7 +3556,7 @@ var $;
|
|
|
3495
3556
|
});
|
|
3496
3557
|
let message = '';
|
|
3497
3558
|
try {
|
|
3498
|
-
const res = await $mol_wire_async(context_mock).$mol_run({ command: 'sleep 10', dir: '.', timeout: 10 });
|
|
3559
|
+
const res = await $mol_wire_async(context_mock).$mol_run({ command: 'sleep 10', dir: '.', timeout: 10, env: { 'MOL_RUN_ASYNC': '1' } });
|
|
3499
3560
|
}
|
|
3500
3561
|
catch (e) {
|
|
3501
3562
|
message = e.message;
|