mol_wire_lib 1.0.103 → 1.0.106
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/README.md +10 -1
- package/node.d.ts +144 -20
- package/node.deps.json +1 -1
- package/node.esm.js +650 -89
- package/node.esm.js.map +1 -1
- package/node.js +650 -89
- package/node.js.map +1 -1
- package/node.test.js +1525 -1525
- package/node.test.js.map +1 -1
- package/package.json +24 -10
- package/web.d.ts +94 -20
- package/web.deps.json +1 -1
- package/web.esm.js +209 -89
- package/web.esm.js.map +1 -1
- package/web.js +209 -89
- package/web.js.map +1 -1
- package/web.test.js +0 -120
- package/web.test.js.map +1 -1
package/node.esm.js
CHANGED
|
@@ -748,34 +748,6 @@ var $;
|
|
|
748
748
|
;
|
|
749
749
|
"use strict";
|
|
750
750
|
var $;
|
|
751
|
-
(function ($) {
|
|
752
|
-
function $mol_wire_probe(task, next) {
|
|
753
|
-
const warm = $mol_wire_fiber.warm;
|
|
754
|
-
try {
|
|
755
|
-
$mol_wire_fiber.warm = false;
|
|
756
|
-
return task();
|
|
757
|
-
}
|
|
758
|
-
finally {
|
|
759
|
-
$mol_wire_fiber.warm = warm;
|
|
760
|
-
}
|
|
761
|
-
}
|
|
762
|
-
$.$mol_wire_probe = $mol_wire_probe;
|
|
763
|
-
})($ || ($ = {}));
|
|
764
|
-
//mol/wire/probe/probe.ts
|
|
765
|
-
;
|
|
766
|
-
"use strict";
|
|
767
|
-
var $;
|
|
768
|
-
(function ($) {
|
|
769
|
-
function $mol_wire_solid() {
|
|
770
|
-
$mol_wire_auto().reap = nothing;
|
|
771
|
-
}
|
|
772
|
-
$.$mol_wire_solid = $mol_wire_solid;
|
|
773
|
-
const nothing = () => { };
|
|
774
|
-
})($ || ($ = {}));
|
|
775
|
-
//mol/wire/solid/solid.ts
|
|
776
|
-
;
|
|
777
|
-
"use strict";
|
|
778
|
-
var $;
|
|
779
751
|
(function ($) {
|
|
780
752
|
$.$mol_compare_deep_cache = new WeakMap();
|
|
781
753
|
function $mol_compare_deep(left, right) {
|
|
@@ -902,12 +874,12 @@ var $;
|
|
|
902
874
|
"use strict";
|
|
903
875
|
var $;
|
|
904
876
|
(function ($) {
|
|
905
|
-
class $
|
|
877
|
+
class $mol_wire_task extends $mol_wire_fiber {
|
|
906
878
|
static getter(task) {
|
|
907
879
|
return function $mol_wire_fiber_temp_get(host, args) {
|
|
908
880
|
const existen = $mol_wire_auto()?.track_next();
|
|
909
881
|
reuse: if (existen) {
|
|
910
|
-
if (!(existen instanceof $
|
|
882
|
+
if (!(existen instanceof $mol_wire_task))
|
|
911
883
|
break reuse;
|
|
912
884
|
if (existen.host !== host)
|
|
913
885
|
break reuse;
|
|
@@ -917,7 +889,7 @@ var $;
|
|
|
917
889
|
break reuse;
|
|
918
890
|
return existen;
|
|
919
891
|
}
|
|
920
|
-
return new $
|
|
892
|
+
return new $mol_wire_task(`${host?.[Symbol.toStringTag] ?? host}.${task.name}(#)`, task, host, ...args);
|
|
921
893
|
};
|
|
922
894
|
}
|
|
923
895
|
complete() {
|
|
@@ -940,53 +912,9 @@ var $;
|
|
|
940
912
|
return next;
|
|
941
913
|
}
|
|
942
914
|
}
|
|
943
|
-
$.$
|
|
944
|
-
})($ || ($ = {}));
|
|
945
|
-
//mol/wire/fiber/temp/temp.ts
|
|
946
|
-
;
|
|
947
|
-
"use strict";
|
|
948
|
-
var $;
|
|
949
|
-
(function ($) {
|
|
950
|
-
function $mol_wire_sync(obj) {
|
|
951
|
-
return new Proxy(obj, {
|
|
952
|
-
get(obj, field) {
|
|
953
|
-
const val = obj[field];
|
|
954
|
-
if (typeof val !== 'function')
|
|
955
|
-
return val;
|
|
956
|
-
const temp = $mol_wire_fiber_temp.getter(val);
|
|
957
|
-
return function $mol_wire_sync(...args) {
|
|
958
|
-
const fiber = temp(obj, args);
|
|
959
|
-
return fiber.sync();
|
|
960
|
-
};
|
|
961
|
-
}
|
|
962
|
-
});
|
|
963
|
-
}
|
|
964
|
-
$.$mol_wire_sync = $mol_wire_sync;
|
|
915
|
+
$.$mol_wire_task = $mol_wire_task;
|
|
965
916
|
})($ || ($ = {}));
|
|
966
|
-
//mol/wire/
|
|
967
|
-
;
|
|
968
|
-
"use strict";
|
|
969
|
-
var $;
|
|
970
|
-
(function ($) {
|
|
971
|
-
function $mol_wire_async(obj) {
|
|
972
|
-
return new Proxy(obj, {
|
|
973
|
-
get(obj, field) {
|
|
974
|
-
const val = obj[field];
|
|
975
|
-
if (typeof val !== 'function')
|
|
976
|
-
return val;
|
|
977
|
-
let fiber;
|
|
978
|
-
const temp = $mol_wire_fiber_temp.getter(val);
|
|
979
|
-
return function $mol_wire_async(...args) {
|
|
980
|
-
fiber?.destructor();
|
|
981
|
-
fiber = temp(obj, args);
|
|
982
|
-
return fiber.async();
|
|
983
|
-
};
|
|
984
|
-
}
|
|
985
|
-
});
|
|
986
|
-
}
|
|
987
|
-
$.$mol_wire_async = $mol_wire_async;
|
|
988
|
-
})($ || ($ = {}));
|
|
989
|
-
//mol/wire/async/async.ts
|
|
917
|
+
//mol/wire/task/task.ts
|
|
990
918
|
;
|
|
991
919
|
"use strict";
|
|
992
920
|
var $;
|
|
@@ -1051,7 +979,7 @@ var $;
|
|
|
1051
979
|
if (typeof sup[field] === 'function') {
|
|
1052
980
|
Object.defineProperty(orig, 'name', { value: sup[field].name });
|
|
1053
981
|
}
|
|
1054
|
-
const temp = $
|
|
982
|
+
const temp = $mol_wire_task.getter(orig);
|
|
1055
983
|
const value = function (...args) {
|
|
1056
984
|
const fiber = temp(this ?? null, args);
|
|
1057
985
|
return fiber.sync();
|
|
@@ -1069,7 +997,7 @@ var $;
|
|
|
1069
997
|
"use strict";
|
|
1070
998
|
var $;
|
|
1071
999
|
(function ($) {
|
|
1072
|
-
class $
|
|
1000
|
+
class $mol_wire_atom extends $mol_wire_fiber {
|
|
1073
1001
|
static getter(task, keys) {
|
|
1074
1002
|
const field = task.name + '()';
|
|
1075
1003
|
if (keys) {
|
|
@@ -1085,7 +1013,7 @@ var $;
|
|
|
1085
1013
|
else {
|
|
1086
1014
|
dict = (host ?? task)[field] = new Map();
|
|
1087
1015
|
}
|
|
1088
|
-
fiber = new $
|
|
1016
|
+
fiber = new $mol_wire_atom(key, task, host, ...args);
|
|
1089
1017
|
dict.set(key, fiber);
|
|
1090
1018
|
return fiber;
|
|
1091
1019
|
};
|
|
@@ -1096,7 +1024,7 @@ var $;
|
|
|
1096
1024
|
if (existen)
|
|
1097
1025
|
return existen;
|
|
1098
1026
|
const key = `${host?.[Symbol.toStringTag] ?? host}.${field}`;
|
|
1099
|
-
const fiber = new $
|
|
1027
|
+
const fiber = new $mol_wire_atom(key, task, host, ...args);
|
|
1100
1028
|
(host ?? task)[field] = fiber;
|
|
1101
1029
|
return fiber;
|
|
1102
1030
|
};
|
|
@@ -1160,13 +1088,85 @@ var $;
|
|
|
1160
1088
|
}
|
|
1161
1089
|
__decorate([
|
|
1162
1090
|
$mol_wire_method
|
|
1163
|
-
], $
|
|
1091
|
+
], $mol_wire_atom.prototype, "recall", null);
|
|
1164
1092
|
__decorate([
|
|
1165
1093
|
$mol_wire_method
|
|
1166
|
-
], $
|
|
1167
|
-
$.$
|
|
1094
|
+
], $mol_wire_atom.prototype, "once", null);
|
|
1095
|
+
$.$mol_wire_atom = $mol_wire_atom;
|
|
1168
1096
|
})($ || ($ = {}));
|
|
1169
|
-
//mol/wire/
|
|
1097
|
+
//mol/wire/atom/atom.ts
|
|
1098
|
+
;
|
|
1099
|
+
"use strict";
|
|
1100
|
+
var $;
|
|
1101
|
+
(function ($) {
|
|
1102
|
+
function $mol_wire_probe(task, next) {
|
|
1103
|
+
const warm = $mol_wire_fiber.warm;
|
|
1104
|
+
try {
|
|
1105
|
+
$mol_wire_fiber.warm = false;
|
|
1106
|
+
return task();
|
|
1107
|
+
}
|
|
1108
|
+
finally {
|
|
1109
|
+
$mol_wire_fiber.warm = warm;
|
|
1110
|
+
}
|
|
1111
|
+
}
|
|
1112
|
+
$.$mol_wire_probe = $mol_wire_probe;
|
|
1113
|
+
})($ || ($ = {}));
|
|
1114
|
+
//mol/wire/probe/probe.ts
|
|
1115
|
+
;
|
|
1116
|
+
"use strict";
|
|
1117
|
+
var $;
|
|
1118
|
+
(function ($) {
|
|
1119
|
+
function $mol_wire_solid() {
|
|
1120
|
+
$mol_wire_auto().reap = nothing;
|
|
1121
|
+
}
|
|
1122
|
+
$.$mol_wire_solid = $mol_wire_solid;
|
|
1123
|
+
const nothing = () => { };
|
|
1124
|
+
})($ || ($ = {}));
|
|
1125
|
+
//mol/wire/solid/solid.ts
|
|
1126
|
+
;
|
|
1127
|
+
"use strict";
|
|
1128
|
+
var $;
|
|
1129
|
+
(function ($) {
|
|
1130
|
+
function $mol_wire_sync(obj) {
|
|
1131
|
+
return new Proxy(obj, {
|
|
1132
|
+
get(obj, field) {
|
|
1133
|
+
const val = obj[field];
|
|
1134
|
+
if (typeof val !== 'function')
|
|
1135
|
+
return val;
|
|
1136
|
+
const temp = $mol_wire_task.getter(val);
|
|
1137
|
+
return function $mol_wire_sync(...args) {
|
|
1138
|
+
const fiber = temp(obj, args);
|
|
1139
|
+
return fiber.sync();
|
|
1140
|
+
};
|
|
1141
|
+
}
|
|
1142
|
+
});
|
|
1143
|
+
}
|
|
1144
|
+
$.$mol_wire_sync = $mol_wire_sync;
|
|
1145
|
+
})($ || ($ = {}));
|
|
1146
|
+
//mol/wire/sync/sync.ts
|
|
1147
|
+
;
|
|
1148
|
+
"use strict";
|
|
1149
|
+
var $;
|
|
1150
|
+
(function ($) {
|
|
1151
|
+
function $mol_wire_async(obj) {
|
|
1152
|
+
return new Proxy(obj, {
|
|
1153
|
+
get(obj, field) {
|
|
1154
|
+
const val = obj[field];
|
|
1155
|
+
if (typeof val !== 'function')
|
|
1156
|
+
return val;
|
|
1157
|
+
let fiber;
|
|
1158
|
+
const temp = $mol_wire_task.getter(val);
|
|
1159
|
+
return function $mol_wire_async(...args) {
|
|
1160
|
+
fiber?.destructor();
|
|
1161
|
+
fiber = temp(obj, args);
|
|
1162
|
+
return fiber.async();
|
|
1163
|
+
};
|
|
1164
|
+
}
|
|
1165
|
+
});
|
|
1166
|
+
}
|
|
1167
|
+
$.$mol_wire_async = $mol_wire_async;
|
|
1168
|
+
})($ || ($ = {}));
|
|
1169
|
+
//mol/wire/async/async.ts
|
|
1170
1170
|
;
|
|
1171
1171
|
"use strict";
|
|
1172
1172
|
var $;
|
|
@@ -1192,11 +1192,11 @@ var $;
|
|
|
1192
1192
|
$.$mol_wire_mem = $mol_wire_mem;
|
|
1193
1193
|
function $mol_wire_mem_func(keys) {
|
|
1194
1194
|
return (func) => {
|
|
1195
|
-
const persist = $
|
|
1195
|
+
const persist = $mol_wire_atom.getter(func, keys);
|
|
1196
1196
|
const wrapper = function (...args) {
|
|
1197
1197
|
let atom = persist(this, args.slice(0, keys));
|
|
1198
1198
|
if (args.length <= keys || args[keys] === undefined) {
|
|
1199
|
-
if ($mol_wire_auto() instanceof $
|
|
1199
|
+
if ($mol_wire_auto() instanceof $mol_wire_task) {
|
|
1200
1200
|
return atom.once();
|
|
1201
1201
|
}
|
|
1202
1202
|
else {
|
|
@@ -1234,7 +1234,7 @@ var $;
|
|
|
1234
1234
|
if (!descr)
|
|
1235
1235
|
descr = Reflect.getOwnPropertyDescriptor(host, field);
|
|
1236
1236
|
const _get = descr?.get || $mol_const(descr?.value);
|
|
1237
|
-
const persist = $
|
|
1237
|
+
const persist = $mol_wire_atom.getter(_get, 0);
|
|
1238
1238
|
const _set = descr?.set || function (next) {
|
|
1239
1239
|
persist(this, []).put(next);
|
|
1240
1240
|
};
|
|
@@ -1245,7 +1245,7 @@ var $;
|
|
|
1245
1245
|
function get() {
|
|
1246
1246
|
return persist(this, []).sync();
|
|
1247
1247
|
}
|
|
1248
|
-
const temp = $
|
|
1248
|
+
const temp = $mol_wire_task.getter(_set);
|
|
1249
1249
|
function set(next) {
|
|
1250
1250
|
temp(this, [next]).sync();
|
|
1251
1251
|
}
|
|
@@ -1434,5 +1434,566 @@ var $;
|
|
|
1434
1434
|
})($ || ($ = {}));
|
|
1435
1435
|
//mol/wait/timeout/timeout.ts
|
|
1436
1436
|
;
|
|
1437
|
+
"use strict";
|
|
1438
|
+
var $;
|
|
1439
|
+
(function ($) {
|
|
1440
|
+
$.$mol_mem = $mol_wire_mem(0);
|
|
1441
|
+
$.$mol_mem_key = $mol_wire_mem(1);
|
|
1442
|
+
$.$mol_mem_key2 = $mol_wire_mem(2);
|
|
1443
|
+
$.$mol_mem_key3 = $mol_wire_mem(3);
|
|
1444
|
+
})($ || ($ = {}));
|
|
1445
|
+
//mol/mem/mem.ts
|
|
1446
|
+
;
|
|
1447
|
+
"use strict";
|
|
1448
|
+
var $;
|
|
1449
|
+
(function ($) {
|
|
1450
|
+
function $mol_log3_area_lazy(event) {
|
|
1451
|
+
const self = this;
|
|
1452
|
+
const stack = self.$mol_log3_stack;
|
|
1453
|
+
const deep = stack.length;
|
|
1454
|
+
let logged = false;
|
|
1455
|
+
stack.push(() => {
|
|
1456
|
+
logged = true;
|
|
1457
|
+
self.$mol_log3_area.call(self, event);
|
|
1458
|
+
});
|
|
1459
|
+
return () => {
|
|
1460
|
+
if (logged)
|
|
1461
|
+
self.console.groupEnd();
|
|
1462
|
+
if (stack.length > deep)
|
|
1463
|
+
stack.length = deep;
|
|
1464
|
+
};
|
|
1465
|
+
}
|
|
1466
|
+
$.$mol_log3_area_lazy = $mol_log3_area_lazy;
|
|
1467
|
+
$.$mol_log3_stack = [];
|
|
1468
|
+
})($ || ($ = {}));
|
|
1469
|
+
//mol/log3/log3.ts
|
|
1470
|
+
;
|
|
1471
|
+
"use strict";
|
|
1472
|
+
//node/node.ts
|
|
1473
|
+
;
|
|
1474
|
+
"use strict";
|
|
1475
|
+
var $node = new Proxy({ require }, {
|
|
1476
|
+
get(target, name, wrapper) {
|
|
1477
|
+
if (target[name])
|
|
1478
|
+
return target[name];
|
|
1479
|
+
const mod = target.require('module');
|
|
1480
|
+
if (mod.builtinModules.indexOf(name) >= 0)
|
|
1481
|
+
return target.require(name);
|
|
1482
|
+
const path = target.require('path');
|
|
1483
|
+
const fs = target.require('fs');
|
|
1484
|
+
let dir = path.resolve('.');
|
|
1485
|
+
const suffix = `./node_modules/${name}`;
|
|
1486
|
+
const $$ = $;
|
|
1487
|
+
while (!fs.existsSync(path.join(dir, suffix))) {
|
|
1488
|
+
const parent = path.resolve(dir, '..');
|
|
1489
|
+
if (parent === dir) {
|
|
1490
|
+
$$.$mol_exec('.', 'npm', 'install', name);
|
|
1491
|
+
try {
|
|
1492
|
+
$$.$mol_exec('.', 'npm', 'install', '@types/' + name);
|
|
1493
|
+
}
|
|
1494
|
+
catch { }
|
|
1495
|
+
break;
|
|
1496
|
+
}
|
|
1497
|
+
else {
|
|
1498
|
+
dir = parent;
|
|
1499
|
+
}
|
|
1500
|
+
}
|
|
1501
|
+
return target.require(name);
|
|
1502
|
+
},
|
|
1503
|
+
set(target, name, value) {
|
|
1504
|
+
target[name] = value;
|
|
1505
|
+
return true;
|
|
1506
|
+
},
|
|
1507
|
+
});
|
|
1508
|
+
require = (req => Object.assign(function require(name) {
|
|
1509
|
+
return $node[name];
|
|
1510
|
+
}, req))(require);
|
|
1511
|
+
//node/node.node.ts
|
|
1512
|
+
;
|
|
1513
|
+
"use strict";
|
|
1514
|
+
var $;
|
|
1515
|
+
(function ($) {
|
|
1516
|
+
function $mol_deprecated(message) {
|
|
1517
|
+
return (host, field, descr) => {
|
|
1518
|
+
const value = descr.value;
|
|
1519
|
+
let warned = false;
|
|
1520
|
+
descr.value = function $mol_deprecated_wrapper(...args) {
|
|
1521
|
+
if (!warned) {
|
|
1522
|
+
$$.$mol_log3_warn({
|
|
1523
|
+
place: `${host.constructor.name}::${field}`,
|
|
1524
|
+
message: `Deprecated`,
|
|
1525
|
+
hint: message,
|
|
1526
|
+
});
|
|
1527
|
+
warned = true;
|
|
1528
|
+
}
|
|
1529
|
+
return value.call(this, ...args);
|
|
1530
|
+
};
|
|
1531
|
+
};
|
|
1532
|
+
}
|
|
1533
|
+
$.$mol_deprecated = $mol_deprecated;
|
|
1534
|
+
})($ || ($ = {}));
|
|
1535
|
+
//mol/deprecated/deprecated.ts
|
|
1536
|
+
;
|
|
1537
|
+
"use strict";
|
|
1538
|
+
var $;
|
|
1539
|
+
(function ($) {
|
|
1540
|
+
$.$mol_tree_convert = Symbol('$mol_tree_convert');
|
|
1541
|
+
class $mol_tree extends $mol_object2 {
|
|
1542
|
+
type;
|
|
1543
|
+
data;
|
|
1544
|
+
sub;
|
|
1545
|
+
baseUri;
|
|
1546
|
+
row;
|
|
1547
|
+
col;
|
|
1548
|
+
length;
|
|
1549
|
+
constructor(config = {}) {
|
|
1550
|
+
super();
|
|
1551
|
+
this.type = config.type || '';
|
|
1552
|
+
if (config.value !== undefined) {
|
|
1553
|
+
var sub = $mol_tree.values(config.value);
|
|
1554
|
+
if (config.type || sub.length > 1) {
|
|
1555
|
+
this.sub = [...sub, ...(config.sub || [])];
|
|
1556
|
+
this.data = config.data || '';
|
|
1557
|
+
}
|
|
1558
|
+
else {
|
|
1559
|
+
this.data = sub[0].data;
|
|
1560
|
+
this.sub = config.sub || [];
|
|
1561
|
+
}
|
|
1562
|
+
}
|
|
1563
|
+
else {
|
|
1564
|
+
this.data = config.data || '';
|
|
1565
|
+
this.sub = config.sub || [];
|
|
1566
|
+
}
|
|
1567
|
+
this.baseUri = config.baseUri || '';
|
|
1568
|
+
this.row = config.row || 0;
|
|
1569
|
+
this.col = config.col || 0;
|
|
1570
|
+
this.length = config.length || 0;
|
|
1571
|
+
}
|
|
1572
|
+
static values(str, baseUri) {
|
|
1573
|
+
return str.split('\n').map((data, index) => new $mol_tree({
|
|
1574
|
+
data: data,
|
|
1575
|
+
baseUri: baseUri,
|
|
1576
|
+
row: index + 1,
|
|
1577
|
+
length: data.length,
|
|
1578
|
+
}));
|
|
1579
|
+
}
|
|
1580
|
+
clone(config = {}) {
|
|
1581
|
+
return new $mol_tree({
|
|
1582
|
+
type: ('type' in config) ? config.type : this.type,
|
|
1583
|
+
data: ('data' in config) ? config.data : this.data,
|
|
1584
|
+
sub: ('sub' in config) ? config.sub : this.sub,
|
|
1585
|
+
baseUri: ('baseUri' in config) ? config.baseUri : this.baseUri,
|
|
1586
|
+
row: ('row' in config) ? config.row : this.row,
|
|
1587
|
+
col: ('col' in config) ? config.col : this.col,
|
|
1588
|
+
length: ('length' in config) ? config.length : this.length,
|
|
1589
|
+
value: config.value
|
|
1590
|
+
});
|
|
1591
|
+
}
|
|
1592
|
+
make(config) {
|
|
1593
|
+
return new $mol_tree({
|
|
1594
|
+
baseUri: this.baseUri,
|
|
1595
|
+
row: this.row,
|
|
1596
|
+
col: this.col,
|
|
1597
|
+
length: this.length,
|
|
1598
|
+
...config,
|
|
1599
|
+
});
|
|
1600
|
+
}
|
|
1601
|
+
make_data(value, sub) {
|
|
1602
|
+
return this.make({ value, sub });
|
|
1603
|
+
}
|
|
1604
|
+
make_struct(type, sub) {
|
|
1605
|
+
return this.make({ type, sub });
|
|
1606
|
+
}
|
|
1607
|
+
static fromString(str, baseUri) {
|
|
1608
|
+
var root = new $mol_tree({ baseUri: baseUri });
|
|
1609
|
+
var stack = [root];
|
|
1610
|
+
var row = 0;
|
|
1611
|
+
var prefix = str.replace(/^\n?(\t*)[\s\S]*/, '$1');
|
|
1612
|
+
var lines = str.replace(new RegExp('^\\t{0,' + prefix.length + '}', 'mg'), '').split('\n');
|
|
1613
|
+
lines.forEach(line => {
|
|
1614
|
+
++row;
|
|
1615
|
+
var chunks = /^(\t*)((?:[^\n\t\\ ]+ *)*)(\\[^\n]*)?(.*?)(?:$|\n)/m.exec(line);
|
|
1616
|
+
if (!chunks || chunks[4])
|
|
1617
|
+
return this.$.$mol_fail(new Error(`Syntax error at ${baseUri}:${row}\n${line}`));
|
|
1618
|
+
var indent = chunks[1];
|
|
1619
|
+
var path = chunks[2];
|
|
1620
|
+
var data = chunks[3];
|
|
1621
|
+
var deep = indent.length;
|
|
1622
|
+
var types = path ? path.replace(/ $/, '').split(/ +/) : [];
|
|
1623
|
+
if (stack.length <= deep)
|
|
1624
|
+
return this.$.$mol_fail(new Error(`Too many tabs at ${baseUri}:${row}\n${line}`));
|
|
1625
|
+
stack.length = deep + 1;
|
|
1626
|
+
var parent = stack[deep];
|
|
1627
|
+
let col = deep;
|
|
1628
|
+
types.forEach(type => {
|
|
1629
|
+
if (!type)
|
|
1630
|
+
return this.$.$mol_fail(new Error(`Unexpected space symbol ${baseUri}:${row}\n${line}`));
|
|
1631
|
+
var next = new $mol_tree({ type, baseUri, row, col, length: type.length });
|
|
1632
|
+
const parent_sub = parent.sub;
|
|
1633
|
+
parent_sub.push(next);
|
|
1634
|
+
parent = next;
|
|
1635
|
+
col += type.length + 1;
|
|
1636
|
+
});
|
|
1637
|
+
if (data) {
|
|
1638
|
+
var next = new $mol_tree({ data: data.substring(1), baseUri, row, col, length: data.length });
|
|
1639
|
+
const parent_sub = parent.sub;
|
|
1640
|
+
parent_sub.push(next);
|
|
1641
|
+
parent = next;
|
|
1642
|
+
}
|
|
1643
|
+
stack.push(parent);
|
|
1644
|
+
});
|
|
1645
|
+
return root;
|
|
1646
|
+
}
|
|
1647
|
+
static fromJSON(json, baseUri = '') {
|
|
1648
|
+
switch (true) {
|
|
1649
|
+
case typeof json === 'boolean':
|
|
1650
|
+
case typeof json === 'number':
|
|
1651
|
+
case json === null:
|
|
1652
|
+
return new $mol_tree({
|
|
1653
|
+
type: String(json),
|
|
1654
|
+
baseUri: baseUri
|
|
1655
|
+
});
|
|
1656
|
+
case typeof json === 'string':
|
|
1657
|
+
return new $mol_tree({
|
|
1658
|
+
value: json,
|
|
1659
|
+
baseUri: baseUri
|
|
1660
|
+
});
|
|
1661
|
+
case Array.isArray(json):
|
|
1662
|
+
return new $mol_tree({
|
|
1663
|
+
type: "/",
|
|
1664
|
+
sub: json.map(json => $mol_tree.fromJSON(json, baseUri))
|
|
1665
|
+
});
|
|
1666
|
+
case json instanceof Date:
|
|
1667
|
+
return new $mol_tree({
|
|
1668
|
+
value: json.toISOString(),
|
|
1669
|
+
baseUri: baseUri
|
|
1670
|
+
});
|
|
1671
|
+
default:
|
|
1672
|
+
if (typeof json[$.$mol_tree_convert] === 'function') {
|
|
1673
|
+
return json[$.$mol_tree_convert]();
|
|
1674
|
+
}
|
|
1675
|
+
if (typeof json.toJSON === 'function') {
|
|
1676
|
+
return $mol_tree.fromJSON(json.toJSON());
|
|
1677
|
+
}
|
|
1678
|
+
if (json instanceof Error) {
|
|
1679
|
+
const { name, message, stack } = json;
|
|
1680
|
+
json = { ...json, name, message, stack };
|
|
1681
|
+
}
|
|
1682
|
+
var sub = [];
|
|
1683
|
+
for (var key in json) {
|
|
1684
|
+
if (json[key] === undefined)
|
|
1685
|
+
continue;
|
|
1686
|
+
const subsub = $mol_tree.fromJSON(json[key], baseUri);
|
|
1687
|
+
if (/^[^\n\t\\ ]+$/.test(key)) {
|
|
1688
|
+
var child = new $mol_tree({
|
|
1689
|
+
type: key,
|
|
1690
|
+
baseUri: baseUri,
|
|
1691
|
+
sub: [subsub],
|
|
1692
|
+
});
|
|
1693
|
+
}
|
|
1694
|
+
else {
|
|
1695
|
+
var child = new $mol_tree({
|
|
1696
|
+
value: key,
|
|
1697
|
+
baseUri: baseUri,
|
|
1698
|
+
sub: [subsub],
|
|
1699
|
+
});
|
|
1700
|
+
}
|
|
1701
|
+
sub.push(child);
|
|
1702
|
+
}
|
|
1703
|
+
return new $mol_tree({
|
|
1704
|
+
type: "*",
|
|
1705
|
+
sub: sub,
|
|
1706
|
+
baseUri: baseUri
|
|
1707
|
+
});
|
|
1708
|
+
}
|
|
1709
|
+
}
|
|
1710
|
+
get uri() {
|
|
1711
|
+
return this.baseUri + '#' + this.row + ':' + this.col;
|
|
1712
|
+
}
|
|
1713
|
+
toString(prefix = '') {
|
|
1714
|
+
var output = '';
|
|
1715
|
+
if (this.type.length) {
|
|
1716
|
+
if (!prefix.length) {
|
|
1717
|
+
prefix = "\t";
|
|
1718
|
+
}
|
|
1719
|
+
output += this.type;
|
|
1720
|
+
if (this.sub.length == 1) {
|
|
1721
|
+
return output + ' ' + this.sub[0].toString(prefix);
|
|
1722
|
+
}
|
|
1723
|
+
output += "\n";
|
|
1724
|
+
}
|
|
1725
|
+
else if (this.data.length || prefix.length) {
|
|
1726
|
+
output += "\\" + this.data + "\n";
|
|
1727
|
+
}
|
|
1728
|
+
for (var child of this.sub) {
|
|
1729
|
+
output += prefix;
|
|
1730
|
+
output += child.toString(prefix + "\t");
|
|
1731
|
+
}
|
|
1732
|
+
return output;
|
|
1733
|
+
}
|
|
1734
|
+
toJSON() {
|
|
1735
|
+
if (!this.type)
|
|
1736
|
+
return this.value;
|
|
1737
|
+
if (this.type === 'true')
|
|
1738
|
+
return true;
|
|
1739
|
+
if (this.type === 'false')
|
|
1740
|
+
return false;
|
|
1741
|
+
if (this.type === 'null')
|
|
1742
|
+
return null;
|
|
1743
|
+
if (this.type === '*') {
|
|
1744
|
+
var obj = {};
|
|
1745
|
+
for (var child of this.sub) {
|
|
1746
|
+
if (child.type === '-')
|
|
1747
|
+
continue;
|
|
1748
|
+
var key = child.type || child.clone({ sub: child.sub.slice(0, child.sub.length - 1) }).value;
|
|
1749
|
+
var val = child.sub[child.sub.length - 1].toJSON();
|
|
1750
|
+
if (val !== undefined)
|
|
1751
|
+
obj[key] = val;
|
|
1752
|
+
}
|
|
1753
|
+
return obj;
|
|
1754
|
+
}
|
|
1755
|
+
if (this.type === '/') {
|
|
1756
|
+
var res = [];
|
|
1757
|
+
this.sub.forEach(child => {
|
|
1758
|
+
if (child.type === '-')
|
|
1759
|
+
return;
|
|
1760
|
+
var val = child.toJSON();
|
|
1761
|
+
if (val !== undefined)
|
|
1762
|
+
res.push(val);
|
|
1763
|
+
});
|
|
1764
|
+
return res;
|
|
1765
|
+
}
|
|
1766
|
+
if (this.type === 'time') {
|
|
1767
|
+
return new Date(this.value);
|
|
1768
|
+
}
|
|
1769
|
+
const numb = Number(this.type);
|
|
1770
|
+
if (!Number.isNaN(numb) || this.type === 'NaN')
|
|
1771
|
+
return numb;
|
|
1772
|
+
throw new Error(`Unknown type (${this.type}) at ${this.uri}`);
|
|
1773
|
+
}
|
|
1774
|
+
get value() {
|
|
1775
|
+
var values = [];
|
|
1776
|
+
for (var child of this.sub) {
|
|
1777
|
+
if (child.type)
|
|
1778
|
+
continue;
|
|
1779
|
+
values.push(child.value);
|
|
1780
|
+
}
|
|
1781
|
+
return this.data + values.join("\n");
|
|
1782
|
+
}
|
|
1783
|
+
insert(value, ...path) {
|
|
1784
|
+
if (path.length === 0)
|
|
1785
|
+
return value;
|
|
1786
|
+
const type = path[0];
|
|
1787
|
+
if (typeof type === 'string') {
|
|
1788
|
+
let replaced = false;
|
|
1789
|
+
const sub = this.sub.map((item, index) => {
|
|
1790
|
+
if (item.type !== type)
|
|
1791
|
+
return item;
|
|
1792
|
+
replaced = true;
|
|
1793
|
+
return item.insert(value, ...path.slice(1));
|
|
1794
|
+
});
|
|
1795
|
+
if (!replaced)
|
|
1796
|
+
sub.push(new $mol_tree({ type }).insert(value, ...path.slice(1)));
|
|
1797
|
+
return this.clone({ sub });
|
|
1798
|
+
}
|
|
1799
|
+
else if (typeof type === 'number') {
|
|
1800
|
+
const sub = this.sub.slice();
|
|
1801
|
+
sub[type] = (sub[type] || new $mol_tree).insert(value, ...path.slice(1));
|
|
1802
|
+
return this.clone({ sub });
|
|
1803
|
+
}
|
|
1804
|
+
else {
|
|
1805
|
+
return this.clone({ sub: ((this.sub.length === 0) ? [new $mol_tree()] : this.sub).map(item => item.insert(value, ...path.slice(1))) });
|
|
1806
|
+
}
|
|
1807
|
+
}
|
|
1808
|
+
select(...path) {
|
|
1809
|
+
var next = [this];
|
|
1810
|
+
for (var type of path) {
|
|
1811
|
+
if (!next.length)
|
|
1812
|
+
break;
|
|
1813
|
+
var prev = next;
|
|
1814
|
+
next = [];
|
|
1815
|
+
for (var item of prev) {
|
|
1816
|
+
switch (typeof (type)) {
|
|
1817
|
+
case 'string':
|
|
1818
|
+
for (var child of item.sub) {
|
|
1819
|
+
if (!type || (child.type == type)) {
|
|
1820
|
+
next.push(child);
|
|
1821
|
+
}
|
|
1822
|
+
}
|
|
1823
|
+
break;
|
|
1824
|
+
case 'number':
|
|
1825
|
+
if (type < item.sub.length)
|
|
1826
|
+
next.push(item.sub[type]);
|
|
1827
|
+
break;
|
|
1828
|
+
default: next.push(...item.sub);
|
|
1829
|
+
}
|
|
1830
|
+
}
|
|
1831
|
+
}
|
|
1832
|
+
return new $mol_tree({ sub: next });
|
|
1833
|
+
}
|
|
1834
|
+
filter(path, value) {
|
|
1835
|
+
var sub = this.sub.filter(function (item) {
|
|
1836
|
+
var found = item.select(...path);
|
|
1837
|
+
if (value == null) {
|
|
1838
|
+
return Boolean(found.sub.length);
|
|
1839
|
+
}
|
|
1840
|
+
else {
|
|
1841
|
+
return found.sub.some(child => child.value == value);
|
|
1842
|
+
}
|
|
1843
|
+
});
|
|
1844
|
+
return new $mol_tree({ sub: sub });
|
|
1845
|
+
}
|
|
1846
|
+
transform(visit, stack = []) {
|
|
1847
|
+
const sub_stack = [this, ...stack];
|
|
1848
|
+
return visit(sub_stack, () => this.sub.map(node => node.transform(visit, sub_stack)).filter(n => n));
|
|
1849
|
+
}
|
|
1850
|
+
hack(context) {
|
|
1851
|
+
const sub = [].concat(...this.sub.map(child => {
|
|
1852
|
+
const handle = context[child.type] || context[''];
|
|
1853
|
+
if (!handle)
|
|
1854
|
+
$mol_fail(child.error('Handler not defined'));
|
|
1855
|
+
return handle(child, context);
|
|
1856
|
+
}));
|
|
1857
|
+
return this.clone({ sub });
|
|
1858
|
+
}
|
|
1859
|
+
error(message) {
|
|
1860
|
+
return new Error(`${message}:\n${this} ${this.baseUri}:${this.row}:${this.col}`);
|
|
1861
|
+
}
|
|
1862
|
+
}
|
|
1863
|
+
__decorate([
|
|
1864
|
+
$mol_deprecated('Use $mol_tree:hack')
|
|
1865
|
+
], $mol_tree.prototype, "transform", null);
|
|
1866
|
+
$.$mol_tree = $mol_tree;
|
|
1867
|
+
})($ || ($ = {}));
|
|
1868
|
+
//mol/tree/tree.ts
|
|
1869
|
+
;
|
|
1870
|
+
"use strict";
|
|
1871
|
+
var $;
|
|
1872
|
+
(function ($) {
|
|
1873
|
+
function $mol_log3_node_make(level, output, type, color) {
|
|
1874
|
+
return function $mol_log3_logger(event) {
|
|
1875
|
+
if (!event.time)
|
|
1876
|
+
event = { time: new Date().toISOString(), ...event };
|
|
1877
|
+
const tree = this.$mol_tree.fromJSON(event).clone({ type });
|
|
1878
|
+
let str = tree.toString();
|
|
1879
|
+
if (process[output].isTTY) {
|
|
1880
|
+
str = $node.colorette[color + 'Bright'](str);
|
|
1881
|
+
}
|
|
1882
|
+
;
|
|
1883
|
+
this.console[level](str);
|
|
1884
|
+
const self = this;
|
|
1885
|
+
return () => self.console.groupEnd();
|
|
1886
|
+
};
|
|
1887
|
+
}
|
|
1888
|
+
$.$mol_log3_node_make = $mol_log3_node_make;
|
|
1889
|
+
$.$mol_log3_come = $mol_log3_node_make('info', 'stdout', 'come', 'blue');
|
|
1890
|
+
$.$mol_log3_done = $mol_log3_node_make('info', 'stdout', 'done', 'green');
|
|
1891
|
+
$.$mol_log3_fail = $mol_log3_node_make('error', 'stderr', 'fail', 'red');
|
|
1892
|
+
$.$mol_log3_warn = $mol_log3_node_make('warn', 'stderr', 'warn', 'yellow');
|
|
1893
|
+
$.$mol_log3_rise = $mol_log3_node_make('log', 'stdout', 'rise', 'magenta');
|
|
1894
|
+
$.$mol_log3_area = $mol_log3_node_make('log', 'stdout', 'area', 'cyan');
|
|
1895
|
+
})($ || ($ = {}));
|
|
1896
|
+
//mol/log3/log3.node.ts
|
|
1897
|
+
;
|
|
1898
|
+
"use strict";
|
|
1899
|
+
var $;
|
|
1900
|
+
(function ($) {
|
|
1901
|
+
function $mol_env() {
|
|
1902
|
+
return {};
|
|
1903
|
+
}
|
|
1904
|
+
$.$mol_env = $mol_env;
|
|
1905
|
+
})($ || ($ = {}));
|
|
1906
|
+
//mol/env/env.ts
|
|
1907
|
+
;
|
|
1908
|
+
"use strict";
|
|
1909
|
+
var $;
|
|
1910
|
+
(function ($) {
|
|
1911
|
+
$.$mol_env = function $mol_env() {
|
|
1912
|
+
return this.process.env;
|
|
1913
|
+
};
|
|
1914
|
+
})($ || ($ = {}));
|
|
1915
|
+
//mol/env/env.node.ts
|
|
1916
|
+
;
|
|
1917
|
+
"use strict";
|
|
1918
|
+
var $;
|
|
1919
|
+
(function ($) {
|
|
1920
|
+
function $mol_exec(dir, command, ...args) {
|
|
1921
|
+
let [app, ...args0] = command.split(' ');
|
|
1922
|
+
args = [...args0, ...args];
|
|
1923
|
+
this.$mol_log3_come({
|
|
1924
|
+
place: '$mol_exec',
|
|
1925
|
+
dir: $node.path.relative('', dir),
|
|
1926
|
+
message: 'Run',
|
|
1927
|
+
command: `${app} ${args.join(' ')}`,
|
|
1928
|
+
});
|
|
1929
|
+
var res = $node['child_process'].spawnSync(app, args, {
|
|
1930
|
+
cwd: $node.path.resolve(dir),
|
|
1931
|
+
shell: true,
|
|
1932
|
+
env: this.$mol_env(),
|
|
1933
|
+
});
|
|
1934
|
+
if (res.status || res.error)
|
|
1935
|
+
return $mol_fail(res.error || new Error(res.stderr.toString()));
|
|
1936
|
+
if (!res.stdout)
|
|
1937
|
+
res.stdout = Buffer.from([]);
|
|
1938
|
+
return res;
|
|
1939
|
+
}
|
|
1940
|
+
$.$mol_exec = $mol_exec;
|
|
1941
|
+
})($ || ($ = {}));
|
|
1942
|
+
//mol/exec/exec.node.ts
|
|
1943
|
+
;
|
|
1944
|
+
"use strict";
|
|
1945
|
+
var $;
|
|
1946
|
+
(function ($) {
|
|
1947
|
+
class $mol_wire_log extends $mol_object2 {
|
|
1948
|
+
static watch(task) {
|
|
1949
|
+
return task;
|
|
1950
|
+
}
|
|
1951
|
+
static track(fiber) {
|
|
1952
|
+
const prev = $mol_wire_probe(() => this.track(fiber));
|
|
1953
|
+
let next;
|
|
1954
|
+
try {
|
|
1955
|
+
next = fiber.sync();
|
|
1956
|
+
}
|
|
1957
|
+
finally {
|
|
1958
|
+
for (const pub of fiber.pub_list) {
|
|
1959
|
+
if (pub instanceof $mol_wire_fiber) {
|
|
1960
|
+
this.track(pub);
|
|
1961
|
+
}
|
|
1962
|
+
}
|
|
1963
|
+
}
|
|
1964
|
+
if (prev !== undefined && !$mol_compare_deep(prev, next)) {
|
|
1965
|
+
this.$.$mol_log3_rise({
|
|
1966
|
+
message: 'Changed',
|
|
1967
|
+
place: fiber,
|
|
1968
|
+
});
|
|
1969
|
+
}
|
|
1970
|
+
return next;
|
|
1971
|
+
}
|
|
1972
|
+
static active() {
|
|
1973
|
+
try {
|
|
1974
|
+
this.watch()?.();
|
|
1975
|
+
}
|
|
1976
|
+
finally {
|
|
1977
|
+
for (const pub of $mol_wire_auto().pub_list) {
|
|
1978
|
+
if (pub instanceof $mol_wire_fiber) {
|
|
1979
|
+
this.track(pub);
|
|
1980
|
+
}
|
|
1981
|
+
}
|
|
1982
|
+
}
|
|
1983
|
+
}
|
|
1984
|
+
}
|
|
1985
|
+
__decorate([
|
|
1986
|
+
$mol_mem
|
|
1987
|
+
], $mol_wire_log, "watch", null);
|
|
1988
|
+
__decorate([
|
|
1989
|
+
$mol_mem_key
|
|
1990
|
+
], $mol_wire_log, "track", null);
|
|
1991
|
+
__decorate([
|
|
1992
|
+
$mol_mem
|
|
1993
|
+
], $mol_wire_log, "active", null);
|
|
1994
|
+
$.$mol_wire_log = $mol_wire_log;
|
|
1995
|
+
})($ || ($ = {}));
|
|
1996
|
+
//mol/wire/log/log.ts
|
|
1997
|
+
;
|
|
1437
1998
|
export default $
|
|
1438
1999
|
//# sourceMappingURL=node.esm.js.map
|