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/node.test.js
CHANGED
|
@@ -152,6 +152,7 @@ var $;
|
|
|
152
152
|
(function ($) {
|
|
153
153
|
class $mol_object2 {
|
|
154
154
|
static $ = $;
|
|
155
|
+
[Symbol.toStringTag];
|
|
155
156
|
[$mol_ambient_ref] = null;
|
|
156
157
|
get $() {
|
|
157
158
|
if (this[$mol_ambient_ref])
|
|
@@ -320,7 +321,7 @@ var $;
|
|
|
320
321
|
"use strict";
|
|
321
322
|
var $;
|
|
322
323
|
(function ($) {
|
|
323
|
-
$['devtoolsFormatters']
|
|
324
|
+
$['devtoolsFormatters'] ||= [];
|
|
324
325
|
function $mol_dev_format_register(config) {
|
|
325
326
|
$['devtoolsFormatters'].push(config);
|
|
326
327
|
}
|
|
@@ -632,6 +633,7 @@ var $;
|
|
|
632
633
|
}
|
|
633
634
|
}
|
|
634
635
|
}
|
|
636
|
+
[Symbol.toStringTag];
|
|
635
637
|
cache = undefined;
|
|
636
638
|
get args() {
|
|
637
639
|
return this.data.slice(0, this.pub_from);
|
|
@@ -900,9 +902,9 @@ var $;
|
|
|
900
902
|
if (left instanceof Date)
|
|
901
903
|
return Object.is(left.valueOf(), right['valueOf']());
|
|
902
904
|
if (left instanceof RegExp)
|
|
903
|
-
return left.source === right
|
|
905
|
+
return left.source === right.source && left.flags === right.flags;
|
|
904
906
|
if (left instanceof Error)
|
|
905
|
-
return left.message === right
|
|
907
|
+
return left.message === right.message && left.stack === right.stack;
|
|
906
908
|
let left_cache = $.$mol_compare_deep_cache.get(left);
|
|
907
909
|
if (left_cache) {
|
|
908
910
|
const right_cache = left_cache.get(right);
|
|
@@ -2121,7 +2123,7 @@ var $;
|
|
|
2121
2123
|
var $;
|
|
2122
2124
|
(function ($) {
|
|
2123
2125
|
function $mol_const(value) {
|
|
2124
|
-
|
|
2126
|
+
const getter = (() => value);
|
|
2125
2127
|
getter['()'] = value;
|
|
2126
2128
|
getter[Symbol.toStringTag] = value;
|
|
2127
2129
|
return getter;
|
|
@@ -6337,7 +6339,7 @@ var $;
|
|
|
6337
6339
|
}
|
|
6338
6340
|
if (typeof Elem !== 'string') {
|
|
6339
6341
|
if ('prototype' in Elem) {
|
|
6340
|
-
const view = node && node[Elem] || new Elem;
|
|
6342
|
+
const view = node && node[String(Elem)] || new Elem;
|
|
6341
6343
|
Object.assign(view, props);
|
|
6342
6344
|
view[Symbol.toStringTag] = guid;
|
|
6343
6345
|
view.childNodes = childNodes;
|
|
@@ -6345,7 +6347,7 @@ var $;
|
|
|
6345
6347
|
view.ownerDocument = $.$mol_jsx_document;
|
|
6346
6348
|
view.className = (crumbs_self ? crumbs_self + ' ' : '') + (Elem['name'] || Elem);
|
|
6347
6349
|
node = view.valueOf();
|
|
6348
|
-
node[Elem] = view;
|
|
6350
|
+
node[String(Elem)] = view;
|
|
6349
6351
|
return node;
|
|
6350
6352
|
}
|
|
6351
6353
|
else {
|
|
@@ -9393,6 +9395,555 @@ var $;
|
|
|
9393
9395
|
//mol/file/file.node.ts
|
|
9394
9396
|
;
|
|
9395
9397
|
"use strict";
|
|
9398
|
+
//hyoo/hyoo.ts
|
|
9399
|
+
;
|
|
9400
|
+
"use strict";
|
|
9401
|
+
//mol/data/value/value.ts
|
|
9402
|
+
;
|
|
9403
|
+
"use strict";
|
|
9404
|
+
//mol/type/merge/merge.ts
|
|
9405
|
+
;
|
|
9406
|
+
"use strict";
|
|
9407
|
+
//mol/type/merge/merge.test.ts
|
|
9408
|
+
;
|
|
9409
|
+
"use strict";
|
|
9410
|
+
//mol/type/partial/undefined/undefined.ts
|
|
9411
|
+
;
|
|
9412
|
+
"use strict";
|
|
9413
|
+
//mol/type/partial/undefined/undefined.test.ts
|
|
9414
|
+
;
|
|
9415
|
+
"use strict";
|
|
9416
|
+
var $;
|
|
9417
|
+
(function ($) {
|
|
9418
|
+
function $mol_data_setup(value, config) {
|
|
9419
|
+
return Object.assign(value, {
|
|
9420
|
+
config,
|
|
9421
|
+
Value: null
|
|
9422
|
+
});
|
|
9423
|
+
}
|
|
9424
|
+
$.$mol_data_setup = $mol_data_setup;
|
|
9425
|
+
})($ || ($ = {}));
|
|
9426
|
+
//mol/data/setup/setup.ts
|
|
9427
|
+
;
|
|
9428
|
+
"use strict";
|
|
9429
|
+
var $;
|
|
9430
|
+
(function ($) {
|
|
9431
|
+
$mol_test({
|
|
9432
|
+
'config by value'() {
|
|
9433
|
+
const N = $mol_data_setup((a) => a, 5);
|
|
9434
|
+
$mol_assert_equal(N.config, 5);
|
|
9435
|
+
},
|
|
9436
|
+
});
|
|
9437
|
+
})($ || ($ = {}));
|
|
9438
|
+
//mol/data/setup/setup.test.ts
|
|
9439
|
+
;
|
|
9440
|
+
"use strict";
|
|
9441
|
+
var $;
|
|
9442
|
+
(function ($) {
|
|
9443
|
+
function $mol_diff_path(...paths) {
|
|
9444
|
+
const limit = Math.min(...paths.map(path => path.length));
|
|
9445
|
+
lookup: for (var i = 0; i < limit; ++i) {
|
|
9446
|
+
const first = paths[0][i];
|
|
9447
|
+
for (let j = 1; j < paths.length; ++j) {
|
|
9448
|
+
if (paths[j][i] !== first)
|
|
9449
|
+
break lookup;
|
|
9450
|
+
}
|
|
9451
|
+
}
|
|
9452
|
+
return {
|
|
9453
|
+
prefix: paths[0].slice(0, i),
|
|
9454
|
+
suffix: paths.map(path => path.slice(i)),
|
|
9455
|
+
};
|
|
9456
|
+
}
|
|
9457
|
+
$.$mol_diff_path = $mol_diff_path;
|
|
9458
|
+
})($ || ($ = {}));
|
|
9459
|
+
//mol/diff/path/path.ts
|
|
9460
|
+
;
|
|
9461
|
+
"use strict";
|
|
9462
|
+
var $;
|
|
9463
|
+
(function ($) {
|
|
9464
|
+
$mol_test({
|
|
9465
|
+
'equal paths'() {
|
|
9466
|
+
const diff = $mol_diff_path([1, 2, 3, 4], [1, 2, 3, 4], [1, 2, 3, 4]);
|
|
9467
|
+
$mol_assert_like(diff, {
|
|
9468
|
+
prefix: [1, 2, 3, 4],
|
|
9469
|
+
suffix: [[], [], []],
|
|
9470
|
+
});
|
|
9471
|
+
},
|
|
9472
|
+
'different suffix'() {
|
|
9473
|
+
const diff = $mol_diff_path([1, 2, 3, 4], [1, 2, 3, 5], [1, 2, 5, 4]);
|
|
9474
|
+
$mol_assert_like(diff, {
|
|
9475
|
+
prefix: [1, 2],
|
|
9476
|
+
suffix: [[3, 4], [3, 5], [5, 4]],
|
|
9477
|
+
});
|
|
9478
|
+
},
|
|
9479
|
+
'one contains other'() {
|
|
9480
|
+
const diff = $mol_diff_path([1, 2, 3, 4], [1, 2], [1, 2, 3]);
|
|
9481
|
+
$mol_assert_like(diff, {
|
|
9482
|
+
prefix: [1, 2],
|
|
9483
|
+
suffix: [[3, 4], [], [3]],
|
|
9484
|
+
});
|
|
9485
|
+
},
|
|
9486
|
+
'fully different'() {
|
|
9487
|
+
const diff = $mol_diff_path([1, 2], [3, 4], [5, 6]);
|
|
9488
|
+
$mol_assert_like(diff, {
|
|
9489
|
+
prefix: [],
|
|
9490
|
+
suffix: [[1, 2], [3, 4], [5, 6]],
|
|
9491
|
+
});
|
|
9492
|
+
},
|
|
9493
|
+
});
|
|
9494
|
+
})($ || ($ = {}));
|
|
9495
|
+
//mol/diff/path/path.test.ts
|
|
9496
|
+
;
|
|
9497
|
+
"use strict";
|
|
9498
|
+
var $;
|
|
9499
|
+
(function ($) {
|
|
9500
|
+
class $mol_error_mix extends Error {
|
|
9501
|
+
errors;
|
|
9502
|
+
constructor(message, ...errors) {
|
|
9503
|
+
super(message);
|
|
9504
|
+
this.errors = errors;
|
|
9505
|
+
if (errors.length) {
|
|
9506
|
+
const stacks = [...errors.map(error => error.stack), this.stack];
|
|
9507
|
+
const diff = $mol_diff_path(...stacks.map(stack => {
|
|
9508
|
+
if (!stack)
|
|
9509
|
+
return [];
|
|
9510
|
+
return stack.split('\n').reverse();
|
|
9511
|
+
}));
|
|
9512
|
+
const head = diff.prefix.reverse().join('\n');
|
|
9513
|
+
const tails = diff.suffix.map(path => path.reverse().map(line => line.replace(/^(?!\s+at)/, '\tat (.) ')).join('\n')).join('\n\tat (.) -----\n');
|
|
9514
|
+
this.stack = `Error: ${this.constructor.name}\n\tat (.) /"""\\\n${tails}\n\tat (.) \\___/\n${head}`;
|
|
9515
|
+
this.message += errors.map(error => '\n' + error.message).join('');
|
|
9516
|
+
}
|
|
9517
|
+
}
|
|
9518
|
+
toJSON() {
|
|
9519
|
+
return this.message;
|
|
9520
|
+
}
|
|
9521
|
+
}
|
|
9522
|
+
$.$mol_error_mix = $mol_error_mix;
|
|
9523
|
+
})($ || ($ = {}));
|
|
9524
|
+
//mol/error/mix/mix.ts
|
|
9525
|
+
;
|
|
9526
|
+
"use strict";
|
|
9527
|
+
var $;
|
|
9528
|
+
(function ($) {
|
|
9529
|
+
class $mol_data_error extends $mol_error_mix {
|
|
9530
|
+
}
|
|
9531
|
+
$.$mol_data_error = $mol_data_error;
|
|
9532
|
+
})($ || ($ = {}));
|
|
9533
|
+
//mol/data/error/error.ts
|
|
9534
|
+
;
|
|
9535
|
+
"use strict";
|
|
9536
|
+
var $;
|
|
9537
|
+
(function ($) {
|
|
9538
|
+
$.$mol_data_number = (val) => {
|
|
9539
|
+
if (typeof val === 'number')
|
|
9540
|
+
return val;
|
|
9541
|
+
return $mol_fail(new $mol_data_error(`${val} is not a number`));
|
|
9542
|
+
};
|
|
9543
|
+
})($ || ($ = {}));
|
|
9544
|
+
//mol/data/number/number.ts
|
|
9545
|
+
;
|
|
9546
|
+
"use strict";
|
|
9547
|
+
var $;
|
|
9548
|
+
(function ($) {
|
|
9549
|
+
$mol_test({
|
|
9550
|
+
'Is number'() {
|
|
9551
|
+
$mol_data_number(0);
|
|
9552
|
+
},
|
|
9553
|
+
'Is not number'() {
|
|
9554
|
+
$mol_assert_fail(() => {
|
|
9555
|
+
$mol_data_number('x');
|
|
9556
|
+
}, 'x is not a number');
|
|
9557
|
+
},
|
|
9558
|
+
'Is object number'() {
|
|
9559
|
+
$mol_assert_fail(() => {
|
|
9560
|
+
$mol_data_number(new Number(''));
|
|
9561
|
+
}, '0 is not a number');
|
|
9562
|
+
},
|
|
9563
|
+
});
|
|
9564
|
+
})($ || ($ = {}));
|
|
9565
|
+
//mol/data/number/number.test.ts
|
|
9566
|
+
;
|
|
9567
|
+
"use strict";
|
|
9568
|
+
var $;
|
|
9569
|
+
(function ($) {
|
|
9570
|
+
$.$mol_data_string = (val) => {
|
|
9571
|
+
if (typeof val === 'string')
|
|
9572
|
+
return val;
|
|
9573
|
+
return $mol_fail(new $mol_data_error(`${val} is not a string`));
|
|
9574
|
+
};
|
|
9575
|
+
})($ || ($ = {}));
|
|
9576
|
+
//mol/data/string/string.ts
|
|
9577
|
+
;
|
|
9578
|
+
"use strict";
|
|
9579
|
+
var $;
|
|
9580
|
+
(function ($) {
|
|
9581
|
+
$mol_test({
|
|
9582
|
+
'Is string'() {
|
|
9583
|
+
$mol_data_string('');
|
|
9584
|
+
},
|
|
9585
|
+
'Is not string'() {
|
|
9586
|
+
$mol_assert_fail(() => {
|
|
9587
|
+
$mol_data_string(0);
|
|
9588
|
+
}, '0 is not a string');
|
|
9589
|
+
},
|
|
9590
|
+
'Is object string'() {
|
|
9591
|
+
$mol_assert_fail(() => {
|
|
9592
|
+
$mol_data_string(new String('x'));
|
|
9593
|
+
}, 'x is not a string');
|
|
9594
|
+
},
|
|
9595
|
+
});
|
|
9596
|
+
})($ || ($ = {}));
|
|
9597
|
+
//mol/data/string/string.test.ts
|
|
9598
|
+
;
|
|
9599
|
+
"use strict";
|
|
9600
|
+
var $;
|
|
9601
|
+
(function ($) {
|
|
9602
|
+
function $mol_data_record(sub) {
|
|
9603
|
+
return $mol_data_setup((val) => {
|
|
9604
|
+
let res = {};
|
|
9605
|
+
for (const field in sub) {
|
|
9606
|
+
try {
|
|
9607
|
+
res[field] = sub[field](val[field]);
|
|
9608
|
+
}
|
|
9609
|
+
catch (error) {
|
|
9610
|
+
if (error instanceof Promise)
|
|
9611
|
+
return $mol_fail_hidden(error);
|
|
9612
|
+
error.message = `[${JSON.stringify(field)}] ${error.message}`;
|
|
9613
|
+
return $mol_fail(error);
|
|
9614
|
+
}
|
|
9615
|
+
}
|
|
9616
|
+
return res;
|
|
9617
|
+
}, sub);
|
|
9618
|
+
}
|
|
9619
|
+
$.$mol_data_record = $mol_data_record;
|
|
9620
|
+
})($ || ($ = {}));
|
|
9621
|
+
//mol/data/record/record.ts
|
|
9622
|
+
;
|
|
9623
|
+
"use strict";
|
|
9624
|
+
var $;
|
|
9625
|
+
(function ($) {
|
|
9626
|
+
$mol_test({
|
|
9627
|
+
'Fit to record'() {
|
|
9628
|
+
const User = $mol_data_record({ age: $mol_data_number });
|
|
9629
|
+
User({ age: 0 });
|
|
9630
|
+
},
|
|
9631
|
+
'Extends record'() {
|
|
9632
|
+
const User = $mol_data_record({ age: $mol_data_number });
|
|
9633
|
+
User({ age: 0, name: 'Jin' });
|
|
9634
|
+
},
|
|
9635
|
+
'Shrinks record'() {
|
|
9636
|
+
$mol_assert_fail(() => {
|
|
9637
|
+
const User = $mol_data_record({ age: $mol_data_number, name: $mol_data_string });
|
|
9638
|
+
User({ age: 0 });
|
|
9639
|
+
}, '["name"] undefined is not a string');
|
|
9640
|
+
},
|
|
9641
|
+
'Shrinks deep record'() {
|
|
9642
|
+
$mol_assert_fail(() => {
|
|
9643
|
+
const User = $mol_data_record({ wife: $mol_data_record({ age: $mol_data_number }) });
|
|
9644
|
+
User({ wife: {} });
|
|
9645
|
+
}, '["wife"] ["age"] undefined is not a number');
|
|
9646
|
+
},
|
|
9647
|
+
});
|
|
9648
|
+
})($ || ($ = {}));
|
|
9649
|
+
//mol/data/record/record.test.ts
|
|
9650
|
+
;
|
|
9651
|
+
"use strict";
|
|
9652
|
+
var $;
|
|
9653
|
+
(function ($) {
|
|
9654
|
+
function $mol_data_array(sub) {
|
|
9655
|
+
return $mol_data_setup((val) => {
|
|
9656
|
+
if (!Array.isArray(val))
|
|
9657
|
+
return $mol_fail(new $mol_data_error(`${val} is not an array`));
|
|
9658
|
+
return val.map((item, index) => {
|
|
9659
|
+
try {
|
|
9660
|
+
return sub(item);
|
|
9661
|
+
}
|
|
9662
|
+
catch (error) {
|
|
9663
|
+
if (error instanceof Promise)
|
|
9664
|
+
return $mol_fail_hidden(error);
|
|
9665
|
+
error.message = `[${index}] ${error.message}`;
|
|
9666
|
+
return $mol_fail(error);
|
|
9667
|
+
}
|
|
9668
|
+
});
|
|
9669
|
+
}, sub);
|
|
9670
|
+
}
|
|
9671
|
+
$.$mol_data_array = $mol_data_array;
|
|
9672
|
+
})($ || ($ = {}));
|
|
9673
|
+
//mol/data/array/array.ts
|
|
9674
|
+
;
|
|
9675
|
+
"use strict";
|
|
9676
|
+
var $;
|
|
9677
|
+
(function ($) {
|
|
9678
|
+
$mol_test({
|
|
9679
|
+
'Is empty array'() {
|
|
9680
|
+
$mol_data_array($mol_data_number)([]);
|
|
9681
|
+
},
|
|
9682
|
+
'Is array'() {
|
|
9683
|
+
$mol_data_array($mol_data_number)([1, 2]);
|
|
9684
|
+
},
|
|
9685
|
+
'Is not array'() {
|
|
9686
|
+
$mol_assert_fail(() => {
|
|
9687
|
+
$mol_data_array($mol_data_number)({ [0]: 1, length: 1, map: () => { } });
|
|
9688
|
+
}, '[object Object] is not an array');
|
|
9689
|
+
},
|
|
9690
|
+
'Has wrong item'() {
|
|
9691
|
+
$mol_assert_fail(() => {
|
|
9692
|
+
$mol_data_array($mol_data_number)([1, '1']);
|
|
9693
|
+
}, '[1] 1 is not a number');
|
|
9694
|
+
},
|
|
9695
|
+
'Has wrong deep item'() {
|
|
9696
|
+
$mol_assert_fail(() => {
|
|
9697
|
+
$mol_data_array($mol_data_array($mol_data_number))([[], [0, 0, false]]);
|
|
9698
|
+
}, '[1] [2] false is not a number');
|
|
9699
|
+
},
|
|
9700
|
+
});
|
|
9701
|
+
})($ || ($ = {}));
|
|
9702
|
+
//mol/data/array/array.test.ts
|
|
9703
|
+
;
|
|
9704
|
+
"use strict";
|
|
9705
|
+
var $;
|
|
9706
|
+
(function ($) {
|
|
9707
|
+
$.$mol_action = $mol_wire_method;
|
|
9708
|
+
})($ || ($ = {}));
|
|
9709
|
+
//mol/action/action.ts
|
|
9710
|
+
;
|
|
9711
|
+
"use strict";
|
|
9712
|
+
var $;
|
|
9713
|
+
(function ($) {
|
|
9714
|
+
function $mol_dom_parse(text, type = 'application/xhtml+xml') {
|
|
9715
|
+
const parser = new $mol_dom_context.DOMParser();
|
|
9716
|
+
const doc = parser.parseFromString(text, type);
|
|
9717
|
+
const error = doc.getElementsByTagName('parsererror');
|
|
9718
|
+
if (error.length)
|
|
9719
|
+
throw new Error(error[0].textContent);
|
|
9720
|
+
return doc;
|
|
9721
|
+
}
|
|
9722
|
+
$.$mol_dom_parse = $mol_dom_parse;
|
|
9723
|
+
})($ || ($ = {}));
|
|
9724
|
+
//mol/dom/parse/parse.ts
|
|
9725
|
+
;
|
|
9726
|
+
"use strict";
|
|
9727
|
+
var $;
|
|
9728
|
+
(function ($) {
|
|
9729
|
+
class $mol_fetch_response extends $mol_object2 {
|
|
9730
|
+
native;
|
|
9731
|
+
constructor(native) {
|
|
9732
|
+
super();
|
|
9733
|
+
this.native = native;
|
|
9734
|
+
}
|
|
9735
|
+
status() {
|
|
9736
|
+
const types = ['unknown', 'inform', 'success', 'redirect', 'wrong', 'failed'];
|
|
9737
|
+
return types[Math.floor(this.native.status / 100)];
|
|
9738
|
+
}
|
|
9739
|
+
code() {
|
|
9740
|
+
return this.native.status;
|
|
9741
|
+
}
|
|
9742
|
+
message() {
|
|
9743
|
+
return this.native.statusText || `HTTP Error ${this.code()}`;
|
|
9744
|
+
}
|
|
9745
|
+
headers() {
|
|
9746
|
+
return this.native.headers;
|
|
9747
|
+
}
|
|
9748
|
+
mime() {
|
|
9749
|
+
return this.headers().get('content-type');
|
|
9750
|
+
}
|
|
9751
|
+
stream() {
|
|
9752
|
+
return this.native.body;
|
|
9753
|
+
}
|
|
9754
|
+
text() {
|
|
9755
|
+
const buffer = this.buffer();
|
|
9756
|
+
const native = this.native;
|
|
9757
|
+
const mime = native.headers.get('content-type') || '';
|
|
9758
|
+
const [, charset] = /charset=(.*)/.exec(mime) || [, 'utf-8'];
|
|
9759
|
+
const decoder = new TextDecoder(charset);
|
|
9760
|
+
return decoder.decode(buffer);
|
|
9761
|
+
}
|
|
9762
|
+
json() {
|
|
9763
|
+
return $mol_wire_sync(this.native).json();
|
|
9764
|
+
}
|
|
9765
|
+
buffer() {
|
|
9766
|
+
return $mol_wire_sync(this.native).arrayBuffer();
|
|
9767
|
+
}
|
|
9768
|
+
xml() {
|
|
9769
|
+
return $mol_dom_parse(this.text(), 'application/xml');
|
|
9770
|
+
}
|
|
9771
|
+
xhtml() {
|
|
9772
|
+
return $mol_dom_parse(this.text(), 'application/xhtml+xml');
|
|
9773
|
+
}
|
|
9774
|
+
html() {
|
|
9775
|
+
return $mol_dom_parse(this.text(), 'text/html');
|
|
9776
|
+
}
|
|
9777
|
+
}
|
|
9778
|
+
__decorate([
|
|
9779
|
+
$mol_action
|
|
9780
|
+
], $mol_fetch_response.prototype, "stream", null);
|
|
9781
|
+
__decorate([
|
|
9782
|
+
$mol_action
|
|
9783
|
+
], $mol_fetch_response.prototype, "text", null);
|
|
9784
|
+
__decorate([
|
|
9785
|
+
$mol_action
|
|
9786
|
+
], $mol_fetch_response.prototype, "buffer", null);
|
|
9787
|
+
__decorate([
|
|
9788
|
+
$mol_action
|
|
9789
|
+
], $mol_fetch_response.prototype, "xml", null);
|
|
9790
|
+
__decorate([
|
|
9791
|
+
$mol_action
|
|
9792
|
+
], $mol_fetch_response.prototype, "xhtml", null);
|
|
9793
|
+
__decorate([
|
|
9794
|
+
$mol_action
|
|
9795
|
+
], $mol_fetch_response.prototype, "html", null);
|
|
9796
|
+
$.$mol_fetch_response = $mol_fetch_response;
|
|
9797
|
+
class $mol_fetch extends $mol_object2 {
|
|
9798
|
+
static request(input, init = {}) {
|
|
9799
|
+
const native = globalThis.fetch ?? $node['undici'].fetch;
|
|
9800
|
+
const controller = new AbortController();
|
|
9801
|
+
let done = false;
|
|
9802
|
+
const promise = native(input, {
|
|
9803
|
+
...init,
|
|
9804
|
+
signal: controller.signal,
|
|
9805
|
+
}).finally(() => {
|
|
9806
|
+
done = true;
|
|
9807
|
+
});
|
|
9808
|
+
return Object.assign(promise, {
|
|
9809
|
+
destructor: () => {
|
|
9810
|
+
if (!done && !controller.signal.aborted)
|
|
9811
|
+
controller.abort();
|
|
9812
|
+
},
|
|
9813
|
+
});
|
|
9814
|
+
}
|
|
9815
|
+
static response(input, init) {
|
|
9816
|
+
return new $mol_fetch_response($mol_wire_sync(this).request(input, init));
|
|
9817
|
+
}
|
|
9818
|
+
static success(input, init) {
|
|
9819
|
+
const response = this.response(input, init);
|
|
9820
|
+
if (response.status() === 'success')
|
|
9821
|
+
return response;
|
|
9822
|
+
throw new Error(response.message());
|
|
9823
|
+
}
|
|
9824
|
+
static stream(input, init) {
|
|
9825
|
+
return this.success(input, init).stream();
|
|
9826
|
+
}
|
|
9827
|
+
static text(input, init) {
|
|
9828
|
+
return this.success(input, init).text();
|
|
9829
|
+
}
|
|
9830
|
+
static json(input, init) {
|
|
9831
|
+
return this.success(input, init).json();
|
|
9832
|
+
}
|
|
9833
|
+
static buffer(input, init) {
|
|
9834
|
+
return this.success(input, init).buffer();
|
|
9835
|
+
}
|
|
9836
|
+
static xml(input, init) {
|
|
9837
|
+
return this.success(input, init).xml();
|
|
9838
|
+
}
|
|
9839
|
+
static xhtml(input, init) {
|
|
9840
|
+
return this.success(input, init).xhtml();
|
|
9841
|
+
}
|
|
9842
|
+
static html(input, init) {
|
|
9843
|
+
return this.success(input, init).html();
|
|
9844
|
+
}
|
|
9845
|
+
}
|
|
9846
|
+
__decorate([
|
|
9847
|
+
$mol_action
|
|
9848
|
+
], $mol_fetch, "response", null);
|
|
9849
|
+
__decorate([
|
|
9850
|
+
$mol_action
|
|
9851
|
+
], $mol_fetch, "success", null);
|
|
9852
|
+
__decorate([
|
|
9853
|
+
$mol_action
|
|
9854
|
+
], $mol_fetch, "stream", null);
|
|
9855
|
+
__decorate([
|
|
9856
|
+
$mol_action
|
|
9857
|
+
], $mol_fetch, "text", null);
|
|
9858
|
+
__decorate([
|
|
9859
|
+
$mol_action
|
|
9860
|
+
], $mol_fetch, "json", null);
|
|
9861
|
+
__decorate([
|
|
9862
|
+
$mol_action
|
|
9863
|
+
], $mol_fetch, "buffer", null);
|
|
9864
|
+
__decorate([
|
|
9865
|
+
$mol_action
|
|
9866
|
+
], $mol_fetch, "xml", null);
|
|
9867
|
+
__decorate([
|
|
9868
|
+
$mol_action
|
|
9869
|
+
], $mol_fetch, "xhtml", null);
|
|
9870
|
+
__decorate([
|
|
9871
|
+
$mol_action
|
|
9872
|
+
], $mol_fetch, "html", null);
|
|
9873
|
+
$.$mol_fetch = $mol_fetch;
|
|
9874
|
+
})($ || ($ = {}));
|
|
9875
|
+
//mol/fetch/fetch.ts
|
|
9876
|
+
;
|
|
9877
|
+
"use strict";
|
|
9878
|
+
var $;
|
|
9879
|
+
(function ($) {
|
|
9880
|
+
const Response = $mol_data_record({
|
|
9881
|
+
data: $mol_data_array($mol_data_string)
|
|
9882
|
+
});
|
|
9883
|
+
function $mol_huggingface_run(space, method, ...data) {
|
|
9884
|
+
if (typeof method === 'number') {
|
|
9885
|
+
return $mol_wire_sync(this).$mol_huggingface_async(space, method, ...data);
|
|
9886
|
+
}
|
|
9887
|
+
const response = $mol_fetch.json(`https://${space}.hf.space/run/${method}`, {
|
|
9888
|
+
method: 'post',
|
|
9889
|
+
headers: { "Content-Type": "application/json" },
|
|
9890
|
+
body: JSON.stringify({ data }),
|
|
9891
|
+
});
|
|
9892
|
+
return Response(response).data;
|
|
9893
|
+
}
|
|
9894
|
+
$.$mol_huggingface_run = $mol_huggingface_run;
|
|
9895
|
+
function $mol_huggingface_async(space, method, ...data) {
|
|
9896
|
+
const session_hash = $mol_guid();
|
|
9897
|
+
const fn_index = method;
|
|
9898
|
+
const socket = new WebSocket(`wss://${space}.hf.space/queue/join`);
|
|
9899
|
+
const promise = new Promise((done, fail) => {
|
|
9900
|
+
socket.onclose = event => {
|
|
9901
|
+
if (event.reason)
|
|
9902
|
+
fail(new Error(event.reason));
|
|
9903
|
+
};
|
|
9904
|
+
socket.onerror = event => {
|
|
9905
|
+
fail(new Error('Scoket error'));
|
|
9906
|
+
};
|
|
9907
|
+
socket.onmessage = event => {
|
|
9908
|
+
const message = JSON.parse(event.data);
|
|
9909
|
+
switch (message.msg) {
|
|
9910
|
+
case 'send_hash':
|
|
9911
|
+
return socket.send(JSON.stringify({ session_hash, fn_index }));
|
|
9912
|
+
case 'estimation': return;
|
|
9913
|
+
case 'send_data':
|
|
9914
|
+
return socket.send(JSON.stringify({ session_hash, fn_index, data }));
|
|
9915
|
+
case 'process_starts': return;
|
|
9916
|
+
case 'process_completed':
|
|
9917
|
+
if (message.success) {
|
|
9918
|
+
return done(message.output.data);
|
|
9919
|
+
}
|
|
9920
|
+
else {
|
|
9921
|
+
return fail(new Error(message.output.error ?? 'Unknown api error'));
|
|
9922
|
+
}
|
|
9923
|
+
default:
|
|
9924
|
+
fail(new Error(`Unknown message type ${message.msg}`));
|
|
9925
|
+
}
|
|
9926
|
+
};
|
|
9927
|
+
});
|
|
9928
|
+
return Object.assign(promise, {
|
|
9929
|
+
destructor: () => socket.close()
|
|
9930
|
+
});
|
|
9931
|
+
}
|
|
9932
|
+
$.$mol_huggingface_async = $mol_huggingface_async;
|
|
9933
|
+
})($ || ($ = {}));
|
|
9934
|
+
//mol/huggingface/huggingface.ts
|
|
9935
|
+
;
|
|
9936
|
+
"use strict";
|
|
9937
|
+
var $;
|
|
9938
|
+
(function ($) {
|
|
9939
|
+
function $hyoo_lingua_translate(lang, text) {
|
|
9940
|
+
return this.$mol_huggingface_run('hyoo-translate', 0, lang, text)[0];
|
|
9941
|
+
}
|
|
9942
|
+
$.$hyoo_lingua_translate = $hyoo_lingua_translate;
|
|
9943
|
+
})($ || ($ = {}));
|
|
9944
|
+
//hyoo/lingua/translate/translate.ts
|
|
9945
|
+
;
|
|
9946
|
+
"use strict";
|
|
9396
9947
|
var $;
|
|
9397
9948
|
(function ($) {
|
|
9398
9949
|
class $mol_locale extends $mol_object {
|
|
@@ -9412,22 +9963,35 @@ var $;
|
|
|
9412
9963
|
return this.source(lang).valueOf();
|
|
9413
9964
|
}
|
|
9414
9965
|
catch (error) {
|
|
9415
|
-
if (error
|
|
9416
|
-
|
|
9417
|
-
|
|
9418
|
-
|
|
9419
|
-
|
|
9420
|
-
|
|
9966
|
+
if ($mol_fail_catch(error)) {
|
|
9967
|
+
const def = this.lang_default();
|
|
9968
|
+
if (lang === def)
|
|
9969
|
+
throw error;
|
|
9970
|
+
return {};
|
|
9971
|
+
}
|
|
9421
9972
|
}
|
|
9422
9973
|
}
|
|
9423
9974
|
static text(key) {
|
|
9424
|
-
|
|
9425
|
-
|
|
9426
|
-
|
|
9427
|
-
|
|
9428
|
-
|
|
9975
|
+
const lang = this.lang();
|
|
9976
|
+
const target = this.texts(lang)[key];
|
|
9977
|
+
if (target)
|
|
9978
|
+
return target;
|
|
9979
|
+
this.warn(key);
|
|
9980
|
+
const en = this.texts('en')[key];
|
|
9981
|
+
if (!en)
|
|
9982
|
+
return key;
|
|
9983
|
+
const cache_key = `$mol_locale.text(${JSON.stringify(key)})`;
|
|
9984
|
+
const cached = this.$.$mol_state_local.value(cache_key);
|
|
9985
|
+
if (cached)
|
|
9986
|
+
return cached;
|
|
9987
|
+
try {
|
|
9988
|
+
const translated = $mol_wire_sync($hyoo_lingua_translate).call(this.$, lang, en);
|
|
9989
|
+
return this.$.$mol_state_local.value(cache_key, translated);
|
|
9990
|
+
}
|
|
9991
|
+
catch (error) {
|
|
9992
|
+
$mol_fail_log(error);
|
|
9429
9993
|
}
|
|
9430
|
-
return
|
|
9994
|
+
return en;
|
|
9431
9995
|
}
|
|
9432
9996
|
static warn(key) {
|
|
9433
9997
|
console.warn(`Not translated to "${this.lang()}": ${key}`);
|