mol_plot_all 1.2.570 → 1.2.571
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 +29 -29
- package/node.js +29 -29
- package/node.js.map +1 -1
- package/node.mjs +29 -29
- package/node.mjs.map +1 -1
- package/node.test.js +60 -356
- package/node.test.js.map +1 -1
- package/package.json +1 -1
- package/web.d.ts +29 -29
- package/web.js +29 -29
- package/web.js.map +1 -1
- package/web.mjs +29 -29
- package/web.mjs.map +1 -1
- package/web.test.js +30 -326
- package/web.test.js.map +1 -1
package/web.test.js
CHANGED
|
@@ -3176,343 +3176,45 @@ var $;
|
|
|
3176
3176
|
//hyoo/hyoo.ts
|
|
3177
3177
|
;
|
|
3178
3178
|
"use strict";
|
|
3179
|
-
//mol/data/value/value.ts
|
|
3180
|
-
;
|
|
3181
|
-
"use strict";
|
|
3182
|
-
//mol/type/merge/merge.ts
|
|
3183
|
-
;
|
|
3184
|
-
"use strict";
|
|
3185
|
-
//mol/type/merge/merge.test.ts
|
|
3186
|
-
;
|
|
3187
|
-
"use strict";
|
|
3188
|
-
//mol/type/partial/undefined/undefined.ts
|
|
3189
|
-
;
|
|
3190
|
-
"use strict";
|
|
3191
|
-
//mol/type/partial/undefined/undefined.test.ts
|
|
3192
|
-
;
|
|
3193
|
-
"use strict";
|
|
3194
|
-
var $;
|
|
3195
|
-
(function ($) {
|
|
3196
|
-
function $mol_data_setup(value, config) {
|
|
3197
|
-
return Object.assign(value, {
|
|
3198
|
-
config,
|
|
3199
|
-
Value: null
|
|
3200
|
-
});
|
|
3201
|
-
}
|
|
3202
|
-
$.$mol_data_setup = $mol_data_setup;
|
|
3203
|
-
})($ || ($ = {}));
|
|
3204
|
-
//mol/data/setup/setup.ts
|
|
3205
|
-
;
|
|
3206
|
-
"use strict";
|
|
3207
|
-
var $;
|
|
3208
|
-
(function ($) {
|
|
3209
|
-
$mol_test({
|
|
3210
|
-
'config by value'() {
|
|
3211
|
-
const N = $mol_data_setup((a) => a, 5);
|
|
3212
|
-
$mol_assert_equal(N.config, 5);
|
|
3213
|
-
},
|
|
3214
|
-
});
|
|
3215
|
-
})($ || ($ = {}));
|
|
3216
|
-
//mol/data/setup/setup.test.ts
|
|
3217
|
-
;
|
|
3218
|
-
"use strict";
|
|
3219
|
-
var $;
|
|
3220
|
-
(function ($) {
|
|
3221
|
-
function $mol_diff_path(...paths) {
|
|
3222
|
-
const limit = Math.min(...paths.map(path => path.length));
|
|
3223
|
-
lookup: for (var i = 0; i < limit; ++i) {
|
|
3224
|
-
const first = paths[0][i];
|
|
3225
|
-
for (let j = 1; j < paths.length; ++j) {
|
|
3226
|
-
if (paths[j][i] !== first)
|
|
3227
|
-
break lookup;
|
|
3228
|
-
}
|
|
3229
|
-
}
|
|
3230
|
-
return {
|
|
3231
|
-
prefix: paths[0].slice(0, i),
|
|
3232
|
-
suffix: paths.map(path => path.slice(i)),
|
|
3233
|
-
};
|
|
3234
|
-
}
|
|
3235
|
-
$.$mol_diff_path = $mol_diff_path;
|
|
3236
|
-
})($ || ($ = {}));
|
|
3237
|
-
//mol/diff/path/path.ts
|
|
3238
|
-
;
|
|
3239
|
-
"use strict";
|
|
3240
|
-
var $;
|
|
3241
|
-
(function ($) {
|
|
3242
|
-
$mol_test({
|
|
3243
|
-
'equal paths'() {
|
|
3244
|
-
const diff = $mol_diff_path([1, 2, 3, 4], [1, 2, 3, 4], [1, 2, 3, 4]);
|
|
3245
|
-
$mol_assert_like(diff, {
|
|
3246
|
-
prefix: [1, 2, 3, 4],
|
|
3247
|
-
suffix: [[], [], []],
|
|
3248
|
-
});
|
|
3249
|
-
},
|
|
3250
|
-
'different suffix'() {
|
|
3251
|
-
const diff = $mol_diff_path([1, 2, 3, 4], [1, 2, 3, 5], [1, 2, 5, 4]);
|
|
3252
|
-
$mol_assert_like(diff, {
|
|
3253
|
-
prefix: [1, 2],
|
|
3254
|
-
suffix: [[3, 4], [3, 5], [5, 4]],
|
|
3255
|
-
});
|
|
3256
|
-
},
|
|
3257
|
-
'one contains other'() {
|
|
3258
|
-
const diff = $mol_diff_path([1, 2, 3, 4], [1, 2], [1, 2, 3]);
|
|
3259
|
-
$mol_assert_like(diff, {
|
|
3260
|
-
prefix: [1, 2],
|
|
3261
|
-
suffix: [[3, 4], [], [3]],
|
|
3262
|
-
});
|
|
3263
|
-
},
|
|
3264
|
-
'fully different'() {
|
|
3265
|
-
const diff = $mol_diff_path([1, 2], [3, 4], [5, 6]);
|
|
3266
|
-
$mol_assert_like(diff, {
|
|
3267
|
-
prefix: [],
|
|
3268
|
-
suffix: [[1, 2], [3, 4], [5, 6]],
|
|
3269
|
-
});
|
|
3270
|
-
},
|
|
3271
|
-
});
|
|
3272
|
-
})($ || ($ = {}));
|
|
3273
|
-
//mol/diff/path/path.test.ts
|
|
3274
|
-
;
|
|
3275
|
-
"use strict";
|
|
3276
|
-
var $;
|
|
3277
|
-
(function ($) {
|
|
3278
|
-
class $mol_error_mix extends Error {
|
|
3279
|
-
errors;
|
|
3280
|
-
constructor(message, ...errors) {
|
|
3281
|
-
super(message);
|
|
3282
|
-
this.errors = errors;
|
|
3283
|
-
if (errors.length) {
|
|
3284
|
-
const stacks = [...errors.map(error => error.stack), this.stack];
|
|
3285
|
-
const diff = $mol_diff_path(...stacks.map(stack => {
|
|
3286
|
-
if (!stack)
|
|
3287
|
-
return [];
|
|
3288
|
-
return stack.split('\n').reverse();
|
|
3289
|
-
}));
|
|
3290
|
-
const head = diff.prefix.reverse().join('\n');
|
|
3291
|
-
const tails = diff.suffix.map(path => path.reverse().map(line => line.replace(/^(?!\s+at)/, '\tat (.) ')).join('\n')).join('\n\tat (.) -----\n');
|
|
3292
|
-
this.stack = `Error: ${this.constructor.name}\n\tat (.) /"""\\\n${tails}\n\tat (.) \\___/\n${head}`;
|
|
3293
|
-
this.message += errors.map(error => '\n' + error.message).join('');
|
|
3294
|
-
}
|
|
3295
|
-
}
|
|
3296
|
-
toJSON() {
|
|
3297
|
-
return this.message;
|
|
3298
|
-
}
|
|
3299
|
-
}
|
|
3300
|
-
$.$mol_error_mix = $mol_error_mix;
|
|
3301
|
-
})($ || ($ = {}));
|
|
3302
|
-
//mol/error/mix/mix.ts
|
|
3303
|
-
;
|
|
3304
|
-
"use strict";
|
|
3305
|
-
var $;
|
|
3306
|
-
(function ($) {
|
|
3307
|
-
class $mol_data_error extends $mol_error_mix {
|
|
3308
|
-
}
|
|
3309
|
-
$.$mol_data_error = $mol_data_error;
|
|
3310
|
-
})($ || ($ = {}));
|
|
3311
|
-
//mol/data/error/error.ts
|
|
3312
|
-
;
|
|
3313
|
-
"use strict";
|
|
3314
|
-
var $;
|
|
3315
|
-
(function ($) {
|
|
3316
|
-
$.$mol_data_number = (val) => {
|
|
3317
|
-
if (typeof val === 'number')
|
|
3318
|
-
return val;
|
|
3319
|
-
return $mol_fail(new $mol_data_error(`${val} is not a number`));
|
|
3320
|
-
};
|
|
3321
|
-
})($ || ($ = {}));
|
|
3322
|
-
//mol/data/number/number.ts
|
|
3323
|
-
;
|
|
3324
|
-
"use strict";
|
|
3325
|
-
var $;
|
|
3326
|
-
(function ($) {
|
|
3327
|
-
$mol_test({
|
|
3328
|
-
'Is number'() {
|
|
3329
|
-
$mol_data_number(0);
|
|
3330
|
-
},
|
|
3331
|
-
'Is not number'() {
|
|
3332
|
-
$mol_assert_fail(() => {
|
|
3333
|
-
$mol_data_number('x');
|
|
3334
|
-
}, 'x is not a number');
|
|
3335
|
-
},
|
|
3336
|
-
'Is object number'() {
|
|
3337
|
-
$mol_assert_fail(() => {
|
|
3338
|
-
$mol_data_number(new Number(''));
|
|
3339
|
-
}, '0 is not a number');
|
|
3340
|
-
},
|
|
3341
|
-
});
|
|
3342
|
-
})($ || ($ = {}));
|
|
3343
|
-
//mol/data/number/number.test.ts
|
|
3344
|
-
;
|
|
3345
|
-
"use strict";
|
|
3346
3179
|
var $;
|
|
3347
3180
|
(function ($) {
|
|
3348
|
-
|
|
3349
|
-
|
|
3350
|
-
|
|
3351
|
-
|
|
3352
|
-
|
|
3353
|
-
})($ || ($ = {}));
|
|
3354
|
-
//mol/data/string/string.ts
|
|
3355
|
-
;
|
|
3356
|
-
"use strict";
|
|
3357
|
-
var $;
|
|
3358
|
-
(function ($) {
|
|
3359
|
-
$mol_test({
|
|
3360
|
-
'Is string'() {
|
|
3361
|
-
$mol_data_string('');
|
|
3362
|
-
},
|
|
3363
|
-
'Is not string'() {
|
|
3364
|
-
$mol_assert_fail(() => {
|
|
3365
|
-
$mol_data_string(0);
|
|
3366
|
-
}, '0 is not a string');
|
|
3367
|
-
},
|
|
3368
|
-
'Is object string'() {
|
|
3369
|
-
$mol_assert_fail(() => {
|
|
3370
|
-
$mol_data_string(new String('x'));
|
|
3371
|
-
}, 'x is not a string');
|
|
3372
|
-
},
|
|
3373
|
-
});
|
|
3374
|
-
})($ || ($ = {}));
|
|
3375
|
-
//mol/data/string/string.test.ts
|
|
3376
|
-
;
|
|
3377
|
-
"use strict";
|
|
3378
|
-
var $;
|
|
3379
|
-
(function ($) {
|
|
3380
|
-
function $mol_data_record(sub) {
|
|
3381
|
-
return $mol_data_setup((val) => {
|
|
3382
|
-
let res = {};
|
|
3383
|
-
for (const field in sub) {
|
|
3384
|
-
try {
|
|
3385
|
-
res[field] = sub[field](val[field]);
|
|
3181
|
+
function $mol_huggingface_run(space, method, ...data) {
|
|
3182
|
+
while (true) {
|
|
3183
|
+
try {
|
|
3184
|
+
if (typeof method === 'number') {
|
|
3185
|
+
return $mol_wire_sync(this).$mol_huggingface_ws(space, method, ...data);
|
|
3386
3186
|
}
|
|
3387
|
-
|
|
3388
|
-
|
|
3389
|
-
return $mol_fail_hidden(error);
|
|
3390
|
-
error.message = `[${JSON.stringify(field)}] ${error.message}`;
|
|
3391
|
-
return $mol_fail(error);
|
|
3187
|
+
else {
|
|
3188
|
+
return this.$mol_huggingface_rest(space, method, ...data);
|
|
3392
3189
|
}
|
|
3393
3190
|
}
|
|
3394
|
-
|
|
3395
|
-
|
|
3396
|
-
}
|
|
3397
|
-
$.$mol_data_record = $mol_data_record;
|
|
3398
|
-
})($ || ($ = {}));
|
|
3399
|
-
//mol/data/record/record.ts
|
|
3400
|
-
;
|
|
3401
|
-
"use strict";
|
|
3402
|
-
var $;
|
|
3403
|
-
(function ($) {
|
|
3404
|
-
$mol_test({
|
|
3405
|
-
'Fit to record'() {
|
|
3406
|
-
const User = $mol_data_record({ age: $mol_data_number });
|
|
3407
|
-
User({ age: 0 });
|
|
3408
|
-
},
|
|
3409
|
-
'Extends record'() {
|
|
3410
|
-
const User = $mol_data_record({ age: $mol_data_number });
|
|
3411
|
-
User({ age: 0, name: 'Jin' });
|
|
3412
|
-
},
|
|
3413
|
-
'Shrinks record'() {
|
|
3414
|
-
$mol_assert_fail(() => {
|
|
3415
|
-
const User = $mol_data_record({ age: $mol_data_number, name: $mol_data_string });
|
|
3416
|
-
User({ age: 0 });
|
|
3417
|
-
}, '["name"] undefined is not a string');
|
|
3418
|
-
},
|
|
3419
|
-
'Shrinks deep record'() {
|
|
3420
|
-
$mol_assert_fail(() => {
|
|
3421
|
-
const User = $mol_data_record({ wife: $mol_data_record({ age: $mol_data_number }) });
|
|
3422
|
-
User({ wife: {} });
|
|
3423
|
-
}, '["wife"] ["age"] undefined is not a number');
|
|
3424
|
-
},
|
|
3425
|
-
});
|
|
3426
|
-
})($ || ($ = {}));
|
|
3427
|
-
//mol/data/record/record.test.ts
|
|
3428
|
-
;
|
|
3429
|
-
"use strict";
|
|
3430
|
-
var $;
|
|
3431
|
-
(function ($) {
|
|
3432
|
-
function $mol_data_array(sub) {
|
|
3433
|
-
return $mol_data_setup((val) => {
|
|
3434
|
-
if (!Array.isArray(val))
|
|
3435
|
-
return $mol_fail(new $mol_data_error(`${val} is not an array`));
|
|
3436
|
-
return val.map((item, index) => {
|
|
3437
|
-
try {
|
|
3438
|
-
return sub(item);
|
|
3439
|
-
}
|
|
3440
|
-
catch (error) {
|
|
3441
|
-
if (error instanceof Promise)
|
|
3442
|
-
return $mol_fail_hidden(error);
|
|
3443
|
-
error.message = `[${index}] ${error.message}`;
|
|
3444
|
-
return $mol_fail(error);
|
|
3445
|
-
}
|
|
3446
|
-
});
|
|
3447
|
-
}, sub);
|
|
3448
|
-
}
|
|
3449
|
-
$.$mol_data_array = $mol_data_array;
|
|
3450
|
-
})($ || ($ = {}));
|
|
3451
|
-
//mol/data/array/array.ts
|
|
3452
|
-
;
|
|
3453
|
-
"use strict";
|
|
3454
|
-
var $;
|
|
3455
|
-
(function ($) {
|
|
3456
|
-
$mol_test({
|
|
3457
|
-
'Is empty array'() {
|
|
3458
|
-
$mol_data_array($mol_data_number)([]);
|
|
3459
|
-
},
|
|
3460
|
-
'Is array'() {
|
|
3461
|
-
$mol_data_array($mol_data_number)([1, 2]);
|
|
3462
|
-
},
|
|
3463
|
-
'Is not array'() {
|
|
3464
|
-
$mol_assert_fail(() => {
|
|
3465
|
-
$mol_data_array($mol_data_number)({ [0]: 1, length: 1, map: () => { } });
|
|
3466
|
-
}, '[object Object] is not an array');
|
|
3467
|
-
},
|
|
3468
|
-
'Has wrong item'() {
|
|
3469
|
-
$mol_assert_fail(() => {
|
|
3470
|
-
$mol_data_array($mol_data_number)([1, '1']);
|
|
3471
|
-
}, '[1] 1 is not a number');
|
|
3472
|
-
},
|
|
3473
|
-
'Has wrong deep item'() {
|
|
3474
|
-
$mol_assert_fail(() => {
|
|
3475
|
-
$mol_data_array($mol_data_array($mol_data_number))([[], [0, 0, false]]);
|
|
3476
|
-
}, '[1] [2] false is not a number');
|
|
3477
|
-
},
|
|
3478
|
-
});
|
|
3479
|
-
})($ || ($ = {}));
|
|
3480
|
-
//mol/data/array/array.test.ts
|
|
3481
|
-
;
|
|
3482
|
-
"use strict";
|
|
3483
|
-
var $;
|
|
3484
|
-
(function ($) {
|
|
3485
|
-
const Response = $mol_data_record({
|
|
3486
|
-
data: $mol_data_array($mol_data_string)
|
|
3487
|
-
});
|
|
3488
|
-
function $mol_huggingface_run(space, method, ...data) {
|
|
3489
|
-
if (typeof method === 'number') {
|
|
3490
|
-
while (true) {
|
|
3491
|
-
try {
|
|
3492
|
-
return $mol_wire_sync(this).$mol_huggingface_async(space, method, ...data);
|
|
3493
|
-
}
|
|
3494
|
-
catch (error) {
|
|
3495
|
-
if ($mol_promise_like(error))
|
|
3496
|
-
$mol_fail_hidden(error);
|
|
3497
|
-
if (error instanceof Error && error.message === `Queue full`) {
|
|
3498
|
-
$mol_fail_log(error);
|
|
3499
|
-
continue;
|
|
3500
|
-
}
|
|
3191
|
+
catch (error) {
|
|
3192
|
+
if ($mol_promise_like(error))
|
|
3501
3193
|
$mol_fail_hidden(error);
|
|
3194
|
+
if (error instanceof Error && error.message === `Queue full`) {
|
|
3195
|
+
$mol_fail_log(error);
|
|
3196
|
+
continue;
|
|
3502
3197
|
}
|
|
3198
|
+
$mol_fail_hidden(error);
|
|
3503
3199
|
}
|
|
3504
3200
|
}
|
|
3505
|
-
|
|
3201
|
+
}
|
|
3202
|
+
$.$mol_huggingface_run = $mol_huggingface_run;
|
|
3203
|
+
function $mol_huggingface_rest(space, method, ...data) {
|
|
3204
|
+
const uri = `https://${space}.hf.space/run/${method}`;
|
|
3205
|
+
const response = $mol_fetch.json(uri, {
|
|
3506
3206
|
method: 'post',
|
|
3507
3207
|
headers: { "Content-Type": "application/json" },
|
|
3508
3208
|
body: JSON.stringify({ data }),
|
|
3509
3209
|
});
|
|
3510
|
-
|
|
3210
|
+
if ('error' in response) {
|
|
3211
|
+
$mol_fail(new Error(response.error ?? 'Unknown API error'));
|
|
3212
|
+
}
|
|
3213
|
+
return response.data;
|
|
3511
3214
|
}
|
|
3512
|
-
$.$
|
|
3513
|
-
function $
|
|
3215
|
+
$.$mol_huggingface_rest = $mol_huggingface_rest;
|
|
3216
|
+
function $mol_huggingface_ws(space, fn_index, ...data) {
|
|
3514
3217
|
const session_hash = $mol_guid();
|
|
3515
|
-
const fn_index = method;
|
|
3516
3218
|
const socket = new WebSocket(`wss://${space}.hf.space/queue/join`);
|
|
3517
3219
|
const promise = new Promise((done, fail) => {
|
|
3518
3220
|
socket.onclose = event => {
|
|
@@ -3520,7 +3222,7 @@ var $;
|
|
|
3520
3222
|
fail(new Error(event.reason));
|
|
3521
3223
|
};
|
|
3522
3224
|
socket.onerror = event => {
|
|
3523
|
-
fail(new Error(
|
|
3225
|
+
fail(new Error(`Socket error`));
|
|
3524
3226
|
};
|
|
3525
3227
|
socket.onmessage = event => {
|
|
3526
3228
|
const message = JSON.parse(event.data);
|
|
@@ -3538,10 +3240,10 @@ var $;
|
|
|
3538
3240
|
return done(message.output.data);
|
|
3539
3241
|
}
|
|
3540
3242
|
else {
|
|
3541
|
-
return fail(new Error(message.output.error ??
|
|
3243
|
+
return fail(new Error(message.output.error ?? `Unknown API error`));
|
|
3542
3244
|
}
|
|
3543
3245
|
default:
|
|
3544
|
-
fail(new Error(`Unknown message type ${message.msg}`));
|
|
3246
|
+
return fail(new Error(`Unknown message type: ${message.msg}`));
|
|
3545
3247
|
}
|
|
3546
3248
|
};
|
|
3547
3249
|
});
|
|
@@ -3549,7 +3251,7 @@ var $;
|
|
|
3549
3251
|
destructor: () => socket.close()
|
|
3550
3252
|
});
|
|
3551
3253
|
}
|
|
3552
|
-
$.$
|
|
3254
|
+
$.$mol_huggingface_ws = $mol_huggingface_ws;
|
|
3553
3255
|
})($ || ($ = {}));
|
|
3554
3256
|
//mol/huggingface/huggingface.ts
|
|
3555
3257
|
;
|
|
@@ -3557,6 +3259,8 @@ var $;
|
|
|
3557
3259
|
var $;
|
|
3558
3260
|
(function ($) {
|
|
3559
3261
|
function $hyoo_lingua_translate(lang, text) {
|
|
3262
|
+
if (!text.trim())
|
|
3263
|
+
return '';
|
|
3560
3264
|
const cache_key = `$hyoo_lingua_translate(${JSON.stringify(lang)},${JSON.stringify(text)})`;
|
|
3561
3265
|
const cached = this.$mol_state_local.value(cache_key);
|
|
3562
3266
|
if (cached)
|