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.test.js
CHANGED
|
@@ -740,34 +740,6 @@ var $;
|
|
|
740
740
|
;
|
|
741
741
|
"use strict";
|
|
742
742
|
var $;
|
|
743
|
-
(function ($) {
|
|
744
|
-
function $mol_wire_probe(task, next) {
|
|
745
|
-
const warm = $mol_wire_fiber.warm;
|
|
746
|
-
try {
|
|
747
|
-
$mol_wire_fiber.warm = false;
|
|
748
|
-
return task();
|
|
749
|
-
}
|
|
750
|
-
finally {
|
|
751
|
-
$mol_wire_fiber.warm = warm;
|
|
752
|
-
}
|
|
753
|
-
}
|
|
754
|
-
$.$mol_wire_probe = $mol_wire_probe;
|
|
755
|
-
})($ || ($ = {}));
|
|
756
|
-
//mol/wire/probe/probe.ts
|
|
757
|
-
;
|
|
758
|
-
"use strict";
|
|
759
|
-
var $;
|
|
760
|
-
(function ($) {
|
|
761
|
-
function $mol_wire_solid() {
|
|
762
|
-
$mol_wire_auto().reap = nothing;
|
|
763
|
-
}
|
|
764
|
-
$.$mol_wire_solid = $mol_wire_solid;
|
|
765
|
-
const nothing = () => { };
|
|
766
|
-
})($ || ($ = {}));
|
|
767
|
-
//mol/wire/solid/solid.ts
|
|
768
|
-
;
|
|
769
|
-
"use strict";
|
|
770
|
-
var $;
|
|
771
743
|
(function ($) {
|
|
772
744
|
$.$mol_compare_deep_cache = new WeakMap();
|
|
773
745
|
function $mol_compare_deep(left, right) {
|
|
@@ -894,12 +866,12 @@ var $;
|
|
|
894
866
|
"use strict";
|
|
895
867
|
var $;
|
|
896
868
|
(function ($) {
|
|
897
|
-
class $
|
|
869
|
+
class $mol_wire_task extends $mol_wire_fiber {
|
|
898
870
|
static getter(task) {
|
|
899
871
|
return function $mol_wire_fiber_temp_get(host, args) {
|
|
900
872
|
const existen = $mol_wire_auto()?.track_next();
|
|
901
873
|
reuse: if (existen) {
|
|
902
|
-
if (!(existen instanceof $
|
|
874
|
+
if (!(existen instanceof $mol_wire_task))
|
|
903
875
|
break reuse;
|
|
904
876
|
if (existen.host !== host)
|
|
905
877
|
break reuse;
|
|
@@ -909,7 +881,7 @@ var $;
|
|
|
909
881
|
break reuse;
|
|
910
882
|
return existen;
|
|
911
883
|
}
|
|
912
|
-
return new $
|
|
884
|
+
return new $mol_wire_task(`${host?.[Symbol.toStringTag] ?? host}.${task.name}(#)`, task, host, ...args);
|
|
913
885
|
};
|
|
914
886
|
}
|
|
915
887
|
complete() {
|
|
@@ -932,53 +904,9 @@ var $;
|
|
|
932
904
|
return next;
|
|
933
905
|
}
|
|
934
906
|
}
|
|
935
|
-
$.$
|
|
936
|
-
})($ || ($ = {}));
|
|
937
|
-
//mol/wire/fiber/temp/temp.ts
|
|
938
|
-
;
|
|
939
|
-
"use strict";
|
|
940
|
-
var $;
|
|
941
|
-
(function ($) {
|
|
942
|
-
function $mol_wire_sync(obj) {
|
|
943
|
-
return new Proxy(obj, {
|
|
944
|
-
get(obj, field) {
|
|
945
|
-
const val = obj[field];
|
|
946
|
-
if (typeof val !== 'function')
|
|
947
|
-
return val;
|
|
948
|
-
const temp = $mol_wire_fiber_temp.getter(val);
|
|
949
|
-
return function $mol_wire_sync(...args) {
|
|
950
|
-
const fiber = temp(obj, args);
|
|
951
|
-
return fiber.sync();
|
|
952
|
-
};
|
|
953
|
-
}
|
|
954
|
-
});
|
|
955
|
-
}
|
|
956
|
-
$.$mol_wire_sync = $mol_wire_sync;
|
|
957
|
-
})($ || ($ = {}));
|
|
958
|
-
//mol/wire/sync/sync.ts
|
|
959
|
-
;
|
|
960
|
-
"use strict";
|
|
961
|
-
var $;
|
|
962
|
-
(function ($) {
|
|
963
|
-
function $mol_wire_async(obj) {
|
|
964
|
-
return new Proxy(obj, {
|
|
965
|
-
get(obj, field) {
|
|
966
|
-
const val = obj[field];
|
|
967
|
-
if (typeof val !== 'function')
|
|
968
|
-
return val;
|
|
969
|
-
let fiber;
|
|
970
|
-
const temp = $mol_wire_fiber_temp.getter(val);
|
|
971
|
-
return function $mol_wire_async(...args) {
|
|
972
|
-
fiber?.destructor();
|
|
973
|
-
fiber = temp(obj, args);
|
|
974
|
-
return fiber.async();
|
|
975
|
-
};
|
|
976
|
-
}
|
|
977
|
-
});
|
|
978
|
-
}
|
|
979
|
-
$.$mol_wire_async = $mol_wire_async;
|
|
907
|
+
$.$mol_wire_task = $mol_wire_task;
|
|
980
908
|
})($ || ($ = {}));
|
|
981
|
-
//mol/wire/
|
|
909
|
+
//mol/wire/task/task.ts
|
|
982
910
|
;
|
|
983
911
|
"use strict";
|
|
984
912
|
var $;
|
|
@@ -1043,7 +971,7 @@ var $;
|
|
|
1043
971
|
if (typeof sup[field] === 'function') {
|
|
1044
972
|
Object.defineProperty(orig, 'name', { value: sup[field].name });
|
|
1045
973
|
}
|
|
1046
|
-
const temp = $
|
|
974
|
+
const temp = $mol_wire_task.getter(orig);
|
|
1047
975
|
const value = function (...args) {
|
|
1048
976
|
const fiber = temp(this ?? null, args);
|
|
1049
977
|
return fiber.sync();
|
|
@@ -1061,7 +989,7 @@ var $;
|
|
|
1061
989
|
"use strict";
|
|
1062
990
|
var $;
|
|
1063
991
|
(function ($) {
|
|
1064
|
-
class $
|
|
992
|
+
class $mol_wire_atom extends $mol_wire_fiber {
|
|
1065
993
|
static getter(task, keys) {
|
|
1066
994
|
const field = task.name + '()';
|
|
1067
995
|
if (keys) {
|
|
@@ -1077,7 +1005,7 @@ var $;
|
|
|
1077
1005
|
else {
|
|
1078
1006
|
dict = (host ?? task)[field] = new Map();
|
|
1079
1007
|
}
|
|
1080
|
-
fiber = new $
|
|
1008
|
+
fiber = new $mol_wire_atom(key, task, host, ...args);
|
|
1081
1009
|
dict.set(key, fiber);
|
|
1082
1010
|
return fiber;
|
|
1083
1011
|
};
|
|
@@ -1088,7 +1016,7 @@ var $;
|
|
|
1088
1016
|
if (existen)
|
|
1089
1017
|
return existen;
|
|
1090
1018
|
const key = `${host?.[Symbol.toStringTag] ?? host}.${field}`;
|
|
1091
|
-
const fiber = new $
|
|
1019
|
+
const fiber = new $mol_wire_atom(key, task, host, ...args);
|
|
1092
1020
|
(host ?? task)[field] = fiber;
|
|
1093
1021
|
return fiber;
|
|
1094
1022
|
};
|
|
@@ -1152,13 +1080,85 @@ var $;
|
|
|
1152
1080
|
}
|
|
1153
1081
|
__decorate([
|
|
1154
1082
|
$mol_wire_method
|
|
1155
|
-
], $
|
|
1083
|
+
], $mol_wire_atom.prototype, "recall", null);
|
|
1156
1084
|
__decorate([
|
|
1157
1085
|
$mol_wire_method
|
|
1158
|
-
], $
|
|
1159
|
-
$.$
|
|
1086
|
+
], $mol_wire_atom.prototype, "once", null);
|
|
1087
|
+
$.$mol_wire_atom = $mol_wire_atom;
|
|
1088
|
+
})($ || ($ = {}));
|
|
1089
|
+
//mol/wire/atom/atom.ts
|
|
1090
|
+
;
|
|
1091
|
+
"use strict";
|
|
1092
|
+
var $;
|
|
1093
|
+
(function ($) {
|
|
1094
|
+
function $mol_wire_probe(task, next) {
|
|
1095
|
+
const warm = $mol_wire_fiber.warm;
|
|
1096
|
+
try {
|
|
1097
|
+
$mol_wire_fiber.warm = false;
|
|
1098
|
+
return task();
|
|
1099
|
+
}
|
|
1100
|
+
finally {
|
|
1101
|
+
$mol_wire_fiber.warm = warm;
|
|
1102
|
+
}
|
|
1103
|
+
}
|
|
1104
|
+
$.$mol_wire_probe = $mol_wire_probe;
|
|
1105
|
+
})($ || ($ = {}));
|
|
1106
|
+
//mol/wire/probe/probe.ts
|
|
1107
|
+
;
|
|
1108
|
+
"use strict";
|
|
1109
|
+
var $;
|
|
1110
|
+
(function ($) {
|
|
1111
|
+
function $mol_wire_solid() {
|
|
1112
|
+
$mol_wire_auto().reap = nothing;
|
|
1113
|
+
}
|
|
1114
|
+
$.$mol_wire_solid = $mol_wire_solid;
|
|
1115
|
+
const nothing = () => { };
|
|
1116
|
+
})($ || ($ = {}));
|
|
1117
|
+
//mol/wire/solid/solid.ts
|
|
1118
|
+
;
|
|
1119
|
+
"use strict";
|
|
1120
|
+
var $;
|
|
1121
|
+
(function ($) {
|
|
1122
|
+
function $mol_wire_sync(obj) {
|
|
1123
|
+
return new Proxy(obj, {
|
|
1124
|
+
get(obj, field) {
|
|
1125
|
+
const val = obj[field];
|
|
1126
|
+
if (typeof val !== 'function')
|
|
1127
|
+
return val;
|
|
1128
|
+
const temp = $mol_wire_task.getter(val);
|
|
1129
|
+
return function $mol_wire_sync(...args) {
|
|
1130
|
+
const fiber = temp(obj, args);
|
|
1131
|
+
return fiber.sync();
|
|
1132
|
+
};
|
|
1133
|
+
}
|
|
1134
|
+
});
|
|
1135
|
+
}
|
|
1136
|
+
$.$mol_wire_sync = $mol_wire_sync;
|
|
1137
|
+
})($ || ($ = {}));
|
|
1138
|
+
//mol/wire/sync/sync.ts
|
|
1139
|
+
;
|
|
1140
|
+
"use strict";
|
|
1141
|
+
var $;
|
|
1142
|
+
(function ($) {
|
|
1143
|
+
function $mol_wire_async(obj) {
|
|
1144
|
+
return new Proxy(obj, {
|
|
1145
|
+
get(obj, field) {
|
|
1146
|
+
const val = obj[field];
|
|
1147
|
+
if (typeof val !== 'function')
|
|
1148
|
+
return val;
|
|
1149
|
+
let fiber;
|
|
1150
|
+
const temp = $mol_wire_task.getter(val);
|
|
1151
|
+
return function $mol_wire_async(...args) {
|
|
1152
|
+
fiber?.destructor();
|
|
1153
|
+
fiber = temp(obj, args);
|
|
1154
|
+
return fiber.async();
|
|
1155
|
+
};
|
|
1156
|
+
}
|
|
1157
|
+
});
|
|
1158
|
+
}
|
|
1159
|
+
$.$mol_wire_async = $mol_wire_async;
|
|
1160
1160
|
})($ || ($ = {}));
|
|
1161
|
-
//mol/wire/
|
|
1161
|
+
//mol/wire/async/async.ts
|
|
1162
1162
|
;
|
|
1163
1163
|
"use strict";
|
|
1164
1164
|
var $;
|
|
@@ -1184,11 +1184,11 @@ var $;
|
|
|
1184
1184
|
$.$mol_wire_mem = $mol_wire_mem;
|
|
1185
1185
|
function $mol_wire_mem_func(keys) {
|
|
1186
1186
|
return (func) => {
|
|
1187
|
-
const persist = $
|
|
1187
|
+
const persist = $mol_wire_atom.getter(func, keys);
|
|
1188
1188
|
const wrapper = function (...args) {
|
|
1189
1189
|
let atom = persist(this, args.slice(0, keys));
|
|
1190
1190
|
if (args.length <= keys || args[keys] === undefined) {
|
|
1191
|
-
if ($mol_wire_auto() instanceof $
|
|
1191
|
+
if ($mol_wire_auto() instanceof $mol_wire_task) {
|
|
1192
1192
|
return atom.once();
|
|
1193
1193
|
}
|
|
1194
1194
|
else {
|
|
@@ -1226,7 +1226,7 @@ var $;
|
|
|
1226
1226
|
if (!descr)
|
|
1227
1227
|
descr = Reflect.getOwnPropertyDescriptor(host, field);
|
|
1228
1228
|
const _get = descr?.get || $mol_const(descr?.value);
|
|
1229
|
-
const persist = $
|
|
1229
|
+
const persist = $mol_wire_atom.getter(_get, 0);
|
|
1230
1230
|
const _set = descr?.set || function (next) {
|
|
1231
1231
|
persist(this, []).put(next);
|
|
1232
1232
|
};
|
|
@@ -1237,7 +1237,7 @@ var $;
|
|
|
1237
1237
|
function get() {
|
|
1238
1238
|
return persist(this, []).sync();
|
|
1239
1239
|
}
|
|
1240
|
-
const temp = $
|
|
1240
|
+
const temp = $mol_wire_task.getter(_set);
|
|
1241
1241
|
function set(next) {
|
|
1242
1242
|
temp(this, [next]).sync();
|
|
1243
1243
|
}
|
|
@@ -1429,109 +1429,36 @@ var $;
|
|
|
1429
1429
|
"use strict";
|
|
1430
1430
|
var $;
|
|
1431
1431
|
(function ($) {
|
|
1432
|
-
|
|
1433
|
-
|
|
1434
|
-
|
|
1435
|
-
$.$
|
|
1432
|
+
$.$mol_mem = $mol_wire_mem(0);
|
|
1433
|
+
$.$mol_mem_key = $mol_wire_mem(1);
|
|
1434
|
+
$.$mol_mem_key2 = $mol_wire_mem(2);
|
|
1435
|
+
$.$mol_mem_key3 = $mol_wire_mem(3);
|
|
1436
1436
|
})($ || ($ = {}));
|
|
1437
|
-
//mol/
|
|
1437
|
+
//mol/mem/mem.ts
|
|
1438
1438
|
;
|
|
1439
1439
|
"use strict";
|
|
1440
1440
|
var $;
|
|
1441
|
-
(function ($
|
|
1442
|
-
function $
|
|
1443
|
-
|
|
1444
|
-
|
|
1445
|
-
|
|
1446
|
-
|
|
1447
|
-
|
|
1448
|
-
|
|
1449
|
-
|
|
1450
|
-
$_1.$mol_test = $mol_test;
|
|
1451
|
-
$_1.$mol_test_mocks = [];
|
|
1452
|
-
$_1.$mol_test_all = [];
|
|
1453
|
-
async function $mol_test_run() {
|
|
1454
|
-
for (var test of $_1.$mol_test_all) {
|
|
1455
|
-
let context = Object.create($$);
|
|
1456
|
-
for (let mock of $_1.$mol_test_mocks)
|
|
1457
|
-
await mock(context);
|
|
1458
|
-
const res = test(context);
|
|
1459
|
-
if (res instanceof Promise) {
|
|
1460
|
-
await new Promise((done, fail) => {
|
|
1461
|
-
res.then(done, fail);
|
|
1462
|
-
setTimeout(() => fail(new Error('Test timeout: ' + test.name)), 1000);
|
|
1463
|
-
});
|
|
1464
|
-
}
|
|
1465
|
-
}
|
|
1466
|
-
$$.$mol_log3_done({
|
|
1467
|
-
place: '$mol_test',
|
|
1468
|
-
message: 'All tests passed',
|
|
1469
|
-
count: $_1.$mol_test_all.length,
|
|
1441
|
+
(function ($) {
|
|
1442
|
+
function $mol_log3_area_lazy(event) {
|
|
1443
|
+
const self = this;
|
|
1444
|
+
const stack = self.$mol_log3_stack;
|
|
1445
|
+
const deep = stack.length;
|
|
1446
|
+
let logged = false;
|
|
1447
|
+
stack.push(() => {
|
|
1448
|
+
logged = true;
|
|
1449
|
+
self.$mol_log3_area.call(self, event);
|
|
1470
1450
|
});
|
|
1451
|
+
return () => {
|
|
1452
|
+
if (logged)
|
|
1453
|
+
self.console.groupEnd();
|
|
1454
|
+
if (stack.length > deep)
|
|
1455
|
+
stack.length = deep;
|
|
1456
|
+
};
|
|
1471
1457
|
}
|
|
1472
|
-
|
|
1473
|
-
|
|
1474
|
-
function $mol_test_schedule() {
|
|
1475
|
-
if (scheduled)
|
|
1476
|
-
return;
|
|
1477
|
-
scheduled = true;
|
|
1478
|
-
setTimeout(async () => {
|
|
1479
|
-
scheduled = false;
|
|
1480
|
-
try {
|
|
1481
|
-
await $mol_test_run();
|
|
1482
|
-
}
|
|
1483
|
-
finally {
|
|
1484
|
-
$$.$mol_test_complete();
|
|
1485
|
-
}
|
|
1486
|
-
}, 0);
|
|
1487
|
-
}
|
|
1488
|
-
$_1.$mol_test_schedule = $mol_test_schedule;
|
|
1489
|
-
$_1.$mol_test_mocks.push(context => {
|
|
1490
|
-
let seed = 0;
|
|
1491
|
-
context.Math = Object.create(Math);
|
|
1492
|
-
context.Math.random = () => Math.sin(seed++);
|
|
1493
|
-
const forbidden = ['XMLHttpRequest', 'fetch'];
|
|
1494
|
-
for (let api of forbidden) {
|
|
1495
|
-
context[api] = new Proxy(function () { }, {
|
|
1496
|
-
get() {
|
|
1497
|
-
$mol_fail_hidden(new Error(`${api} is forbidden in tests`));
|
|
1498
|
-
},
|
|
1499
|
-
apply() {
|
|
1500
|
-
$mol_fail_hidden(new Error(`${api} is forbidden in tests`));
|
|
1501
|
-
},
|
|
1502
|
-
});
|
|
1503
|
-
}
|
|
1504
|
-
});
|
|
1505
|
-
$mol_test({
|
|
1506
|
-
'mocked Math.random'($) {
|
|
1507
|
-
console.assert($.Math.random() === 0);
|
|
1508
|
-
console.assert($.Math.random() === Math.sin(1));
|
|
1509
|
-
},
|
|
1510
|
-
'forbidden XMLHttpRequest'($) {
|
|
1511
|
-
try {
|
|
1512
|
-
console.assert(void new $.XMLHttpRequest);
|
|
1513
|
-
}
|
|
1514
|
-
catch (error) {
|
|
1515
|
-
console.assert(error.message === 'XMLHttpRequest is forbidden in tests');
|
|
1516
|
-
}
|
|
1517
|
-
},
|
|
1518
|
-
'forbidden fetch'($) {
|
|
1519
|
-
try {
|
|
1520
|
-
console.assert(void $.fetch(''));
|
|
1521
|
-
}
|
|
1522
|
-
catch (error) {
|
|
1523
|
-
console.assert(error.message === 'fetch is forbidden in tests');
|
|
1524
|
-
}
|
|
1525
|
-
},
|
|
1526
|
-
});
|
|
1458
|
+
$.$mol_log3_area_lazy = $mol_log3_area_lazy;
|
|
1459
|
+
$.$mol_log3_stack = [];
|
|
1527
1460
|
})($ || ($ = {}));
|
|
1528
|
-
//mol/
|
|
1529
|
-
;
|
|
1530
|
-
"use strict";
|
|
1531
|
-
var $;
|
|
1532
|
-
(function ($) {
|
|
1533
|
-
})($ || ($ = {}));
|
|
1534
|
-
//mol/dom/context/context.ts
|
|
1461
|
+
//mol/log3/log3.ts
|
|
1535
1462
|
;
|
|
1536
1463
|
"use strict";
|
|
1537
1464
|
//node/node.ts
|
|
@@ -1578,934 +1505,1428 @@ require = (req => Object.assign(function require(name) {
|
|
|
1578
1505
|
"use strict";
|
|
1579
1506
|
var $;
|
|
1580
1507
|
(function ($) {
|
|
1581
|
-
|
|
1508
|
+
function $mol_deprecated(message) {
|
|
1509
|
+
return (host, field, descr) => {
|
|
1510
|
+
const value = descr.value;
|
|
1511
|
+
let warned = false;
|
|
1512
|
+
descr.value = function $mol_deprecated_wrapper(...args) {
|
|
1513
|
+
if (!warned) {
|
|
1514
|
+
$$.$mol_log3_warn({
|
|
1515
|
+
place: `${host.constructor.name}::${field}`,
|
|
1516
|
+
message: `Deprecated`,
|
|
1517
|
+
hint: message,
|
|
1518
|
+
});
|
|
1519
|
+
warned = true;
|
|
1520
|
+
}
|
|
1521
|
+
return value.call(this, ...args);
|
|
1522
|
+
};
|
|
1523
|
+
};
|
|
1524
|
+
}
|
|
1525
|
+
$.$mol_deprecated = $mol_deprecated;
|
|
1582
1526
|
})($ || ($ = {}));
|
|
1583
|
-
//mol/
|
|
1527
|
+
//mol/deprecated/deprecated.ts
|
|
1584
1528
|
;
|
|
1585
1529
|
"use strict";
|
|
1586
1530
|
var $;
|
|
1587
1531
|
(function ($) {
|
|
1588
|
-
|
|
1589
|
-
|
|
1590
|
-
|
|
1591
|
-
|
|
1592
|
-
|
|
1593
|
-
|
|
1594
|
-
|
|
1595
|
-
|
|
1596
|
-
|
|
1597
|
-
|
|
1598
|
-
|
|
1532
|
+
$.$mol_tree_convert = Symbol('$mol_tree_convert');
|
|
1533
|
+
class $mol_tree extends $mol_object2 {
|
|
1534
|
+
type;
|
|
1535
|
+
data;
|
|
1536
|
+
sub;
|
|
1537
|
+
baseUri;
|
|
1538
|
+
row;
|
|
1539
|
+
col;
|
|
1540
|
+
length;
|
|
1541
|
+
constructor(config = {}) {
|
|
1542
|
+
super();
|
|
1543
|
+
this.type = config.type || '';
|
|
1544
|
+
if (config.value !== undefined) {
|
|
1545
|
+
var sub = $mol_tree.values(config.value);
|
|
1546
|
+
if (config.type || sub.length > 1) {
|
|
1547
|
+
this.sub = [...sub, ...(config.sub || [])];
|
|
1548
|
+
this.data = config.data || '';
|
|
1549
|
+
}
|
|
1550
|
+
else {
|
|
1551
|
+
this.data = sub[0].data;
|
|
1552
|
+
this.sub = config.sub || [];
|
|
1553
|
+
}
|
|
1554
|
+
}
|
|
1555
|
+
else {
|
|
1556
|
+
this.data = config.data || '';
|
|
1557
|
+
this.sub = config.sub || [];
|
|
1558
|
+
}
|
|
1559
|
+
this.baseUri = config.baseUri || '';
|
|
1560
|
+
this.row = config.row || 0;
|
|
1561
|
+
this.col = config.col || 0;
|
|
1562
|
+
this.length = config.length || 0;
|
|
1563
|
+
}
|
|
1564
|
+
static values(str, baseUri) {
|
|
1565
|
+
return str.split('\n').map((data, index) => new $mol_tree({
|
|
1566
|
+
data: data,
|
|
1567
|
+
baseUri: baseUri,
|
|
1568
|
+
row: index + 1,
|
|
1569
|
+
length: data.length,
|
|
1570
|
+
}));
|
|
1571
|
+
}
|
|
1572
|
+
clone(config = {}) {
|
|
1573
|
+
return new $mol_tree({
|
|
1574
|
+
type: ('type' in config) ? config.type : this.type,
|
|
1575
|
+
data: ('data' in config) ? config.data : this.data,
|
|
1576
|
+
sub: ('sub' in config) ? config.sub : this.sub,
|
|
1577
|
+
baseUri: ('baseUri' in config) ? config.baseUri : this.baseUri,
|
|
1578
|
+
row: ('row' in config) ? config.row : this.row,
|
|
1579
|
+
col: ('col' in config) ? config.col : this.col,
|
|
1580
|
+
length: ('length' in config) ? config.length : this.length,
|
|
1581
|
+
value: config.value
|
|
1582
|
+
});
|
|
1583
|
+
}
|
|
1584
|
+
make(config) {
|
|
1585
|
+
return new $mol_tree({
|
|
1586
|
+
baseUri: this.baseUri,
|
|
1587
|
+
row: this.row,
|
|
1588
|
+
col: this.col,
|
|
1589
|
+
length: this.length,
|
|
1590
|
+
...config,
|
|
1591
|
+
});
|
|
1592
|
+
}
|
|
1593
|
+
make_data(value, sub) {
|
|
1594
|
+
return this.make({ value, sub });
|
|
1595
|
+
}
|
|
1596
|
+
make_struct(type, sub) {
|
|
1597
|
+
return this.make({ type, sub });
|
|
1598
|
+
}
|
|
1599
|
+
static fromString(str, baseUri) {
|
|
1600
|
+
var root = new $mol_tree({ baseUri: baseUri });
|
|
1601
|
+
var stack = [root];
|
|
1602
|
+
var row = 0;
|
|
1603
|
+
var prefix = str.replace(/^\n?(\t*)[\s\S]*/, '$1');
|
|
1604
|
+
var lines = str.replace(new RegExp('^\\t{0,' + prefix.length + '}', 'mg'), '').split('\n');
|
|
1605
|
+
lines.forEach(line => {
|
|
1606
|
+
++row;
|
|
1607
|
+
var chunks = /^(\t*)((?:[^\n\t\\ ]+ *)*)(\\[^\n]*)?(.*?)(?:$|\n)/m.exec(line);
|
|
1608
|
+
if (!chunks || chunks[4])
|
|
1609
|
+
return this.$.$mol_fail(new Error(`Syntax error at ${baseUri}:${row}\n${line}`));
|
|
1610
|
+
var indent = chunks[1];
|
|
1611
|
+
var path = chunks[2];
|
|
1612
|
+
var data = chunks[3];
|
|
1613
|
+
var deep = indent.length;
|
|
1614
|
+
var types = path ? path.replace(/ $/, '').split(/ +/) : [];
|
|
1615
|
+
if (stack.length <= deep)
|
|
1616
|
+
return this.$.$mol_fail(new Error(`Too many tabs at ${baseUri}:${row}\n${line}`));
|
|
1617
|
+
stack.length = deep + 1;
|
|
1618
|
+
var parent = stack[deep];
|
|
1619
|
+
let col = deep;
|
|
1620
|
+
types.forEach(type => {
|
|
1621
|
+
if (!type)
|
|
1622
|
+
return this.$.$mol_fail(new Error(`Unexpected space symbol ${baseUri}:${row}\n${line}`));
|
|
1623
|
+
var next = new $mol_tree({ type, baseUri, row, col, length: type.length });
|
|
1624
|
+
const parent_sub = parent.sub;
|
|
1625
|
+
parent_sub.push(next);
|
|
1626
|
+
parent = next;
|
|
1627
|
+
col += type.length + 1;
|
|
1628
|
+
});
|
|
1629
|
+
if (data) {
|
|
1630
|
+
var next = new $mol_tree({ data: data.substring(1), baseUri, row, col, length: data.length });
|
|
1631
|
+
const parent_sub = parent.sub;
|
|
1632
|
+
parent_sub.push(next);
|
|
1633
|
+
parent = next;
|
|
1634
|
+
}
|
|
1635
|
+
stack.push(parent);
|
|
1636
|
+
});
|
|
1637
|
+
return root;
|
|
1638
|
+
}
|
|
1639
|
+
static fromJSON(json, baseUri = '') {
|
|
1640
|
+
switch (true) {
|
|
1641
|
+
case typeof json === 'boolean':
|
|
1642
|
+
case typeof json === 'number':
|
|
1643
|
+
case json === null:
|
|
1644
|
+
return new $mol_tree({
|
|
1645
|
+
type: String(json),
|
|
1646
|
+
baseUri: baseUri
|
|
1647
|
+
});
|
|
1648
|
+
case typeof json === 'string':
|
|
1649
|
+
return new $mol_tree({
|
|
1650
|
+
value: json,
|
|
1651
|
+
baseUri: baseUri
|
|
1652
|
+
});
|
|
1653
|
+
case Array.isArray(json):
|
|
1654
|
+
return new $mol_tree({
|
|
1655
|
+
type: "/",
|
|
1656
|
+
sub: json.map(json => $mol_tree.fromJSON(json, baseUri))
|
|
1657
|
+
});
|
|
1658
|
+
case json instanceof Date:
|
|
1659
|
+
return new $mol_tree({
|
|
1660
|
+
value: json.toISOString(),
|
|
1661
|
+
baseUri: baseUri
|
|
1662
|
+
});
|
|
1663
|
+
default:
|
|
1664
|
+
if (typeof json[$.$mol_tree_convert] === 'function') {
|
|
1665
|
+
return json[$.$mol_tree_convert]();
|
|
1599
1666
|
}
|
|
1600
|
-
if (
|
|
1601
|
-
|
|
1602
|
-
break;
|
|
1667
|
+
if (typeof json.toJSON === 'function') {
|
|
1668
|
+
return $mol_tree.fromJSON(json.toJSON());
|
|
1603
1669
|
}
|
|
1604
|
-
|
|
1605
|
-
|
|
1606
|
-
|
|
1607
|
-
|
|
1670
|
+
if (json instanceof Error) {
|
|
1671
|
+
const { name, message, stack } = json;
|
|
1672
|
+
json = { ...json, name, message, stack };
|
|
1673
|
+
}
|
|
1674
|
+
var sub = [];
|
|
1675
|
+
for (var key in json) {
|
|
1676
|
+
if (json[key] === undefined)
|
|
1677
|
+
continue;
|
|
1678
|
+
const subsub = $mol_tree.fromJSON(json[key], baseUri);
|
|
1679
|
+
if (/^[^\n\t\\ ]+$/.test(key)) {
|
|
1680
|
+
var child = new $mol_tree({
|
|
1681
|
+
type: key,
|
|
1682
|
+
baseUri: baseUri,
|
|
1683
|
+
sub: [subsub],
|
|
1684
|
+
});
|
|
1608
1685
|
}
|
|
1609
1686
|
else {
|
|
1610
|
-
|
|
1611
|
-
|
|
1612
|
-
|
|
1687
|
+
var child = new $mol_tree({
|
|
1688
|
+
value: key,
|
|
1689
|
+
baseUri: baseUri,
|
|
1690
|
+
sub: [subsub],
|
|
1691
|
+
});
|
|
1613
1692
|
}
|
|
1693
|
+
sub.push(child);
|
|
1614
1694
|
}
|
|
1615
|
-
|
|
1695
|
+
return new $mol_tree({
|
|
1696
|
+
type: "*",
|
|
1697
|
+
sub: sub,
|
|
1698
|
+
baseUri: baseUri
|
|
1699
|
+
});
|
|
1616
1700
|
}
|
|
1617
|
-
|
|
1618
|
-
|
|
1619
|
-
|
|
1620
|
-
|
|
1621
|
-
|
|
1622
|
-
|
|
1701
|
+
}
|
|
1702
|
+
get uri() {
|
|
1703
|
+
return this.baseUri + '#' + this.row + ':' + this.col;
|
|
1704
|
+
}
|
|
1705
|
+
toString(prefix = '') {
|
|
1706
|
+
var output = '';
|
|
1707
|
+
if (this.type.length) {
|
|
1708
|
+
if (!prefix.length) {
|
|
1709
|
+
prefix = "\t";
|
|
1623
1710
|
}
|
|
1624
|
-
|
|
1625
|
-
|
|
1626
|
-
|
|
1711
|
+
output += this.type;
|
|
1712
|
+
if (this.sub.length == 1) {
|
|
1713
|
+
return output + ' ' + this.sub[0].toString(prefix);
|
|
1627
1714
|
}
|
|
1715
|
+
output += "\n";
|
|
1628
1716
|
}
|
|
1717
|
+
else if (this.data.length || prefix.length) {
|
|
1718
|
+
output += "\\" + this.data + "\n";
|
|
1719
|
+
}
|
|
1720
|
+
for (var child of this.sub) {
|
|
1721
|
+
output += prefix;
|
|
1722
|
+
output += child.toString(prefix + "\t");
|
|
1723
|
+
}
|
|
1724
|
+
return output;
|
|
1629
1725
|
}
|
|
1630
|
-
|
|
1631
|
-
|
|
1632
|
-
|
|
1633
|
-
|
|
1634
|
-
|
|
1635
|
-
|
|
1636
|
-
|
|
1637
|
-
|
|
1638
|
-
|
|
1639
|
-
|
|
1640
|
-
|
|
1641
|
-
|
|
1642
|
-
|
|
1643
|
-
|
|
1644
|
-
|
|
1645
|
-
;
|
|
1646
|
-
|
|
1647
|
-
|
|
1648
|
-
|
|
1649
|
-
|
|
1650
|
-
|
|
1651
|
-
|
|
1652
|
-
|
|
1653
|
-
|
|
1726
|
+
toJSON() {
|
|
1727
|
+
if (!this.type)
|
|
1728
|
+
return this.value;
|
|
1729
|
+
if (this.type === 'true')
|
|
1730
|
+
return true;
|
|
1731
|
+
if (this.type === 'false')
|
|
1732
|
+
return false;
|
|
1733
|
+
if (this.type === 'null')
|
|
1734
|
+
return null;
|
|
1735
|
+
if (this.type === '*') {
|
|
1736
|
+
var obj = {};
|
|
1737
|
+
for (var child of this.sub) {
|
|
1738
|
+
if (child.type === '-')
|
|
1739
|
+
continue;
|
|
1740
|
+
var key = child.type || child.clone({ sub: child.sub.slice(0, child.sub.length - 1) }).value;
|
|
1741
|
+
var val = child.sub[child.sub.length - 1].toJSON();
|
|
1742
|
+
if (val !== undefined)
|
|
1743
|
+
obj[key] = val;
|
|
1744
|
+
}
|
|
1745
|
+
return obj;
|
|
1746
|
+
}
|
|
1747
|
+
if (this.type === '/') {
|
|
1748
|
+
var res = [];
|
|
1749
|
+
this.sub.forEach(child => {
|
|
1750
|
+
if (child.type === '-')
|
|
1751
|
+
return;
|
|
1752
|
+
var val = child.toJSON();
|
|
1753
|
+
if (val !== undefined)
|
|
1754
|
+
res.push(val);
|
|
1755
|
+
});
|
|
1756
|
+
return res;
|
|
1757
|
+
}
|
|
1758
|
+
if (this.type === 'time') {
|
|
1759
|
+
return new Date(this.value);
|
|
1760
|
+
}
|
|
1761
|
+
const numb = Number(this.type);
|
|
1762
|
+
if (!Number.isNaN(numb) || this.type === 'NaN')
|
|
1763
|
+
return numb;
|
|
1764
|
+
throw new Error(`Unknown type (${this.type}) at ${this.uri}`);
|
|
1765
|
+
}
|
|
1766
|
+
get value() {
|
|
1767
|
+
var values = [];
|
|
1768
|
+
for (var child of this.sub) {
|
|
1769
|
+
if (child.type)
|
|
1770
|
+
continue;
|
|
1771
|
+
values.push(child.value);
|
|
1772
|
+
}
|
|
1773
|
+
return this.data + values.join("\n");
|
|
1774
|
+
}
|
|
1775
|
+
insert(value, ...path) {
|
|
1776
|
+
if (path.length === 0)
|
|
1777
|
+
return value;
|
|
1778
|
+
const type = path[0];
|
|
1779
|
+
if (typeof type === 'string') {
|
|
1780
|
+
let replaced = false;
|
|
1781
|
+
const sub = this.sub.map((item, index) => {
|
|
1782
|
+
if (item.type !== type)
|
|
1783
|
+
return item;
|
|
1784
|
+
replaced = true;
|
|
1785
|
+
return item.insert(value, ...path.slice(1));
|
|
1786
|
+
});
|
|
1787
|
+
if (!replaced)
|
|
1788
|
+
sub.push(new $mol_tree({ type }).insert(value, ...path.slice(1)));
|
|
1789
|
+
return this.clone({ sub });
|
|
1790
|
+
}
|
|
1791
|
+
else if (typeof type === 'number') {
|
|
1792
|
+
const sub = this.sub.slice();
|
|
1793
|
+
sub[type] = (sub[type] || new $mol_tree).insert(value, ...path.slice(1));
|
|
1794
|
+
return this.clone({ sub });
|
|
1795
|
+
}
|
|
1796
|
+
else {
|
|
1797
|
+
return this.clone({ sub: ((this.sub.length === 0) ? [new $mol_tree()] : this.sub).map(item => item.insert(value, ...path.slice(1))) });
|
|
1798
|
+
}
|
|
1799
|
+
}
|
|
1800
|
+
select(...path) {
|
|
1801
|
+
var next = [this];
|
|
1802
|
+
for (var type of path) {
|
|
1803
|
+
if (!next.length)
|
|
1804
|
+
break;
|
|
1805
|
+
var prev = next;
|
|
1806
|
+
next = [];
|
|
1807
|
+
for (var item of prev) {
|
|
1808
|
+
switch (typeof (type)) {
|
|
1809
|
+
case 'string':
|
|
1810
|
+
for (var child of item.sub) {
|
|
1811
|
+
if (!type || (child.type == type)) {
|
|
1812
|
+
next.push(child);
|
|
1813
|
+
}
|
|
1814
|
+
}
|
|
1815
|
+
break;
|
|
1816
|
+
case 'number':
|
|
1817
|
+
if (type < item.sub.length)
|
|
1818
|
+
next.push(item.sub[type]);
|
|
1819
|
+
break;
|
|
1820
|
+
default: next.push(...item.sub);
|
|
1821
|
+
}
|
|
1822
|
+
}
|
|
1823
|
+
}
|
|
1824
|
+
return new $mol_tree({ sub: next });
|
|
1825
|
+
}
|
|
1826
|
+
filter(path, value) {
|
|
1827
|
+
var sub = this.sub.filter(function (item) {
|
|
1828
|
+
var found = item.select(...path);
|
|
1829
|
+
if (value == null) {
|
|
1830
|
+
return Boolean(found.sub.length);
|
|
1831
|
+
}
|
|
1832
|
+
else {
|
|
1833
|
+
return found.sub.some(child => child.value == value);
|
|
1834
|
+
}
|
|
1835
|
+
});
|
|
1836
|
+
return new $mol_tree({ sub: sub });
|
|
1837
|
+
}
|
|
1838
|
+
transform(visit, stack = []) {
|
|
1839
|
+
const sub_stack = [this, ...stack];
|
|
1840
|
+
return visit(sub_stack, () => this.sub.map(node => node.transform(visit, sub_stack)).filter(n => n));
|
|
1841
|
+
}
|
|
1842
|
+
hack(context) {
|
|
1843
|
+
const sub = [].concat(...this.sub.map(child => {
|
|
1844
|
+
const handle = context[child.type] || context[''];
|
|
1845
|
+
if (!handle)
|
|
1846
|
+
$mol_fail(child.error('Handler not defined'));
|
|
1847
|
+
return handle(child, context);
|
|
1848
|
+
}));
|
|
1849
|
+
return this.clone({ sub });
|
|
1850
|
+
}
|
|
1851
|
+
error(message) {
|
|
1852
|
+
return new Error(`${message}:\n${this} ${this.baseUri}:${this.row}:${this.col}`);
|
|
1853
|
+
}
|
|
1854
|
+
}
|
|
1855
|
+
__decorate([
|
|
1856
|
+
$mol_deprecated('Use $mol_tree:hack')
|
|
1857
|
+
], $mol_tree.prototype, "transform", null);
|
|
1858
|
+
$.$mol_tree = $mol_tree;
|
|
1859
|
+
})($ || ($ = {}));
|
|
1860
|
+
//mol/tree/tree.ts
|
|
1654
1861
|
;
|
|
1655
1862
|
"use strict";
|
|
1656
|
-
|
|
1863
|
+
var $;
|
|
1864
|
+
(function ($) {
|
|
1865
|
+
function $mol_log3_node_make(level, output, type, color) {
|
|
1866
|
+
return function $mol_log3_logger(event) {
|
|
1867
|
+
if (!event.time)
|
|
1868
|
+
event = { time: new Date().toISOString(), ...event };
|
|
1869
|
+
const tree = this.$mol_tree.fromJSON(event).clone({ type });
|
|
1870
|
+
let str = tree.toString();
|
|
1871
|
+
if (process[output].isTTY) {
|
|
1872
|
+
str = $node.colorette[color + 'Bright'](str);
|
|
1873
|
+
}
|
|
1874
|
+
;
|
|
1875
|
+
this.console[level](str);
|
|
1876
|
+
const self = this;
|
|
1877
|
+
return () => self.console.groupEnd();
|
|
1878
|
+
};
|
|
1879
|
+
}
|
|
1880
|
+
$.$mol_log3_node_make = $mol_log3_node_make;
|
|
1881
|
+
$.$mol_log3_come = $mol_log3_node_make('info', 'stdout', 'come', 'blue');
|
|
1882
|
+
$.$mol_log3_done = $mol_log3_node_make('info', 'stdout', 'done', 'green');
|
|
1883
|
+
$.$mol_log3_fail = $mol_log3_node_make('error', 'stderr', 'fail', 'red');
|
|
1884
|
+
$.$mol_log3_warn = $mol_log3_node_make('warn', 'stderr', 'warn', 'yellow');
|
|
1885
|
+
$.$mol_log3_rise = $mol_log3_node_make('log', 'stdout', 'rise', 'magenta');
|
|
1886
|
+
$.$mol_log3_area = $mol_log3_node_make('log', 'stdout', 'area', 'cyan');
|
|
1887
|
+
})($ || ($ = {}));
|
|
1888
|
+
//mol/log3/log3.node.ts
|
|
1657
1889
|
;
|
|
1658
1890
|
"use strict";
|
|
1659
|
-
|
|
1891
|
+
var $;
|
|
1892
|
+
(function ($) {
|
|
1893
|
+
function $mol_env() {
|
|
1894
|
+
return {};
|
|
1895
|
+
}
|
|
1896
|
+
$.$mol_env = $mol_env;
|
|
1897
|
+
})($ || ($ = {}));
|
|
1898
|
+
//mol/env/env.ts
|
|
1660
1899
|
;
|
|
1661
1900
|
"use strict";
|
|
1662
1901
|
var $;
|
|
1663
1902
|
(function ($) {
|
|
1664
|
-
$
|
|
1665
|
-
|
|
1666
|
-
|
|
1667
|
-
},
|
|
1668
|
-
'Define native field'() {
|
|
1669
|
-
const dom = $mol_jsx("input", { value: '123' });
|
|
1670
|
-
$mol_assert_equal(dom.outerHTML, '<input value="123">');
|
|
1671
|
-
$mol_assert_equal(dom.value, '123');
|
|
1672
|
-
},
|
|
1673
|
-
'Define classes'() {
|
|
1674
|
-
const dom = $mol_jsx("div", { class: 'foo bar' });
|
|
1675
|
-
$mol_assert_equal(dom.outerHTML, '<div class="foo bar"></div>');
|
|
1676
|
-
},
|
|
1677
|
-
'Define styles'() {
|
|
1678
|
-
const dom = $mol_jsx("div", { style: { color: 'red' } });
|
|
1679
|
-
$mol_assert_equal(dom.outerHTML, '<div style="color: red;"></div>');
|
|
1680
|
-
},
|
|
1681
|
-
'Define dataset'() {
|
|
1682
|
-
const dom = $mol_jsx("div", { dataset: { foo: 'bar' } });
|
|
1683
|
-
$mol_assert_equal(dom.outerHTML, '<div data-foo="bar"></div>');
|
|
1684
|
-
},
|
|
1685
|
-
'Define attributes'() {
|
|
1686
|
-
const dom = $mol_jsx("div", { lang: "ru", hidden: true });
|
|
1687
|
-
$mol_assert_equal(dom.outerHTML, '<div lang="ru" hidden=""></div>');
|
|
1688
|
-
},
|
|
1689
|
-
'Define child nodes'() {
|
|
1690
|
-
const dom = $mol_jsx("div", null,
|
|
1691
|
-
"hello",
|
|
1692
|
-
$mol_jsx("strong", null, "world"),
|
|
1693
|
-
"!");
|
|
1694
|
-
$mol_assert_equal(dom.outerHTML, '<div>hello<strong>world</strong>!</div>');
|
|
1695
|
-
},
|
|
1696
|
-
'Function as component'() {
|
|
1697
|
-
const Button = ({ hint }, target) => {
|
|
1698
|
-
return $mol_jsx("button", { title: hint }, target());
|
|
1699
|
-
};
|
|
1700
|
-
const dom = $mol_jsx(Button, { id: "/foo", hint: "click me" }, () => 'hey!');
|
|
1701
|
-
$mol_assert_equal(dom.outerHTML, '<button title="click me" id="/foo">hey!</button>');
|
|
1702
|
-
},
|
|
1703
|
-
'Nested guid generation'() {
|
|
1704
|
-
const Foo = () => {
|
|
1705
|
-
return $mol_jsx("div", null,
|
|
1706
|
-
$mol_jsx(Bar, { id: "/bar" },
|
|
1707
|
-
$mol_jsx("img", { id: "/icon" })));
|
|
1708
|
-
};
|
|
1709
|
-
const Bar = (props, icon) => {
|
|
1710
|
-
return $mol_jsx("span", null, icon);
|
|
1711
|
-
};
|
|
1712
|
-
const dom = $mol_jsx(Foo, { id: "/foo" });
|
|
1713
|
-
$mol_assert_equal(dom.outerHTML, '<div id="/foo"><span id="/foo/bar"><img id="/foo/icon"></span></div>');
|
|
1714
|
-
},
|
|
1715
|
-
'Fail on non unique ids'() {
|
|
1716
|
-
const App = () => {
|
|
1717
|
-
return $mol_jsx("div", null,
|
|
1718
|
-
$mol_jsx("span", { id: "/bar" }),
|
|
1719
|
-
$mol_jsx("span", { id: "/bar" }));
|
|
1720
|
-
};
|
|
1721
|
-
$mol_assert_fail(() => $mol_jsx(App, { id: "/foo" }), 'JSX already has tag with id "/bar"');
|
|
1722
|
-
},
|
|
1723
|
-
});
|
|
1903
|
+
$.$mol_env = function $mol_env() {
|
|
1904
|
+
return this.process.env;
|
|
1905
|
+
};
|
|
1724
1906
|
})($ || ($ = {}));
|
|
1725
|
-
//mol/
|
|
1907
|
+
//mol/env/env.node.ts
|
|
1726
1908
|
;
|
|
1727
1909
|
"use strict";
|
|
1728
1910
|
var $;
|
|
1729
1911
|
(function ($) {
|
|
1730
|
-
|
|
1731
|
-
|
|
1732
|
-
|
|
1733
|
-
|
|
1734
|
-
|
|
1735
|
-
|
|
1736
|
-
|
|
1737
|
-
|
|
1738
|
-
|
|
1739
|
-
|
|
1740
|
-
|
|
1741
|
-
|
|
1742
|
-
|
|
1743
|
-
|
|
1744
|
-
|
|
1745
|
-
|
|
1746
|
-
|
|
1747
|
-
|
|
1748
|
-
|
|
1749
|
-
let node = guid ? $.$mol_jsx_document.getElementById(guid) : null;
|
|
1750
|
-
if (typeof Elem !== 'string') {
|
|
1751
|
-
if ('prototype' in Elem) {
|
|
1752
|
-
const view = node && node[Elem] || new Elem;
|
|
1753
|
-
Object.assign(view, props);
|
|
1754
|
-
view[Symbol.toStringTag] = guid;
|
|
1755
|
-
view.childNodes = childNodes;
|
|
1756
|
-
if (!view.ownerDocument)
|
|
1757
|
-
view.ownerDocument = $.$mol_jsx_document;
|
|
1758
|
-
node = view.valueOf();
|
|
1759
|
-
node[Elem] = view;
|
|
1760
|
-
return node;
|
|
1761
|
-
}
|
|
1762
|
-
else {
|
|
1763
|
-
const prefix = $.$mol_jsx_prefix;
|
|
1764
|
-
const booked = $.$mol_jsx_booked;
|
|
1765
|
-
try {
|
|
1766
|
-
$.$mol_jsx_prefix = guid;
|
|
1767
|
-
$.$mol_jsx_booked = new Set;
|
|
1768
|
-
return Elem(props, ...childNodes);
|
|
1769
|
-
}
|
|
1770
|
-
finally {
|
|
1771
|
-
$.$mol_jsx_prefix = prefix;
|
|
1772
|
-
$.$mol_jsx_booked = booked;
|
|
1773
|
-
}
|
|
1774
|
-
}
|
|
1775
|
-
}
|
|
1776
|
-
if (!node) {
|
|
1777
|
-
node = Elem
|
|
1778
|
-
? $.$mol_jsx_document.createElementNS(props?.xmlns ?? 'http://www.w3.org/1999/xhtml', Elem)
|
|
1779
|
-
: $.$mol_jsx_document.createDocumentFragment();
|
|
1780
|
-
}
|
|
1781
|
-
$mol_dom_render_children(node, [].concat(...childNodes));
|
|
1782
|
-
if (!Elem)
|
|
1783
|
-
return node;
|
|
1784
|
-
for (const key in props) {
|
|
1785
|
-
if (typeof props[key] === 'string') {
|
|
1786
|
-
;
|
|
1787
|
-
node.setAttribute(key, props[key]);
|
|
1788
|
-
}
|
|
1789
|
-
else if (props[key] &&
|
|
1790
|
-
typeof props[key] === 'object' &&
|
|
1791
|
-
Reflect.getPrototypeOf(props[key]) === Reflect.getPrototypeOf({})) {
|
|
1792
|
-
if (typeof node[key] === 'object') {
|
|
1793
|
-
Object.assign(node[key], props[key]);
|
|
1794
|
-
continue;
|
|
1795
|
-
}
|
|
1796
|
-
}
|
|
1797
|
-
else {
|
|
1798
|
-
node[key] = props[key];
|
|
1799
|
-
}
|
|
1800
|
-
}
|
|
1801
|
-
if (guid)
|
|
1802
|
-
node.id = guid;
|
|
1803
|
-
return node;
|
|
1912
|
+
function $mol_exec(dir, command, ...args) {
|
|
1913
|
+
let [app, ...args0] = command.split(' ');
|
|
1914
|
+
args = [...args0, ...args];
|
|
1915
|
+
this.$mol_log3_come({
|
|
1916
|
+
place: '$mol_exec',
|
|
1917
|
+
dir: $node.path.relative('', dir),
|
|
1918
|
+
message: 'Run',
|
|
1919
|
+
command: `${app} ${args.join(' ')}`,
|
|
1920
|
+
});
|
|
1921
|
+
var res = $node['child_process'].spawnSync(app, args, {
|
|
1922
|
+
cwd: $node.path.resolve(dir),
|
|
1923
|
+
shell: true,
|
|
1924
|
+
env: this.$mol_env(),
|
|
1925
|
+
});
|
|
1926
|
+
if (res.status || res.error)
|
|
1927
|
+
return $mol_fail(res.error || new Error(res.stderr.toString()));
|
|
1928
|
+
if (!res.stdout)
|
|
1929
|
+
res.stdout = Buffer.from([]);
|
|
1930
|
+
return res;
|
|
1804
1931
|
}
|
|
1805
|
-
$.$
|
|
1932
|
+
$.$mol_exec = $mol_exec;
|
|
1806
1933
|
})($ || ($ = {}));
|
|
1807
|
-
//mol/
|
|
1934
|
+
//mol/exec/exec.node.ts
|
|
1808
1935
|
;
|
|
1809
1936
|
"use strict";
|
|
1810
1937
|
var $;
|
|
1811
1938
|
(function ($) {
|
|
1812
|
-
$
|
|
1813
|
-
|
|
1814
|
-
|
|
1815
|
-
|
|
1816
|
-
|
|
1817
|
-
$
|
|
1818
|
-
|
|
1819
|
-
|
|
1820
|
-
|
|
1821
|
-
$mol_assert_ok($mol_compare_deep(Number.NaN, Number.NaN));
|
|
1822
|
-
$mol_assert_not($mol_compare_deep(1, 2));
|
|
1823
|
-
$mol_assert_ok($mol_compare_deep(Object(1), Object(1)));
|
|
1824
|
-
$mol_assert_not($mol_compare_deep(Object(1), Object(2)));
|
|
1825
|
-
},
|
|
1826
|
-
'POJO'() {
|
|
1827
|
-
$mol_assert_ok($mol_compare_deep({}, {}));
|
|
1828
|
-
$mol_assert_not($mol_compare_deep({ a: 1 }, { b: 2 }));
|
|
1829
|
-
$mol_assert_not($mol_compare_deep({ a: 1 }, { a: 2 }));
|
|
1830
|
-
$mol_assert_not($mol_compare_deep({}, { a: undefined }));
|
|
1831
|
-
$mol_assert_ok($mol_compare_deep({ a: 1, b: 2 }, { b: 2, a: 1 }));
|
|
1832
|
-
$mol_assert_ok($mol_compare_deep({ a: { b: 1 } }, { a: { b: 1 } }));
|
|
1833
|
-
},
|
|
1834
|
-
'Array'() {
|
|
1835
|
-
$mol_assert_ok($mol_compare_deep([], []));
|
|
1836
|
-
$mol_assert_ok($mol_compare_deep([1, [2]], [1, [2]]));
|
|
1837
|
-
$mol_assert_not($mol_compare_deep([1, 2], [1, 3]));
|
|
1838
|
-
$mol_assert_not($mol_compare_deep([1, 2,], [1, 3, undefined]));
|
|
1839
|
-
},
|
|
1840
|
-
'Non POJO are different'() {
|
|
1841
|
-
class Thing extends Object {
|
|
1939
|
+
class $mol_wire_log extends $mol_object2 {
|
|
1940
|
+
static watch(task) {
|
|
1941
|
+
return task;
|
|
1942
|
+
}
|
|
1943
|
+
static track(fiber) {
|
|
1944
|
+
const prev = $mol_wire_probe(() => this.track(fiber));
|
|
1945
|
+
let next;
|
|
1946
|
+
try {
|
|
1947
|
+
next = fiber.sync();
|
|
1842
1948
|
}
|
|
1843
|
-
|
|
1844
|
-
|
|
1845
|
-
|
|
1846
|
-
|
|
1847
|
-
|
|
1848
|
-
const a = { foo: {} };
|
|
1849
|
-
a['self'] = a;
|
|
1850
|
-
const b = { foo: {} };
|
|
1851
|
-
b['self'] = b;
|
|
1852
|
-
$mol_assert_ok($mol_compare_deep(a, b));
|
|
1853
|
-
},
|
|
1854
|
-
'Date'() {
|
|
1855
|
-
$mol_assert_ok($mol_compare_deep(new Date(12345), new Date(12345)));
|
|
1856
|
-
$mol_assert_not($mol_compare_deep(new Date(12345), new Date(12346)));
|
|
1857
|
-
},
|
|
1858
|
-
'RegExp'() {
|
|
1859
|
-
$mol_assert_ok($mol_compare_deep(/\x22/mig, /\x22/mig));
|
|
1860
|
-
$mol_assert_not($mol_compare_deep(/\x22/mig, /\x21/mig));
|
|
1861
|
-
$mol_assert_not($mol_compare_deep(/\x22/mig, /\x22/mg));
|
|
1862
|
-
},
|
|
1863
|
-
'Error'() {
|
|
1864
|
-
$mol_assert_not($mol_compare_deep(new Error('xxx'), new Error('xxx')));
|
|
1865
|
-
const fail = (message) => new Error(message);
|
|
1866
|
-
$mol_assert_ok($mol_compare_deep(...['xxx', 'xxx'].map(msg => new Error(msg))));
|
|
1867
|
-
$mol_assert_not($mol_compare_deep(...['xxx', 'yyy'].map(msg => new Error(msg))));
|
|
1868
|
-
},
|
|
1869
|
-
'Map'() {
|
|
1870
|
-
$mol_assert_ok($mol_compare_deep(new Map, new Map));
|
|
1871
|
-
$mol_assert_ok($mol_compare_deep(new Map([[1, [2]]]), new Map([[1, [2]]])));
|
|
1872
|
-
$mol_assert_not($mol_compare_deep(new Map([[1, 2]]), new Map([[1, 3]])));
|
|
1873
|
-
$mol_assert_not($mol_compare_deep(new Map([[[1], 2]]), new Map([[[1], 2]])));
|
|
1874
|
-
},
|
|
1875
|
-
'Set'() {
|
|
1876
|
-
$mol_assert_ok($mol_compare_deep(new Set, new Set));
|
|
1877
|
-
$mol_assert_ok($mol_compare_deep(new Set([1, [2]]), new Set([1, [2]])));
|
|
1878
|
-
$mol_assert_not($mol_compare_deep(new Set([1]), new Set([2])));
|
|
1879
|
-
},
|
|
1880
|
-
'Uint8Array'() {
|
|
1881
|
-
$mol_assert_ok($mol_compare_deep(new Uint8Array, new Uint8Array));
|
|
1882
|
-
$mol_assert_ok($mol_compare_deep(new Uint8Array([0]), new Uint8Array([0])));
|
|
1883
|
-
$mol_assert_not($mol_compare_deep(new Uint8Array([0]), new Uint8Array([1])));
|
|
1884
|
-
},
|
|
1885
|
-
'Custom comparator'() {
|
|
1886
|
-
class User {
|
|
1887
|
-
name;
|
|
1888
|
-
rand;
|
|
1889
|
-
constructor(name, rand = Math.random()) {
|
|
1890
|
-
this.name = name;
|
|
1891
|
-
this.rand = rand;
|
|
1949
|
+
finally {
|
|
1950
|
+
for (const pub of fiber.pub_list) {
|
|
1951
|
+
if (pub instanceof $mol_wire_fiber) {
|
|
1952
|
+
this.track(pub);
|
|
1953
|
+
}
|
|
1892
1954
|
}
|
|
1893
|
-
|
|
1894
|
-
|
|
1955
|
+
}
|
|
1956
|
+
if (prev !== undefined && !$mol_compare_deep(prev, next)) {
|
|
1957
|
+
this.$.$mol_log3_rise({
|
|
1958
|
+
message: 'Changed',
|
|
1959
|
+
place: fiber,
|
|
1960
|
+
});
|
|
1961
|
+
}
|
|
1962
|
+
return next;
|
|
1963
|
+
}
|
|
1964
|
+
static active() {
|
|
1965
|
+
try {
|
|
1966
|
+
this.watch()?.();
|
|
1967
|
+
}
|
|
1968
|
+
finally {
|
|
1969
|
+
for (const pub of $mol_wire_auto().pub_list) {
|
|
1970
|
+
if (pub instanceof $mol_wire_fiber) {
|
|
1971
|
+
this.track(pub);
|
|
1972
|
+
}
|
|
1895
1973
|
}
|
|
1896
1974
|
}
|
|
1897
|
-
|
|
1898
|
-
$mol_assert_not($mol_compare_deep(new User('Jin'), new User('John')));
|
|
1899
|
-
},
|
|
1900
|
-
});
|
|
1901
|
-
})($ || ($ = {}));
|
|
1902
|
-
//mol/compare/deep/deep.test.tsx
|
|
1903
|
-
;
|
|
1904
|
-
"use strict";
|
|
1905
|
-
var $;
|
|
1906
|
-
(function ($) {
|
|
1907
|
-
function $mol_dom_serialize(node) {
|
|
1908
|
-
const serializer = new $mol_dom_context.XMLSerializer;
|
|
1909
|
-
return serializer.serializeToString(node);
|
|
1975
|
+
}
|
|
1910
1976
|
}
|
|
1911
|
-
|
|
1977
|
+
__decorate([
|
|
1978
|
+
$mol_mem
|
|
1979
|
+
], $mol_wire_log, "watch", null);
|
|
1980
|
+
__decorate([
|
|
1981
|
+
$mol_mem_key
|
|
1982
|
+
], $mol_wire_log, "track", null);
|
|
1983
|
+
__decorate([
|
|
1984
|
+
$mol_mem
|
|
1985
|
+
], $mol_wire_log, "active", null);
|
|
1986
|
+
$.$mol_wire_log = $mol_wire_log;
|
|
1912
1987
|
})($ || ($ = {}));
|
|
1913
|
-
//mol/
|
|
1988
|
+
//mol/wire/log/log.ts
|
|
1914
1989
|
;
|
|
1915
1990
|
"use strict";
|
|
1916
1991
|
var $;
|
|
1917
1992
|
(function ($) {
|
|
1918
|
-
$
|
|
1919
|
-
|
|
1920
|
-
|
|
1921
|
-
|
|
1922
|
-
'must be true'() {
|
|
1923
|
-
$mol_assert_ok(1);
|
|
1924
|
-
},
|
|
1925
|
-
'two must be equal'() {
|
|
1926
|
-
$mol_assert_equal(2, 2);
|
|
1927
|
-
},
|
|
1928
|
-
'three must be equal'() {
|
|
1929
|
-
$mol_assert_equal(2, 2, 2);
|
|
1930
|
-
},
|
|
1931
|
-
'two must be unique'() {
|
|
1932
|
-
$mol_assert_unique([3], [3]);
|
|
1933
|
-
},
|
|
1934
|
-
'three must be unique'() {
|
|
1935
|
-
$mol_assert_unique([3], [3], [3]);
|
|
1936
|
-
},
|
|
1937
|
-
'two must be alike'() {
|
|
1938
|
-
$mol_assert_like([3], [3]);
|
|
1939
|
-
},
|
|
1940
|
-
'three must be alike'() {
|
|
1941
|
-
$mol_assert_like([3], [3], [3]);
|
|
1942
|
-
},
|
|
1943
|
-
});
|
|
1993
|
+
function $mol_test_complete() {
|
|
1994
|
+
process.exit(0);
|
|
1995
|
+
}
|
|
1996
|
+
$.$mol_test_complete = $mol_test_complete;
|
|
1944
1997
|
})($ || ($ = {}));
|
|
1945
|
-
//mol/
|
|
1998
|
+
//mol/test/test.node.test.ts
|
|
1946
1999
|
;
|
|
1947
2000
|
"use strict";
|
|
1948
2001
|
var $;
|
|
1949
|
-
(function ($) {
|
|
1950
|
-
function $
|
|
1951
|
-
|
|
1952
|
-
|
|
1953
|
-
|
|
1954
|
-
|
|
1955
|
-
$.$mol_assert_ok = $mol_assert_ok;
|
|
1956
|
-
function $mol_assert_not(value) {
|
|
1957
|
-
if (!value)
|
|
1958
|
-
return;
|
|
1959
|
-
$mol_fail(new Error(`${value} ≠ false`));
|
|
1960
|
-
}
|
|
1961
|
-
$.$mol_assert_not = $mol_assert_not;
|
|
1962
|
-
function $mol_assert_fail(handler, ErrorRight) {
|
|
1963
|
-
const fail = $.$mol_fail;
|
|
1964
|
-
try {
|
|
1965
|
-
$.$mol_fail = $.$mol_fail_hidden;
|
|
1966
|
-
handler();
|
|
1967
|
-
}
|
|
1968
|
-
catch (error) {
|
|
1969
|
-
if (!ErrorRight)
|
|
1970
|
-
return error;
|
|
1971
|
-
$.$mol_fail = fail;
|
|
1972
|
-
if (typeof ErrorRight === 'string') {
|
|
1973
|
-
$mol_assert_equal(error.message, ErrorRight);
|
|
1974
|
-
}
|
|
1975
|
-
else {
|
|
1976
|
-
$mol_assert_ok(error instanceof ErrorRight);
|
|
1977
|
-
}
|
|
1978
|
-
return error;
|
|
1979
|
-
}
|
|
1980
|
-
finally {
|
|
1981
|
-
$.$mol_fail = fail;
|
|
2002
|
+
(function ($_1) {
|
|
2003
|
+
function $mol_test(set) {
|
|
2004
|
+
for (let name in set) {
|
|
2005
|
+
const code = set[name];
|
|
2006
|
+
const test = (typeof code === 'string') ? new Function('', code) : code;
|
|
2007
|
+
$_1.$mol_test_all.push(test);
|
|
1982
2008
|
}
|
|
1983
|
-
$
|
|
2009
|
+
$mol_test_schedule();
|
|
1984
2010
|
}
|
|
1985
|
-
|
|
1986
|
-
|
|
1987
|
-
|
|
1988
|
-
|
|
1989
|
-
|
|
1990
|
-
|
|
1991
|
-
|
|
1992
|
-
|
|
1993
|
-
|
|
1994
|
-
|
|
2011
|
+
$_1.$mol_test = $mol_test;
|
|
2012
|
+
$_1.$mol_test_mocks = [];
|
|
2013
|
+
$_1.$mol_test_all = [];
|
|
2014
|
+
async function $mol_test_run() {
|
|
2015
|
+
for (var test of $_1.$mol_test_all) {
|
|
2016
|
+
let context = Object.create($$);
|
|
2017
|
+
for (let mock of $_1.$mol_test_mocks)
|
|
2018
|
+
await mock(context);
|
|
2019
|
+
const res = test(context);
|
|
2020
|
+
if (res instanceof Promise) {
|
|
2021
|
+
await new Promise((done, fail) => {
|
|
2022
|
+
res.then(done, fail);
|
|
2023
|
+
setTimeout(() => fail(new Error('Test timeout: ' + test.name)), 1000);
|
|
2024
|
+
});
|
|
1995
2025
|
}
|
|
1996
2026
|
}
|
|
2027
|
+
$$.$mol_log3_done({
|
|
2028
|
+
place: '$mol_test',
|
|
2029
|
+
message: 'All tests passed',
|
|
2030
|
+
count: $_1.$mol_test_all.length,
|
|
2031
|
+
});
|
|
1997
2032
|
}
|
|
1998
|
-
|
|
1999
|
-
|
|
2000
|
-
|
|
2001
|
-
|
|
2002
|
-
|
|
2003
|
-
|
|
2004
|
-
|
|
2005
|
-
|
|
2006
|
-
|
|
2033
|
+
$_1.$mol_test_run = $mol_test_run;
|
|
2034
|
+
let scheduled = false;
|
|
2035
|
+
function $mol_test_schedule() {
|
|
2036
|
+
if (scheduled)
|
|
2037
|
+
return;
|
|
2038
|
+
scheduled = true;
|
|
2039
|
+
setTimeout(async () => {
|
|
2040
|
+
scheduled = false;
|
|
2041
|
+
try {
|
|
2042
|
+
await $mol_test_run();
|
|
2007
2043
|
}
|
|
2008
|
-
|
|
2009
|
-
|
|
2010
|
-
$.$mol_assert_unique = $mol_assert_unique;
|
|
2011
|
-
function $mol_assert_like(head, ...tail) {
|
|
2012
|
-
for (let [index, value] of Object.entries(tail)) {
|
|
2013
|
-
if (!$mol_compare_deep(value, head)) {
|
|
2014
|
-
const print = (val) => {
|
|
2015
|
-
if (!val)
|
|
2016
|
-
return val;
|
|
2017
|
-
if (typeof val !== 'object')
|
|
2018
|
-
return val;
|
|
2019
|
-
if ('outerHTML' in val)
|
|
2020
|
-
return val.outerHTML;
|
|
2021
|
-
try {
|
|
2022
|
-
return JSON.stringify(val);
|
|
2023
|
-
}
|
|
2024
|
-
catch (error) {
|
|
2025
|
-
console.error(error);
|
|
2026
|
-
return val;
|
|
2027
|
-
}
|
|
2028
|
-
};
|
|
2029
|
-
return $mol_fail(new Error(`Not like (1:${+index + 2})\n${print(head)}\n---\n${print(value)}`));
|
|
2044
|
+
finally {
|
|
2045
|
+
$$.$mol_test_complete();
|
|
2030
2046
|
}
|
|
2031
|
-
}
|
|
2032
|
-
}
|
|
2033
|
-
$.$mol_assert_like = $mol_assert_like;
|
|
2034
|
-
function $mol_assert_dom(left, right) {
|
|
2035
|
-
$mol_assert_equal($mol_dom_serialize(left), $mol_dom_serialize(right));
|
|
2036
|
-
}
|
|
2037
|
-
$.$mol_assert_dom = $mol_assert_dom;
|
|
2038
|
-
})($ || ($ = {}));
|
|
2039
|
-
//mol/assert/assert.ts
|
|
2040
|
-
;
|
|
2041
|
-
"use strict";
|
|
2042
|
-
var $;
|
|
2043
|
-
(function ($) {
|
|
2044
|
-
function $mol_log3_area_lazy(event) {
|
|
2045
|
-
const self = this;
|
|
2046
|
-
const stack = self.$mol_log3_stack;
|
|
2047
|
-
const deep = stack.length;
|
|
2048
|
-
let logged = false;
|
|
2049
|
-
stack.push(() => {
|
|
2050
|
-
logged = true;
|
|
2051
|
-
self.$mol_log3_area.call(self, event);
|
|
2052
|
-
});
|
|
2053
|
-
return () => {
|
|
2054
|
-
if (logged)
|
|
2055
|
-
self.console.groupEnd();
|
|
2056
|
-
if (stack.length > deep)
|
|
2057
|
-
stack.length = deep;
|
|
2058
|
-
};
|
|
2047
|
+
}, 0);
|
|
2059
2048
|
}
|
|
2060
|
-
|
|
2061
|
-
|
|
2062
|
-
|
|
2063
|
-
|
|
2064
|
-
;
|
|
2065
|
-
|
|
2066
|
-
|
|
2067
|
-
(function (
|
|
2068
|
-
|
|
2069
|
-
|
|
2070
|
-
|
|
2071
|
-
|
|
2072
|
-
|
|
2073
|
-
|
|
2074
|
-
|
|
2075
|
-
|
|
2049
|
+
$_1.$mol_test_schedule = $mol_test_schedule;
|
|
2050
|
+
$_1.$mol_test_mocks.push(context => {
|
|
2051
|
+
let seed = 0;
|
|
2052
|
+
context.Math = Object.create(Math);
|
|
2053
|
+
context.Math.random = () => Math.sin(seed++);
|
|
2054
|
+
const forbidden = ['XMLHttpRequest', 'fetch'];
|
|
2055
|
+
for (let api of forbidden) {
|
|
2056
|
+
context[api] = new Proxy(function () { }, {
|
|
2057
|
+
get() {
|
|
2058
|
+
$mol_fail_hidden(new Error(`${api} is forbidden in tests`));
|
|
2059
|
+
},
|
|
2060
|
+
apply() {
|
|
2061
|
+
$mol_fail_hidden(new Error(`${api} is forbidden in tests`));
|
|
2062
|
+
},
|
|
2063
|
+
});
|
|
2064
|
+
}
|
|
2065
|
+
});
|
|
2066
|
+
$mol_test({
|
|
2067
|
+
'mocked Math.random'($) {
|
|
2068
|
+
console.assert($.Math.random() === 0);
|
|
2069
|
+
console.assert($.Math.random() === Math.sin(1));
|
|
2070
|
+
},
|
|
2071
|
+
'forbidden XMLHttpRequest'($) {
|
|
2072
|
+
try {
|
|
2073
|
+
console.assert(void new $.XMLHttpRequest);
|
|
2076
2074
|
}
|
|
2077
|
-
|
|
2078
|
-
|
|
2079
|
-
|
|
2080
|
-
|
|
2081
|
-
|
|
2082
|
-
|
|
2083
|
-
|
|
2084
|
-
|
|
2085
|
-
|
|
2086
|
-
|
|
2087
|
-
|
|
2088
|
-
|
|
2089
|
-
$.$mol_log3_area = $mol_log3_node_make('log', 'stdout', 'area', 'cyan');
|
|
2090
|
-
})($ || ($ = {}));
|
|
2091
|
-
//mol/log3/log3.node.ts
|
|
2092
|
-
;
|
|
2093
|
-
"use strict";
|
|
2094
|
-
var $;
|
|
2095
|
-
(function ($_1) {
|
|
2096
|
-
$mol_test_mocks.push($ => {
|
|
2097
|
-
$.$mol_log3_come = () => { };
|
|
2098
|
-
$.$mol_log3_done = () => { };
|
|
2099
|
-
$.$mol_log3_fail = () => { };
|
|
2100
|
-
$.$mol_log3_warn = () => { };
|
|
2101
|
-
$.$mol_log3_rise = () => { };
|
|
2102
|
-
$.$mol_log3_area = () => () => { };
|
|
2075
|
+
catch (error) {
|
|
2076
|
+
console.assert(error.message === 'XMLHttpRequest is forbidden in tests');
|
|
2077
|
+
}
|
|
2078
|
+
},
|
|
2079
|
+
'forbidden fetch'($) {
|
|
2080
|
+
try {
|
|
2081
|
+
console.assert(void $.fetch(''));
|
|
2082
|
+
}
|
|
2083
|
+
catch (error) {
|
|
2084
|
+
console.assert(error.message === 'fetch is forbidden in tests');
|
|
2085
|
+
}
|
|
2086
|
+
},
|
|
2103
2087
|
});
|
|
2104
2088
|
})($ || ($ = {}));
|
|
2105
|
-
//mol/
|
|
2089
|
+
//mol/test/test.test.ts
|
|
2106
2090
|
;
|
|
2107
2091
|
"use strict";
|
|
2108
2092
|
var $;
|
|
2109
2093
|
(function ($) {
|
|
2110
|
-
function $mol_env() {
|
|
2111
|
-
return {};
|
|
2112
|
-
}
|
|
2113
|
-
$.$mol_env = $mol_env;
|
|
2114
2094
|
})($ || ($ = {}));
|
|
2115
|
-
//mol/
|
|
2095
|
+
//mol/dom/context/context.ts
|
|
2116
2096
|
;
|
|
2117
2097
|
"use strict";
|
|
2118
2098
|
var $;
|
|
2119
2099
|
(function ($) {
|
|
2120
|
-
$.$
|
|
2121
|
-
return this.process.env;
|
|
2122
|
-
};
|
|
2100
|
+
$.$mol_dom_context = new $node.jsdom.JSDOM('', { url: 'https://localhost/' }).window;
|
|
2123
2101
|
})($ || ($ = {}));
|
|
2124
|
-
//mol/
|
|
2102
|
+
//mol/dom/context/context.node.ts
|
|
2125
2103
|
;
|
|
2126
2104
|
"use strict";
|
|
2127
2105
|
var $;
|
|
2128
2106
|
(function ($) {
|
|
2129
|
-
function $
|
|
2130
|
-
|
|
2131
|
-
|
|
2132
|
-
|
|
2133
|
-
|
|
2134
|
-
|
|
2135
|
-
|
|
2136
|
-
|
|
2137
|
-
|
|
2138
|
-
|
|
2139
|
-
|
|
2140
|
-
|
|
2141
|
-
|
|
2142
|
-
|
|
2143
|
-
|
|
2144
|
-
|
|
2145
|
-
|
|
2146
|
-
|
|
2147
|
-
|
|
2148
|
-
|
|
2149
|
-
|
|
2150
|
-
|
|
2151
|
-
|
|
2107
|
+
function $mol_dom_render_children(el, childNodes) {
|
|
2108
|
+
const node_set = new Set(childNodes);
|
|
2109
|
+
let nextNode = el.firstChild;
|
|
2110
|
+
for (let view of childNodes) {
|
|
2111
|
+
if (view == null)
|
|
2112
|
+
continue;
|
|
2113
|
+
if (view instanceof $mol_dom_context.Node) {
|
|
2114
|
+
while (true) {
|
|
2115
|
+
if (!nextNode) {
|
|
2116
|
+
el.appendChild(view);
|
|
2117
|
+
break;
|
|
2118
|
+
}
|
|
2119
|
+
if (nextNode == view) {
|
|
2120
|
+
nextNode = nextNode.nextSibling;
|
|
2121
|
+
break;
|
|
2122
|
+
}
|
|
2123
|
+
else {
|
|
2124
|
+
if (node_set.has(nextNode)) {
|
|
2125
|
+
el.insertBefore(view, nextNode);
|
|
2126
|
+
break;
|
|
2127
|
+
}
|
|
2128
|
+
else {
|
|
2129
|
+
const nn = nextNode.nextSibling;
|
|
2130
|
+
el.removeChild(nextNode);
|
|
2131
|
+
nextNode = nn;
|
|
2132
|
+
}
|
|
2133
|
+
}
|
|
2134
|
+
}
|
|
2135
|
+
}
|
|
2136
|
+
else {
|
|
2137
|
+
if (nextNode && nextNode.nodeName === '#text') {
|
|
2138
|
+
const str = String(view);
|
|
2139
|
+
if (nextNode.nodeValue !== str)
|
|
2140
|
+
nextNode.nodeValue = str;
|
|
2141
|
+
nextNode = nextNode.nextSibling;
|
|
2142
|
+
}
|
|
2143
|
+
else {
|
|
2144
|
+
const textNode = $mol_dom_context.document.createTextNode(String(view));
|
|
2145
|
+
el.insertBefore(textNode, nextNode);
|
|
2146
|
+
}
|
|
2147
|
+
}
|
|
2148
|
+
}
|
|
2149
|
+
while (nextNode) {
|
|
2150
|
+
const currNode = nextNode;
|
|
2151
|
+
nextNode = currNode.nextSibling;
|
|
2152
|
+
el.removeChild(currNode);
|
|
2153
|
+
}
|
|
2154
|
+
}
|
|
2155
|
+
$.$mol_dom_render_children = $mol_dom_render_children;
|
|
2156
|
+
})($ || ($ = {}));
|
|
2157
|
+
//mol/dom/render/children/children.ts
|
|
2158
|
+
;
|
|
2159
|
+
"use strict";
|
|
2160
|
+
//mol/type/error/error.ts
|
|
2161
|
+
;
|
|
2162
|
+
"use strict";
|
|
2163
|
+
//mol/type/assert/assert.test.ts
|
|
2164
|
+
;
|
|
2165
|
+
"use strict";
|
|
2166
|
+
//mol/type/assert/assert.ts
|
|
2167
|
+
;
|
|
2168
|
+
"use strict";
|
|
2169
|
+
//mol/type/equals/equals.test.ts
|
|
2170
|
+
;
|
|
2171
|
+
"use strict";
|
|
2172
|
+
//mol/type/equals/equals.ts
|
|
2173
|
+
;
|
|
2174
|
+
"use strict";
|
|
2175
|
+
//mol/type/partial/deep/deep.test.ts
|
|
2176
|
+
;
|
|
2177
|
+
"use strict";
|
|
2178
|
+
//mol/type/partial/deep/deep.ts
|
|
2152
2179
|
;
|
|
2153
2180
|
"use strict";
|
|
2154
2181
|
var $;
|
|
2155
2182
|
(function ($) {
|
|
2156
2183
|
$mol_test({
|
|
2157
|
-
'
|
|
2158
|
-
|
|
2159
|
-
$mol_assert_equal(proxy.foo, 777);
|
|
2184
|
+
'Make empty div'() {
|
|
2185
|
+
$mol_assert_equal(($mol_jsx("div", null)).outerHTML, '<div></div>');
|
|
2160
2186
|
},
|
|
2161
|
-
'
|
|
2162
|
-
const
|
|
2163
|
-
$mol_assert_equal('
|
|
2187
|
+
'Define native field'() {
|
|
2188
|
+
const dom = $mol_jsx("input", { value: '123' });
|
|
2189
|
+
$mol_assert_equal(dom.outerHTML, '<input value="123">');
|
|
2190
|
+
$mol_assert_equal(dom.value, '123');
|
|
2164
2191
|
},
|
|
2165
|
-
'
|
|
2166
|
-
const
|
|
2167
|
-
|
|
2168
|
-
proxy.foo = 123;
|
|
2169
|
-
$mol_assert_equal(target.foo, 123);
|
|
2192
|
+
'Define classes'() {
|
|
2193
|
+
const dom = $mol_jsx("div", { class: 'foo bar' });
|
|
2194
|
+
$mol_assert_equal(dom.outerHTML, '<div class="foo bar"></div>');
|
|
2170
2195
|
},
|
|
2171
|
-
'
|
|
2172
|
-
const
|
|
2173
|
-
$
|
|
2174
|
-
value: 777,
|
|
2175
|
-
writable: true,
|
|
2176
|
-
enumerable: true,
|
|
2177
|
-
configurable: true,
|
|
2178
|
-
});
|
|
2196
|
+
'Define styles'() {
|
|
2197
|
+
const dom = $mol_jsx("div", { style: { color: 'red' } });
|
|
2198
|
+
$mol_assert_equal(dom.outerHTML, '<div style="color: red;"></div>');
|
|
2179
2199
|
},
|
|
2180
|
-
'
|
|
2181
|
-
const
|
|
2182
|
-
$
|
|
2200
|
+
'Define dataset'() {
|
|
2201
|
+
const dom = $mol_jsx("div", { dataset: { foo: 'bar' } });
|
|
2202
|
+
$mol_assert_equal(dom.outerHTML, '<div data-foo="bar"></div>');
|
|
2183
2203
|
},
|
|
2184
|
-
'
|
|
2185
|
-
|
|
2186
|
-
|
|
2187
|
-
const proxy = $mol_delegate({}, () => new Foo);
|
|
2188
|
-
$mol_assert_equal(Object.getPrototypeOf(proxy), Foo.prototype);
|
|
2204
|
+
'Define attributes'() {
|
|
2205
|
+
const dom = $mol_jsx("div", { lang: "ru", hidden: true });
|
|
2206
|
+
$mol_assert_equal(dom.outerHTML, '<div lang="ru" hidden=""></div>');
|
|
2189
2207
|
},
|
|
2190
|
-
'
|
|
2191
|
-
|
|
2192
|
-
|
|
2193
|
-
|
|
2194
|
-
|
|
2195
|
-
|
|
2196
|
-
$mol_assert_equal(Object.getPrototypeOf(target), Foo.prototype);
|
|
2208
|
+
'Define child nodes'() {
|
|
2209
|
+
const dom = $mol_jsx("div", null,
|
|
2210
|
+
"hello",
|
|
2211
|
+
$mol_jsx("strong", null, "world"),
|
|
2212
|
+
"!");
|
|
2213
|
+
$mol_assert_equal(dom.outerHTML, '<div>hello<strong>world</strong>!</div>');
|
|
2197
2214
|
},
|
|
2198
|
-
'
|
|
2199
|
-
|
|
2200
|
-
|
|
2201
|
-
|
|
2202
|
-
$
|
|
2203
|
-
$
|
|
2215
|
+
'Function as component'() {
|
|
2216
|
+
const Button = ({ hint }, target) => {
|
|
2217
|
+
return $mol_jsx("button", { title: hint }, target());
|
|
2218
|
+
};
|
|
2219
|
+
const dom = $mol_jsx(Button, { id: "/foo", hint: "click me" }, () => 'hey!');
|
|
2220
|
+
$mol_assert_equal(dom.outerHTML, '<button title="click me" id="/foo">hey!</button>');
|
|
2204
2221
|
},
|
|
2205
|
-
'
|
|
2206
|
-
|
|
2207
|
-
|
|
2208
|
-
|
|
2209
|
-
|
|
2210
|
-
|
|
2222
|
+
'Nested guid generation'() {
|
|
2223
|
+
const Foo = () => {
|
|
2224
|
+
return $mol_jsx("div", null,
|
|
2225
|
+
$mol_jsx(Bar, { id: "/bar" },
|
|
2226
|
+
$mol_jsx("img", { id: "/icon" })));
|
|
2227
|
+
};
|
|
2228
|
+
const Bar = (props, icon) => {
|
|
2229
|
+
return $mol_jsx("span", null, icon);
|
|
2230
|
+
};
|
|
2231
|
+
const dom = $mol_jsx(Foo, { id: "/foo" });
|
|
2232
|
+
$mol_assert_equal(dom.outerHTML, '<div id="/foo"><span id="/foo/bar"><img id="/foo/icon"></span></div>');
|
|
2233
|
+
},
|
|
2234
|
+
'Fail on non unique ids'() {
|
|
2235
|
+
const App = () => {
|
|
2236
|
+
return $mol_jsx("div", null,
|
|
2237
|
+
$mol_jsx("span", { id: "/bar" }),
|
|
2238
|
+
$mol_jsx("span", { id: "/bar" }));
|
|
2239
|
+
};
|
|
2240
|
+
$mol_assert_fail(() => $mol_jsx(App, { id: "/foo" }), 'JSX already has tag with id "/bar"');
|
|
2211
2241
|
},
|
|
2212
2242
|
});
|
|
2213
2243
|
})($ || ($ = {}));
|
|
2214
|
-
//mol/
|
|
2215
|
-
;
|
|
2216
|
-
"use strict";
|
|
2217
|
-
//mol/type/writable/writable.test.ts
|
|
2244
|
+
//mol/jsx/jsx.test.tsx
|
|
2218
2245
|
;
|
|
2219
2246
|
"use strict";
|
|
2220
2247
|
var $;
|
|
2221
2248
|
(function ($) {
|
|
2222
|
-
$.$
|
|
2223
|
-
|
|
2224
|
-
|
|
2225
|
-
|
|
2226
|
-
|
|
2227
|
-
|
|
2228
|
-
|
|
2229
|
-
|
|
2230
|
-
|
|
2231
|
-
|
|
2232
|
-
|
|
2233
|
-
|
|
2234
|
-
|
|
2235
|
-
|
|
2236
|
-
|
|
2237
|
-
|
|
2249
|
+
$.$mol_jsx_prefix = '';
|
|
2250
|
+
$.$mol_jsx_booked = null;
|
|
2251
|
+
$.$mol_jsx_document = {
|
|
2252
|
+
getElementById: () => null,
|
|
2253
|
+
createElementNS: (space, name) => $mol_dom_context.document.createElementNS(space, name),
|
|
2254
|
+
createDocumentFragment: () => $mol_dom_context.document.createDocumentFragment(),
|
|
2255
|
+
};
|
|
2256
|
+
$.$mol_jsx_frag = '';
|
|
2257
|
+
function $mol_jsx(Elem, props, ...childNodes) {
|
|
2258
|
+
const id = props && props.id || '';
|
|
2259
|
+
if (Elem && $.$mol_jsx_booked) {
|
|
2260
|
+
if ($.$mol_jsx_booked.has(id)) {
|
|
2261
|
+
$mol_fail(new Error(`JSX already has tag with id ${JSON.stringify(id)}`));
|
|
2262
|
+
}
|
|
2263
|
+
else {
|
|
2264
|
+
$.$mol_jsx_booked.add(id);
|
|
2265
|
+
}
|
|
2238
2266
|
}
|
|
2239
|
-
|
|
2240
|
-
|
|
2241
|
-
|
|
2242
|
-
|
|
2267
|
+
const guid = $.$mol_jsx_prefix + id;
|
|
2268
|
+
let node = guid ? $.$mol_jsx_document.getElementById(guid) : null;
|
|
2269
|
+
if (typeof Elem !== 'string') {
|
|
2270
|
+
if ('prototype' in Elem) {
|
|
2271
|
+
const view = node && node[Elem] || new Elem;
|
|
2272
|
+
Object.assign(view, props);
|
|
2273
|
+
view[Symbol.toStringTag] = guid;
|
|
2274
|
+
view.childNodes = childNodes;
|
|
2275
|
+
if (!view.ownerDocument)
|
|
2276
|
+
view.ownerDocument = $.$mol_jsx_document;
|
|
2277
|
+
node = view.valueOf();
|
|
2278
|
+
node[Elem] = view;
|
|
2279
|
+
return node;
|
|
2280
|
+
}
|
|
2281
|
+
else {
|
|
2282
|
+
const prefix = $.$mol_jsx_prefix;
|
|
2283
|
+
const booked = $.$mol_jsx_booked;
|
|
2284
|
+
try {
|
|
2285
|
+
$.$mol_jsx_prefix = guid;
|
|
2286
|
+
$.$mol_jsx_booked = new Set;
|
|
2287
|
+
return Elem(props, ...childNodes);
|
|
2288
|
+
}
|
|
2289
|
+
finally {
|
|
2290
|
+
$.$mol_jsx_prefix = prefix;
|
|
2291
|
+
$.$mol_jsx_booked = booked;
|
|
2292
|
+
}
|
|
2293
|
+
}
|
|
2243
2294
|
}
|
|
2244
|
-
|
|
2245
|
-
|
|
2246
|
-
|
|
2247
|
-
|
|
2248
|
-
constructor(delay, task) {
|
|
2249
|
-
super(task);
|
|
2250
|
-
this.delay = delay;
|
|
2295
|
+
if (!node) {
|
|
2296
|
+
node = Elem
|
|
2297
|
+
? $.$mol_jsx_document.createElementNS(props?.xmlns ?? 'http://www.w3.org/1999/xhtml', Elem)
|
|
2298
|
+
: $.$mol_jsx_document.createDocumentFragment();
|
|
2251
2299
|
}
|
|
2252
|
-
|
|
2253
|
-
|
|
2254
|
-
|
|
2255
|
-
|
|
2256
|
-
|
|
2257
|
-
|
|
2258
|
-
|
|
2259
|
-
|
|
2260
|
-
|
|
2261
|
-
|
|
2262
|
-
|
|
2263
|
-
|
|
2264
|
-
|
|
2265
|
-
|
|
2266
|
-
static send(next) {
|
|
2267
|
-
$mol_wire_sync(this.first).push(next);
|
|
2268
|
-
this.$.$mol_wait_timeout(0);
|
|
2269
|
-
this.last.push(next);
|
|
2300
|
+
$mol_dom_render_children(node, [].concat(...childNodes));
|
|
2301
|
+
if (!Elem)
|
|
2302
|
+
return node;
|
|
2303
|
+
for (const key in props) {
|
|
2304
|
+
if (typeof props[key] === 'string') {
|
|
2305
|
+
;
|
|
2306
|
+
node.setAttribute(key, props[key]);
|
|
2307
|
+
}
|
|
2308
|
+
else if (props[key] &&
|
|
2309
|
+
typeof props[key] === 'object' &&
|
|
2310
|
+
Reflect.getPrototypeOf(props[key]) === Reflect.getPrototypeOf({})) {
|
|
2311
|
+
if (typeof node[key] === 'object') {
|
|
2312
|
+
Object.assign(node[key], props[key]);
|
|
2313
|
+
continue;
|
|
2270
2314
|
}
|
|
2271
2315
|
}
|
|
2272
|
-
|
|
2273
|
-
|
|
2274
|
-
|
|
2275
|
-
|
|
2276
|
-
|
|
2277
|
-
|
|
2278
|
-
|
|
2279
|
-
|
|
2280
|
-
|
|
2316
|
+
else {
|
|
2317
|
+
node[key] = props[key];
|
|
2318
|
+
}
|
|
2319
|
+
}
|
|
2320
|
+
if (guid)
|
|
2321
|
+
node.id = guid;
|
|
2322
|
+
return node;
|
|
2323
|
+
}
|
|
2324
|
+
$.$mol_jsx = $mol_jsx;
|
|
2281
2325
|
})($ || ($ = {}));
|
|
2282
|
-
//mol/
|
|
2326
|
+
//mol/jsx/jsx.ts
|
|
2283
2327
|
;
|
|
2284
2328
|
"use strict";
|
|
2285
2329
|
var $;
|
|
2286
|
-
(function ($
|
|
2330
|
+
(function ($) {
|
|
2287
2331
|
$mol_test({
|
|
2288
|
-
'
|
|
2289
|
-
|
|
2290
|
-
|
|
2291
|
-
|
|
2292
|
-
|
|
2293
|
-
|
|
2294
|
-
|
|
2295
|
-
|
|
2296
|
-
|
|
2297
|
-
|
|
2298
|
-
|
|
2299
|
-
|
|
2300
|
-
|
|
2301
|
-
|
|
2302
|
-
|
|
2303
|
-
|
|
2304
|
-
$
|
|
2305
|
-
|
|
2306
|
-
|
|
2307
|
-
|
|
2308
|
-
|
|
2309
|
-
|
|
2310
|
-
|
|
2311
|
-
|
|
2312
|
-
|
|
2313
|
-
|
|
2332
|
+
'nulls & undefineds'() {
|
|
2333
|
+
$mol_assert_ok($mol_compare_deep(null, null));
|
|
2334
|
+
$mol_assert_ok($mol_compare_deep(undefined, undefined));
|
|
2335
|
+
$mol_assert_not($mol_compare_deep(undefined, null));
|
|
2336
|
+
$mol_assert_not($mol_compare_deep({}, null));
|
|
2337
|
+
},
|
|
2338
|
+
'number'() {
|
|
2339
|
+
$mol_assert_ok($mol_compare_deep(1, 1));
|
|
2340
|
+
$mol_assert_ok($mol_compare_deep(Number.NaN, Number.NaN));
|
|
2341
|
+
$mol_assert_not($mol_compare_deep(1, 2));
|
|
2342
|
+
$mol_assert_ok($mol_compare_deep(Object(1), Object(1)));
|
|
2343
|
+
$mol_assert_not($mol_compare_deep(Object(1), Object(2)));
|
|
2344
|
+
},
|
|
2345
|
+
'POJO'() {
|
|
2346
|
+
$mol_assert_ok($mol_compare_deep({}, {}));
|
|
2347
|
+
$mol_assert_not($mol_compare_deep({ a: 1 }, { b: 2 }));
|
|
2348
|
+
$mol_assert_not($mol_compare_deep({ a: 1 }, { a: 2 }));
|
|
2349
|
+
$mol_assert_not($mol_compare_deep({}, { a: undefined }));
|
|
2350
|
+
$mol_assert_ok($mol_compare_deep({ a: 1, b: 2 }, { b: 2, a: 1 }));
|
|
2351
|
+
$mol_assert_ok($mol_compare_deep({ a: { b: 1 } }, { a: { b: 1 } }));
|
|
2352
|
+
},
|
|
2353
|
+
'Array'() {
|
|
2354
|
+
$mol_assert_ok($mol_compare_deep([], []));
|
|
2355
|
+
$mol_assert_ok($mol_compare_deep([1, [2]], [1, [2]]));
|
|
2356
|
+
$mol_assert_not($mol_compare_deep([1, 2], [1, 3]));
|
|
2357
|
+
$mol_assert_not($mol_compare_deep([1, 2,], [1, 3, undefined]));
|
|
2358
|
+
},
|
|
2359
|
+
'Non POJO are different'() {
|
|
2360
|
+
class Thing extends Object {
|
|
2314
2361
|
}
|
|
2315
|
-
|
|
2316
|
-
|
|
2317
|
-
$
|
|
2362
|
+
$mol_assert_not($mol_compare_deep(new Thing, new Thing));
|
|
2363
|
+
$mol_assert_not($mol_compare_deep(() => 1, () => 1));
|
|
2364
|
+
$mol_assert_not($mol_compare_deep(new RangeError('Test error'), new RangeError('Test error')));
|
|
2318
2365
|
},
|
|
2319
|
-
'cyclic
|
|
2320
|
-
const
|
|
2321
|
-
|
|
2322
|
-
const
|
|
2323
|
-
|
|
2324
|
-
|
|
2325
|
-
|
|
2326
|
-
|
|
2366
|
+
'same POJOs with cyclic reference'() {
|
|
2367
|
+
const a = { foo: {} };
|
|
2368
|
+
a['self'] = a;
|
|
2369
|
+
const b = { foo: {} };
|
|
2370
|
+
b['self'] = b;
|
|
2371
|
+
$mol_assert_ok($mol_compare_deep(a, b));
|
|
2372
|
+
},
|
|
2373
|
+
'Date'() {
|
|
2374
|
+
$mol_assert_ok($mol_compare_deep(new Date(12345), new Date(12345)));
|
|
2375
|
+
$mol_assert_not($mol_compare_deep(new Date(12345), new Date(12346)));
|
|
2376
|
+
},
|
|
2377
|
+
'RegExp'() {
|
|
2378
|
+
$mol_assert_ok($mol_compare_deep(/\x22/mig, /\x22/mig));
|
|
2379
|
+
$mol_assert_not($mol_compare_deep(/\x22/mig, /\x21/mig));
|
|
2380
|
+
$mol_assert_not($mol_compare_deep(/\x22/mig, /\x22/mg));
|
|
2381
|
+
},
|
|
2382
|
+
'Error'() {
|
|
2383
|
+
$mol_assert_not($mol_compare_deep(new Error('xxx'), new Error('xxx')));
|
|
2384
|
+
const fail = (message) => new Error(message);
|
|
2385
|
+
$mol_assert_ok($mol_compare_deep(...['xxx', 'xxx'].map(msg => new Error(msg))));
|
|
2386
|
+
$mol_assert_not($mol_compare_deep(...['xxx', 'yyy'].map(msg => new Error(msg))));
|
|
2387
|
+
},
|
|
2388
|
+
'Map'() {
|
|
2389
|
+
$mol_assert_ok($mol_compare_deep(new Map, new Map));
|
|
2390
|
+
$mol_assert_ok($mol_compare_deep(new Map([[1, [2]]]), new Map([[1, [2]]])));
|
|
2391
|
+
$mol_assert_not($mol_compare_deep(new Map([[1, 2]]), new Map([[1, 3]])));
|
|
2392
|
+
$mol_assert_not($mol_compare_deep(new Map([[[1], 2]]), new Map([[[1], 2]])));
|
|
2393
|
+
},
|
|
2394
|
+
'Set'() {
|
|
2395
|
+
$mol_assert_ok($mol_compare_deep(new Set, new Set));
|
|
2396
|
+
$mol_assert_ok($mol_compare_deep(new Set([1, [2]]), new Set([1, [2]])));
|
|
2397
|
+
$mol_assert_not($mol_compare_deep(new Set([1]), new Set([2])));
|
|
2398
|
+
},
|
|
2399
|
+
'Uint8Array'() {
|
|
2400
|
+
$mol_assert_ok($mol_compare_deep(new Uint8Array, new Uint8Array));
|
|
2401
|
+
$mol_assert_ok($mol_compare_deep(new Uint8Array([0]), new Uint8Array([0])));
|
|
2402
|
+
$mol_assert_not($mol_compare_deep(new Uint8Array([0]), new Uint8Array([1])));
|
|
2403
|
+
},
|
|
2404
|
+
'Custom comparator'() {
|
|
2405
|
+
class User {
|
|
2406
|
+
name;
|
|
2407
|
+
rand;
|
|
2408
|
+
constructor(name, rand = Math.random()) {
|
|
2409
|
+
this.name = name;
|
|
2410
|
+
this.rand = rand;
|
|
2327
2411
|
}
|
|
2328
|
-
|
|
2329
|
-
|
|
2330
|
-
sub2.track_off(bu2);
|
|
2412
|
+
[Symbol.toPrimitive](mode) {
|
|
2413
|
+
return this.name;
|
|
2331
2414
|
}
|
|
2332
2415
|
}
|
|
2333
|
-
|
|
2334
|
-
|
|
2335
|
-
sub1.track_off(bu1);
|
|
2336
|
-
}
|
|
2416
|
+
$mol_assert_ok($mol_compare_deep(new User('Jin'), new User('Jin')));
|
|
2417
|
+
$mol_assert_not($mol_compare_deep(new User('Jin'), new User('John')));
|
|
2337
2418
|
},
|
|
2338
2419
|
});
|
|
2339
2420
|
})($ || ($ = {}));
|
|
2340
|
-
//mol/
|
|
2421
|
+
//mol/compare/deep/deep.test.tsx
|
|
2341
2422
|
;
|
|
2342
2423
|
"use strict";
|
|
2343
2424
|
var $;
|
|
2344
|
-
(function ($
|
|
2345
|
-
$
|
|
2346
|
-
|
|
2347
|
-
|
|
2425
|
+
(function ($) {
|
|
2426
|
+
function $mol_dom_serialize(node) {
|
|
2427
|
+
const serializer = new $mol_dom_context.XMLSerializer;
|
|
2428
|
+
return serializer.serializeToString(node);
|
|
2429
|
+
}
|
|
2430
|
+
$.$mol_dom_serialize = $mol_dom_serialize;
|
|
2348
2431
|
})($ || ($ = {}));
|
|
2349
|
-
//mol/
|
|
2432
|
+
//mol/dom/serialize/serialize.ts
|
|
2350
2433
|
;
|
|
2351
2434
|
"use strict";
|
|
2352
2435
|
var $;
|
|
2353
|
-
(function ($
|
|
2354
|
-
$
|
|
2355
|
-
|
|
2436
|
+
(function ($) {
|
|
2437
|
+
$mol_test({
|
|
2438
|
+
'must be false'() {
|
|
2439
|
+
$mol_assert_not(0);
|
|
2440
|
+
},
|
|
2441
|
+
'must be true'() {
|
|
2442
|
+
$mol_assert_ok(1);
|
|
2443
|
+
},
|
|
2444
|
+
'two must be equal'() {
|
|
2445
|
+
$mol_assert_equal(2, 2);
|
|
2446
|
+
},
|
|
2447
|
+
'three must be equal'() {
|
|
2448
|
+
$mol_assert_equal(2, 2, 2);
|
|
2449
|
+
},
|
|
2450
|
+
'two must be unique'() {
|
|
2451
|
+
$mol_assert_unique([3], [3]);
|
|
2452
|
+
},
|
|
2453
|
+
'three must be unique'() {
|
|
2454
|
+
$mol_assert_unique([3], [3], [3]);
|
|
2455
|
+
},
|
|
2456
|
+
'two must be alike'() {
|
|
2457
|
+
$mol_assert_like([3], [3]);
|
|
2458
|
+
},
|
|
2459
|
+
'three must be alike'() {
|
|
2460
|
+
$mol_assert_like([3], [3], [3]);
|
|
2461
|
+
},
|
|
2356
2462
|
});
|
|
2357
2463
|
})($ || ($ = {}));
|
|
2358
|
-
//mol/
|
|
2464
|
+
//mol/assert/assert.test.ts
|
|
2359
2465
|
;
|
|
2360
2466
|
"use strict";
|
|
2361
2467
|
var $;
|
|
2362
2468
|
(function ($) {
|
|
2363
|
-
$
|
|
2364
|
-
|
|
2365
|
-
|
|
2366
|
-
|
|
2367
|
-
|
|
2368
|
-
|
|
2469
|
+
function $mol_assert_ok(value) {
|
|
2470
|
+
if (value)
|
|
2471
|
+
return;
|
|
2472
|
+
$mol_fail(new Error(`${value} ≠ true`));
|
|
2473
|
+
}
|
|
2474
|
+
$.$mol_assert_ok = $mol_assert_ok;
|
|
2475
|
+
function $mol_assert_not(value) {
|
|
2476
|
+
if (!value)
|
|
2477
|
+
return;
|
|
2478
|
+
$mol_fail(new Error(`${value} ≠ false`));
|
|
2479
|
+
}
|
|
2480
|
+
$.$mol_assert_not = $mol_assert_not;
|
|
2481
|
+
function $mol_assert_fail(handler, ErrorRight) {
|
|
2482
|
+
const fail = $.$mol_fail;
|
|
2483
|
+
try {
|
|
2484
|
+
$.$mol_fail = $.$mol_fail_hidden;
|
|
2485
|
+
handler();
|
|
2486
|
+
}
|
|
2487
|
+
catch (error) {
|
|
2488
|
+
if (!ErrorRight)
|
|
2489
|
+
return error;
|
|
2490
|
+
$.$mol_fail = fail;
|
|
2491
|
+
if (typeof ErrorRight === 'string') {
|
|
2492
|
+
$mol_assert_equal(error.message, ErrorRight);
|
|
2369
2493
|
}
|
|
2370
|
-
|
|
2371
|
-
$
|
|
2372
|
-
], Sync, "calc", null);
|
|
2373
|
-
$mol_assert_equal(Sync.calc(1, 2), 3);
|
|
2374
|
-
},
|
|
2375
|
-
async 'async <=> sync'() {
|
|
2376
|
-
class SyncAsync extends $mol_object2 {
|
|
2377
|
-
static async val(a) {
|
|
2378
|
-
return a;
|
|
2379
|
-
}
|
|
2380
|
-
static sum(a, b) {
|
|
2381
|
-
const syn = $mol_wire_sync(this);
|
|
2382
|
-
return syn.val(a) + syn.val(b);
|
|
2383
|
-
}
|
|
2384
|
-
static async calc(a, b) {
|
|
2385
|
-
return 5 + await $mol_wire_async(this).sum(a, b);
|
|
2386
|
-
}
|
|
2494
|
+
else {
|
|
2495
|
+
$mol_assert_ok(error instanceof ErrorRight);
|
|
2387
2496
|
}
|
|
2388
|
-
|
|
2389
|
-
}
|
|
2390
|
-
|
|
2391
|
-
|
|
2392
|
-
|
|
2393
|
-
|
|
2394
|
-
|
|
2395
|
-
|
|
2396
|
-
|
|
2397
|
-
|
|
2398
|
-
|
|
2399
|
-
|
|
2400
|
-
|
|
2401
|
-
|
|
2402
|
-
|
|
2403
|
-
|
|
2404
|
-
|
|
2405
|
-
this.log_unidemp();
|
|
2406
|
-
const syn = $mol_wire_sync(this);
|
|
2407
|
-
return syn.val(a) + syn.val(b);
|
|
2408
|
-
}
|
|
2409
|
-
static async calc(a, b) {
|
|
2410
|
-
return 5 + await $mol_wire_async(this).sum(a, b);
|
|
2411
|
-
}
|
|
2497
|
+
return error;
|
|
2498
|
+
}
|
|
2499
|
+
finally {
|
|
2500
|
+
$.$mol_fail = fail;
|
|
2501
|
+
}
|
|
2502
|
+
$mol_fail(new Error('Not failed'));
|
|
2503
|
+
}
|
|
2504
|
+
$.$mol_assert_fail = $mol_assert_fail;
|
|
2505
|
+
function $mol_assert_equal(...args) {
|
|
2506
|
+
for (let i = 0; i < args.length; ++i) {
|
|
2507
|
+
for (let j = 0; j < args.length; ++j) {
|
|
2508
|
+
if (i === j)
|
|
2509
|
+
continue;
|
|
2510
|
+
if (Number.isNaN(args[i]) && Number.isNaN(args[j]))
|
|
2511
|
+
continue;
|
|
2512
|
+
if (args[i] !== args[j])
|
|
2513
|
+
$mol_fail(new Error(`Not equal (${i + 1}:${j + 1})\n${args[i]}\n${args[j]}`));
|
|
2412
2514
|
}
|
|
2413
|
-
|
|
2414
|
-
|
|
2415
|
-
|
|
2416
|
-
|
|
2417
|
-
|
|
2418
|
-
|
|
2419
|
-
|
|
2420
|
-
|
|
2421
|
-
|
|
2422
|
-
|
|
2423
|
-
$mol_fail(new Error('test error ' + (a + b)));
|
|
2515
|
+
}
|
|
2516
|
+
}
|
|
2517
|
+
$.$mol_assert_equal = $mol_assert_equal;
|
|
2518
|
+
function $mol_assert_unique(...args) {
|
|
2519
|
+
for (let i = 0; i < args.length; ++i) {
|
|
2520
|
+
for (let j = 0; j < args.length; ++j) {
|
|
2521
|
+
if (i === j)
|
|
2522
|
+
continue;
|
|
2523
|
+
if (args[i] === args[j] || (Number.isNaN(args[i]) && Number.isNaN(args[j]))) {
|
|
2524
|
+
$mol_fail(new Error(`args[${i}] = args[${j}] = ${args[i]}`));
|
|
2424
2525
|
}
|
|
2425
|
-
|
|
2526
|
+
}
|
|
2527
|
+
}
|
|
2528
|
+
}
|
|
2529
|
+
$.$mol_assert_unique = $mol_assert_unique;
|
|
2530
|
+
function $mol_assert_like(head, ...tail) {
|
|
2531
|
+
for (let [index, value] of Object.entries(tail)) {
|
|
2532
|
+
if (!$mol_compare_deep(value, head)) {
|
|
2533
|
+
const print = (val) => {
|
|
2534
|
+
if (!val)
|
|
2535
|
+
return val;
|
|
2536
|
+
if (typeof val !== 'object')
|
|
2537
|
+
return val;
|
|
2538
|
+
if ('outerHTML' in val)
|
|
2539
|
+
return val.outerHTML;
|
|
2426
2540
|
try {
|
|
2427
|
-
return
|
|
2541
|
+
return JSON.stringify(val);
|
|
2428
2542
|
}
|
|
2429
2543
|
catch (error) {
|
|
2430
|
-
|
|
2431
|
-
|
|
2432
|
-
$mol_assert_equal(error.message, 'test error 3');
|
|
2544
|
+
console.error(error);
|
|
2545
|
+
return val;
|
|
2433
2546
|
}
|
|
2434
|
-
}
|
|
2547
|
+
};
|
|
2548
|
+
return $mol_fail(new Error(`Not like (1:${+index + 2})\n${print(head)}\n---\n${print(value)}`));
|
|
2435
2549
|
}
|
|
2436
|
-
|
|
2437
|
-
|
|
2550
|
+
}
|
|
2551
|
+
}
|
|
2552
|
+
$.$mol_assert_like = $mol_assert_like;
|
|
2553
|
+
function $mol_assert_dom(left, right) {
|
|
2554
|
+
$mol_assert_equal($mol_dom_serialize(left), $mol_dom_serialize(right));
|
|
2555
|
+
}
|
|
2556
|
+
$.$mol_assert_dom = $mol_assert_dom;
|
|
2557
|
+
})($ || ($ = {}));
|
|
2558
|
+
//mol/assert/assert.ts
|
|
2559
|
+
;
|
|
2560
|
+
"use strict";
|
|
2561
|
+
var $;
|
|
2562
|
+
(function ($_1) {
|
|
2563
|
+
$mol_test_mocks.push($ => {
|
|
2564
|
+
$.$mol_log3_come = () => { };
|
|
2565
|
+
$.$mol_log3_done = () => { };
|
|
2566
|
+
$.$mol_log3_fail = () => { };
|
|
2567
|
+
$.$mol_log3_warn = () => { };
|
|
2568
|
+
$.$mol_log3_rise = () => { };
|
|
2569
|
+
$.$mol_log3_area = () => () => { };
|
|
2438
2570
|
});
|
|
2439
2571
|
})($ || ($ = {}));
|
|
2440
|
-
//mol/
|
|
2572
|
+
//mol/log3/log3.test.ts
|
|
2441
2573
|
;
|
|
2442
2574
|
"use strict";
|
|
2443
2575
|
var $;
|
|
2444
2576
|
(function ($) {
|
|
2445
2577
|
$mol_test({
|
|
2446
|
-
'
|
|
2447
|
-
$
|
|
2448
|
-
$mol_assert_equal(
|
|
2449
|
-
$mol_assert_equal($mol_key(true), 'true');
|
|
2450
|
-
$mol_assert_equal($mol_key(0), '0');
|
|
2451
|
-
$mol_assert_equal($mol_key(''), '""');
|
|
2578
|
+
'get'() {
|
|
2579
|
+
const proxy = $mol_delegate({}, () => ({ foo: 777 }));
|
|
2580
|
+
$mol_assert_equal(proxy.foo, 777);
|
|
2452
2581
|
},
|
|
2453
|
-
'
|
|
2454
|
-
$
|
|
2455
|
-
$mol_assert_equal(
|
|
2456
|
-
$mol_assert_equal($mol_key({ foo: [false] }), '{"foo":[false]}');
|
|
2582
|
+
'has'() {
|
|
2583
|
+
const proxy = $mol_delegate({}, () => ({ foo: 777 }));
|
|
2584
|
+
$mol_assert_equal('foo' in proxy, true);
|
|
2457
2585
|
},
|
|
2458
|
-
'
|
|
2459
|
-
const
|
|
2460
|
-
$
|
|
2461
|
-
|
|
2586
|
+
'set'() {
|
|
2587
|
+
const target = { foo: 777 };
|
|
2588
|
+
const proxy = $mol_delegate({}, () => target);
|
|
2589
|
+
proxy.foo = 123;
|
|
2590
|
+
$mol_assert_equal(target.foo, 123);
|
|
2462
2591
|
},
|
|
2463
|
-
'
|
|
2464
|
-
|
|
2592
|
+
'getOwnPropertyDescriptor'() {
|
|
2593
|
+
const proxy = $mol_delegate({}, () => ({ foo: 777 }));
|
|
2594
|
+
$mol_assert_like(Object.getOwnPropertyDescriptor(proxy, 'foo'), {
|
|
2595
|
+
value: 777,
|
|
2596
|
+
writable: true,
|
|
2597
|
+
enumerable: true,
|
|
2598
|
+
configurable: true,
|
|
2599
|
+
});
|
|
2600
|
+
},
|
|
2601
|
+
'ownKeys'() {
|
|
2602
|
+
const proxy = $mol_delegate({}, () => ({ foo: 777, [Symbol.toStringTag]: 'bar' }));
|
|
2603
|
+
$mol_assert_like(Reflect.ownKeys(proxy), ['foo', Symbol.toStringTag]);
|
|
2604
|
+
},
|
|
2605
|
+
'getPrototypeOf'() {
|
|
2606
|
+
class Foo {
|
|
2465
2607
|
}
|
|
2466
|
-
const
|
|
2467
|
-
$mol_assert_equal(
|
|
2468
|
-
$mol_assert_unique($mol_key(jin), $mol_key(new User()));
|
|
2608
|
+
const proxy = $mol_delegate({}, () => new Foo);
|
|
2609
|
+
$mol_assert_equal(Object.getPrototypeOf(proxy), Foo.prototype);
|
|
2469
2610
|
},
|
|
2470
|
-
'
|
|
2471
|
-
|
|
2472
|
-
|
|
2473
|
-
|
|
2611
|
+
'setPrototypeOf'() {
|
|
2612
|
+
class Foo {
|
|
2613
|
+
}
|
|
2614
|
+
const target = {};
|
|
2615
|
+
const proxy = $mol_delegate({}, () => target);
|
|
2616
|
+
Object.setPrototypeOf(proxy, Foo.prototype);
|
|
2617
|
+
$mol_assert_equal(Object.getPrototypeOf(target), Foo.prototype);
|
|
2474
2618
|
},
|
|
2475
|
-
'
|
|
2476
|
-
class
|
|
2477
|
-
name;
|
|
2478
|
-
age;
|
|
2479
|
-
constructor(name, age) {
|
|
2480
|
-
this.name = name;
|
|
2481
|
-
this.age = age;
|
|
2482
|
-
}
|
|
2483
|
-
toJSON() { return { name: this.name }; }
|
|
2619
|
+
'instanceof'() {
|
|
2620
|
+
class Foo {
|
|
2484
2621
|
}
|
|
2485
|
-
$
|
|
2622
|
+
const proxy = $mol_delegate({}, () => new Foo);
|
|
2623
|
+
$mol_assert_ok(proxy instanceof Foo);
|
|
2624
|
+
$mol_assert_ok(proxy instanceof $mol_delegate);
|
|
2486
2625
|
},
|
|
2487
|
-
'
|
|
2488
|
-
|
|
2489
|
-
|
|
2490
|
-
$
|
|
2491
|
-
$
|
|
2626
|
+
'autobind'() {
|
|
2627
|
+
class Foo {
|
|
2628
|
+
}
|
|
2629
|
+
const proxy = $mol_delegate({}, () => new Foo);
|
|
2630
|
+
$mol_assert_ok(proxy instanceof Foo);
|
|
2631
|
+
$mol_assert_ok(proxy instanceof $mol_delegate);
|
|
2492
2632
|
},
|
|
2493
2633
|
});
|
|
2494
2634
|
})($ || ($ = {}));
|
|
2495
|
-
//mol/
|
|
2635
|
+
//mol/delegate/delegate.test.ts
|
|
2636
|
+
;
|
|
2637
|
+
"use strict";
|
|
2638
|
+
//mol/type/writable/writable.test.ts
|
|
2639
|
+
;
|
|
2640
|
+
"use strict";
|
|
2641
|
+
var $;
|
|
2642
|
+
(function ($) {
|
|
2643
|
+
$.$mol_after_mock_queue = [];
|
|
2644
|
+
function $mol_after_mock_warp() {
|
|
2645
|
+
const queue = $.$mol_after_mock_queue.splice(0);
|
|
2646
|
+
for (const task of queue)
|
|
2647
|
+
task();
|
|
2648
|
+
}
|
|
2649
|
+
$.$mol_after_mock_warp = $mol_after_mock_warp;
|
|
2650
|
+
class $mol_after_mock_commmon extends $mol_object2 {
|
|
2651
|
+
task;
|
|
2652
|
+
promise = Promise.resolve();
|
|
2653
|
+
cancelled = false;
|
|
2654
|
+
id;
|
|
2655
|
+
constructor(task) {
|
|
2656
|
+
super();
|
|
2657
|
+
this.task = task;
|
|
2658
|
+
$.$mol_after_mock_queue.push(task);
|
|
2659
|
+
}
|
|
2660
|
+
destructor() {
|
|
2661
|
+
const index = $.$mol_after_mock_queue.indexOf(this.task);
|
|
2662
|
+
if (index >= 0)
|
|
2663
|
+
$.$mol_after_mock_queue.splice(index, 1);
|
|
2664
|
+
}
|
|
2665
|
+
}
|
|
2666
|
+
$.$mol_after_mock_commmon = $mol_after_mock_commmon;
|
|
2667
|
+
class $mol_after_mock_timeout extends $mol_after_mock_commmon {
|
|
2668
|
+
delay;
|
|
2669
|
+
constructor(delay, task) {
|
|
2670
|
+
super(task);
|
|
2671
|
+
this.delay = delay;
|
|
2672
|
+
}
|
|
2673
|
+
}
|
|
2674
|
+
$.$mol_after_mock_timeout = $mol_after_mock_timeout;
|
|
2675
|
+
})($ || ($ = {}));
|
|
2676
|
+
//mol/after/mock/mock.test.ts
|
|
2496
2677
|
;
|
|
2497
2678
|
"use strict";
|
|
2498
2679
|
var $;
|
|
2499
2680
|
(function ($_1) {
|
|
2500
2681
|
$mol_test({
|
|
2501
|
-
'
|
|
2502
|
-
class
|
|
2682
|
+
async 'Latest Calls Wins on Concurrency'($) {
|
|
2683
|
+
class NameLogger extends $mol_object2 {
|
|
2503
2684
|
static $ = $;
|
|
2504
|
-
static
|
|
2505
|
-
|
|
2506
|
-
|
|
2507
|
-
|
|
2508
|
-
|
|
2685
|
+
static first = [];
|
|
2686
|
+
static last = [];
|
|
2687
|
+
static send(next) {
|
|
2688
|
+
$mol_wire_sync(this.first).push(next);
|
|
2689
|
+
this.$.$mol_wait_timeout(0);
|
|
2690
|
+
this.last.push(next);
|
|
2691
|
+
}
|
|
2692
|
+
}
|
|
2693
|
+
const name = $mol_wire_async(NameLogger).send;
|
|
2694
|
+
name('john');
|
|
2695
|
+
const promise = name('jin');
|
|
2696
|
+
$.$mol_after_mock_warp();
|
|
2697
|
+
await promise;
|
|
2698
|
+
$mol_assert_like(NameLogger.first, ['john', 'jin']);
|
|
2699
|
+
$mol_assert_like(NameLogger.last, ['jin']);
|
|
2700
|
+
},
|
|
2701
|
+
});
|
|
2702
|
+
})($ || ($ = {}));
|
|
2703
|
+
//mol/wire/async/async.test.ts
|
|
2704
|
+
;
|
|
2705
|
+
"use strict";
|
|
2706
|
+
var $;
|
|
2707
|
+
(function ($_1) {
|
|
2708
|
+
$mol_test({
|
|
2709
|
+
'Collect deps'() {
|
|
2710
|
+
const pub1 = new $mol_wire_pub;
|
|
2711
|
+
const pub2 = new $mol_wire_pub;
|
|
2712
|
+
const sub = new $mol_wire_pub_sub;
|
|
2713
|
+
const bu1 = sub.track_on();
|
|
2714
|
+
try {
|
|
2715
|
+
pub1.promote();
|
|
2716
|
+
pub2.promote();
|
|
2717
|
+
pub2.promote();
|
|
2718
|
+
}
|
|
2719
|
+
finally {
|
|
2720
|
+
sub.track_cut();
|
|
2721
|
+
sub.track_off(bu1);
|
|
2722
|
+
}
|
|
2723
|
+
pub1.emit();
|
|
2724
|
+
pub2.emit();
|
|
2725
|
+
$mol_assert_like(sub.pub_list, [pub1, pub2, pub2]);
|
|
2726
|
+
const bu2 = sub.track_on();
|
|
2727
|
+
try {
|
|
2728
|
+
pub1.promote();
|
|
2729
|
+
pub1.promote();
|
|
2730
|
+
pub2.promote();
|
|
2731
|
+
}
|
|
2732
|
+
finally {
|
|
2733
|
+
sub.track_cut();
|
|
2734
|
+
sub.track_off(bu2);
|
|
2735
|
+
}
|
|
2736
|
+
pub1.emit();
|
|
2737
|
+
pub2.emit();
|
|
2738
|
+
$mol_assert_like(sub.pub_list, [pub1, pub1, pub2]);
|
|
2739
|
+
},
|
|
2740
|
+
'cyclic detection'($) {
|
|
2741
|
+
const sub1 = new $mol_wire_pub_sub;
|
|
2742
|
+
const sub2 = new $mol_wire_pub_sub;
|
|
2743
|
+
const bu1 = sub1.track_on();
|
|
2744
|
+
try {
|
|
2745
|
+
const bu2 = sub2.track_on();
|
|
2746
|
+
try {
|
|
2747
|
+
$mol_assert_fail(() => sub1.promote(), 'Circular subscription');
|
|
2748
|
+
}
|
|
2749
|
+
finally {
|
|
2750
|
+
sub2.track_cut();
|
|
2751
|
+
sub2.track_off(bu2);
|
|
2752
|
+
}
|
|
2753
|
+
}
|
|
2754
|
+
finally {
|
|
2755
|
+
sub1.track_cut();
|
|
2756
|
+
sub1.track_off(bu1);
|
|
2757
|
+
}
|
|
2758
|
+
},
|
|
2759
|
+
});
|
|
2760
|
+
})($ || ($ = {}));
|
|
2761
|
+
//mol/wire/pub/sub/sub.test.ts
|
|
2762
|
+
;
|
|
2763
|
+
"use strict";
|
|
2764
|
+
var $;
|
|
2765
|
+
(function ($_1) {
|
|
2766
|
+
$mol_test_mocks.push($ => {
|
|
2767
|
+
$.$mol_after_timeout = $mol_after_mock_timeout;
|
|
2768
|
+
});
|
|
2769
|
+
})($ || ($ = {}));
|
|
2770
|
+
//mol/after/timeout/timeout.test.ts
|
|
2771
|
+
;
|
|
2772
|
+
"use strict";
|
|
2773
|
+
var $;
|
|
2774
|
+
(function ($_1) {
|
|
2775
|
+
$mol_test_mocks.push($ => {
|
|
2776
|
+
$.$mol_after_frame = $mol_after_mock_commmon;
|
|
2777
|
+
});
|
|
2778
|
+
})($ || ($ = {}));
|
|
2779
|
+
//mol/after/frame/frame.test.ts
|
|
2780
|
+
;
|
|
2781
|
+
"use strict";
|
|
2782
|
+
var $;
|
|
2783
|
+
(function ($) {
|
|
2784
|
+
$mol_test({
|
|
2785
|
+
'Sync execution'() {
|
|
2786
|
+
class Sync extends $mol_object2 {
|
|
2787
|
+
static calc(a, b) {
|
|
2788
|
+
return a + b;
|
|
2789
|
+
}
|
|
2790
|
+
}
|
|
2791
|
+
__decorate([
|
|
2792
|
+
$mol_wire_method
|
|
2793
|
+
], Sync, "calc", null);
|
|
2794
|
+
$mol_assert_equal(Sync.calc(1, 2), 3);
|
|
2795
|
+
},
|
|
2796
|
+
async 'async <=> sync'() {
|
|
2797
|
+
class SyncAsync extends $mol_object2 {
|
|
2798
|
+
static async val(a) {
|
|
2799
|
+
return a;
|
|
2800
|
+
}
|
|
2801
|
+
static sum(a, b) {
|
|
2802
|
+
const syn = $mol_wire_sync(this);
|
|
2803
|
+
return syn.val(a) + syn.val(b);
|
|
2804
|
+
}
|
|
2805
|
+
static async calc(a, b) {
|
|
2806
|
+
return 5 + await $mol_wire_async(this).sum(a, b);
|
|
2807
|
+
}
|
|
2808
|
+
}
|
|
2809
|
+
$mol_assert_equal(await SyncAsync.calc(1, 2), 8);
|
|
2810
|
+
},
|
|
2811
|
+
async 'Idempotence control'() {
|
|
2812
|
+
class Idempotence extends $mol_object2 {
|
|
2813
|
+
static logs_idemp = 0;
|
|
2814
|
+
static logs_unidemp = 0;
|
|
2815
|
+
static log_idemp() {
|
|
2816
|
+
this.logs_idemp += 1;
|
|
2817
|
+
}
|
|
2818
|
+
static log_unidemp() {
|
|
2819
|
+
this.logs_unidemp += 1;
|
|
2820
|
+
}
|
|
2821
|
+
static async val(a) {
|
|
2822
|
+
return a;
|
|
2823
|
+
}
|
|
2824
|
+
static sum(a, b) {
|
|
2825
|
+
this.log_idemp();
|
|
2826
|
+
this.log_unidemp();
|
|
2827
|
+
const syn = $mol_wire_sync(this);
|
|
2828
|
+
return syn.val(a) + syn.val(b);
|
|
2829
|
+
}
|
|
2830
|
+
static async calc(a, b) {
|
|
2831
|
+
return 5 + await $mol_wire_async(this).sum(a, b);
|
|
2832
|
+
}
|
|
2833
|
+
}
|
|
2834
|
+
__decorate([
|
|
2835
|
+
$mol_wire_method
|
|
2836
|
+
], Idempotence, "log_idemp", null);
|
|
2837
|
+
$mol_assert_equal(await Idempotence.calc(1, 2), 8);
|
|
2838
|
+
$mol_assert_equal(Idempotence.logs_idemp, 1);
|
|
2839
|
+
$mol_assert_equal(Idempotence.logs_unidemp, 3);
|
|
2840
|
+
},
|
|
2841
|
+
async 'Error handling'() {
|
|
2842
|
+
class Handle extends $mol_object2 {
|
|
2843
|
+
static async sum(a, b) {
|
|
2844
|
+
$mol_fail(new Error('test error ' + (a + b)));
|
|
2845
|
+
}
|
|
2846
|
+
static check() {
|
|
2847
|
+
try {
|
|
2848
|
+
return $mol_wire_sync(Handle).sum(1, 2);
|
|
2849
|
+
}
|
|
2850
|
+
catch (error) {
|
|
2851
|
+
if (error instanceof Promise)
|
|
2852
|
+
$mol_fail_hidden(error);
|
|
2853
|
+
$mol_assert_equal(error.message, 'test error 3');
|
|
2854
|
+
}
|
|
2855
|
+
}
|
|
2856
|
+
}
|
|
2857
|
+
await $mol_wire_async(Handle).check();
|
|
2858
|
+
},
|
|
2859
|
+
});
|
|
2860
|
+
})($ || ($ = {}));
|
|
2861
|
+
//mol/wire/fiber/fiber.test.ts
|
|
2862
|
+
;
|
|
2863
|
+
"use strict";
|
|
2864
|
+
var $;
|
|
2865
|
+
(function ($) {
|
|
2866
|
+
$mol_test({
|
|
2867
|
+
'Primitives'() {
|
|
2868
|
+
$mol_assert_equal($mol_key(null), 'null');
|
|
2869
|
+
$mol_assert_equal($mol_key(false), 'false');
|
|
2870
|
+
$mol_assert_equal($mol_key(true), 'true');
|
|
2871
|
+
$mol_assert_equal($mol_key(0), '0');
|
|
2872
|
+
$mol_assert_equal($mol_key(''), '""');
|
|
2873
|
+
},
|
|
2874
|
+
'Array & POJO'() {
|
|
2875
|
+
$mol_assert_equal($mol_key([null]), '[null]');
|
|
2876
|
+
$mol_assert_equal($mol_key({ foo: 0 }), '{"foo":0}');
|
|
2877
|
+
$mol_assert_equal($mol_key({ foo: [false] }), '{"foo":[false]}');
|
|
2878
|
+
},
|
|
2879
|
+
'Function'() {
|
|
2880
|
+
const func = () => { };
|
|
2881
|
+
$mol_assert_equal($mol_key(func), $mol_key(func));
|
|
2882
|
+
$mol_assert_unique($mol_key(func), $mol_key(() => { }));
|
|
2883
|
+
},
|
|
2884
|
+
'Objects'() {
|
|
2885
|
+
class User {
|
|
2886
|
+
}
|
|
2887
|
+
const jin = new User();
|
|
2888
|
+
$mol_assert_equal($mol_key(jin), $mol_key(jin));
|
|
2889
|
+
$mol_assert_unique($mol_key(jin), $mol_key(new User()));
|
|
2890
|
+
},
|
|
2891
|
+
'Elements'() {
|
|
2892
|
+
const foo = $mol_jsx("div", null, "bar");
|
|
2893
|
+
$mol_assert_equal($mol_key(foo), $mol_key(foo));
|
|
2894
|
+
$mol_assert_unique($mol_key(foo), $mol_key($mol_jsx("div", null, "bar")));
|
|
2895
|
+
},
|
|
2896
|
+
'Custom JSON representation'() {
|
|
2897
|
+
class User {
|
|
2898
|
+
name;
|
|
2899
|
+
age;
|
|
2900
|
+
constructor(name, age) {
|
|
2901
|
+
this.name = name;
|
|
2902
|
+
this.age = age;
|
|
2903
|
+
}
|
|
2904
|
+
toJSON() { return { name: this.name }; }
|
|
2905
|
+
}
|
|
2906
|
+
$mol_assert_equal($mol_key(new User('jin', 18)), '{"name":"jin"}');
|
|
2907
|
+
},
|
|
2908
|
+
'Special native classes'() {
|
|
2909
|
+
$mol_assert_equal($mol_key(new Date('xyz')), 'null');
|
|
2910
|
+
$mol_assert_equal($mol_key(new Date('2001-01-02T03:04:05.678Z')), '"2001-01-02T03:04:05.678Z"');
|
|
2911
|
+
$mol_assert_equal($mol_key(/./), '"/./"');
|
|
2912
|
+
$mol_assert_equal($mol_key(/\./gimsu), '"/\\\\./gimsu"');
|
|
2913
|
+
},
|
|
2914
|
+
});
|
|
2915
|
+
})($ || ($ = {}));
|
|
2916
|
+
//mol/key/key.test.tsx
|
|
2917
|
+
;
|
|
2918
|
+
"use strict";
|
|
2919
|
+
var $;
|
|
2920
|
+
(function ($_1) {
|
|
2921
|
+
$mol_test({
|
|
2922
|
+
'Cached channel'($) {
|
|
2923
|
+
class App extends $mol_object2 {
|
|
2924
|
+
static $ = $;
|
|
2925
|
+
static value(next = 1) {
|
|
2926
|
+
return next + 1;
|
|
2927
|
+
}
|
|
2928
|
+
}
|
|
2929
|
+
__decorate([
|
|
2509
2930
|
$mol_wire_mem(0)
|
|
2510
2931
|
], App, "value", null);
|
|
2511
2932
|
$mol_assert_equal(App.value(), 2);
|
|
@@ -2921,588 +3342,167 @@ var $;
|
|
|
2921
3342
|
static test() {
|
|
2922
3343
|
}
|
|
2923
3344
|
}
|
|
2924
|
-
__decorate([
|
|
2925
|
-
$mol_wire_mem(1)
|
|
2926
|
-
], Team, "user_name", null);
|
|
2927
|
-
__decorate([
|
|
2928
|
-
$mol_wire_mem(1)
|
|
2929
|
-
], Team, "user_names", null);
|
|
2930
|
-
__decorate([
|
|
2931
|
-
$mol_wire_method
|
|
2932
|
-
], Team, "test", null);
|
|
2933
|
-
$mol_assert_like(Team.user_names(), ['jin', 'john']);
|
|
2934
|
-
Team.user_name('jin', 'JIN');
|
|
2935
|
-
$mol_assert_like(Team.user_names(), ['JIN', 'john']);
|
|
2936
|
-
},
|
|
2937
|
-
'Memoize by single complex key'($) {
|
|
2938
|
-
class Map extends $mol_object2 {
|
|
2939
|
-
static $ = $;
|
|
2940
|
-
static tile(pos) {
|
|
2941
|
-
return new String(`/tile=${pos}`);
|
|
2942
|
-
}
|
|
2943
|
-
static test() {
|
|
2944
|
-
$mol_assert_like(this.tile([0, 1]), new String('/tile=0,1'));
|
|
2945
|
-
$mol_assert_equal(this.tile([0, 1]), this.tile([0, 1]));
|
|
2946
|
-
}
|
|
2947
|
-
}
|
|
2948
|
-
__decorate([
|
|
2949
|
-
$mol_wire_mem(1)
|
|
2950
|
-
], Map, "tile", null);
|
|
2951
|
-
__decorate([
|
|
2952
|
-
$mol_wire_method
|
|
2953
|
-
], Map, "test", null);
|
|
2954
|
-
Map.test();
|
|
2955
|
-
},
|
|
2956
|
-
'Memoize by multiple keys'($) {
|
|
2957
|
-
class Map extends $mol_object2 {
|
|
2958
|
-
static $ = $;
|
|
2959
|
-
static tile(x, y) {
|
|
2960
|
-
return new String(`/tile=${x},${y}`);
|
|
2961
|
-
}
|
|
2962
|
-
static test() {
|
|
2963
|
-
$mol_assert_like(this.tile(0, 1), new String('/tile=0,1'));
|
|
2964
|
-
$mol_assert_equal(this.tile(0, 1), this.tile(0, 1));
|
|
2965
|
-
}
|
|
2966
|
-
}
|
|
2967
|
-
__decorate([
|
|
2968
|
-
$mol_wire_mem(2)
|
|
2969
|
-
], Map, "tile", null);
|
|
2970
|
-
__decorate([
|
|
2971
|
-
$mol_wire_method
|
|
2972
|
-
], Map, "test", null);
|
|
2973
|
-
Map.test();
|
|
2974
|
-
},
|
|
2975
|
-
'Owned value has js-path name'() {
|
|
2976
|
-
class App extends $mol_object2 {
|
|
2977
|
-
static title() {
|
|
2978
|
-
return new $mol_object2;
|
|
2979
|
-
}
|
|
2980
|
-
static like(friend) {
|
|
2981
|
-
return new $mol_object2;
|
|
2982
|
-
}
|
|
2983
|
-
static relation(friend, props) {
|
|
2984
|
-
return new $mol_object2;
|
|
2985
|
-
}
|
|
2986
|
-
}
|
|
2987
|
-
__decorate([
|
|
2988
|
-
$mol_wire_mem(0)
|
|
2989
|
-
], App, "title", null);
|
|
2990
|
-
__decorate([
|
|
2991
|
-
$mol_wire_mem(1)
|
|
2992
|
-
], App, "like", null);
|
|
2993
|
-
__decorate([
|
|
2994
|
-
$mol_wire_mem(2)
|
|
2995
|
-
], App, "relation", null);
|
|
2996
|
-
$mol_assert_equal(`${App.title()}`, 'App.title()');
|
|
2997
|
-
$mol_assert_equal(`${App.like(123)}`, 'App.like(123)');
|
|
2998
|
-
$mol_assert_equal(`${App.relation(123, [456])}`, 'App.relation(123,[456])');
|
|
2999
|
-
},
|
|
3000
|
-
'Deep deps'($) {
|
|
3001
|
-
class Fib extends $mol_object2 {
|
|
3002
|
-
static $ = $;
|
|
3003
|
-
static sums = 0;
|
|
3004
|
-
static value(index, next) {
|
|
3005
|
-
if (next)
|
|
3006
|
-
return next;
|
|
3007
|
-
if (index < 2)
|
|
3008
|
-
return 1;
|
|
3009
|
-
++this.sums;
|
|
3010
|
-
return this.value(index - 1) + this.value(index - 2);
|
|
3011
|
-
}
|
|
3012
|
-
}
|
|
3013
|
-
__decorate([
|
|
3014
|
-
$mol_wire_mem(1)
|
|
3015
|
-
], Fib, "value", null);
|
|
3016
|
-
$mol_assert_equal(Fib.value(4), 5);
|
|
3017
|
-
$mol_assert_equal(Fib.sums, 3);
|
|
3018
|
-
Fib.value(1, 2);
|
|
3019
|
-
$mol_assert_equal(Fib.value(4), 8);
|
|
3020
|
-
$mol_assert_equal(Fib.sums, 6);
|
|
3021
|
-
},
|
|
3022
|
-
});
|
|
3023
|
-
})($ || ($ = {}));
|
|
3024
|
-
//mol/wire/mem/mem.test.ts
|
|
3025
|
-
;
|
|
3026
|
-
"use strict";
|
|
3027
|
-
var $;
|
|
3028
|
-
(function ($) {
|
|
3029
|
-
$.$mol_mem = $mol_wire_mem(0);
|
|
3030
|
-
$.$mol_mem_key = $mol_wire_mem(1);
|
|
3031
|
-
$.$mol_mem_key2 = $mol_wire_mem(2);
|
|
3032
|
-
$.$mol_mem_key3 = $mol_wire_mem(3);
|
|
3033
|
-
})($ || ($ = {}));
|
|
3034
|
-
//mol/mem/mem.ts
|
|
3035
|
-
;
|
|
3036
|
-
"use strict";
|
|
3037
|
-
var $;
|
|
3038
|
-
(function ($) {
|
|
3039
|
-
function $mol_deprecated(message) {
|
|
3040
|
-
return (host, field, descr) => {
|
|
3041
|
-
const value = descr.value;
|
|
3042
|
-
let warned = false;
|
|
3043
|
-
descr.value = function $mol_deprecated_wrapper(...args) {
|
|
3044
|
-
if (!warned) {
|
|
3045
|
-
$$.$mol_log3_warn({
|
|
3046
|
-
place: `${host.constructor.name}::${field}`,
|
|
3047
|
-
message: `Deprecated`,
|
|
3048
|
-
hint: message,
|
|
3049
|
-
});
|
|
3050
|
-
warned = true;
|
|
3051
|
-
}
|
|
3052
|
-
return value.call(this, ...args);
|
|
3053
|
-
};
|
|
3054
|
-
};
|
|
3055
|
-
}
|
|
3056
|
-
$.$mol_deprecated = $mol_deprecated;
|
|
3057
|
-
})($ || ($ = {}));
|
|
3058
|
-
//mol/deprecated/deprecated.ts
|
|
3059
|
-
;
|
|
3060
|
-
"use strict";
|
|
3061
|
-
var $;
|
|
3062
|
-
(function ($_1) {
|
|
3063
|
-
$mol_test({
|
|
3064
|
-
'tree parsing'() {
|
|
3065
|
-
$mol_assert_equal($mol_tree.fromString("foo\nbar\n").sub.length, 2);
|
|
3066
|
-
$mol_assert_equal($mol_tree.fromString("foo\nbar\n").sub[1].type, "bar");
|
|
3067
|
-
$mol_assert_equal($mol_tree.fromString("foo\n\n\n").sub.length, 1);
|
|
3068
|
-
$mol_assert_equal($mol_tree.fromString("=foo\n\\bar\n").sub.length, 2);
|
|
3069
|
-
$mol_assert_equal($mol_tree.fromString("=foo\n\\bar\n").sub[1].data, "bar");
|
|
3070
|
-
$mol_assert_equal($mol_tree.fromString("foo bar \\pol").sub[0].sub[0].sub[0].data, "pol");
|
|
3071
|
-
$mol_assert_equal($mol_tree.fromString("foo bar\n\t\\pol\n\t\\men").sub[0].sub[0].sub[1].data, "men");
|
|
3072
|
-
$mol_assert_equal($mol_tree.fromString('foo bar \\text\n').toString(), 'foo bar \\text\n');
|
|
3073
|
-
},
|
|
3074
|
-
'inserting'() {
|
|
3075
|
-
$mol_assert_equal($mol_tree.fromString('a b c d').insert(new $mol_tree, 'a', 'b', 'c').toString(), 'a b \\\n');
|
|
3076
|
-
$mol_assert_equal($mol_tree.fromString('a b').insert(new $mol_tree, 'a', 'b', 'c', 'd').toString(), 'a b c \\\n');
|
|
3077
|
-
$mol_assert_equal($mol_tree.fromString('a b c d').insert(new $mol_tree, 0, 0, 0).toString(), 'a b \\\n');
|
|
3078
|
-
$mol_assert_equal($mol_tree.fromString('a b').insert(new $mol_tree, 0, 0, 0, 0).toString(), 'a b \\\n\t\\\n');
|
|
3079
|
-
$mol_assert_equal($mol_tree.fromString('a b c d').insert(new $mol_tree, null, null, null).toString(), 'a b \\\n');
|
|
3080
|
-
$mol_assert_equal($mol_tree.fromString('a b').insert(new $mol_tree, null, null, null, null).toString(), 'a b \\\n\t\\\n');
|
|
3081
|
-
},
|
|
3082
|
-
'fromJSON'() {
|
|
3083
|
-
$mol_assert_equal($mol_tree.fromJSON([]).toString(), '/\n');
|
|
3084
|
-
$mol_assert_equal($mol_tree.fromJSON([false, true]).toString(), '/\n\tfalse\n\ttrue\n');
|
|
3085
|
-
$mol_assert_equal($mol_tree.fromJSON([0, 1, 2.3]).toString(), '/\n\t0\n\t1\n\t2.3\n');
|
|
3086
|
-
$mol_assert_equal($mol_tree.fromJSON(['', 'foo', 'bar\nbaz']).toString(), '/\n\t\\\n\t\\foo\n\t\\\n\t\t\\bar\n\t\t\\baz\n');
|
|
3087
|
-
$mol_assert_equal($mol_tree.fromJSON({ 'foo': false, 'bar\nbaz': 'lol' }).toString(), '*\n\tfoo false\n\t\\\n\t\t\\bar\n\t\t\\baz\n\t\t\\lol\n');
|
|
3088
|
-
},
|
|
3089
|
-
'toJSON'() {
|
|
3090
|
-
$mol_assert_equal(JSON.stringify($mol_tree.fromString('/\n').sub[0]), '[]');
|
|
3091
|
-
$mol_assert_equal(JSON.stringify($mol_tree.fromString('/\n\tfalse\n\ttrue\n').sub[0]), '[false,true]');
|
|
3092
|
-
$mol_assert_equal(JSON.stringify($mol_tree.fromString('/\n\t0\n\t1\n\t2.3\n').sub[0]), '[0,1,2.3]');
|
|
3093
|
-
$mol_assert_equal(JSON.stringify($mol_tree.fromString('/\n\t\\\n\t\\foo\n\t\\\n\t\t\\bar\n\t\t\\baz\n').sub[0]), '["","foo","bar\\nbaz"]');
|
|
3094
|
-
$mol_assert_equal(JSON.stringify($mol_tree.fromString('*\n\tfoo false\n\t\\\n\t\t\\bar\n\t\t\\baz\n\t\t\\lol\n').sub[0]), '{"foo":false,"bar\\nbaz":"lol"}');
|
|
3095
|
-
},
|
|
3096
|
-
'hack'() {
|
|
3097
|
-
const res = $mol_tree.fromString(`foo bar xxx`).hack({
|
|
3098
|
-
'': (tree, context) => [tree.hack(context)],
|
|
3099
|
-
'bar': (tree, context) => [tree.hack(context).clone({ type: '777' })],
|
|
3100
|
-
});
|
|
3101
|
-
$mol_assert_equal(res.toString(), new $mol_tree({ type: 'foo 777 xxx' }).toString());
|
|
3102
|
-
},
|
|
3103
|
-
'errors handling'($) {
|
|
3104
|
-
const errors = [];
|
|
3105
|
-
class Tree extends $mol_tree {
|
|
3106
|
-
static $ = $.$mol_ambient({
|
|
3107
|
-
$mol_fail: error => errors.push(error.message)
|
|
3108
|
-
});
|
|
3109
|
-
}
|
|
3110
|
-
Tree.fromString(`
|
|
3111
|
-
\t \tfoo
|
|
3112
|
-
bar \\data
|
|
3113
|
-
`, 'test');
|
|
3114
|
-
$mol_assert_like(errors, ['Syntax error at test:2\n \tfoo']);
|
|
3115
|
-
},
|
|
3116
|
-
});
|
|
3117
|
-
})($ || ($ = {}));
|
|
3118
|
-
//mol/tree/tree.test.ts
|
|
3119
|
-
;
|
|
3120
|
-
"use strict";
|
|
3121
|
-
var $;
|
|
3122
|
-
(function ($) {
|
|
3123
|
-
$.$mol_tree_convert = Symbol('$mol_tree_convert');
|
|
3124
|
-
class $mol_tree extends $mol_object2 {
|
|
3125
|
-
type;
|
|
3126
|
-
data;
|
|
3127
|
-
sub;
|
|
3128
|
-
baseUri;
|
|
3129
|
-
row;
|
|
3130
|
-
col;
|
|
3131
|
-
length;
|
|
3132
|
-
constructor(config = {}) {
|
|
3133
|
-
super();
|
|
3134
|
-
this.type = config.type || '';
|
|
3135
|
-
if (config.value !== undefined) {
|
|
3136
|
-
var sub = $mol_tree.values(config.value);
|
|
3137
|
-
if (config.type || sub.length > 1) {
|
|
3138
|
-
this.sub = [...sub, ...(config.sub || [])];
|
|
3139
|
-
this.data = config.data || '';
|
|
3140
|
-
}
|
|
3141
|
-
else {
|
|
3142
|
-
this.data = sub[0].data;
|
|
3143
|
-
this.sub = config.sub || [];
|
|
3144
|
-
}
|
|
3145
|
-
}
|
|
3146
|
-
else {
|
|
3147
|
-
this.data = config.data || '';
|
|
3148
|
-
this.sub = config.sub || [];
|
|
3149
|
-
}
|
|
3150
|
-
this.baseUri = config.baseUri || '';
|
|
3151
|
-
this.row = config.row || 0;
|
|
3152
|
-
this.col = config.col || 0;
|
|
3153
|
-
this.length = config.length || 0;
|
|
3154
|
-
}
|
|
3155
|
-
static values(str, baseUri) {
|
|
3156
|
-
return str.split('\n').map((data, index) => new $mol_tree({
|
|
3157
|
-
data: data,
|
|
3158
|
-
baseUri: baseUri,
|
|
3159
|
-
row: index + 1,
|
|
3160
|
-
length: data.length,
|
|
3161
|
-
}));
|
|
3162
|
-
}
|
|
3163
|
-
clone(config = {}) {
|
|
3164
|
-
return new $mol_tree({
|
|
3165
|
-
type: ('type' in config) ? config.type : this.type,
|
|
3166
|
-
data: ('data' in config) ? config.data : this.data,
|
|
3167
|
-
sub: ('sub' in config) ? config.sub : this.sub,
|
|
3168
|
-
baseUri: ('baseUri' in config) ? config.baseUri : this.baseUri,
|
|
3169
|
-
row: ('row' in config) ? config.row : this.row,
|
|
3170
|
-
col: ('col' in config) ? config.col : this.col,
|
|
3171
|
-
length: ('length' in config) ? config.length : this.length,
|
|
3172
|
-
value: config.value
|
|
3173
|
-
});
|
|
3174
|
-
}
|
|
3175
|
-
make(config) {
|
|
3176
|
-
return new $mol_tree({
|
|
3177
|
-
baseUri: this.baseUri,
|
|
3178
|
-
row: this.row,
|
|
3179
|
-
col: this.col,
|
|
3180
|
-
length: this.length,
|
|
3181
|
-
...config,
|
|
3182
|
-
});
|
|
3183
|
-
}
|
|
3184
|
-
make_data(value, sub) {
|
|
3185
|
-
return this.make({ value, sub });
|
|
3186
|
-
}
|
|
3187
|
-
make_struct(type, sub) {
|
|
3188
|
-
return this.make({ type, sub });
|
|
3189
|
-
}
|
|
3190
|
-
static fromString(str, baseUri) {
|
|
3191
|
-
var root = new $mol_tree({ baseUri: baseUri });
|
|
3192
|
-
var stack = [root];
|
|
3193
|
-
var row = 0;
|
|
3194
|
-
var prefix = str.replace(/^\n?(\t*)[\s\S]*/, '$1');
|
|
3195
|
-
var lines = str.replace(new RegExp('^\\t{0,' + prefix.length + '}', 'mg'), '').split('\n');
|
|
3196
|
-
lines.forEach(line => {
|
|
3197
|
-
++row;
|
|
3198
|
-
var chunks = /^(\t*)((?:[^\n\t\\ ]+ *)*)(\\[^\n]*)?(.*?)(?:$|\n)/m.exec(line);
|
|
3199
|
-
if (!chunks || chunks[4])
|
|
3200
|
-
return this.$.$mol_fail(new Error(`Syntax error at ${baseUri}:${row}\n${line}`));
|
|
3201
|
-
var indent = chunks[1];
|
|
3202
|
-
var path = chunks[2];
|
|
3203
|
-
var data = chunks[3];
|
|
3204
|
-
var deep = indent.length;
|
|
3205
|
-
var types = path ? path.replace(/ $/, '').split(/ +/) : [];
|
|
3206
|
-
if (stack.length <= deep)
|
|
3207
|
-
return this.$.$mol_fail(new Error(`Too many tabs at ${baseUri}:${row}\n${line}`));
|
|
3208
|
-
stack.length = deep + 1;
|
|
3209
|
-
var parent = stack[deep];
|
|
3210
|
-
let col = deep;
|
|
3211
|
-
types.forEach(type => {
|
|
3212
|
-
if (!type)
|
|
3213
|
-
return this.$.$mol_fail(new Error(`Unexpected space symbol ${baseUri}:${row}\n${line}`));
|
|
3214
|
-
var next = new $mol_tree({ type, baseUri, row, col, length: type.length });
|
|
3215
|
-
const parent_sub = parent.sub;
|
|
3216
|
-
parent_sub.push(next);
|
|
3217
|
-
parent = next;
|
|
3218
|
-
col += type.length + 1;
|
|
3219
|
-
});
|
|
3220
|
-
if (data) {
|
|
3221
|
-
var next = new $mol_tree({ data: data.substring(1), baseUri, row, col, length: data.length });
|
|
3222
|
-
const parent_sub = parent.sub;
|
|
3223
|
-
parent_sub.push(next);
|
|
3224
|
-
parent = next;
|
|
3225
|
-
}
|
|
3226
|
-
stack.push(parent);
|
|
3227
|
-
});
|
|
3228
|
-
return root;
|
|
3229
|
-
}
|
|
3230
|
-
static fromJSON(json, baseUri = '') {
|
|
3231
|
-
switch (true) {
|
|
3232
|
-
case typeof json === 'boolean':
|
|
3233
|
-
case typeof json === 'number':
|
|
3234
|
-
case json === null:
|
|
3235
|
-
return new $mol_tree({
|
|
3236
|
-
type: String(json),
|
|
3237
|
-
baseUri: baseUri
|
|
3238
|
-
});
|
|
3239
|
-
case typeof json === 'string':
|
|
3240
|
-
return new $mol_tree({
|
|
3241
|
-
value: json,
|
|
3242
|
-
baseUri: baseUri
|
|
3243
|
-
});
|
|
3244
|
-
case Array.isArray(json):
|
|
3245
|
-
return new $mol_tree({
|
|
3246
|
-
type: "/",
|
|
3247
|
-
sub: json.map(json => $mol_tree.fromJSON(json, baseUri))
|
|
3248
|
-
});
|
|
3249
|
-
case json instanceof Date:
|
|
3250
|
-
return new $mol_tree({
|
|
3251
|
-
value: json.toISOString(),
|
|
3252
|
-
baseUri: baseUri
|
|
3253
|
-
});
|
|
3254
|
-
default:
|
|
3255
|
-
if (typeof json[$.$mol_tree_convert] === 'function') {
|
|
3256
|
-
return json[$.$mol_tree_convert]();
|
|
3257
|
-
}
|
|
3258
|
-
if (typeof json.toJSON === 'function') {
|
|
3259
|
-
return $mol_tree.fromJSON(json.toJSON());
|
|
3260
|
-
}
|
|
3261
|
-
if (json instanceof Error) {
|
|
3262
|
-
const { name, message, stack } = json;
|
|
3263
|
-
json = { ...json, name, message, stack };
|
|
3264
|
-
}
|
|
3265
|
-
var sub = [];
|
|
3266
|
-
for (var key in json) {
|
|
3267
|
-
if (json[key] === undefined)
|
|
3268
|
-
continue;
|
|
3269
|
-
const subsub = $mol_tree.fromJSON(json[key], baseUri);
|
|
3270
|
-
if (/^[^\n\t\\ ]+$/.test(key)) {
|
|
3271
|
-
var child = new $mol_tree({
|
|
3272
|
-
type: key,
|
|
3273
|
-
baseUri: baseUri,
|
|
3274
|
-
sub: [subsub],
|
|
3275
|
-
});
|
|
3276
|
-
}
|
|
3277
|
-
else {
|
|
3278
|
-
var child = new $mol_tree({
|
|
3279
|
-
value: key,
|
|
3280
|
-
baseUri: baseUri,
|
|
3281
|
-
sub: [subsub],
|
|
3282
|
-
});
|
|
3283
|
-
}
|
|
3284
|
-
sub.push(child);
|
|
3285
|
-
}
|
|
3286
|
-
return new $mol_tree({
|
|
3287
|
-
type: "*",
|
|
3288
|
-
sub: sub,
|
|
3289
|
-
baseUri: baseUri
|
|
3290
|
-
});
|
|
3291
|
-
}
|
|
3292
|
-
}
|
|
3293
|
-
get uri() {
|
|
3294
|
-
return this.baseUri + '#' + this.row + ':' + this.col;
|
|
3295
|
-
}
|
|
3296
|
-
toString(prefix = '') {
|
|
3297
|
-
var output = '';
|
|
3298
|
-
if (this.type.length) {
|
|
3299
|
-
if (!prefix.length) {
|
|
3300
|
-
prefix = "\t";
|
|
3301
|
-
}
|
|
3302
|
-
output += this.type;
|
|
3303
|
-
if (this.sub.length == 1) {
|
|
3304
|
-
return output + ' ' + this.sub[0].toString(prefix);
|
|
3305
|
-
}
|
|
3306
|
-
output += "\n";
|
|
3307
|
-
}
|
|
3308
|
-
else if (this.data.length || prefix.length) {
|
|
3309
|
-
output += "\\" + this.data + "\n";
|
|
3310
|
-
}
|
|
3311
|
-
for (var child of this.sub) {
|
|
3312
|
-
output += prefix;
|
|
3313
|
-
output += child.toString(prefix + "\t");
|
|
3314
|
-
}
|
|
3315
|
-
return output;
|
|
3316
|
-
}
|
|
3317
|
-
toJSON() {
|
|
3318
|
-
if (!this.type)
|
|
3319
|
-
return this.value;
|
|
3320
|
-
if (this.type === 'true')
|
|
3321
|
-
return true;
|
|
3322
|
-
if (this.type === 'false')
|
|
3323
|
-
return false;
|
|
3324
|
-
if (this.type === 'null')
|
|
3325
|
-
return null;
|
|
3326
|
-
if (this.type === '*') {
|
|
3327
|
-
var obj = {};
|
|
3328
|
-
for (var child of this.sub) {
|
|
3329
|
-
if (child.type === '-')
|
|
3330
|
-
continue;
|
|
3331
|
-
var key = child.type || child.clone({ sub: child.sub.slice(0, child.sub.length - 1) }).value;
|
|
3332
|
-
var val = child.sub[child.sub.length - 1].toJSON();
|
|
3333
|
-
if (val !== undefined)
|
|
3334
|
-
obj[key] = val;
|
|
3335
|
-
}
|
|
3336
|
-
return obj;
|
|
3337
|
-
}
|
|
3338
|
-
if (this.type === '/') {
|
|
3339
|
-
var res = [];
|
|
3340
|
-
this.sub.forEach(child => {
|
|
3341
|
-
if (child.type === '-')
|
|
3342
|
-
return;
|
|
3343
|
-
var val = child.toJSON();
|
|
3344
|
-
if (val !== undefined)
|
|
3345
|
-
res.push(val);
|
|
3346
|
-
});
|
|
3347
|
-
return res;
|
|
3348
|
-
}
|
|
3349
|
-
if (this.type === 'time') {
|
|
3350
|
-
return new Date(this.value);
|
|
3351
|
-
}
|
|
3352
|
-
const numb = Number(this.type);
|
|
3353
|
-
if (!Number.isNaN(numb) || this.type === 'NaN')
|
|
3354
|
-
return numb;
|
|
3355
|
-
throw new Error(`Unknown type (${this.type}) at ${this.uri}`);
|
|
3356
|
-
}
|
|
3357
|
-
get value() {
|
|
3358
|
-
var values = [];
|
|
3359
|
-
for (var child of this.sub) {
|
|
3360
|
-
if (child.type)
|
|
3361
|
-
continue;
|
|
3362
|
-
values.push(child.value);
|
|
3363
|
-
}
|
|
3364
|
-
return this.data + values.join("\n");
|
|
3365
|
-
}
|
|
3366
|
-
insert(value, ...path) {
|
|
3367
|
-
if (path.length === 0)
|
|
3368
|
-
return value;
|
|
3369
|
-
const type = path[0];
|
|
3370
|
-
if (typeof type === 'string') {
|
|
3371
|
-
let replaced = false;
|
|
3372
|
-
const sub = this.sub.map((item, index) => {
|
|
3373
|
-
if (item.type !== type)
|
|
3374
|
-
return item;
|
|
3375
|
-
replaced = true;
|
|
3376
|
-
return item.insert(value, ...path.slice(1));
|
|
3377
|
-
});
|
|
3378
|
-
if (!replaced)
|
|
3379
|
-
sub.push(new $mol_tree({ type }).insert(value, ...path.slice(1)));
|
|
3380
|
-
return this.clone({ sub });
|
|
3381
|
-
}
|
|
3382
|
-
else if (typeof type === 'number') {
|
|
3383
|
-
const sub = this.sub.slice();
|
|
3384
|
-
sub[type] = (sub[type] || new $mol_tree).insert(value, ...path.slice(1));
|
|
3385
|
-
return this.clone({ sub });
|
|
3386
|
-
}
|
|
3387
|
-
else {
|
|
3388
|
-
return this.clone({ sub: ((this.sub.length === 0) ? [new $mol_tree()] : this.sub).map(item => item.insert(value, ...path.slice(1))) });
|
|
3345
|
+
__decorate([
|
|
3346
|
+
$mol_wire_mem(1)
|
|
3347
|
+
], Team, "user_name", null);
|
|
3348
|
+
__decorate([
|
|
3349
|
+
$mol_wire_mem(1)
|
|
3350
|
+
], Team, "user_names", null);
|
|
3351
|
+
__decorate([
|
|
3352
|
+
$mol_wire_method
|
|
3353
|
+
], Team, "test", null);
|
|
3354
|
+
$mol_assert_like(Team.user_names(), ['jin', 'john']);
|
|
3355
|
+
Team.user_name('jin', 'JIN');
|
|
3356
|
+
$mol_assert_like(Team.user_names(), ['JIN', 'john']);
|
|
3357
|
+
},
|
|
3358
|
+
'Memoize by single complex key'($) {
|
|
3359
|
+
class Map extends $mol_object2 {
|
|
3360
|
+
static $ = $;
|
|
3361
|
+
static tile(pos) {
|
|
3362
|
+
return new String(`/tile=${pos}`);
|
|
3363
|
+
}
|
|
3364
|
+
static test() {
|
|
3365
|
+
$mol_assert_like(this.tile([0, 1]), new String('/tile=0,1'));
|
|
3366
|
+
$mol_assert_equal(this.tile([0, 1]), this.tile([0, 1]));
|
|
3367
|
+
}
|
|
3389
3368
|
}
|
|
3390
|
-
|
|
3391
|
-
|
|
3392
|
-
|
|
3393
|
-
|
|
3394
|
-
|
|
3395
|
-
|
|
3396
|
-
|
|
3397
|
-
|
|
3398
|
-
|
|
3399
|
-
|
|
3400
|
-
|
|
3401
|
-
|
|
3402
|
-
|
|
3403
|
-
|
|
3404
|
-
|
|
3405
|
-
|
|
3406
|
-
|
|
3407
|
-
case 'number':
|
|
3408
|
-
if (type < item.sub.length)
|
|
3409
|
-
next.push(item.sub[type]);
|
|
3410
|
-
break;
|
|
3411
|
-
default: next.push(...item.sub);
|
|
3412
|
-
}
|
|
3369
|
+
__decorate([
|
|
3370
|
+
$mol_wire_mem(1)
|
|
3371
|
+
], Map, "tile", null);
|
|
3372
|
+
__decorate([
|
|
3373
|
+
$mol_wire_method
|
|
3374
|
+
], Map, "test", null);
|
|
3375
|
+
Map.test();
|
|
3376
|
+
},
|
|
3377
|
+
'Memoize by multiple keys'($) {
|
|
3378
|
+
class Map extends $mol_object2 {
|
|
3379
|
+
static $ = $;
|
|
3380
|
+
static tile(x, y) {
|
|
3381
|
+
return new String(`/tile=${x},${y}`);
|
|
3382
|
+
}
|
|
3383
|
+
static test() {
|
|
3384
|
+
$mol_assert_like(this.tile(0, 1), new String('/tile=0,1'));
|
|
3385
|
+
$mol_assert_equal(this.tile(0, 1), this.tile(0, 1));
|
|
3413
3386
|
}
|
|
3414
3387
|
}
|
|
3415
|
-
|
|
3416
|
-
|
|
3417
|
-
|
|
3418
|
-
|
|
3419
|
-
|
|
3420
|
-
|
|
3421
|
-
|
|
3388
|
+
__decorate([
|
|
3389
|
+
$mol_wire_mem(2)
|
|
3390
|
+
], Map, "tile", null);
|
|
3391
|
+
__decorate([
|
|
3392
|
+
$mol_wire_method
|
|
3393
|
+
], Map, "test", null);
|
|
3394
|
+
Map.test();
|
|
3395
|
+
},
|
|
3396
|
+
'Owned value has js-path name'() {
|
|
3397
|
+
class App extends $mol_object2 {
|
|
3398
|
+
static title() {
|
|
3399
|
+
return new $mol_object2;
|
|
3422
3400
|
}
|
|
3423
|
-
|
|
3424
|
-
return
|
|
3401
|
+
static like(friend) {
|
|
3402
|
+
return new $mol_object2;
|
|
3425
3403
|
}
|
|
3426
|
-
|
|
3427
|
-
|
|
3428
|
-
|
|
3429
|
-
|
|
3430
|
-
|
|
3431
|
-
|
|
3432
|
-
|
|
3433
|
-
|
|
3434
|
-
|
|
3435
|
-
|
|
3436
|
-
|
|
3437
|
-
|
|
3438
|
-
|
|
3439
|
-
}));
|
|
3440
|
-
|
|
3441
|
-
|
|
3442
|
-
|
|
3443
|
-
|
|
3444
|
-
|
|
3445
|
-
|
|
3446
|
-
|
|
3447
|
-
|
|
3448
|
-
|
|
3449
|
-
|
|
3404
|
+
static relation(friend, props) {
|
|
3405
|
+
return new $mol_object2;
|
|
3406
|
+
}
|
|
3407
|
+
}
|
|
3408
|
+
__decorate([
|
|
3409
|
+
$mol_wire_mem(0)
|
|
3410
|
+
], App, "title", null);
|
|
3411
|
+
__decorate([
|
|
3412
|
+
$mol_wire_mem(1)
|
|
3413
|
+
], App, "like", null);
|
|
3414
|
+
__decorate([
|
|
3415
|
+
$mol_wire_mem(2)
|
|
3416
|
+
], App, "relation", null);
|
|
3417
|
+
$mol_assert_equal(`${App.title()}`, 'App.title()');
|
|
3418
|
+
$mol_assert_equal(`${App.like(123)}`, 'App.like(123)');
|
|
3419
|
+
$mol_assert_equal(`${App.relation(123, [456])}`, 'App.relation(123,[456])');
|
|
3420
|
+
},
|
|
3421
|
+
'Deep deps'($) {
|
|
3422
|
+
class Fib extends $mol_object2 {
|
|
3423
|
+
static $ = $;
|
|
3424
|
+
static sums = 0;
|
|
3425
|
+
static value(index, next) {
|
|
3426
|
+
if (next)
|
|
3427
|
+
return next;
|
|
3428
|
+
if (index < 2)
|
|
3429
|
+
return 1;
|
|
3430
|
+
++this.sums;
|
|
3431
|
+
return this.value(index - 1) + this.value(index - 2);
|
|
3432
|
+
}
|
|
3433
|
+
}
|
|
3434
|
+
__decorate([
|
|
3435
|
+
$mol_wire_mem(1)
|
|
3436
|
+
], Fib, "value", null);
|
|
3437
|
+
$mol_assert_equal(Fib.value(4), 5);
|
|
3438
|
+
$mol_assert_equal(Fib.sums, 3);
|
|
3439
|
+
Fib.value(1, 2);
|
|
3440
|
+
$mol_assert_equal(Fib.value(4), 8);
|
|
3441
|
+
$mol_assert_equal(Fib.sums, 6);
|
|
3442
|
+
},
|
|
3443
|
+
});
|
|
3450
3444
|
})($ || ($ = {}));
|
|
3451
|
-
//mol/
|
|
3445
|
+
//mol/wire/mem/mem.test.ts
|
|
3452
3446
|
;
|
|
3453
3447
|
"use strict";
|
|
3454
3448
|
var $;
|
|
3455
|
-
(function ($) {
|
|
3456
|
-
|
|
3457
|
-
|
|
3458
|
-
|
|
3459
|
-
|
|
3460
|
-
|
|
3461
|
-
|
|
3462
|
-
|
|
3463
|
-
|
|
3464
|
-
|
|
3465
|
-
|
|
3466
|
-
|
|
3467
|
-
|
|
3468
|
-
|
|
3469
|
-
|
|
3470
|
-
|
|
3471
|
-
|
|
3472
|
-
|
|
3473
|
-
|
|
3474
|
-
|
|
3475
|
-
|
|
3476
|
-
|
|
3449
|
+
(function ($_1) {
|
|
3450
|
+
$mol_test({
|
|
3451
|
+
'tree parsing'() {
|
|
3452
|
+
$mol_assert_equal($mol_tree.fromString("foo\nbar\n").sub.length, 2);
|
|
3453
|
+
$mol_assert_equal($mol_tree.fromString("foo\nbar\n").sub[1].type, "bar");
|
|
3454
|
+
$mol_assert_equal($mol_tree.fromString("foo\n\n\n").sub.length, 1);
|
|
3455
|
+
$mol_assert_equal($mol_tree.fromString("=foo\n\\bar\n").sub.length, 2);
|
|
3456
|
+
$mol_assert_equal($mol_tree.fromString("=foo\n\\bar\n").sub[1].data, "bar");
|
|
3457
|
+
$mol_assert_equal($mol_tree.fromString("foo bar \\pol").sub[0].sub[0].sub[0].data, "pol");
|
|
3458
|
+
$mol_assert_equal($mol_tree.fromString("foo bar\n\t\\pol\n\t\\men").sub[0].sub[0].sub[1].data, "men");
|
|
3459
|
+
$mol_assert_equal($mol_tree.fromString('foo bar \\text\n').toString(), 'foo bar \\text\n');
|
|
3460
|
+
},
|
|
3461
|
+
'inserting'() {
|
|
3462
|
+
$mol_assert_equal($mol_tree.fromString('a b c d').insert(new $mol_tree, 'a', 'b', 'c').toString(), 'a b \\\n');
|
|
3463
|
+
$mol_assert_equal($mol_tree.fromString('a b').insert(new $mol_tree, 'a', 'b', 'c', 'd').toString(), 'a b c \\\n');
|
|
3464
|
+
$mol_assert_equal($mol_tree.fromString('a b c d').insert(new $mol_tree, 0, 0, 0).toString(), 'a b \\\n');
|
|
3465
|
+
$mol_assert_equal($mol_tree.fromString('a b').insert(new $mol_tree, 0, 0, 0, 0).toString(), 'a b \\\n\t\\\n');
|
|
3466
|
+
$mol_assert_equal($mol_tree.fromString('a b c d').insert(new $mol_tree, null, null, null).toString(), 'a b \\\n');
|
|
3467
|
+
$mol_assert_equal($mol_tree.fromString('a b').insert(new $mol_tree, null, null, null, null).toString(), 'a b \\\n\t\\\n');
|
|
3468
|
+
},
|
|
3469
|
+
'fromJSON'() {
|
|
3470
|
+
$mol_assert_equal($mol_tree.fromJSON([]).toString(), '/\n');
|
|
3471
|
+
$mol_assert_equal($mol_tree.fromJSON([false, true]).toString(), '/\n\tfalse\n\ttrue\n');
|
|
3472
|
+
$mol_assert_equal($mol_tree.fromJSON([0, 1, 2.3]).toString(), '/\n\t0\n\t1\n\t2.3\n');
|
|
3473
|
+
$mol_assert_equal($mol_tree.fromJSON(['', 'foo', 'bar\nbaz']).toString(), '/\n\t\\\n\t\\foo\n\t\\\n\t\t\\bar\n\t\t\\baz\n');
|
|
3474
|
+
$mol_assert_equal($mol_tree.fromJSON({ 'foo': false, 'bar\nbaz': 'lol' }).toString(), '*\n\tfoo false\n\t\\\n\t\t\\bar\n\t\t\\baz\n\t\t\\lol\n');
|
|
3475
|
+
},
|
|
3476
|
+
'toJSON'() {
|
|
3477
|
+
$mol_assert_equal(JSON.stringify($mol_tree.fromString('/\n').sub[0]), '[]');
|
|
3478
|
+
$mol_assert_equal(JSON.stringify($mol_tree.fromString('/\n\tfalse\n\ttrue\n').sub[0]), '[false,true]');
|
|
3479
|
+
$mol_assert_equal(JSON.stringify($mol_tree.fromString('/\n\t0\n\t1\n\t2.3\n').sub[0]), '[0,1,2.3]');
|
|
3480
|
+
$mol_assert_equal(JSON.stringify($mol_tree.fromString('/\n\t\\\n\t\\foo\n\t\\\n\t\t\\bar\n\t\t\\baz\n').sub[0]), '["","foo","bar\\nbaz"]');
|
|
3481
|
+
$mol_assert_equal(JSON.stringify($mol_tree.fromString('*\n\tfoo false\n\t\\\n\t\t\\bar\n\t\t\\baz\n\t\t\\lol\n').sub[0]), '{"foo":false,"bar\\nbaz":"lol"}');
|
|
3482
|
+
},
|
|
3483
|
+
'hack'() {
|
|
3484
|
+
const res = $mol_tree.fromString(`foo bar xxx`).hack({
|
|
3485
|
+
'': (tree, context) => [tree.hack(context)],
|
|
3486
|
+
'bar': (tree, context) => [tree.hack(context).clone({ type: '777' })],
|
|
3487
|
+
});
|
|
3488
|
+
$mol_assert_equal(res.toString(), new $mol_tree({ type: 'foo 777 xxx' }).toString());
|
|
3489
|
+
},
|
|
3490
|
+
'errors handling'($) {
|
|
3491
|
+
const errors = [];
|
|
3492
|
+
class Tree extends $mol_tree {
|
|
3493
|
+
static $ = $.$mol_ambient({
|
|
3494
|
+
$mol_fail: error => errors.push(error.message)
|
|
3477
3495
|
});
|
|
3478
3496
|
}
|
|
3479
|
-
|
|
3480
|
-
|
|
3481
|
-
|
|
3482
|
-
|
|
3483
|
-
|
|
3484
|
-
|
|
3485
|
-
|
|
3486
|
-
for (const pub of $mol_wire_auto().pub_list) {
|
|
3487
|
-
if (pub instanceof $mol_wire_fiber) {
|
|
3488
|
-
this.track(pub);
|
|
3489
|
-
}
|
|
3490
|
-
}
|
|
3491
|
-
}
|
|
3492
|
-
}
|
|
3493
|
-
}
|
|
3494
|
-
__decorate([
|
|
3495
|
-
$mol_mem
|
|
3496
|
-
], $mol_wire_log, "watch", null);
|
|
3497
|
-
__decorate([
|
|
3498
|
-
$mol_mem_key
|
|
3499
|
-
], $mol_wire_log, "track", null);
|
|
3500
|
-
__decorate([
|
|
3501
|
-
$mol_mem
|
|
3502
|
-
], $mol_wire_log, "active", null);
|
|
3503
|
-
$.$mol_wire_log = $mol_wire_log;
|
|
3497
|
+
Tree.fromString(`
|
|
3498
|
+
\t \tfoo
|
|
3499
|
+
bar \\data
|
|
3500
|
+
`, 'test');
|
|
3501
|
+
$mol_assert_like(errors, ['Syntax error at test:2\n \tfoo']);
|
|
3502
|
+
},
|
|
3503
|
+
});
|
|
3504
3504
|
})($ || ($ = {}));
|
|
3505
|
-
//mol/
|
|
3505
|
+
//mol/tree/tree.test.ts
|
|
3506
3506
|
;
|
|
3507
3507
|
"use strict";
|
|
3508
3508
|
var $;
|