mol_jsx_lib 0.0.1102 → 0.0.1103
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 +161 -153
- package/node.d.ts.map +1 -1
- package/node.deps.json +1 -1
- package/node.js +883 -865
- package/node.js.map +1 -1
- package/node.mjs +883 -865
- package/node.test.js +1206 -1162
- package/node.test.js.map +1 -1
- package/package.json +14 -14
package/node.js
CHANGED
|
@@ -217,30 +217,6 @@ var $;
|
|
|
217
217
|
$.$mol_error_mix = $mol_error_mix;
|
|
218
218
|
})($ || ($ = {}));
|
|
219
219
|
|
|
220
|
-
;
|
|
221
|
-
"use strict";
|
|
222
|
-
var $;
|
|
223
|
-
(function ($) {
|
|
224
|
-
function $mol_log3_area_lazy(event) {
|
|
225
|
-
const self = this;
|
|
226
|
-
const stack = self.$mol_log3_stack;
|
|
227
|
-
const deep = stack.length;
|
|
228
|
-
let logged = false;
|
|
229
|
-
stack.push(() => {
|
|
230
|
-
logged = true;
|
|
231
|
-
self.$mol_log3_area.call(self, event);
|
|
232
|
-
});
|
|
233
|
-
return () => {
|
|
234
|
-
if (logged)
|
|
235
|
-
self.console.groupEnd();
|
|
236
|
-
if (stack.length > deep)
|
|
237
|
-
stack.length = deep;
|
|
238
|
-
};
|
|
239
|
-
}
|
|
240
|
-
$.$mol_log3_area_lazy = $mol_log3_area_lazy;
|
|
241
|
-
$.$mol_log3_stack = [];
|
|
242
|
-
})($ || ($ = {}));
|
|
243
|
-
|
|
244
220
|
;
|
|
245
221
|
"use strict";
|
|
246
222
|
var $;
|
|
@@ -394,656 +370,183 @@ var $;
|
|
|
394
370
|
;
|
|
395
371
|
"use strict";
|
|
396
372
|
var $;
|
|
397
|
-
(function ($) {
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
super(
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
this.col = col;
|
|
410
|
-
this.length = length;
|
|
411
|
-
this[Symbol.toStringTag] = this.uri + ('#' + this.row + ':' + this.col + '/' + this.length);
|
|
412
|
-
}
|
|
413
|
-
static unknown = $mol_span.begin('?');
|
|
414
|
-
static begin(uri, source = '') {
|
|
415
|
-
return new $mol_span(uri, source, 1, 1, 0);
|
|
416
|
-
}
|
|
417
|
-
static end(uri, source) {
|
|
418
|
-
return new $mol_span(uri, source, 1, source.length + 1, 0);
|
|
419
|
-
}
|
|
420
|
-
static entire(uri, source) {
|
|
421
|
-
return new $mol_span(uri, source, 1, 1, source.length);
|
|
422
|
-
}
|
|
423
|
-
toString() {
|
|
424
|
-
return this[Symbol.toStringTag];
|
|
425
|
-
}
|
|
426
|
-
toJSON() {
|
|
427
|
-
return {
|
|
428
|
-
uri: this.uri,
|
|
429
|
-
row: this.row,
|
|
430
|
-
col: this.col,
|
|
431
|
-
length: this.length
|
|
432
|
-
};
|
|
433
|
-
}
|
|
434
|
-
error(message, Class = Error) {
|
|
435
|
-
return new Class(`${message} (${this})`);
|
|
436
|
-
}
|
|
437
|
-
span(row, col, length) {
|
|
438
|
-
return new $mol_span(this.uri, this.source, row, col, length);
|
|
439
|
-
}
|
|
440
|
-
after(length = 0) {
|
|
441
|
-
return new $mol_span(this.uri, this.source, this.row, this.col + this.length, length);
|
|
442
|
-
}
|
|
443
|
-
slice(begin, end = -1) {
|
|
444
|
-
let len = this.length;
|
|
445
|
-
if (begin < 0)
|
|
446
|
-
begin += len;
|
|
447
|
-
if (end < 0)
|
|
448
|
-
end += len;
|
|
449
|
-
if (begin < 0 || begin > len)
|
|
450
|
-
this.$.$mol_fail(this.error(`Begin value '${begin}' out of range`, RangeError));
|
|
451
|
-
if (end < 0 || end > len)
|
|
452
|
-
this.$.$mol_fail(this.error(`End value '${end}' out of range`, RangeError));
|
|
453
|
-
if (end < begin)
|
|
454
|
-
this.$.$mol_fail(this.error(`End value '${end}' can't be less than begin value`, RangeError));
|
|
455
|
-
return this.span(this.row, this.col + begin, end - begin);
|
|
373
|
+
(function ($_1) {
|
|
374
|
+
let $$;
|
|
375
|
+
(function ($$) {
|
|
376
|
+
let $;
|
|
377
|
+
})($$ = $_1.$$ || ($_1.$$ = {}));
|
|
378
|
+
$_1.$mol_object_field = Symbol('$mol_object_field');
|
|
379
|
+
class $mol_object extends $mol_object2 {
|
|
380
|
+
static make(config) {
|
|
381
|
+
return super.create(obj => {
|
|
382
|
+
for (let key in config)
|
|
383
|
+
obj[key] = config[key];
|
|
384
|
+
});
|
|
456
385
|
}
|
|
457
386
|
}
|
|
458
|
-
|
|
387
|
+
$_1.$mol_object = $mol_object;
|
|
459
388
|
})($ || ($ = {}));
|
|
460
389
|
|
|
461
390
|
;
|
|
462
391
|
"use strict";
|
|
463
392
|
var $;
|
|
464
393
|
(function ($) {
|
|
465
|
-
function $
|
|
466
|
-
|
|
467
|
-
function dump(tree, prefix = '') {
|
|
468
|
-
if (tree.type.length) {
|
|
469
|
-
if (!prefix.length) {
|
|
470
|
-
prefix = "\t";
|
|
471
|
-
}
|
|
472
|
-
output.push(tree.type);
|
|
473
|
-
if (tree.kids.length == 1) {
|
|
474
|
-
output.push(' ');
|
|
475
|
-
dump(tree.kids[0], prefix);
|
|
476
|
-
return;
|
|
477
|
-
}
|
|
478
|
-
output.push("\n");
|
|
479
|
-
}
|
|
480
|
-
else if (tree.value.length || prefix.length) {
|
|
481
|
-
output.push("\\" + tree.value + "\n");
|
|
482
|
-
}
|
|
483
|
-
for (const kid of tree.kids) {
|
|
484
|
-
output.push(prefix);
|
|
485
|
-
dump(kid, prefix + "\t");
|
|
486
|
-
}
|
|
487
|
-
}
|
|
488
|
-
dump(tree);
|
|
489
|
-
return output.join('');
|
|
394
|
+
function $mol_env() {
|
|
395
|
+
return {};
|
|
490
396
|
}
|
|
491
|
-
$.$
|
|
397
|
+
$.$mol_env = $mol_env;
|
|
492
398
|
})($ || ($ = {}));
|
|
493
399
|
|
|
494
400
|
;
|
|
495
401
|
"use strict";
|
|
496
402
|
var $;
|
|
497
403
|
(function ($) {
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
404
|
+
$.$mol_env = function $mol_env() {
|
|
405
|
+
return this.process.env;
|
|
406
|
+
};
|
|
407
|
+
})($ || ($ = {}));
|
|
408
|
+
|
|
409
|
+
;
|
|
410
|
+
"use strict";
|
|
411
|
+
var $;
|
|
412
|
+
(function ($) {
|
|
413
|
+
let $mol_wire_cursor;
|
|
414
|
+
(function ($mol_wire_cursor) {
|
|
415
|
+
$mol_wire_cursor[$mol_wire_cursor["stale"] = -1] = "stale";
|
|
416
|
+
$mol_wire_cursor[$mol_wire_cursor["doubt"] = -2] = "doubt";
|
|
417
|
+
$mol_wire_cursor[$mol_wire_cursor["fresh"] = -3] = "fresh";
|
|
418
|
+
$mol_wire_cursor[$mol_wire_cursor["final"] = -4] = "final";
|
|
419
|
+
})($mol_wire_cursor = $.$mol_wire_cursor || ($.$mol_wire_cursor = {}));
|
|
420
|
+
})($ || ($ = {}));
|
|
421
|
+
|
|
422
|
+
;
|
|
423
|
+
"use strict";
|
|
424
|
+
var $;
|
|
425
|
+
(function ($) {
|
|
426
|
+
class $mol_wire_pub extends Object {
|
|
427
|
+
data = [];
|
|
428
|
+
static get [Symbol.species]() {
|
|
429
|
+
return Array;
|
|
516
430
|
}
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
kid_span = kid_span.after(chunk.length);
|
|
523
|
-
return new $mol_tree2('', chunk, [], kid_span);
|
|
524
|
-
});
|
|
525
|
-
kids = [...data, ...kids];
|
|
526
|
-
value = '';
|
|
431
|
+
sub_from = 0;
|
|
432
|
+
get sub_list() {
|
|
433
|
+
const res = [];
|
|
434
|
+
for (let i = this.sub_from; i < this.data.length; i += 2) {
|
|
435
|
+
res.push(this.data[i]);
|
|
527
436
|
}
|
|
528
|
-
return
|
|
437
|
+
return res;
|
|
529
438
|
}
|
|
530
|
-
|
|
531
|
-
return
|
|
439
|
+
get sub_empty() {
|
|
440
|
+
return this.sub_from === this.data.length;
|
|
532
441
|
}
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
442
|
+
sub_on(sub, pub_pos) {
|
|
443
|
+
const pos = this.data.length;
|
|
444
|
+
this.data.push(sub, pub_pos);
|
|
445
|
+
return pos;
|
|
446
|
+
}
|
|
447
|
+
sub_off(sub_pos) {
|
|
448
|
+
if (!(sub_pos < this.data.length)) {
|
|
449
|
+
$mol_fail(new Error(`Wrong pos ${sub_pos}`));
|
|
536
450
|
}
|
|
537
|
-
|
|
451
|
+
const end = this.data.length - 2;
|
|
452
|
+
if (sub_pos !== end) {
|
|
453
|
+
this.peer_move(end, sub_pos);
|
|
454
|
+
}
|
|
455
|
+
this.data.pop();
|
|
456
|
+
this.data.pop();
|
|
457
|
+
if (this.data.length === this.sub_from)
|
|
458
|
+
this.reap();
|
|
538
459
|
}
|
|
539
|
-
|
|
540
|
-
|
|
460
|
+
reap() { }
|
|
461
|
+
promote() {
|
|
462
|
+
$mol_wire_auto()?.track_next(this);
|
|
541
463
|
}
|
|
542
|
-
|
|
543
|
-
|
|
464
|
+
fresh() { }
|
|
465
|
+
complete() { }
|
|
466
|
+
get incompleted() {
|
|
467
|
+
return false;
|
|
544
468
|
}
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
continue;
|
|
550
|
-
values.push(kid.value);
|
|
469
|
+
emit(quant = $mol_wire_cursor.stale) {
|
|
470
|
+
for (let i = this.sub_from; i < this.data.length; i += 2) {
|
|
471
|
+
;
|
|
472
|
+
this.data[i].absorb(quant);
|
|
551
473
|
}
|
|
552
|
-
return this.value + values.join('\n');
|
|
553
474
|
}
|
|
554
|
-
|
|
555
|
-
|
|
475
|
+
peer_move(from_pos, to_pos) {
|
|
476
|
+
const peer = this.data[from_pos];
|
|
477
|
+
const self_pos = this.data[from_pos + 1];
|
|
478
|
+
this.data[to_pos] = peer;
|
|
479
|
+
this.data[to_pos + 1] = self_pos;
|
|
480
|
+
peer.peer_repos(self_pos, to_pos);
|
|
556
481
|
}
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
}
|
|
560
|
-
insert(value, ...path) {
|
|
561
|
-
if (path.length === 0)
|
|
562
|
-
return value;
|
|
563
|
-
const type = path[0];
|
|
564
|
-
if (typeof type === 'string') {
|
|
565
|
-
let replaced = false;
|
|
566
|
-
const sub = this.kids.map((item, index) => {
|
|
567
|
-
if (item.type !== type)
|
|
568
|
-
return item;
|
|
569
|
-
replaced = true;
|
|
570
|
-
return item.insert(value, ...path.slice(1));
|
|
571
|
-
}).filter(Boolean);
|
|
572
|
-
if (!replaced && value) {
|
|
573
|
-
sub.push(this.struct(type, []).insert(value, ...path.slice(1)));
|
|
574
|
-
}
|
|
575
|
-
return this.clone(sub);
|
|
576
|
-
}
|
|
577
|
-
else if (typeof type === 'number') {
|
|
578
|
-
const sub = this.kids.slice();
|
|
579
|
-
sub[type] = (sub[type] || this.list([]))
|
|
580
|
-
.insert(value, ...path.slice(1));
|
|
581
|
-
return this.clone(sub.filter(Boolean));
|
|
582
|
-
}
|
|
583
|
-
else {
|
|
584
|
-
const kids = ((this.kids.length === 0) ? [this.list([])] : this.kids)
|
|
585
|
-
.map(item => item.insert(value, ...path.slice(1)))
|
|
586
|
-
.filter(Boolean);
|
|
587
|
-
return this.clone(kids);
|
|
588
|
-
}
|
|
589
|
-
}
|
|
590
|
-
select(...path) {
|
|
591
|
-
let next = [this];
|
|
592
|
-
for (const type of path) {
|
|
593
|
-
if (!next.length)
|
|
594
|
-
break;
|
|
595
|
-
const prev = next;
|
|
596
|
-
next = [];
|
|
597
|
-
for (var item of prev) {
|
|
598
|
-
switch (typeof (type)) {
|
|
599
|
-
case 'string':
|
|
600
|
-
for (var child of item.kids) {
|
|
601
|
-
if (child.type == type) {
|
|
602
|
-
next.push(child);
|
|
603
|
-
}
|
|
604
|
-
}
|
|
605
|
-
break;
|
|
606
|
-
case 'number':
|
|
607
|
-
if (type < item.kids.length)
|
|
608
|
-
next.push(item.kids[type]);
|
|
609
|
-
break;
|
|
610
|
-
default: next.push(...item.kids);
|
|
611
|
-
}
|
|
612
|
-
}
|
|
613
|
-
}
|
|
614
|
-
return this.list(next);
|
|
615
|
-
}
|
|
616
|
-
filter(path, value) {
|
|
617
|
-
const sub = this.kids.filter(item => {
|
|
618
|
-
var found = item.select(...path);
|
|
619
|
-
if (value === undefined) {
|
|
620
|
-
return Boolean(found.kids.length);
|
|
621
|
-
}
|
|
622
|
-
else {
|
|
623
|
-
return found.kids.some(child => child.value == value);
|
|
624
|
-
}
|
|
625
|
-
});
|
|
626
|
-
return this.clone(sub);
|
|
627
|
-
}
|
|
628
|
-
hack_self(belt, context = {}) {
|
|
629
|
-
let handle = belt[this.type] || belt[''];
|
|
630
|
-
if (!handle || handle === Object.prototype[this.type]) {
|
|
631
|
-
handle = (input, belt, context) => [
|
|
632
|
-
input.clone(input.hack(belt, context), context.span)
|
|
633
|
-
];
|
|
634
|
-
}
|
|
635
|
-
try {
|
|
636
|
-
return handle(this, belt, context);
|
|
637
|
-
}
|
|
638
|
-
catch (error) {
|
|
639
|
-
error.message += `\n${this.clone([])}${this.span}`;
|
|
640
|
-
$mol_fail_hidden(error);
|
|
641
|
-
}
|
|
642
|
-
}
|
|
643
|
-
hack(belt, context = {}) {
|
|
644
|
-
return [].concat(...this.kids.map(child => child.hack_self(belt, context)));
|
|
645
|
-
}
|
|
646
|
-
error(message, Class = Error) {
|
|
647
|
-
return this.span.error(`${message}\n${this.clone([])}`, Class);
|
|
648
|
-
}
|
|
649
|
-
}
|
|
650
|
-
$.$mol_tree2 = $mol_tree2;
|
|
651
|
-
class $mol_tree2_empty extends $mol_tree2 {
|
|
652
|
-
constructor() {
|
|
653
|
-
super('', '', [], $mol_span.unknown);
|
|
482
|
+
peer_repos(peer_pos, self_pos) {
|
|
483
|
+
this.data[peer_pos + 1] = self_pos;
|
|
654
484
|
}
|
|
655
485
|
}
|
|
656
|
-
$.$
|
|
486
|
+
$.$mol_wire_pub = $mol_wire_pub;
|
|
657
487
|
})($ || ($ = {}));
|
|
658
488
|
|
|
489
|
+
;
|
|
490
|
+
"use strict";
|
|
491
|
+
|
|
659
492
|
;
|
|
660
493
|
"use strict";
|
|
661
494
|
var $;
|
|
662
495
|
(function ($) {
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
span;
|
|
667
|
-
constructor(reason, line, span) {
|
|
668
|
-
super(`${reason}\n${span}\n${line.substring(0, span.col - 1).replace(/\S/g, ' ')}${''.padEnd(span.length, '!')}\n${line}`);
|
|
669
|
-
this.reason = reason;
|
|
670
|
-
this.line = line;
|
|
671
|
-
this.span = span;
|
|
672
|
-
}
|
|
496
|
+
$.$mol_wire_auto_sub = null;
|
|
497
|
+
function $mol_wire_auto(next = $.$mol_wire_auto_sub) {
|
|
498
|
+
return $.$mol_wire_auto_sub = next;
|
|
673
499
|
}
|
|
674
|
-
$.$
|
|
500
|
+
$.$mol_wire_auto = $mol_wire_auto;
|
|
501
|
+
$.$mol_wire_affected = [];
|
|
675
502
|
})($ || ($ = {}));
|
|
676
503
|
|
|
677
504
|
;
|
|
678
505
|
"use strict";
|
|
679
506
|
var $;
|
|
680
507
|
(function ($) {
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
if (
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
indent -= min_indent;
|
|
698
|
-
if (indent < 0 || indent >= stack.length) {
|
|
699
|
-
const sp = span.span(row, 1, pos - line_start);
|
|
700
|
-
while (str.length > pos && str[pos] != '\n') {
|
|
701
|
-
pos++;
|
|
702
|
-
}
|
|
703
|
-
if (indent < 0) {
|
|
704
|
-
if (str.length > pos) {
|
|
705
|
-
this.$mol_fail(new this.$mol_error_syntax(`Too few tabs`, str.substring(line_start, pos), sp));
|
|
706
|
-
}
|
|
707
|
-
}
|
|
708
|
-
else {
|
|
709
|
-
this.$mol_fail(new this.$mol_error_syntax(`Too many tabs`, str.substring(line_start, pos), sp));
|
|
710
|
-
}
|
|
711
|
-
}
|
|
712
|
-
stack.length = indent + 1;
|
|
713
|
-
var parent = stack[indent];
|
|
714
|
-
while (str.length > pos && str[pos] != '\\' && str[pos] != '\n') {
|
|
715
|
-
var error_start = pos;
|
|
716
|
-
while (str.length > pos && (str[pos] == ' ' || str[pos] == '\t')) {
|
|
717
|
-
pos++;
|
|
718
|
-
}
|
|
719
|
-
if (pos > error_start) {
|
|
720
|
-
let line_end = str.indexOf('\n', pos);
|
|
721
|
-
if (line_end === -1)
|
|
722
|
-
line_end = str.length;
|
|
723
|
-
const sp = span.span(row, error_start - line_start + 1, pos - error_start);
|
|
724
|
-
this.$mol_fail(new this.$mol_error_syntax(`Wrong nodes separator`, str.substring(line_start, line_end), sp));
|
|
725
|
-
}
|
|
726
|
-
var type_start = pos;
|
|
727
|
-
while (str.length > pos &&
|
|
728
|
-
str[pos] != '\\' &&
|
|
729
|
-
str[pos] != ' ' &&
|
|
730
|
-
str[pos] != '\t' &&
|
|
731
|
-
str[pos] != '\n') {
|
|
732
|
-
pos++;
|
|
733
|
-
}
|
|
734
|
-
if (pos > type_start) {
|
|
735
|
-
let next = new $mol_tree2(str.slice(type_start, pos), '', [], span.span(row, type_start - line_start + 1, pos - type_start));
|
|
736
|
-
const parent_kids = parent.kids;
|
|
737
|
-
parent_kids.push(next);
|
|
738
|
-
parent = next;
|
|
508
|
+
$['devtoolsFormatters'] ||= [];
|
|
509
|
+
function $mol_dev_format_register(config) {
|
|
510
|
+
$['devtoolsFormatters'].push(config);
|
|
511
|
+
}
|
|
512
|
+
$.$mol_dev_format_register = $mol_dev_format_register;
|
|
513
|
+
$.$mol_dev_format_head = Symbol('$mol_dev_format_head');
|
|
514
|
+
$.$mol_dev_format_body = Symbol('$mol_dev_format_body');
|
|
515
|
+
$mol_dev_format_register({
|
|
516
|
+
header: (val, config = false) => {
|
|
517
|
+
if (config)
|
|
518
|
+
return null;
|
|
519
|
+
if (!val)
|
|
520
|
+
return null;
|
|
521
|
+
if ($.$mol_dev_format_head in val) {
|
|
522
|
+
try {
|
|
523
|
+
return val[$.$mol_dev_format_head]();
|
|
739
524
|
}
|
|
740
|
-
|
|
741
|
-
|
|
525
|
+
catch (error) {
|
|
526
|
+
return $.$mol_dev_format_accent($mol_dev_format_native(val), '💨', $mol_dev_format_native(error), '');
|
|
742
527
|
}
|
|
743
528
|
}
|
|
744
|
-
if (
|
|
745
|
-
|
|
746
|
-
while (str.length > pos && str[pos] != '\n') {
|
|
747
|
-
pos++;
|
|
748
|
-
}
|
|
749
|
-
let next = new $mol_tree2('', str.slice(data_start + 1, pos), [], span.span(row, data_start - line_start + 2, pos - data_start - 1));
|
|
750
|
-
const parent_kids = parent.kids;
|
|
751
|
-
parent_kids.push(next);
|
|
752
|
-
parent = next;
|
|
529
|
+
if (typeof val === 'function') {
|
|
530
|
+
return $mol_dev_format_native(val);
|
|
753
531
|
}
|
|
754
|
-
if (
|
|
755
|
-
|
|
756
|
-
this.$mol_fail(new this.$mol_error_syntax(`Unexpected EOF, LF required`, str.substring(line_start, str.length), sp));
|
|
532
|
+
if (Symbol.toStringTag in val) {
|
|
533
|
+
return $mol_dev_format_native(val);
|
|
757
534
|
}
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
}
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
}
|
|
774
|
-
if (typeof json === 'string') {
|
|
775
|
-
return $mol_tree2.data(json, [], span);
|
|
776
|
-
}
|
|
777
|
-
if (typeof json.toJSON === 'function') {
|
|
778
|
-
return $mol_tree2_from_json(json.toJSON());
|
|
779
|
-
}
|
|
780
|
-
if (Array.isArray(json)) {
|
|
781
|
-
const sub = json.map(json => $mol_tree2_from_json(json, span));
|
|
782
|
-
return new $mol_tree2('/', '', sub, span);
|
|
783
|
-
}
|
|
784
|
-
if (ArrayBuffer.isView(json)) {
|
|
785
|
-
const buf = new Uint8Array(json.buffer, json.byteOffset, json.byteLength);
|
|
786
|
-
return $mol_tree2.data(String.fromCharCode(...buf), [], span);
|
|
787
|
-
}
|
|
788
|
-
if (json instanceof Date) {
|
|
789
|
-
return new $mol_tree2('', json.toISOString(), [], span);
|
|
790
|
-
}
|
|
791
|
-
if (json.toString !== Object.prototype.toString) {
|
|
792
|
-
return $mol_tree2.data(json.toString(), [], span);
|
|
793
|
-
}
|
|
794
|
-
if (json instanceof Error) {
|
|
795
|
-
const { name, message, stack } = json;
|
|
796
|
-
json = { ...json, name, message, stack };
|
|
797
|
-
}
|
|
798
|
-
const sub = [];
|
|
799
|
-
for (var key in json) {
|
|
800
|
-
const val = json[key];
|
|
801
|
-
if (val === undefined)
|
|
802
|
-
continue;
|
|
803
|
-
const subsub = $mol_tree2_from_json(val, span);
|
|
804
|
-
if (/^[^\n\t\\ ]+$/.test(key)) {
|
|
805
|
-
sub.push(new $mol_tree2(key, '', [subsub], span));
|
|
806
|
-
}
|
|
807
|
-
else {
|
|
808
|
-
sub.push($mol_tree2.data(key, [subsub], span));
|
|
809
|
-
}
|
|
810
|
-
}
|
|
811
|
-
return new $mol_tree2('*', '', sub, span);
|
|
812
|
-
}
|
|
813
|
-
$.$mol_tree2_from_json = $mol_tree2_from_json;
|
|
814
|
-
})($ || ($ = {}));
|
|
815
|
-
|
|
816
|
-
;
|
|
817
|
-
"use strict";
|
|
818
|
-
var $;
|
|
819
|
-
(function ($) {
|
|
820
|
-
class $mol_term_color {
|
|
821
|
-
static reset = this.ansi(0, 0);
|
|
822
|
-
static bold = this.ansi(1, 22);
|
|
823
|
-
static italic = this.ansi(3, 23);
|
|
824
|
-
static underline = this.ansi(4, 24);
|
|
825
|
-
static inverse = this.ansi(7, 27);
|
|
826
|
-
static hidden = this.ansi(8, 28);
|
|
827
|
-
static strike = this.ansi(9, 29);
|
|
828
|
-
static gray = this.ansi(90, 39);
|
|
829
|
-
static red = this.ansi(91, 39);
|
|
830
|
-
static green = this.ansi(92, 39);
|
|
831
|
-
static yellow = this.ansi(93, 39);
|
|
832
|
-
static blue = this.ansi(94, 39);
|
|
833
|
-
static magenta = this.ansi(95, 39);
|
|
834
|
-
static cyan = this.ansi(96, 39);
|
|
835
|
-
static Gray = (str) => this.inverse(this.gray(str));
|
|
836
|
-
static Red = (str) => this.inverse(this.red(str));
|
|
837
|
-
static Green = (str) => this.inverse(this.green(str));
|
|
838
|
-
static Yellow = (str) => this.inverse(this.yellow(str));
|
|
839
|
-
static Blue = (str) => this.inverse(this.blue(str));
|
|
840
|
-
static Magenta = (str) => this.inverse(this.magenta(str));
|
|
841
|
-
static Cyan = (str) => this.inverse(this.cyan(str));
|
|
842
|
-
static ansi(open, close) {
|
|
843
|
-
if (typeof process === 'undefined')
|
|
844
|
-
return String;
|
|
845
|
-
if (!process.stdout.isTTY)
|
|
846
|
-
return String;
|
|
847
|
-
const prefix = `\x1b[${open}m`;
|
|
848
|
-
const postfix = `\x1b[${close}m`;
|
|
849
|
-
const suffix_regexp = new RegExp(postfix.replace('[', '\\['), 'g');
|
|
850
|
-
return function colorer(str) {
|
|
851
|
-
str = String(str);
|
|
852
|
-
if (str === '')
|
|
853
|
-
return str;
|
|
854
|
-
const suffix = str.replace(suffix_regexp, prefix);
|
|
855
|
-
return prefix + suffix + postfix;
|
|
856
|
-
};
|
|
857
|
-
}
|
|
858
|
-
}
|
|
859
|
-
$.$mol_term_color = $mol_term_color;
|
|
860
|
-
})($ || ($ = {}));
|
|
861
|
-
|
|
862
|
-
;
|
|
863
|
-
"use strict";
|
|
864
|
-
var $;
|
|
865
|
-
(function ($) {
|
|
866
|
-
function $mol_log3_node_make(level, output, type, color) {
|
|
867
|
-
return function $mol_log3_logger(event) {
|
|
868
|
-
if (!event.time)
|
|
869
|
-
event = { time: new Date().toISOString(), ...event };
|
|
870
|
-
let tree = this.$mol_tree2_from_json(event);
|
|
871
|
-
tree = tree.struct(type, tree.kids);
|
|
872
|
-
let str = color(tree.toString());
|
|
873
|
-
this.console[level](str);
|
|
874
|
-
const self = this;
|
|
875
|
-
return () => self.console.groupEnd();
|
|
876
|
-
};
|
|
877
|
-
}
|
|
878
|
-
$.$mol_log3_node_make = $mol_log3_node_make;
|
|
879
|
-
$.$mol_log3_come = $mol_log3_node_make('info', 'stdout', 'come', $mol_term_color.blue);
|
|
880
|
-
$.$mol_log3_done = $mol_log3_node_make('info', 'stdout', 'done', $mol_term_color.green);
|
|
881
|
-
$.$mol_log3_fail = $mol_log3_node_make('error', 'stderr', 'fail', $mol_term_color.red);
|
|
882
|
-
$.$mol_log3_warn = $mol_log3_node_make('warn', 'stderr', 'warn', $mol_term_color.yellow);
|
|
883
|
-
$.$mol_log3_rise = $mol_log3_node_make('log', 'stdout', 'rise', $mol_term_color.magenta);
|
|
884
|
-
$.$mol_log3_area = $mol_log3_node_make('log', 'stdout', 'area', $mol_term_color.cyan);
|
|
885
|
-
})($ || ($ = {}));
|
|
886
|
-
|
|
887
|
-
;
|
|
888
|
-
"use strict";
|
|
889
|
-
var $;
|
|
890
|
-
(function ($) {
|
|
891
|
-
function $mol_env() {
|
|
892
|
-
return {};
|
|
893
|
-
}
|
|
894
|
-
$.$mol_env = $mol_env;
|
|
895
|
-
})($ || ($ = {}));
|
|
896
|
-
|
|
897
|
-
;
|
|
898
|
-
"use strict";
|
|
899
|
-
var $;
|
|
900
|
-
(function ($) {
|
|
901
|
-
$.$mol_env = function $mol_env() {
|
|
902
|
-
return this.process.env;
|
|
903
|
-
};
|
|
904
|
-
})($ || ($ = {}));
|
|
905
|
-
|
|
906
|
-
;
|
|
907
|
-
"use strict";
|
|
908
|
-
var $;
|
|
909
|
-
(function ($) {
|
|
910
|
-
let $mol_wire_cursor;
|
|
911
|
-
(function ($mol_wire_cursor) {
|
|
912
|
-
$mol_wire_cursor[$mol_wire_cursor["stale"] = -1] = "stale";
|
|
913
|
-
$mol_wire_cursor[$mol_wire_cursor["doubt"] = -2] = "doubt";
|
|
914
|
-
$mol_wire_cursor[$mol_wire_cursor["fresh"] = -3] = "fresh";
|
|
915
|
-
$mol_wire_cursor[$mol_wire_cursor["final"] = -4] = "final";
|
|
916
|
-
})($mol_wire_cursor = $.$mol_wire_cursor || ($.$mol_wire_cursor = {}));
|
|
917
|
-
})($ || ($ = {}));
|
|
918
|
-
|
|
919
|
-
;
|
|
920
|
-
"use strict";
|
|
921
|
-
var $;
|
|
922
|
-
(function ($) {
|
|
923
|
-
class $mol_wire_pub extends Object {
|
|
924
|
-
data = [];
|
|
925
|
-
static get [Symbol.species]() {
|
|
926
|
-
return Array;
|
|
927
|
-
}
|
|
928
|
-
sub_from = 0;
|
|
929
|
-
get sub_list() {
|
|
930
|
-
const res = [];
|
|
931
|
-
for (let i = this.sub_from; i < this.data.length; i += 2) {
|
|
932
|
-
res.push(this.data[i]);
|
|
933
|
-
}
|
|
934
|
-
return res;
|
|
935
|
-
}
|
|
936
|
-
get sub_empty() {
|
|
937
|
-
return this.sub_from === this.data.length;
|
|
938
|
-
}
|
|
939
|
-
sub_on(sub, pub_pos) {
|
|
940
|
-
const pos = this.data.length;
|
|
941
|
-
this.data.push(sub, pub_pos);
|
|
942
|
-
return pos;
|
|
943
|
-
}
|
|
944
|
-
sub_off(sub_pos) {
|
|
945
|
-
if (!(sub_pos < this.data.length)) {
|
|
946
|
-
$mol_fail(new Error(`Wrong pos ${sub_pos}`));
|
|
947
|
-
}
|
|
948
|
-
const end = this.data.length - 2;
|
|
949
|
-
if (sub_pos !== end) {
|
|
950
|
-
this.peer_move(end, sub_pos);
|
|
951
|
-
}
|
|
952
|
-
this.data.pop();
|
|
953
|
-
this.data.pop();
|
|
954
|
-
if (this.data.length === this.sub_from)
|
|
955
|
-
this.reap();
|
|
956
|
-
}
|
|
957
|
-
reap() { }
|
|
958
|
-
promote() {
|
|
959
|
-
$mol_wire_auto()?.track_next(this);
|
|
960
|
-
}
|
|
961
|
-
fresh() { }
|
|
962
|
-
complete() { }
|
|
963
|
-
get incompleted() {
|
|
964
|
-
return false;
|
|
965
|
-
}
|
|
966
|
-
emit(quant = $mol_wire_cursor.stale) {
|
|
967
|
-
for (let i = this.sub_from; i < this.data.length; i += 2) {
|
|
968
|
-
;
|
|
969
|
-
this.data[i].absorb(quant);
|
|
970
|
-
}
|
|
971
|
-
}
|
|
972
|
-
peer_move(from_pos, to_pos) {
|
|
973
|
-
const peer = this.data[from_pos];
|
|
974
|
-
const self_pos = this.data[from_pos + 1];
|
|
975
|
-
this.data[to_pos] = peer;
|
|
976
|
-
this.data[to_pos + 1] = self_pos;
|
|
977
|
-
peer.peer_repos(self_pos, to_pos);
|
|
978
|
-
}
|
|
979
|
-
peer_repos(peer_pos, self_pos) {
|
|
980
|
-
this.data[peer_pos + 1] = self_pos;
|
|
981
|
-
}
|
|
982
|
-
}
|
|
983
|
-
$.$mol_wire_pub = $mol_wire_pub;
|
|
984
|
-
})($ || ($ = {}));
|
|
985
|
-
|
|
986
|
-
;
|
|
987
|
-
"use strict";
|
|
988
|
-
|
|
989
|
-
;
|
|
990
|
-
"use strict";
|
|
991
|
-
var $;
|
|
992
|
-
(function ($) {
|
|
993
|
-
$.$mol_wire_auto_sub = null;
|
|
994
|
-
function $mol_wire_auto(next = $.$mol_wire_auto_sub) {
|
|
995
|
-
return $.$mol_wire_auto_sub = next;
|
|
996
|
-
}
|
|
997
|
-
$.$mol_wire_auto = $mol_wire_auto;
|
|
998
|
-
$.$mol_wire_affected = [];
|
|
999
|
-
})($ || ($ = {}));
|
|
1000
|
-
|
|
1001
|
-
;
|
|
1002
|
-
"use strict";
|
|
1003
|
-
var $;
|
|
1004
|
-
(function ($) {
|
|
1005
|
-
$['devtoolsFormatters'] ||= [];
|
|
1006
|
-
function $mol_dev_format_register(config) {
|
|
1007
|
-
$['devtoolsFormatters'].push(config);
|
|
1008
|
-
}
|
|
1009
|
-
$.$mol_dev_format_register = $mol_dev_format_register;
|
|
1010
|
-
$.$mol_dev_format_head = Symbol('$mol_dev_format_head');
|
|
1011
|
-
$.$mol_dev_format_body = Symbol('$mol_dev_format_body');
|
|
1012
|
-
$mol_dev_format_register({
|
|
1013
|
-
header: (val, config = false) => {
|
|
1014
|
-
if (config)
|
|
1015
|
-
return null;
|
|
1016
|
-
if (!val)
|
|
1017
|
-
return null;
|
|
1018
|
-
if ($.$mol_dev_format_head in val) {
|
|
1019
|
-
try {
|
|
1020
|
-
return val[$.$mol_dev_format_head]();
|
|
1021
|
-
}
|
|
1022
|
-
catch (error) {
|
|
1023
|
-
return $.$mol_dev_format_accent($mol_dev_format_native(val), '💨', $mol_dev_format_native(error), '');
|
|
1024
|
-
}
|
|
1025
|
-
}
|
|
1026
|
-
if (typeof val === 'function') {
|
|
1027
|
-
return $mol_dev_format_native(val);
|
|
1028
|
-
}
|
|
1029
|
-
if (Symbol.toStringTag in val) {
|
|
1030
|
-
return $mol_dev_format_native(val);
|
|
1031
|
-
}
|
|
1032
|
-
return null;
|
|
1033
|
-
},
|
|
1034
|
-
hasBody: val => val[$.$mol_dev_format_body],
|
|
1035
|
-
body: val => val[$.$mol_dev_format_body](),
|
|
1036
|
-
});
|
|
1037
|
-
function $mol_dev_format_native(obj) {
|
|
1038
|
-
if (typeof obj === 'undefined')
|
|
1039
|
-
return $.$mol_dev_format_shade('undefined');
|
|
1040
|
-
return [
|
|
1041
|
-
'object',
|
|
1042
|
-
{
|
|
1043
|
-
object: obj,
|
|
1044
|
-
config: true,
|
|
1045
|
-
},
|
|
1046
|
-
];
|
|
535
|
+
return null;
|
|
536
|
+
},
|
|
537
|
+
hasBody: val => val[$.$mol_dev_format_body],
|
|
538
|
+
body: val => val[$.$mol_dev_format_body](),
|
|
539
|
+
});
|
|
540
|
+
function $mol_dev_format_native(obj) {
|
|
541
|
+
if (typeof obj === 'undefined')
|
|
542
|
+
return $.$mol_dev_format_shade('undefined');
|
|
543
|
+
return [
|
|
544
|
+
'object',
|
|
545
|
+
{
|
|
546
|
+
object: obj,
|
|
547
|
+
config: true,
|
|
548
|
+
},
|
|
549
|
+
];
|
|
1047
550
|
}
|
|
1048
551
|
$.$mol_dev_format_native = $mol_dev_format_native;
|
|
1049
552
|
function $mol_dev_format_auto(obj) {
|
|
@@ -1515,147 +1018,664 @@ var $;
|
|
|
1515
1018
|
}
|
|
1516
1019
|
}
|
|
1517
1020
|
}
|
|
1518
|
-
$.$mol_wire_fiber = $mol_wire_fiber;
|
|
1021
|
+
$.$mol_wire_fiber = $mol_wire_fiber;
|
|
1022
|
+
})($ || ($ = {}));
|
|
1023
|
+
|
|
1024
|
+
;
|
|
1025
|
+
"use strict";
|
|
1026
|
+
var $;
|
|
1027
|
+
(function ($) {
|
|
1028
|
+
$.$mol_compare_deep_cache = new WeakMap();
|
|
1029
|
+
function $mol_compare_deep(left, right) {
|
|
1030
|
+
if (Object.is(left, right))
|
|
1031
|
+
return true;
|
|
1032
|
+
if (left === null)
|
|
1033
|
+
return false;
|
|
1034
|
+
if (right === null)
|
|
1035
|
+
return false;
|
|
1036
|
+
if (typeof left !== 'object')
|
|
1037
|
+
return false;
|
|
1038
|
+
if (typeof right !== 'object')
|
|
1039
|
+
return false;
|
|
1040
|
+
const left_proto = Reflect.getPrototypeOf(left);
|
|
1041
|
+
const right_proto = Reflect.getPrototypeOf(right);
|
|
1042
|
+
if (left_proto !== right_proto)
|
|
1043
|
+
return false;
|
|
1044
|
+
if (left instanceof Boolean)
|
|
1045
|
+
return Object.is(left.valueOf(), right['valueOf']());
|
|
1046
|
+
if (left instanceof Number)
|
|
1047
|
+
return Object.is(left.valueOf(), right['valueOf']());
|
|
1048
|
+
if (left instanceof String)
|
|
1049
|
+
return Object.is(left.valueOf(), right['valueOf']());
|
|
1050
|
+
if (left instanceof Date)
|
|
1051
|
+
return Object.is(left.valueOf(), right['valueOf']());
|
|
1052
|
+
if (left instanceof RegExp)
|
|
1053
|
+
return left.source === right.source && left.flags === right.flags;
|
|
1054
|
+
if (left instanceof Error)
|
|
1055
|
+
return left.message === right.message && left.stack === right.stack;
|
|
1056
|
+
let left_cache = $.$mol_compare_deep_cache.get(left);
|
|
1057
|
+
if (left_cache) {
|
|
1058
|
+
const right_cache = left_cache.get(right);
|
|
1059
|
+
if (typeof right_cache === 'boolean')
|
|
1060
|
+
return right_cache;
|
|
1061
|
+
}
|
|
1062
|
+
else {
|
|
1063
|
+
left_cache = new WeakMap();
|
|
1064
|
+
$.$mol_compare_deep_cache.set(left, left_cache);
|
|
1065
|
+
}
|
|
1066
|
+
left_cache.set(right, true);
|
|
1067
|
+
let result;
|
|
1068
|
+
try {
|
|
1069
|
+
if (!left_proto)
|
|
1070
|
+
result = compare_pojo(left, right);
|
|
1071
|
+
else if (!Reflect.getPrototypeOf(left_proto))
|
|
1072
|
+
result = compare_pojo(left, right);
|
|
1073
|
+
else if (Symbol.toPrimitive in left)
|
|
1074
|
+
result = compare_primitive(left, right);
|
|
1075
|
+
else if (Array.isArray(left))
|
|
1076
|
+
result = compare_array(left, right);
|
|
1077
|
+
else if (left instanceof Set)
|
|
1078
|
+
result = compare_set(left, right);
|
|
1079
|
+
else if (left instanceof Map)
|
|
1080
|
+
result = compare_map(left, right);
|
|
1081
|
+
else if (ArrayBuffer.isView(left))
|
|
1082
|
+
result = compare_buffer(left, right);
|
|
1083
|
+
else if (Symbol.iterator in left)
|
|
1084
|
+
result = compare_iterator(left[Symbol.iterator](), right[Symbol.iterator]());
|
|
1085
|
+
else
|
|
1086
|
+
result = false;
|
|
1087
|
+
}
|
|
1088
|
+
finally {
|
|
1089
|
+
left_cache.set(right, result);
|
|
1090
|
+
}
|
|
1091
|
+
return result;
|
|
1092
|
+
}
|
|
1093
|
+
$.$mol_compare_deep = $mol_compare_deep;
|
|
1094
|
+
function compare_array(left, right) {
|
|
1095
|
+
const len = left.length;
|
|
1096
|
+
if (len !== right.length)
|
|
1097
|
+
return false;
|
|
1098
|
+
for (let i = 0; i < len; ++i) {
|
|
1099
|
+
if (!$mol_compare_deep(left[i], right[i]))
|
|
1100
|
+
return false;
|
|
1101
|
+
}
|
|
1102
|
+
return true;
|
|
1103
|
+
}
|
|
1104
|
+
function compare_buffer(left, right) {
|
|
1105
|
+
const len = left.byteLength;
|
|
1106
|
+
if (len !== right.byteLength)
|
|
1107
|
+
return false;
|
|
1108
|
+
if (left instanceof DataView)
|
|
1109
|
+
return compare_buffer(new Uint8Array(left.buffer, left.byteOffset, left.byteLength), new Uint8Array(right.buffer, left.byteOffset, left.byteLength));
|
|
1110
|
+
for (let i = 0; i < len; ++i) {
|
|
1111
|
+
if (left[i] !== right[i])
|
|
1112
|
+
return false;
|
|
1113
|
+
}
|
|
1114
|
+
return true;
|
|
1115
|
+
}
|
|
1116
|
+
function compare_iterator(left, right) {
|
|
1117
|
+
while (true) {
|
|
1118
|
+
const left_next = left.next();
|
|
1119
|
+
const right_next = right.next();
|
|
1120
|
+
if (left_next.done !== right_next.done)
|
|
1121
|
+
return false;
|
|
1122
|
+
if (left_next.done)
|
|
1123
|
+
break;
|
|
1124
|
+
if (!$mol_compare_deep(left_next.value, right_next.value))
|
|
1125
|
+
return false;
|
|
1126
|
+
}
|
|
1127
|
+
return true;
|
|
1128
|
+
}
|
|
1129
|
+
function compare_set(left, right) {
|
|
1130
|
+
if (left.size !== right.size)
|
|
1131
|
+
return false;
|
|
1132
|
+
return compare_iterator(left.values(), right.values());
|
|
1133
|
+
}
|
|
1134
|
+
function compare_map(left, right) {
|
|
1135
|
+
if (left.size !== right.size)
|
|
1136
|
+
return false;
|
|
1137
|
+
return compare_iterator(left.keys(), right.keys())
|
|
1138
|
+
&& compare_iterator(left.values(), right.values());
|
|
1139
|
+
}
|
|
1140
|
+
function compare_pojo(left, right) {
|
|
1141
|
+
const left_keys = Object.getOwnPropertyNames(left);
|
|
1142
|
+
const right_keys = Object.getOwnPropertyNames(right);
|
|
1143
|
+
if (!compare_array(left_keys, right_keys))
|
|
1144
|
+
return false;
|
|
1145
|
+
for (let key of left_keys) {
|
|
1146
|
+
if (!$mol_compare_deep(left[key], right[key]))
|
|
1147
|
+
return false;
|
|
1148
|
+
}
|
|
1149
|
+
const left_syms = Object.getOwnPropertySymbols(left);
|
|
1150
|
+
const right_syms = Object.getOwnPropertySymbols(right);
|
|
1151
|
+
if (!compare_array(left_syms, right_syms))
|
|
1152
|
+
return false;
|
|
1153
|
+
for (let key of left_syms) {
|
|
1154
|
+
if (!$mol_compare_deep(left[key], right[key]))
|
|
1155
|
+
return false;
|
|
1156
|
+
}
|
|
1157
|
+
return true;
|
|
1158
|
+
}
|
|
1159
|
+
function compare_primitive(left, right) {
|
|
1160
|
+
return Object.is(left[Symbol.toPrimitive]('default'), right[Symbol.toPrimitive]('default'));
|
|
1161
|
+
}
|
|
1162
|
+
})($ || ($ = {}));
|
|
1163
|
+
|
|
1164
|
+
;
|
|
1165
|
+
"use strict";
|
|
1166
|
+
var $;
|
|
1167
|
+
(function ($) {
|
|
1168
|
+
function $mol_log3_area_lazy(event) {
|
|
1169
|
+
const self = this;
|
|
1170
|
+
const stack = self.$mol_log3_stack;
|
|
1171
|
+
const deep = stack.length;
|
|
1172
|
+
let logged = false;
|
|
1173
|
+
stack.push(() => {
|
|
1174
|
+
logged = true;
|
|
1175
|
+
self.$mol_log3_area.call(self, event);
|
|
1176
|
+
});
|
|
1177
|
+
return () => {
|
|
1178
|
+
if (logged)
|
|
1179
|
+
self.console.groupEnd();
|
|
1180
|
+
if (stack.length > deep)
|
|
1181
|
+
stack.length = deep;
|
|
1182
|
+
};
|
|
1183
|
+
}
|
|
1184
|
+
$.$mol_log3_area_lazy = $mol_log3_area_lazy;
|
|
1185
|
+
$.$mol_log3_stack = [];
|
|
1186
|
+
})($ || ($ = {}));
|
|
1187
|
+
|
|
1188
|
+
;
|
|
1189
|
+
"use strict";
|
|
1190
|
+
var $;
|
|
1191
|
+
(function ($) {
|
|
1192
|
+
class $mol_span extends $mol_object2 {
|
|
1193
|
+
uri;
|
|
1194
|
+
source;
|
|
1195
|
+
row;
|
|
1196
|
+
col;
|
|
1197
|
+
length;
|
|
1198
|
+
constructor(uri, source, row, col, length) {
|
|
1199
|
+
super();
|
|
1200
|
+
this.uri = uri;
|
|
1201
|
+
this.source = source;
|
|
1202
|
+
this.row = row;
|
|
1203
|
+
this.col = col;
|
|
1204
|
+
this.length = length;
|
|
1205
|
+
this[Symbol.toStringTag] = this.uri + ('#' + this.row + ':' + this.col + '/' + this.length);
|
|
1206
|
+
}
|
|
1207
|
+
static unknown = $mol_span.begin('?');
|
|
1208
|
+
static begin(uri, source = '') {
|
|
1209
|
+
return new $mol_span(uri, source, 1, 1, 0);
|
|
1210
|
+
}
|
|
1211
|
+
static end(uri, source) {
|
|
1212
|
+
return new $mol_span(uri, source, 1, source.length + 1, 0);
|
|
1213
|
+
}
|
|
1214
|
+
static entire(uri, source) {
|
|
1215
|
+
return new $mol_span(uri, source, 1, 1, source.length);
|
|
1216
|
+
}
|
|
1217
|
+
toString() {
|
|
1218
|
+
return this[Symbol.toStringTag];
|
|
1219
|
+
}
|
|
1220
|
+
toJSON() {
|
|
1221
|
+
return {
|
|
1222
|
+
uri: this.uri,
|
|
1223
|
+
row: this.row,
|
|
1224
|
+
col: this.col,
|
|
1225
|
+
length: this.length
|
|
1226
|
+
};
|
|
1227
|
+
}
|
|
1228
|
+
error(message, Class = Error) {
|
|
1229
|
+
return new Class(`${message} (${this})`);
|
|
1230
|
+
}
|
|
1231
|
+
span(row, col, length) {
|
|
1232
|
+
return new $mol_span(this.uri, this.source, row, col, length);
|
|
1233
|
+
}
|
|
1234
|
+
after(length = 0) {
|
|
1235
|
+
return new $mol_span(this.uri, this.source, this.row, this.col + this.length, length);
|
|
1236
|
+
}
|
|
1237
|
+
slice(begin, end = -1) {
|
|
1238
|
+
let len = this.length;
|
|
1239
|
+
if (begin < 0)
|
|
1240
|
+
begin += len;
|
|
1241
|
+
if (end < 0)
|
|
1242
|
+
end += len;
|
|
1243
|
+
if (begin < 0 || begin > len)
|
|
1244
|
+
this.$.$mol_fail(this.error(`Begin value '${begin}' out of range`, RangeError));
|
|
1245
|
+
if (end < 0 || end > len)
|
|
1246
|
+
this.$.$mol_fail(this.error(`End value '${end}' out of range`, RangeError));
|
|
1247
|
+
if (end < begin)
|
|
1248
|
+
this.$.$mol_fail(this.error(`End value '${end}' can't be less than begin value`, RangeError));
|
|
1249
|
+
return this.span(this.row, this.col + begin, end - begin);
|
|
1250
|
+
}
|
|
1251
|
+
}
|
|
1252
|
+
$.$mol_span = $mol_span;
|
|
1253
|
+
})($ || ($ = {}));
|
|
1254
|
+
|
|
1255
|
+
;
|
|
1256
|
+
"use strict";
|
|
1257
|
+
var $;
|
|
1258
|
+
(function ($) {
|
|
1259
|
+
function $mol_tree2_to_string(tree) {
|
|
1260
|
+
let output = [];
|
|
1261
|
+
function dump(tree, prefix = '') {
|
|
1262
|
+
if (tree.type.length) {
|
|
1263
|
+
if (!prefix.length) {
|
|
1264
|
+
prefix = "\t";
|
|
1265
|
+
}
|
|
1266
|
+
output.push(tree.type);
|
|
1267
|
+
if (tree.kids.length == 1) {
|
|
1268
|
+
output.push(' ');
|
|
1269
|
+
dump(tree.kids[0], prefix);
|
|
1270
|
+
return;
|
|
1271
|
+
}
|
|
1272
|
+
output.push("\n");
|
|
1273
|
+
}
|
|
1274
|
+
else if (tree.value.length || prefix.length) {
|
|
1275
|
+
output.push("\\" + tree.value + "\n");
|
|
1276
|
+
}
|
|
1277
|
+
for (const kid of tree.kids) {
|
|
1278
|
+
output.push(prefix);
|
|
1279
|
+
dump(kid, prefix + "\t");
|
|
1280
|
+
}
|
|
1281
|
+
}
|
|
1282
|
+
dump(tree);
|
|
1283
|
+
return output.join('');
|
|
1284
|
+
}
|
|
1285
|
+
$.$mol_tree2_to_string = $mol_tree2_to_string;
|
|
1286
|
+
})($ || ($ = {}));
|
|
1287
|
+
|
|
1288
|
+
;
|
|
1289
|
+
"use strict";
|
|
1290
|
+
var $;
|
|
1291
|
+
(function ($) {
|
|
1292
|
+
class $mol_tree2 extends Object {
|
|
1293
|
+
type;
|
|
1294
|
+
value;
|
|
1295
|
+
kids;
|
|
1296
|
+
span;
|
|
1297
|
+
constructor(type, value, kids, span) {
|
|
1298
|
+
super();
|
|
1299
|
+
this.type = type;
|
|
1300
|
+
this.value = value;
|
|
1301
|
+
this.kids = kids;
|
|
1302
|
+
this.span = span;
|
|
1303
|
+
this[Symbol.toStringTag] = type || '\\' + value;
|
|
1304
|
+
}
|
|
1305
|
+
static list(kids, span = $mol_span.unknown) {
|
|
1306
|
+
return new $mol_tree2('', '', kids, span);
|
|
1307
|
+
}
|
|
1308
|
+
list(kids) {
|
|
1309
|
+
return $mol_tree2.list(kids, this.span);
|
|
1310
|
+
}
|
|
1311
|
+
static data(value, kids = [], span = $mol_span.unknown) {
|
|
1312
|
+
const chunks = value.split('\n');
|
|
1313
|
+
if (chunks.length > 1) {
|
|
1314
|
+
let kid_span = span.span(span.row, span.col, 0);
|
|
1315
|
+
const data = chunks.map(chunk => {
|
|
1316
|
+
kid_span = kid_span.after(chunk.length);
|
|
1317
|
+
return new $mol_tree2('', chunk, [], kid_span);
|
|
1318
|
+
});
|
|
1319
|
+
kids = [...data, ...kids];
|
|
1320
|
+
value = '';
|
|
1321
|
+
}
|
|
1322
|
+
return new $mol_tree2('', value, kids, span);
|
|
1323
|
+
}
|
|
1324
|
+
data(value, kids = []) {
|
|
1325
|
+
return $mol_tree2.data(value, kids, this.span);
|
|
1326
|
+
}
|
|
1327
|
+
static struct(type, kids = [], span = $mol_span.unknown) {
|
|
1328
|
+
if (/[ \n\t\\]/.test(type)) {
|
|
1329
|
+
$$.$mol_fail(span.error(`Wrong type ${JSON.stringify(type)}`));
|
|
1330
|
+
}
|
|
1331
|
+
return new $mol_tree2(type, '', kids, span);
|
|
1332
|
+
}
|
|
1333
|
+
struct(type, kids = []) {
|
|
1334
|
+
return $mol_tree2.struct(type, kids, this.span);
|
|
1335
|
+
}
|
|
1336
|
+
clone(kids, span = this.span) {
|
|
1337
|
+
return new $mol_tree2(this.type, this.value, kids, span);
|
|
1338
|
+
}
|
|
1339
|
+
text() {
|
|
1340
|
+
var values = [];
|
|
1341
|
+
for (var kid of this.kids) {
|
|
1342
|
+
if (kid.type)
|
|
1343
|
+
continue;
|
|
1344
|
+
values.push(kid.value);
|
|
1345
|
+
}
|
|
1346
|
+
return this.value + values.join('\n');
|
|
1347
|
+
}
|
|
1348
|
+
static fromString(str, uri = 'unknown') {
|
|
1349
|
+
return $$.$mol_tree2_from_string(str, uri);
|
|
1350
|
+
}
|
|
1351
|
+
toString() {
|
|
1352
|
+
return $$.$mol_tree2_to_string(this);
|
|
1353
|
+
}
|
|
1354
|
+
insert(value, ...path) {
|
|
1355
|
+
if (path.length === 0)
|
|
1356
|
+
return value;
|
|
1357
|
+
const type = path[0];
|
|
1358
|
+
if (typeof type === 'string') {
|
|
1359
|
+
let replaced = false;
|
|
1360
|
+
const sub = this.kids.map((item, index) => {
|
|
1361
|
+
if (item.type !== type)
|
|
1362
|
+
return item;
|
|
1363
|
+
replaced = true;
|
|
1364
|
+
return item.insert(value, ...path.slice(1));
|
|
1365
|
+
}).filter(Boolean);
|
|
1366
|
+
if (!replaced && value) {
|
|
1367
|
+
sub.push(this.struct(type, []).insert(value, ...path.slice(1)));
|
|
1368
|
+
}
|
|
1369
|
+
return this.clone(sub);
|
|
1370
|
+
}
|
|
1371
|
+
else if (typeof type === 'number') {
|
|
1372
|
+
const sub = this.kids.slice();
|
|
1373
|
+
sub[type] = (sub[type] || this.list([]))
|
|
1374
|
+
.insert(value, ...path.slice(1));
|
|
1375
|
+
return this.clone(sub.filter(Boolean));
|
|
1376
|
+
}
|
|
1377
|
+
else {
|
|
1378
|
+
const kids = ((this.kids.length === 0) ? [this.list([])] : this.kids)
|
|
1379
|
+
.map(item => item.insert(value, ...path.slice(1)))
|
|
1380
|
+
.filter(Boolean);
|
|
1381
|
+
return this.clone(kids);
|
|
1382
|
+
}
|
|
1383
|
+
}
|
|
1384
|
+
select(...path) {
|
|
1385
|
+
let next = [this];
|
|
1386
|
+
for (const type of path) {
|
|
1387
|
+
if (!next.length)
|
|
1388
|
+
break;
|
|
1389
|
+
const prev = next;
|
|
1390
|
+
next = [];
|
|
1391
|
+
for (var item of prev) {
|
|
1392
|
+
switch (typeof (type)) {
|
|
1393
|
+
case 'string':
|
|
1394
|
+
for (var child of item.kids) {
|
|
1395
|
+
if (child.type == type) {
|
|
1396
|
+
next.push(child);
|
|
1397
|
+
}
|
|
1398
|
+
}
|
|
1399
|
+
break;
|
|
1400
|
+
case 'number':
|
|
1401
|
+
if (type < item.kids.length)
|
|
1402
|
+
next.push(item.kids[type]);
|
|
1403
|
+
break;
|
|
1404
|
+
default: next.push(...item.kids);
|
|
1405
|
+
}
|
|
1406
|
+
}
|
|
1407
|
+
}
|
|
1408
|
+
return this.list(next);
|
|
1409
|
+
}
|
|
1410
|
+
filter(path, value) {
|
|
1411
|
+
const sub = this.kids.filter(item => {
|
|
1412
|
+
var found = item.select(...path);
|
|
1413
|
+
if (value === undefined) {
|
|
1414
|
+
return Boolean(found.kids.length);
|
|
1415
|
+
}
|
|
1416
|
+
else {
|
|
1417
|
+
return found.kids.some(child => child.value == value);
|
|
1418
|
+
}
|
|
1419
|
+
});
|
|
1420
|
+
return this.clone(sub);
|
|
1421
|
+
}
|
|
1422
|
+
hack_self(belt, context = {}) {
|
|
1423
|
+
let handle = belt[this.type] || belt[''];
|
|
1424
|
+
if (!handle || handle === Object.prototype[this.type]) {
|
|
1425
|
+
handle = (input, belt, context) => [
|
|
1426
|
+
input.clone(input.hack(belt, context), context.span)
|
|
1427
|
+
];
|
|
1428
|
+
}
|
|
1429
|
+
try {
|
|
1430
|
+
return handle(this, belt, context);
|
|
1431
|
+
}
|
|
1432
|
+
catch (error) {
|
|
1433
|
+
error.message += `\n${this.clone([])}${this.span}`;
|
|
1434
|
+
$mol_fail_hidden(error);
|
|
1435
|
+
}
|
|
1436
|
+
}
|
|
1437
|
+
hack(belt, context = {}) {
|
|
1438
|
+
return [].concat(...this.kids.map(child => child.hack_self(belt, context)));
|
|
1439
|
+
}
|
|
1440
|
+
error(message, Class = Error) {
|
|
1441
|
+
return this.span.error(`${message}\n${this.clone([])}`, Class);
|
|
1442
|
+
}
|
|
1443
|
+
}
|
|
1444
|
+
$.$mol_tree2 = $mol_tree2;
|
|
1445
|
+
class $mol_tree2_empty extends $mol_tree2 {
|
|
1446
|
+
constructor() {
|
|
1447
|
+
super('', '', [], $mol_span.unknown);
|
|
1448
|
+
}
|
|
1449
|
+
}
|
|
1450
|
+
$.$mol_tree2_empty = $mol_tree2_empty;
|
|
1451
|
+
})($ || ($ = {}));
|
|
1452
|
+
|
|
1453
|
+
;
|
|
1454
|
+
"use strict";
|
|
1455
|
+
var $;
|
|
1456
|
+
(function ($) {
|
|
1457
|
+
class $mol_error_syntax extends SyntaxError {
|
|
1458
|
+
reason;
|
|
1459
|
+
line;
|
|
1460
|
+
span;
|
|
1461
|
+
constructor(reason, line, span) {
|
|
1462
|
+
super(`${reason}\n${span}\n${line.substring(0, span.col - 1).replace(/\S/g, ' ')}${''.padEnd(span.length, '!')}\n${line}`);
|
|
1463
|
+
this.reason = reason;
|
|
1464
|
+
this.line = line;
|
|
1465
|
+
this.span = span;
|
|
1466
|
+
}
|
|
1467
|
+
}
|
|
1468
|
+
$.$mol_error_syntax = $mol_error_syntax;
|
|
1469
|
+
})($ || ($ = {}));
|
|
1470
|
+
|
|
1471
|
+
;
|
|
1472
|
+
"use strict";
|
|
1473
|
+
var $;
|
|
1474
|
+
(function ($) {
|
|
1475
|
+
function $mol_tree2_from_string(str, uri = '?') {
|
|
1476
|
+
const span = $mol_span.entire(uri, str);
|
|
1477
|
+
var root = $mol_tree2.list([], span);
|
|
1478
|
+
var stack = [root];
|
|
1479
|
+
var pos = 0, row = 0, min_indent = 0;
|
|
1480
|
+
while (str.length > pos) {
|
|
1481
|
+
var indent = 0;
|
|
1482
|
+
var line_start = pos;
|
|
1483
|
+
row++;
|
|
1484
|
+
while (str.length > pos && str[pos] == '\t') {
|
|
1485
|
+
indent++;
|
|
1486
|
+
pos++;
|
|
1487
|
+
}
|
|
1488
|
+
if (!root.kids.length) {
|
|
1489
|
+
min_indent = indent;
|
|
1490
|
+
}
|
|
1491
|
+
indent -= min_indent;
|
|
1492
|
+
if (indent < 0 || indent >= stack.length) {
|
|
1493
|
+
const sp = span.span(row, 1, pos - line_start);
|
|
1494
|
+
while (str.length > pos && str[pos] != '\n') {
|
|
1495
|
+
pos++;
|
|
1496
|
+
}
|
|
1497
|
+
if (indent < 0) {
|
|
1498
|
+
if (str.length > pos) {
|
|
1499
|
+
this.$mol_fail(new this.$mol_error_syntax(`Too few tabs`, str.substring(line_start, pos), sp));
|
|
1500
|
+
}
|
|
1501
|
+
}
|
|
1502
|
+
else {
|
|
1503
|
+
this.$mol_fail(new this.$mol_error_syntax(`Too many tabs`, str.substring(line_start, pos), sp));
|
|
1504
|
+
}
|
|
1505
|
+
}
|
|
1506
|
+
stack.length = indent + 1;
|
|
1507
|
+
var parent = stack[indent];
|
|
1508
|
+
while (str.length > pos && str[pos] != '\\' && str[pos] != '\n') {
|
|
1509
|
+
var error_start = pos;
|
|
1510
|
+
while (str.length > pos && (str[pos] == ' ' || str[pos] == '\t')) {
|
|
1511
|
+
pos++;
|
|
1512
|
+
}
|
|
1513
|
+
if (pos > error_start) {
|
|
1514
|
+
let line_end = str.indexOf('\n', pos);
|
|
1515
|
+
if (line_end === -1)
|
|
1516
|
+
line_end = str.length;
|
|
1517
|
+
const sp = span.span(row, error_start - line_start + 1, pos - error_start);
|
|
1518
|
+
this.$mol_fail(new this.$mol_error_syntax(`Wrong nodes separator`, str.substring(line_start, line_end), sp));
|
|
1519
|
+
}
|
|
1520
|
+
var type_start = pos;
|
|
1521
|
+
while (str.length > pos &&
|
|
1522
|
+
str[pos] != '\\' &&
|
|
1523
|
+
str[pos] != ' ' &&
|
|
1524
|
+
str[pos] != '\t' &&
|
|
1525
|
+
str[pos] != '\n') {
|
|
1526
|
+
pos++;
|
|
1527
|
+
}
|
|
1528
|
+
if (pos > type_start) {
|
|
1529
|
+
let next = new $mol_tree2(str.slice(type_start, pos), '', [], span.span(row, type_start - line_start + 1, pos - type_start));
|
|
1530
|
+
const parent_kids = parent.kids;
|
|
1531
|
+
parent_kids.push(next);
|
|
1532
|
+
parent = next;
|
|
1533
|
+
}
|
|
1534
|
+
if (str.length > pos && str[pos] == ' ') {
|
|
1535
|
+
pos++;
|
|
1536
|
+
}
|
|
1537
|
+
}
|
|
1538
|
+
if (str.length > pos && str[pos] == '\\') {
|
|
1539
|
+
var data_start = pos;
|
|
1540
|
+
while (str.length > pos && str[pos] != '\n') {
|
|
1541
|
+
pos++;
|
|
1542
|
+
}
|
|
1543
|
+
let next = new $mol_tree2('', str.slice(data_start + 1, pos), [], span.span(row, data_start - line_start + 2, pos - data_start - 1));
|
|
1544
|
+
const parent_kids = parent.kids;
|
|
1545
|
+
parent_kids.push(next);
|
|
1546
|
+
parent = next;
|
|
1547
|
+
}
|
|
1548
|
+
if (str.length === pos && stack.length > 0) {
|
|
1549
|
+
const sp = span.span(row, pos - line_start + 1, 1);
|
|
1550
|
+
this.$mol_fail(new this.$mol_error_syntax(`Unexpected EOF, LF required`, str.substring(line_start, str.length), sp));
|
|
1551
|
+
}
|
|
1552
|
+
stack.push(parent);
|
|
1553
|
+
pos++;
|
|
1554
|
+
}
|
|
1555
|
+
return root;
|
|
1556
|
+
}
|
|
1557
|
+
$.$mol_tree2_from_string = $mol_tree2_from_string;
|
|
1558
|
+
})($ || ($ = {}));
|
|
1559
|
+
|
|
1560
|
+
;
|
|
1561
|
+
"use strict";
|
|
1562
|
+
var $;
|
|
1563
|
+
(function ($) {
|
|
1564
|
+
function $mol_tree2_from_json(json, span = $mol_span.unknown) {
|
|
1565
|
+
if (typeof json === 'boolean' || typeof json === 'number' || json === null) {
|
|
1566
|
+
return new $mol_tree2(String(json), '', [], span);
|
|
1567
|
+
}
|
|
1568
|
+
if (typeof json === 'string') {
|
|
1569
|
+
return $mol_tree2.data(json, [], span);
|
|
1570
|
+
}
|
|
1571
|
+
if (typeof json.toJSON === 'function') {
|
|
1572
|
+
return $mol_tree2_from_json(json.toJSON());
|
|
1573
|
+
}
|
|
1574
|
+
if (Array.isArray(json)) {
|
|
1575
|
+
const sub = json.map(json => $mol_tree2_from_json(json, span));
|
|
1576
|
+
return new $mol_tree2('/', '', sub, span);
|
|
1577
|
+
}
|
|
1578
|
+
if (ArrayBuffer.isView(json)) {
|
|
1579
|
+
const buf = new Uint8Array(json.buffer, json.byteOffset, json.byteLength);
|
|
1580
|
+
return $mol_tree2.data(String.fromCharCode(...buf), [], span);
|
|
1581
|
+
}
|
|
1582
|
+
if (json instanceof Date) {
|
|
1583
|
+
return new $mol_tree2('', json.toISOString(), [], span);
|
|
1584
|
+
}
|
|
1585
|
+
if (json.toString !== Object.prototype.toString) {
|
|
1586
|
+
return $mol_tree2.data(json.toString(), [], span);
|
|
1587
|
+
}
|
|
1588
|
+
if (json instanceof Error) {
|
|
1589
|
+
const { name, message, stack } = json;
|
|
1590
|
+
json = { ...json, name, message, stack };
|
|
1591
|
+
}
|
|
1592
|
+
const sub = [];
|
|
1593
|
+
for (var key in json) {
|
|
1594
|
+
const val = json[key];
|
|
1595
|
+
if (val === undefined)
|
|
1596
|
+
continue;
|
|
1597
|
+
const subsub = $mol_tree2_from_json(val, span);
|
|
1598
|
+
if (/^[^\n\t\\ ]+$/.test(key)) {
|
|
1599
|
+
sub.push(new $mol_tree2(key, '', [subsub], span));
|
|
1600
|
+
}
|
|
1601
|
+
else {
|
|
1602
|
+
sub.push($mol_tree2.data(key, [subsub], span));
|
|
1603
|
+
}
|
|
1604
|
+
}
|
|
1605
|
+
return new $mol_tree2('*', '', sub, span);
|
|
1606
|
+
}
|
|
1607
|
+
$.$mol_tree2_from_json = $mol_tree2_from_json;
|
|
1519
1608
|
})($ || ($ = {}));
|
|
1520
1609
|
|
|
1521
1610
|
;
|
|
1522
1611
|
"use strict";
|
|
1523
1612
|
var $;
|
|
1524
1613
|
(function ($) {
|
|
1525
|
-
|
|
1526
|
-
|
|
1527
|
-
|
|
1528
|
-
|
|
1529
|
-
|
|
1530
|
-
|
|
1531
|
-
|
|
1532
|
-
|
|
1533
|
-
|
|
1534
|
-
|
|
1535
|
-
|
|
1536
|
-
|
|
1537
|
-
|
|
1538
|
-
|
|
1539
|
-
|
|
1540
|
-
|
|
1541
|
-
|
|
1542
|
-
|
|
1543
|
-
|
|
1544
|
-
|
|
1545
|
-
|
|
1546
|
-
|
|
1547
|
-
|
|
1548
|
-
|
|
1549
|
-
|
|
1550
|
-
|
|
1551
|
-
|
|
1552
|
-
|
|
1553
|
-
|
|
1554
|
-
|
|
1555
|
-
|
|
1556
|
-
|
|
1557
|
-
|
|
1558
|
-
|
|
1559
|
-
|
|
1560
|
-
|
|
1561
|
-
|
|
1562
|
-
}
|
|
1563
|
-
left_cache.set(right, true);
|
|
1564
|
-
let result;
|
|
1565
|
-
try {
|
|
1566
|
-
if (!left_proto)
|
|
1567
|
-
result = compare_pojo(left, right);
|
|
1568
|
-
else if (!Reflect.getPrototypeOf(left_proto))
|
|
1569
|
-
result = compare_pojo(left, right);
|
|
1570
|
-
else if (Symbol.toPrimitive in left)
|
|
1571
|
-
result = compare_primitive(left, right);
|
|
1572
|
-
else if (Array.isArray(left))
|
|
1573
|
-
result = compare_array(left, right);
|
|
1574
|
-
else if (left instanceof Set)
|
|
1575
|
-
result = compare_set(left, right);
|
|
1576
|
-
else if (left instanceof Map)
|
|
1577
|
-
result = compare_map(left, right);
|
|
1578
|
-
else if (ArrayBuffer.isView(left))
|
|
1579
|
-
result = compare_buffer(left, right);
|
|
1580
|
-
else if (Symbol.iterator in left)
|
|
1581
|
-
result = compare_iterator(left[Symbol.iterator](), right[Symbol.iterator]());
|
|
1582
|
-
else
|
|
1583
|
-
result = false;
|
|
1584
|
-
}
|
|
1585
|
-
finally {
|
|
1586
|
-
left_cache.set(right, result);
|
|
1587
|
-
}
|
|
1588
|
-
return result;
|
|
1589
|
-
}
|
|
1590
|
-
$.$mol_compare_deep = $mol_compare_deep;
|
|
1591
|
-
function compare_array(left, right) {
|
|
1592
|
-
const len = left.length;
|
|
1593
|
-
if (len !== right.length)
|
|
1594
|
-
return false;
|
|
1595
|
-
for (let i = 0; i < len; ++i) {
|
|
1596
|
-
if (!$mol_compare_deep(left[i], right[i]))
|
|
1597
|
-
return false;
|
|
1598
|
-
}
|
|
1599
|
-
return true;
|
|
1600
|
-
}
|
|
1601
|
-
function compare_buffer(left, right) {
|
|
1602
|
-
const len = left.byteLength;
|
|
1603
|
-
if (len !== right.byteLength)
|
|
1604
|
-
return false;
|
|
1605
|
-
if (left instanceof DataView)
|
|
1606
|
-
return compare_buffer(new Uint8Array(left.buffer, left.byteOffset, left.byteLength), new Uint8Array(right.buffer, left.byteOffset, left.byteLength));
|
|
1607
|
-
for (let i = 0; i < len; ++i) {
|
|
1608
|
-
if (left[i] !== right[i])
|
|
1609
|
-
return false;
|
|
1610
|
-
}
|
|
1611
|
-
return true;
|
|
1612
|
-
}
|
|
1613
|
-
function compare_iterator(left, right) {
|
|
1614
|
-
while (true) {
|
|
1615
|
-
const left_next = left.next();
|
|
1616
|
-
const right_next = right.next();
|
|
1617
|
-
if (left_next.done !== right_next.done)
|
|
1618
|
-
return false;
|
|
1619
|
-
if (left_next.done)
|
|
1620
|
-
break;
|
|
1621
|
-
if (!$mol_compare_deep(left_next.value, right_next.value))
|
|
1622
|
-
return false;
|
|
1623
|
-
}
|
|
1624
|
-
return true;
|
|
1625
|
-
}
|
|
1626
|
-
function compare_set(left, right) {
|
|
1627
|
-
if (left.size !== right.size)
|
|
1628
|
-
return false;
|
|
1629
|
-
return compare_iterator(left.values(), right.values());
|
|
1630
|
-
}
|
|
1631
|
-
function compare_map(left, right) {
|
|
1632
|
-
if (left.size !== right.size)
|
|
1633
|
-
return false;
|
|
1634
|
-
return compare_iterator(left.keys(), right.keys())
|
|
1635
|
-
&& compare_iterator(left.values(), right.values());
|
|
1636
|
-
}
|
|
1637
|
-
function compare_pojo(left, right) {
|
|
1638
|
-
const left_keys = Object.getOwnPropertyNames(left);
|
|
1639
|
-
const right_keys = Object.getOwnPropertyNames(right);
|
|
1640
|
-
if (!compare_array(left_keys, right_keys))
|
|
1641
|
-
return false;
|
|
1642
|
-
for (let key of left_keys) {
|
|
1643
|
-
if (!$mol_compare_deep(left[key], right[key]))
|
|
1644
|
-
return false;
|
|
1645
|
-
}
|
|
1646
|
-
const left_syms = Object.getOwnPropertySymbols(left);
|
|
1647
|
-
const right_syms = Object.getOwnPropertySymbols(right);
|
|
1648
|
-
if (!compare_array(left_syms, right_syms))
|
|
1649
|
-
return false;
|
|
1650
|
-
for (let key of left_syms) {
|
|
1651
|
-
if (!$mol_compare_deep(left[key], right[key]))
|
|
1652
|
-
return false;
|
|
1614
|
+
class $mol_term_color {
|
|
1615
|
+
static reset = this.ansi(0, 0);
|
|
1616
|
+
static bold = this.ansi(1, 22);
|
|
1617
|
+
static italic = this.ansi(3, 23);
|
|
1618
|
+
static underline = this.ansi(4, 24);
|
|
1619
|
+
static inverse = this.ansi(7, 27);
|
|
1620
|
+
static hidden = this.ansi(8, 28);
|
|
1621
|
+
static strike = this.ansi(9, 29);
|
|
1622
|
+
static gray = this.ansi(90, 39);
|
|
1623
|
+
static red = this.ansi(91, 39);
|
|
1624
|
+
static green = this.ansi(92, 39);
|
|
1625
|
+
static yellow = this.ansi(93, 39);
|
|
1626
|
+
static blue = this.ansi(94, 39);
|
|
1627
|
+
static magenta = this.ansi(95, 39);
|
|
1628
|
+
static cyan = this.ansi(96, 39);
|
|
1629
|
+
static Gray = (str) => this.inverse(this.gray(str));
|
|
1630
|
+
static Red = (str) => this.inverse(this.red(str));
|
|
1631
|
+
static Green = (str) => this.inverse(this.green(str));
|
|
1632
|
+
static Yellow = (str) => this.inverse(this.yellow(str));
|
|
1633
|
+
static Blue = (str) => this.inverse(this.blue(str));
|
|
1634
|
+
static Magenta = (str) => this.inverse(this.magenta(str));
|
|
1635
|
+
static Cyan = (str) => this.inverse(this.cyan(str));
|
|
1636
|
+
static ansi(open, close) {
|
|
1637
|
+
if (typeof process === 'undefined')
|
|
1638
|
+
return String;
|
|
1639
|
+
if (!process.stdout.isTTY)
|
|
1640
|
+
return String;
|
|
1641
|
+
const prefix = `\x1b[${open}m`;
|
|
1642
|
+
const postfix = `\x1b[${close}m`;
|
|
1643
|
+
const suffix_regexp = new RegExp(postfix.replace('[', '\\['), 'g');
|
|
1644
|
+
return function colorer(str) {
|
|
1645
|
+
str = String(str);
|
|
1646
|
+
if (str === '')
|
|
1647
|
+
return str;
|
|
1648
|
+
const suffix = str.replace(suffix_regexp, prefix);
|
|
1649
|
+
return prefix + suffix + postfix;
|
|
1650
|
+
};
|
|
1653
1651
|
}
|
|
1654
|
-
return true;
|
|
1655
1652
|
}
|
|
1656
|
-
|
|
1657
|
-
|
|
1653
|
+
$.$mol_term_color = $mol_term_color;
|
|
1654
|
+
})($ || ($ = {}));
|
|
1655
|
+
|
|
1656
|
+
;
|
|
1657
|
+
"use strict";
|
|
1658
|
+
var $;
|
|
1659
|
+
(function ($) {
|
|
1660
|
+
function $mol_log3_node_make(level, output, type, color) {
|
|
1661
|
+
return function $mol_log3_logger(event) {
|
|
1662
|
+
if (!event.time)
|
|
1663
|
+
event = { time: new Date().toISOString(), ...event };
|
|
1664
|
+
let tree = this.$mol_tree2_from_json(event);
|
|
1665
|
+
tree = tree.struct(type, tree.kids);
|
|
1666
|
+
let str = color(tree.toString());
|
|
1667
|
+
this.console[level](str);
|
|
1668
|
+
const self = this;
|
|
1669
|
+
return () => self.console.groupEnd();
|
|
1670
|
+
};
|
|
1658
1671
|
}
|
|
1672
|
+
$.$mol_log3_node_make = $mol_log3_node_make;
|
|
1673
|
+
$.$mol_log3_come = $mol_log3_node_make('info', 'stdout', 'come', $mol_term_color.blue);
|
|
1674
|
+
$.$mol_log3_done = $mol_log3_node_make('info', 'stdout', 'done', $mol_term_color.green);
|
|
1675
|
+
$.$mol_log3_fail = $mol_log3_node_make('error', 'stderr', 'fail', $mol_term_color.red);
|
|
1676
|
+
$.$mol_log3_warn = $mol_log3_node_make('warn', 'stderr', 'warn', $mol_term_color.yellow);
|
|
1677
|
+
$.$mol_log3_rise = $mol_log3_node_make('log', 'stdout', 'rise', $mol_term_color.magenta);
|
|
1678
|
+
$.$mol_log3_area = $mol_log3_node_make('log', 'stdout', 'area', $mol_term_color.cyan);
|
|
1659
1679
|
})($ || ($ = {}));
|
|
1660
1680
|
|
|
1661
1681
|
;
|
|
@@ -1774,97 +1794,115 @@ var $;
|
|
|
1774
1794
|
class $mol_run_error extends $mol_error_mix {
|
|
1775
1795
|
}
|
|
1776
1796
|
$.$mol_run_error = $mol_run_error;
|
|
1777
|
-
|
|
1778
|
-
$.$
|
|
1779
|
-
|
|
1780
|
-
|
|
1781
|
-
|
|
1782
|
-
|
|
1783
|
-
|
|
1784
|
-
this
|
|
1785
|
-
|
|
1797
|
+
$.$mol_run_spawn = (...args) => $node['child_process'].spawn(...args);
|
|
1798
|
+
$.$mol_run_spawn_sync = (...args) => $node['child_process'].spawnSync(...args);
|
|
1799
|
+
class $mol_run extends $mol_object {
|
|
1800
|
+
static async_enabled() {
|
|
1801
|
+
return Boolean(this.$.$mol_env()['MOL_RUN_ASYNC']);
|
|
1802
|
+
}
|
|
1803
|
+
static spawn(options) {
|
|
1804
|
+
const sync = !this.async_enabled() || !Boolean($mol_wire_auto());
|
|
1805
|
+
const env = options.env ?? this.$.$mol_env();
|
|
1806
|
+
return $mol_wire_sync(this).spawn_async({ ...options, sync, env });
|
|
1807
|
+
}
|
|
1808
|
+
static spawn_async({ dir, sync, timeout, command, env }) {
|
|
1809
|
+
const args_raw = typeof command === 'string' ? command.split(' ') : command;
|
|
1810
|
+
const [app, ...args] = args_raw;
|
|
1811
|
+
const opts = { shell: true, cwd: dir, env };
|
|
1812
|
+
const log_object = {
|
|
1813
|
+
place: `${this}.spawn()`,
|
|
1786
1814
|
message: 'Run',
|
|
1787
1815
|
command: args_raw.join(' '),
|
|
1788
1816
|
dir: $node.path.relative('', dir),
|
|
1817
|
+
};
|
|
1818
|
+
if (sync) {
|
|
1819
|
+
this.$.$mol_log3_come({
|
|
1820
|
+
hint: 'Run inside fiber',
|
|
1821
|
+
...log_object
|
|
1822
|
+
});
|
|
1823
|
+
let error;
|
|
1824
|
+
let res;
|
|
1825
|
+
try {
|
|
1826
|
+
res = this.$.$mol_run_spawn_sync(app, args, opts);
|
|
1827
|
+
error = res.error;
|
|
1828
|
+
}
|
|
1829
|
+
catch (err) {
|
|
1830
|
+
error = err;
|
|
1831
|
+
}
|
|
1832
|
+
if (!res || error || res.status) {
|
|
1833
|
+
throw new $mol_run_error(this.error_message(res), { ...log_object, status: res?.status, signal: res?.signal }, ...(error ? [error] : []));
|
|
1834
|
+
}
|
|
1835
|
+
return res;
|
|
1836
|
+
}
|
|
1837
|
+
let sub;
|
|
1838
|
+
try {
|
|
1839
|
+
sub = this.$.$mol_run_spawn(app, args, {
|
|
1840
|
+
...opts,
|
|
1841
|
+
stdio: ['pipe', 'inherit', 'inherit'],
|
|
1842
|
+
});
|
|
1843
|
+
}
|
|
1844
|
+
catch (error) {
|
|
1845
|
+
throw new $mol_run_error(this.error_message(undefined), log_object, error);
|
|
1846
|
+
}
|
|
1847
|
+
const pid = sub.pid ?? 0;
|
|
1848
|
+
this.$.$mol_log3_come({
|
|
1849
|
+
...log_object,
|
|
1850
|
+
pid,
|
|
1789
1851
|
});
|
|
1790
|
-
|
|
1791
|
-
|
|
1792
|
-
|
|
1793
|
-
|
|
1794
|
-
|
|
1795
|
-
|
|
1796
|
-
|
|
1797
|
-
|
|
1798
|
-
|
|
1799
|
-
|
|
1800
|
-
this.$mol_log3_come({
|
|
1801
|
-
place: '$mol_run_async',
|
|
1802
|
-
pid: sub.pid,
|
|
1803
|
-
message: 'Run',
|
|
1804
|
-
command: args_raw.join(' '),
|
|
1805
|
-
dir: $node.path.relative('', dir),
|
|
1806
|
-
});
|
|
1807
|
-
let killed = false;
|
|
1808
|
-
let timer;
|
|
1809
|
-
const std_data = [];
|
|
1810
|
-
const error_data = [];
|
|
1811
|
-
const add = (std_chunk, error_chunk) => {
|
|
1812
|
-
if (std_chunk)
|
|
1813
|
-
std_data.push(std_chunk);
|
|
1814
|
-
if (error_chunk)
|
|
1815
|
-
error_data.push(error_chunk);
|
|
1816
|
-
if (!timeout)
|
|
1817
|
-
return;
|
|
1818
|
-
clearTimeout(timer);
|
|
1819
|
-
timer = setTimeout(() => {
|
|
1820
|
-
const signal = killed ? 'SIGKILL' : 'SIGTERM';
|
|
1821
|
-
killed = true;
|
|
1822
|
-
add();
|
|
1823
|
-
sub.kill(signal);
|
|
1824
|
-
}, timeout);
|
|
1825
|
-
};
|
|
1826
|
-
add();
|
|
1827
|
-
sub.stdout?.on('data', data => add(data));
|
|
1828
|
-
sub.stderr?.on('data', data => add(undefined, data));
|
|
1829
|
-
const promise = new Promise((done, fail) => {
|
|
1830
|
-
const close = (error, status = null, signal = null) => {
|
|
1831
|
-
if (!timer && timeout)
|
|
1852
|
+
let timeout_kill = false;
|
|
1853
|
+
let timer;
|
|
1854
|
+
const std_data = [];
|
|
1855
|
+
const error_data = [];
|
|
1856
|
+
const add = (std_chunk, error_chunk) => {
|
|
1857
|
+
if (std_chunk)
|
|
1858
|
+
std_data.push(std_chunk);
|
|
1859
|
+
if (error_chunk)
|
|
1860
|
+
error_data.push(error_chunk);
|
|
1861
|
+
if (!timeout)
|
|
1832
1862
|
return;
|
|
1833
1863
|
clearTimeout(timer);
|
|
1834
|
-
timer =
|
|
1835
|
-
|
|
1836
|
-
|
|
1837
|
-
|
|
1838
|
-
signal
|
|
1839
|
-
|
|
1840
|
-
get stderr() { return Buffer.concat(error_data); }
|
|
1841
|
-
};
|
|
1842
|
-
this.$mol_log3_done({
|
|
1843
|
-
place: '$mol_run_async',
|
|
1844
|
-
pid: sub.pid,
|
|
1845
|
-
message: 'Run',
|
|
1846
|
-
status,
|
|
1847
|
-
command: args_raw.join(' '),
|
|
1848
|
-
dir: $node.path.relative('', dir),
|
|
1849
|
-
});
|
|
1850
|
-
if (error || status || killed)
|
|
1851
|
-
return fail(new $mol_run_error((res.stderr.toString() || res.stdout.toString() || 'Run error') + (killed ? ', timeout' : ''), { signal, timeout: killed }, ...error ? [error] : []));
|
|
1852
|
-
done(res);
|
|
1864
|
+
timer = setTimeout(() => {
|
|
1865
|
+
const signal = timeout_kill ? 'SIGKILL' : 'SIGTERM';
|
|
1866
|
+
timeout_kill = true;
|
|
1867
|
+
add();
|
|
1868
|
+
sub.kill(signal);
|
|
1869
|
+
}, timeout);
|
|
1853
1870
|
};
|
|
1854
|
-
|
|
1855
|
-
sub.on('
|
|
1856
|
-
sub.on('
|
|
1857
|
-
|
|
1858
|
-
|
|
1859
|
-
|
|
1860
|
-
|
|
1861
|
-
|
|
1862
|
-
|
|
1863
|
-
|
|
1864
|
-
|
|
1865
|
-
|
|
1866
|
-
|
|
1867
|
-
|
|
1871
|
+
add();
|
|
1872
|
+
sub.stdout?.on('data', data => add(data));
|
|
1873
|
+
sub.stderr?.on('data', data => add(undefined, data));
|
|
1874
|
+
const result_promise = new Promise((done, fail) => {
|
|
1875
|
+
const close = (error, status = null, signal = null) => {
|
|
1876
|
+
if (!timer && timeout)
|
|
1877
|
+
return;
|
|
1878
|
+
clearTimeout(timer);
|
|
1879
|
+
timer = undefined;
|
|
1880
|
+
const res = {
|
|
1881
|
+
pid,
|
|
1882
|
+
signal,
|
|
1883
|
+
get stdout() { return Buffer.concat(std_data); },
|
|
1884
|
+
get stderr() { return Buffer.concat(error_data); }
|
|
1885
|
+
};
|
|
1886
|
+
if (error || status || timeout_kill)
|
|
1887
|
+
return fail(new $mol_run_error(this.error_message(res) + (timeout_kill ? ', timeout' : ''), { ...log_object, pid, status, signal, timeout_kill }, ...error ? [error] : []));
|
|
1888
|
+
this.$.$mol_log3_done({
|
|
1889
|
+
...log_object,
|
|
1890
|
+
pid,
|
|
1891
|
+
});
|
|
1892
|
+
done(res);
|
|
1893
|
+
};
|
|
1894
|
+
sub.on('disconnect', () => close(new Error('Disconnected')));
|
|
1895
|
+
sub.on('error', err => close(err));
|
|
1896
|
+
sub.on('exit', (status, signal) => close(null, status, signal));
|
|
1897
|
+
});
|
|
1898
|
+
return Object.assign(result_promise, { destructor: () => {
|
|
1899
|
+
clearTimeout(timer);
|
|
1900
|
+
sub.kill('SIGKILL');
|
|
1901
|
+
} });
|
|
1902
|
+
}
|
|
1903
|
+
static error_message(res) {
|
|
1904
|
+
return res?.stderr.toString() || res?.stdout.toString() || 'Run error';
|
|
1905
|
+
}
|
|
1868
1906
|
}
|
|
1869
1907
|
$.$mol_run = $mol_run;
|
|
1870
1908
|
})($ || ($ = {}));
|
|
@@ -1874,7 +1912,7 @@ var $;
|
|
|
1874
1912
|
var $;
|
|
1875
1913
|
(function ($) {
|
|
1876
1914
|
function $mol_exec(dir, command, ...args) {
|
|
1877
|
-
return this.$mol_run({ command: [command, ...args], dir });
|
|
1915
|
+
return this.$mol_run.spawn({ command: [command, ...args], dir });
|
|
1878
1916
|
}
|
|
1879
1917
|
$.$mol_exec = $mol_exec;
|
|
1880
1918
|
})($ || ($ = {}));
|
|
@@ -2620,26 +2658,6 @@ var $;
|
|
|
2620
2658
|
$.$mol_wire_race = $mol_wire_race;
|
|
2621
2659
|
})($ || ($ = {}));
|
|
2622
2660
|
|
|
2623
|
-
;
|
|
2624
|
-
"use strict";
|
|
2625
|
-
var $;
|
|
2626
|
-
(function ($_1) {
|
|
2627
|
-
let $$;
|
|
2628
|
-
(function ($$) {
|
|
2629
|
-
let $;
|
|
2630
|
-
})($$ = $_1.$$ || ($_1.$$ = {}));
|
|
2631
|
-
$_1.$mol_object_field = Symbol('$mol_object_field');
|
|
2632
|
-
class $mol_object extends $mol_object2 {
|
|
2633
|
-
static make(config) {
|
|
2634
|
-
return super.create(obj => {
|
|
2635
|
-
for (let key in config)
|
|
2636
|
-
obj[key] = config[key];
|
|
2637
|
-
});
|
|
2638
|
-
}
|
|
2639
|
-
}
|
|
2640
|
-
$_1.$mol_object = $mol_object;
|
|
2641
|
-
})($ || ($ = {}));
|
|
2642
|
-
|
|
2643
2661
|
;
|
|
2644
2662
|
"use strict";
|
|
2645
2663
|
var $;
|