mol_plot_all 1.2.553 → 1.2.555
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 +5 -3
- package/node.deps.json +1 -1
- package/node.js +6 -4
- package/node.js.map +1 -1
- package/node.mjs +6 -4
- package/node.mjs.map +1 -1
- package/node.test.js +582 -18
- package/node.test.js.map +1 -1
- package/package.json +1 -1
- package/web.d.ts +4 -2
- package/web.deps.json +1 -1
- package/web.js +6 -4
- package/web.js.map +1 -1
- package/web.mjs +6 -4
- package/web.mjs.map +1 -1
- package/web.test.js +403 -14
- package/web.test.js.map +1 -1
package/web.test.js
CHANGED
|
@@ -166,7 +166,7 @@ var $;
|
|
|
166
166
|
}
|
|
167
167
|
if (typeof Elem !== 'string') {
|
|
168
168
|
if ('prototype' in Elem) {
|
|
169
|
-
const view = node && node[Elem] || new Elem;
|
|
169
|
+
const view = node && node[String(Elem)] || new Elem;
|
|
170
170
|
Object.assign(view, props);
|
|
171
171
|
view[Symbol.toStringTag] = guid;
|
|
172
172
|
view.childNodes = childNodes;
|
|
@@ -174,7 +174,7 @@ var $;
|
|
|
174
174
|
view.ownerDocument = $.$mol_jsx_document;
|
|
175
175
|
view.className = (crumbs_self ? crumbs_self + ' ' : '') + (Elem['name'] || Elem);
|
|
176
176
|
node = view.valueOf();
|
|
177
|
-
node[Elem] = view;
|
|
177
|
+
node[String(Elem)] = view;
|
|
178
178
|
return node;
|
|
179
179
|
}
|
|
180
180
|
else {
|
|
@@ -3173,6 +3173,382 @@ var $;
|
|
|
3173
3173
|
//mol/file/file.web.ts
|
|
3174
3174
|
;
|
|
3175
3175
|
"use strict";
|
|
3176
|
+
//hyoo/hyoo.ts
|
|
3177
|
+
;
|
|
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
|
+
var $;
|
|
3347
|
+
(function ($) {
|
|
3348
|
+
$.$mol_data_string = (val) => {
|
|
3349
|
+
if (typeof val === 'string')
|
|
3350
|
+
return val;
|
|
3351
|
+
return $mol_fail(new $mol_data_error(`${val} is not a string`));
|
|
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]);
|
|
3386
|
+
}
|
|
3387
|
+
catch (error) {
|
|
3388
|
+
if (error instanceof Promise)
|
|
3389
|
+
return $mol_fail_hidden(error);
|
|
3390
|
+
error.message = `[${JSON.stringify(field)}] ${error.message}`;
|
|
3391
|
+
return $mol_fail(error);
|
|
3392
|
+
}
|
|
3393
|
+
}
|
|
3394
|
+
return res;
|
|
3395
|
+
}, sub);
|
|
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
|
+
return $mol_wire_sync(this).$mol_huggingface_async(space, method, ...data);
|
|
3491
|
+
}
|
|
3492
|
+
const response = $mol_fetch.json(`https://${space}.hf.space/run/${method}`, {
|
|
3493
|
+
method: 'post',
|
|
3494
|
+
headers: { "Content-Type": "application/json" },
|
|
3495
|
+
body: JSON.stringify({ data }),
|
|
3496
|
+
});
|
|
3497
|
+
return Response(response).data;
|
|
3498
|
+
}
|
|
3499
|
+
$.$mol_huggingface_run = $mol_huggingface_run;
|
|
3500
|
+
function $mol_huggingface_async(space, method, ...data) {
|
|
3501
|
+
const session_hash = $mol_guid();
|
|
3502
|
+
const fn_index = method;
|
|
3503
|
+
const socket = new WebSocket(`wss://${space}.hf.space/queue/join`);
|
|
3504
|
+
const promise = new Promise((done, fail) => {
|
|
3505
|
+
socket.onclose = event => {
|
|
3506
|
+
if (event.reason)
|
|
3507
|
+
fail(new Error(event.reason));
|
|
3508
|
+
};
|
|
3509
|
+
socket.onerror = event => {
|
|
3510
|
+
fail(new Error('Scoket error'));
|
|
3511
|
+
};
|
|
3512
|
+
socket.onmessage = event => {
|
|
3513
|
+
const message = JSON.parse(event.data);
|
|
3514
|
+
switch (message.msg) {
|
|
3515
|
+
case 'send_hash':
|
|
3516
|
+
return socket.send(JSON.stringify({ session_hash, fn_index }));
|
|
3517
|
+
case 'estimation': return;
|
|
3518
|
+
case 'send_data':
|
|
3519
|
+
return socket.send(JSON.stringify({ session_hash, fn_index, data }));
|
|
3520
|
+
case 'process_starts': return;
|
|
3521
|
+
case 'process_completed':
|
|
3522
|
+
if (message.success) {
|
|
3523
|
+
return done(message.output.data);
|
|
3524
|
+
}
|
|
3525
|
+
else {
|
|
3526
|
+
return fail(new Error(message.output.error ?? 'Unknown api error'));
|
|
3527
|
+
}
|
|
3528
|
+
default:
|
|
3529
|
+
fail(new Error(`Unknown message type ${message.msg}`));
|
|
3530
|
+
}
|
|
3531
|
+
};
|
|
3532
|
+
});
|
|
3533
|
+
return Object.assign(promise, {
|
|
3534
|
+
destructor: () => socket.close()
|
|
3535
|
+
});
|
|
3536
|
+
}
|
|
3537
|
+
$.$mol_huggingface_async = $mol_huggingface_async;
|
|
3538
|
+
})($ || ($ = {}));
|
|
3539
|
+
//mol/huggingface/huggingface.ts
|
|
3540
|
+
;
|
|
3541
|
+
"use strict";
|
|
3542
|
+
var $;
|
|
3543
|
+
(function ($) {
|
|
3544
|
+
function $hyoo_lingua_translate(lang, text) {
|
|
3545
|
+
return this.$mol_huggingface_run('hyoo-translate', 0, lang, text)[0];
|
|
3546
|
+
}
|
|
3547
|
+
$.$hyoo_lingua_translate = $hyoo_lingua_translate;
|
|
3548
|
+
})($ || ($ = {}));
|
|
3549
|
+
//hyoo/lingua/translate/translate.ts
|
|
3550
|
+
;
|
|
3551
|
+
"use strict";
|
|
3176
3552
|
var $;
|
|
3177
3553
|
(function ($) {
|
|
3178
3554
|
class $mol_locale extends $mol_object {
|
|
@@ -3192,22 +3568,35 @@ var $;
|
|
|
3192
3568
|
return this.source(lang).valueOf();
|
|
3193
3569
|
}
|
|
3194
3570
|
catch (error) {
|
|
3195
|
-
if (error
|
|
3196
|
-
|
|
3197
|
-
|
|
3198
|
-
|
|
3199
|
-
|
|
3200
|
-
|
|
3571
|
+
if ($mol_fail_catch(error)) {
|
|
3572
|
+
const def = this.lang_default();
|
|
3573
|
+
if (lang === def)
|
|
3574
|
+
throw error;
|
|
3575
|
+
return {};
|
|
3576
|
+
}
|
|
3201
3577
|
}
|
|
3202
3578
|
}
|
|
3203
3579
|
static text(key) {
|
|
3204
|
-
|
|
3205
|
-
|
|
3206
|
-
|
|
3207
|
-
|
|
3208
|
-
|
|
3580
|
+
const lang = this.lang();
|
|
3581
|
+
const target = this.texts(lang)[key];
|
|
3582
|
+
if (target)
|
|
3583
|
+
return target;
|
|
3584
|
+
this.warn(key);
|
|
3585
|
+
const en = this.texts('en')[key];
|
|
3586
|
+
if (!en)
|
|
3587
|
+
return key;
|
|
3588
|
+
const cache_key = `$mol_locale.text(${JSON.stringify(key)})`;
|
|
3589
|
+
const cached = this.$.$mol_state_local.value(cache_key);
|
|
3590
|
+
if (cached)
|
|
3591
|
+
return cached;
|
|
3592
|
+
try {
|
|
3593
|
+
const translated = $mol_wire_sync($hyoo_lingua_translate).call(this.$, lang, en);
|
|
3594
|
+
return this.$.$mol_state_local.value(cache_key, translated);
|
|
3595
|
+
}
|
|
3596
|
+
catch (error) {
|
|
3597
|
+
$mol_fail_log(error);
|
|
3209
3598
|
}
|
|
3210
|
-
return
|
|
3599
|
+
return en;
|
|
3211
3600
|
}
|
|
3212
3601
|
static warn(key) {
|
|
3213
3602
|
console.warn(`Not translated to "${this.lang()}": ${key}`);
|