mol_text_distance 0.0.955 → 0.0.956
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
|
@@ -274,7 +274,11 @@ var $node = new Proxy({ require }, {
|
|
|
274
274
|
try {
|
|
275
275
|
$$.$mol_exec('.', 'npm', 'install', '--omit=dev', '@types/' + name);
|
|
276
276
|
}
|
|
277
|
-
catch {
|
|
277
|
+
catch (e) {
|
|
278
|
+
if ($$.$mol_fail_catch(e)) {
|
|
279
|
+
$$.$mol_fail_log(e);
|
|
280
|
+
}
|
|
281
|
+
}
|
|
278
282
|
break;
|
|
279
283
|
}
|
|
280
284
|
else {
|
|
@@ -285,7 +289,7 @@ var $node = new Proxy({ require }, {
|
|
|
285
289
|
return target.require(name);
|
|
286
290
|
}
|
|
287
291
|
catch (error) {
|
|
288
|
-
if (error.code === 'ERR_REQUIRE_ESM') {
|
|
292
|
+
if ($.$mol_fail_catch(error) && error.code === 'ERR_REQUIRE_ESM') {
|
|
289
293
|
const module = cache.get(name);
|
|
290
294
|
if (module)
|
|
291
295
|
return module;
|
|
@@ -3191,32 +3195,6 @@ var $;
|
|
|
3191
3195
|
$.$mol_wire_task = $mol_wire_task;
|
|
3192
3196
|
})($ || ($ = {}));
|
|
3193
3197
|
|
|
3194
|
-
;
|
|
3195
|
-
"use strict";
|
|
3196
|
-
var $;
|
|
3197
|
-
(function ($) {
|
|
3198
|
-
function $mol_wire_method(host, field, descr) {
|
|
3199
|
-
if (!descr)
|
|
3200
|
-
descr = Reflect.getOwnPropertyDescriptor(host, field);
|
|
3201
|
-
const orig = descr?.value ?? host[field];
|
|
3202
|
-
const sup = Reflect.getPrototypeOf(host);
|
|
3203
|
-
if (typeof sup[field] === 'function') {
|
|
3204
|
-
Object.defineProperty(orig, 'name', { value: sup[field].name });
|
|
3205
|
-
}
|
|
3206
|
-
const temp = $mol_wire_task.getter(orig);
|
|
3207
|
-
const value = function (...args) {
|
|
3208
|
-
const fiber = temp(this ?? null, args);
|
|
3209
|
-
return fiber.sync();
|
|
3210
|
-
};
|
|
3211
|
-
Object.defineProperty(value, 'name', { value: orig.name + ' ' });
|
|
3212
|
-
Object.assign(value, { orig });
|
|
3213
|
-
const descr2 = { ...descr, value };
|
|
3214
|
-
Reflect.defineProperty(host, field, descr2);
|
|
3215
|
-
return descr2;
|
|
3216
|
-
}
|
|
3217
|
-
$.$mol_wire_method = $mol_wire_method;
|
|
3218
|
-
})($ || ($ = {}));
|
|
3219
|
-
|
|
3220
3198
|
;
|
|
3221
3199
|
"use strict";
|
|
3222
3200
|
var $;
|
|
@@ -3304,10 +3282,45 @@ var $;
|
|
|
3304
3282
|
"use strict";
|
|
3305
3283
|
var $;
|
|
3306
3284
|
(function ($) {
|
|
3285
|
+
function $mol_wire_method(host, field, descr) {
|
|
3286
|
+
if (!descr)
|
|
3287
|
+
descr = Reflect.getOwnPropertyDescriptor(host, field);
|
|
3288
|
+
const orig = descr?.value ?? host[field];
|
|
3289
|
+
const sup = Reflect.getPrototypeOf(host);
|
|
3290
|
+
if (typeof sup[field] === 'function') {
|
|
3291
|
+
Object.defineProperty(orig, 'name', { value: sup[field].name });
|
|
3292
|
+
}
|
|
3293
|
+
const temp = $mol_wire_task.getter(orig);
|
|
3294
|
+
const value = function (...args) {
|
|
3295
|
+
const fiber = temp(this ?? null, args);
|
|
3296
|
+
return fiber.sync();
|
|
3297
|
+
};
|
|
3298
|
+
Object.defineProperty(value, 'name', { value: orig.name + ' ' });
|
|
3299
|
+
Object.assign(value, { orig });
|
|
3300
|
+
const descr2 = { ...descr, value };
|
|
3301
|
+
Reflect.defineProperty(host, field, descr2);
|
|
3302
|
+
return descr2;
|
|
3303
|
+
}
|
|
3304
|
+
$.$mol_wire_method = $mol_wire_method;
|
|
3305
|
+
})($ || ($ = {}));
|
|
3306
|
+
|
|
3307
|
+
;
|
|
3308
|
+
"use strict";
|
|
3309
|
+
var $;
|
|
3310
|
+
(function ($) {
|
|
3311
|
+
const factories = new WeakMap();
|
|
3312
|
+
function factory(val) {
|
|
3313
|
+
let make = factories.get(val);
|
|
3314
|
+
if (make)
|
|
3315
|
+
return make;
|
|
3316
|
+
make = $mol_func_name_from((...args) => new val(...args), val);
|
|
3317
|
+
factories.set(val, make);
|
|
3318
|
+
return make;
|
|
3319
|
+
}
|
|
3307
3320
|
function $mol_wire_sync(obj) {
|
|
3308
3321
|
return new Proxy(obj, {
|
|
3309
3322
|
get(obj, field) {
|
|
3310
|
-
|
|
3323
|
+
let val = obj[field];
|
|
3311
3324
|
if (typeof val !== 'function')
|
|
3312
3325
|
return val;
|
|
3313
3326
|
const temp = $mol_wire_task.getter(val);
|
|
@@ -3316,10 +3329,13 @@ var $;
|
|
|
3316
3329
|
return fiber.sync();
|
|
3317
3330
|
};
|
|
3318
3331
|
},
|
|
3332
|
+
construct(obj, args) {
|
|
3333
|
+
const temp = $mol_wire_task.getter(factory(obj));
|
|
3334
|
+
return temp(obj, args).sync();
|
|
3335
|
+
},
|
|
3319
3336
|
apply(obj, self, args) {
|
|
3320
3337
|
const temp = $mol_wire_task.getter(obj);
|
|
3321
|
-
|
|
3322
|
-
return fiber.sync();
|
|
3338
|
+
return temp(self, args).sync();
|
|
3323
3339
|
},
|
|
3324
3340
|
});
|
|
3325
3341
|
}
|
|
@@ -3341,6 +3357,41 @@ var $;
|
|
|
3341
3357
|
}
|
|
3342
3358
|
}
|
|
3343
3359
|
},
|
|
3360
|
+
async 'test method from host'($) {
|
|
3361
|
+
let count = 0;
|
|
3362
|
+
class A {
|
|
3363
|
+
static a() {
|
|
3364
|
+
return $mol_wire_sync(this).b();
|
|
3365
|
+
}
|
|
3366
|
+
static b() { return Promise.resolve(++count); }
|
|
3367
|
+
}
|
|
3368
|
+
$mol_assert_equal(await $mol_wire_async(A).a(), 1, count);
|
|
3369
|
+
},
|
|
3370
|
+
async 'test function'($) {
|
|
3371
|
+
let count = 0;
|
|
3372
|
+
class A {
|
|
3373
|
+
static a() {
|
|
3374
|
+
return $mol_wire_sync(this.b)();
|
|
3375
|
+
}
|
|
3376
|
+
static b() { return Promise.resolve(++count); }
|
|
3377
|
+
}
|
|
3378
|
+
$mol_assert_equal(await $mol_wire_async(A).a(), 1, count);
|
|
3379
|
+
},
|
|
3380
|
+
async 'test construct itself'($) {
|
|
3381
|
+
class A {
|
|
3382
|
+
static instances = [];
|
|
3383
|
+
static a() {
|
|
3384
|
+
const a = new ($mol_wire_sync(A))();
|
|
3385
|
+
this.instances.push(a);
|
|
3386
|
+
$mol_wire_sync(this).b();
|
|
3387
|
+
}
|
|
3388
|
+
static b() { return Promise.resolve(); }
|
|
3389
|
+
}
|
|
3390
|
+
await $mol_wire_async(A).a();
|
|
3391
|
+
$mol_assert_equal(A.instances.length, 2);
|
|
3392
|
+
$mol_assert_equal(A.instances[0] instanceof A);
|
|
3393
|
+
$mol_assert_equal(A.instances[0], A.instances[1]);
|
|
3394
|
+
}
|
|
3344
3395
|
});
|
|
3345
3396
|
})($ || ($ = {}));
|
|
3346
3397
|
|
|
@@ -3420,9 +3471,19 @@ var $;
|
|
|
3420
3471
|
$.$mol_run_error = $mol_run_error;
|
|
3421
3472
|
const child_process = $node['child_process'];
|
|
3422
3473
|
$.$mol_run_spawn = child_process.spawn.bind(child_process);
|
|
3474
|
+
$.$mol_run_spawn_sync = child_process.spawnSync.bind(child_process);
|
|
3423
3475
|
function $mol_run_async({ dir, timeout, command, env }) {
|
|
3424
3476
|
const args_raw = typeof command === 'string' ? command.split(' ') : command;
|
|
3425
3477
|
const [app, ...args] = args_raw;
|
|
3478
|
+
if (!env?.MOL_RUN_ASYNC) {
|
|
3479
|
+
this.$mol_log3_come({
|
|
3480
|
+
place: '$mol_run_sync',
|
|
3481
|
+
message: 'Run',
|
|
3482
|
+
command: args_raw.join(' '),
|
|
3483
|
+
dir: $node.path.relative('', dir),
|
|
3484
|
+
});
|
|
3485
|
+
return this.$mol_run_spawn_sync(app, args, { shell: true, cwd: dir, env });
|
|
3486
|
+
}
|
|
3426
3487
|
const sub = this.$mol_run_spawn(app, args, {
|
|
3427
3488
|
shell: true,
|
|
3428
3489
|
cwd: dir,
|
|
@@ -3518,7 +3579,7 @@ var $;
|
|
|
3518
3579
|
});
|
|
3519
3580
|
let message = '';
|
|
3520
3581
|
try {
|
|
3521
|
-
const res = await $mol_wire_async(context_mock).$mol_run({ command: 'sleep 10', dir: '.', timeout: 10 });
|
|
3582
|
+
const res = await $mol_wire_async(context_mock).$mol_run({ command: 'sleep 10', dir: '.', timeout: 10, env: { 'MOL_RUN_ASYNC': '1' } });
|
|
3522
3583
|
}
|
|
3523
3584
|
catch (e) {
|
|
3524
3585
|
message = e.message;
|