mol_dump_lib 0.0.179 → 0.0.181
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.audit.js +1 -1
- package/node.d.ts +85 -138
- package/node.deps.json +1 -1
- package/node.js +761 -1030
- package/node.js.map +1 -1
- package/node.meta.tree +0 -58
- package/node.mjs +761 -1030
- package/node.test.js +798 -1091
- package/node.test.js.map +1 -1
- package/package.json +12 -20
- package/web.audit.js +1 -1
- package/web.d.ts +33 -45
- package/web.deps.json +1 -1
- package/web.js +67 -163
- package/web.js.map +1 -1
- package/web.meta.tree +0 -58
- package/web.mjs +67 -163
- package/web.test.js +33 -57
- package/web.test.js.map +1 -1
package/node.js
CHANGED
|
@@ -1076,894 +1076,904 @@ var $;
|
|
|
1076
1076
|
"use strict";
|
|
1077
1077
|
var $;
|
|
1078
1078
|
(function ($) {
|
|
1079
|
-
|
|
1080
|
-
|
|
1081
|
-
|
|
1082
|
-
|
|
1083
|
-
|
|
1084
|
-
|
|
1085
|
-
|
|
1086
|
-
|
|
1087
|
-
|
|
1088
|
-
|
|
1089
|
-
|
|
1090
|
-
|
|
1091
|
-
|
|
1092
|
-
|
|
1093
|
-
return existen;
|
|
1094
|
-
}
|
|
1095
|
-
return new $mol_wire_task(`${host?.[Symbol.toStringTag] ?? host}.${task.name}(#)`, task, host, args);
|
|
1096
|
-
};
|
|
1097
|
-
}
|
|
1098
|
-
get temp() {
|
|
1099
|
-
return true;
|
|
1100
|
-
}
|
|
1101
|
-
complete() {
|
|
1102
|
-
if ($mol_promise_like(this.cache))
|
|
1103
|
-
return;
|
|
1104
|
-
this.destructor();
|
|
1105
|
-
}
|
|
1106
|
-
put(next) {
|
|
1107
|
-
const prev = this.cache;
|
|
1108
|
-
this.cache = next;
|
|
1109
|
-
if ($mol_promise_like(next)) {
|
|
1110
|
-
this.cursor = $mol_wire_cursor.fresh;
|
|
1111
|
-
if (next !== prev)
|
|
1112
|
-
this.emit();
|
|
1113
|
-
return next;
|
|
1114
|
-
}
|
|
1115
|
-
this.cursor = $mol_wire_cursor.final;
|
|
1116
|
-
if (this.sub_empty)
|
|
1117
|
-
this.destructor();
|
|
1118
|
-
else if (next !== prev)
|
|
1119
|
-
this.emit();
|
|
1120
|
-
return next;
|
|
1121
|
-
}
|
|
1122
|
-
}
|
|
1123
|
-
$.$mol_wire_task = $mol_wire_task;
|
|
1124
|
-
})($ || ($ = {}));
|
|
1125
|
-
//mol/wire/task/task.ts
|
|
1126
|
-
;
|
|
1127
|
-
"use strict";
|
|
1128
|
-
var $;
|
|
1129
|
-
(function ($) {
|
|
1130
|
-
function $mol_wire_method(host, field, descr) {
|
|
1131
|
-
if (!descr)
|
|
1132
|
-
descr = Reflect.getOwnPropertyDescriptor(host, field);
|
|
1133
|
-
const orig = descr?.value ?? host[field];
|
|
1134
|
-
const sup = Reflect.getPrototypeOf(host);
|
|
1135
|
-
if (typeof sup[field] === 'function') {
|
|
1136
|
-
Object.defineProperty(orig, 'name', { value: sup[field].name });
|
|
1137
|
-
}
|
|
1138
|
-
const temp = $mol_wire_task.getter(orig);
|
|
1139
|
-
const value = function (...args) {
|
|
1140
|
-
const fiber = temp(this ?? null, args);
|
|
1141
|
-
return fiber.sync();
|
|
1079
|
+
function $mol_log3_area_lazy(event) {
|
|
1080
|
+
const self = this;
|
|
1081
|
+
const stack = self.$mol_log3_stack;
|
|
1082
|
+
const deep = stack.length;
|
|
1083
|
+
let logged = false;
|
|
1084
|
+
stack.push(() => {
|
|
1085
|
+
logged = true;
|
|
1086
|
+
self.$mol_log3_area.call(self, event);
|
|
1087
|
+
});
|
|
1088
|
+
return () => {
|
|
1089
|
+
if (logged)
|
|
1090
|
+
self.console.groupEnd();
|
|
1091
|
+
if (stack.length > deep)
|
|
1092
|
+
stack.length = deep;
|
|
1142
1093
|
};
|
|
1143
|
-
Object.defineProperty(value, 'name', { value: orig.name + ' ' });
|
|
1144
|
-
Object.assign(value, { orig });
|
|
1145
|
-
const descr2 = { ...descr, value };
|
|
1146
|
-
Reflect.defineProperty(host, field, descr2);
|
|
1147
|
-
return descr2;
|
|
1148
1094
|
}
|
|
1149
|
-
$.$
|
|
1095
|
+
$.$mol_log3_area_lazy = $mol_log3_area_lazy;
|
|
1096
|
+
$.$mol_log3_stack = [];
|
|
1150
1097
|
})($ || ($ = {}));
|
|
1151
|
-
//mol/
|
|
1152
|
-
;
|
|
1153
|
-
"use strict";
|
|
1154
|
-
//mol/type/tail/tail.ts
|
|
1155
|
-
;
|
|
1156
|
-
"use strict";
|
|
1157
|
-
//mol/type/foot/foot.ts
|
|
1098
|
+
//mol/log3/log3.ts
|
|
1158
1099
|
;
|
|
1159
1100
|
"use strict";
|
|
1160
1101
|
var $;
|
|
1161
1102
|
(function ($) {
|
|
1162
|
-
|
|
1163
|
-
|
|
1164
|
-
|
|
1165
|
-
|
|
1166
|
-
|
|
1167
|
-
|
|
1168
|
-
|
|
1169
|
-
|
|
1170
|
-
|
|
1171
|
-
|
|
1103
|
+
class $mol_span extends $mol_object2 {
|
|
1104
|
+
uri;
|
|
1105
|
+
source;
|
|
1106
|
+
row;
|
|
1107
|
+
col;
|
|
1108
|
+
length;
|
|
1109
|
+
constructor(uri, source, row, col, length) {
|
|
1110
|
+
super();
|
|
1111
|
+
this.uri = uri;
|
|
1112
|
+
this.source = source;
|
|
1113
|
+
this.row = row;
|
|
1114
|
+
this.col = col;
|
|
1115
|
+
this.length = length;
|
|
1116
|
+
this[Symbol.toStringTag] = `${this.uri}#${this.row}:${this.col}/${this.length}`;
|
|
1117
|
+
}
|
|
1118
|
+
static unknown = $mol_span.begin('?');
|
|
1119
|
+
static begin(uri, source = '') {
|
|
1120
|
+
return new $mol_span(uri, source, 1, 1, 0);
|
|
1121
|
+
}
|
|
1122
|
+
static end(uri, source) {
|
|
1123
|
+
return new $mol_span(uri, source, 1, source.length + 1, 0);
|
|
1124
|
+
}
|
|
1125
|
+
static entire(uri, source) {
|
|
1126
|
+
return new $mol_span(uri, source, 1, 1, source.length);
|
|
1127
|
+
}
|
|
1128
|
+
toString() {
|
|
1129
|
+
return this[Symbol.toStringTag];
|
|
1130
|
+
}
|
|
1131
|
+
toJSON() {
|
|
1132
|
+
return {
|
|
1133
|
+
uri: this.uri,
|
|
1134
|
+
row: this.row,
|
|
1135
|
+
col: this.col,
|
|
1136
|
+
length: this.length
|
|
1137
|
+
};
|
|
1138
|
+
}
|
|
1139
|
+
error(message, Class = Error) {
|
|
1140
|
+
return new Class(`${message} (${this})`);
|
|
1141
|
+
}
|
|
1142
|
+
span(row, col, length) {
|
|
1143
|
+
return new $mol_span(this.uri, this.source, row, col, length);
|
|
1144
|
+
}
|
|
1145
|
+
after(length = 0) {
|
|
1146
|
+
return new $mol_span(this.uri, this.source, this.row, this.col + this.length, length);
|
|
1147
|
+
}
|
|
1148
|
+
slice(begin, end = -1) {
|
|
1149
|
+
let len = this.length;
|
|
1150
|
+
if (begin < 0)
|
|
1151
|
+
begin += len;
|
|
1152
|
+
if (end < 0)
|
|
1153
|
+
end += len;
|
|
1154
|
+
if (begin < 0 || begin > len)
|
|
1155
|
+
this.$.$mol_fail(this.error(`Begin value '${begin}' out of range`, RangeError));
|
|
1156
|
+
if (end < 0 || end > len)
|
|
1157
|
+
this.$.$mol_fail(this.error(`End value '${end}' out of range`, RangeError));
|
|
1158
|
+
if (end < begin)
|
|
1159
|
+
this.$.$mol_fail(this.error(`End value '${end}' can't be less than begin value`, RangeError));
|
|
1160
|
+
return this.span(this.row, this.col + begin, end - begin);
|
|
1161
|
+
}
|
|
1172
1162
|
}
|
|
1173
|
-
$.$
|
|
1163
|
+
$.$mol_span = $mol_span;
|
|
1174
1164
|
})($ || ($ = {}));
|
|
1175
|
-
//mol/
|
|
1165
|
+
//mol/span/span.ts
|
|
1176
1166
|
;
|
|
1177
1167
|
"use strict";
|
|
1178
1168
|
var $;
|
|
1179
1169
|
(function ($) {
|
|
1180
|
-
function $
|
|
1181
|
-
|
|
1182
|
-
|
|
1183
|
-
|
|
1184
|
-
|
|
1185
|
-
|
|
1186
|
-
|
|
1170
|
+
function $mol_tree2_to_string(tree) {
|
|
1171
|
+
let output = [];
|
|
1172
|
+
function dump(tree, prefix = '') {
|
|
1173
|
+
if (tree.type.length) {
|
|
1174
|
+
if (!prefix.length) {
|
|
1175
|
+
prefix = "\t";
|
|
1176
|
+
}
|
|
1177
|
+
output.push(tree.type);
|
|
1178
|
+
if (tree.kids.length == 1) {
|
|
1179
|
+
output.push(' ');
|
|
1180
|
+
dump(tree.kids[0], prefix);
|
|
1181
|
+
return;
|
|
1182
|
+
}
|
|
1183
|
+
output.push("\n");
|
|
1184
|
+
}
|
|
1185
|
+
else if (tree.value.length || prefix.length) {
|
|
1186
|
+
output.push("\\" + tree.value + "\n");
|
|
1187
|
+
}
|
|
1188
|
+
for (const kid of tree.kids) {
|
|
1189
|
+
output.push(prefix);
|
|
1190
|
+
dump(kid, prefix + "\t");
|
|
1191
|
+
}
|
|
1192
|
+
}
|
|
1193
|
+
dump(tree);
|
|
1194
|
+
return output.join('');
|
|
1187
1195
|
}
|
|
1188
|
-
$.$
|
|
1196
|
+
$.$mol_tree2_to_string = $mol_tree2_to_string;
|
|
1189
1197
|
})($ || ($ = {}));
|
|
1190
|
-
//mol/
|
|
1198
|
+
//mol/tree2/to/string/string.ts
|
|
1191
1199
|
;
|
|
1192
1200
|
"use strict";
|
|
1193
1201
|
var $;
|
|
1194
1202
|
(function ($) {
|
|
1195
|
-
class $
|
|
1196
|
-
|
|
1197
|
-
|
|
1198
|
-
|
|
1199
|
-
|
|
1200
|
-
|
|
1201
|
-
|
|
1202
|
-
|
|
1203
|
-
|
|
1204
|
-
|
|
1205
|
-
|
|
1203
|
+
class $mol_tree2 extends Object {
|
|
1204
|
+
type;
|
|
1205
|
+
value;
|
|
1206
|
+
kids;
|
|
1207
|
+
span;
|
|
1208
|
+
constructor(type, value, kids, span) {
|
|
1209
|
+
super();
|
|
1210
|
+
this.type = type;
|
|
1211
|
+
this.value = value;
|
|
1212
|
+
this.kids = kids;
|
|
1213
|
+
this.span = span;
|
|
1214
|
+
this[Symbol.toStringTag] = type || '\\' + value;
|
|
1206
1215
|
}
|
|
1207
|
-
static
|
|
1208
|
-
|
|
1209
|
-
let dict = Object.getOwnPropertyDescriptor(host ?? task, field)?.value;
|
|
1210
|
-
const prefix = host?.[Symbol.toStringTag] ?? (host instanceof Function ? $$.$mol_func_name(host) : host);
|
|
1211
|
-
const id = `${prefix}.${task.name}(${$mol_key(key).replace(/^"|"$/g, "'")})`;
|
|
1212
|
-
if (dict) {
|
|
1213
|
-
const existen = dict.get(id);
|
|
1214
|
-
if (existen)
|
|
1215
|
-
return existen;
|
|
1216
|
-
}
|
|
1217
|
-
else {
|
|
1218
|
-
dict = (host ?? task)[field] = new Map();
|
|
1219
|
-
}
|
|
1220
|
-
const fiber = new $mol_wire_atom(id, task, host, [key]);
|
|
1221
|
-
dict.set(id, fiber);
|
|
1222
|
-
return fiber;
|
|
1216
|
+
static list(kids, span = $mol_span.unknown) {
|
|
1217
|
+
return new $mol_tree2('', '', kids, span);
|
|
1223
1218
|
}
|
|
1224
|
-
|
|
1225
|
-
|
|
1226
|
-
static watch() {
|
|
1227
|
-
$mol_wire_atom.watcher = new $mol_after_frame($mol_wire_atom.watch);
|
|
1228
|
-
for (const atom of $mol_wire_atom.watching) {
|
|
1229
|
-
if (atom.cursor === $mol_wire_cursor.final) {
|
|
1230
|
-
$mol_wire_atom.watching.delete(atom);
|
|
1231
|
-
}
|
|
1232
|
-
else {
|
|
1233
|
-
atom.cursor = $mol_wire_cursor.stale;
|
|
1234
|
-
atom.fresh();
|
|
1235
|
-
}
|
|
1236
|
-
}
|
|
1219
|
+
list(kids) {
|
|
1220
|
+
return $mol_tree2.list(kids, this.span);
|
|
1237
1221
|
}
|
|
1238
|
-
|
|
1239
|
-
|
|
1240
|
-
|
|
1222
|
+
static data(value, kids = [], span = $mol_span.unknown) {
|
|
1223
|
+
const chunks = value.split('\n');
|
|
1224
|
+
if (chunks.length > 1) {
|
|
1225
|
+
let kid_span = span.span(span.row, span.col, 0);
|
|
1226
|
+
const data = chunks.map(chunk => {
|
|
1227
|
+
kid_span = kid_span.after(chunk.length);
|
|
1228
|
+
return new $mol_tree2('', chunk, [], kid_span);
|
|
1229
|
+
});
|
|
1230
|
+
kids = [...data, ...kids];
|
|
1231
|
+
value = '';
|
|
1241
1232
|
}
|
|
1242
|
-
$
|
|
1233
|
+
return new $mol_tree2('', value, kids, span);
|
|
1243
1234
|
}
|
|
1244
|
-
|
|
1245
|
-
return
|
|
1235
|
+
data(value, kids = []) {
|
|
1236
|
+
return $mol_tree2.data(value, kids, this.span);
|
|
1246
1237
|
}
|
|
1247
|
-
|
|
1248
|
-
|
|
1238
|
+
static struct(type, kids = [], span = $mol_span.unknown) {
|
|
1239
|
+
if (/[ \n\t\\]/.test(type)) {
|
|
1240
|
+
$$.$mol_fail(span.error(`Wrong type ${JSON.stringify(type)}`));
|
|
1241
|
+
}
|
|
1242
|
+
return new $mol_tree2(type, '', kids, span);
|
|
1249
1243
|
}
|
|
1250
|
-
|
|
1251
|
-
return
|
|
1252
|
-
if (next !== undefined)
|
|
1253
|
-
return this.resync([...this.args, next]);
|
|
1254
|
-
if (!$mol_wire_fiber.warm)
|
|
1255
|
-
return this.result();
|
|
1256
|
-
if ($mol_wire_auto()?.temp) {
|
|
1257
|
-
return this.once();
|
|
1258
|
-
}
|
|
1259
|
-
else {
|
|
1260
|
-
return this.sync();
|
|
1261
|
-
}
|
|
1262
|
-
}, { atom: this });
|
|
1244
|
+
struct(type, kids = []) {
|
|
1245
|
+
return $mol_tree2.struct(type, kids, this.span);
|
|
1263
1246
|
}
|
|
1264
|
-
|
|
1265
|
-
|
|
1266
|
-
|
|
1267
|
-
|
|
1268
|
-
|
|
1247
|
+
clone(kids, span = this.span) {
|
|
1248
|
+
return new $mol_tree2(this.type, this.value, kids, span);
|
|
1249
|
+
}
|
|
1250
|
+
text() {
|
|
1251
|
+
var values = [];
|
|
1252
|
+
for (var kid of this.kids) {
|
|
1253
|
+
if (kid.type)
|
|
1254
|
+
continue;
|
|
1255
|
+
values.push(kid.value);
|
|
1269
1256
|
}
|
|
1270
|
-
|
|
1271
|
-
|
|
1272
|
-
|
|
1257
|
+
return this.value + values.join('\n');
|
|
1258
|
+
}
|
|
1259
|
+
static fromString(str, uri = 'unknown') {
|
|
1260
|
+
return $$.$mol_tree2_from_string(str, uri);
|
|
1261
|
+
}
|
|
1262
|
+
toString() {
|
|
1263
|
+
return $$.$mol_tree2_to_string(this);
|
|
1264
|
+
}
|
|
1265
|
+
insert(value, ...path) {
|
|
1266
|
+
if (path.length === 0)
|
|
1267
|
+
return value;
|
|
1268
|
+
const type = path[0];
|
|
1269
|
+
if (typeof type === 'string') {
|
|
1270
|
+
let replaced = false;
|
|
1271
|
+
const sub = this.kids.map((item, index) => {
|
|
1272
|
+
if (item.type !== type)
|
|
1273
|
+
return item;
|
|
1274
|
+
replaced = true;
|
|
1275
|
+
return item.insert(value, ...path.slice(1));
|
|
1276
|
+
}).filter(Boolean);
|
|
1277
|
+
if (!replaced && value) {
|
|
1278
|
+
sub.push(this.struct(type, []).insert(value, ...path.slice(1)));
|
|
1279
|
+
}
|
|
1280
|
+
return this.clone(sub);
|
|
1281
|
+
}
|
|
1282
|
+
else if (typeof type === 'number') {
|
|
1283
|
+
const sub = this.kids.slice();
|
|
1284
|
+
sub[type] = (sub[type] || this.list([]))
|
|
1285
|
+
.insert(value, ...path.slice(1));
|
|
1286
|
+
return this.clone(sub.filter(Boolean));
|
|
1273
1287
|
}
|
|
1274
1288
|
else {
|
|
1275
|
-
|
|
1276
|
-
|
|
1289
|
+
const kids = ((this.kids.length === 0) ? [this.list([])] : this.kids)
|
|
1290
|
+
.map(item => item.insert(value, ...path.slice(1)))
|
|
1291
|
+
.filter(Boolean);
|
|
1292
|
+
return this.clone(kids);
|
|
1277
1293
|
}
|
|
1278
1294
|
}
|
|
1279
|
-
|
|
1280
|
-
|
|
1281
|
-
|
|
1282
|
-
|
|
1283
|
-
|
|
1284
|
-
|
|
1295
|
+
select(...path) {
|
|
1296
|
+
let next = [this];
|
|
1297
|
+
for (const type of path) {
|
|
1298
|
+
if (!next.length)
|
|
1299
|
+
break;
|
|
1300
|
+
const prev = next;
|
|
1301
|
+
next = [];
|
|
1302
|
+
for (var item of prev) {
|
|
1303
|
+
switch (typeof (type)) {
|
|
1304
|
+
case 'string':
|
|
1305
|
+
for (var child of item.kids) {
|
|
1306
|
+
if (child.type == type) {
|
|
1307
|
+
next.push(child);
|
|
1308
|
+
}
|
|
1309
|
+
}
|
|
1310
|
+
break;
|
|
1311
|
+
case 'number':
|
|
1312
|
+
if (type < item.kids.length)
|
|
1313
|
+
next.push(item.kids[type]);
|
|
1314
|
+
break;
|
|
1315
|
+
default: next.push(...item.kids);
|
|
1316
|
+
}
|
|
1285
1317
|
}
|
|
1286
|
-
|
|
1287
|
-
|
|
1318
|
+
}
|
|
1319
|
+
return this.list(next);
|
|
1320
|
+
}
|
|
1321
|
+
filter(path, value) {
|
|
1322
|
+
const sub = this.kids.filter(item => {
|
|
1323
|
+
var found = item.select(...path);
|
|
1324
|
+
if (value === undefined) {
|
|
1325
|
+
return Boolean(found.kids.length);
|
|
1288
1326
|
}
|
|
1289
|
-
|
|
1290
|
-
|
|
1327
|
+
else {
|
|
1328
|
+
return found.kids.some(child => child.value == value);
|
|
1291
1329
|
}
|
|
1292
|
-
|
|
1293
|
-
|
|
1294
|
-
|
|
1295
|
-
|
|
1296
|
-
|
|
1297
|
-
|
|
1298
|
-
|
|
1330
|
+
});
|
|
1331
|
+
return this.clone(sub);
|
|
1332
|
+
}
|
|
1333
|
+
hack(belt, context = {}) {
|
|
1334
|
+
return [].concat(...this.kids.map(child => {
|
|
1335
|
+
let handle = belt[child.type] || belt[''];
|
|
1336
|
+
if (!handle || handle === Object.prototype[child.type]) {
|
|
1337
|
+
handle = (input, belt, context) => [
|
|
1338
|
+
input.clone(input.hack(belt, context), context.span)
|
|
1339
|
+
];
|
|
1299
1340
|
}
|
|
1300
|
-
|
|
1301
|
-
|
|
1302
|
-
|
|
1303
|
-
|
|
1304
|
-
|
|
1305
|
-
|
|
1306
|
-
|
|
1307
|
-
|
|
1308
|
-
|
|
1341
|
+
try {
|
|
1342
|
+
return handle(child, belt, context);
|
|
1343
|
+
}
|
|
1344
|
+
catch (error) {
|
|
1345
|
+
error.message += `\n${child.clone([])}${child.span}`;
|
|
1346
|
+
$mol_fail_hidden(error);
|
|
1347
|
+
}
|
|
1348
|
+
}));
|
|
1349
|
+
}
|
|
1350
|
+
error(message, Class = Error) {
|
|
1351
|
+
return this.span.error(`${message}\n${this.clone([])}`, Class);
|
|
1309
1352
|
}
|
|
1310
1353
|
}
|
|
1311
|
-
|
|
1312
|
-
|
|
1313
|
-
|
|
1314
|
-
|
|
1315
|
-
|
|
1316
|
-
|
|
1317
|
-
$.$
|
|
1354
|
+
$.$mol_tree2 = $mol_tree2;
|
|
1355
|
+
class $mol_tree2_empty extends $mol_tree2 {
|
|
1356
|
+
constructor() {
|
|
1357
|
+
super('', '', [], $mol_span.unknown);
|
|
1358
|
+
}
|
|
1359
|
+
}
|
|
1360
|
+
$.$mol_tree2_empty = $mol_tree2_empty;
|
|
1318
1361
|
})($ || ($ = {}));
|
|
1319
|
-
//mol/
|
|
1362
|
+
//mol/tree2/tree2.ts
|
|
1320
1363
|
;
|
|
1321
1364
|
"use strict";
|
|
1322
1365
|
var $;
|
|
1323
1366
|
(function ($) {
|
|
1324
|
-
|
|
1325
|
-
|
|
1326
|
-
|
|
1327
|
-
|
|
1328
|
-
|
|
1329
|
-
|
|
1330
|
-
|
|
1367
|
+
class $mol_error_syntax extends SyntaxError {
|
|
1368
|
+
reason;
|
|
1369
|
+
line;
|
|
1370
|
+
span;
|
|
1371
|
+
constructor(reason, line, span) {
|
|
1372
|
+
super(`${reason}\n${span}\n${line.substring(0, span.col - 1).replace(/\S/g, ' ')}${''.padEnd(span.length, '!')}\n${line}`);
|
|
1373
|
+
this.reason = reason;
|
|
1374
|
+
this.line = line;
|
|
1375
|
+
this.span = span;
|
|
1331
1376
|
}
|
|
1332
|
-
const descr2 = {
|
|
1333
|
-
...descr,
|
|
1334
|
-
value: function (...args) {
|
|
1335
|
-
let atom = $mol_wire_atom.solo(this, orig);
|
|
1336
|
-
if ((args.length === 0) || (args[0] === undefined)) {
|
|
1337
|
-
if (!$mol_wire_fiber.warm)
|
|
1338
|
-
return atom.result();
|
|
1339
|
-
if ($mol_wire_auto()?.temp) {
|
|
1340
|
-
return atom.once();
|
|
1341
|
-
}
|
|
1342
|
-
else {
|
|
1343
|
-
return atom.sync();
|
|
1344
|
-
}
|
|
1345
|
-
}
|
|
1346
|
-
return atom.resync(args);
|
|
1347
|
-
}
|
|
1348
|
-
};
|
|
1349
|
-
Reflect.defineProperty(descr2.value, 'name', { value: orig.name + ' ' });
|
|
1350
|
-
Reflect.defineProperty(descr2.value, 'length', { value: orig.length });
|
|
1351
|
-
Object.assign(descr2.value, { orig });
|
|
1352
|
-
Reflect.defineProperty(host, field, descr2);
|
|
1353
|
-
return descr2;
|
|
1354
1377
|
}
|
|
1355
|
-
$.$
|
|
1378
|
+
$.$mol_error_syntax = $mol_error_syntax;
|
|
1356
1379
|
})($ || ($ = {}));
|
|
1357
|
-
//mol/
|
|
1380
|
+
//mol/error/syntax/syntax.ts
|
|
1358
1381
|
;
|
|
1359
1382
|
"use strict";
|
|
1360
1383
|
var $;
|
|
1361
1384
|
(function ($) {
|
|
1362
|
-
function $
|
|
1363
|
-
|
|
1364
|
-
|
|
1365
|
-
|
|
1366
|
-
|
|
1367
|
-
|
|
1368
|
-
|
|
1369
|
-
|
|
1370
|
-
|
|
1371
|
-
|
|
1372
|
-
|
|
1373
|
-
|
|
1374
|
-
|
|
1375
|
-
|
|
1376
|
-
|
|
1377
|
-
|
|
1378
|
-
|
|
1379
|
-
|
|
1380
|
-
|
|
1381
|
-
|
|
1382
|
-
|
|
1383
|
-
}
|
|
1384
|
-
|
|
1385
|
-
|
|
1386
|
-
|
|
1387
|
-
|
|
1388
|
-
|
|
1389
|
-
|
|
1390
|
-
|
|
1391
|
-
return descr2;
|
|
1392
|
-
}
|
|
1393
|
-
$.$mol_wire_plex = $mol_wire_plex;
|
|
1394
|
-
})($ || ($ = {}));
|
|
1395
|
-
//mol/wire/plex/plex.ts
|
|
1396
|
-
;
|
|
1397
|
-
"use strict";
|
|
1398
|
-
var $;
|
|
1399
|
-
(function ($) {
|
|
1400
|
-
$.$mol_mem = $mol_wire_solo;
|
|
1401
|
-
$.$mol_mem_key = $mol_wire_plex;
|
|
1402
|
-
})($ || ($ = {}));
|
|
1403
|
-
//mol/mem/mem.ts
|
|
1404
|
-
;
|
|
1405
|
-
"use strict";
|
|
1406
|
-
var $;
|
|
1407
|
-
(function ($) {
|
|
1408
|
-
})($ || ($ = {}));
|
|
1409
|
-
//mol/dom/context/context.ts
|
|
1410
|
-
;
|
|
1411
|
-
"use strict";
|
|
1412
|
-
//node/node.ts
|
|
1413
|
-
;
|
|
1414
|
-
"use strict";
|
|
1415
|
-
var $node = new Proxy({ require }, {
|
|
1416
|
-
get(target, name, wrapper) {
|
|
1417
|
-
if (target[name])
|
|
1418
|
-
return target[name];
|
|
1419
|
-
const mod = target.require('module');
|
|
1420
|
-
if (mod.builtinModules.indexOf(name) >= 0)
|
|
1421
|
-
return target.require(name);
|
|
1422
|
-
if (name[0] === '.')
|
|
1423
|
-
return target.require(name);
|
|
1424
|
-
const path = target.require('path');
|
|
1425
|
-
const fs = target.require('fs');
|
|
1426
|
-
let dir = path.resolve('.');
|
|
1427
|
-
const suffix = `./node_modules/${name}`;
|
|
1428
|
-
const $$ = $;
|
|
1429
|
-
while (!fs.existsSync(path.join(dir, suffix))) {
|
|
1430
|
-
const parent = path.resolve(dir, '..');
|
|
1431
|
-
if (parent === dir) {
|
|
1432
|
-
$$.$mol_exec('.', 'npm', 'install', '--omit=dev', name);
|
|
1433
|
-
try {
|
|
1434
|
-
$$.$mol_exec('.', 'npm', 'install', '--omit=dev', '@types/' + name);
|
|
1385
|
+
function $mol_tree2_from_string(str, uri = '?') {
|
|
1386
|
+
const span = $mol_span.entire(uri, str);
|
|
1387
|
+
var root = $mol_tree2.list([], span);
|
|
1388
|
+
var stack = [root];
|
|
1389
|
+
var pos = 0, row = 0, min_indent = 0;
|
|
1390
|
+
while (str.length > pos) {
|
|
1391
|
+
var indent = 0;
|
|
1392
|
+
var line_start = pos;
|
|
1393
|
+
row++;
|
|
1394
|
+
while (str.length > pos && str[pos] == '\t') {
|
|
1395
|
+
indent++;
|
|
1396
|
+
pos++;
|
|
1397
|
+
}
|
|
1398
|
+
if (!root.kids.length) {
|
|
1399
|
+
min_indent = indent;
|
|
1400
|
+
}
|
|
1401
|
+
indent -= min_indent;
|
|
1402
|
+
if (indent < 0 || indent >= stack.length) {
|
|
1403
|
+
const sp = span.span(row, 1, pos - line_start);
|
|
1404
|
+
while (str.length > pos && str[pos] != '\n') {
|
|
1405
|
+
pos++;
|
|
1406
|
+
}
|
|
1407
|
+
if (indent < 0) {
|
|
1408
|
+
if (str.length > pos) {
|
|
1409
|
+
this.$mol_fail(new this.$mol_error_syntax(`Too few tabs`, str.substring(line_start, pos), sp));
|
|
1410
|
+
}
|
|
1411
|
+
}
|
|
1412
|
+
else {
|
|
1413
|
+
this.$mol_fail(new this.$mol_error_syntax(`Too many tabs`, str.substring(line_start, pos), sp));
|
|
1435
1414
|
}
|
|
1436
|
-
catch { }
|
|
1437
|
-
break;
|
|
1438
1415
|
}
|
|
1439
|
-
|
|
1440
|
-
|
|
1416
|
+
stack.length = indent + 1;
|
|
1417
|
+
var parent = stack[indent];
|
|
1418
|
+
while (str.length > pos && str[pos] != '\\' && str[pos] != '\n') {
|
|
1419
|
+
var error_start = pos;
|
|
1420
|
+
while (str.length > pos && (str[pos] == ' ' || str[pos] == '\t')) {
|
|
1421
|
+
pos++;
|
|
1422
|
+
}
|
|
1423
|
+
if (pos > error_start) {
|
|
1424
|
+
let line_end = str.indexOf('\n', pos);
|
|
1425
|
+
if (line_end === -1)
|
|
1426
|
+
line_end = str.length;
|
|
1427
|
+
const sp = span.span(row, error_start - line_start + 1, pos - error_start);
|
|
1428
|
+
this.$mol_fail(new this.$mol_error_syntax(`Wrong nodes separator`, str.substring(line_start, line_end), sp));
|
|
1429
|
+
}
|
|
1430
|
+
var type_start = pos;
|
|
1431
|
+
while (str.length > pos &&
|
|
1432
|
+
str[pos] != '\\' &&
|
|
1433
|
+
str[pos] != ' ' &&
|
|
1434
|
+
str[pos] != '\t' &&
|
|
1435
|
+
str[pos] != '\n') {
|
|
1436
|
+
pos++;
|
|
1437
|
+
}
|
|
1438
|
+
if (pos > type_start) {
|
|
1439
|
+
let next = new $mol_tree2(str.slice(type_start, pos), '', [], span.span(row, type_start - line_start + 1, pos - type_start));
|
|
1440
|
+
const parent_kids = parent.kids;
|
|
1441
|
+
parent_kids.push(next);
|
|
1442
|
+
parent = next;
|
|
1443
|
+
}
|
|
1444
|
+
if (str.length > pos && str[pos] == ' ') {
|
|
1445
|
+
pos++;
|
|
1446
|
+
}
|
|
1447
|
+
}
|
|
1448
|
+
if (str.length > pos && str[pos] == '\\') {
|
|
1449
|
+
var data_start = pos;
|
|
1450
|
+
while (str.length > pos && str[pos] != '\n') {
|
|
1451
|
+
pos++;
|
|
1452
|
+
}
|
|
1453
|
+
let next = new $mol_tree2('', str.slice(data_start + 1, pos), [], span.span(row, data_start - line_start + 2, pos - data_start - 1));
|
|
1454
|
+
const parent_kids = parent.kids;
|
|
1455
|
+
parent_kids.push(next);
|
|
1456
|
+
parent = next;
|
|
1457
|
+
}
|
|
1458
|
+
if (str.length === pos && stack.length > 0) {
|
|
1459
|
+
const sp = span.span(row, pos - line_start + 1, 1);
|
|
1460
|
+
this.$mol_fail(new this.$mol_error_syntax(`Unexpected EOF, LF required`, str.substring(line_start, str.length), sp));
|
|
1441
1461
|
}
|
|
1462
|
+
stack.push(parent);
|
|
1463
|
+
pos++;
|
|
1442
1464
|
}
|
|
1443
|
-
return
|
|
1444
|
-
},
|
|
1445
|
-
set(target, name, value) {
|
|
1446
|
-
target[name] = value;
|
|
1447
|
-
return true;
|
|
1448
|
-
},
|
|
1449
|
-
});
|
|
1450
|
-
require = (req => Object.assign(function require(name) {
|
|
1451
|
-
return $node[name];
|
|
1452
|
-
}, req))(require);
|
|
1453
|
-
//node/node.node.ts
|
|
1454
|
-
;
|
|
1455
|
-
"use strict";
|
|
1456
|
-
var $;
|
|
1457
|
-
(function ($) {
|
|
1458
|
-
function $mol_log3_area_lazy(event) {
|
|
1459
|
-
const self = this;
|
|
1460
|
-
const stack = self.$mol_log3_stack;
|
|
1461
|
-
const deep = stack.length;
|
|
1462
|
-
let logged = false;
|
|
1463
|
-
stack.push(() => {
|
|
1464
|
-
logged = true;
|
|
1465
|
-
self.$mol_log3_area.call(self, event);
|
|
1466
|
-
});
|
|
1467
|
-
return () => {
|
|
1468
|
-
if (logged)
|
|
1469
|
-
self.console.groupEnd();
|
|
1470
|
-
if (stack.length > deep)
|
|
1471
|
-
stack.length = deep;
|
|
1472
|
-
};
|
|
1465
|
+
return root;
|
|
1473
1466
|
}
|
|
1474
|
-
$.$
|
|
1475
|
-
$.$mol_log3_stack = [];
|
|
1467
|
+
$.$mol_tree2_from_string = $mol_tree2_from_string;
|
|
1476
1468
|
})($ || ($ = {}));
|
|
1477
|
-
//mol/
|
|
1469
|
+
//mol/tree2/from/string/string.ts
|
|
1478
1470
|
;
|
|
1479
1471
|
"use strict";
|
|
1480
1472
|
var $;
|
|
1481
1473
|
(function ($) {
|
|
1482
|
-
|
|
1483
|
-
|
|
1484
|
-
|
|
1485
|
-
row;
|
|
1486
|
-
col;
|
|
1487
|
-
length;
|
|
1488
|
-
constructor(uri, source, row, col, length) {
|
|
1489
|
-
super();
|
|
1490
|
-
this.uri = uri;
|
|
1491
|
-
this.source = source;
|
|
1492
|
-
this.row = row;
|
|
1493
|
-
this.col = col;
|
|
1494
|
-
this.length = length;
|
|
1495
|
-
this[Symbol.toStringTag] = `${this.uri}#${this.row}:${this.col}/${this.length}`;
|
|
1496
|
-
}
|
|
1497
|
-
static unknown = $mol_span.begin('?');
|
|
1498
|
-
static begin(uri, source = '') {
|
|
1499
|
-
return new $mol_span(uri, source, 1, 1, 0);
|
|
1500
|
-
}
|
|
1501
|
-
static end(uri, source) {
|
|
1502
|
-
return new $mol_span(uri, source, 1, source.length + 1, 0);
|
|
1474
|
+
function $mol_tree2_from_json(json, span = $mol_span.unknown) {
|
|
1475
|
+
if (typeof json === 'boolean' || typeof json === 'number' || json === null) {
|
|
1476
|
+
return new $mol_tree2(String(json), '', [], span);
|
|
1503
1477
|
}
|
|
1504
|
-
|
|
1505
|
-
return
|
|
1478
|
+
if (typeof json === 'string') {
|
|
1479
|
+
return $mol_tree2.data(json, [], span);
|
|
1506
1480
|
}
|
|
1507
|
-
|
|
1508
|
-
|
|
1481
|
+
if (Array.isArray(json)) {
|
|
1482
|
+
const sub = json.map(json => $mol_tree2_from_json(json, span));
|
|
1483
|
+
return new $mol_tree2('/', '', sub, span);
|
|
1509
1484
|
}
|
|
1510
|
-
|
|
1511
|
-
|
|
1512
|
-
|
|
1513
|
-
row: this.row,
|
|
1514
|
-
col: this.col,
|
|
1515
|
-
length: this.length
|
|
1516
|
-
};
|
|
1485
|
+
if (ArrayBuffer.isView(json)) {
|
|
1486
|
+
const buf = new Uint8Array(json.buffer, json.byteOffset, json.byteLength);
|
|
1487
|
+
return $mol_tree2.data(String.fromCharCode(...buf), [], span);
|
|
1517
1488
|
}
|
|
1518
|
-
|
|
1519
|
-
return new
|
|
1489
|
+
if (json instanceof Date) {
|
|
1490
|
+
return new $mol_tree2('', json.toISOString(), [], span);
|
|
1520
1491
|
}
|
|
1521
|
-
|
|
1522
|
-
return
|
|
1492
|
+
if (typeof json.toJSON === 'function') {
|
|
1493
|
+
return $mol_tree2_from_json(json.toJSON());
|
|
1523
1494
|
}
|
|
1524
|
-
|
|
1525
|
-
|
|
1495
|
+
if (json instanceof Error) {
|
|
1496
|
+
const { name, message, stack } = json;
|
|
1497
|
+
json = { ...json, name, message, stack };
|
|
1526
1498
|
}
|
|
1527
|
-
|
|
1528
|
-
|
|
1529
|
-
|
|
1530
|
-
|
|
1531
|
-
|
|
1532
|
-
|
|
1533
|
-
if (
|
|
1534
|
-
|
|
1535
|
-
|
|
1536
|
-
|
|
1537
|
-
|
|
1538
|
-
|
|
1539
|
-
return this.span(this.row, this.col + begin, end - begin);
|
|
1499
|
+
const sub = [];
|
|
1500
|
+
for (var key in json) {
|
|
1501
|
+
const val = json[key];
|
|
1502
|
+
if (val === undefined)
|
|
1503
|
+
continue;
|
|
1504
|
+
const subsub = $mol_tree2_from_json(val, span);
|
|
1505
|
+
if (/^[^\n\t\\ ]+$/.test(key)) {
|
|
1506
|
+
sub.push(new $mol_tree2(key, '', [subsub], span));
|
|
1507
|
+
}
|
|
1508
|
+
else {
|
|
1509
|
+
sub.push($mol_tree2.data(key, [subsub], span));
|
|
1510
|
+
}
|
|
1540
1511
|
}
|
|
1512
|
+
return new $mol_tree2('*', '', sub, span);
|
|
1541
1513
|
}
|
|
1542
|
-
$.$
|
|
1514
|
+
$.$mol_tree2_from_json = $mol_tree2_from_json;
|
|
1543
1515
|
})($ || ($ = {}));
|
|
1544
|
-
//mol/
|
|
1516
|
+
//mol/tree2/from/json/json.ts
|
|
1545
1517
|
;
|
|
1546
1518
|
"use strict";
|
|
1547
1519
|
var $;
|
|
1548
1520
|
(function ($) {
|
|
1549
|
-
|
|
1550
|
-
|
|
1551
|
-
|
|
1552
|
-
|
|
1553
|
-
|
|
1554
|
-
|
|
1555
|
-
|
|
1556
|
-
|
|
1557
|
-
|
|
1558
|
-
|
|
1559
|
-
|
|
1560
|
-
|
|
1561
|
-
|
|
1562
|
-
|
|
1563
|
-
|
|
1564
|
-
|
|
1565
|
-
|
|
1566
|
-
|
|
1567
|
-
|
|
1568
|
-
|
|
1569
|
-
|
|
1570
|
-
|
|
1521
|
+
class $mol_term_color {
|
|
1522
|
+
static reset = this.ansi(0, 0);
|
|
1523
|
+
static bold = this.ansi(1, 22);
|
|
1524
|
+
static italic = this.ansi(3, 23);
|
|
1525
|
+
static underline = this.ansi(4, 24);
|
|
1526
|
+
static inverse = this.ansi(7, 27);
|
|
1527
|
+
static hidden = this.ansi(8, 28);
|
|
1528
|
+
static strike = this.ansi(9, 29);
|
|
1529
|
+
static gray = this.ansi(90, 39);
|
|
1530
|
+
static red = this.ansi(91, 39);
|
|
1531
|
+
static green = this.ansi(92, 39);
|
|
1532
|
+
static yellow = this.ansi(93, 39);
|
|
1533
|
+
static blue = this.ansi(94, 39);
|
|
1534
|
+
static magenta = this.ansi(95, 39);
|
|
1535
|
+
static cyan = this.ansi(96, 39);
|
|
1536
|
+
static Gray = (str) => this.inverse(this.gray(str));
|
|
1537
|
+
static Red = (str) => this.inverse(this.red(str));
|
|
1538
|
+
static Green = (str) => this.inverse(this.green(str));
|
|
1539
|
+
static Yellow = (str) => this.inverse(this.yellow(str));
|
|
1540
|
+
static Blue = (str) => this.inverse(this.blue(str));
|
|
1541
|
+
static Magenta = (str) => this.inverse(this.magenta(str));
|
|
1542
|
+
static Cyan = (str) => this.inverse(this.cyan(str));
|
|
1543
|
+
static ansi(open, close) {
|
|
1544
|
+
if (typeof process === 'undefined')
|
|
1545
|
+
return String;
|
|
1546
|
+
if (!process.stdout.isTTY)
|
|
1547
|
+
return String;
|
|
1548
|
+
const prefix = `\x1b[${open}m`;
|
|
1549
|
+
const postfix = `\x1b[${close}m`;
|
|
1550
|
+
const suffix_regexp = new RegExp(postfix.replace('[', '\\['), 'g');
|
|
1551
|
+
return function colorer(str) {
|
|
1552
|
+
str = String(str);
|
|
1553
|
+
if (str === '')
|
|
1554
|
+
return str;
|
|
1555
|
+
const suffix = str.replace(suffix_regexp, prefix);
|
|
1556
|
+
return prefix + suffix + postfix;
|
|
1557
|
+
};
|
|
1571
1558
|
}
|
|
1572
|
-
dump(tree);
|
|
1573
|
-
return output.join('');
|
|
1574
1559
|
}
|
|
1575
|
-
$.$
|
|
1560
|
+
$.$mol_term_color = $mol_term_color;
|
|
1576
1561
|
})($ || ($ = {}));
|
|
1577
|
-
//mol/
|
|
1562
|
+
//mol/term/color/color.ts
|
|
1578
1563
|
;
|
|
1579
1564
|
"use strict";
|
|
1580
1565
|
var $;
|
|
1581
1566
|
(function ($) {
|
|
1582
|
-
|
|
1583
|
-
|
|
1584
|
-
|
|
1585
|
-
|
|
1586
|
-
|
|
1587
|
-
|
|
1588
|
-
|
|
1589
|
-
this.
|
|
1590
|
-
|
|
1591
|
-
|
|
1592
|
-
|
|
1593
|
-
|
|
1594
|
-
|
|
1595
|
-
|
|
1596
|
-
|
|
1597
|
-
|
|
1598
|
-
|
|
1599
|
-
|
|
1600
|
-
|
|
1601
|
-
|
|
1602
|
-
|
|
1603
|
-
|
|
1604
|
-
|
|
1605
|
-
|
|
1606
|
-
|
|
1607
|
-
|
|
1608
|
-
|
|
1609
|
-
|
|
1610
|
-
|
|
1611
|
-
|
|
1612
|
-
|
|
1613
|
-
|
|
1614
|
-
|
|
1615
|
-
|
|
1616
|
-
|
|
1617
|
-
|
|
1618
|
-
|
|
1619
|
-
|
|
1620
|
-
|
|
1621
|
-
|
|
1622
|
-
}
|
|
1623
|
-
struct(type, kids = []) {
|
|
1624
|
-
return $mol_tree2.struct(type, kids, this.span);
|
|
1625
|
-
}
|
|
1626
|
-
clone(kids, span = this.span) {
|
|
1627
|
-
return new $mol_tree2(this.type, this.value, kids, span);
|
|
1628
|
-
}
|
|
1629
|
-
text() {
|
|
1630
|
-
var values = [];
|
|
1631
|
-
for (var kid of this.kids) {
|
|
1632
|
-
if (kid.type)
|
|
1633
|
-
continue;
|
|
1634
|
-
values.push(kid.value);
|
|
1635
|
-
}
|
|
1636
|
-
return this.value + values.join('\n');
|
|
1637
|
-
}
|
|
1638
|
-
static fromString(str, uri = 'unknown') {
|
|
1639
|
-
return $$.$mol_tree2_from_string(str, uri);
|
|
1640
|
-
}
|
|
1641
|
-
toString() {
|
|
1642
|
-
return $$.$mol_tree2_to_string(this);
|
|
1643
|
-
}
|
|
1644
|
-
insert(value, ...path) {
|
|
1645
|
-
if (path.length === 0)
|
|
1646
|
-
return value;
|
|
1647
|
-
const type = path[0];
|
|
1648
|
-
if (typeof type === 'string') {
|
|
1649
|
-
let replaced = false;
|
|
1650
|
-
const sub = this.kids.map((item, index) => {
|
|
1651
|
-
if (item.type !== type)
|
|
1652
|
-
return item;
|
|
1653
|
-
replaced = true;
|
|
1654
|
-
return item.insert(value, ...path.slice(1));
|
|
1655
|
-
}).filter(Boolean);
|
|
1656
|
-
if (!replaced && value) {
|
|
1657
|
-
sub.push(this.struct(type, []).insert(value, ...path.slice(1)));
|
|
1567
|
+
function $mol_log3_node_make(level, output, type, color) {
|
|
1568
|
+
return function $mol_log3_logger(event) {
|
|
1569
|
+
if (!event.time)
|
|
1570
|
+
event = { time: new Date().toISOString(), ...event };
|
|
1571
|
+
let tree = this.$mol_tree2_from_json(event);
|
|
1572
|
+
tree = tree.struct(type, tree.kids);
|
|
1573
|
+
let str = color(tree.toString());
|
|
1574
|
+
this.console[level](str);
|
|
1575
|
+
const self = this;
|
|
1576
|
+
return () => self.console.groupEnd();
|
|
1577
|
+
};
|
|
1578
|
+
}
|
|
1579
|
+
$.$mol_log3_node_make = $mol_log3_node_make;
|
|
1580
|
+
$.$mol_log3_come = $mol_log3_node_make('info', 'stdout', 'come', $mol_term_color.blue);
|
|
1581
|
+
$.$mol_log3_done = $mol_log3_node_make('info', 'stdout', 'done', $mol_term_color.green);
|
|
1582
|
+
$.$mol_log3_fail = $mol_log3_node_make('error', 'stderr', 'fail', $mol_term_color.red);
|
|
1583
|
+
$.$mol_log3_warn = $mol_log3_node_make('warn', 'stderr', 'warn', $mol_term_color.yellow);
|
|
1584
|
+
$.$mol_log3_rise = $mol_log3_node_make('log', 'stdout', 'rise', $mol_term_color.magenta);
|
|
1585
|
+
$.$mol_log3_area = $mol_log3_node_make('log', 'stdout', 'area', $mol_term_color.cyan);
|
|
1586
|
+
})($ || ($ = {}));
|
|
1587
|
+
//mol/log3/log3.node.ts
|
|
1588
|
+
;
|
|
1589
|
+
"use strict";
|
|
1590
|
+
var $;
|
|
1591
|
+
(function ($) {
|
|
1592
|
+
class $mol_wire_task extends $mol_wire_fiber {
|
|
1593
|
+
static getter(task) {
|
|
1594
|
+
return function $mol_wire_task_get(host, args) {
|
|
1595
|
+
const sub = $mol_wire_auto();
|
|
1596
|
+
const existen = sub?.track_next();
|
|
1597
|
+
reuse: if (existen) {
|
|
1598
|
+
if (!existen.temp)
|
|
1599
|
+
break reuse;
|
|
1600
|
+
if (existen.host !== host)
|
|
1601
|
+
break reuse;
|
|
1602
|
+
if (existen.task !== task)
|
|
1603
|
+
break reuse;
|
|
1604
|
+
if (!$mol_compare_deep(existen.args, args))
|
|
1605
|
+
break reuse;
|
|
1606
|
+
return existen;
|
|
1658
1607
|
}
|
|
1659
|
-
|
|
1660
|
-
|
|
1661
|
-
|
|
1662
|
-
|
|
1663
|
-
|
|
1664
|
-
|
|
1665
|
-
|
|
1666
|
-
|
|
1667
|
-
|
|
1668
|
-
const kids = ((this.kids.length === 0) ? [this.list([])] : this.kids)
|
|
1669
|
-
.map(item => item.insert(value, ...path.slice(1)))
|
|
1670
|
-
.filter(Boolean);
|
|
1671
|
-
return this.clone(kids);
|
|
1672
|
-
}
|
|
1673
|
-
}
|
|
1674
|
-
select(...path) {
|
|
1675
|
-
let next = [this];
|
|
1676
|
-
for (const type of path) {
|
|
1677
|
-
if (!next.length)
|
|
1678
|
-
break;
|
|
1679
|
-
const prev = next;
|
|
1680
|
-
next = [];
|
|
1681
|
-
for (var item of prev) {
|
|
1682
|
-
switch (typeof (type)) {
|
|
1683
|
-
case 'string':
|
|
1684
|
-
for (var child of item.kids) {
|
|
1685
|
-
if (child.type == type) {
|
|
1686
|
-
next.push(child);
|
|
1687
|
-
}
|
|
1688
|
-
}
|
|
1689
|
-
break;
|
|
1690
|
-
case 'number':
|
|
1691
|
-
if (type < item.kids.length)
|
|
1692
|
-
next.push(item.kids[type]);
|
|
1693
|
-
break;
|
|
1694
|
-
default: next.push(...item.kids);
|
|
1695
|
-
}
|
|
1608
|
+
const next = new $mol_wire_task(`${host?.[Symbol.toStringTag] ?? host}.${task.name}(#)`, task, host, args);
|
|
1609
|
+
if (existen?.temp) {
|
|
1610
|
+
$$.$mol_log3_warn({
|
|
1611
|
+
place: '$mol_wire_task',
|
|
1612
|
+
message: `Non idempotency`,
|
|
1613
|
+
existen,
|
|
1614
|
+
next,
|
|
1615
|
+
hint: 'Ignore it',
|
|
1616
|
+
});
|
|
1696
1617
|
}
|
|
1697
|
-
|
|
1698
|
-
|
|
1618
|
+
return next;
|
|
1619
|
+
};
|
|
1699
1620
|
}
|
|
1700
|
-
|
|
1701
|
-
|
|
1702
|
-
var found = item.select(...path);
|
|
1703
|
-
if (value === undefined) {
|
|
1704
|
-
return Boolean(found.kids.length);
|
|
1705
|
-
}
|
|
1706
|
-
else {
|
|
1707
|
-
return found.kids.some(child => child.value == value);
|
|
1708
|
-
}
|
|
1709
|
-
});
|
|
1710
|
-
return this.clone(sub);
|
|
1621
|
+
get temp() {
|
|
1622
|
+
return true;
|
|
1711
1623
|
}
|
|
1712
|
-
|
|
1713
|
-
|
|
1714
|
-
|
|
1715
|
-
|
|
1716
|
-
handle = (input, belt, context) => [
|
|
1717
|
-
input.clone(input.hack(belt, context), context.span)
|
|
1718
|
-
];
|
|
1719
|
-
}
|
|
1720
|
-
try {
|
|
1721
|
-
return handle(child, belt, context);
|
|
1722
|
-
}
|
|
1723
|
-
catch (error) {
|
|
1724
|
-
error.message += `\n${child.clone([])}${child.span}`;
|
|
1725
|
-
$mol_fail_hidden(error);
|
|
1726
|
-
}
|
|
1727
|
-
}));
|
|
1624
|
+
complete() {
|
|
1625
|
+
if ($mol_promise_like(this.cache))
|
|
1626
|
+
return;
|
|
1627
|
+
this.destructor();
|
|
1728
1628
|
}
|
|
1729
|
-
|
|
1730
|
-
|
|
1629
|
+
put(next) {
|
|
1630
|
+
const prev = this.cache;
|
|
1631
|
+
this.cache = next;
|
|
1632
|
+
if ($mol_promise_like(next)) {
|
|
1633
|
+
this.cursor = $mol_wire_cursor.fresh;
|
|
1634
|
+
if (next !== prev)
|
|
1635
|
+
this.emit();
|
|
1636
|
+
return next;
|
|
1637
|
+
}
|
|
1638
|
+
this.cursor = $mol_wire_cursor.final;
|
|
1639
|
+
if (this.sub_empty)
|
|
1640
|
+
this.destructor();
|
|
1641
|
+
else if (next !== prev)
|
|
1642
|
+
this.emit();
|
|
1643
|
+
return next;
|
|
1731
1644
|
}
|
|
1732
1645
|
}
|
|
1733
|
-
$.$
|
|
1734
|
-
|
|
1735
|
-
|
|
1736
|
-
|
|
1646
|
+
$.$mol_wire_task = $mol_wire_task;
|
|
1647
|
+
})($ || ($ = {}));
|
|
1648
|
+
//mol/wire/task/task.ts
|
|
1649
|
+
;
|
|
1650
|
+
"use strict";
|
|
1651
|
+
var $;
|
|
1652
|
+
(function ($) {
|
|
1653
|
+
function $mol_wire_method(host, field, descr) {
|
|
1654
|
+
if (!descr)
|
|
1655
|
+
descr = Reflect.getOwnPropertyDescriptor(host, field);
|
|
1656
|
+
const orig = descr?.value ?? host[field];
|
|
1657
|
+
const sup = Reflect.getPrototypeOf(host);
|
|
1658
|
+
if (typeof sup[field] === 'function') {
|
|
1659
|
+
Object.defineProperty(orig, 'name', { value: sup[field].name });
|
|
1737
1660
|
}
|
|
1661
|
+
const temp = $mol_wire_task.getter(orig);
|
|
1662
|
+
const value = function (...args) {
|
|
1663
|
+
const fiber = temp(this ?? null, args);
|
|
1664
|
+
return fiber.sync();
|
|
1665
|
+
};
|
|
1666
|
+
Object.defineProperty(value, 'name', { value: orig.name + ' ' });
|
|
1667
|
+
Object.assign(value, { orig });
|
|
1668
|
+
const descr2 = { ...descr, value };
|
|
1669
|
+
Reflect.defineProperty(host, field, descr2);
|
|
1670
|
+
return descr2;
|
|
1738
1671
|
}
|
|
1739
|
-
$.$
|
|
1672
|
+
$.$mol_wire_method = $mol_wire_method;
|
|
1740
1673
|
})($ || ($ = {}));
|
|
1741
|
-
//mol/
|
|
1674
|
+
//mol/wire/method/method.ts
|
|
1675
|
+
;
|
|
1676
|
+
"use strict";
|
|
1677
|
+
//mol/type/tail/tail.ts
|
|
1678
|
+
;
|
|
1679
|
+
"use strict";
|
|
1680
|
+
//mol/type/foot/foot.ts
|
|
1742
1681
|
;
|
|
1743
1682
|
"use strict";
|
|
1744
1683
|
var $;
|
|
1745
1684
|
(function ($) {
|
|
1746
|
-
|
|
1747
|
-
|
|
1748
|
-
|
|
1749
|
-
|
|
1750
|
-
|
|
1751
|
-
|
|
1752
|
-
|
|
1753
|
-
|
|
1754
|
-
|
|
1755
|
-
|
|
1685
|
+
const catched = new WeakMap();
|
|
1686
|
+
function $mol_fail_catch(error) {
|
|
1687
|
+
if (typeof error !== 'object')
|
|
1688
|
+
return false;
|
|
1689
|
+
if ($mol_promise_like(error))
|
|
1690
|
+
$mol_fail_hidden(error);
|
|
1691
|
+
if (catched.get(error))
|
|
1692
|
+
return false;
|
|
1693
|
+
catched.set(error, true);
|
|
1694
|
+
return true;
|
|
1695
|
+
}
|
|
1696
|
+
$.$mol_fail_catch = $mol_fail_catch;
|
|
1697
|
+
})($ || ($ = {}));
|
|
1698
|
+
//mol/fail/catch/catch.ts
|
|
1699
|
+
;
|
|
1700
|
+
"use strict";
|
|
1701
|
+
var $;
|
|
1702
|
+
(function ($) {
|
|
1703
|
+
function $mol_fail_log(error) {
|
|
1704
|
+
if ($mol_promise_like(error))
|
|
1705
|
+
return false;
|
|
1706
|
+
if (!$mol_fail_catch(error))
|
|
1707
|
+
return false;
|
|
1708
|
+
console.error(error);
|
|
1709
|
+
return true;
|
|
1756
1710
|
}
|
|
1757
|
-
$.$
|
|
1711
|
+
$.$mol_fail_log = $mol_fail_log;
|
|
1758
1712
|
})($ || ($ = {}));
|
|
1759
|
-
//mol/
|
|
1713
|
+
//mol/fail/log/log.ts
|
|
1760
1714
|
;
|
|
1761
1715
|
"use strict";
|
|
1762
1716
|
var $;
|
|
1763
1717
|
(function ($) {
|
|
1764
|
-
|
|
1765
|
-
|
|
1766
|
-
|
|
1767
|
-
|
|
1768
|
-
|
|
1769
|
-
|
|
1770
|
-
|
|
1771
|
-
|
|
1772
|
-
|
|
1773
|
-
|
|
1774
|
-
|
|
1775
|
-
|
|
1718
|
+
class $mol_wire_atom extends $mol_wire_fiber {
|
|
1719
|
+
static solo(host, task) {
|
|
1720
|
+
const field = task.name + '()';
|
|
1721
|
+
const existen = Object.getOwnPropertyDescriptor(host ?? task, field)?.value;
|
|
1722
|
+
if (existen)
|
|
1723
|
+
return existen;
|
|
1724
|
+
const prefix = host?.[Symbol.toStringTag] ?? (host instanceof Function ? $$.$mol_func_name(host) : host);
|
|
1725
|
+
const key = `${prefix}.${field}`;
|
|
1726
|
+
const fiber = new $mol_wire_atom(key, task, host, []);
|
|
1727
|
+
(host ?? task)[field] = fiber;
|
|
1728
|
+
return fiber;
|
|
1729
|
+
}
|
|
1730
|
+
static plex(host, task, key) {
|
|
1731
|
+
const field = task.name + '()';
|
|
1732
|
+
let dict = Object.getOwnPropertyDescriptor(host ?? task, field)?.value;
|
|
1733
|
+
const prefix = host?.[Symbol.toStringTag] ?? (host instanceof Function ? $$.$mol_func_name(host) : host);
|
|
1734
|
+
const id = `${prefix}.${task.name}(${$mol_key(key).replace(/^"|"$/g, "'")})`;
|
|
1735
|
+
if (dict) {
|
|
1736
|
+
const existen = dict.get(id);
|
|
1737
|
+
if (existen)
|
|
1738
|
+
return existen;
|
|
1776
1739
|
}
|
|
1777
|
-
|
|
1778
|
-
|
|
1740
|
+
else {
|
|
1741
|
+
dict = (host ?? task)[field] = new Map();
|
|
1779
1742
|
}
|
|
1780
|
-
|
|
1781
|
-
|
|
1782
|
-
|
|
1783
|
-
|
|
1784
|
-
|
|
1785
|
-
|
|
1786
|
-
|
|
1787
|
-
|
|
1788
|
-
|
|
1789
|
-
|
|
1743
|
+
const fiber = new $mol_wire_atom(id, task, host, [key]);
|
|
1744
|
+
dict.set(id, fiber);
|
|
1745
|
+
return fiber;
|
|
1746
|
+
}
|
|
1747
|
+
static watching = new Set();
|
|
1748
|
+
static watcher = null;
|
|
1749
|
+
static watch() {
|
|
1750
|
+
$mol_wire_atom.watcher = new $mol_after_frame($mol_wire_atom.watch);
|
|
1751
|
+
for (const atom of $mol_wire_atom.watching) {
|
|
1752
|
+
if (atom.cursor === $mol_wire_cursor.final) {
|
|
1753
|
+
$mol_wire_atom.watching.delete(atom);
|
|
1790
1754
|
}
|
|
1791
1755
|
else {
|
|
1792
|
-
|
|
1756
|
+
atom.cursor = $mol_wire_cursor.stale;
|
|
1757
|
+
atom.fresh();
|
|
1793
1758
|
}
|
|
1794
1759
|
}
|
|
1795
|
-
|
|
1796
|
-
|
|
1797
|
-
|
|
1798
|
-
|
|
1799
|
-
|
|
1800
|
-
|
|
1760
|
+
}
|
|
1761
|
+
watch() {
|
|
1762
|
+
if (!$mol_wire_atom.watcher) {
|
|
1763
|
+
$mol_wire_atom.watcher = new $mol_after_frame($mol_wire_atom.watch);
|
|
1764
|
+
}
|
|
1765
|
+
$mol_wire_atom.watching.add(this);
|
|
1766
|
+
}
|
|
1767
|
+
resync(args) {
|
|
1768
|
+
return this.put(this.task.call(this.host, ...args));
|
|
1769
|
+
}
|
|
1770
|
+
once() {
|
|
1771
|
+
return this.sync();
|
|
1772
|
+
}
|
|
1773
|
+
channel() {
|
|
1774
|
+
return Object.assign((next) => {
|
|
1775
|
+
if (next !== undefined)
|
|
1776
|
+
return this.resync([...this.args, next]);
|
|
1777
|
+
if (!$mol_wire_fiber.warm)
|
|
1778
|
+
return this.result();
|
|
1779
|
+
if ($mol_wire_auto()?.temp) {
|
|
1780
|
+
return this.once();
|
|
1801
1781
|
}
|
|
1802
|
-
|
|
1803
|
-
|
|
1804
|
-
if (line_end === -1)
|
|
1805
|
-
line_end = str.length;
|
|
1806
|
-
const sp = span.span(row, error_start - line_start + 1, pos - error_start);
|
|
1807
|
-
this.$mol_fail(new this.$mol_error_syntax(`Wrong nodes separator`, str.substring(line_start, line_end), sp));
|
|
1782
|
+
else {
|
|
1783
|
+
return this.sync();
|
|
1808
1784
|
}
|
|
1809
|
-
|
|
1810
|
-
|
|
1811
|
-
|
|
1812
|
-
|
|
1813
|
-
|
|
1814
|
-
|
|
1815
|
-
|
|
1785
|
+
}, { atom: this });
|
|
1786
|
+
}
|
|
1787
|
+
destructor() {
|
|
1788
|
+
super.destructor();
|
|
1789
|
+
const prev = this.cache;
|
|
1790
|
+
if ($mol_owning_check(this, prev)) {
|
|
1791
|
+
prev.destructor();
|
|
1792
|
+
}
|
|
1793
|
+
if (this.pub_from === 0) {
|
|
1794
|
+
;
|
|
1795
|
+
(this.host ?? this.task)[this.field()] = null;
|
|
1796
|
+
}
|
|
1797
|
+
else {
|
|
1798
|
+
;
|
|
1799
|
+
(this.host ?? this.task)[this.field()].delete(this[Symbol.toStringTag]);
|
|
1800
|
+
}
|
|
1801
|
+
}
|
|
1802
|
+
put(next) {
|
|
1803
|
+
const prev = this.cache;
|
|
1804
|
+
update: if (next !== prev) {
|
|
1805
|
+
try {
|
|
1806
|
+
if ($mol_compare_deep(prev, next))
|
|
1807
|
+
break update;
|
|
1816
1808
|
}
|
|
1817
|
-
|
|
1818
|
-
|
|
1819
|
-
const parent_kids = parent.kids;
|
|
1820
|
-
parent_kids.push(next);
|
|
1821
|
-
parent = next;
|
|
1809
|
+
catch (error) {
|
|
1810
|
+
$mol_fail_log(error);
|
|
1822
1811
|
}
|
|
1823
|
-
if (
|
|
1824
|
-
|
|
1812
|
+
if ($mol_owning_check(this, prev)) {
|
|
1813
|
+
prev.destructor();
|
|
1825
1814
|
}
|
|
1826
|
-
|
|
1827
|
-
|
|
1828
|
-
|
|
1829
|
-
|
|
1830
|
-
|
|
1815
|
+
if ($mol_owning_catch(this, next)) {
|
|
1816
|
+
try {
|
|
1817
|
+
next[Symbol.toStringTag] = this[Symbol.toStringTag];
|
|
1818
|
+
}
|
|
1819
|
+
catch {
|
|
1820
|
+
Object.defineProperty(next, Symbol.toStringTag, { value: this[Symbol.toStringTag] });
|
|
1821
|
+
}
|
|
1831
1822
|
}
|
|
1832
|
-
|
|
1833
|
-
|
|
1834
|
-
parent_kids.push(next);
|
|
1835
|
-
parent = next;
|
|
1836
|
-
}
|
|
1837
|
-
if (str.length === pos && stack.length > 0) {
|
|
1838
|
-
const sp = span.span(row, pos - line_start + 1, 1);
|
|
1839
|
-
this.$mol_fail(new this.$mol_error_syntax(`Unexpected EOF, LF required`, str.substring(line_start, str.length), sp));
|
|
1823
|
+
if (!this.sub_empty)
|
|
1824
|
+
this.emit();
|
|
1840
1825
|
}
|
|
1841
|
-
|
|
1842
|
-
|
|
1826
|
+
this.cache = next;
|
|
1827
|
+
this.cursor = $mol_wire_cursor.fresh;
|
|
1828
|
+
if ($mol_promise_like(next))
|
|
1829
|
+
return next;
|
|
1830
|
+
this.complete_pubs();
|
|
1831
|
+
return next;
|
|
1843
1832
|
}
|
|
1844
|
-
return root;
|
|
1845
1833
|
}
|
|
1846
|
-
|
|
1834
|
+
__decorate([
|
|
1835
|
+
$mol_wire_method
|
|
1836
|
+
], $mol_wire_atom.prototype, "resync", null);
|
|
1837
|
+
__decorate([
|
|
1838
|
+
$mol_wire_method
|
|
1839
|
+
], $mol_wire_atom.prototype, "once", null);
|
|
1840
|
+
$.$mol_wire_atom = $mol_wire_atom;
|
|
1847
1841
|
})($ || ($ = {}));
|
|
1848
|
-
//mol/
|
|
1842
|
+
//mol/wire/atom/atom.ts
|
|
1849
1843
|
;
|
|
1850
1844
|
"use strict";
|
|
1851
1845
|
var $;
|
|
1852
1846
|
(function ($) {
|
|
1853
|
-
function $
|
|
1854
|
-
if (
|
|
1855
|
-
|
|
1856
|
-
|
|
1857
|
-
|
|
1858
|
-
|
|
1859
|
-
|
|
1860
|
-
if (Array.isArray(json)) {
|
|
1861
|
-
const sub = json.map(json => $mol_tree2_from_json(json, span));
|
|
1862
|
-
return new $mol_tree2('/', '', sub, span);
|
|
1863
|
-
}
|
|
1864
|
-
if (ArrayBuffer.isView(json)) {
|
|
1865
|
-
const buf = new Uint8Array(json.buffer, json.byteOffset, json.byteLength);
|
|
1866
|
-
return $mol_tree2.data(String.fromCharCode(...buf), [], span);
|
|
1867
|
-
}
|
|
1868
|
-
if (json instanceof Date) {
|
|
1869
|
-
return new $mol_tree2('', json.toISOString(), [], span);
|
|
1870
|
-
}
|
|
1871
|
-
if (typeof json.toJSON === 'function') {
|
|
1872
|
-
return $mol_tree2_from_json(json.toJSON());
|
|
1873
|
-
}
|
|
1874
|
-
if (json instanceof Error) {
|
|
1875
|
-
const { name, message, stack } = json;
|
|
1876
|
-
json = { ...json, name, message, stack };
|
|
1847
|
+
function $mol_wire_solo(host, field, descr) {
|
|
1848
|
+
if (!descr)
|
|
1849
|
+
descr = Reflect.getOwnPropertyDescriptor(host, field);
|
|
1850
|
+
const orig = descr?.value ?? host[field];
|
|
1851
|
+
const sup = Reflect.getPrototypeOf(host);
|
|
1852
|
+
if (typeof sup[field] === 'function') {
|
|
1853
|
+
Object.defineProperty(orig, 'name', { value: sup[field].name });
|
|
1877
1854
|
}
|
|
1878
|
-
const
|
|
1879
|
-
|
|
1880
|
-
|
|
1881
|
-
|
|
1882
|
-
|
|
1883
|
-
|
|
1884
|
-
|
|
1885
|
-
|
|
1886
|
-
|
|
1887
|
-
|
|
1888
|
-
|
|
1855
|
+
const descr2 = {
|
|
1856
|
+
...descr,
|
|
1857
|
+
value: function (...args) {
|
|
1858
|
+
let atom = $mol_wire_atom.solo(this, orig);
|
|
1859
|
+
if ((args.length === 0) || (args[0] === undefined)) {
|
|
1860
|
+
if (!$mol_wire_fiber.warm)
|
|
1861
|
+
return atom.result();
|
|
1862
|
+
if ($mol_wire_auto()?.temp) {
|
|
1863
|
+
return atom.once();
|
|
1864
|
+
}
|
|
1865
|
+
else {
|
|
1866
|
+
return atom.sync();
|
|
1867
|
+
}
|
|
1868
|
+
}
|
|
1869
|
+
return atom.resync(args);
|
|
1889
1870
|
}
|
|
1890
|
-
}
|
|
1891
|
-
|
|
1871
|
+
};
|
|
1872
|
+
Reflect.defineProperty(descr2.value, 'name', { value: orig.name + ' ' });
|
|
1873
|
+
Reflect.defineProperty(descr2.value, 'length', { value: orig.length });
|
|
1874
|
+
Object.assign(descr2.value, { orig });
|
|
1875
|
+
Reflect.defineProperty(host, field, descr2);
|
|
1876
|
+
return descr2;
|
|
1892
1877
|
}
|
|
1893
|
-
$.$
|
|
1878
|
+
$.$mol_wire_solo = $mol_wire_solo;
|
|
1894
1879
|
})($ || ($ = {}));
|
|
1895
|
-
//mol/
|
|
1880
|
+
//mol/wire/solo/solo.ts
|
|
1896
1881
|
;
|
|
1897
1882
|
"use strict";
|
|
1898
1883
|
var $;
|
|
1899
1884
|
(function ($) {
|
|
1900
|
-
|
|
1901
|
-
|
|
1902
|
-
|
|
1903
|
-
|
|
1904
|
-
|
|
1905
|
-
|
|
1906
|
-
|
|
1907
|
-
static strike = this.ansi(9, 29);
|
|
1908
|
-
static gray = this.ansi(90, 39);
|
|
1909
|
-
static red = this.ansi(91, 39);
|
|
1910
|
-
static green = this.ansi(92, 39);
|
|
1911
|
-
static yellow = this.ansi(93, 39);
|
|
1912
|
-
static blue = this.ansi(94, 39);
|
|
1913
|
-
static magenta = this.ansi(95, 39);
|
|
1914
|
-
static cyan = this.ansi(96, 39);
|
|
1915
|
-
static Gray = (str) => this.inverse(this.gray(str));
|
|
1916
|
-
static Red = (str) => this.inverse(this.red(str));
|
|
1917
|
-
static Green = (str) => this.inverse(this.green(str));
|
|
1918
|
-
static Yellow = (str) => this.inverse(this.yellow(str));
|
|
1919
|
-
static Blue = (str) => this.inverse(this.blue(str));
|
|
1920
|
-
static Magenta = (str) => this.inverse(this.magenta(str));
|
|
1921
|
-
static Cyan = (str) => this.inverse(this.cyan(str));
|
|
1922
|
-
static ansi(open, close) {
|
|
1923
|
-
if (typeof process === 'undefined')
|
|
1924
|
-
return String;
|
|
1925
|
-
if (!process.stdout.isTTY)
|
|
1926
|
-
return String;
|
|
1927
|
-
const prefix = `\x1b[${open}m`;
|
|
1928
|
-
const postfix = `\x1b[${close}m`;
|
|
1929
|
-
const suffix_regexp = new RegExp(postfix.replace('[', '\\['), 'g');
|
|
1930
|
-
return function colorer(str) {
|
|
1931
|
-
str = String(str);
|
|
1932
|
-
if (str === '')
|
|
1933
|
-
return str;
|
|
1934
|
-
const suffix = str.replace(suffix_regexp, prefix);
|
|
1935
|
-
return prefix + suffix + postfix;
|
|
1936
|
-
};
|
|
1885
|
+
function $mol_wire_plex(host, field, descr) {
|
|
1886
|
+
if (!descr)
|
|
1887
|
+
descr = Reflect.getOwnPropertyDescriptor(host, field);
|
|
1888
|
+
const orig = descr?.value ?? host[field];
|
|
1889
|
+
const sup = Reflect.getPrototypeOf(host);
|
|
1890
|
+
if (typeof sup[field] === 'function') {
|
|
1891
|
+
Object.defineProperty(orig, 'name', { value: sup[field].name });
|
|
1937
1892
|
}
|
|
1893
|
+
const descr2 = {
|
|
1894
|
+
...descr,
|
|
1895
|
+
value: function (...args) {
|
|
1896
|
+
let atom = $mol_wire_atom.plex(this, orig, args[0]);
|
|
1897
|
+
if ((args.length === 1) || (args[1] === undefined)) {
|
|
1898
|
+
if (!$mol_wire_fiber.warm)
|
|
1899
|
+
return atom.result();
|
|
1900
|
+
if ($mol_wire_auto()?.temp) {
|
|
1901
|
+
return atom.once();
|
|
1902
|
+
}
|
|
1903
|
+
else {
|
|
1904
|
+
return atom.sync();
|
|
1905
|
+
}
|
|
1906
|
+
}
|
|
1907
|
+
return atom.resync(args);
|
|
1908
|
+
}
|
|
1909
|
+
};
|
|
1910
|
+
Reflect.defineProperty(descr2.value, 'name', { value: orig.name + ' ' });
|
|
1911
|
+
Reflect.defineProperty(descr2.value, 'length', { value: orig.length });
|
|
1912
|
+
Object.assign(descr2.value, { orig });
|
|
1913
|
+
Reflect.defineProperty(host, field, descr2);
|
|
1914
|
+
return descr2;
|
|
1938
1915
|
}
|
|
1939
|
-
$.$
|
|
1916
|
+
$.$mol_wire_plex = $mol_wire_plex;
|
|
1940
1917
|
})($ || ($ = {}));
|
|
1941
|
-
//mol/
|
|
1918
|
+
//mol/wire/plex/plex.ts
|
|
1942
1919
|
;
|
|
1943
1920
|
"use strict";
|
|
1944
1921
|
var $;
|
|
1945
1922
|
(function ($) {
|
|
1946
|
-
|
|
1947
|
-
|
|
1948
|
-
if (!event.time)
|
|
1949
|
-
event = { time: new Date().toISOString(), ...event };
|
|
1950
|
-
let tree = this.$mol_tree2_from_json(event);
|
|
1951
|
-
tree = tree.struct(type, tree.kids);
|
|
1952
|
-
let str = color(tree.toString());
|
|
1953
|
-
this.console[level](str);
|
|
1954
|
-
const self = this;
|
|
1955
|
-
return () => self.console.groupEnd();
|
|
1956
|
-
};
|
|
1957
|
-
}
|
|
1958
|
-
$.$mol_log3_node_make = $mol_log3_node_make;
|
|
1959
|
-
$.$mol_log3_come = $mol_log3_node_make('info', 'stdout', 'come', $mol_term_color.blue);
|
|
1960
|
-
$.$mol_log3_done = $mol_log3_node_make('info', 'stdout', 'done', $mol_term_color.green);
|
|
1961
|
-
$.$mol_log3_fail = $mol_log3_node_make('error', 'stderr', 'fail', $mol_term_color.red);
|
|
1962
|
-
$.$mol_log3_warn = $mol_log3_node_make('warn', 'stderr', 'warn', $mol_term_color.yellow);
|
|
1963
|
-
$.$mol_log3_rise = $mol_log3_node_make('log', 'stdout', 'rise', $mol_term_color.magenta);
|
|
1964
|
-
$.$mol_log3_area = $mol_log3_node_make('log', 'stdout', 'area', $mol_term_color.cyan);
|
|
1923
|
+
$.$mol_mem = $mol_wire_solo;
|
|
1924
|
+
$.$mol_mem_key = $mol_wire_plex;
|
|
1965
1925
|
})($ || ($ = {}));
|
|
1966
|
-
//mol/
|
|
1926
|
+
//mol/mem/mem.ts
|
|
1927
|
+
;
|
|
1928
|
+
"use strict";
|
|
1929
|
+
var $;
|
|
1930
|
+
(function ($) {
|
|
1931
|
+
})($ || ($ = {}));
|
|
1932
|
+
//mol/dom/context/context.ts
|
|
1933
|
+
;
|
|
1934
|
+
"use strict";
|
|
1935
|
+
//node/node.ts
|
|
1936
|
+
;
|
|
1937
|
+
"use strict";
|
|
1938
|
+
var $node = new Proxy({ require }, {
|
|
1939
|
+
get(target, name, wrapper) {
|
|
1940
|
+
if (target[name])
|
|
1941
|
+
return target[name];
|
|
1942
|
+
const mod = target.require('module');
|
|
1943
|
+
if (mod.builtinModules.indexOf(name) >= 0)
|
|
1944
|
+
return target.require(name);
|
|
1945
|
+
if (name[0] === '.')
|
|
1946
|
+
return target.require(name);
|
|
1947
|
+
const path = target.require('path');
|
|
1948
|
+
const fs = target.require('fs');
|
|
1949
|
+
let dir = path.resolve('.');
|
|
1950
|
+
const suffix = `./node_modules/${name}`;
|
|
1951
|
+
const $$ = $;
|
|
1952
|
+
while (!fs.existsSync(path.join(dir, suffix))) {
|
|
1953
|
+
const parent = path.resolve(dir, '..');
|
|
1954
|
+
if (parent === dir) {
|
|
1955
|
+
$$.$mol_exec('.', 'npm', 'install', '--omit=dev', name);
|
|
1956
|
+
try {
|
|
1957
|
+
$$.$mol_exec('.', 'npm', 'install', '--omit=dev', '@types/' + name);
|
|
1958
|
+
}
|
|
1959
|
+
catch { }
|
|
1960
|
+
break;
|
|
1961
|
+
}
|
|
1962
|
+
else {
|
|
1963
|
+
dir = parent;
|
|
1964
|
+
}
|
|
1965
|
+
}
|
|
1966
|
+
return target.require(name);
|
|
1967
|
+
},
|
|
1968
|
+
set(target, name, value) {
|
|
1969
|
+
target[name] = value;
|
|
1970
|
+
return true;
|
|
1971
|
+
},
|
|
1972
|
+
});
|
|
1973
|
+
require = (req => Object.assign(function require(name) {
|
|
1974
|
+
return $node[name];
|
|
1975
|
+
}, req))(require);
|
|
1976
|
+
//node/node.node.ts
|
|
1967
1977
|
;
|
|
1968
1978
|
"use strict";
|
|
1969
1979
|
var $;
|
|
@@ -5599,279 +5609,6 @@ var $;
|
|
|
5599
5609
|
//mol/file/file.node.ts
|
|
5600
5610
|
;
|
|
5601
5611
|
"use strict";
|
|
5602
|
-
//hyoo/hyoo.ts
|
|
5603
|
-
;
|
|
5604
|
-
"use strict";
|
|
5605
|
-
var $;
|
|
5606
|
-
(function ($) {
|
|
5607
|
-
$.$mol_action = $mol_wire_method;
|
|
5608
|
-
})($ || ($ = {}));
|
|
5609
|
-
//mol/action/action.ts
|
|
5610
|
-
;
|
|
5611
|
-
"use strict";
|
|
5612
|
-
var $;
|
|
5613
|
-
(function ($) {
|
|
5614
|
-
function $mol_dom_parse(text, type = 'application/xhtml+xml') {
|
|
5615
|
-
const parser = new $mol_dom_context.DOMParser();
|
|
5616
|
-
const doc = parser.parseFromString(text, type);
|
|
5617
|
-
const error = doc.getElementsByTagName('parsererror');
|
|
5618
|
-
if (error.length)
|
|
5619
|
-
throw new Error(error[0].textContent);
|
|
5620
|
-
return doc;
|
|
5621
|
-
}
|
|
5622
|
-
$.$mol_dom_parse = $mol_dom_parse;
|
|
5623
|
-
})($ || ($ = {}));
|
|
5624
|
-
//mol/dom/parse/parse.ts
|
|
5625
|
-
;
|
|
5626
|
-
"use strict";
|
|
5627
|
-
var $;
|
|
5628
|
-
(function ($) {
|
|
5629
|
-
class $mol_fetch_response extends $mol_object2 {
|
|
5630
|
-
native;
|
|
5631
|
-
constructor(native) {
|
|
5632
|
-
super();
|
|
5633
|
-
this.native = native;
|
|
5634
|
-
}
|
|
5635
|
-
status() {
|
|
5636
|
-
const types = ['unknown', 'inform', 'success', 'redirect', 'wrong', 'failed'];
|
|
5637
|
-
return types[Math.floor(this.native.status / 100)];
|
|
5638
|
-
}
|
|
5639
|
-
code() {
|
|
5640
|
-
return this.native.status;
|
|
5641
|
-
}
|
|
5642
|
-
message() {
|
|
5643
|
-
return this.native.statusText || `HTTP Error ${this.code()}`;
|
|
5644
|
-
}
|
|
5645
|
-
headers() {
|
|
5646
|
-
return this.native.headers;
|
|
5647
|
-
}
|
|
5648
|
-
mime() {
|
|
5649
|
-
return this.headers().get('content-type');
|
|
5650
|
-
}
|
|
5651
|
-
stream() {
|
|
5652
|
-
return this.native.body;
|
|
5653
|
-
}
|
|
5654
|
-
text() {
|
|
5655
|
-
const buffer = this.buffer();
|
|
5656
|
-
const native = this.native;
|
|
5657
|
-
const mime = native.headers.get('content-type') || '';
|
|
5658
|
-
const [, charset] = /charset=(.*)/.exec(mime) || [, 'utf-8'];
|
|
5659
|
-
const decoder = new TextDecoder(charset);
|
|
5660
|
-
return decoder.decode(buffer);
|
|
5661
|
-
}
|
|
5662
|
-
json() {
|
|
5663
|
-
return $mol_wire_sync(this.native).json();
|
|
5664
|
-
}
|
|
5665
|
-
buffer() {
|
|
5666
|
-
return $mol_wire_sync(this.native).arrayBuffer();
|
|
5667
|
-
}
|
|
5668
|
-
xml() {
|
|
5669
|
-
return $mol_dom_parse(this.text(), 'application/xml');
|
|
5670
|
-
}
|
|
5671
|
-
xhtml() {
|
|
5672
|
-
return $mol_dom_parse(this.text(), 'application/xhtml+xml');
|
|
5673
|
-
}
|
|
5674
|
-
html() {
|
|
5675
|
-
return $mol_dom_parse(this.text(), 'text/html');
|
|
5676
|
-
}
|
|
5677
|
-
}
|
|
5678
|
-
__decorate([
|
|
5679
|
-
$mol_action
|
|
5680
|
-
], $mol_fetch_response.prototype, "stream", null);
|
|
5681
|
-
__decorate([
|
|
5682
|
-
$mol_action
|
|
5683
|
-
], $mol_fetch_response.prototype, "text", null);
|
|
5684
|
-
__decorate([
|
|
5685
|
-
$mol_action
|
|
5686
|
-
], $mol_fetch_response.prototype, "buffer", null);
|
|
5687
|
-
__decorate([
|
|
5688
|
-
$mol_action
|
|
5689
|
-
], $mol_fetch_response.prototype, "xml", null);
|
|
5690
|
-
__decorate([
|
|
5691
|
-
$mol_action
|
|
5692
|
-
], $mol_fetch_response.prototype, "xhtml", null);
|
|
5693
|
-
__decorate([
|
|
5694
|
-
$mol_action
|
|
5695
|
-
], $mol_fetch_response.prototype, "html", null);
|
|
5696
|
-
$.$mol_fetch_response = $mol_fetch_response;
|
|
5697
|
-
class $mol_fetch extends $mol_object2 {
|
|
5698
|
-
static request(input, init = {}) {
|
|
5699
|
-
const native = globalThis.fetch ?? $node['undici'].fetch;
|
|
5700
|
-
const controller = new AbortController();
|
|
5701
|
-
let done = false;
|
|
5702
|
-
const promise = native(input, {
|
|
5703
|
-
...init,
|
|
5704
|
-
signal: controller.signal,
|
|
5705
|
-
}).finally(() => {
|
|
5706
|
-
done = true;
|
|
5707
|
-
});
|
|
5708
|
-
return Object.assign(promise, {
|
|
5709
|
-
destructor: () => {
|
|
5710
|
-
if (!done && !controller.signal.aborted)
|
|
5711
|
-
controller.abort();
|
|
5712
|
-
},
|
|
5713
|
-
});
|
|
5714
|
-
}
|
|
5715
|
-
static response(input, init) {
|
|
5716
|
-
return new $mol_fetch_response($mol_wire_sync(this).request(input, init));
|
|
5717
|
-
}
|
|
5718
|
-
static success(input, init) {
|
|
5719
|
-
const response = this.response(input, init);
|
|
5720
|
-
if (response.status() === 'success')
|
|
5721
|
-
return response;
|
|
5722
|
-
throw new Error(response.message());
|
|
5723
|
-
}
|
|
5724
|
-
static stream(input, init) {
|
|
5725
|
-
return this.success(input, init).stream();
|
|
5726
|
-
}
|
|
5727
|
-
static text(input, init) {
|
|
5728
|
-
return this.success(input, init).text();
|
|
5729
|
-
}
|
|
5730
|
-
static json(input, init) {
|
|
5731
|
-
return this.success(input, init).json();
|
|
5732
|
-
}
|
|
5733
|
-
static buffer(input, init) {
|
|
5734
|
-
return this.success(input, init).buffer();
|
|
5735
|
-
}
|
|
5736
|
-
static xml(input, init) {
|
|
5737
|
-
return this.success(input, init).xml();
|
|
5738
|
-
}
|
|
5739
|
-
static xhtml(input, init) {
|
|
5740
|
-
return this.success(input, init).xhtml();
|
|
5741
|
-
}
|
|
5742
|
-
static html(input, init) {
|
|
5743
|
-
return this.success(input, init).html();
|
|
5744
|
-
}
|
|
5745
|
-
}
|
|
5746
|
-
__decorate([
|
|
5747
|
-
$mol_action
|
|
5748
|
-
], $mol_fetch, "response", null);
|
|
5749
|
-
__decorate([
|
|
5750
|
-
$mol_action
|
|
5751
|
-
], $mol_fetch, "success", null);
|
|
5752
|
-
__decorate([
|
|
5753
|
-
$mol_action
|
|
5754
|
-
], $mol_fetch, "stream", null);
|
|
5755
|
-
__decorate([
|
|
5756
|
-
$mol_action
|
|
5757
|
-
], $mol_fetch, "text", null);
|
|
5758
|
-
__decorate([
|
|
5759
|
-
$mol_action
|
|
5760
|
-
], $mol_fetch, "json", null);
|
|
5761
|
-
__decorate([
|
|
5762
|
-
$mol_action
|
|
5763
|
-
], $mol_fetch, "buffer", null);
|
|
5764
|
-
__decorate([
|
|
5765
|
-
$mol_action
|
|
5766
|
-
], $mol_fetch, "xml", null);
|
|
5767
|
-
__decorate([
|
|
5768
|
-
$mol_action
|
|
5769
|
-
], $mol_fetch, "xhtml", null);
|
|
5770
|
-
__decorate([
|
|
5771
|
-
$mol_action
|
|
5772
|
-
], $mol_fetch, "html", null);
|
|
5773
|
-
$.$mol_fetch = $mol_fetch;
|
|
5774
|
-
})($ || ($ = {}));
|
|
5775
|
-
//mol/fetch/fetch.ts
|
|
5776
|
-
;
|
|
5777
|
-
"use strict";
|
|
5778
|
-
var $;
|
|
5779
|
-
(function ($) {
|
|
5780
|
-
function $mol_huggingface_run(space, method, ...data) {
|
|
5781
|
-
while (true) {
|
|
5782
|
-
try {
|
|
5783
|
-
if (typeof method === 'number') {
|
|
5784
|
-
return $mol_wire_sync(this).$mol_huggingface_ws(space, method, ...data);
|
|
5785
|
-
}
|
|
5786
|
-
else {
|
|
5787
|
-
return this.$mol_huggingface_rest(space, method, ...data);
|
|
5788
|
-
}
|
|
5789
|
-
}
|
|
5790
|
-
catch (error) {
|
|
5791
|
-
if ($mol_promise_like(error))
|
|
5792
|
-
$mol_fail_hidden(error);
|
|
5793
|
-
if (error instanceof Error && error.message === `Queue full`) {
|
|
5794
|
-
$mol_fail_log(error);
|
|
5795
|
-
continue;
|
|
5796
|
-
}
|
|
5797
|
-
$mol_fail_hidden(error);
|
|
5798
|
-
}
|
|
5799
|
-
}
|
|
5800
|
-
}
|
|
5801
|
-
$.$mol_huggingface_run = $mol_huggingface_run;
|
|
5802
|
-
function $mol_huggingface_rest(space, method, ...data) {
|
|
5803
|
-
const uri = `https://${space}.hf.space/run/${method}`;
|
|
5804
|
-
const response = $mol_fetch.json(uri, {
|
|
5805
|
-
method: 'post',
|
|
5806
|
-
headers: { "Content-Type": "application/json" },
|
|
5807
|
-
body: JSON.stringify({ data }),
|
|
5808
|
-
});
|
|
5809
|
-
if ('error' in response) {
|
|
5810
|
-
$mol_fail(new Error(response.error ?? 'Unknown API error'));
|
|
5811
|
-
}
|
|
5812
|
-
return response.data;
|
|
5813
|
-
}
|
|
5814
|
-
$.$mol_huggingface_rest = $mol_huggingface_rest;
|
|
5815
|
-
function $mol_huggingface_ws(space, fn_index, ...data) {
|
|
5816
|
-
const session_hash = $mol_guid();
|
|
5817
|
-
const socket = new WebSocket(`wss://${space}.hf.space/queue/join`);
|
|
5818
|
-
const promise = new Promise((done, fail) => {
|
|
5819
|
-
socket.onclose = event => {
|
|
5820
|
-
if (event.reason)
|
|
5821
|
-
fail(new Error(event.reason));
|
|
5822
|
-
};
|
|
5823
|
-
socket.onerror = event => {
|
|
5824
|
-
fail(new Error(`Socket error`));
|
|
5825
|
-
};
|
|
5826
|
-
socket.onmessage = event => {
|
|
5827
|
-
const message = JSON.parse(event.data);
|
|
5828
|
-
switch (message.msg) {
|
|
5829
|
-
case 'send_hash':
|
|
5830
|
-
return socket.send(JSON.stringify({ session_hash, fn_index }));
|
|
5831
|
-
case 'estimation': return;
|
|
5832
|
-
case 'queue_full':
|
|
5833
|
-
fail(new Error(`Queue full`));
|
|
5834
|
-
case 'send_data':
|
|
5835
|
-
return socket.send(JSON.stringify({ session_hash, fn_index, data }));
|
|
5836
|
-
case 'process_starts': return;
|
|
5837
|
-
case 'process_completed':
|
|
5838
|
-
if (message.success) {
|
|
5839
|
-
return done(message.output.data);
|
|
5840
|
-
}
|
|
5841
|
-
else {
|
|
5842
|
-
return fail(new Error(message.output.error ?? `Unknown API error`));
|
|
5843
|
-
}
|
|
5844
|
-
default:
|
|
5845
|
-
return fail(new Error(`Unknown message type: ${message.msg}`));
|
|
5846
|
-
}
|
|
5847
|
-
};
|
|
5848
|
-
});
|
|
5849
|
-
return Object.assign(promise, {
|
|
5850
|
-
destructor: () => socket.close()
|
|
5851
|
-
});
|
|
5852
|
-
}
|
|
5853
|
-
$.$mol_huggingface_ws = $mol_huggingface_ws;
|
|
5854
|
-
})($ || ($ = {}));
|
|
5855
|
-
//mol/huggingface/huggingface.ts
|
|
5856
|
-
;
|
|
5857
|
-
"use strict";
|
|
5858
|
-
var $;
|
|
5859
|
-
(function ($) {
|
|
5860
|
-
function $hyoo_lingua_translate(lang, text) {
|
|
5861
|
-
if (!text.trim())
|
|
5862
|
-
return '';
|
|
5863
|
-
const cache_key = `$hyoo_lingua_translate(${JSON.stringify(lang)},${JSON.stringify(text)})`;
|
|
5864
|
-
const cached = this.$mol_state_local.value(cache_key);
|
|
5865
|
-
if (cached)
|
|
5866
|
-
return String(cached);
|
|
5867
|
-
const translated = this.$mol_huggingface_run('hyoo-translate', 0, lang, text)[0];
|
|
5868
|
-
return this.$mol_state_local.value(cache_key, translated);
|
|
5869
|
-
}
|
|
5870
|
-
$.$hyoo_lingua_translate = $hyoo_lingua_translate;
|
|
5871
|
-
})($ || ($ = {}));
|
|
5872
|
-
//hyoo/lingua/translate/translate.ts
|
|
5873
|
-
;
|
|
5874
|
-
"use strict";
|
|
5875
5612
|
var $;
|
|
5876
5613
|
(function ($) {
|
|
5877
5614
|
class $mol_locale extends $mol_object {
|
|
@@ -5908,12 +5645,6 @@ var $;
|
|
|
5908
5645
|
const en = this.texts('en')[key];
|
|
5909
5646
|
if (!en)
|
|
5910
5647
|
return key;
|
|
5911
|
-
try {
|
|
5912
|
-
return $mol_wire_sync($hyoo_lingua_translate).call(this.$, lang, en);
|
|
5913
|
-
}
|
|
5914
|
-
catch (error) {
|
|
5915
|
-
$mol_fail_log(error);
|
|
5916
|
-
}
|
|
5917
5648
|
return en;
|
|
5918
5649
|
}
|
|
5919
5650
|
static warn(key) {
|