mol_plot_all 1.2.536 → 1.2.537
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 +74 -28
- package/node.deps.json +1 -1
- package/node.js +346 -257
- package/node.js.map +1 -1
- package/node.mjs +346 -257
- package/node.mjs.map +1 -1
- package/node.test.js +846 -252
- package/node.test.js.map +1 -1
- package/package.json +10 -2
- package/web.deps.json +1 -1
package/node.js
CHANGED
|
@@ -1406,248 +1406,167 @@ var $;
|
|
|
1406
1406
|
"use strict";
|
|
1407
1407
|
var $;
|
|
1408
1408
|
(function ($) {
|
|
1409
|
-
|
|
1410
|
-
|
|
1411
|
-
|
|
1412
|
-
data;
|
|
1413
|
-
sub;
|
|
1414
|
-
baseUri;
|
|
1409
|
+
class $mol_span extends $mol_object2 {
|
|
1410
|
+
uri;
|
|
1411
|
+
source;
|
|
1415
1412
|
row;
|
|
1416
1413
|
col;
|
|
1417
1414
|
length;
|
|
1418
|
-
constructor(
|
|
1415
|
+
constructor(uri, source, row, col, length) {
|
|
1419
1416
|
super();
|
|
1420
|
-
this.
|
|
1421
|
-
|
|
1422
|
-
|
|
1423
|
-
|
|
1424
|
-
|
|
1425
|
-
|
|
1426
|
-
}
|
|
1427
|
-
else {
|
|
1428
|
-
this.data = sub[0].data;
|
|
1429
|
-
this.sub = config.sub || [];
|
|
1430
|
-
}
|
|
1431
|
-
}
|
|
1432
|
-
else {
|
|
1433
|
-
this.data = config.data || '';
|
|
1434
|
-
this.sub = config.sub || [];
|
|
1435
|
-
}
|
|
1436
|
-
this.baseUri = config.baseUri || '';
|
|
1437
|
-
this.row = config.row || 0;
|
|
1438
|
-
this.col = config.col || 0;
|
|
1439
|
-
this.length = config.length || 0;
|
|
1440
|
-
}
|
|
1441
|
-
static values(str, baseUri) {
|
|
1442
|
-
return str.split('\n').map((data, index) => new $mol_tree({
|
|
1443
|
-
data: data,
|
|
1444
|
-
baseUri: baseUri,
|
|
1445
|
-
row: index + 1,
|
|
1446
|
-
length: data.length,
|
|
1447
|
-
}));
|
|
1417
|
+
this.uri = uri;
|
|
1418
|
+
this.source = source;
|
|
1419
|
+
this.row = row;
|
|
1420
|
+
this.col = col;
|
|
1421
|
+
this.length = length;
|
|
1422
|
+
this[Symbol.toStringTag] = `${this.uri}#${this.row}:${this.col}/${this.length}`;
|
|
1448
1423
|
}
|
|
1449
|
-
|
|
1450
|
-
|
|
1451
|
-
|
|
1452
|
-
data: ('data' in config) ? config.data : this.data,
|
|
1453
|
-
sub: ('sub' in config) ? config.sub : this.sub,
|
|
1454
|
-
baseUri: ('baseUri' in config) ? config.baseUri : this.baseUri,
|
|
1455
|
-
row: ('row' in config) ? config.row : this.row,
|
|
1456
|
-
col: ('col' in config) ? config.col : this.col,
|
|
1457
|
-
length: ('length' in config) ? config.length : this.length,
|
|
1458
|
-
value: config.value
|
|
1459
|
-
});
|
|
1424
|
+
static unknown = $mol_span.begin('?');
|
|
1425
|
+
static begin(uri, source = '') {
|
|
1426
|
+
return new $mol_span(uri, source, 1, 1, 0);
|
|
1460
1427
|
}
|
|
1461
|
-
|
|
1462
|
-
return new $
|
|
1463
|
-
|
|
1428
|
+
static end(uri, source) {
|
|
1429
|
+
return new $mol_span(uri, source, 1, source.length + 1, length);
|
|
1430
|
+
}
|
|
1431
|
+
static entire(uri, source) {
|
|
1432
|
+
return new $mol_span(uri, source, 1, 1, source.length);
|
|
1433
|
+
}
|
|
1434
|
+
toString() {
|
|
1435
|
+
return this[Symbol.toStringTag];
|
|
1436
|
+
}
|
|
1437
|
+
toJSON() {
|
|
1438
|
+
return {
|
|
1439
|
+
uri: this.uri,
|
|
1464
1440
|
row: this.row,
|
|
1465
1441
|
col: this.col,
|
|
1466
|
-
length: this.length
|
|
1467
|
-
|
|
1468
|
-
});
|
|
1469
|
-
}
|
|
1470
|
-
make_data(value, sub) {
|
|
1471
|
-
return this.make({ value, sub });
|
|
1472
|
-
}
|
|
1473
|
-
make_struct(type, sub) {
|
|
1474
|
-
return this.make({ type, sub });
|
|
1475
|
-
}
|
|
1476
|
-
static fromString(str, baseUri) {
|
|
1477
|
-
var root = new $mol_tree({ baseUri: baseUri });
|
|
1478
|
-
var stack = [root];
|
|
1479
|
-
var row = 0;
|
|
1480
|
-
var prefix = str.replace(/^\n?(\t*)[\s\S]*/, '$1');
|
|
1481
|
-
var lines = str.replace(new RegExp('^\\t{0,' + prefix.length + '}', 'mg'), '').split('\n');
|
|
1482
|
-
lines.forEach(line => {
|
|
1483
|
-
++row;
|
|
1484
|
-
var chunks = /^(\t*)((?:[^\n\t\\ ]+ *)*)(\\[^\n]*)?(.*?)(?:$|\n)/m.exec(line);
|
|
1485
|
-
if (!chunks || chunks[4])
|
|
1486
|
-
return this.$.$mol_fail(new Error(`Syntax error at ${baseUri}:${row}\n${line}`));
|
|
1487
|
-
var indent = chunks[1];
|
|
1488
|
-
var path = chunks[2];
|
|
1489
|
-
var data = chunks[3];
|
|
1490
|
-
var deep = indent.length;
|
|
1491
|
-
var types = path ? path.replace(/ $/, '').split(/ +/) : [];
|
|
1492
|
-
if (stack.length <= deep)
|
|
1493
|
-
return this.$.$mol_fail(new Error(`Too many tabs at ${baseUri}:${row}\n${line}`));
|
|
1494
|
-
stack.length = deep + 1;
|
|
1495
|
-
var parent = stack[deep];
|
|
1496
|
-
let col = deep;
|
|
1497
|
-
types.forEach(type => {
|
|
1498
|
-
if (!type)
|
|
1499
|
-
return this.$.$mol_fail(new Error(`Unexpected space symbol ${baseUri}:${row}\n${line}`));
|
|
1500
|
-
var next = new $mol_tree({ type, baseUri, row, col, length: type.length });
|
|
1501
|
-
const parent_sub = parent.sub;
|
|
1502
|
-
parent_sub.push(next);
|
|
1503
|
-
parent = next;
|
|
1504
|
-
col += type.length + 1;
|
|
1505
|
-
});
|
|
1506
|
-
if (data) {
|
|
1507
|
-
var next = new $mol_tree({ data: data.substring(1), baseUri, row, col, length: data.length });
|
|
1508
|
-
const parent_sub = parent.sub;
|
|
1509
|
-
parent_sub.push(next);
|
|
1510
|
-
parent = next;
|
|
1511
|
-
}
|
|
1512
|
-
stack.push(parent);
|
|
1513
|
-
});
|
|
1514
|
-
return root;
|
|
1515
|
-
}
|
|
1516
|
-
static fromJSON(json, baseUri = '') {
|
|
1517
|
-
switch (true) {
|
|
1518
|
-
case typeof json === 'boolean':
|
|
1519
|
-
case typeof json === 'number':
|
|
1520
|
-
case json === null:
|
|
1521
|
-
return new $mol_tree({
|
|
1522
|
-
type: String(json),
|
|
1523
|
-
baseUri: baseUri
|
|
1524
|
-
});
|
|
1525
|
-
case typeof json === 'string':
|
|
1526
|
-
return new $mol_tree({
|
|
1527
|
-
value: json,
|
|
1528
|
-
baseUri: baseUri
|
|
1529
|
-
});
|
|
1530
|
-
case Array.isArray(json):
|
|
1531
|
-
return new $mol_tree({
|
|
1532
|
-
type: "/",
|
|
1533
|
-
sub: json.map(json => $mol_tree.fromJSON(json, baseUri))
|
|
1534
|
-
});
|
|
1535
|
-
case json instanceof Date:
|
|
1536
|
-
return new $mol_tree({
|
|
1537
|
-
value: json.toISOString(),
|
|
1538
|
-
baseUri: baseUri
|
|
1539
|
-
});
|
|
1540
|
-
default:
|
|
1541
|
-
if (typeof json[$.$mol_tree_convert] === 'function') {
|
|
1542
|
-
return json[$.$mol_tree_convert]();
|
|
1543
|
-
}
|
|
1544
|
-
if (typeof json.toJSON === 'function') {
|
|
1545
|
-
return $mol_tree.fromJSON(json.toJSON());
|
|
1546
|
-
}
|
|
1547
|
-
if (json instanceof Error) {
|
|
1548
|
-
const { name, message, stack } = json;
|
|
1549
|
-
json = { ...json, name, message, stack };
|
|
1550
|
-
}
|
|
1551
|
-
var sub = [];
|
|
1552
|
-
for (var key in json) {
|
|
1553
|
-
if (json[key] === undefined)
|
|
1554
|
-
continue;
|
|
1555
|
-
const subsub = $mol_tree.fromJSON(json[key], baseUri);
|
|
1556
|
-
if (/^[^\n\t\\ ]+$/.test(key)) {
|
|
1557
|
-
var child = new $mol_tree({
|
|
1558
|
-
type: key,
|
|
1559
|
-
baseUri: baseUri,
|
|
1560
|
-
sub: [subsub],
|
|
1561
|
-
});
|
|
1562
|
-
}
|
|
1563
|
-
else {
|
|
1564
|
-
var child = new $mol_tree({
|
|
1565
|
-
value: key,
|
|
1566
|
-
baseUri: baseUri,
|
|
1567
|
-
sub: [subsub],
|
|
1568
|
-
});
|
|
1569
|
-
}
|
|
1570
|
-
sub.push(child);
|
|
1571
|
-
}
|
|
1572
|
-
return new $mol_tree({
|
|
1573
|
-
type: "*",
|
|
1574
|
-
sub: sub,
|
|
1575
|
-
baseUri: baseUri
|
|
1576
|
-
});
|
|
1577
|
-
}
|
|
1442
|
+
length: this.length
|
|
1443
|
+
};
|
|
1578
1444
|
}
|
|
1579
|
-
|
|
1580
|
-
return
|
|
1445
|
+
error(message, Class = Error) {
|
|
1446
|
+
return new Class(`${message}${this}`);
|
|
1447
|
+
}
|
|
1448
|
+
span(row, col, length) {
|
|
1449
|
+
return new $mol_span(this.uri, this.source, row, col, length);
|
|
1450
|
+
}
|
|
1451
|
+
after(length = 0) {
|
|
1452
|
+
return new $mol_span(this.uri, this.source, this.row, this.col + this.length, length);
|
|
1453
|
+
}
|
|
1454
|
+
slice(begin, end = -1) {
|
|
1455
|
+
let len = this.length;
|
|
1456
|
+
if (begin < 0)
|
|
1457
|
+
begin += len;
|
|
1458
|
+
if (end < 0)
|
|
1459
|
+
end += len;
|
|
1460
|
+
if (begin < 0 || begin > len)
|
|
1461
|
+
this.$.$mol_fail(`Begin value '${begin}' out of range ${this}`);
|
|
1462
|
+
if (end < 0 || end > len)
|
|
1463
|
+
this.$.$mol_fail(`End value '${end}' out of range ${this}`);
|
|
1464
|
+
if (end < begin)
|
|
1465
|
+
this.$.$mol_fail(`End value '${end}' can't be less than begin value ${this}`);
|
|
1466
|
+
return this.span(this.row, this.col + begin, end - begin);
|
|
1581
1467
|
}
|
|
1582
|
-
|
|
1583
|
-
|
|
1584
|
-
|
|
1468
|
+
}
|
|
1469
|
+
$.$mol_span = $mol_span;
|
|
1470
|
+
})($ || ($ = {}));
|
|
1471
|
+
//mol/span/span.ts
|
|
1472
|
+
;
|
|
1473
|
+
"use strict";
|
|
1474
|
+
var $;
|
|
1475
|
+
(function ($) {
|
|
1476
|
+
function $mol_tree2_to_string(tree) {
|
|
1477
|
+
let output = [];
|
|
1478
|
+
function dump(tree, prefix = '') {
|
|
1479
|
+
if (tree.type.length) {
|
|
1585
1480
|
if (!prefix.length) {
|
|
1586
1481
|
prefix = "\t";
|
|
1587
1482
|
}
|
|
1588
|
-
output
|
|
1589
|
-
if (
|
|
1590
|
-
|
|
1483
|
+
output.push(tree.type);
|
|
1484
|
+
if (tree.kids.length == 1) {
|
|
1485
|
+
output.push(' ');
|
|
1486
|
+
dump(tree.kids[0], prefix);
|
|
1487
|
+
return;
|
|
1591
1488
|
}
|
|
1592
|
-
output
|
|
1489
|
+
output.push("\n");
|
|
1593
1490
|
}
|
|
1594
|
-
else if (
|
|
1595
|
-
output
|
|
1491
|
+
else if (tree.value.length || prefix.length) {
|
|
1492
|
+
output.push("\\" + tree.value + "\n");
|
|
1596
1493
|
}
|
|
1597
|
-
for (
|
|
1598
|
-
output
|
|
1599
|
-
|
|
1494
|
+
for (const kid of tree.kids) {
|
|
1495
|
+
output.push(prefix);
|
|
1496
|
+
dump(kid, prefix + "\t");
|
|
1600
1497
|
}
|
|
1601
|
-
return output;
|
|
1602
1498
|
}
|
|
1603
|
-
|
|
1604
|
-
|
|
1605
|
-
|
|
1606
|
-
|
|
1607
|
-
|
|
1608
|
-
|
|
1609
|
-
|
|
1610
|
-
|
|
1611
|
-
|
|
1612
|
-
|
|
1613
|
-
|
|
1614
|
-
|
|
1615
|
-
|
|
1616
|
-
|
|
1617
|
-
|
|
1618
|
-
|
|
1619
|
-
|
|
1620
|
-
|
|
1621
|
-
|
|
1622
|
-
|
|
1623
|
-
|
|
1624
|
-
|
|
1625
|
-
|
|
1626
|
-
|
|
1627
|
-
|
|
1628
|
-
|
|
1629
|
-
|
|
1630
|
-
|
|
1631
|
-
|
|
1499
|
+
dump(tree);
|
|
1500
|
+
return output.join('');
|
|
1501
|
+
}
|
|
1502
|
+
$.$mol_tree2_to_string = $mol_tree2_to_string;
|
|
1503
|
+
})($ || ($ = {}));
|
|
1504
|
+
//mol/tree2/to/string/string.ts
|
|
1505
|
+
;
|
|
1506
|
+
"use strict";
|
|
1507
|
+
var $;
|
|
1508
|
+
(function ($) {
|
|
1509
|
+
class $mol_tree2 extends Object {
|
|
1510
|
+
type;
|
|
1511
|
+
value;
|
|
1512
|
+
kids;
|
|
1513
|
+
span;
|
|
1514
|
+
constructor(type, value, kids, span) {
|
|
1515
|
+
super();
|
|
1516
|
+
this.type = type;
|
|
1517
|
+
this.value = value;
|
|
1518
|
+
this.kids = kids;
|
|
1519
|
+
this.span = span;
|
|
1520
|
+
this[Symbol.toStringTag] = type || '\\' + value;
|
|
1521
|
+
}
|
|
1522
|
+
static list(kids, span = $mol_span.unknown) {
|
|
1523
|
+
return new $mol_tree2('', '', kids, span);
|
|
1524
|
+
}
|
|
1525
|
+
list(kids) {
|
|
1526
|
+
return $mol_tree2.list(kids, this.span);
|
|
1527
|
+
}
|
|
1528
|
+
static data(value, kids = [], span = $mol_span.unknown) {
|
|
1529
|
+
const chunks = value.split('\n');
|
|
1530
|
+
if (chunks.length > 1) {
|
|
1531
|
+
let kid_span = span.span(span.row, span.col, 0);
|
|
1532
|
+
const data = chunks.map(chunk => {
|
|
1533
|
+
kid_span = kid_span.after(chunk.length);
|
|
1534
|
+
return new $mol_tree2('', chunk, [], kid_span);
|
|
1632
1535
|
});
|
|
1633
|
-
|
|
1536
|
+
kids = [...data, ...kids];
|
|
1537
|
+
value = '';
|
|
1634
1538
|
}
|
|
1635
|
-
|
|
1636
|
-
|
|
1539
|
+
return new $mol_tree2('', value, kids, span);
|
|
1540
|
+
}
|
|
1541
|
+
data(value, kids = []) {
|
|
1542
|
+
return $mol_tree2.data(value, kids, this.span);
|
|
1543
|
+
}
|
|
1544
|
+
static struct(type, kids = [], span = $mol_span.unknown) {
|
|
1545
|
+
if (/[ \n\t\\]/.test(type)) {
|
|
1546
|
+
$$.$mol_fail(span.error(`Wrong type ${JSON.stringify(type)}`));
|
|
1637
1547
|
}
|
|
1638
|
-
|
|
1639
|
-
|
|
1640
|
-
|
|
1641
|
-
|
|
1548
|
+
return new $mol_tree2(type, '', kids, span);
|
|
1549
|
+
}
|
|
1550
|
+
struct(type, kids = []) {
|
|
1551
|
+
return $mol_tree2.struct(type, kids, this.span);
|
|
1552
|
+
}
|
|
1553
|
+
clone(kids, span = this.span) {
|
|
1554
|
+
return new $mol_tree2(this.type, this.value, kids, span);
|
|
1642
1555
|
}
|
|
1643
|
-
|
|
1556
|
+
text() {
|
|
1644
1557
|
var values = [];
|
|
1645
|
-
for (var
|
|
1646
|
-
if (
|
|
1558
|
+
for (var kid of this.kids) {
|
|
1559
|
+
if (kid.type)
|
|
1647
1560
|
continue;
|
|
1648
|
-
values.push(
|
|
1561
|
+
values.push(kid.value);
|
|
1649
1562
|
}
|
|
1650
|
-
return this.
|
|
1563
|
+
return this.value + values.join('\n');
|
|
1564
|
+
}
|
|
1565
|
+
static fromString(str, uri = 'unknown') {
|
|
1566
|
+
return $$.$mol_tree2_from_string(str, uri);
|
|
1567
|
+
}
|
|
1568
|
+
toString() {
|
|
1569
|
+
return $$.$mol_tree2_to_string(this);
|
|
1651
1570
|
}
|
|
1652
1571
|
insert(value, ...path) {
|
|
1653
1572
|
if (path.length === 0)
|
|
@@ -1655,83 +1574,252 @@ var $;
|
|
|
1655
1574
|
const type = path[0];
|
|
1656
1575
|
if (typeof type === 'string') {
|
|
1657
1576
|
let replaced = false;
|
|
1658
|
-
const sub = this.
|
|
1577
|
+
const sub = this.kids.map((item, index) => {
|
|
1659
1578
|
if (item.type !== type)
|
|
1660
1579
|
return item;
|
|
1661
1580
|
replaced = true;
|
|
1662
1581
|
return item.insert(value, ...path.slice(1));
|
|
1663
|
-
});
|
|
1664
|
-
if (!replaced)
|
|
1665
|
-
sub.push(
|
|
1666
|
-
|
|
1582
|
+
}).filter(Boolean);
|
|
1583
|
+
if (!replaced && value) {
|
|
1584
|
+
sub.push(this.struct(type, []).insert(value, ...path.slice(1)));
|
|
1585
|
+
}
|
|
1586
|
+
return this.clone(sub);
|
|
1667
1587
|
}
|
|
1668
1588
|
else if (typeof type === 'number') {
|
|
1669
|
-
const sub = this.
|
|
1670
|
-
sub[type] = (sub[type] ||
|
|
1671
|
-
|
|
1589
|
+
const sub = this.kids.slice();
|
|
1590
|
+
sub[type] = (sub[type] || this.list([]))
|
|
1591
|
+
.insert(value, ...path.slice(1));
|
|
1592
|
+
return this.clone(sub.filter(Boolean));
|
|
1672
1593
|
}
|
|
1673
1594
|
else {
|
|
1674
|
-
|
|
1595
|
+
const kids = ((this.kids.length === 0) ? [this.list([])] : this.kids)
|
|
1596
|
+
.map(item => item.insert(value, ...path.slice(1)))
|
|
1597
|
+
.filter(Boolean);
|
|
1598
|
+
return this.clone(kids);
|
|
1675
1599
|
}
|
|
1676
1600
|
}
|
|
1677
1601
|
select(...path) {
|
|
1678
|
-
|
|
1679
|
-
for (
|
|
1602
|
+
let next = [this];
|
|
1603
|
+
for (const type of path) {
|
|
1680
1604
|
if (!next.length)
|
|
1681
1605
|
break;
|
|
1682
|
-
|
|
1606
|
+
const prev = next;
|
|
1683
1607
|
next = [];
|
|
1684
1608
|
for (var item of prev) {
|
|
1685
1609
|
switch (typeof (type)) {
|
|
1686
1610
|
case 'string':
|
|
1687
|
-
for (var child of item.
|
|
1688
|
-
if (
|
|
1611
|
+
for (var child of item.kids) {
|
|
1612
|
+
if (child.type == type) {
|
|
1689
1613
|
next.push(child);
|
|
1690
1614
|
}
|
|
1691
1615
|
}
|
|
1692
1616
|
break;
|
|
1693
1617
|
case 'number':
|
|
1694
|
-
if (type < item.
|
|
1695
|
-
next.push(item.
|
|
1618
|
+
if (type < item.kids.length)
|
|
1619
|
+
next.push(item.kids[type]);
|
|
1696
1620
|
break;
|
|
1697
|
-
default: next.push(...item.
|
|
1621
|
+
default: next.push(...item.kids);
|
|
1698
1622
|
}
|
|
1699
1623
|
}
|
|
1700
1624
|
}
|
|
1701
|
-
return
|
|
1625
|
+
return this.list(next);
|
|
1702
1626
|
}
|
|
1703
1627
|
filter(path, value) {
|
|
1704
|
-
|
|
1628
|
+
const sub = this.kids.filter(item => {
|
|
1705
1629
|
var found = item.select(...path);
|
|
1706
|
-
if (value
|
|
1707
|
-
return Boolean(found.
|
|
1630
|
+
if (value === undefined) {
|
|
1631
|
+
return Boolean(found.kids.length);
|
|
1708
1632
|
}
|
|
1709
1633
|
else {
|
|
1710
|
-
return found.
|
|
1634
|
+
return found.kids.some(child => child.value == value);
|
|
1711
1635
|
}
|
|
1712
1636
|
});
|
|
1713
|
-
return
|
|
1714
|
-
}
|
|
1715
|
-
|
|
1716
|
-
|
|
1717
|
-
|
|
1718
|
-
|
|
1719
|
-
|
|
1720
|
-
|
|
1721
|
-
|
|
1722
|
-
|
|
1723
|
-
|
|
1724
|
-
|
|
1637
|
+
return this.clone(sub);
|
|
1638
|
+
}
|
|
1639
|
+
hack(belt, context = {}) {
|
|
1640
|
+
return [].concat(...this.kids.map(child => {
|
|
1641
|
+
let handle = belt[child.type] || belt[''];
|
|
1642
|
+
if (!handle || handle === Object.prototype[child.type]) {
|
|
1643
|
+
handle = (input, belt, context) => [
|
|
1644
|
+
input.clone(input.hack(belt, context), context.span)
|
|
1645
|
+
];
|
|
1646
|
+
}
|
|
1647
|
+
try {
|
|
1648
|
+
return handle(child, belt, context);
|
|
1649
|
+
}
|
|
1650
|
+
catch (error) {
|
|
1651
|
+
error.message += `\n${child.clone([])}${child.span}`;
|
|
1652
|
+
$mol_fail_hidden(error);
|
|
1653
|
+
}
|
|
1725
1654
|
}));
|
|
1726
|
-
return this.clone({ sub });
|
|
1727
1655
|
}
|
|
1728
|
-
error(message) {
|
|
1729
|
-
return
|
|
1656
|
+
error(message, Class = Error) {
|
|
1657
|
+
return this.span.error(`${message}\n${this.clone([])}`, Class);
|
|
1658
|
+
}
|
|
1659
|
+
}
|
|
1660
|
+
$.$mol_tree2 = $mol_tree2;
|
|
1661
|
+
class $mol_tree2_empty extends $mol_tree2 {
|
|
1662
|
+
constructor() {
|
|
1663
|
+
super('', '', [], $mol_span.unknown);
|
|
1664
|
+
}
|
|
1665
|
+
}
|
|
1666
|
+
$.$mol_tree2_empty = $mol_tree2_empty;
|
|
1667
|
+
})($ || ($ = {}));
|
|
1668
|
+
//mol/tree2/tree2.ts
|
|
1669
|
+
;
|
|
1670
|
+
"use strict";
|
|
1671
|
+
var $;
|
|
1672
|
+
(function ($) {
|
|
1673
|
+
class $mol_error_syntax extends SyntaxError {
|
|
1674
|
+
reason;
|
|
1675
|
+
line;
|
|
1676
|
+
span;
|
|
1677
|
+
constructor(reason, line, span) {
|
|
1678
|
+
super(`${reason}\n${span}\n${line.substring(0, span.col - 1).replace(/\S/g, ' ')}${''.padEnd(span.length, '!')}\n${line}`);
|
|
1679
|
+
this.reason = reason;
|
|
1680
|
+
this.line = line;
|
|
1681
|
+
this.span = span;
|
|
1682
|
+
}
|
|
1683
|
+
}
|
|
1684
|
+
$.$mol_error_syntax = $mol_error_syntax;
|
|
1685
|
+
})($ || ($ = {}));
|
|
1686
|
+
//mol/error/syntax/syntax.ts
|
|
1687
|
+
;
|
|
1688
|
+
"use strict";
|
|
1689
|
+
var $;
|
|
1690
|
+
(function ($) {
|
|
1691
|
+
function $mol_tree2_from_string(str, uri = '?') {
|
|
1692
|
+
const span = $mol_span.entire(uri, str);
|
|
1693
|
+
var root = $mol_tree2.list([], span);
|
|
1694
|
+
var stack = [root];
|
|
1695
|
+
var pos = 0, row = 0, min_indent = 0;
|
|
1696
|
+
while (str.length > pos) {
|
|
1697
|
+
var indent = 0;
|
|
1698
|
+
var line_start = pos;
|
|
1699
|
+
row++;
|
|
1700
|
+
while (str.length > pos && str[pos] == '\t') {
|
|
1701
|
+
indent++;
|
|
1702
|
+
pos++;
|
|
1703
|
+
}
|
|
1704
|
+
if (!root.kids.length) {
|
|
1705
|
+
min_indent = indent;
|
|
1706
|
+
}
|
|
1707
|
+
indent -= min_indent;
|
|
1708
|
+
if (indent < 0 || indent >= stack.length) {
|
|
1709
|
+
const sp = span.span(row, 1, pos - line_start);
|
|
1710
|
+
while (str.length > pos && str[pos] != '\n') {
|
|
1711
|
+
pos++;
|
|
1712
|
+
}
|
|
1713
|
+
if (indent < 0) {
|
|
1714
|
+
if (str.length > pos) {
|
|
1715
|
+
this.$mol_fail(new this.$mol_error_syntax(`Too few tabs`, str.substring(line_start, pos), sp));
|
|
1716
|
+
}
|
|
1717
|
+
}
|
|
1718
|
+
else {
|
|
1719
|
+
this.$mol_fail(new this.$mol_error_syntax(`Too many tabs`, str.substring(line_start, pos), sp));
|
|
1720
|
+
}
|
|
1721
|
+
}
|
|
1722
|
+
stack.length = indent + 1;
|
|
1723
|
+
var parent = stack[indent];
|
|
1724
|
+
while (str.length > pos && str[pos] != '\\' && str[pos] != '\n') {
|
|
1725
|
+
var error_start = pos;
|
|
1726
|
+
while (str.length > pos && (str[pos] == ' ' || str[pos] == '\t')) {
|
|
1727
|
+
pos++;
|
|
1728
|
+
}
|
|
1729
|
+
if (pos > error_start) {
|
|
1730
|
+
let line_end = str.indexOf('\n', pos);
|
|
1731
|
+
if (line_end === -1)
|
|
1732
|
+
line_end = str.length;
|
|
1733
|
+
const sp = span.span(row, error_start - line_start, pos - error_start + 1);
|
|
1734
|
+
this.$mol_fail(new this.$mol_error_syntax(`Wrong nodes separator`, str.substring(line_start, line_end), sp));
|
|
1735
|
+
}
|
|
1736
|
+
var type_start = pos;
|
|
1737
|
+
while (str.length > pos &&
|
|
1738
|
+
str[pos] != '\\' &&
|
|
1739
|
+
str[pos] != ' ' &&
|
|
1740
|
+
str[pos] != '\t' &&
|
|
1741
|
+
str[pos] != '\n') {
|
|
1742
|
+
pos++;
|
|
1743
|
+
}
|
|
1744
|
+
if (pos > type_start) {
|
|
1745
|
+
let next = new $mol_tree2(str.slice(type_start, pos), '', [], span.span(row, type_start - line_start + 1, pos - type_start));
|
|
1746
|
+
const parent_kids = parent.kids;
|
|
1747
|
+
parent_kids.push(next);
|
|
1748
|
+
parent = next;
|
|
1749
|
+
}
|
|
1750
|
+
if (str.length > pos && str[pos] == ' ') {
|
|
1751
|
+
pos++;
|
|
1752
|
+
}
|
|
1753
|
+
}
|
|
1754
|
+
if (str.length > pos && str[pos] == '\\') {
|
|
1755
|
+
var data_start = pos;
|
|
1756
|
+
while (str.length > pos && str[pos] != '\n') {
|
|
1757
|
+
pos++;
|
|
1758
|
+
}
|
|
1759
|
+
let next = new $mol_tree2('', str.slice(data_start + 1, pos), [], span.span(row, data_start - line_start + 2, pos - data_start - 1));
|
|
1760
|
+
const parent_kids = parent.kids;
|
|
1761
|
+
parent_kids.push(next);
|
|
1762
|
+
parent = next;
|
|
1763
|
+
}
|
|
1764
|
+
if (str.length === pos && stack.length > 0) {
|
|
1765
|
+
const sp = span.span(row, pos - line_start + 1, 1);
|
|
1766
|
+
this.$mol_fail(new this.$mol_error_syntax(`Undexpected EOF, LF required`, str.substring(line_start, str.length), sp));
|
|
1767
|
+
}
|
|
1768
|
+
stack.push(parent);
|
|
1769
|
+
pos++;
|
|
1770
|
+
}
|
|
1771
|
+
return root;
|
|
1772
|
+
}
|
|
1773
|
+
$.$mol_tree2_from_string = $mol_tree2_from_string;
|
|
1774
|
+
})($ || ($ = {}));
|
|
1775
|
+
//mol/tree2/from/string/string.ts
|
|
1776
|
+
;
|
|
1777
|
+
"use strict";
|
|
1778
|
+
var $;
|
|
1779
|
+
(function ($) {
|
|
1780
|
+
function $mol_tree2_from_json(json, span = $mol_span.unknown) {
|
|
1781
|
+
if (typeof json === 'boolean' || typeof json === 'number' || json === null) {
|
|
1782
|
+
return new $mol_tree2(String(json), '', [], span);
|
|
1783
|
+
}
|
|
1784
|
+
if (typeof json === 'string') {
|
|
1785
|
+
return $mol_tree2.data(json, [], span);
|
|
1786
|
+
}
|
|
1787
|
+
if (Array.isArray(json)) {
|
|
1788
|
+
const sub = json.map(json => $mol_tree2_from_json(json, span));
|
|
1789
|
+
return new $mol_tree2('/', '', sub, span);
|
|
1790
|
+
}
|
|
1791
|
+
if (ArrayBuffer.isView(json)) {
|
|
1792
|
+
const buf = new Uint8Array(json.buffer, json.byteOffset, json.byteLength);
|
|
1793
|
+
return $mol_tree2.data(String.fromCharCode(...buf), [], span);
|
|
1794
|
+
}
|
|
1795
|
+
if (json instanceof Date) {
|
|
1796
|
+
return new $mol_tree2('', json.toISOString(), [], span);
|
|
1797
|
+
}
|
|
1798
|
+
if (typeof json.toJSON === 'function') {
|
|
1799
|
+
return $mol_tree2_from_json(json.toJSON());
|
|
1800
|
+
}
|
|
1801
|
+
if (json instanceof Error) {
|
|
1802
|
+
const { name, message, stack } = json;
|
|
1803
|
+
json = { ...json, name, message, stack };
|
|
1804
|
+
}
|
|
1805
|
+
const sub = [];
|
|
1806
|
+
for (var key in json) {
|
|
1807
|
+
const val = json[key];
|
|
1808
|
+
if (val === undefined)
|
|
1809
|
+
continue;
|
|
1810
|
+
const subsub = $mol_tree2_from_json(val, span);
|
|
1811
|
+
if (/^[^\n\t\\ ]+$/.test(key)) {
|
|
1812
|
+
sub.push(new $mol_tree2(key, '', [subsub], span));
|
|
1813
|
+
}
|
|
1814
|
+
else {
|
|
1815
|
+
sub.push($mol_tree2.data(key, [subsub], span));
|
|
1816
|
+
}
|
|
1730
1817
|
}
|
|
1818
|
+
return new $mol_tree2('*', '', sub, span);
|
|
1731
1819
|
}
|
|
1732
|
-
$.$
|
|
1820
|
+
$.$mol_tree2_from_json = $mol_tree2_from_json;
|
|
1733
1821
|
})($ || ($ = {}));
|
|
1734
|
-
//mol/
|
|
1822
|
+
//mol/tree2/from/json/json.ts
|
|
1735
1823
|
;
|
|
1736
1824
|
"use strict";
|
|
1737
1825
|
var $;
|
|
@@ -1786,7 +1874,8 @@ var $;
|
|
|
1786
1874
|
return function $mol_log3_logger(event) {
|
|
1787
1875
|
if (!event.time)
|
|
1788
1876
|
event = { time: new Date().toISOString(), ...event };
|
|
1789
|
-
|
|
1877
|
+
let tree = this.$mol_tree2_from_json(event);
|
|
1878
|
+
tree = tree.struct(type, tree.kids);
|
|
1790
1879
|
let str = color(tree.toString());
|
|
1791
1880
|
this.console[level](str);
|
|
1792
1881
|
const self = this;
|