mol_wire_lib 1.0.837 → 1.0.838
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/node.d.ts +133 -133
- package/node.deps.json +1 -1
- package/node.js +1129 -1119
- package/node.js.map +1 -1
- package/node.mjs +1129 -1119
- package/node.test.js +1129 -1119
- package/node.test.js.map +1 -1
- package/package.json +14 -14
- package/web.d.ts +33 -33
- package/web.deps.json +1 -1
- package/web.js +67 -57
- package/web.js.map +1 -1
- package/web.mjs +67 -57
package/node.test.js
CHANGED
|
@@ -975,480 +975,639 @@ var $;
|
|
|
975
975
|
"use strict";
|
|
976
976
|
var $;
|
|
977
977
|
(function ($) {
|
|
978
|
-
|
|
979
|
-
|
|
980
|
-
|
|
981
|
-
|
|
982
|
-
|
|
983
|
-
|
|
984
|
-
|
|
985
|
-
|
|
986
|
-
if (existen.host !== host)
|
|
987
|
-
break reuse;
|
|
988
|
-
if (existen.task !== task)
|
|
989
|
-
break reuse;
|
|
990
|
-
if (!$mol_compare_deep(existen.args, args))
|
|
991
|
-
break reuse;
|
|
992
|
-
return existen;
|
|
993
|
-
}
|
|
994
|
-
return new $mol_wire_task(`${host?.[Symbol.toStringTag] ?? host}.${task.name}(#)`, task, host, args);
|
|
995
|
-
};
|
|
996
|
-
}
|
|
997
|
-
get temp() {
|
|
998
|
-
return true;
|
|
999
|
-
}
|
|
1000
|
-
complete() {
|
|
1001
|
-
if ($mol_promise_like(this.cache))
|
|
1002
|
-
return;
|
|
1003
|
-
this.destructor();
|
|
1004
|
-
}
|
|
1005
|
-
put(next) {
|
|
1006
|
-
const prev = this.cache;
|
|
1007
|
-
this.cache = next;
|
|
1008
|
-
if ($mol_promise_like(next)) {
|
|
1009
|
-
this.cursor = $mol_wire_cursor.fresh;
|
|
1010
|
-
if (next !== prev)
|
|
1011
|
-
this.emit();
|
|
1012
|
-
return next;
|
|
1013
|
-
}
|
|
1014
|
-
this.cursor = $mol_wire_cursor.final;
|
|
1015
|
-
if (this.sub_empty)
|
|
1016
|
-
this.destructor();
|
|
1017
|
-
else if (next !== prev)
|
|
1018
|
-
this.emit();
|
|
1019
|
-
return next;
|
|
1020
|
-
}
|
|
1021
|
-
}
|
|
1022
|
-
$.$mol_wire_task = $mol_wire_task;
|
|
1023
|
-
})($ || ($ = {}));
|
|
1024
|
-
//mol/wire/task/task.ts
|
|
1025
|
-
;
|
|
1026
|
-
"use strict";
|
|
1027
|
-
var $;
|
|
1028
|
-
(function ($) {
|
|
1029
|
-
function $mol_guid(length = 8, exists = () => false) {
|
|
1030
|
-
for (;;) {
|
|
1031
|
-
let id = Math.random().toString(36).substring(2, length + 2).toUpperCase();
|
|
1032
|
-
if (exists(id))
|
|
1033
|
-
continue;
|
|
1034
|
-
return id;
|
|
1035
|
-
}
|
|
1036
|
-
}
|
|
1037
|
-
$.$mol_guid = $mol_guid;
|
|
1038
|
-
})($ || ($ = {}));
|
|
1039
|
-
//mol/guid/guid.ts
|
|
1040
|
-
;
|
|
1041
|
-
"use strict";
|
|
1042
|
-
var $;
|
|
1043
|
-
(function ($) {
|
|
1044
|
-
$.$mol_key_store = new WeakMap();
|
|
1045
|
-
function $mol_key(value) {
|
|
1046
|
-
if (typeof value === 'bigint')
|
|
1047
|
-
return value.toString() + 'n';
|
|
1048
|
-
if (!value)
|
|
1049
|
-
return JSON.stringify(value);
|
|
1050
|
-
if (typeof value !== 'object' && typeof value !== 'function')
|
|
1051
|
-
return JSON.stringify(value);
|
|
1052
|
-
return JSON.stringify(value, (field, value) => {
|
|
1053
|
-
if (typeof value === 'bigint')
|
|
1054
|
-
return value.toString() + 'n';
|
|
1055
|
-
if (!value)
|
|
1056
|
-
return value;
|
|
1057
|
-
if (typeof value !== 'object' && typeof value !== 'function')
|
|
1058
|
-
return value;
|
|
1059
|
-
if (Array.isArray(value))
|
|
1060
|
-
return value;
|
|
1061
|
-
const proto = Reflect.getPrototypeOf(value);
|
|
1062
|
-
if (!proto)
|
|
1063
|
-
return value;
|
|
1064
|
-
if (Reflect.getPrototypeOf(proto) === null)
|
|
1065
|
-
return value;
|
|
1066
|
-
if ('toJSON' in value)
|
|
1067
|
-
return value;
|
|
1068
|
-
if (value instanceof RegExp)
|
|
1069
|
-
return value.toString();
|
|
1070
|
-
if (value instanceof Uint8Array)
|
|
1071
|
-
return [...value];
|
|
1072
|
-
let key = $.$mol_key_store.get(value);
|
|
1073
|
-
if (key)
|
|
1074
|
-
return key;
|
|
1075
|
-
key = $mol_guid();
|
|
1076
|
-
$.$mol_key_store.set(value, key);
|
|
1077
|
-
return key;
|
|
978
|
+
function $mol_log3_area_lazy(event) {
|
|
979
|
+
const self = this;
|
|
980
|
+
const stack = self.$mol_log3_stack;
|
|
981
|
+
const deep = stack.length;
|
|
982
|
+
let logged = false;
|
|
983
|
+
stack.push(() => {
|
|
984
|
+
logged = true;
|
|
985
|
+
self.$mol_log3_area.call(self, event);
|
|
1078
986
|
});
|
|
987
|
+
return () => {
|
|
988
|
+
if (logged)
|
|
989
|
+
self.console.groupEnd();
|
|
990
|
+
if (stack.length > deep)
|
|
991
|
+
stack.length = deep;
|
|
992
|
+
};
|
|
1079
993
|
}
|
|
1080
|
-
$.$
|
|
994
|
+
$.$mol_log3_area_lazy = $mol_log3_area_lazy;
|
|
995
|
+
$.$mol_log3_stack = [];
|
|
1081
996
|
})($ || ($ = {}));
|
|
1082
|
-
//mol/
|
|
997
|
+
//mol/log3/log3.ts
|
|
1083
998
|
;
|
|
1084
999
|
"use strict";
|
|
1085
1000
|
var $;
|
|
1086
1001
|
(function ($) {
|
|
1087
|
-
|
|
1088
|
-
|
|
1089
|
-
|
|
1090
|
-
|
|
1091
|
-
|
|
1092
|
-
|
|
1093
|
-
|
|
1002
|
+
class $mol_span extends $mol_object2 {
|
|
1003
|
+
uri;
|
|
1004
|
+
source;
|
|
1005
|
+
row;
|
|
1006
|
+
col;
|
|
1007
|
+
length;
|
|
1008
|
+
constructor(uri, source, row, col, length) {
|
|
1009
|
+
super();
|
|
1010
|
+
this.uri = uri;
|
|
1011
|
+
this.source = source;
|
|
1012
|
+
this.row = row;
|
|
1013
|
+
this.col = col;
|
|
1014
|
+
this.length = length;
|
|
1015
|
+
this[Symbol.toStringTag] = `${this.uri}#${this.row}:${this.col}/${this.length}`;
|
|
1016
|
+
}
|
|
1017
|
+
static unknown = $mol_span.begin('?');
|
|
1018
|
+
static begin(uri, source = '') {
|
|
1019
|
+
return new $mol_span(uri, source, 1, 1, 0);
|
|
1020
|
+
}
|
|
1021
|
+
static end(uri, source) {
|
|
1022
|
+
return new $mol_span(uri, source, 1, source.length + 1, 0);
|
|
1023
|
+
}
|
|
1024
|
+
static entire(uri, source) {
|
|
1025
|
+
return new $mol_span(uri, source, 1, 1, source.length);
|
|
1026
|
+
}
|
|
1027
|
+
toString() {
|
|
1028
|
+
return this[Symbol.toStringTag];
|
|
1029
|
+
}
|
|
1030
|
+
toJSON() {
|
|
1031
|
+
return {
|
|
1032
|
+
uri: this.uri,
|
|
1033
|
+
row: this.row,
|
|
1034
|
+
col: this.col,
|
|
1035
|
+
length: this.length
|
|
1036
|
+
};
|
|
1037
|
+
}
|
|
1038
|
+
error(message, Class = Error) {
|
|
1039
|
+
return new Class(`${message}${this}`);
|
|
1040
|
+
}
|
|
1041
|
+
span(row, col, length) {
|
|
1042
|
+
return new $mol_span(this.uri, this.source, row, col, length);
|
|
1043
|
+
}
|
|
1044
|
+
after(length = 0) {
|
|
1045
|
+
return new $mol_span(this.uri, this.source, this.row, this.col + this.length, length);
|
|
1046
|
+
}
|
|
1047
|
+
slice(begin, end = -1) {
|
|
1048
|
+
let len = this.length;
|
|
1049
|
+
if (begin < 0)
|
|
1050
|
+
begin += len;
|
|
1051
|
+
if (end < 0)
|
|
1052
|
+
end += len;
|
|
1053
|
+
if (begin < 0 || begin > len)
|
|
1054
|
+
this.$.$mol_fail(`Begin value '${begin}' out of range ${this}`);
|
|
1055
|
+
if (end < 0 || end > len)
|
|
1056
|
+
this.$.$mol_fail(`End value '${end}' out of range ${this}`);
|
|
1057
|
+
if (end < begin)
|
|
1058
|
+
this.$.$mol_fail(`End value '${end}' can't be less than begin value ${this}`);
|
|
1059
|
+
return this.span(this.row, this.col + begin, end - begin);
|
|
1094
1060
|
}
|
|
1095
|
-
const temp = $mol_wire_task.getter(orig);
|
|
1096
|
-
const value = function (...args) {
|
|
1097
|
-
const fiber = temp(this ?? null, args);
|
|
1098
|
-
return fiber.sync();
|
|
1099
|
-
};
|
|
1100
|
-
Object.defineProperty(value, 'name', { value: orig.name + ' ' });
|
|
1101
|
-
Object.assign(value, { orig });
|
|
1102
|
-
const descr2 = { ...descr, value };
|
|
1103
|
-
Reflect.defineProperty(host, field, descr2);
|
|
1104
|
-
return descr2;
|
|
1105
1061
|
}
|
|
1106
|
-
$.$
|
|
1062
|
+
$.$mol_span = $mol_span;
|
|
1107
1063
|
})($ || ($ = {}));
|
|
1108
|
-
//mol/
|
|
1109
|
-
;
|
|
1110
|
-
"use strict";
|
|
1111
|
-
//mol/type/tail/tail.ts
|
|
1112
|
-
;
|
|
1113
|
-
"use strict";
|
|
1114
|
-
//mol/type/foot/foot.ts
|
|
1064
|
+
//mol/span/span.ts
|
|
1115
1065
|
;
|
|
1116
1066
|
"use strict";
|
|
1117
1067
|
var $;
|
|
1118
1068
|
(function ($) {
|
|
1119
|
-
|
|
1120
|
-
|
|
1121
|
-
|
|
1122
|
-
|
|
1123
|
-
|
|
1124
|
-
|
|
1125
|
-
|
|
1126
|
-
|
|
1127
|
-
|
|
1128
|
-
|
|
1069
|
+
function $mol_tree2_to_string(tree) {
|
|
1070
|
+
let output = [];
|
|
1071
|
+
function dump(tree, prefix = '') {
|
|
1072
|
+
if (tree.type.length) {
|
|
1073
|
+
if (!prefix.length) {
|
|
1074
|
+
prefix = "\t";
|
|
1075
|
+
}
|
|
1076
|
+
output.push(tree.type);
|
|
1077
|
+
if (tree.kids.length == 1) {
|
|
1078
|
+
output.push(' ');
|
|
1079
|
+
dump(tree.kids[0], prefix);
|
|
1080
|
+
return;
|
|
1081
|
+
}
|
|
1082
|
+
output.push("\n");
|
|
1083
|
+
}
|
|
1084
|
+
else if (tree.value.length || prefix.length) {
|
|
1085
|
+
output.push("\\" + tree.value + "\n");
|
|
1086
|
+
}
|
|
1087
|
+
for (const kid of tree.kids) {
|
|
1088
|
+
output.push(prefix);
|
|
1089
|
+
dump(kid, prefix + "\t");
|
|
1090
|
+
}
|
|
1091
|
+
}
|
|
1092
|
+
dump(tree);
|
|
1093
|
+
return output.join('');
|
|
1129
1094
|
}
|
|
1130
|
-
$.$
|
|
1095
|
+
$.$mol_tree2_to_string = $mol_tree2_to_string;
|
|
1131
1096
|
})($ || ($ = {}));
|
|
1132
|
-
//mol/
|
|
1097
|
+
//mol/tree2/to/string/string.ts
|
|
1133
1098
|
;
|
|
1134
1099
|
"use strict";
|
|
1135
1100
|
var $;
|
|
1136
1101
|
(function ($) {
|
|
1137
|
-
|
|
1138
|
-
|
|
1139
|
-
|
|
1140
|
-
|
|
1141
|
-
|
|
1142
|
-
|
|
1143
|
-
|
|
1144
|
-
|
|
1145
|
-
|
|
1146
|
-
|
|
1147
|
-
|
|
1148
|
-
;
|
|
1149
|
-
"use strict";
|
|
1150
|
-
var $;
|
|
1151
|
-
(function ($) {
|
|
1152
|
-
class $mol_wire_atom extends $mol_wire_fiber {
|
|
1153
|
-
static solo(host, task) {
|
|
1154
|
-
const field = task.name + '()';
|
|
1155
|
-
const existen = Object.getOwnPropertyDescriptor(host ?? task, field)?.value;
|
|
1156
|
-
if (existen)
|
|
1157
|
-
return existen;
|
|
1158
|
-
const prefix = host?.[Symbol.toStringTag] ?? (host instanceof Function ? $$.$mol_func_name(host) : host);
|
|
1159
|
-
const key = `${prefix}.${field}`;
|
|
1160
|
-
const fiber = new $mol_wire_atom(key, task, host, []);
|
|
1161
|
-
(host ?? task)[field] = fiber;
|
|
1162
|
-
return fiber;
|
|
1102
|
+
class $mol_tree2 extends Object {
|
|
1103
|
+
type;
|
|
1104
|
+
value;
|
|
1105
|
+
kids;
|
|
1106
|
+
span;
|
|
1107
|
+
constructor(type, value, kids, span) {
|
|
1108
|
+
super();
|
|
1109
|
+
this.type = type;
|
|
1110
|
+
this.value = value;
|
|
1111
|
+
this.kids = kids;
|
|
1112
|
+
this.span = span;
|
|
1113
|
+
this[Symbol.toStringTag] = type || '\\' + value;
|
|
1163
1114
|
}
|
|
1164
|
-
static
|
|
1165
|
-
|
|
1166
|
-
|
|
1167
|
-
|
|
1168
|
-
|
|
1169
|
-
|
|
1170
|
-
|
|
1171
|
-
|
|
1172
|
-
|
|
1173
|
-
|
|
1174
|
-
|
|
1175
|
-
|
|
1115
|
+
static list(kids, span = $mol_span.unknown) {
|
|
1116
|
+
return new $mol_tree2('', '', kids, span);
|
|
1117
|
+
}
|
|
1118
|
+
list(kids) {
|
|
1119
|
+
return $mol_tree2.list(kids, this.span);
|
|
1120
|
+
}
|
|
1121
|
+
static data(value, kids = [], span = $mol_span.unknown) {
|
|
1122
|
+
const chunks = value.split('\n');
|
|
1123
|
+
if (chunks.length > 1) {
|
|
1124
|
+
let kid_span = span.span(span.row, span.col, 0);
|
|
1125
|
+
const data = chunks.map(chunk => {
|
|
1126
|
+
kid_span = kid_span.after(chunk.length);
|
|
1127
|
+
return new $mol_tree2('', chunk, [], kid_span);
|
|
1128
|
+
});
|
|
1129
|
+
kids = [...data, ...kids];
|
|
1130
|
+
value = '';
|
|
1176
1131
|
}
|
|
1177
|
-
|
|
1178
|
-
dict.set(id, fiber);
|
|
1179
|
-
return fiber;
|
|
1132
|
+
return new $mol_tree2('', value, kids, span);
|
|
1180
1133
|
}
|
|
1181
|
-
|
|
1182
|
-
|
|
1183
|
-
|
|
1184
|
-
|
|
1185
|
-
|
|
1186
|
-
|
|
1187
|
-
$mol_wire_atom.watching.delete(atom);
|
|
1188
|
-
}
|
|
1189
|
-
else {
|
|
1190
|
-
atom.cursor = $mol_wire_cursor.stale;
|
|
1191
|
-
atom.fresh();
|
|
1192
|
-
}
|
|
1134
|
+
data(value, kids = []) {
|
|
1135
|
+
return $mol_tree2.data(value, kids, this.span);
|
|
1136
|
+
}
|
|
1137
|
+
static struct(type, kids = [], span = $mol_span.unknown) {
|
|
1138
|
+
if (/[ \n\t\\]/.test(type)) {
|
|
1139
|
+
$$.$mol_fail(span.error(`Wrong type ${JSON.stringify(type)}`));
|
|
1193
1140
|
}
|
|
1141
|
+
return new $mol_tree2(type, '', kids, span);
|
|
1194
1142
|
}
|
|
1195
|
-
|
|
1196
|
-
|
|
1197
|
-
|
|
1143
|
+
struct(type, kids = []) {
|
|
1144
|
+
return $mol_tree2.struct(type, kids, this.span);
|
|
1145
|
+
}
|
|
1146
|
+
clone(kids, span = this.span) {
|
|
1147
|
+
return new $mol_tree2(this.type, this.value, kids, span);
|
|
1148
|
+
}
|
|
1149
|
+
text() {
|
|
1150
|
+
var values = [];
|
|
1151
|
+
for (var kid of this.kids) {
|
|
1152
|
+
if (kid.type)
|
|
1153
|
+
continue;
|
|
1154
|
+
values.push(kid.value);
|
|
1198
1155
|
}
|
|
1199
|
-
|
|
1156
|
+
return this.value + values.join('\n');
|
|
1200
1157
|
}
|
|
1201
|
-
|
|
1202
|
-
return
|
|
1158
|
+
static fromString(str, uri = 'unknown') {
|
|
1159
|
+
return $$.$mol_tree2_from_string(str, uri);
|
|
1203
1160
|
}
|
|
1204
|
-
|
|
1205
|
-
return this
|
|
1161
|
+
toString() {
|
|
1162
|
+
return $$.$mol_tree2_to_string(this);
|
|
1206
1163
|
}
|
|
1207
|
-
|
|
1208
|
-
|
|
1209
|
-
|
|
1210
|
-
|
|
1211
|
-
|
|
1212
|
-
|
|
1213
|
-
|
|
1214
|
-
|
|
1215
|
-
|
|
1216
|
-
|
|
1217
|
-
return
|
|
1164
|
+
insert(value, ...path) {
|
|
1165
|
+
if (path.length === 0)
|
|
1166
|
+
return value;
|
|
1167
|
+
const type = path[0];
|
|
1168
|
+
if (typeof type === 'string') {
|
|
1169
|
+
let replaced = false;
|
|
1170
|
+
const sub = this.kids.map((item, index) => {
|
|
1171
|
+
if (item.type !== type)
|
|
1172
|
+
return item;
|
|
1173
|
+
replaced = true;
|
|
1174
|
+
return item.insert(value, ...path.slice(1));
|
|
1175
|
+
}).filter(Boolean);
|
|
1176
|
+
if (!replaced && value) {
|
|
1177
|
+
sub.push(this.struct(type, []).insert(value, ...path.slice(1)));
|
|
1218
1178
|
}
|
|
1219
|
-
|
|
1220
|
-
}
|
|
1221
|
-
destructor() {
|
|
1222
|
-
super.destructor();
|
|
1223
|
-
const prev = this.cache;
|
|
1224
|
-
if ($mol_owning_check(this, prev)) {
|
|
1225
|
-
prev.destructor();
|
|
1179
|
+
return this.clone(sub);
|
|
1226
1180
|
}
|
|
1227
|
-
if (
|
|
1228
|
-
;
|
|
1229
|
-
(
|
|
1181
|
+
else if (typeof type === 'number') {
|
|
1182
|
+
const sub = this.kids.slice();
|
|
1183
|
+
sub[type] = (sub[type] || this.list([]))
|
|
1184
|
+
.insert(value, ...path.slice(1));
|
|
1185
|
+
return this.clone(sub.filter(Boolean));
|
|
1230
1186
|
}
|
|
1231
1187
|
else {
|
|
1232
|
-
|
|
1233
|
-
|
|
1188
|
+
const kids = ((this.kids.length === 0) ? [this.list([])] : this.kids)
|
|
1189
|
+
.map(item => item.insert(value, ...path.slice(1)))
|
|
1190
|
+
.filter(Boolean);
|
|
1191
|
+
return this.clone(kids);
|
|
1234
1192
|
}
|
|
1235
1193
|
}
|
|
1236
|
-
|
|
1237
|
-
|
|
1238
|
-
|
|
1239
|
-
|
|
1240
|
-
|
|
1241
|
-
|
|
1194
|
+
select(...path) {
|
|
1195
|
+
let next = [this];
|
|
1196
|
+
for (const type of path) {
|
|
1197
|
+
if (!next.length)
|
|
1198
|
+
break;
|
|
1199
|
+
const prev = next;
|
|
1200
|
+
next = [];
|
|
1201
|
+
for (var item of prev) {
|
|
1202
|
+
switch (typeof (type)) {
|
|
1203
|
+
case 'string':
|
|
1204
|
+
for (var child of item.kids) {
|
|
1205
|
+
if (child.type == type) {
|
|
1206
|
+
next.push(child);
|
|
1207
|
+
}
|
|
1208
|
+
}
|
|
1209
|
+
break;
|
|
1210
|
+
case 'number':
|
|
1211
|
+
if (type < item.kids.length)
|
|
1212
|
+
next.push(item.kids[type]);
|
|
1213
|
+
break;
|
|
1214
|
+
default: next.push(...item.kids);
|
|
1215
|
+
}
|
|
1242
1216
|
}
|
|
1243
|
-
|
|
1244
|
-
|
|
1217
|
+
}
|
|
1218
|
+
return this.list(next);
|
|
1219
|
+
}
|
|
1220
|
+
filter(path, value) {
|
|
1221
|
+
const sub = this.kids.filter(item => {
|
|
1222
|
+
var found = item.select(...path);
|
|
1223
|
+
if (value === undefined) {
|
|
1224
|
+
return Boolean(found.kids.length);
|
|
1245
1225
|
}
|
|
1246
|
-
|
|
1247
|
-
|
|
1226
|
+
else {
|
|
1227
|
+
return found.kids.some(child => child.value == value);
|
|
1248
1228
|
}
|
|
1249
|
-
|
|
1250
|
-
|
|
1251
|
-
|
|
1252
|
-
|
|
1253
|
-
|
|
1254
|
-
|
|
1255
|
-
|
|
1229
|
+
});
|
|
1230
|
+
return this.clone(sub);
|
|
1231
|
+
}
|
|
1232
|
+
hack(belt, context = {}) {
|
|
1233
|
+
return [].concat(...this.kids.map(child => {
|
|
1234
|
+
let handle = belt[child.type] || belt[''];
|
|
1235
|
+
if (!handle || handle === Object.prototype[child.type]) {
|
|
1236
|
+
handle = (input, belt, context) => [
|
|
1237
|
+
input.clone(input.hack(belt, context), context.span)
|
|
1238
|
+
];
|
|
1256
1239
|
}
|
|
1257
|
-
|
|
1258
|
-
|
|
1259
|
-
|
|
1260
|
-
|
|
1261
|
-
|
|
1262
|
-
|
|
1263
|
-
|
|
1264
|
-
|
|
1265
|
-
|
|
1240
|
+
try {
|
|
1241
|
+
return handle(child, belt, context);
|
|
1242
|
+
}
|
|
1243
|
+
catch (error) {
|
|
1244
|
+
error.message += `\n${child.clone([])}${child.span}`;
|
|
1245
|
+
$mol_fail_hidden(error);
|
|
1246
|
+
}
|
|
1247
|
+
}));
|
|
1248
|
+
}
|
|
1249
|
+
error(message, Class = Error) {
|
|
1250
|
+
return this.span.error(`${message}\n${this.clone([])}`, Class);
|
|
1266
1251
|
}
|
|
1267
1252
|
}
|
|
1268
|
-
|
|
1269
|
-
|
|
1270
|
-
|
|
1271
|
-
|
|
1272
|
-
|
|
1273
|
-
|
|
1274
|
-
$.$
|
|
1253
|
+
$.$mol_tree2 = $mol_tree2;
|
|
1254
|
+
class $mol_tree2_empty extends $mol_tree2 {
|
|
1255
|
+
constructor() {
|
|
1256
|
+
super('', '', [], $mol_span.unknown);
|
|
1257
|
+
}
|
|
1258
|
+
}
|
|
1259
|
+
$.$mol_tree2_empty = $mol_tree2_empty;
|
|
1275
1260
|
})($ || ($ = {}));
|
|
1276
|
-
//mol/
|
|
1261
|
+
//mol/tree2/tree2.ts
|
|
1277
1262
|
;
|
|
1278
1263
|
"use strict";
|
|
1279
1264
|
var $;
|
|
1280
1265
|
(function ($) {
|
|
1281
|
-
|
|
1282
|
-
|
|
1283
|
-
|
|
1284
|
-
|
|
1285
|
-
|
|
1286
|
-
|
|
1287
|
-
|
|
1288
|
-
|
|
1289
|
-
|
|
1290
|
-
|
|
1291
|
-
|
|
1292
|
-
|
|
1293
|
-
}
|
|
1294
|
-
$.$mol_wire_probe = $mol_wire_probe;
|
|
1266
|
+
class $mol_error_syntax extends SyntaxError {
|
|
1267
|
+
reason;
|
|
1268
|
+
line;
|
|
1269
|
+
span;
|
|
1270
|
+
constructor(reason, line, span) {
|
|
1271
|
+
super(`${reason}\n${span}\n${line.substring(0, span.col - 1).replace(/\S/g, ' ')}${''.padEnd(span.length, '!')}\n${line}`);
|
|
1272
|
+
this.reason = reason;
|
|
1273
|
+
this.line = line;
|
|
1274
|
+
this.span = span;
|
|
1275
|
+
}
|
|
1276
|
+
}
|
|
1277
|
+
$.$mol_error_syntax = $mol_error_syntax;
|
|
1295
1278
|
})($ || ($ = {}));
|
|
1296
|
-
//mol/
|
|
1279
|
+
//mol/error/syntax/syntax.ts
|
|
1297
1280
|
;
|
|
1298
1281
|
"use strict";
|
|
1299
1282
|
var $;
|
|
1300
1283
|
(function ($) {
|
|
1301
|
-
function $
|
|
1302
|
-
const
|
|
1303
|
-
|
|
1304
|
-
|
|
1284
|
+
function $mol_tree2_from_string(str, uri = '?') {
|
|
1285
|
+
const span = $mol_span.entire(uri, str);
|
|
1286
|
+
var root = $mol_tree2.list([], span);
|
|
1287
|
+
var stack = [root];
|
|
1288
|
+
var pos = 0, row = 0, min_indent = 0;
|
|
1289
|
+
while (str.length > pos) {
|
|
1290
|
+
var indent = 0;
|
|
1291
|
+
var line_start = pos;
|
|
1292
|
+
row++;
|
|
1293
|
+
while (str.length > pos && str[pos] == '\t') {
|
|
1294
|
+
indent++;
|
|
1295
|
+
pos++;
|
|
1296
|
+
}
|
|
1297
|
+
if (!root.kids.length) {
|
|
1298
|
+
min_indent = indent;
|
|
1299
|
+
}
|
|
1300
|
+
indent -= min_indent;
|
|
1301
|
+
if (indent < 0 || indent >= stack.length) {
|
|
1302
|
+
const sp = span.span(row, 1, pos - line_start);
|
|
1303
|
+
while (str.length > pos && str[pos] != '\n') {
|
|
1304
|
+
pos++;
|
|
1305
|
+
}
|
|
1306
|
+
if (indent < 0) {
|
|
1307
|
+
if (str.length > pos) {
|
|
1308
|
+
this.$mol_fail(new this.$mol_error_syntax(`Too few tabs`, str.substring(line_start, pos), sp));
|
|
1309
|
+
}
|
|
1310
|
+
}
|
|
1311
|
+
else {
|
|
1312
|
+
this.$mol_fail(new this.$mol_error_syntax(`Too many tabs`, str.substring(line_start, pos), sp));
|
|
1313
|
+
}
|
|
1314
|
+
}
|
|
1315
|
+
stack.length = indent + 1;
|
|
1316
|
+
var parent = stack[indent];
|
|
1317
|
+
while (str.length > pos && str[pos] != '\\' && str[pos] != '\n') {
|
|
1318
|
+
var error_start = pos;
|
|
1319
|
+
while (str.length > pos && (str[pos] == ' ' || str[pos] == '\t')) {
|
|
1320
|
+
pos++;
|
|
1321
|
+
}
|
|
1322
|
+
if (pos > error_start) {
|
|
1323
|
+
let line_end = str.indexOf('\n', pos);
|
|
1324
|
+
if (line_end === -1)
|
|
1325
|
+
line_end = str.length;
|
|
1326
|
+
const sp = span.span(row, error_start - line_start + 1, pos - error_start);
|
|
1327
|
+
this.$mol_fail(new this.$mol_error_syntax(`Wrong nodes separator`, str.substring(line_start, line_end), sp));
|
|
1328
|
+
}
|
|
1329
|
+
var type_start = pos;
|
|
1330
|
+
while (str.length > pos &&
|
|
1331
|
+
str[pos] != '\\' &&
|
|
1332
|
+
str[pos] != ' ' &&
|
|
1333
|
+
str[pos] != '\t' &&
|
|
1334
|
+
str[pos] != '\n') {
|
|
1335
|
+
pos++;
|
|
1336
|
+
}
|
|
1337
|
+
if (pos > type_start) {
|
|
1338
|
+
let next = new $mol_tree2(str.slice(type_start, pos), '', [], span.span(row, type_start - line_start + 1, pos - type_start));
|
|
1339
|
+
const parent_kids = parent.kids;
|
|
1340
|
+
parent_kids.push(next);
|
|
1341
|
+
parent = next;
|
|
1342
|
+
}
|
|
1343
|
+
if (str.length > pos && str[pos] == ' ') {
|
|
1344
|
+
pos++;
|
|
1345
|
+
}
|
|
1346
|
+
}
|
|
1347
|
+
if (str.length > pos && str[pos] == '\\') {
|
|
1348
|
+
var data_start = pos;
|
|
1349
|
+
while (str.length > pos && str[pos] != '\n') {
|
|
1350
|
+
pos++;
|
|
1351
|
+
}
|
|
1352
|
+
let next = new $mol_tree2('', str.slice(data_start + 1, pos), [], span.span(row, data_start - line_start + 2, pos - data_start - 1));
|
|
1353
|
+
const parent_kids = parent.kids;
|
|
1354
|
+
parent_kids.push(next);
|
|
1355
|
+
parent = next;
|
|
1356
|
+
}
|
|
1357
|
+
if (str.length === pos && stack.length > 0) {
|
|
1358
|
+
const sp = span.span(row, pos - line_start + 1, 1);
|
|
1359
|
+
this.$mol_fail(new this.$mol_error_syntax(`Unexpected EOF, LF required`, str.substring(line_start, str.length), sp));
|
|
1360
|
+
}
|
|
1361
|
+
stack.push(parent);
|
|
1362
|
+
pos++;
|
|
1305
1363
|
}
|
|
1306
|
-
|
|
1364
|
+
return root;
|
|
1307
1365
|
}
|
|
1308
|
-
$.$
|
|
1309
|
-
const nothing = () => { };
|
|
1310
|
-
const sub = new $mol_wire_pub_sub;
|
|
1366
|
+
$.$mol_tree2_from_string = $mol_tree2_from_string;
|
|
1311
1367
|
})($ || ($ = {}));
|
|
1312
|
-
//mol/
|
|
1368
|
+
//mol/tree2/from/string/string.ts
|
|
1313
1369
|
;
|
|
1314
1370
|
"use strict";
|
|
1315
1371
|
var $;
|
|
1316
1372
|
(function ($) {
|
|
1317
|
-
function $
|
|
1318
|
-
|
|
1319
|
-
|
|
1320
|
-
atom.watch();
|
|
1373
|
+
function $mol_tree2_from_json(json, span = $mol_span.unknown) {
|
|
1374
|
+
if (typeof json === 'boolean' || typeof json === 'number' || json === null) {
|
|
1375
|
+
return new $mol_tree2(String(json), '', [], span);
|
|
1321
1376
|
}
|
|
1322
|
-
|
|
1323
|
-
$
|
|
1377
|
+
if (typeof json === 'string') {
|
|
1378
|
+
return $mol_tree2.data(json, [], span);
|
|
1379
|
+
}
|
|
1380
|
+
if (Array.isArray(json)) {
|
|
1381
|
+
const sub = json.map(json => $mol_tree2_from_json(json, span));
|
|
1382
|
+
return new $mol_tree2('/', '', sub, span);
|
|
1383
|
+
}
|
|
1384
|
+
if (ArrayBuffer.isView(json)) {
|
|
1385
|
+
const buf = new Uint8Array(json.buffer, json.byteOffset, json.byteLength);
|
|
1386
|
+
return $mol_tree2.data(String.fromCharCode(...buf), [], span);
|
|
1387
|
+
}
|
|
1388
|
+
if (json instanceof Date) {
|
|
1389
|
+
return new $mol_tree2('', json.toISOString(), [], span);
|
|
1390
|
+
}
|
|
1391
|
+
if (typeof json.toJSON === 'function') {
|
|
1392
|
+
return $mol_tree2_from_json(json.toJSON());
|
|
1393
|
+
}
|
|
1394
|
+
if (json instanceof Error) {
|
|
1395
|
+
const { name, message, stack } = json;
|
|
1396
|
+
json = { ...json, name, message, stack };
|
|
1397
|
+
}
|
|
1398
|
+
const sub = [];
|
|
1399
|
+
for (var key in json) {
|
|
1400
|
+
const val = json[key];
|
|
1401
|
+
if (val === undefined)
|
|
1402
|
+
continue;
|
|
1403
|
+
const subsub = $mol_tree2_from_json(val, span);
|
|
1404
|
+
if (/^[^\n\t\\ ]+$/.test(key)) {
|
|
1405
|
+
sub.push(new $mol_tree2(key, '', [subsub], span));
|
|
1406
|
+
}
|
|
1407
|
+
else {
|
|
1408
|
+
sub.push($mol_tree2.data(key, [subsub], span));
|
|
1409
|
+
}
|
|
1324
1410
|
}
|
|
1411
|
+
return new $mol_tree2('*', '', sub, span);
|
|
1325
1412
|
}
|
|
1326
|
-
$.$
|
|
1413
|
+
$.$mol_tree2_from_json = $mol_tree2_from_json;
|
|
1327
1414
|
})($ || ($ = {}));
|
|
1328
|
-
//mol/
|
|
1415
|
+
//mol/tree2/from/json/json.ts
|
|
1329
1416
|
;
|
|
1330
1417
|
"use strict";
|
|
1331
1418
|
var $;
|
|
1332
1419
|
(function ($) {
|
|
1333
|
-
|
|
1334
|
-
|
|
1335
|
-
|
|
1336
|
-
|
|
1337
|
-
|
|
1338
|
-
|
|
1339
|
-
|
|
1340
|
-
|
|
1341
|
-
|
|
1342
|
-
|
|
1343
|
-
|
|
1344
|
-
|
|
1345
|
-
|
|
1346
|
-
|
|
1347
|
-
|
|
1348
|
-
|
|
1349
|
-
|
|
1350
|
-
|
|
1420
|
+
class $mol_term_color {
|
|
1421
|
+
static reset = this.ansi(0, 0);
|
|
1422
|
+
static bold = this.ansi(1, 22);
|
|
1423
|
+
static italic = this.ansi(3, 23);
|
|
1424
|
+
static underline = this.ansi(4, 24);
|
|
1425
|
+
static inverse = this.ansi(7, 27);
|
|
1426
|
+
static hidden = this.ansi(8, 28);
|
|
1427
|
+
static strike = this.ansi(9, 29);
|
|
1428
|
+
static gray = this.ansi(90, 39);
|
|
1429
|
+
static red = this.ansi(91, 39);
|
|
1430
|
+
static green = this.ansi(92, 39);
|
|
1431
|
+
static yellow = this.ansi(93, 39);
|
|
1432
|
+
static blue = this.ansi(94, 39);
|
|
1433
|
+
static magenta = this.ansi(95, 39);
|
|
1434
|
+
static cyan = this.ansi(96, 39);
|
|
1435
|
+
static Gray = (str) => this.inverse(this.gray(str));
|
|
1436
|
+
static Red = (str) => this.inverse(this.red(str));
|
|
1437
|
+
static Green = (str) => this.inverse(this.green(str));
|
|
1438
|
+
static Yellow = (str) => this.inverse(this.yellow(str));
|
|
1439
|
+
static Blue = (str) => this.inverse(this.blue(str));
|
|
1440
|
+
static Magenta = (str) => this.inverse(this.magenta(str));
|
|
1441
|
+
static Cyan = (str) => this.inverse(this.cyan(str));
|
|
1442
|
+
static ansi(open, close) {
|
|
1443
|
+
if (typeof process === 'undefined')
|
|
1444
|
+
return String;
|
|
1445
|
+
if (!process.stdout.isTTY)
|
|
1446
|
+
return String;
|
|
1447
|
+
const prefix = `\x1b[${open}m`;
|
|
1448
|
+
const postfix = `\x1b[${close}m`;
|
|
1449
|
+
const suffix_regexp = new RegExp(postfix.replace('[', '\\['), 'g');
|
|
1450
|
+
return function colorer(str) {
|
|
1451
|
+
str = String(str);
|
|
1452
|
+
if (str === '')
|
|
1453
|
+
return str;
|
|
1454
|
+
const suffix = str.replace(suffix_regexp, prefix);
|
|
1455
|
+
return prefix + suffix + postfix;
|
|
1456
|
+
};
|
|
1457
|
+
}
|
|
1351
1458
|
}
|
|
1352
|
-
$.$
|
|
1459
|
+
$.$mol_term_color = $mol_term_color;
|
|
1353
1460
|
})($ || ($ = {}));
|
|
1354
|
-
//mol/
|
|
1461
|
+
//mol/term/color/color.ts
|
|
1355
1462
|
;
|
|
1356
1463
|
"use strict";
|
|
1357
1464
|
var $;
|
|
1358
1465
|
(function ($) {
|
|
1359
|
-
function $
|
|
1360
|
-
|
|
1361
|
-
|
|
1362
|
-
|
|
1363
|
-
|
|
1364
|
-
|
|
1365
|
-
|
|
1366
|
-
|
|
1367
|
-
|
|
1368
|
-
|
|
1369
|
-
|
|
1370
|
-
fiber?.destructor();
|
|
1371
|
-
fiber = temp(obj, args);
|
|
1372
|
-
return fiber.async();
|
|
1373
|
-
};
|
|
1374
|
-
},
|
|
1375
|
-
apply(obj, self, args) {
|
|
1376
|
-
fiber?.destructor();
|
|
1377
|
-
fiber = temp(self, args);
|
|
1378
|
-
return fiber.async();
|
|
1379
|
-
},
|
|
1380
|
-
});
|
|
1466
|
+
function $mol_log3_node_make(level, output, type, color) {
|
|
1467
|
+
return function $mol_log3_logger(event) {
|
|
1468
|
+
if (!event.time)
|
|
1469
|
+
event = { time: new Date().toISOString(), ...event };
|
|
1470
|
+
let tree = this.$mol_tree2_from_json(event);
|
|
1471
|
+
tree = tree.struct(type, tree.kids);
|
|
1472
|
+
let str = color(tree.toString());
|
|
1473
|
+
this.console[level](str);
|
|
1474
|
+
const self = this;
|
|
1475
|
+
return () => self.console.groupEnd();
|
|
1476
|
+
};
|
|
1381
1477
|
}
|
|
1382
|
-
$.$
|
|
1478
|
+
$.$mol_log3_node_make = $mol_log3_node_make;
|
|
1479
|
+
$.$mol_log3_come = $mol_log3_node_make('info', 'stdout', 'come', $mol_term_color.blue);
|
|
1480
|
+
$.$mol_log3_done = $mol_log3_node_make('info', 'stdout', 'done', $mol_term_color.green);
|
|
1481
|
+
$.$mol_log3_fail = $mol_log3_node_make('error', 'stderr', 'fail', $mol_term_color.red);
|
|
1482
|
+
$.$mol_log3_warn = $mol_log3_node_make('warn', 'stderr', 'warn', $mol_term_color.yellow);
|
|
1483
|
+
$.$mol_log3_rise = $mol_log3_node_make('log', 'stdout', 'rise', $mol_term_color.magenta);
|
|
1484
|
+
$.$mol_log3_area = $mol_log3_node_make('log', 'stdout', 'area', $mol_term_color.cyan);
|
|
1383
1485
|
})($ || ($ = {}));
|
|
1384
|
-
//mol/
|
|
1486
|
+
//mol/log3/log3.node.ts
|
|
1385
1487
|
;
|
|
1386
1488
|
"use strict";
|
|
1387
1489
|
var $;
|
|
1388
1490
|
(function ($) {
|
|
1389
|
-
|
|
1390
|
-
|
|
1391
|
-
|
|
1392
|
-
|
|
1393
|
-
|
|
1394
|
-
|
|
1395
|
-
|
|
1491
|
+
class $mol_wire_task extends $mol_wire_fiber {
|
|
1492
|
+
static getter(task) {
|
|
1493
|
+
return function $mol_wire_task_get(host, args) {
|
|
1494
|
+
const sub = $mol_wire_auto();
|
|
1495
|
+
const existen = sub?.track_next();
|
|
1496
|
+
reuse: if (existen) {
|
|
1497
|
+
if (!existen.temp)
|
|
1498
|
+
break reuse;
|
|
1499
|
+
if (existen.host !== host)
|
|
1500
|
+
break reuse;
|
|
1501
|
+
if (existen.task !== task)
|
|
1502
|
+
break reuse;
|
|
1503
|
+
if (!$mol_compare_deep(existen.args, args))
|
|
1504
|
+
break reuse;
|
|
1505
|
+
return existen;
|
|
1506
|
+
}
|
|
1507
|
+
const next = new $mol_wire_task(`${host?.[Symbol.toStringTag] ?? host}.${task.name}(#)`, task, host, args);
|
|
1508
|
+
if (existen?.temp) {
|
|
1509
|
+
$$.$mol_log3_warn({
|
|
1510
|
+
place: '$mol_wire_task',
|
|
1511
|
+
message: `Non idempotency`,
|
|
1512
|
+
existen,
|
|
1513
|
+
next,
|
|
1514
|
+
hint: 'Ignore it',
|
|
1515
|
+
});
|
|
1516
|
+
}
|
|
1517
|
+
return next;
|
|
1518
|
+
};
|
|
1519
|
+
}
|
|
1520
|
+
get temp() {
|
|
1521
|
+
return true;
|
|
1522
|
+
}
|
|
1523
|
+
complete() {
|
|
1524
|
+
if ($mol_promise_like(this.cache))
|
|
1525
|
+
return;
|
|
1526
|
+
this.destructor();
|
|
1527
|
+
}
|
|
1528
|
+
put(next) {
|
|
1529
|
+
const prev = this.cache;
|
|
1530
|
+
this.cache = next;
|
|
1531
|
+
if ($mol_promise_like(next)) {
|
|
1532
|
+
this.cursor = $mol_wire_cursor.fresh;
|
|
1533
|
+
if (next !== prev)
|
|
1534
|
+
this.emit();
|
|
1535
|
+
return next;
|
|
1396
1536
|
}
|
|
1397
|
-
|
|
1398
|
-
|
|
1399
|
-
|
|
1400
|
-
|
|
1401
|
-
|
|
1402
|
-
|
|
1403
|
-
|
|
1404
|
-
return results;
|
|
1537
|
+
this.cursor = $mol_wire_cursor.final;
|
|
1538
|
+
if (this.sub_empty)
|
|
1539
|
+
this.destructor();
|
|
1540
|
+
else if (next !== prev)
|
|
1541
|
+
this.emit();
|
|
1542
|
+
return next;
|
|
1543
|
+
}
|
|
1405
1544
|
}
|
|
1406
|
-
$.$
|
|
1545
|
+
$.$mol_wire_task = $mol_wire_task;
|
|
1407
1546
|
})($ || ($ = {}));
|
|
1408
|
-
//mol/wire/
|
|
1547
|
+
//mol/wire/task/task.ts
|
|
1409
1548
|
;
|
|
1410
1549
|
"use strict";
|
|
1411
1550
|
var $;
|
|
1412
1551
|
(function ($) {
|
|
1413
|
-
function $
|
|
1414
|
-
|
|
1415
|
-
|
|
1416
|
-
|
|
1417
|
-
|
|
1418
|
-
|
|
1419
|
-
Object.defineProperty(orig, 'name', { value: sup[field].name });
|
|
1552
|
+
function $mol_guid(length = 8, exists = () => false) {
|
|
1553
|
+
for (;;) {
|
|
1554
|
+
let id = Math.random().toString(36).substring(2, length + 2).toUpperCase();
|
|
1555
|
+
if (exists(id))
|
|
1556
|
+
continue;
|
|
1557
|
+
return id;
|
|
1420
1558
|
}
|
|
1421
|
-
const descr2 = {
|
|
1422
|
-
...descr,
|
|
1423
|
-
value: function (...args) {
|
|
1424
|
-
let atom = $mol_wire_atom.solo(this, orig);
|
|
1425
|
-
if ((args.length === 0) || (args[0] === undefined)) {
|
|
1426
|
-
if (!$mol_wire_fiber.warm)
|
|
1427
|
-
return atom.result();
|
|
1428
|
-
if ($mol_wire_auto()?.temp) {
|
|
1429
|
-
return atom.once();
|
|
1430
|
-
}
|
|
1431
|
-
else {
|
|
1432
|
-
return atom.sync();
|
|
1433
|
-
}
|
|
1434
|
-
}
|
|
1435
|
-
return atom.resync(args);
|
|
1436
|
-
}
|
|
1437
|
-
};
|
|
1438
|
-
Reflect.defineProperty(descr2.value, 'name', { value: orig.name + ' ' });
|
|
1439
|
-
Reflect.defineProperty(descr2.value, 'length', { value: orig.length });
|
|
1440
|
-
Object.assign(descr2.value, { orig });
|
|
1441
|
-
Reflect.defineProperty(host, field, descr2);
|
|
1442
|
-
return descr2;
|
|
1443
1559
|
}
|
|
1444
|
-
$.$
|
|
1560
|
+
$.$mol_guid = $mol_guid;
|
|
1445
1561
|
})($ || ($ = {}));
|
|
1446
|
-
//mol/
|
|
1562
|
+
//mol/guid/guid.ts
|
|
1447
1563
|
;
|
|
1448
1564
|
"use strict";
|
|
1449
1565
|
var $;
|
|
1450
1566
|
(function ($) {
|
|
1451
|
-
|
|
1567
|
+
$.$mol_key_store = new WeakMap();
|
|
1568
|
+
function $mol_key(value) {
|
|
1569
|
+
if (typeof value === 'bigint')
|
|
1570
|
+
return value.toString() + 'n';
|
|
1571
|
+
if (!value)
|
|
1572
|
+
return JSON.stringify(value);
|
|
1573
|
+
if (typeof value !== 'object' && typeof value !== 'function')
|
|
1574
|
+
return JSON.stringify(value);
|
|
1575
|
+
return JSON.stringify(value, (field, value) => {
|
|
1576
|
+
if (typeof value === 'bigint')
|
|
1577
|
+
return value.toString() + 'n';
|
|
1578
|
+
if (!value)
|
|
1579
|
+
return value;
|
|
1580
|
+
if (typeof value !== 'object' && typeof value !== 'function')
|
|
1581
|
+
return value;
|
|
1582
|
+
if (Array.isArray(value))
|
|
1583
|
+
return value;
|
|
1584
|
+
const proto = Reflect.getPrototypeOf(value);
|
|
1585
|
+
if (!proto)
|
|
1586
|
+
return value;
|
|
1587
|
+
if (Reflect.getPrototypeOf(proto) === null)
|
|
1588
|
+
return value;
|
|
1589
|
+
if ('toJSON' in value)
|
|
1590
|
+
return value;
|
|
1591
|
+
if (value instanceof RegExp)
|
|
1592
|
+
return value.toString();
|
|
1593
|
+
if (value instanceof Uint8Array)
|
|
1594
|
+
return [...value];
|
|
1595
|
+
let key = $.$mol_key_store.get(value);
|
|
1596
|
+
if (key)
|
|
1597
|
+
return key;
|
|
1598
|
+
key = $mol_guid();
|
|
1599
|
+
$.$mol_key_store.set(value, key);
|
|
1600
|
+
return key;
|
|
1601
|
+
});
|
|
1602
|
+
}
|
|
1603
|
+
$.$mol_key = $mol_key;
|
|
1604
|
+
})($ || ($ = {}));
|
|
1605
|
+
//mol/key/key.ts
|
|
1606
|
+
;
|
|
1607
|
+
"use strict";
|
|
1608
|
+
var $;
|
|
1609
|
+
(function ($) {
|
|
1610
|
+
function $mol_wire_method(host, field, descr) {
|
|
1452
1611
|
if (!descr)
|
|
1453
1612
|
descr = Reflect.getOwnPropertyDescriptor(host, field);
|
|
1454
1613
|
const orig = descr?.value ?? host[field];
|
|
@@ -1456,889 +1615,740 @@ var $;
|
|
|
1456
1615
|
if (typeof sup[field] === 'function') {
|
|
1457
1616
|
Object.defineProperty(orig, 'name', { value: sup[field].name });
|
|
1458
1617
|
}
|
|
1459
|
-
const
|
|
1460
|
-
|
|
1461
|
-
|
|
1462
|
-
|
|
1463
|
-
if ((args.length === 1) || (args[1] === undefined)) {
|
|
1464
|
-
if (!$mol_wire_fiber.warm)
|
|
1465
|
-
return atom.result();
|
|
1466
|
-
if ($mol_wire_auto()?.temp) {
|
|
1467
|
-
return atom.once();
|
|
1468
|
-
}
|
|
1469
|
-
else {
|
|
1470
|
-
return atom.sync();
|
|
1471
|
-
}
|
|
1472
|
-
}
|
|
1473
|
-
return atom.resync(args);
|
|
1474
|
-
}
|
|
1618
|
+
const temp = $mol_wire_task.getter(orig);
|
|
1619
|
+
const value = function (...args) {
|
|
1620
|
+
const fiber = temp(this ?? null, args);
|
|
1621
|
+
return fiber.sync();
|
|
1475
1622
|
};
|
|
1476
|
-
|
|
1477
|
-
|
|
1478
|
-
|
|
1623
|
+
Object.defineProperty(value, 'name', { value: orig.name + ' ' });
|
|
1624
|
+
Object.assign(value, { orig });
|
|
1625
|
+
const descr2 = { ...descr, value };
|
|
1479
1626
|
Reflect.defineProperty(host, field, descr2);
|
|
1480
1627
|
return descr2;
|
|
1481
1628
|
}
|
|
1482
|
-
$.$
|
|
1629
|
+
$.$mol_wire_method = $mol_wire_method;
|
|
1483
1630
|
})($ || ($ = {}));
|
|
1484
|
-
//mol/wire/
|
|
1631
|
+
//mol/wire/method/method.ts
|
|
1485
1632
|
;
|
|
1486
1633
|
"use strict";
|
|
1487
|
-
|
|
1488
|
-
|
|
1489
|
-
|
|
1490
|
-
|
|
1491
|
-
getter['()'] = value;
|
|
1492
|
-
getter[Symbol.toStringTag] = value;
|
|
1493
|
-
getter[$mol_dev_format_head] = () => $mol_dev_format_span({}, '()=> ', $mol_dev_format_auto(value));
|
|
1494
|
-
return getter;
|
|
1495
|
-
}
|
|
1496
|
-
$.$mol_const = $mol_const;
|
|
1497
|
-
})($ || ($ = {}));
|
|
1498
|
-
//mol/const/const.ts
|
|
1634
|
+
//mol/type/tail/tail.ts
|
|
1635
|
+
;
|
|
1636
|
+
"use strict";
|
|
1637
|
+
//mol/type/foot/foot.ts
|
|
1499
1638
|
;
|
|
1500
1639
|
"use strict";
|
|
1501
1640
|
var $;
|
|
1502
1641
|
(function ($) {
|
|
1503
|
-
|
|
1504
|
-
|
|
1505
|
-
|
|
1506
|
-
|
|
1507
|
-
|
|
1508
|
-
$
|
|
1509
|
-
|
|
1510
|
-
|
|
1511
|
-
|
|
1512
|
-
|
|
1513
|
-
Object.defineProperty(_set, 'name', { value: sup_descr?.set?.name ?? field });
|
|
1514
|
-
function get() {
|
|
1515
|
-
return $mol_wire_atom.solo(this, _get).sync();
|
|
1516
|
-
}
|
|
1517
|
-
const temp = $mol_wire_task.getter(_set);
|
|
1518
|
-
function set(next) {
|
|
1519
|
-
temp(this, [next]).sync();
|
|
1520
|
-
}
|
|
1521
|
-
Object.defineProperty(get, 'name', { value: _get.name + '$' });
|
|
1522
|
-
Object.defineProperty(set, 'name', { value: _set.name + '@' });
|
|
1523
|
-
Object.assign(get, { orig: _get });
|
|
1524
|
-
Object.assign(set, { orig: _set });
|
|
1525
|
-
const { value, writable, ...descr2 } = { ...descr, get, set };
|
|
1526
|
-
Reflect.defineProperty(host, field, descr2);
|
|
1527
|
-
return descr2;
|
|
1642
|
+
const catched = new WeakMap();
|
|
1643
|
+
function $mol_fail_catch(error) {
|
|
1644
|
+
if (typeof error !== 'object')
|
|
1645
|
+
return false;
|
|
1646
|
+
if ($mol_promise_like(error))
|
|
1647
|
+
$mol_fail_hidden(error);
|
|
1648
|
+
if (catched.get(error))
|
|
1649
|
+
return false;
|
|
1650
|
+
catched.set(error, true);
|
|
1651
|
+
return true;
|
|
1528
1652
|
}
|
|
1529
|
-
$.$
|
|
1653
|
+
$.$mol_fail_catch = $mol_fail_catch;
|
|
1530
1654
|
})($ || ($ = {}));
|
|
1531
|
-
//mol/
|
|
1655
|
+
//mol/fail/catch/catch.ts
|
|
1532
1656
|
;
|
|
1533
1657
|
"use strict";
|
|
1534
1658
|
var $;
|
|
1535
|
-
(function ($
|
|
1536
|
-
|
|
1537
|
-
|
|
1538
|
-
|
|
1539
|
-
|
|
1540
|
-
|
|
1541
|
-
|
|
1542
|
-
|
|
1543
|
-
return super.create(obj => {
|
|
1544
|
-
for (let key in config)
|
|
1545
|
-
obj[key] = config[key];
|
|
1546
|
-
});
|
|
1547
|
-
}
|
|
1659
|
+
(function ($) {
|
|
1660
|
+
function $mol_fail_log(error) {
|
|
1661
|
+
if ($mol_promise_like(error))
|
|
1662
|
+
return false;
|
|
1663
|
+
if (!$mol_fail_catch(error))
|
|
1664
|
+
return false;
|
|
1665
|
+
console.error(error);
|
|
1666
|
+
return true;
|
|
1548
1667
|
}
|
|
1549
|
-
|
|
1668
|
+
$.$mol_fail_log = $mol_fail_log;
|
|
1550
1669
|
})($ || ($ = {}));
|
|
1551
|
-
//mol/
|
|
1670
|
+
//mol/fail/log/log.ts
|
|
1552
1671
|
;
|
|
1553
1672
|
"use strict";
|
|
1554
1673
|
var $;
|
|
1555
1674
|
(function ($) {
|
|
1556
|
-
|
|
1557
|
-
|
|
1558
|
-
|
|
1559
|
-
|
|
1560
|
-
|
|
1561
|
-
|
|
1562
|
-
|
|
1563
|
-
|
|
1564
|
-
|
|
1565
|
-
|
|
1566
|
-
|
|
1567
|
-
|
|
1675
|
+
class $mol_wire_atom extends $mol_wire_fiber {
|
|
1676
|
+
static solo(host, task) {
|
|
1677
|
+
const field = task.name + '()';
|
|
1678
|
+
const existen = Object.getOwnPropertyDescriptor(host ?? task, field)?.value;
|
|
1679
|
+
if (existen)
|
|
1680
|
+
return existen;
|
|
1681
|
+
const prefix = host?.[Symbol.toStringTag] ?? (host instanceof Function ? $$.$mol_func_name(host) : host);
|
|
1682
|
+
const key = `${prefix}.${field}`;
|
|
1683
|
+
const fiber = new $mol_wire_atom(key, task, host, []);
|
|
1684
|
+
(host ?? task)[field] = fiber;
|
|
1685
|
+
return fiber;
|
|
1686
|
+
}
|
|
1687
|
+
static plex(host, task, key) {
|
|
1688
|
+
const field = task.name + '()';
|
|
1689
|
+
let dict = Object.getOwnPropertyDescriptor(host ?? task, field)?.value;
|
|
1690
|
+
const prefix = host?.[Symbol.toStringTag] ?? (host instanceof Function ? $$.$mol_func_name(host) : host);
|
|
1691
|
+
const id = `${prefix}.${task.name}(${$mol_key(key).replace(/^"|"$/g, "'")})`;
|
|
1692
|
+
if (dict) {
|
|
1693
|
+
const existen = dict.get(id);
|
|
1694
|
+
if (existen)
|
|
1695
|
+
return existen;
|
|
1568
1696
|
}
|
|
1569
1697
|
else {
|
|
1570
|
-
|
|
1698
|
+
dict = (host ?? task)[field] = new Map();
|
|
1571
1699
|
}
|
|
1700
|
+
const fiber = new $mol_wire_atom(id, task, host, [key]);
|
|
1701
|
+
dict.set(id, fiber);
|
|
1702
|
+
return fiber;
|
|
1572
1703
|
}
|
|
1573
|
-
static
|
|
1574
|
-
|
|
1575
|
-
|
|
1704
|
+
static watching = new Set();
|
|
1705
|
+
static watcher = null;
|
|
1706
|
+
static watch() {
|
|
1707
|
+
$mol_wire_atom.watcher = new $mol_after_frame($mol_wire_atom.watch);
|
|
1708
|
+
for (const atom of $mol_wire_atom.watching) {
|
|
1709
|
+
if (atom.cursor === $mol_wire_cursor.final) {
|
|
1710
|
+
$mol_wire_atom.watching.delete(atom);
|
|
1711
|
+
}
|
|
1712
|
+
else {
|
|
1713
|
+
atom.cursor = $mol_wire_cursor.stale;
|
|
1714
|
+
atom.fresh();
|
|
1715
|
+
}
|
|
1716
|
+
}
|
|
1717
|
+
}
|
|
1718
|
+
watch() {
|
|
1719
|
+
if (!$mol_wire_atom.watcher) {
|
|
1720
|
+
$mol_wire_atom.watcher = new $mol_after_frame($mol_wire_atom.watch);
|
|
1721
|
+
}
|
|
1722
|
+
$mol_wire_atom.watching.add(this);
|
|
1723
|
+
}
|
|
1724
|
+
resync(args) {
|
|
1725
|
+
return this.put(this.task.call(this.host, ...args));
|
|
1726
|
+
}
|
|
1727
|
+
once() {
|
|
1728
|
+
return this.sync();
|
|
1729
|
+
}
|
|
1730
|
+
channel() {
|
|
1731
|
+
return Object.assign((next) => {
|
|
1732
|
+
if (next !== undefined)
|
|
1733
|
+
return this.resync([...this.args, next]);
|
|
1734
|
+
if (!$mol_wire_fiber.warm)
|
|
1735
|
+
return this.result();
|
|
1736
|
+
if ($mol_wire_auto()?.temp) {
|
|
1737
|
+
return this.once();
|
|
1738
|
+
}
|
|
1739
|
+
else {
|
|
1740
|
+
return this.sync();
|
|
1741
|
+
}
|
|
1742
|
+
}, { atom: this });
|
|
1743
|
+
}
|
|
1744
|
+
destructor() {
|
|
1745
|
+
super.destructor();
|
|
1746
|
+
const prev = this.cache;
|
|
1747
|
+
if ($mol_owning_check(this, prev)) {
|
|
1748
|
+
prev.destructor();
|
|
1749
|
+
}
|
|
1750
|
+
if (this.pub_from === 0) {
|
|
1751
|
+
;
|
|
1752
|
+
(this.host ?? this.task)[this.field()] = null;
|
|
1753
|
+
}
|
|
1754
|
+
else {
|
|
1755
|
+
;
|
|
1756
|
+
(this.host ?? this.task)[this.field()].delete(this[Symbol.toStringTag]);
|
|
1757
|
+
}
|
|
1758
|
+
}
|
|
1759
|
+
put(next) {
|
|
1760
|
+
const prev = this.cache;
|
|
1761
|
+
update: if (next !== prev) {
|
|
1762
|
+
try {
|
|
1763
|
+
if ($mol_compare_deep(prev, next))
|
|
1764
|
+
break update;
|
|
1765
|
+
}
|
|
1766
|
+
catch (error) {
|
|
1767
|
+
$mol_fail_log(error);
|
|
1768
|
+
}
|
|
1769
|
+
if ($mol_owning_check(this, prev)) {
|
|
1770
|
+
prev.destructor();
|
|
1771
|
+
}
|
|
1772
|
+
if ($mol_owning_catch(this, next)) {
|
|
1773
|
+
try {
|
|
1774
|
+
next[Symbol.toStringTag] = this[Symbol.toStringTag];
|
|
1775
|
+
}
|
|
1776
|
+
catch {
|
|
1777
|
+
Object.defineProperty(next, Symbol.toStringTag, { value: this[Symbol.toStringTag] });
|
|
1778
|
+
}
|
|
1779
|
+
}
|
|
1780
|
+
if (!this.sub_empty)
|
|
1781
|
+
this.emit();
|
|
1782
|
+
}
|
|
1783
|
+
this.cache = next;
|
|
1784
|
+
this.cursor = $mol_wire_cursor.fresh;
|
|
1785
|
+
if ($mol_promise_like(next))
|
|
1786
|
+
return next;
|
|
1787
|
+
this.complete_pubs();
|
|
1788
|
+
return next;
|
|
1576
1789
|
}
|
|
1577
1790
|
}
|
|
1578
1791
|
__decorate([
|
|
1579
|
-
$
|
|
1580
|
-
], $
|
|
1792
|
+
$mol_wire_method
|
|
1793
|
+
], $mol_wire_atom.prototype, "resync", null);
|
|
1581
1794
|
__decorate([
|
|
1582
|
-
$
|
|
1583
|
-
], $
|
|
1584
|
-
$.$
|
|
1795
|
+
$mol_wire_method
|
|
1796
|
+
], $mol_wire_atom.prototype, "once", null);
|
|
1797
|
+
$.$mol_wire_atom = $mol_wire_atom;
|
|
1585
1798
|
})($ || ($ = {}));
|
|
1586
|
-
//mol/
|
|
1799
|
+
//mol/wire/atom/atom.ts
|
|
1587
1800
|
;
|
|
1588
1801
|
"use strict";
|
|
1589
1802
|
var $;
|
|
1590
1803
|
(function ($) {
|
|
1591
|
-
function $
|
|
1592
|
-
const
|
|
1593
|
-
|
|
1594
|
-
$
|
|
1595
|
-
|
|
1596
|
-
|
|
1597
|
-
|
|
1598
|
-
|
|
1599
|
-
|
|
1600
|
-
|
|
1601
|
-
|
|
1602
|
-
|
|
1603
|
-
return current;
|
|
1804
|
+
function $mol_wire_probe(task, def) {
|
|
1805
|
+
const warm = $mol_wire_fiber.warm;
|
|
1806
|
+
try {
|
|
1807
|
+
$mol_wire_fiber.warm = false;
|
|
1808
|
+
const res = task();
|
|
1809
|
+
if (res === undefined)
|
|
1810
|
+
return def;
|
|
1811
|
+
return res;
|
|
1812
|
+
}
|
|
1813
|
+
finally {
|
|
1814
|
+
$mol_wire_fiber.warm = warm;
|
|
1815
|
+
}
|
|
1604
1816
|
}
|
|
1605
|
-
$.$
|
|
1817
|
+
$.$mol_wire_probe = $mol_wire_probe;
|
|
1606
1818
|
})($ || ($ = {}));
|
|
1607
|
-
//mol/wire/
|
|
1819
|
+
//mol/wire/probe/probe.ts
|
|
1608
1820
|
;
|
|
1609
1821
|
"use strict";
|
|
1610
1822
|
var $;
|
|
1611
1823
|
(function ($) {
|
|
1612
|
-
function $
|
|
1613
|
-
|
|
1614
|
-
|
|
1615
|
-
|
|
1616
|
-
continue;
|
|
1617
|
-
if (!descr.get)
|
|
1618
|
-
continue;
|
|
1619
|
-
const get = descr.get ?? (() => descr.value);
|
|
1620
|
-
const set = descr.set ?? (next => descr.value = next);
|
|
1621
|
-
Reflect.defineProperty(obj, field, {
|
|
1622
|
-
configurable: true,
|
|
1623
|
-
enumerable: descr.enumerable,
|
|
1624
|
-
get() {
|
|
1625
|
-
const atom = $mol_wire_atom.solo(obj, get);
|
|
1626
|
-
atom.watch();
|
|
1627
|
-
return atom.sync();
|
|
1628
|
-
},
|
|
1629
|
-
set(next) {
|
|
1630
|
-
const atom = $mol_wire_atom.solo(obj, get);
|
|
1631
|
-
set.call(this, next);
|
|
1632
|
-
atom.refresh();
|
|
1633
|
-
},
|
|
1634
|
-
});
|
|
1824
|
+
function $mol_wire_solid() {
|
|
1825
|
+
const current = $mol_wire_auto();
|
|
1826
|
+
if (current.reap !== nothing) {
|
|
1827
|
+
current?.sub_on(sub, sub.data.length);
|
|
1635
1828
|
}
|
|
1829
|
+
current.reap = nothing;
|
|
1636
1830
|
}
|
|
1637
|
-
$.$
|
|
1831
|
+
$.$mol_wire_solid = $mol_wire_solid;
|
|
1832
|
+
const nothing = () => { };
|
|
1833
|
+
const sub = new $mol_wire_pub_sub;
|
|
1638
1834
|
})($ || ($ = {}));
|
|
1639
|
-
//mol/wire/
|
|
1835
|
+
//mol/wire/solid/solid.ts
|
|
1640
1836
|
;
|
|
1641
1837
|
"use strict";
|
|
1642
|
-
|
|
1838
|
+
var $;
|
|
1839
|
+
(function ($) {
|
|
1840
|
+
function $mol_wire_watch() {
|
|
1841
|
+
const atom = $mol_wire_auto();
|
|
1842
|
+
if (atom instanceof $mol_wire_atom) {
|
|
1843
|
+
atom.watch();
|
|
1844
|
+
}
|
|
1845
|
+
else {
|
|
1846
|
+
$mol_fail(new Error('Atom is required for watching'));
|
|
1847
|
+
}
|
|
1848
|
+
}
|
|
1849
|
+
$.$mol_wire_watch = $mol_wire_watch;
|
|
1850
|
+
})($ || ($ = {}));
|
|
1851
|
+
//mol/wire/watch/watch.ts
|
|
1643
1852
|
;
|
|
1644
1853
|
"use strict";
|
|
1645
1854
|
var $;
|
|
1646
1855
|
(function ($) {
|
|
1647
|
-
function $
|
|
1648
|
-
|
|
1649
|
-
|
|
1650
|
-
|
|
1651
|
-
|
|
1856
|
+
function $mol_wire_sync(obj) {
|
|
1857
|
+
return new Proxy(obj, {
|
|
1858
|
+
get(obj, field) {
|
|
1859
|
+
const val = obj[field];
|
|
1860
|
+
if (typeof val !== 'function')
|
|
1861
|
+
return val;
|
|
1862
|
+
const temp = $mol_wire_task.getter(val);
|
|
1863
|
+
return function $mol_wire_sync(...args) {
|
|
1864
|
+
const fiber = temp(obj, args);
|
|
1865
|
+
return fiber.sync();
|
|
1866
|
+
};
|
|
1867
|
+
},
|
|
1868
|
+
apply(obj, self, args) {
|
|
1869
|
+
const temp = $mol_wire_task.getter(obj);
|
|
1870
|
+
const fiber = temp(self, args);
|
|
1871
|
+
return fiber.sync();
|
|
1872
|
+
},
|
|
1873
|
+
});
|
|
1652
1874
|
}
|
|
1653
|
-
$.$
|
|
1875
|
+
$.$mol_wire_sync = $mol_wire_sync;
|
|
1654
1876
|
})($ || ($ = {}));
|
|
1655
|
-
//mol/wire/
|
|
1877
|
+
//mol/wire/sync/sync.ts
|
|
1656
1878
|
;
|
|
1657
1879
|
"use strict";
|
|
1658
1880
|
var $;
|
|
1659
1881
|
(function ($) {
|
|
1660
|
-
|
|
1661
|
-
|
|
1662
|
-
|
|
1663
|
-
|
|
1664
|
-
|
|
1665
|
-
|
|
1666
|
-
|
|
1667
|
-
|
|
1668
|
-
|
|
1669
|
-
|
|
1670
|
-
|
|
1671
|
-
|
|
1672
|
-
|
|
1673
|
-
|
|
1674
|
-
|
|
1675
|
-
|
|
1676
|
-
|
|
1677
|
-
|
|
1678
|
-
|
|
1679
|
-
|
|
1680
|
-
|
|
1681
|
-
}
|
|
1682
|
-
[Symbol.iterator]() {
|
|
1683
|
-
this.pub.promote();
|
|
1684
|
-
return super[Symbol.iterator]();
|
|
1685
|
-
}
|
|
1686
|
-
get size() {
|
|
1687
|
-
this.pub.promote();
|
|
1688
|
-
return super.size;
|
|
1689
|
-
}
|
|
1690
|
-
add(value) {
|
|
1691
|
-
if (super.has(value))
|
|
1692
|
-
return this;
|
|
1693
|
-
super.add(value);
|
|
1694
|
-
this.pub.emit();
|
|
1695
|
-
return this;
|
|
1696
|
-
}
|
|
1697
|
-
delete(value) {
|
|
1698
|
-
const res = super.delete(value);
|
|
1699
|
-
if (res)
|
|
1700
|
-
this.pub.emit();
|
|
1701
|
-
return res;
|
|
1702
|
-
}
|
|
1703
|
-
clear() {
|
|
1704
|
-
if (!super.size)
|
|
1705
|
-
return;
|
|
1706
|
-
super.clear();
|
|
1707
|
-
this.pub.emit();
|
|
1708
|
-
}
|
|
1709
|
-
item(val, next) {
|
|
1710
|
-
if (next === undefined)
|
|
1711
|
-
return this.has(val);
|
|
1712
|
-
if (next)
|
|
1713
|
-
this.add(val);
|
|
1714
|
-
else
|
|
1715
|
-
this.delete(val);
|
|
1716
|
-
return next;
|
|
1717
|
-
}
|
|
1882
|
+
function $mol_wire_async(obj) {
|
|
1883
|
+
let fiber;
|
|
1884
|
+
const temp = $mol_wire_task.getter(obj);
|
|
1885
|
+
return new Proxy(obj, {
|
|
1886
|
+
get(obj, field) {
|
|
1887
|
+
const val = obj[field];
|
|
1888
|
+
if (typeof val !== 'function')
|
|
1889
|
+
return val;
|
|
1890
|
+
let fiber;
|
|
1891
|
+
const temp = $mol_wire_task.getter(val);
|
|
1892
|
+
return function $mol_wire_async(...args) {
|
|
1893
|
+
fiber?.destructor();
|
|
1894
|
+
fiber = temp(obj, args);
|
|
1895
|
+
return fiber.async();
|
|
1896
|
+
};
|
|
1897
|
+
},
|
|
1898
|
+
apply(obj, self, args) {
|
|
1899
|
+
fiber?.destructor();
|
|
1900
|
+
fiber = temp(self, args);
|
|
1901
|
+
return fiber.async();
|
|
1902
|
+
},
|
|
1903
|
+
});
|
|
1718
1904
|
}
|
|
1719
|
-
$.$
|
|
1905
|
+
$.$mol_wire_async = $mol_wire_async;
|
|
1720
1906
|
})($ || ($ = {}));
|
|
1721
|
-
//mol/wire/
|
|
1907
|
+
//mol/wire/async/async.ts
|
|
1722
1908
|
;
|
|
1723
1909
|
"use strict";
|
|
1724
1910
|
var $;
|
|
1725
1911
|
(function ($) {
|
|
1726
|
-
|
|
1727
|
-
|
|
1728
|
-
|
|
1729
|
-
|
|
1730
|
-
|
|
1731
|
-
|
|
1732
|
-
|
|
1733
|
-
|
|
1734
|
-
|
|
1735
|
-
|
|
1736
|
-
|
|
1737
|
-
|
|
1738
|
-
|
|
1739
|
-
|
|
1740
|
-
|
|
1741
|
-
|
|
1742
|
-
return super.keys();
|
|
1743
|
-
}
|
|
1744
|
-
values() {
|
|
1745
|
-
this.pub.promote();
|
|
1746
|
-
return super.values();
|
|
1747
|
-
}
|
|
1748
|
-
forEach(task, self) {
|
|
1749
|
-
this.pub.promote();
|
|
1750
|
-
super.forEach(task, self);
|
|
1751
|
-
}
|
|
1752
|
-
[Symbol.iterator]() {
|
|
1753
|
-
this.pub.promote();
|
|
1754
|
-
return super[Symbol.iterator]();
|
|
1755
|
-
}
|
|
1756
|
-
get size() {
|
|
1757
|
-
this.pub.promote();
|
|
1758
|
-
return super.size;
|
|
1759
|
-
}
|
|
1760
|
-
set(key, value) {
|
|
1761
|
-
if (super.get(key) === value)
|
|
1762
|
-
return this;
|
|
1763
|
-
super.set(key, value);
|
|
1764
|
-
this.pub?.emit();
|
|
1765
|
-
return this;
|
|
1766
|
-
}
|
|
1767
|
-
delete(key) {
|
|
1768
|
-
const res = super.delete(key);
|
|
1769
|
-
if (res)
|
|
1770
|
-
this.pub.emit();
|
|
1771
|
-
return res;
|
|
1772
|
-
}
|
|
1773
|
-
clear() {
|
|
1774
|
-
if (!super.size)
|
|
1775
|
-
return;
|
|
1776
|
-
super.clear();
|
|
1777
|
-
this.pub.emit();
|
|
1778
|
-
}
|
|
1779
|
-
item(key, next) {
|
|
1780
|
-
if (next === undefined)
|
|
1781
|
-
return this.get(key) ?? null;
|
|
1782
|
-
if (next === null)
|
|
1783
|
-
this.delete(key);
|
|
1784
|
-
else
|
|
1785
|
-
this.set(key, next);
|
|
1786
|
-
return next;
|
|
1787
|
-
}
|
|
1912
|
+
function $mol_wire_race(...tasks) {
|
|
1913
|
+
const results = tasks.map(task => {
|
|
1914
|
+
try {
|
|
1915
|
+
return task();
|
|
1916
|
+
}
|
|
1917
|
+
catch (error) {
|
|
1918
|
+
return error;
|
|
1919
|
+
}
|
|
1920
|
+
});
|
|
1921
|
+
const promises = results.filter(res => $mol_promise_like(res));
|
|
1922
|
+
if (promises.length)
|
|
1923
|
+
$mol_fail(Promise.race(promises));
|
|
1924
|
+
const error = results.find(res => res instanceof Error);
|
|
1925
|
+
if (error)
|
|
1926
|
+
$mol_fail(error);
|
|
1927
|
+
return results;
|
|
1788
1928
|
}
|
|
1789
|
-
$.$
|
|
1929
|
+
$.$mol_wire_race = $mol_wire_race;
|
|
1790
1930
|
})($ || ($ = {}));
|
|
1791
|
-
//mol/wire/
|
|
1931
|
+
//mol/wire/race/race.ts
|
|
1792
1932
|
;
|
|
1793
1933
|
"use strict";
|
|
1794
1934
|
var $;
|
|
1795
1935
|
(function ($) {
|
|
1796
|
-
function $
|
|
1797
|
-
|
|
1798
|
-
|
|
1799
|
-
const
|
|
1800
|
-
|
|
1801
|
-
|
|
1802
|
-
|
|
1803
|
-
|
|
1804
|
-
|
|
1805
|
-
|
|
1806
|
-
|
|
1936
|
+
function $mol_wire_solo(host, field, descr) {
|
|
1937
|
+
if (!descr)
|
|
1938
|
+
descr = Reflect.getOwnPropertyDescriptor(host, field);
|
|
1939
|
+
const orig = descr?.value ?? host[field];
|
|
1940
|
+
const sup = Reflect.getPrototypeOf(host);
|
|
1941
|
+
if (typeof sup[field] === 'function') {
|
|
1942
|
+
Object.defineProperty(orig, 'name', { value: sup[field].name });
|
|
1943
|
+
}
|
|
1944
|
+
const descr2 = {
|
|
1945
|
+
...descr,
|
|
1946
|
+
value: function (...args) {
|
|
1947
|
+
let atom = $mol_wire_atom.solo(this, orig);
|
|
1948
|
+
if ((args.length === 0) || (args[0] === undefined)) {
|
|
1949
|
+
if (!$mol_wire_fiber.warm)
|
|
1950
|
+
return atom.result();
|
|
1951
|
+
if ($mol_wire_auto()?.temp) {
|
|
1952
|
+
return atom.once();
|
|
1953
|
+
}
|
|
1954
|
+
else {
|
|
1955
|
+
return atom.sync();
|
|
1956
|
+
}
|
|
1957
|
+
}
|
|
1958
|
+
return atom.resync(args);
|
|
1959
|
+
}
|
|
1960
|
+
};
|
|
1961
|
+
Reflect.defineProperty(descr2.value, 'name', { value: orig.name + ' ' });
|
|
1962
|
+
Reflect.defineProperty(descr2.value, 'length', { value: orig.length });
|
|
1963
|
+
Object.assign(descr2.value, { orig });
|
|
1964
|
+
Reflect.defineProperty(host, field, descr2);
|
|
1965
|
+
return descr2;
|
|
1807
1966
|
}
|
|
1808
|
-
$.$
|
|
1967
|
+
$.$mol_wire_solo = $mol_wire_solo;
|
|
1809
1968
|
})($ || ($ = {}));
|
|
1810
|
-
//mol/
|
|
1969
|
+
//mol/wire/solo/solo.ts
|
|
1811
1970
|
;
|
|
1812
1971
|
"use strict";
|
|
1813
1972
|
var $;
|
|
1814
1973
|
(function ($) {
|
|
1815
|
-
function $
|
|
1816
|
-
|
|
1817
|
-
|
|
1818
|
-
|
|
1819
|
-
|
|
1820
|
-
|
|
1974
|
+
function $mol_wire_plex(host, field, descr) {
|
|
1975
|
+
if (!descr)
|
|
1976
|
+
descr = Reflect.getOwnPropertyDescriptor(host, field);
|
|
1977
|
+
const orig = descr?.value ?? host[field];
|
|
1978
|
+
const sup = Reflect.getPrototypeOf(host);
|
|
1979
|
+
if (typeof sup[field] === 'function') {
|
|
1980
|
+
Object.defineProperty(orig, 'name', { value: sup[field].name });
|
|
1981
|
+
}
|
|
1982
|
+
const descr2 = {
|
|
1983
|
+
...descr,
|
|
1984
|
+
value: function (...args) {
|
|
1985
|
+
let atom = $mol_wire_atom.plex(this, orig, args[0]);
|
|
1986
|
+
if ((args.length === 1) || (args[1] === undefined)) {
|
|
1987
|
+
if (!$mol_wire_fiber.warm)
|
|
1988
|
+
return atom.result();
|
|
1989
|
+
if ($mol_wire_auto()?.temp) {
|
|
1990
|
+
return atom.once();
|
|
1991
|
+
}
|
|
1992
|
+
else {
|
|
1993
|
+
return atom.sync();
|
|
1994
|
+
}
|
|
1995
|
+
}
|
|
1996
|
+
return atom.resync(args);
|
|
1997
|
+
}
|
|
1998
|
+
};
|
|
1999
|
+
Reflect.defineProperty(descr2.value, 'name', { value: orig.name + ' ' });
|
|
2000
|
+
Reflect.defineProperty(descr2.value, 'length', { value: orig.length });
|
|
2001
|
+
Object.assign(descr2.value, { orig });
|
|
2002
|
+
Reflect.defineProperty(host, field, descr2);
|
|
2003
|
+
return descr2;
|
|
1821
2004
|
}
|
|
1822
|
-
$.$
|
|
1823
|
-
|
|
1824
|
-
|
|
2005
|
+
$.$mol_wire_plex = $mol_wire_plex;
|
|
2006
|
+
})($ || ($ = {}));
|
|
2007
|
+
//mol/wire/plex/plex.ts
|
|
2008
|
+
;
|
|
2009
|
+
"use strict";
|
|
2010
|
+
var $;
|
|
2011
|
+
(function ($) {
|
|
2012
|
+
function $mol_const(value) {
|
|
2013
|
+
const getter = (() => value);
|
|
2014
|
+
getter['()'] = value;
|
|
2015
|
+
getter[Symbol.toStringTag] = value;
|
|
2016
|
+
getter[$mol_dev_format_head] = () => $mol_dev_format_span({}, '()=> ', $mol_dev_format_auto(value));
|
|
2017
|
+
return getter;
|
|
1825
2018
|
}
|
|
1826
|
-
$.$
|
|
2019
|
+
$.$mol_const = $mol_const;
|
|
1827
2020
|
})($ || ($ = {}));
|
|
1828
|
-
//mol/
|
|
2021
|
+
//mol/const/const.ts
|
|
1829
2022
|
;
|
|
1830
2023
|
"use strict";
|
|
1831
2024
|
var $;
|
|
1832
2025
|
(function ($) {
|
|
1833
|
-
function $
|
|
1834
|
-
|
|
1835
|
-
|
|
1836
|
-
const
|
|
1837
|
-
|
|
1838
|
-
|
|
1839
|
-
logged = true;
|
|
1840
|
-
self.$mol_log3_area.call(self, event);
|
|
1841
|
-
});
|
|
1842
|
-
return () => {
|
|
1843
|
-
if (logged)
|
|
1844
|
-
self.console.groupEnd();
|
|
1845
|
-
if (stack.length > deep)
|
|
1846
|
-
stack.length = deep;
|
|
2026
|
+
function $mol_wire_field(host, field, descr) {
|
|
2027
|
+
if (!descr)
|
|
2028
|
+
descr = Reflect.getOwnPropertyDescriptor(host, field);
|
|
2029
|
+
const _get = descr?.get || $mol_const(descr?.value);
|
|
2030
|
+
const _set = descr?.set || function (next) {
|
|
2031
|
+
$mol_wire_atom.solo(this, _get).put(next);
|
|
1847
2032
|
};
|
|
2033
|
+
const sup = Reflect.getPrototypeOf(host);
|
|
2034
|
+
const sup_descr = Reflect.getOwnPropertyDescriptor(sup, field);
|
|
2035
|
+
Object.defineProperty(_get, 'name', { value: sup_descr?.get?.name ?? field });
|
|
2036
|
+
Object.defineProperty(_set, 'name', { value: sup_descr?.set?.name ?? field });
|
|
2037
|
+
function get() {
|
|
2038
|
+
return $mol_wire_atom.solo(this, _get).sync();
|
|
2039
|
+
}
|
|
2040
|
+
const temp = $mol_wire_task.getter(_set);
|
|
2041
|
+
function set(next) {
|
|
2042
|
+
temp(this, [next]).sync();
|
|
2043
|
+
}
|
|
2044
|
+
Object.defineProperty(get, 'name', { value: _get.name + '$' });
|
|
2045
|
+
Object.defineProperty(set, 'name', { value: _set.name + '@' });
|
|
2046
|
+
Object.assign(get, { orig: _get });
|
|
2047
|
+
Object.assign(set, { orig: _set });
|
|
2048
|
+
const { value, writable, ...descr2 } = { ...descr, get, set };
|
|
2049
|
+
Reflect.defineProperty(host, field, descr2);
|
|
2050
|
+
return descr2;
|
|
1848
2051
|
}
|
|
1849
|
-
$.$
|
|
1850
|
-
$.$mol_log3_stack = [];
|
|
2052
|
+
$.$mol_wire_field = $mol_wire_field;
|
|
1851
2053
|
})($ || ($ = {}));
|
|
1852
|
-
//mol/
|
|
2054
|
+
//mol/wire/field/field.ts
|
|
1853
2055
|
;
|
|
1854
2056
|
"use strict";
|
|
1855
2057
|
var $;
|
|
1856
|
-
(function ($) {
|
|
1857
|
-
|
|
1858
|
-
|
|
1859
|
-
|
|
1860
|
-
|
|
1861
|
-
|
|
1862
|
-
|
|
1863
|
-
|
|
1864
|
-
super(
|
|
1865
|
-
|
|
1866
|
-
|
|
1867
|
-
|
|
1868
|
-
this.col = col;
|
|
1869
|
-
this.length = length;
|
|
1870
|
-
this[Symbol.toStringTag] = `${this.uri}#${this.row}:${this.col}/${this.length}`;
|
|
1871
|
-
}
|
|
1872
|
-
static unknown = $mol_span.begin('?');
|
|
1873
|
-
static begin(uri, source = '') {
|
|
1874
|
-
return new $mol_span(uri, source, 1, 1, 0);
|
|
1875
|
-
}
|
|
1876
|
-
static end(uri, source) {
|
|
1877
|
-
return new $mol_span(uri, source, 1, source.length + 1, 0);
|
|
1878
|
-
}
|
|
1879
|
-
static entire(uri, source) {
|
|
1880
|
-
return new $mol_span(uri, source, 1, 1, source.length);
|
|
1881
|
-
}
|
|
1882
|
-
toString() {
|
|
1883
|
-
return this[Symbol.toStringTag];
|
|
1884
|
-
}
|
|
1885
|
-
toJSON() {
|
|
1886
|
-
return {
|
|
1887
|
-
uri: this.uri,
|
|
1888
|
-
row: this.row,
|
|
1889
|
-
col: this.col,
|
|
1890
|
-
length: this.length
|
|
1891
|
-
};
|
|
1892
|
-
}
|
|
1893
|
-
error(message, Class = Error) {
|
|
1894
|
-
return new Class(`${message}${this}`);
|
|
1895
|
-
}
|
|
1896
|
-
span(row, col, length) {
|
|
1897
|
-
return new $mol_span(this.uri, this.source, row, col, length);
|
|
1898
|
-
}
|
|
1899
|
-
after(length = 0) {
|
|
1900
|
-
return new $mol_span(this.uri, this.source, this.row, this.col + this.length, length);
|
|
1901
|
-
}
|
|
1902
|
-
slice(begin, end = -1) {
|
|
1903
|
-
let len = this.length;
|
|
1904
|
-
if (begin < 0)
|
|
1905
|
-
begin += len;
|
|
1906
|
-
if (end < 0)
|
|
1907
|
-
end += len;
|
|
1908
|
-
if (begin < 0 || begin > len)
|
|
1909
|
-
this.$.$mol_fail(`Begin value '${begin}' out of range ${this}`);
|
|
1910
|
-
if (end < 0 || end > len)
|
|
1911
|
-
this.$.$mol_fail(`End value '${end}' out of range ${this}`);
|
|
1912
|
-
if (end < begin)
|
|
1913
|
-
this.$.$mol_fail(`End value '${end}' can't be less than begin value ${this}`);
|
|
1914
|
-
return this.span(this.row, this.col + begin, end - begin);
|
|
2058
|
+
(function ($_1) {
|
|
2059
|
+
let $$;
|
|
2060
|
+
(function ($$) {
|
|
2061
|
+
let $;
|
|
2062
|
+
})($$ = $_1.$$ || ($_1.$$ = {}));
|
|
2063
|
+
$_1.$mol_object_field = Symbol('$mol_object_field');
|
|
2064
|
+
class $mol_object extends $mol_object2 {
|
|
2065
|
+
static make(config) {
|
|
2066
|
+
return super.create(obj => {
|
|
2067
|
+
for (let key in config)
|
|
2068
|
+
obj[key] = config[key];
|
|
2069
|
+
});
|
|
1915
2070
|
}
|
|
1916
2071
|
}
|
|
1917
|
-
|
|
2072
|
+
$_1.$mol_object = $mol_object;
|
|
1918
2073
|
})($ || ($ = {}));
|
|
1919
|
-
//mol/
|
|
2074
|
+
//mol/object/object.ts
|
|
1920
2075
|
;
|
|
1921
2076
|
"use strict";
|
|
1922
2077
|
var $;
|
|
1923
2078
|
(function ($) {
|
|
1924
|
-
|
|
1925
|
-
|
|
1926
|
-
function dump(tree, prefix = '') {
|
|
1927
|
-
if (tree.type.length) {
|
|
1928
|
-
if (!prefix.length) {
|
|
1929
|
-
prefix = "\t";
|
|
1930
|
-
}
|
|
1931
|
-
output.push(tree.type);
|
|
1932
|
-
if (tree.kids.length == 1) {
|
|
1933
|
-
output.push(' ');
|
|
1934
|
-
dump(tree.kids[0], prefix);
|
|
1935
|
-
return;
|
|
1936
|
-
}
|
|
1937
|
-
output.push("\n");
|
|
1938
|
-
}
|
|
1939
|
-
else if (tree.value.length || prefix.length) {
|
|
1940
|
-
output.push("\\" + tree.value + "\n");
|
|
1941
|
-
}
|
|
1942
|
-
for (const kid of tree.kids) {
|
|
1943
|
-
output.push(prefix);
|
|
1944
|
-
dump(kid, prefix + "\t");
|
|
1945
|
-
}
|
|
1946
|
-
}
|
|
1947
|
-
dump(tree);
|
|
1948
|
-
return output.join('');
|
|
1949
|
-
}
|
|
1950
|
-
$.$mol_tree2_to_string = $mol_tree2_to_string;
|
|
2079
|
+
$.$mol_mem = $mol_wire_solo;
|
|
2080
|
+
$.$mol_mem_key = $mol_wire_plex;
|
|
1951
2081
|
})($ || ($ = {}));
|
|
1952
|
-
//mol/
|
|
2082
|
+
//mol/mem/mem.ts
|
|
1953
2083
|
;
|
|
1954
2084
|
"use strict";
|
|
1955
2085
|
var $;
|
|
1956
2086
|
(function ($) {
|
|
1957
|
-
class $
|
|
1958
|
-
|
|
1959
|
-
|
|
1960
|
-
|
|
1961
|
-
span;
|
|
1962
|
-
constructor(type, value, kids, span) {
|
|
1963
|
-
super();
|
|
1964
|
-
this.type = type;
|
|
1965
|
-
this.value = value;
|
|
1966
|
-
this.kids = kids;
|
|
1967
|
-
this.span = span;
|
|
1968
|
-
this[Symbol.toStringTag] = type || '\\' + value;
|
|
1969
|
-
}
|
|
1970
|
-
static list(kids, span = $mol_span.unknown) {
|
|
1971
|
-
return new $mol_tree2('', '', kids, span);
|
|
1972
|
-
}
|
|
1973
|
-
list(kids) {
|
|
1974
|
-
return $mol_tree2.list(kids, this.span);
|
|
1975
|
-
}
|
|
1976
|
-
static data(value, kids = [], span = $mol_span.unknown) {
|
|
1977
|
-
const chunks = value.split('\n');
|
|
1978
|
-
if (chunks.length > 1) {
|
|
1979
|
-
let kid_span = span.span(span.row, span.col, 0);
|
|
1980
|
-
const data = chunks.map(chunk => {
|
|
1981
|
-
kid_span = kid_span.after(chunk.length);
|
|
1982
|
-
return new $mol_tree2('', chunk, [], kid_span);
|
|
1983
|
-
});
|
|
1984
|
-
kids = [...data, ...kids];
|
|
1985
|
-
value = '';
|
|
1986
|
-
}
|
|
1987
|
-
return new $mol_tree2('', value, kids, span);
|
|
1988
|
-
}
|
|
1989
|
-
data(value, kids = []) {
|
|
1990
|
-
return $mol_tree2.data(value, kids, this.span);
|
|
1991
|
-
}
|
|
1992
|
-
static struct(type, kids = [], span = $mol_span.unknown) {
|
|
1993
|
-
if (/[ \n\t\\]/.test(type)) {
|
|
1994
|
-
$$.$mol_fail(span.error(`Wrong type ${JSON.stringify(type)}`));
|
|
1995
|
-
}
|
|
1996
|
-
return new $mol_tree2(type, '', kids, span);
|
|
1997
|
-
}
|
|
1998
|
-
struct(type, kids = []) {
|
|
1999
|
-
return $mol_tree2.struct(type, kids, this.span);
|
|
2000
|
-
}
|
|
2001
|
-
clone(kids, span = this.span) {
|
|
2002
|
-
return new $mol_tree2(this.type, this.value, kids, span);
|
|
2003
|
-
}
|
|
2004
|
-
text() {
|
|
2005
|
-
var values = [];
|
|
2006
|
-
for (var kid of this.kids) {
|
|
2007
|
-
if (kid.type)
|
|
2008
|
-
continue;
|
|
2009
|
-
values.push(kid.value);
|
|
2010
|
-
}
|
|
2011
|
-
return this.value + values.join('\n');
|
|
2012
|
-
}
|
|
2013
|
-
static fromString(str, uri = 'unknown') {
|
|
2014
|
-
return $$.$mol_tree2_from_string(str, uri);
|
|
2015
|
-
}
|
|
2016
|
-
toString() {
|
|
2017
|
-
return $$.$mol_tree2_to_string(this);
|
|
2018
|
-
}
|
|
2019
|
-
insert(value, ...path) {
|
|
2020
|
-
if (path.length === 0)
|
|
2021
|
-
return value;
|
|
2022
|
-
const type = path[0];
|
|
2023
|
-
if (typeof type === 'string') {
|
|
2024
|
-
let replaced = false;
|
|
2025
|
-
const sub = this.kids.map((item, index) => {
|
|
2026
|
-
if (item.type !== type)
|
|
2027
|
-
return item;
|
|
2028
|
-
replaced = true;
|
|
2029
|
-
return item.insert(value, ...path.slice(1));
|
|
2030
|
-
}).filter(Boolean);
|
|
2031
|
-
if (!replaced && value) {
|
|
2032
|
-
sub.push(this.struct(type, []).insert(value, ...path.slice(1)));
|
|
2033
|
-
}
|
|
2034
|
-
return this.clone(sub);
|
|
2035
|
-
}
|
|
2036
|
-
else if (typeof type === 'number') {
|
|
2037
|
-
const sub = this.kids.slice();
|
|
2038
|
-
sub[type] = (sub[type] || this.list([]))
|
|
2039
|
-
.insert(value, ...path.slice(1));
|
|
2040
|
-
return this.clone(sub.filter(Boolean));
|
|
2087
|
+
class $mol_state_time extends $mol_object {
|
|
2088
|
+
static task(precision, reset) {
|
|
2089
|
+
if (precision) {
|
|
2090
|
+
return new $mol_after_timeout(precision, () => this.task(precision, null));
|
|
2041
2091
|
}
|
|
2042
2092
|
else {
|
|
2043
|
-
|
|
2044
|
-
.map(item => item.insert(value, ...path.slice(1)))
|
|
2045
|
-
.filter(Boolean);
|
|
2046
|
-
return this.clone(kids);
|
|
2047
|
-
}
|
|
2048
|
-
}
|
|
2049
|
-
select(...path) {
|
|
2050
|
-
let next = [this];
|
|
2051
|
-
for (const type of path) {
|
|
2052
|
-
if (!next.length)
|
|
2053
|
-
break;
|
|
2054
|
-
const prev = next;
|
|
2055
|
-
next = [];
|
|
2056
|
-
for (var item of prev) {
|
|
2057
|
-
switch (typeof (type)) {
|
|
2058
|
-
case 'string':
|
|
2059
|
-
for (var child of item.kids) {
|
|
2060
|
-
if (child.type == type) {
|
|
2061
|
-
next.push(child);
|
|
2062
|
-
}
|
|
2063
|
-
}
|
|
2064
|
-
break;
|
|
2065
|
-
case 'number':
|
|
2066
|
-
if (type < item.kids.length)
|
|
2067
|
-
next.push(item.kids[type]);
|
|
2068
|
-
break;
|
|
2069
|
-
default: next.push(...item.kids);
|
|
2070
|
-
}
|
|
2071
|
-
}
|
|
2093
|
+
return new $mol_after_frame(() => this.task(precision, null));
|
|
2072
2094
|
}
|
|
2073
|
-
return this.list(next);
|
|
2074
|
-
}
|
|
2075
|
-
filter(path, value) {
|
|
2076
|
-
const sub = this.kids.filter(item => {
|
|
2077
|
-
var found = item.select(...path);
|
|
2078
|
-
if (value === undefined) {
|
|
2079
|
-
return Boolean(found.kids.length);
|
|
2080
|
-
}
|
|
2081
|
-
else {
|
|
2082
|
-
return found.kids.some(child => child.value == value);
|
|
2083
|
-
}
|
|
2084
|
-
});
|
|
2085
|
-
return this.clone(sub);
|
|
2086
|
-
}
|
|
2087
|
-
hack(belt, context = {}) {
|
|
2088
|
-
return [].concat(...this.kids.map(child => {
|
|
2089
|
-
let handle = belt[child.type] || belt[''];
|
|
2090
|
-
if (!handle || handle === Object.prototype[child.type]) {
|
|
2091
|
-
handle = (input, belt, context) => [
|
|
2092
|
-
input.clone(input.hack(belt, context), context.span)
|
|
2093
|
-
];
|
|
2094
|
-
}
|
|
2095
|
-
try {
|
|
2096
|
-
return handle(child, belt, context);
|
|
2097
|
-
}
|
|
2098
|
-
catch (error) {
|
|
2099
|
-
error.message += `\n${child.clone([])}${child.span}`;
|
|
2100
|
-
$mol_fail_hidden(error);
|
|
2101
|
-
}
|
|
2102
|
-
}));
|
|
2103
|
-
}
|
|
2104
|
-
error(message, Class = Error) {
|
|
2105
|
-
return this.span.error(`${message}\n${this.clone([])}`, Class);
|
|
2106
2095
|
}
|
|
2107
|
-
|
|
2108
|
-
|
|
2109
|
-
|
|
2110
|
-
constructor() {
|
|
2111
|
-
super('', '', [], $mol_span.unknown);
|
|
2096
|
+
static now(precision) {
|
|
2097
|
+
this.task(precision);
|
|
2098
|
+
return Date.now();
|
|
2112
2099
|
}
|
|
2113
2100
|
}
|
|
2114
|
-
|
|
2101
|
+
__decorate([
|
|
2102
|
+
$mol_mem_key
|
|
2103
|
+
], $mol_state_time, "task", null);
|
|
2104
|
+
__decorate([
|
|
2105
|
+
$mol_mem_key
|
|
2106
|
+
], $mol_state_time, "now", null);
|
|
2107
|
+
$.$mol_state_time = $mol_state_time;
|
|
2115
2108
|
})($ || ($ = {}));
|
|
2116
|
-
//mol/
|
|
2109
|
+
//mol/state/time/time.ts
|
|
2117
2110
|
;
|
|
2118
2111
|
"use strict";
|
|
2119
2112
|
var $;
|
|
2120
2113
|
(function ($) {
|
|
2121
|
-
|
|
2122
|
-
|
|
2123
|
-
|
|
2124
|
-
|
|
2125
|
-
|
|
2126
|
-
|
|
2127
|
-
|
|
2128
|
-
|
|
2129
|
-
|
|
2130
|
-
|
|
2114
|
+
function $mol_wire_easing(next) {
|
|
2115
|
+
const atom = $mol_wire_auto();
|
|
2116
|
+
if (!(atom instanceof $mol_wire_atom))
|
|
2117
|
+
$mol_fail(new Error('Allowed only inside atom'));
|
|
2118
|
+
const prev = atom.result() ?? next;
|
|
2119
|
+
if (typeof prev !== 'number')
|
|
2120
|
+
return next;
|
|
2121
|
+
const current = (prev * 2 + next) / 3;
|
|
2122
|
+
const diff = Math.abs(current - next);
|
|
2123
|
+
if (diff < 1)
|
|
2124
|
+
return next;
|
|
2125
|
+
$mol_state_time.now(0);
|
|
2126
|
+
return current;
|
|
2131
2127
|
}
|
|
2132
|
-
$.$
|
|
2128
|
+
$.$mol_wire_easing = $mol_wire_easing;
|
|
2133
2129
|
})($ || ($ = {}));
|
|
2134
|
-
//mol/
|
|
2130
|
+
//mol/wire/easing/easing.ts
|
|
2135
2131
|
;
|
|
2136
2132
|
"use strict";
|
|
2137
2133
|
var $;
|
|
2138
2134
|
(function ($) {
|
|
2139
|
-
function $
|
|
2140
|
-
const
|
|
2141
|
-
|
|
2142
|
-
|
|
2143
|
-
|
|
2144
|
-
|
|
2145
|
-
|
|
2146
|
-
|
|
2147
|
-
|
|
2148
|
-
|
|
2149
|
-
|
|
2150
|
-
|
|
2151
|
-
|
|
2152
|
-
|
|
2153
|
-
|
|
2154
|
-
|
|
2155
|
-
|
|
2156
|
-
|
|
2157
|
-
|
|
2158
|
-
|
|
2159
|
-
|
|
2160
|
-
}
|
|
2161
|
-
|
|
2162
|
-
|
|
2163
|
-
|
|
2164
|
-
|
|
2165
|
-
|
|
2166
|
-
|
|
2167
|
-
|
|
2168
|
-
|
|
2169
|
-
|
|
2170
|
-
|
|
2171
|
-
|
|
2172
|
-
|
|
2173
|
-
|
|
2174
|
-
|
|
2175
|
-
|
|
2176
|
-
|
|
2177
|
-
if (pos > error_start) {
|
|
2178
|
-
let line_end = str.indexOf('\n', pos);
|
|
2179
|
-
if (line_end === -1)
|
|
2180
|
-
line_end = str.length;
|
|
2181
|
-
const sp = span.span(row, error_start - line_start + 1, pos - error_start);
|
|
2182
|
-
this.$mol_fail(new this.$mol_error_syntax(`Wrong nodes separator`, str.substring(line_start, line_end), sp));
|
|
2183
|
-
}
|
|
2184
|
-
var type_start = pos;
|
|
2185
|
-
while (str.length > pos &&
|
|
2186
|
-
str[pos] != '\\' &&
|
|
2187
|
-
str[pos] != ' ' &&
|
|
2188
|
-
str[pos] != '\t' &&
|
|
2189
|
-
str[pos] != '\n') {
|
|
2190
|
-
pos++;
|
|
2191
|
-
}
|
|
2192
|
-
if (pos > type_start) {
|
|
2193
|
-
let next = new $mol_tree2(str.slice(type_start, pos), '', [], span.span(row, type_start - line_start + 1, pos - type_start));
|
|
2194
|
-
const parent_kids = parent.kids;
|
|
2195
|
-
parent_kids.push(next);
|
|
2196
|
-
parent = next;
|
|
2197
|
-
}
|
|
2198
|
-
if (str.length > pos && str[pos] == ' ') {
|
|
2199
|
-
pos++;
|
|
2200
|
-
}
|
|
2201
|
-
}
|
|
2202
|
-
if (str.length > pos && str[pos] == '\\') {
|
|
2203
|
-
var data_start = pos;
|
|
2204
|
-
while (str.length > pos && str[pos] != '\n') {
|
|
2205
|
-
pos++;
|
|
2206
|
-
}
|
|
2207
|
-
let next = new $mol_tree2('', str.slice(data_start + 1, pos), [], span.span(row, data_start - line_start + 2, pos - data_start - 1));
|
|
2208
|
-
const parent_kids = parent.kids;
|
|
2209
|
-
parent_kids.push(next);
|
|
2210
|
-
parent = next;
|
|
2211
|
-
}
|
|
2212
|
-
if (str.length === pos && stack.length > 0) {
|
|
2213
|
-
const sp = span.span(row, pos - line_start + 1, 1);
|
|
2214
|
-
this.$mol_fail(new this.$mol_error_syntax(`Unexpected EOF, LF required`, str.substring(line_start, str.length), sp));
|
|
2215
|
-
}
|
|
2216
|
-
stack.push(parent);
|
|
2217
|
-
pos++;
|
|
2135
|
+
function $mol_wire_patch(obj) {
|
|
2136
|
+
for (const field of Reflect.ownKeys(obj)) {
|
|
2137
|
+
const descr = Reflect.getOwnPropertyDescriptor(obj, field);
|
|
2138
|
+
if (!descr.configurable)
|
|
2139
|
+
continue;
|
|
2140
|
+
if (!descr.get)
|
|
2141
|
+
continue;
|
|
2142
|
+
const get = descr.get ?? (() => descr.value);
|
|
2143
|
+
const set = descr.set ?? (next => descr.value = next);
|
|
2144
|
+
Reflect.defineProperty(obj, field, {
|
|
2145
|
+
configurable: true,
|
|
2146
|
+
enumerable: descr.enumerable,
|
|
2147
|
+
get() {
|
|
2148
|
+
const atom = $mol_wire_atom.solo(obj, get);
|
|
2149
|
+
atom.watch();
|
|
2150
|
+
return atom.sync();
|
|
2151
|
+
},
|
|
2152
|
+
set(next) {
|
|
2153
|
+
const atom = $mol_wire_atom.solo(obj, get);
|
|
2154
|
+
set.call(this, next);
|
|
2155
|
+
atom.refresh();
|
|
2156
|
+
},
|
|
2157
|
+
});
|
|
2158
|
+
}
|
|
2159
|
+
}
|
|
2160
|
+
$.$mol_wire_patch = $mol_wire_patch;
|
|
2161
|
+
})($ || ($ = {}));
|
|
2162
|
+
//mol/wire/patch/patch.ts
|
|
2163
|
+
;
|
|
2164
|
+
"use strict";
|
|
2165
|
+
//mol/type/result/result.ts
|
|
2166
|
+
;
|
|
2167
|
+
"use strict";
|
|
2168
|
+
var $;
|
|
2169
|
+
(function ($) {
|
|
2170
|
+
function $mol_wire_let(host) {
|
|
2171
|
+
for (const field of Object.keys(host)) {
|
|
2172
|
+
host[field] = new $mol_wire_atom(field, host[field], host).channel();
|
|
2218
2173
|
}
|
|
2219
|
-
return
|
|
2174
|
+
return host;
|
|
2220
2175
|
}
|
|
2221
|
-
$.$
|
|
2176
|
+
$.$mol_wire_let = $mol_wire_let;
|
|
2222
2177
|
})($ || ($ = {}));
|
|
2223
|
-
//mol/
|
|
2178
|
+
//mol/wire/let/let.ts
|
|
2224
2179
|
;
|
|
2225
2180
|
"use strict";
|
|
2226
2181
|
var $;
|
|
2227
2182
|
(function ($) {
|
|
2228
|
-
|
|
2229
|
-
|
|
2230
|
-
|
|
2183
|
+
class $mol_wire_set extends Set {
|
|
2184
|
+
pub = new $mol_wire_pub;
|
|
2185
|
+
has(value) {
|
|
2186
|
+
this.pub.promote();
|
|
2187
|
+
return super.has(value);
|
|
2231
2188
|
}
|
|
2232
|
-
|
|
2233
|
-
|
|
2189
|
+
entries() {
|
|
2190
|
+
this.pub.promote();
|
|
2191
|
+
return super.entries();
|
|
2234
2192
|
}
|
|
2235
|
-
|
|
2236
|
-
|
|
2237
|
-
return
|
|
2193
|
+
keys() {
|
|
2194
|
+
this.pub.promote();
|
|
2195
|
+
return super.keys();
|
|
2238
2196
|
}
|
|
2239
|
-
|
|
2240
|
-
|
|
2241
|
-
return
|
|
2197
|
+
values() {
|
|
2198
|
+
this.pub.promote();
|
|
2199
|
+
return super.values();
|
|
2242
2200
|
}
|
|
2243
|
-
|
|
2244
|
-
|
|
2201
|
+
forEach(task, self) {
|
|
2202
|
+
this.pub.promote();
|
|
2203
|
+
super.forEach(task, self);
|
|
2245
2204
|
}
|
|
2246
|
-
|
|
2247
|
-
|
|
2205
|
+
[Symbol.iterator]() {
|
|
2206
|
+
this.pub.promote();
|
|
2207
|
+
return super[Symbol.iterator]();
|
|
2248
2208
|
}
|
|
2249
|
-
|
|
2250
|
-
|
|
2251
|
-
|
|
2209
|
+
get size() {
|
|
2210
|
+
this.pub.promote();
|
|
2211
|
+
return super.size;
|
|
2252
2212
|
}
|
|
2253
|
-
|
|
2254
|
-
|
|
2255
|
-
|
|
2256
|
-
|
|
2257
|
-
|
|
2258
|
-
|
|
2259
|
-
|
|
2260
|
-
|
|
2261
|
-
|
|
2262
|
-
|
|
2263
|
-
|
|
2264
|
-
|
|
2213
|
+
add(value) {
|
|
2214
|
+
if (super.has(value))
|
|
2215
|
+
return this;
|
|
2216
|
+
super.add(value);
|
|
2217
|
+
this.pub.emit();
|
|
2218
|
+
return this;
|
|
2219
|
+
}
|
|
2220
|
+
delete(value) {
|
|
2221
|
+
const res = super.delete(value);
|
|
2222
|
+
if (res)
|
|
2223
|
+
this.pub.emit();
|
|
2224
|
+
return res;
|
|
2225
|
+
}
|
|
2226
|
+
clear() {
|
|
2227
|
+
if (!super.size)
|
|
2228
|
+
return;
|
|
2229
|
+
super.clear();
|
|
2230
|
+
this.pub.emit();
|
|
2231
|
+
}
|
|
2232
|
+
item(val, next) {
|
|
2233
|
+
if (next === undefined)
|
|
2234
|
+
return this.has(val);
|
|
2235
|
+
if (next)
|
|
2236
|
+
this.add(val);
|
|
2237
|
+
else
|
|
2238
|
+
this.delete(val);
|
|
2239
|
+
return next;
|
|
2265
2240
|
}
|
|
2266
|
-
return new $mol_tree2('*', '', sub, span);
|
|
2267
2241
|
}
|
|
2268
|
-
$.$
|
|
2242
|
+
$.$mol_wire_set = $mol_wire_set;
|
|
2269
2243
|
})($ || ($ = {}));
|
|
2270
|
-
//mol/
|
|
2244
|
+
//mol/wire/set/set.ts
|
|
2271
2245
|
;
|
|
2272
2246
|
"use strict";
|
|
2273
2247
|
var $;
|
|
2274
2248
|
(function ($) {
|
|
2275
|
-
class $
|
|
2276
|
-
|
|
2277
|
-
|
|
2278
|
-
|
|
2279
|
-
|
|
2280
|
-
|
|
2281
|
-
|
|
2282
|
-
|
|
2283
|
-
|
|
2284
|
-
|
|
2285
|
-
|
|
2286
|
-
|
|
2287
|
-
|
|
2288
|
-
|
|
2289
|
-
|
|
2290
|
-
|
|
2291
|
-
|
|
2292
|
-
|
|
2293
|
-
|
|
2294
|
-
|
|
2295
|
-
|
|
2296
|
-
|
|
2297
|
-
|
|
2298
|
-
|
|
2299
|
-
|
|
2300
|
-
|
|
2301
|
-
|
|
2302
|
-
|
|
2303
|
-
|
|
2304
|
-
|
|
2305
|
-
|
|
2306
|
-
|
|
2307
|
-
|
|
2308
|
-
|
|
2309
|
-
|
|
2310
|
-
|
|
2311
|
-
|
|
2249
|
+
class $mol_wire_dict extends Map {
|
|
2250
|
+
pub = new $mol_wire_pub;
|
|
2251
|
+
has(key) {
|
|
2252
|
+
this.pub.promote();
|
|
2253
|
+
return super.has(key);
|
|
2254
|
+
}
|
|
2255
|
+
get(key) {
|
|
2256
|
+
this.pub.promote();
|
|
2257
|
+
return super.get(key);
|
|
2258
|
+
}
|
|
2259
|
+
entries() {
|
|
2260
|
+
this.pub.promote();
|
|
2261
|
+
return super.entries();
|
|
2262
|
+
}
|
|
2263
|
+
keys() {
|
|
2264
|
+
this.pub.promote();
|
|
2265
|
+
return super.keys();
|
|
2266
|
+
}
|
|
2267
|
+
values() {
|
|
2268
|
+
this.pub.promote();
|
|
2269
|
+
return super.values();
|
|
2270
|
+
}
|
|
2271
|
+
forEach(task, self) {
|
|
2272
|
+
this.pub.promote();
|
|
2273
|
+
super.forEach(task, self);
|
|
2274
|
+
}
|
|
2275
|
+
[Symbol.iterator]() {
|
|
2276
|
+
this.pub.promote();
|
|
2277
|
+
return super[Symbol.iterator]();
|
|
2278
|
+
}
|
|
2279
|
+
get size() {
|
|
2280
|
+
this.pub.promote();
|
|
2281
|
+
return super.size;
|
|
2282
|
+
}
|
|
2283
|
+
set(key, value) {
|
|
2284
|
+
if (super.get(key) === value)
|
|
2285
|
+
return this;
|
|
2286
|
+
super.set(key, value);
|
|
2287
|
+
this.pub?.emit();
|
|
2288
|
+
return this;
|
|
2289
|
+
}
|
|
2290
|
+
delete(key) {
|
|
2291
|
+
const res = super.delete(key);
|
|
2292
|
+
if (res)
|
|
2293
|
+
this.pub.emit();
|
|
2294
|
+
return res;
|
|
2295
|
+
}
|
|
2296
|
+
clear() {
|
|
2297
|
+
if (!super.size)
|
|
2298
|
+
return;
|
|
2299
|
+
super.clear();
|
|
2300
|
+
this.pub.emit();
|
|
2301
|
+
}
|
|
2302
|
+
item(key, next) {
|
|
2303
|
+
if (next === undefined)
|
|
2304
|
+
return this.get(key) ?? null;
|
|
2305
|
+
if (next === null)
|
|
2306
|
+
this.delete(key);
|
|
2307
|
+
else
|
|
2308
|
+
this.set(key, next);
|
|
2309
|
+
return next;
|
|
2312
2310
|
}
|
|
2313
2311
|
}
|
|
2314
|
-
$.$
|
|
2312
|
+
$.$mol_wire_dict = $mol_wire_dict;
|
|
2315
2313
|
})($ || ($ = {}));
|
|
2316
|
-
//mol/
|
|
2314
|
+
//mol/wire/dict/dict.ts
|
|
2317
2315
|
;
|
|
2318
2316
|
"use strict";
|
|
2319
2317
|
var $;
|
|
2320
2318
|
(function ($) {
|
|
2321
|
-
function $
|
|
2322
|
-
|
|
2323
|
-
|
|
2324
|
-
|
|
2325
|
-
|
|
2326
|
-
|
|
2327
|
-
|
|
2328
|
-
|
|
2329
|
-
|
|
2330
|
-
|
|
2331
|
-
};
|
|
2319
|
+
function $mol_promise() {
|
|
2320
|
+
let done;
|
|
2321
|
+
let fail;
|
|
2322
|
+
const promise = new Promise((d, f) => {
|
|
2323
|
+
done = d;
|
|
2324
|
+
fail = f;
|
|
2325
|
+
});
|
|
2326
|
+
return Object.assign(promise, {
|
|
2327
|
+
done,
|
|
2328
|
+
fail,
|
|
2329
|
+
});
|
|
2332
2330
|
}
|
|
2333
|
-
$.$
|
|
2334
|
-
$.$mol_log3_come = $mol_log3_node_make('info', 'stdout', 'come', $mol_term_color.blue);
|
|
2335
|
-
$.$mol_log3_done = $mol_log3_node_make('info', 'stdout', 'done', $mol_term_color.green);
|
|
2336
|
-
$.$mol_log3_fail = $mol_log3_node_make('error', 'stderr', 'fail', $mol_term_color.red);
|
|
2337
|
-
$.$mol_log3_warn = $mol_log3_node_make('warn', 'stderr', 'warn', $mol_term_color.yellow);
|
|
2338
|
-
$.$mol_log3_rise = $mol_log3_node_make('log', 'stdout', 'rise', $mol_term_color.magenta);
|
|
2339
|
-
$.$mol_log3_area = $mol_log3_node_make('log', 'stdout', 'area', $mol_term_color.cyan);
|
|
2331
|
+
$.$mol_promise = $mol_promise;
|
|
2340
2332
|
})($ || ($ = {}));
|
|
2341
|
-
//mol/
|
|
2333
|
+
//mol/promise/promise/promise.ts
|
|
2334
|
+
;
|
|
2335
|
+
"use strict";
|
|
2336
|
+
var $;
|
|
2337
|
+
(function ($) {
|
|
2338
|
+
function $mol_wait_timeout_async(timeout) {
|
|
2339
|
+
const promise = $mol_promise();
|
|
2340
|
+
const task = new this.$mol_after_timeout(timeout, () => promise.done());
|
|
2341
|
+
return Object.assign(promise, {
|
|
2342
|
+
destructor: () => task.destructor()
|
|
2343
|
+
});
|
|
2344
|
+
}
|
|
2345
|
+
$.$mol_wait_timeout_async = $mol_wait_timeout_async;
|
|
2346
|
+
function $mol_wait_timeout(timeout) {
|
|
2347
|
+
return this.$mol_wire_sync(this).$mol_wait_timeout_async(timeout);
|
|
2348
|
+
}
|
|
2349
|
+
$.$mol_wait_timeout = $mol_wait_timeout;
|
|
2350
|
+
})($ || ($ = {}));
|
|
2351
|
+
//mol/wait/timeout/timeout.ts
|
|
2342
2352
|
;
|
|
2343
2353
|
"use strict";
|
|
2344
2354
|
var $;
|