mol_plot_all 1.2.844 → 1.2.846
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 -85
- package/node.deps.json +1 -1
- package/node.js +585 -575
- package/node.js.map +1 -1
- package/node.mjs +585 -575
- package/node.test.js +798 -1091
- package/node.test.js.map +1 -1
- package/package.json +11 -11
- package/web.audit.js +1 -1
- package/web.d.ts +33 -8
- package/web.deps.json +1 -1
- package/web.js +67 -4
- package/web.js.map +1 -1
- package/web.mjs +67 -4
- package/web.test.js +33 -216
- package/web.test.js.map +1 -1
package/node.test.js
CHANGED
|
@@ -1068,894 +1068,904 @@ var $;
|
|
|
1068
1068
|
"use strict";
|
|
1069
1069
|
var $;
|
|
1070
1070
|
(function ($) {
|
|
1071
|
-
|
|
1072
|
-
|
|
1073
|
-
|
|
1074
|
-
|
|
1075
|
-
|
|
1076
|
-
|
|
1077
|
-
|
|
1078
|
-
|
|
1079
|
-
|
|
1080
|
-
|
|
1081
|
-
|
|
1082
|
-
|
|
1083
|
-
|
|
1084
|
-
|
|
1085
|
-
return existen;
|
|
1086
|
-
}
|
|
1087
|
-
return new $mol_wire_task(`${host?.[Symbol.toStringTag] ?? host}.${task.name}(#)`, task, host, args);
|
|
1088
|
-
};
|
|
1089
|
-
}
|
|
1090
|
-
get temp() {
|
|
1091
|
-
return true;
|
|
1092
|
-
}
|
|
1093
|
-
complete() {
|
|
1094
|
-
if ($mol_promise_like(this.cache))
|
|
1095
|
-
return;
|
|
1096
|
-
this.destructor();
|
|
1097
|
-
}
|
|
1098
|
-
put(next) {
|
|
1099
|
-
const prev = this.cache;
|
|
1100
|
-
this.cache = next;
|
|
1101
|
-
if ($mol_promise_like(next)) {
|
|
1102
|
-
this.cursor = $mol_wire_cursor.fresh;
|
|
1103
|
-
if (next !== prev)
|
|
1104
|
-
this.emit();
|
|
1105
|
-
return next;
|
|
1106
|
-
}
|
|
1107
|
-
this.cursor = $mol_wire_cursor.final;
|
|
1108
|
-
if (this.sub_empty)
|
|
1109
|
-
this.destructor();
|
|
1110
|
-
else if (next !== prev)
|
|
1111
|
-
this.emit();
|
|
1112
|
-
return next;
|
|
1113
|
-
}
|
|
1114
|
-
}
|
|
1115
|
-
$.$mol_wire_task = $mol_wire_task;
|
|
1116
|
-
})($ || ($ = {}));
|
|
1117
|
-
//mol/wire/task/task.ts
|
|
1118
|
-
;
|
|
1119
|
-
"use strict";
|
|
1120
|
-
var $;
|
|
1121
|
-
(function ($) {
|
|
1122
|
-
function $mol_wire_method(host, field, descr) {
|
|
1123
|
-
if (!descr)
|
|
1124
|
-
descr = Reflect.getOwnPropertyDescriptor(host, field);
|
|
1125
|
-
const orig = descr?.value ?? host[field];
|
|
1126
|
-
const sup = Reflect.getPrototypeOf(host);
|
|
1127
|
-
if (typeof sup[field] === 'function') {
|
|
1128
|
-
Object.defineProperty(orig, 'name', { value: sup[field].name });
|
|
1129
|
-
}
|
|
1130
|
-
const temp = $mol_wire_task.getter(orig);
|
|
1131
|
-
const value = function (...args) {
|
|
1132
|
-
const fiber = temp(this ?? null, args);
|
|
1133
|
-
return fiber.sync();
|
|
1071
|
+
function $mol_log3_area_lazy(event) {
|
|
1072
|
+
const self = this;
|
|
1073
|
+
const stack = self.$mol_log3_stack;
|
|
1074
|
+
const deep = stack.length;
|
|
1075
|
+
let logged = false;
|
|
1076
|
+
stack.push(() => {
|
|
1077
|
+
logged = true;
|
|
1078
|
+
self.$mol_log3_area.call(self, event);
|
|
1079
|
+
});
|
|
1080
|
+
return () => {
|
|
1081
|
+
if (logged)
|
|
1082
|
+
self.console.groupEnd();
|
|
1083
|
+
if (stack.length > deep)
|
|
1084
|
+
stack.length = deep;
|
|
1134
1085
|
};
|
|
1135
|
-
Object.defineProperty(value, 'name', { value: orig.name + ' ' });
|
|
1136
|
-
Object.assign(value, { orig });
|
|
1137
|
-
const descr2 = { ...descr, value };
|
|
1138
|
-
Reflect.defineProperty(host, field, descr2);
|
|
1139
|
-
return descr2;
|
|
1140
1086
|
}
|
|
1141
|
-
$.$
|
|
1087
|
+
$.$mol_log3_area_lazy = $mol_log3_area_lazy;
|
|
1088
|
+
$.$mol_log3_stack = [];
|
|
1142
1089
|
})($ || ($ = {}));
|
|
1143
|
-
//mol/
|
|
1144
|
-
;
|
|
1145
|
-
"use strict";
|
|
1146
|
-
//mol/type/tail/tail.ts
|
|
1147
|
-
;
|
|
1148
|
-
"use strict";
|
|
1149
|
-
//mol/type/foot/foot.ts
|
|
1090
|
+
//mol/log3/log3.ts
|
|
1150
1091
|
;
|
|
1151
1092
|
"use strict";
|
|
1152
1093
|
var $;
|
|
1153
1094
|
(function ($) {
|
|
1154
|
-
|
|
1155
|
-
|
|
1156
|
-
|
|
1157
|
-
|
|
1158
|
-
|
|
1159
|
-
|
|
1160
|
-
|
|
1161
|
-
|
|
1162
|
-
|
|
1163
|
-
|
|
1095
|
+
class $mol_span extends $mol_object2 {
|
|
1096
|
+
uri;
|
|
1097
|
+
source;
|
|
1098
|
+
row;
|
|
1099
|
+
col;
|
|
1100
|
+
length;
|
|
1101
|
+
constructor(uri, source, row, col, length) {
|
|
1102
|
+
super();
|
|
1103
|
+
this.uri = uri;
|
|
1104
|
+
this.source = source;
|
|
1105
|
+
this.row = row;
|
|
1106
|
+
this.col = col;
|
|
1107
|
+
this.length = length;
|
|
1108
|
+
this[Symbol.toStringTag] = `${this.uri}#${this.row}:${this.col}/${this.length}`;
|
|
1109
|
+
}
|
|
1110
|
+
static unknown = $mol_span.begin('?');
|
|
1111
|
+
static begin(uri, source = '') {
|
|
1112
|
+
return new $mol_span(uri, source, 1, 1, 0);
|
|
1113
|
+
}
|
|
1114
|
+
static end(uri, source) {
|
|
1115
|
+
return new $mol_span(uri, source, 1, source.length + 1, 0);
|
|
1116
|
+
}
|
|
1117
|
+
static entire(uri, source) {
|
|
1118
|
+
return new $mol_span(uri, source, 1, 1, source.length);
|
|
1119
|
+
}
|
|
1120
|
+
toString() {
|
|
1121
|
+
return this[Symbol.toStringTag];
|
|
1122
|
+
}
|
|
1123
|
+
toJSON() {
|
|
1124
|
+
return {
|
|
1125
|
+
uri: this.uri,
|
|
1126
|
+
row: this.row,
|
|
1127
|
+
col: this.col,
|
|
1128
|
+
length: this.length
|
|
1129
|
+
};
|
|
1130
|
+
}
|
|
1131
|
+
error(message, Class = Error) {
|
|
1132
|
+
return new Class(`${message} (${this})`);
|
|
1133
|
+
}
|
|
1134
|
+
span(row, col, length) {
|
|
1135
|
+
return new $mol_span(this.uri, this.source, row, col, length);
|
|
1136
|
+
}
|
|
1137
|
+
after(length = 0) {
|
|
1138
|
+
return new $mol_span(this.uri, this.source, this.row, this.col + this.length, length);
|
|
1139
|
+
}
|
|
1140
|
+
slice(begin, end = -1) {
|
|
1141
|
+
let len = this.length;
|
|
1142
|
+
if (begin < 0)
|
|
1143
|
+
begin += len;
|
|
1144
|
+
if (end < 0)
|
|
1145
|
+
end += len;
|
|
1146
|
+
if (begin < 0 || begin > len)
|
|
1147
|
+
this.$.$mol_fail(this.error(`Begin value '${begin}' out of range`, RangeError));
|
|
1148
|
+
if (end < 0 || end > len)
|
|
1149
|
+
this.$.$mol_fail(this.error(`End value '${end}' out of range`, RangeError));
|
|
1150
|
+
if (end < begin)
|
|
1151
|
+
this.$.$mol_fail(this.error(`End value '${end}' can't be less than begin value`, RangeError));
|
|
1152
|
+
return this.span(this.row, this.col + begin, end - begin);
|
|
1153
|
+
}
|
|
1164
1154
|
}
|
|
1165
|
-
$.$
|
|
1155
|
+
$.$mol_span = $mol_span;
|
|
1166
1156
|
})($ || ($ = {}));
|
|
1167
|
-
//mol/
|
|
1157
|
+
//mol/span/span.ts
|
|
1168
1158
|
;
|
|
1169
1159
|
"use strict";
|
|
1170
1160
|
var $;
|
|
1171
1161
|
(function ($) {
|
|
1172
|
-
function $
|
|
1173
|
-
|
|
1174
|
-
|
|
1175
|
-
|
|
1176
|
-
|
|
1177
|
-
|
|
1178
|
-
|
|
1162
|
+
function $mol_tree2_to_string(tree) {
|
|
1163
|
+
let output = [];
|
|
1164
|
+
function dump(tree, prefix = '') {
|
|
1165
|
+
if (tree.type.length) {
|
|
1166
|
+
if (!prefix.length) {
|
|
1167
|
+
prefix = "\t";
|
|
1168
|
+
}
|
|
1169
|
+
output.push(tree.type);
|
|
1170
|
+
if (tree.kids.length == 1) {
|
|
1171
|
+
output.push(' ');
|
|
1172
|
+
dump(tree.kids[0], prefix);
|
|
1173
|
+
return;
|
|
1174
|
+
}
|
|
1175
|
+
output.push("\n");
|
|
1176
|
+
}
|
|
1177
|
+
else if (tree.value.length || prefix.length) {
|
|
1178
|
+
output.push("\\" + tree.value + "\n");
|
|
1179
|
+
}
|
|
1180
|
+
for (const kid of tree.kids) {
|
|
1181
|
+
output.push(prefix);
|
|
1182
|
+
dump(kid, prefix + "\t");
|
|
1183
|
+
}
|
|
1184
|
+
}
|
|
1185
|
+
dump(tree);
|
|
1186
|
+
return output.join('');
|
|
1179
1187
|
}
|
|
1180
|
-
$.$
|
|
1188
|
+
$.$mol_tree2_to_string = $mol_tree2_to_string;
|
|
1181
1189
|
})($ || ($ = {}));
|
|
1182
|
-
//mol/
|
|
1190
|
+
//mol/tree2/to/string/string.ts
|
|
1183
1191
|
;
|
|
1184
1192
|
"use strict";
|
|
1185
1193
|
var $;
|
|
1186
1194
|
(function ($) {
|
|
1187
|
-
class $
|
|
1188
|
-
|
|
1189
|
-
|
|
1190
|
-
|
|
1191
|
-
|
|
1192
|
-
|
|
1193
|
-
|
|
1194
|
-
|
|
1195
|
-
|
|
1196
|
-
|
|
1197
|
-
|
|
1195
|
+
class $mol_tree2 extends Object {
|
|
1196
|
+
type;
|
|
1197
|
+
value;
|
|
1198
|
+
kids;
|
|
1199
|
+
span;
|
|
1200
|
+
constructor(type, value, kids, span) {
|
|
1201
|
+
super();
|
|
1202
|
+
this.type = type;
|
|
1203
|
+
this.value = value;
|
|
1204
|
+
this.kids = kids;
|
|
1205
|
+
this.span = span;
|
|
1206
|
+
this[Symbol.toStringTag] = type || '\\' + value;
|
|
1198
1207
|
}
|
|
1199
|
-
static
|
|
1200
|
-
|
|
1201
|
-
|
|
1202
|
-
|
|
1203
|
-
|
|
1204
|
-
|
|
1205
|
-
|
|
1206
|
-
|
|
1207
|
-
|
|
1208
|
-
|
|
1209
|
-
|
|
1210
|
-
|
|
1208
|
+
static list(kids, span = $mol_span.unknown) {
|
|
1209
|
+
return new $mol_tree2('', '', kids, span);
|
|
1210
|
+
}
|
|
1211
|
+
list(kids) {
|
|
1212
|
+
return $mol_tree2.list(kids, this.span);
|
|
1213
|
+
}
|
|
1214
|
+
static data(value, kids = [], span = $mol_span.unknown) {
|
|
1215
|
+
const chunks = value.split('\n');
|
|
1216
|
+
if (chunks.length > 1) {
|
|
1217
|
+
let kid_span = span.span(span.row, span.col, 0);
|
|
1218
|
+
const data = chunks.map(chunk => {
|
|
1219
|
+
kid_span = kid_span.after(chunk.length);
|
|
1220
|
+
return new $mol_tree2('', chunk, [], kid_span);
|
|
1221
|
+
});
|
|
1222
|
+
kids = [...data, ...kids];
|
|
1223
|
+
value = '';
|
|
1211
1224
|
}
|
|
1212
|
-
|
|
1213
|
-
dict.set(id, fiber);
|
|
1214
|
-
return fiber;
|
|
1225
|
+
return new $mol_tree2('', value, kids, span);
|
|
1215
1226
|
}
|
|
1216
|
-
|
|
1217
|
-
|
|
1218
|
-
|
|
1219
|
-
|
|
1220
|
-
|
|
1221
|
-
|
|
1222
|
-
$mol_wire_atom.watching.delete(atom);
|
|
1223
|
-
}
|
|
1224
|
-
else {
|
|
1225
|
-
atom.cursor = $mol_wire_cursor.stale;
|
|
1226
|
-
atom.fresh();
|
|
1227
|
-
}
|
|
1227
|
+
data(value, kids = []) {
|
|
1228
|
+
return $mol_tree2.data(value, kids, this.span);
|
|
1229
|
+
}
|
|
1230
|
+
static struct(type, kids = [], span = $mol_span.unknown) {
|
|
1231
|
+
if (/[ \n\t\\]/.test(type)) {
|
|
1232
|
+
$$.$mol_fail(span.error(`Wrong type ${JSON.stringify(type)}`));
|
|
1228
1233
|
}
|
|
1234
|
+
return new $mol_tree2(type, '', kids, span);
|
|
1229
1235
|
}
|
|
1230
|
-
|
|
1231
|
-
|
|
1232
|
-
|
|
1236
|
+
struct(type, kids = []) {
|
|
1237
|
+
return $mol_tree2.struct(type, kids, this.span);
|
|
1238
|
+
}
|
|
1239
|
+
clone(kids, span = this.span) {
|
|
1240
|
+
return new $mol_tree2(this.type, this.value, kids, span);
|
|
1241
|
+
}
|
|
1242
|
+
text() {
|
|
1243
|
+
var values = [];
|
|
1244
|
+
for (var kid of this.kids) {
|
|
1245
|
+
if (kid.type)
|
|
1246
|
+
continue;
|
|
1247
|
+
values.push(kid.value);
|
|
1233
1248
|
}
|
|
1234
|
-
|
|
1249
|
+
return this.value + values.join('\n');
|
|
1235
1250
|
}
|
|
1236
|
-
|
|
1237
|
-
return
|
|
1251
|
+
static fromString(str, uri = 'unknown') {
|
|
1252
|
+
return $$.$mol_tree2_from_string(str, uri);
|
|
1238
1253
|
}
|
|
1239
|
-
|
|
1240
|
-
return this
|
|
1254
|
+
toString() {
|
|
1255
|
+
return $$.$mol_tree2_to_string(this);
|
|
1241
1256
|
}
|
|
1242
|
-
|
|
1243
|
-
|
|
1244
|
-
|
|
1245
|
-
|
|
1246
|
-
|
|
1247
|
-
|
|
1248
|
-
|
|
1249
|
-
|
|
1257
|
+
insert(value, ...path) {
|
|
1258
|
+
if (path.length === 0)
|
|
1259
|
+
return value;
|
|
1260
|
+
const type = path[0];
|
|
1261
|
+
if (typeof type === 'string') {
|
|
1262
|
+
let replaced = false;
|
|
1263
|
+
const sub = this.kids.map((item, index) => {
|
|
1264
|
+
if (item.type !== type)
|
|
1265
|
+
return item;
|
|
1266
|
+
replaced = true;
|
|
1267
|
+
return item.insert(value, ...path.slice(1));
|
|
1268
|
+
}).filter(Boolean);
|
|
1269
|
+
if (!replaced && value) {
|
|
1270
|
+
sub.push(this.struct(type, []).insert(value, ...path.slice(1)));
|
|
1271
|
+
}
|
|
1272
|
+
return this.clone(sub);
|
|
1273
|
+
}
|
|
1274
|
+
else if (typeof type === 'number') {
|
|
1275
|
+
const sub = this.kids.slice();
|
|
1276
|
+
sub[type] = (sub[type] || this.list([]))
|
|
1277
|
+
.insert(value, ...path.slice(1));
|
|
1278
|
+
return this.clone(sub.filter(Boolean));
|
|
1279
|
+
}
|
|
1280
|
+
else {
|
|
1281
|
+
const kids = ((this.kids.length === 0) ? [this.list([])] : this.kids)
|
|
1282
|
+
.map(item => item.insert(value, ...path.slice(1)))
|
|
1283
|
+
.filter(Boolean);
|
|
1284
|
+
return this.clone(kids);
|
|
1285
|
+
}
|
|
1286
|
+
}
|
|
1287
|
+
select(...path) {
|
|
1288
|
+
let next = [this];
|
|
1289
|
+
for (const type of path) {
|
|
1290
|
+
if (!next.length)
|
|
1291
|
+
break;
|
|
1292
|
+
const prev = next;
|
|
1293
|
+
next = [];
|
|
1294
|
+
for (var item of prev) {
|
|
1295
|
+
switch (typeof (type)) {
|
|
1296
|
+
case 'string':
|
|
1297
|
+
for (var child of item.kids) {
|
|
1298
|
+
if (child.type == type) {
|
|
1299
|
+
next.push(child);
|
|
1300
|
+
}
|
|
1301
|
+
}
|
|
1302
|
+
break;
|
|
1303
|
+
case 'number':
|
|
1304
|
+
if (type < item.kids.length)
|
|
1305
|
+
next.push(item.kids[type]);
|
|
1306
|
+
break;
|
|
1307
|
+
default: next.push(...item.kids);
|
|
1308
|
+
}
|
|
1309
|
+
}
|
|
1310
|
+
}
|
|
1311
|
+
return this.list(next);
|
|
1312
|
+
}
|
|
1313
|
+
filter(path, value) {
|
|
1314
|
+
const sub = this.kids.filter(item => {
|
|
1315
|
+
var found = item.select(...path);
|
|
1316
|
+
if (value === undefined) {
|
|
1317
|
+
return Boolean(found.kids.length);
|
|
1250
1318
|
}
|
|
1251
1319
|
else {
|
|
1252
|
-
return
|
|
1320
|
+
return found.kids.some(child => child.value == value);
|
|
1253
1321
|
}
|
|
1254
|
-
}
|
|
1255
|
-
|
|
1256
|
-
destructor() {
|
|
1257
|
-
super.destructor();
|
|
1258
|
-
const prev = this.cache;
|
|
1259
|
-
if ($mol_owning_check(this, prev)) {
|
|
1260
|
-
prev.destructor();
|
|
1261
|
-
}
|
|
1262
|
-
if (this.pub_from === 0) {
|
|
1263
|
-
;
|
|
1264
|
-
(this.host ?? this.task)[this.field()] = null;
|
|
1265
|
-
}
|
|
1266
|
-
else {
|
|
1267
|
-
;
|
|
1268
|
-
(this.host ?? this.task)[this.field()].delete(this[Symbol.toStringTag]);
|
|
1269
|
-
}
|
|
1322
|
+
});
|
|
1323
|
+
return this.clone(sub);
|
|
1270
1324
|
}
|
|
1271
|
-
|
|
1272
|
-
|
|
1273
|
-
|
|
1325
|
+
hack(belt, context = {}) {
|
|
1326
|
+
return [].concat(...this.kids.map(child => {
|
|
1327
|
+
let handle = belt[child.type] || belt[''];
|
|
1328
|
+
if (!handle || handle === Object.prototype[child.type]) {
|
|
1329
|
+
handle = (input, belt, context) => [
|
|
1330
|
+
input.clone(input.hack(belt, context), context.span)
|
|
1331
|
+
];
|
|
1332
|
+
}
|
|
1274
1333
|
try {
|
|
1275
|
-
|
|
1276
|
-
break update;
|
|
1334
|
+
return handle(child, belt, context);
|
|
1277
1335
|
}
|
|
1278
1336
|
catch (error) {
|
|
1279
|
-
$
|
|
1280
|
-
|
|
1281
|
-
if ($mol_owning_check(this, prev)) {
|
|
1282
|
-
prev.destructor();
|
|
1283
|
-
}
|
|
1284
|
-
if ($mol_owning_catch(this, next)) {
|
|
1285
|
-
try {
|
|
1286
|
-
next[Symbol.toStringTag] = this[Symbol.toStringTag];
|
|
1287
|
-
}
|
|
1288
|
-
catch {
|
|
1289
|
-
Object.defineProperty(next, Symbol.toStringTag, { value: this[Symbol.toStringTag] });
|
|
1290
|
-
}
|
|
1337
|
+
error.message += `\n${child.clone([])}${child.span}`;
|
|
1338
|
+
$mol_fail_hidden(error);
|
|
1291
1339
|
}
|
|
1292
|
-
|
|
1293
|
-
|
|
1294
|
-
|
|
1295
|
-
this.
|
|
1296
|
-
this.cursor = $mol_wire_cursor.fresh;
|
|
1297
|
-
if ($mol_promise_like(next))
|
|
1298
|
-
return next;
|
|
1299
|
-
this.complete_pubs();
|
|
1300
|
-
return next;
|
|
1340
|
+
}));
|
|
1341
|
+
}
|
|
1342
|
+
error(message, Class = Error) {
|
|
1343
|
+
return this.span.error(`${message}\n${this.clone([])}`, Class);
|
|
1301
1344
|
}
|
|
1302
1345
|
}
|
|
1303
|
-
|
|
1304
|
-
|
|
1305
|
-
|
|
1306
|
-
|
|
1307
|
-
|
|
1308
|
-
|
|
1309
|
-
$.$
|
|
1346
|
+
$.$mol_tree2 = $mol_tree2;
|
|
1347
|
+
class $mol_tree2_empty extends $mol_tree2 {
|
|
1348
|
+
constructor() {
|
|
1349
|
+
super('', '', [], $mol_span.unknown);
|
|
1350
|
+
}
|
|
1351
|
+
}
|
|
1352
|
+
$.$mol_tree2_empty = $mol_tree2_empty;
|
|
1310
1353
|
})($ || ($ = {}));
|
|
1311
|
-
//mol/
|
|
1354
|
+
//mol/tree2/tree2.ts
|
|
1312
1355
|
;
|
|
1313
1356
|
"use strict";
|
|
1314
1357
|
var $;
|
|
1315
1358
|
(function ($) {
|
|
1316
|
-
|
|
1317
|
-
|
|
1318
|
-
|
|
1319
|
-
|
|
1320
|
-
|
|
1321
|
-
|
|
1322
|
-
|
|
1359
|
+
class $mol_error_syntax extends SyntaxError {
|
|
1360
|
+
reason;
|
|
1361
|
+
line;
|
|
1362
|
+
span;
|
|
1363
|
+
constructor(reason, line, span) {
|
|
1364
|
+
super(`${reason}\n${span}\n${line.substring(0, span.col - 1).replace(/\S/g, ' ')}${''.padEnd(span.length, '!')}\n${line}`);
|
|
1365
|
+
this.reason = reason;
|
|
1366
|
+
this.line = line;
|
|
1367
|
+
this.span = span;
|
|
1323
1368
|
}
|
|
1324
|
-
|
|
1325
|
-
|
|
1326
|
-
|
|
1327
|
-
|
|
1328
|
-
|
|
1329
|
-
|
|
1330
|
-
|
|
1331
|
-
|
|
1332
|
-
|
|
1333
|
-
|
|
1334
|
-
|
|
1335
|
-
|
|
1369
|
+
}
|
|
1370
|
+
$.$mol_error_syntax = $mol_error_syntax;
|
|
1371
|
+
})($ || ($ = {}));
|
|
1372
|
+
//mol/error/syntax/syntax.ts
|
|
1373
|
+
;
|
|
1374
|
+
"use strict";
|
|
1375
|
+
var $;
|
|
1376
|
+
(function ($) {
|
|
1377
|
+
function $mol_tree2_from_string(str, uri = '?') {
|
|
1378
|
+
const span = $mol_span.entire(uri, str);
|
|
1379
|
+
var root = $mol_tree2.list([], span);
|
|
1380
|
+
var stack = [root];
|
|
1381
|
+
var pos = 0, row = 0, min_indent = 0;
|
|
1382
|
+
while (str.length > pos) {
|
|
1383
|
+
var indent = 0;
|
|
1384
|
+
var line_start = pos;
|
|
1385
|
+
row++;
|
|
1386
|
+
while (str.length > pos && str[pos] == '\t') {
|
|
1387
|
+
indent++;
|
|
1388
|
+
pos++;
|
|
1389
|
+
}
|
|
1390
|
+
if (!root.kids.length) {
|
|
1391
|
+
min_indent = indent;
|
|
1392
|
+
}
|
|
1393
|
+
indent -= min_indent;
|
|
1394
|
+
if (indent < 0 || indent >= stack.length) {
|
|
1395
|
+
const sp = span.span(row, 1, pos - line_start);
|
|
1396
|
+
while (str.length > pos && str[pos] != '\n') {
|
|
1397
|
+
pos++;
|
|
1398
|
+
}
|
|
1399
|
+
if (indent < 0) {
|
|
1400
|
+
if (str.length > pos) {
|
|
1401
|
+
this.$mol_fail(new this.$mol_error_syntax(`Too few tabs`, str.substring(line_start, pos), sp));
|
|
1336
1402
|
}
|
|
1337
1403
|
}
|
|
1338
|
-
|
|
1404
|
+
else {
|
|
1405
|
+
this.$mol_fail(new this.$mol_error_syntax(`Too many tabs`, str.substring(line_start, pos), sp));
|
|
1406
|
+
}
|
|
1339
1407
|
}
|
|
1340
|
-
|
|
1341
|
-
|
|
1342
|
-
|
|
1343
|
-
|
|
1344
|
-
|
|
1345
|
-
|
|
1408
|
+
stack.length = indent + 1;
|
|
1409
|
+
var parent = stack[indent];
|
|
1410
|
+
while (str.length > pos && str[pos] != '\\' && str[pos] != '\n') {
|
|
1411
|
+
var error_start = pos;
|
|
1412
|
+
while (str.length > pos && (str[pos] == ' ' || str[pos] == '\t')) {
|
|
1413
|
+
pos++;
|
|
1414
|
+
}
|
|
1415
|
+
if (pos > error_start) {
|
|
1416
|
+
let line_end = str.indexOf('\n', pos);
|
|
1417
|
+
if (line_end === -1)
|
|
1418
|
+
line_end = str.length;
|
|
1419
|
+
const sp = span.span(row, error_start - line_start + 1, pos - error_start);
|
|
1420
|
+
this.$mol_fail(new this.$mol_error_syntax(`Wrong nodes separator`, str.substring(line_start, line_end), sp));
|
|
1421
|
+
}
|
|
1422
|
+
var type_start = pos;
|
|
1423
|
+
while (str.length > pos &&
|
|
1424
|
+
str[pos] != '\\' &&
|
|
1425
|
+
str[pos] != ' ' &&
|
|
1426
|
+
str[pos] != '\t' &&
|
|
1427
|
+
str[pos] != '\n') {
|
|
1428
|
+
pos++;
|
|
1429
|
+
}
|
|
1430
|
+
if (pos > type_start) {
|
|
1431
|
+
let next = new $mol_tree2(str.slice(type_start, pos), '', [], span.span(row, type_start - line_start + 1, pos - type_start));
|
|
1432
|
+
const parent_kids = parent.kids;
|
|
1433
|
+
parent_kids.push(next);
|
|
1434
|
+
parent = next;
|
|
1435
|
+
}
|
|
1436
|
+
if (str.length > pos && str[pos] == ' ') {
|
|
1437
|
+
pos++;
|
|
1438
|
+
}
|
|
1439
|
+
}
|
|
1440
|
+
if (str.length > pos && str[pos] == '\\') {
|
|
1441
|
+
var data_start = pos;
|
|
1442
|
+
while (str.length > pos && str[pos] != '\n') {
|
|
1443
|
+
pos++;
|
|
1444
|
+
}
|
|
1445
|
+
let next = new $mol_tree2('', str.slice(data_start + 1, pos), [], span.span(row, data_start - line_start + 2, pos - data_start - 1));
|
|
1446
|
+
const parent_kids = parent.kids;
|
|
1447
|
+
parent_kids.push(next);
|
|
1448
|
+
parent = next;
|
|
1449
|
+
}
|
|
1450
|
+
if (str.length === pos && stack.length > 0) {
|
|
1451
|
+
const sp = span.span(row, pos - line_start + 1, 1);
|
|
1452
|
+
this.$mol_fail(new this.$mol_error_syntax(`Unexpected EOF, LF required`, str.substring(line_start, str.length), sp));
|
|
1453
|
+
}
|
|
1454
|
+
stack.push(parent);
|
|
1455
|
+
pos++;
|
|
1456
|
+
}
|
|
1457
|
+
return root;
|
|
1346
1458
|
}
|
|
1347
|
-
$.$
|
|
1459
|
+
$.$mol_tree2_from_string = $mol_tree2_from_string;
|
|
1348
1460
|
})($ || ($ = {}));
|
|
1349
|
-
//mol/
|
|
1461
|
+
//mol/tree2/from/string/string.ts
|
|
1350
1462
|
;
|
|
1351
1463
|
"use strict";
|
|
1352
1464
|
var $;
|
|
1353
1465
|
(function ($) {
|
|
1354
|
-
function $
|
|
1355
|
-
if (
|
|
1356
|
-
|
|
1357
|
-
const orig = descr?.value ?? host[field];
|
|
1358
|
-
const sup = Reflect.getPrototypeOf(host);
|
|
1359
|
-
if (typeof sup[field] === 'function') {
|
|
1360
|
-
Object.defineProperty(orig, 'name', { value: sup[field].name });
|
|
1466
|
+
function $mol_tree2_from_json(json, span = $mol_span.unknown) {
|
|
1467
|
+
if (typeof json === 'boolean' || typeof json === 'number' || json === null) {
|
|
1468
|
+
return new $mol_tree2(String(json), '', [], span);
|
|
1361
1469
|
}
|
|
1362
|
-
|
|
1363
|
-
|
|
1364
|
-
|
|
1365
|
-
|
|
1366
|
-
|
|
1367
|
-
|
|
1368
|
-
|
|
1369
|
-
|
|
1370
|
-
|
|
1371
|
-
|
|
1372
|
-
|
|
1373
|
-
|
|
1374
|
-
|
|
1375
|
-
|
|
1376
|
-
|
|
1470
|
+
if (typeof json === 'string') {
|
|
1471
|
+
return $mol_tree2.data(json, [], span);
|
|
1472
|
+
}
|
|
1473
|
+
if (Array.isArray(json)) {
|
|
1474
|
+
const sub = json.map(json => $mol_tree2_from_json(json, span));
|
|
1475
|
+
return new $mol_tree2('/', '', sub, span);
|
|
1476
|
+
}
|
|
1477
|
+
if (ArrayBuffer.isView(json)) {
|
|
1478
|
+
const buf = new Uint8Array(json.buffer, json.byteOffset, json.byteLength);
|
|
1479
|
+
return $mol_tree2.data(String.fromCharCode(...buf), [], span);
|
|
1480
|
+
}
|
|
1481
|
+
if (json instanceof Date) {
|
|
1482
|
+
return new $mol_tree2('', json.toISOString(), [], span);
|
|
1483
|
+
}
|
|
1484
|
+
if (typeof json.toJSON === 'function') {
|
|
1485
|
+
return $mol_tree2_from_json(json.toJSON());
|
|
1486
|
+
}
|
|
1487
|
+
if (json instanceof Error) {
|
|
1488
|
+
const { name, message, stack } = json;
|
|
1489
|
+
json = { ...json, name, message, stack };
|
|
1490
|
+
}
|
|
1491
|
+
const sub = [];
|
|
1492
|
+
for (var key in json) {
|
|
1493
|
+
const val = json[key];
|
|
1494
|
+
if (val === undefined)
|
|
1495
|
+
continue;
|
|
1496
|
+
const subsub = $mol_tree2_from_json(val, span);
|
|
1497
|
+
if (/^[^\n\t\\ ]+$/.test(key)) {
|
|
1498
|
+
sub.push(new $mol_tree2(key, '', [subsub], span));
|
|
1377
1499
|
}
|
|
1378
|
-
|
|
1379
|
-
|
|
1380
|
-
|
|
1381
|
-
|
|
1382
|
-
|
|
1383
|
-
return descr2;
|
|
1500
|
+
else {
|
|
1501
|
+
sub.push($mol_tree2.data(key, [subsub], span));
|
|
1502
|
+
}
|
|
1503
|
+
}
|
|
1504
|
+
return new $mol_tree2('*', '', sub, span);
|
|
1384
1505
|
}
|
|
1385
|
-
$.$
|
|
1386
|
-
})($ || ($ = {}));
|
|
1387
|
-
//mol/wire/plex/plex.ts
|
|
1388
|
-
;
|
|
1389
|
-
"use strict";
|
|
1390
|
-
var $;
|
|
1391
|
-
(function ($) {
|
|
1392
|
-
$.$mol_mem = $mol_wire_solo;
|
|
1393
|
-
$.$mol_mem_key = $mol_wire_plex;
|
|
1506
|
+
$.$mol_tree2_from_json = $mol_tree2_from_json;
|
|
1394
1507
|
})($ || ($ = {}));
|
|
1395
|
-
//mol/
|
|
1508
|
+
//mol/tree2/from/json/json.ts
|
|
1396
1509
|
;
|
|
1397
1510
|
"use strict";
|
|
1398
1511
|
var $;
|
|
1399
1512
|
(function ($) {
|
|
1400
|
-
|
|
1401
|
-
|
|
1402
|
-
;
|
|
1403
|
-
|
|
1404
|
-
|
|
1405
|
-
;
|
|
1406
|
-
|
|
1407
|
-
|
|
1408
|
-
|
|
1409
|
-
|
|
1410
|
-
|
|
1411
|
-
|
|
1412
|
-
|
|
1413
|
-
|
|
1414
|
-
|
|
1415
|
-
|
|
1416
|
-
|
|
1417
|
-
|
|
1418
|
-
|
|
1419
|
-
|
|
1420
|
-
|
|
1421
|
-
|
|
1422
|
-
|
|
1423
|
-
if (
|
|
1424
|
-
|
|
1425
|
-
|
|
1426
|
-
|
|
1427
|
-
|
|
1428
|
-
|
|
1429
|
-
|
|
1430
|
-
|
|
1431
|
-
|
|
1432
|
-
|
|
1433
|
-
|
|
1513
|
+
class $mol_term_color {
|
|
1514
|
+
static reset = this.ansi(0, 0);
|
|
1515
|
+
static bold = this.ansi(1, 22);
|
|
1516
|
+
static italic = this.ansi(3, 23);
|
|
1517
|
+
static underline = this.ansi(4, 24);
|
|
1518
|
+
static inverse = this.ansi(7, 27);
|
|
1519
|
+
static hidden = this.ansi(8, 28);
|
|
1520
|
+
static strike = this.ansi(9, 29);
|
|
1521
|
+
static gray = this.ansi(90, 39);
|
|
1522
|
+
static red = this.ansi(91, 39);
|
|
1523
|
+
static green = this.ansi(92, 39);
|
|
1524
|
+
static yellow = this.ansi(93, 39);
|
|
1525
|
+
static blue = this.ansi(94, 39);
|
|
1526
|
+
static magenta = this.ansi(95, 39);
|
|
1527
|
+
static cyan = this.ansi(96, 39);
|
|
1528
|
+
static Gray = (str) => this.inverse(this.gray(str));
|
|
1529
|
+
static Red = (str) => this.inverse(this.red(str));
|
|
1530
|
+
static Green = (str) => this.inverse(this.green(str));
|
|
1531
|
+
static Yellow = (str) => this.inverse(this.yellow(str));
|
|
1532
|
+
static Blue = (str) => this.inverse(this.blue(str));
|
|
1533
|
+
static Magenta = (str) => this.inverse(this.magenta(str));
|
|
1534
|
+
static Cyan = (str) => this.inverse(this.cyan(str));
|
|
1535
|
+
static ansi(open, close) {
|
|
1536
|
+
if (typeof process === 'undefined')
|
|
1537
|
+
return String;
|
|
1538
|
+
if (!process.stdout.isTTY)
|
|
1539
|
+
return String;
|
|
1540
|
+
const prefix = `\x1b[${open}m`;
|
|
1541
|
+
const postfix = `\x1b[${close}m`;
|
|
1542
|
+
const suffix_regexp = new RegExp(postfix.replace('[', '\\['), 'g');
|
|
1543
|
+
return function colorer(str) {
|
|
1544
|
+
str = String(str);
|
|
1545
|
+
if (str === '')
|
|
1546
|
+
return str;
|
|
1547
|
+
const suffix = str.replace(suffix_regexp, prefix);
|
|
1548
|
+
return prefix + suffix + postfix;
|
|
1549
|
+
};
|
|
1434
1550
|
}
|
|
1435
|
-
|
|
1436
|
-
|
|
1437
|
-
|
|
1438
|
-
|
|
1439
|
-
return true;
|
|
1440
|
-
},
|
|
1441
|
-
});
|
|
1442
|
-
require = (req => Object.assign(function require(name) {
|
|
1443
|
-
return $node[name];
|
|
1444
|
-
}, req))(require);
|
|
1445
|
-
//node/node.node.ts
|
|
1551
|
+
}
|
|
1552
|
+
$.$mol_term_color = $mol_term_color;
|
|
1553
|
+
})($ || ($ = {}));
|
|
1554
|
+
//mol/term/color/color.ts
|
|
1446
1555
|
;
|
|
1447
1556
|
"use strict";
|
|
1448
1557
|
var $;
|
|
1449
1558
|
(function ($) {
|
|
1450
|
-
function $
|
|
1451
|
-
|
|
1452
|
-
|
|
1453
|
-
|
|
1454
|
-
|
|
1455
|
-
|
|
1456
|
-
|
|
1457
|
-
|
|
1458
|
-
|
|
1459
|
-
|
|
1460
|
-
if (logged)
|
|
1461
|
-
self.console.groupEnd();
|
|
1462
|
-
if (stack.length > deep)
|
|
1463
|
-
stack.length = deep;
|
|
1559
|
+
function $mol_log3_node_make(level, output, type, color) {
|
|
1560
|
+
return function $mol_log3_logger(event) {
|
|
1561
|
+
if (!event.time)
|
|
1562
|
+
event = { time: new Date().toISOString(), ...event };
|
|
1563
|
+
let tree = this.$mol_tree2_from_json(event);
|
|
1564
|
+
tree = tree.struct(type, tree.kids);
|
|
1565
|
+
let str = color(tree.toString());
|
|
1566
|
+
this.console[level](str);
|
|
1567
|
+
const self = this;
|
|
1568
|
+
return () => self.console.groupEnd();
|
|
1464
1569
|
};
|
|
1465
1570
|
}
|
|
1466
|
-
$.$
|
|
1467
|
-
$.$
|
|
1571
|
+
$.$mol_log3_node_make = $mol_log3_node_make;
|
|
1572
|
+
$.$mol_log3_come = $mol_log3_node_make('info', 'stdout', 'come', $mol_term_color.blue);
|
|
1573
|
+
$.$mol_log3_done = $mol_log3_node_make('info', 'stdout', 'done', $mol_term_color.green);
|
|
1574
|
+
$.$mol_log3_fail = $mol_log3_node_make('error', 'stderr', 'fail', $mol_term_color.red);
|
|
1575
|
+
$.$mol_log3_warn = $mol_log3_node_make('warn', 'stderr', 'warn', $mol_term_color.yellow);
|
|
1576
|
+
$.$mol_log3_rise = $mol_log3_node_make('log', 'stdout', 'rise', $mol_term_color.magenta);
|
|
1577
|
+
$.$mol_log3_area = $mol_log3_node_make('log', 'stdout', 'area', $mol_term_color.cyan);
|
|
1468
1578
|
})($ || ($ = {}));
|
|
1469
|
-
//mol/log3/log3.ts
|
|
1579
|
+
//mol/log3/log3.node.ts
|
|
1470
1580
|
;
|
|
1471
1581
|
"use strict";
|
|
1472
1582
|
var $;
|
|
1473
1583
|
(function ($) {
|
|
1474
|
-
class $
|
|
1475
|
-
|
|
1476
|
-
|
|
1477
|
-
|
|
1478
|
-
|
|
1479
|
-
|
|
1480
|
-
|
|
1481
|
-
|
|
1482
|
-
|
|
1483
|
-
|
|
1484
|
-
|
|
1485
|
-
|
|
1486
|
-
|
|
1487
|
-
|
|
1488
|
-
|
|
1489
|
-
|
|
1490
|
-
|
|
1491
|
-
|
|
1492
|
-
|
|
1493
|
-
|
|
1494
|
-
|
|
1495
|
-
|
|
1496
|
-
|
|
1497
|
-
|
|
1498
|
-
|
|
1499
|
-
|
|
1500
|
-
|
|
1501
|
-
}
|
|
1502
|
-
toJSON() {
|
|
1503
|
-
return {
|
|
1504
|
-
uri: this.uri,
|
|
1505
|
-
row: this.row,
|
|
1506
|
-
col: this.col,
|
|
1507
|
-
length: this.length
|
|
1584
|
+
class $mol_wire_task extends $mol_wire_fiber {
|
|
1585
|
+
static getter(task) {
|
|
1586
|
+
return function $mol_wire_task_get(host, args) {
|
|
1587
|
+
const sub = $mol_wire_auto();
|
|
1588
|
+
const existen = sub?.track_next();
|
|
1589
|
+
reuse: if (existen) {
|
|
1590
|
+
if (!existen.temp)
|
|
1591
|
+
break reuse;
|
|
1592
|
+
if (existen.host !== host)
|
|
1593
|
+
break reuse;
|
|
1594
|
+
if (existen.task !== task)
|
|
1595
|
+
break reuse;
|
|
1596
|
+
if (!$mol_compare_deep(existen.args, args))
|
|
1597
|
+
break reuse;
|
|
1598
|
+
return existen;
|
|
1599
|
+
}
|
|
1600
|
+
const next = new $mol_wire_task(`${host?.[Symbol.toStringTag] ?? host}.${task.name}(#)`, task, host, args);
|
|
1601
|
+
if (existen?.temp) {
|
|
1602
|
+
$$.$mol_log3_warn({
|
|
1603
|
+
place: '$mol_wire_task',
|
|
1604
|
+
message: `Non idempotency`,
|
|
1605
|
+
existen,
|
|
1606
|
+
next,
|
|
1607
|
+
hint: 'Ignore it',
|
|
1608
|
+
});
|
|
1609
|
+
}
|
|
1610
|
+
return next;
|
|
1508
1611
|
};
|
|
1509
1612
|
}
|
|
1510
|
-
|
|
1511
|
-
return
|
|
1613
|
+
get temp() {
|
|
1614
|
+
return true;
|
|
1512
1615
|
}
|
|
1513
|
-
|
|
1514
|
-
|
|
1616
|
+
complete() {
|
|
1617
|
+
if ($mol_promise_like(this.cache))
|
|
1618
|
+
return;
|
|
1619
|
+
this.destructor();
|
|
1515
1620
|
}
|
|
1516
|
-
|
|
1517
|
-
|
|
1621
|
+
put(next) {
|
|
1622
|
+
const prev = this.cache;
|
|
1623
|
+
this.cache = next;
|
|
1624
|
+
if ($mol_promise_like(next)) {
|
|
1625
|
+
this.cursor = $mol_wire_cursor.fresh;
|
|
1626
|
+
if (next !== prev)
|
|
1627
|
+
this.emit();
|
|
1628
|
+
return next;
|
|
1629
|
+
}
|
|
1630
|
+
this.cursor = $mol_wire_cursor.final;
|
|
1631
|
+
if (this.sub_empty)
|
|
1632
|
+
this.destructor();
|
|
1633
|
+
else if (next !== prev)
|
|
1634
|
+
this.emit();
|
|
1635
|
+
return next;
|
|
1518
1636
|
}
|
|
1519
|
-
|
|
1520
|
-
|
|
1521
|
-
|
|
1522
|
-
|
|
1523
|
-
|
|
1524
|
-
|
|
1525
|
-
|
|
1526
|
-
|
|
1527
|
-
|
|
1528
|
-
|
|
1529
|
-
|
|
1530
|
-
|
|
1531
|
-
|
|
1637
|
+
}
|
|
1638
|
+
$.$mol_wire_task = $mol_wire_task;
|
|
1639
|
+
})($ || ($ = {}));
|
|
1640
|
+
//mol/wire/task/task.ts
|
|
1641
|
+
;
|
|
1642
|
+
"use strict";
|
|
1643
|
+
var $;
|
|
1644
|
+
(function ($) {
|
|
1645
|
+
function $mol_wire_method(host, field, descr) {
|
|
1646
|
+
if (!descr)
|
|
1647
|
+
descr = Reflect.getOwnPropertyDescriptor(host, field);
|
|
1648
|
+
const orig = descr?.value ?? host[field];
|
|
1649
|
+
const sup = Reflect.getPrototypeOf(host);
|
|
1650
|
+
if (typeof sup[field] === 'function') {
|
|
1651
|
+
Object.defineProperty(orig, 'name', { value: sup[field].name });
|
|
1532
1652
|
}
|
|
1653
|
+
const temp = $mol_wire_task.getter(orig);
|
|
1654
|
+
const value = function (...args) {
|
|
1655
|
+
const fiber = temp(this ?? null, args);
|
|
1656
|
+
return fiber.sync();
|
|
1657
|
+
};
|
|
1658
|
+
Object.defineProperty(value, 'name', { value: orig.name + ' ' });
|
|
1659
|
+
Object.assign(value, { orig });
|
|
1660
|
+
const descr2 = { ...descr, value };
|
|
1661
|
+
Reflect.defineProperty(host, field, descr2);
|
|
1662
|
+
return descr2;
|
|
1533
1663
|
}
|
|
1534
|
-
$.$
|
|
1664
|
+
$.$mol_wire_method = $mol_wire_method;
|
|
1535
1665
|
})($ || ($ = {}));
|
|
1536
|
-
//mol/
|
|
1666
|
+
//mol/wire/method/method.ts
|
|
1667
|
+
;
|
|
1668
|
+
"use strict";
|
|
1669
|
+
//mol/type/tail/tail.ts
|
|
1670
|
+
;
|
|
1671
|
+
"use strict";
|
|
1672
|
+
//mol/type/foot/foot.ts
|
|
1537
1673
|
;
|
|
1538
1674
|
"use strict";
|
|
1539
1675
|
var $;
|
|
1540
1676
|
(function ($) {
|
|
1541
|
-
|
|
1542
|
-
|
|
1543
|
-
|
|
1544
|
-
|
|
1545
|
-
|
|
1546
|
-
|
|
1547
|
-
|
|
1548
|
-
|
|
1549
|
-
|
|
1550
|
-
|
|
1551
|
-
dump(tree.kids[0], prefix);
|
|
1552
|
-
return;
|
|
1553
|
-
}
|
|
1554
|
-
output.push("\n");
|
|
1555
|
-
}
|
|
1556
|
-
else if (tree.value.length || prefix.length) {
|
|
1557
|
-
output.push("\\" + tree.value + "\n");
|
|
1558
|
-
}
|
|
1559
|
-
for (const kid of tree.kids) {
|
|
1560
|
-
output.push(prefix);
|
|
1561
|
-
dump(kid, prefix + "\t");
|
|
1562
|
-
}
|
|
1563
|
-
}
|
|
1564
|
-
dump(tree);
|
|
1565
|
-
return output.join('');
|
|
1677
|
+
const catched = new WeakMap();
|
|
1678
|
+
function $mol_fail_catch(error) {
|
|
1679
|
+
if (typeof error !== 'object')
|
|
1680
|
+
return false;
|
|
1681
|
+
if ($mol_promise_like(error))
|
|
1682
|
+
$mol_fail_hidden(error);
|
|
1683
|
+
if (catched.get(error))
|
|
1684
|
+
return false;
|
|
1685
|
+
catched.set(error, true);
|
|
1686
|
+
return true;
|
|
1566
1687
|
}
|
|
1567
|
-
$.$
|
|
1688
|
+
$.$mol_fail_catch = $mol_fail_catch;
|
|
1568
1689
|
})($ || ($ = {}));
|
|
1569
|
-
//mol/
|
|
1690
|
+
//mol/fail/catch/catch.ts
|
|
1570
1691
|
;
|
|
1571
1692
|
"use strict";
|
|
1572
1693
|
var $;
|
|
1573
1694
|
(function ($) {
|
|
1574
|
-
|
|
1575
|
-
|
|
1576
|
-
|
|
1577
|
-
|
|
1578
|
-
|
|
1579
|
-
|
|
1580
|
-
|
|
1581
|
-
|
|
1582
|
-
|
|
1583
|
-
|
|
1584
|
-
|
|
1585
|
-
|
|
1586
|
-
|
|
1587
|
-
|
|
1588
|
-
|
|
1589
|
-
|
|
1590
|
-
|
|
1591
|
-
|
|
1592
|
-
|
|
1593
|
-
|
|
1594
|
-
|
|
1595
|
-
|
|
1596
|
-
|
|
1597
|
-
|
|
1598
|
-
|
|
1599
|
-
|
|
1600
|
-
});
|
|
1601
|
-
kids = [...data, ...kids];
|
|
1602
|
-
value = '';
|
|
1603
|
-
}
|
|
1604
|
-
return new $mol_tree2('', value, kids, span);
|
|
1605
|
-
}
|
|
1606
|
-
data(value, kids = []) {
|
|
1607
|
-
return $mol_tree2.data(value, kids, this.span);
|
|
1695
|
+
function $mol_fail_log(error) {
|
|
1696
|
+
if ($mol_promise_like(error))
|
|
1697
|
+
return false;
|
|
1698
|
+
if (!$mol_fail_catch(error))
|
|
1699
|
+
return false;
|
|
1700
|
+
console.error(error);
|
|
1701
|
+
return true;
|
|
1702
|
+
}
|
|
1703
|
+
$.$mol_fail_log = $mol_fail_log;
|
|
1704
|
+
})($ || ($ = {}));
|
|
1705
|
+
//mol/fail/log/log.ts
|
|
1706
|
+
;
|
|
1707
|
+
"use strict";
|
|
1708
|
+
var $;
|
|
1709
|
+
(function ($) {
|
|
1710
|
+
class $mol_wire_atom extends $mol_wire_fiber {
|
|
1711
|
+
static solo(host, task) {
|
|
1712
|
+
const field = task.name + '()';
|
|
1713
|
+
const existen = Object.getOwnPropertyDescriptor(host ?? task, field)?.value;
|
|
1714
|
+
if (existen)
|
|
1715
|
+
return existen;
|
|
1716
|
+
const prefix = host?.[Symbol.toStringTag] ?? (host instanceof Function ? $$.$mol_func_name(host) : host);
|
|
1717
|
+
const key = `${prefix}.${field}`;
|
|
1718
|
+
const fiber = new $mol_wire_atom(key, task, host, []);
|
|
1719
|
+
(host ?? task)[field] = fiber;
|
|
1720
|
+
return fiber;
|
|
1608
1721
|
}
|
|
1609
|
-
static
|
|
1610
|
-
|
|
1611
|
-
|
|
1722
|
+
static plex(host, task, key) {
|
|
1723
|
+
const field = task.name + '()';
|
|
1724
|
+
let dict = Object.getOwnPropertyDescriptor(host ?? task, field)?.value;
|
|
1725
|
+
const prefix = host?.[Symbol.toStringTag] ?? (host instanceof Function ? $$.$mol_func_name(host) : host);
|
|
1726
|
+
const id = `${prefix}.${task.name}(${$mol_key(key).replace(/^"|"$/g, "'")})`;
|
|
1727
|
+
if (dict) {
|
|
1728
|
+
const existen = dict.get(id);
|
|
1729
|
+
if (existen)
|
|
1730
|
+
return existen;
|
|
1612
1731
|
}
|
|
1613
|
-
|
|
1614
|
-
|
|
1615
|
-
struct(type, kids = []) {
|
|
1616
|
-
return $mol_tree2.struct(type, kids, this.span);
|
|
1617
|
-
}
|
|
1618
|
-
clone(kids, span = this.span) {
|
|
1619
|
-
return new $mol_tree2(this.type, this.value, kids, span);
|
|
1620
|
-
}
|
|
1621
|
-
text() {
|
|
1622
|
-
var values = [];
|
|
1623
|
-
for (var kid of this.kids) {
|
|
1624
|
-
if (kid.type)
|
|
1625
|
-
continue;
|
|
1626
|
-
values.push(kid.value);
|
|
1732
|
+
else {
|
|
1733
|
+
dict = (host ?? task)[field] = new Map();
|
|
1627
1734
|
}
|
|
1628
|
-
|
|
1629
|
-
|
|
1630
|
-
|
|
1631
|
-
return $$.$mol_tree2_from_string(str, uri);
|
|
1632
|
-
}
|
|
1633
|
-
toString() {
|
|
1634
|
-
return $$.$mol_tree2_to_string(this);
|
|
1735
|
+
const fiber = new $mol_wire_atom(id, task, host, [key]);
|
|
1736
|
+
dict.set(id, fiber);
|
|
1737
|
+
return fiber;
|
|
1635
1738
|
}
|
|
1636
|
-
|
|
1637
|
-
|
|
1638
|
-
|
|
1639
|
-
|
|
1640
|
-
|
|
1641
|
-
|
|
1642
|
-
|
|
1643
|
-
|
|
1644
|
-
|
|
1645
|
-
|
|
1646
|
-
|
|
1647
|
-
}).filter(Boolean);
|
|
1648
|
-
if (!replaced && value) {
|
|
1649
|
-
sub.push(this.struct(type, []).insert(value, ...path.slice(1)));
|
|
1739
|
+
static watching = new Set();
|
|
1740
|
+
static watcher = null;
|
|
1741
|
+
static watch() {
|
|
1742
|
+
$mol_wire_atom.watcher = new $mol_after_frame($mol_wire_atom.watch);
|
|
1743
|
+
for (const atom of $mol_wire_atom.watching) {
|
|
1744
|
+
if (atom.cursor === $mol_wire_cursor.final) {
|
|
1745
|
+
$mol_wire_atom.watching.delete(atom);
|
|
1746
|
+
}
|
|
1747
|
+
else {
|
|
1748
|
+
atom.cursor = $mol_wire_cursor.stale;
|
|
1749
|
+
atom.fresh();
|
|
1650
1750
|
}
|
|
1651
|
-
return this.clone(sub);
|
|
1652
|
-
}
|
|
1653
|
-
else if (typeof type === 'number') {
|
|
1654
|
-
const sub = this.kids.slice();
|
|
1655
|
-
sub[type] = (sub[type] || this.list([]))
|
|
1656
|
-
.insert(value, ...path.slice(1));
|
|
1657
|
-
return this.clone(sub.filter(Boolean));
|
|
1658
|
-
}
|
|
1659
|
-
else {
|
|
1660
|
-
const kids = ((this.kids.length === 0) ? [this.list([])] : this.kids)
|
|
1661
|
-
.map(item => item.insert(value, ...path.slice(1)))
|
|
1662
|
-
.filter(Boolean);
|
|
1663
|
-
return this.clone(kids);
|
|
1664
1751
|
}
|
|
1665
1752
|
}
|
|
1666
|
-
|
|
1667
|
-
|
|
1668
|
-
|
|
1669
|
-
if (!next.length)
|
|
1670
|
-
break;
|
|
1671
|
-
const prev = next;
|
|
1672
|
-
next = [];
|
|
1673
|
-
for (var item of prev) {
|
|
1674
|
-
switch (typeof (type)) {
|
|
1675
|
-
case 'string':
|
|
1676
|
-
for (var child of item.kids) {
|
|
1677
|
-
if (child.type == type) {
|
|
1678
|
-
next.push(child);
|
|
1679
|
-
}
|
|
1680
|
-
}
|
|
1681
|
-
break;
|
|
1682
|
-
case 'number':
|
|
1683
|
-
if (type < item.kids.length)
|
|
1684
|
-
next.push(item.kids[type]);
|
|
1685
|
-
break;
|
|
1686
|
-
default: next.push(...item.kids);
|
|
1687
|
-
}
|
|
1688
|
-
}
|
|
1753
|
+
watch() {
|
|
1754
|
+
if (!$mol_wire_atom.watcher) {
|
|
1755
|
+
$mol_wire_atom.watcher = new $mol_after_frame($mol_wire_atom.watch);
|
|
1689
1756
|
}
|
|
1690
|
-
|
|
1757
|
+
$mol_wire_atom.watching.add(this);
|
|
1691
1758
|
}
|
|
1692
|
-
|
|
1693
|
-
|
|
1694
|
-
|
|
1695
|
-
|
|
1696
|
-
|
|
1759
|
+
resync(args) {
|
|
1760
|
+
return this.put(this.task.call(this.host, ...args));
|
|
1761
|
+
}
|
|
1762
|
+
once() {
|
|
1763
|
+
return this.sync();
|
|
1764
|
+
}
|
|
1765
|
+
channel() {
|
|
1766
|
+
return Object.assign((next) => {
|
|
1767
|
+
if (next !== undefined)
|
|
1768
|
+
return this.resync([...this.args, next]);
|
|
1769
|
+
if (!$mol_wire_fiber.warm)
|
|
1770
|
+
return this.result();
|
|
1771
|
+
if ($mol_wire_auto()?.temp) {
|
|
1772
|
+
return this.once();
|
|
1697
1773
|
}
|
|
1698
1774
|
else {
|
|
1699
|
-
return
|
|
1700
|
-
}
|
|
1701
|
-
});
|
|
1702
|
-
return this.clone(sub);
|
|
1703
|
-
}
|
|
1704
|
-
hack(belt, context = {}) {
|
|
1705
|
-
return [].concat(...this.kids.map(child => {
|
|
1706
|
-
let handle = belt[child.type] || belt[''];
|
|
1707
|
-
if (!handle || handle === Object.prototype[child.type]) {
|
|
1708
|
-
handle = (input, belt, context) => [
|
|
1709
|
-
input.clone(input.hack(belt, context), context.span)
|
|
1710
|
-
];
|
|
1775
|
+
return this.sync();
|
|
1711
1776
|
}
|
|
1777
|
+
}, { atom: this });
|
|
1778
|
+
}
|
|
1779
|
+
destructor() {
|
|
1780
|
+
super.destructor();
|
|
1781
|
+
const prev = this.cache;
|
|
1782
|
+
if ($mol_owning_check(this, prev)) {
|
|
1783
|
+
prev.destructor();
|
|
1784
|
+
}
|
|
1785
|
+
if (this.pub_from === 0) {
|
|
1786
|
+
;
|
|
1787
|
+
(this.host ?? this.task)[this.field()] = null;
|
|
1788
|
+
}
|
|
1789
|
+
else {
|
|
1790
|
+
;
|
|
1791
|
+
(this.host ?? this.task)[this.field()].delete(this[Symbol.toStringTag]);
|
|
1792
|
+
}
|
|
1793
|
+
}
|
|
1794
|
+
put(next) {
|
|
1795
|
+
const prev = this.cache;
|
|
1796
|
+
update: if (next !== prev) {
|
|
1712
1797
|
try {
|
|
1713
|
-
|
|
1798
|
+
if ($mol_compare_deep(prev, next))
|
|
1799
|
+
break update;
|
|
1714
1800
|
}
|
|
1715
1801
|
catch (error) {
|
|
1716
|
-
|
|
1717
|
-
$mol_fail_hidden(error);
|
|
1802
|
+
$mol_fail_log(error);
|
|
1718
1803
|
}
|
|
1719
|
-
|
|
1720
|
-
|
|
1721
|
-
|
|
1722
|
-
|
|
1723
|
-
|
|
1724
|
-
|
|
1725
|
-
|
|
1726
|
-
|
|
1727
|
-
|
|
1728
|
-
|
|
1804
|
+
if ($mol_owning_check(this, prev)) {
|
|
1805
|
+
prev.destructor();
|
|
1806
|
+
}
|
|
1807
|
+
if ($mol_owning_catch(this, next)) {
|
|
1808
|
+
try {
|
|
1809
|
+
next[Symbol.toStringTag] = this[Symbol.toStringTag];
|
|
1810
|
+
}
|
|
1811
|
+
catch {
|
|
1812
|
+
Object.defineProperty(next, Symbol.toStringTag, { value: this[Symbol.toStringTag] });
|
|
1813
|
+
}
|
|
1814
|
+
}
|
|
1815
|
+
if (!this.sub_empty)
|
|
1816
|
+
this.emit();
|
|
1817
|
+
}
|
|
1818
|
+
this.cache = next;
|
|
1819
|
+
this.cursor = $mol_wire_cursor.fresh;
|
|
1820
|
+
if ($mol_promise_like(next))
|
|
1821
|
+
return next;
|
|
1822
|
+
this.complete_pubs();
|
|
1823
|
+
return next;
|
|
1729
1824
|
}
|
|
1730
1825
|
}
|
|
1731
|
-
|
|
1826
|
+
__decorate([
|
|
1827
|
+
$mol_wire_method
|
|
1828
|
+
], $mol_wire_atom.prototype, "resync", null);
|
|
1829
|
+
__decorate([
|
|
1830
|
+
$mol_wire_method
|
|
1831
|
+
], $mol_wire_atom.prototype, "once", null);
|
|
1832
|
+
$.$mol_wire_atom = $mol_wire_atom;
|
|
1732
1833
|
})($ || ($ = {}));
|
|
1733
|
-
//mol/
|
|
1834
|
+
//mol/wire/atom/atom.ts
|
|
1734
1835
|
;
|
|
1735
1836
|
"use strict";
|
|
1736
1837
|
var $;
|
|
1737
1838
|
(function ($) {
|
|
1738
|
-
|
|
1739
|
-
|
|
1740
|
-
|
|
1741
|
-
|
|
1742
|
-
|
|
1743
|
-
|
|
1744
|
-
|
|
1745
|
-
this.line = line;
|
|
1746
|
-
this.span = span;
|
|
1839
|
+
function $mol_wire_solo(host, field, descr) {
|
|
1840
|
+
if (!descr)
|
|
1841
|
+
descr = Reflect.getOwnPropertyDescriptor(host, field);
|
|
1842
|
+
const orig = descr?.value ?? host[field];
|
|
1843
|
+
const sup = Reflect.getPrototypeOf(host);
|
|
1844
|
+
if (typeof sup[field] === 'function') {
|
|
1845
|
+
Object.defineProperty(orig, 'name', { value: sup[field].name });
|
|
1747
1846
|
}
|
|
1748
|
-
|
|
1749
|
-
|
|
1750
|
-
|
|
1751
|
-
|
|
1752
|
-
|
|
1753
|
-
|
|
1754
|
-
|
|
1755
|
-
|
|
1756
|
-
|
|
1757
|
-
|
|
1758
|
-
|
|
1759
|
-
|
|
1760
|
-
var pos = 0, row = 0, min_indent = 0;
|
|
1761
|
-
while (str.length > pos) {
|
|
1762
|
-
var indent = 0;
|
|
1763
|
-
var line_start = pos;
|
|
1764
|
-
row++;
|
|
1765
|
-
while (str.length > pos && str[pos] == '\t') {
|
|
1766
|
-
indent++;
|
|
1767
|
-
pos++;
|
|
1768
|
-
}
|
|
1769
|
-
if (!root.kids.length) {
|
|
1770
|
-
min_indent = indent;
|
|
1771
|
-
}
|
|
1772
|
-
indent -= min_indent;
|
|
1773
|
-
if (indent < 0 || indent >= stack.length) {
|
|
1774
|
-
const sp = span.span(row, 1, pos - line_start);
|
|
1775
|
-
while (str.length > pos && str[pos] != '\n') {
|
|
1776
|
-
pos++;
|
|
1777
|
-
}
|
|
1778
|
-
if (indent < 0) {
|
|
1779
|
-
if (str.length > pos) {
|
|
1780
|
-
this.$mol_fail(new this.$mol_error_syntax(`Too few tabs`, str.substring(line_start, pos), sp));
|
|
1847
|
+
const descr2 = {
|
|
1848
|
+
...descr,
|
|
1849
|
+
value: function (...args) {
|
|
1850
|
+
let atom = $mol_wire_atom.solo(this, orig);
|
|
1851
|
+
if ((args.length === 0) || (args[0] === undefined)) {
|
|
1852
|
+
if (!$mol_wire_fiber.warm)
|
|
1853
|
+
return atom.result();
|
|
1854
|
+
if ($mol_wire_auto()?.temp) {
|
|
1855
|
+
return atom.once();
|
|
1856
|
+
}
|
|
1857
|
+
else {
|
|
1858
|
+
return atom.sync();
|
|
1781
1859
|
}
|
|
1782
1860
|
}
|
|
1783
|
-
|
|
1784
|
-
this.$mol_fail(new this.$mol_error_syntax(`Too many tabs`, str.substring(line_start, pos), sp));
|
|
1785
|
-
}
|
|
1786
|
-
}
|
|
1787
|
-
stack.length = indent + 1;
|
|
1788
|
-
var parent = stack[indent];
|
|
1789
|
-
while (str.length > pos && str[pos] != '\\' && str[pos] != '\n') {
|
|
1790
|
-
var error_start = pos;
|
|
1791
|
-
while (str.length > pos && (str[pos] == ' ' || str[pos] == '\t')) {
|
|
1792
|
-
pos++;
|
|
1793
|
-
}
|
|
1794
|
-
if (pos > error_start) {
|
|
1795
|
-
let line_end = str.indexOf('\n', pos);
|
|
1796
|
-
if (line_end === -1)
|
|
1797
|
-
line_end = str.length;
|
|
1798
|
-
const sp = span.span(row, error_start - line_start + 1, pos - error_start);
|
|
1799
|
-
this.$mol_fail(new this.$mol_error_syntax(`Wrong nodes separator`, str.substring(line_start, line_end), sp));
|
|
1800
|
-
}
|
|
1801
|
-
var type_start = pos;
|
|
1802
|
-
while (str.length > pos &&
|
|
1803
|
-
str[pos] != '\\' &&
|
|
1804
|
-
str[pos] != ' ' &&
|
|
1805
|
-
str[pos] != '\t' &&
|
|
1806
|
-
str[pos] != '\n') {
|
|
1807
|
-
pos++;
|
|
1808
|
-
}
|
|
1809
|
-
if (pos > type_start) {
|
|
1810
|
-
let next = new $mol_tree2(str.slice(type_start, pos), '', [], span.span(row, type_start - line_start + 1, pos - type_start));
|
|
1811
|
-
const parent_kids = parent.kids;
|
|
1812
|
-
parent_kids.push(next);
|
|
1813
|
-
parent = next;
|
|
1814
|
-
}
|
|
1815
|
-
if (str.length > pos && str[pos] == ' ') {
|
|
1816
|
-
pos++;
|
|
1817
|
-
}
|
|
1818
|
-
}
|
|
1819
|
-
if (str.length > pos && str[pos] == '\\') {
|
|
1820
|
-
var data_start = pos;
|
|
1821
|
-
while (str.length > pos && str[pos] != '\n') {
|
|
1822
|
-
pos++;
|
|
1823
|
-
}
|
|
1824
|
-
let next = new $mol_tree2('', str.slice(data_start + 1, pos), [], span.span(row, data_start - line_start + 2, pos - data_start - 1));
|
|
1825
|
-
const parent_kids = parent.kids;
|
|
1826
|
-
parent_kids.push(next);
|
|
1827
|
-
parent = next;
|
|
1828
|
-
}
|
|
1829
|
-
if (str.length === pos && stack.length > 0) {
|
|
1830
|
-
const sp = span.span(row, pos - line_start + 1, 1);
|
|
1831
|
-
this.$mol_fail(new this.$mol_error_syntax(`Unexpected EOF, LF required`, str.substring(line_start, str.length), sp));
|
|
1861
|
+
return atom.resync(args);
|
|
1832
1862
|
}
|
|
1833
|
-
|
|
1834
|
-
|
|
1835
|
-
}
|
|
1836
|
-
|
|
1863
|
+
};
|
|
1864
|
+
Reflect.defineProperty(descr2.value, 'name', { value: orig.name + ' ' });
|
|
1865
|
+
Reflect.defineProperty(descr2.value, 'length', { value: orig.length });
|
|
1866
|
+
Object.assign(descr2.value, { orig });
|
|
1867
|
+
Reflect.defineProperty(host, field, descr2);
|
|
1868
|
+
return descr2;
|
|
1837
1869
|
}
|
|
1838
|
-
$.$
|
|
1870
|
+
$.$mol_wire_solo = $mol_wire_solo;
|
|
1839
1871
|
})($ || ($ = {}));
|
|
1840
|
-
//mol/
|
|
1872
|
+
//mol/wire/solo/solo.ts
|
|
1841
1873
|
;
|
|
1842
1874
|
"use strict";
|
|
1843
1875
|
var $;
|
|
1844
1876
|
(function ($) {
|
|
1845
|
-
function $
|
|
1846
|
-
if (
|
|
1847
|
-
|
|
1848
|
-
|
|
1849
|
-
|
|
1850
|
-
|
|
1851
|
-
|
|
1852
|
-
if (Array.isArray(json)) {
|
|
1853
|
-
const sub = json.map(json => $mol_tree2_from_json(json, span));
|
|
1854
|
-
return new $mol_tree2('/', '', sub, span);
|
|
1855
|
-
}
|
|
1856
|
-
if (ArrayBuffer.isView(json)) {
|
|
1857
|
-
const buf = new Uint8Array(json.buffer, json.byteOffset, json.byteLength);
|
|
1858
|
-
return $mol_tree2.data(String.fromCharCode(...buf), [], span);
|
|
1859
|
-
}
|
|
1860
|
-
if (json instanceof Date) {
|
|
1861
|
-
return new $mol_tree2('', json.toISOString(), [], span);
|
|
1862
|
-
}
|
|
1863
|
-
if (typeof json.toJSON === 'function') {
|
|
1864
|
-
return $mol_tree2_from_json(json.toJSON());
|
|
1865
|
-
}
|
|
1866
|
-
if (json instanceof Error) {
|
|
1867
|
-
const { name, message, stack } = json;
|
|
1868
|
-
json = { ...json, name, message, stack };
|
|
1877
|
+
function $mol_wire_plex(host, field, descr) {
|
|
1878
|
+
if (!descr)
|
|
1879
|
+
descr = Reflect.getOwnPropertyDescriptor(host, field);
|
|
1880
|
+
const orig = descr?.value ?? host[field];
|
|
1881
|
+
const sup = Reflect.getPrototypeOf(host);
|
|
1882
|
+
if (typeof sup[field] === 'function') {
|
|
1883
|
+
Object.defineProperty(orig, 'name', { value: sup[field].name });
|
|
1869
1884
|
}
|
|
1870
|
-
const
|
|
1871
|
-
|
|
1872
|
-
|
|
1873
|
-
|
|
1874
|
-
|
|
1875
|
-
|
|
1876
|
-
|
|
1877
|
-
|
|
1878
|
-
|
|
1879
|
-
|
|
1880
|
-
|
|
1885
|
+
const descr2 = {
|
|
1886
|
+
...descr,
|
|
1887
|
+
value: function (...args) {
|
|
1888
|
+
let atom = $mol_wire_atom.plex(this, orig, args[0]);
|
|
1889
|
+
if ((args.length === 1) || (args[1] === undefined)) {
|
|
1890
|
+
if (!$mol_wire_fiber.warm)
|
|
1891
|
+
return atom.result();
|
|
1892
|
+
if ($mol_wire_auto()?.temp) {
|
|
1893
|
+
return atom.once();
|
|
1894
|
+
}
|
|
1895
|
+
else {
|
|
1896
|
+
return atom.sync();
|
|
1897
|
+
}
|
|
1898
|
+
}
|
|
1899
|
+
return atom.resync(args);
|
|
1881
1900
|
}
|
|
1882
|
-
}
|
|
1883
|
-
|
|
1901
|
+
};
|
|
1902
|
+
Reflect.defineProperty(descr2.value, 'name', { value: orig.name + ' ' });
|
|
1903
|
+
Reflect.defineProperty(descr2.value, 'length', { value: orig.length });
|
|
1904
|
+
Object.assign(descr2.value, { orig });
|
|
1905
|
+
Reflect.defineProperty(host, field, descr2);
|
|
1906
|
+
return descr2;
|
|
1884
1907
|
}
|
|
1885
|
-
$.$
|
|
1908
|
+
$.$mol_wire_plex = $mol_wire_plex;
|
|
1886
1909
|
})($ || ($ = {}));
|
|
1887
|
-
//mol/
|
|
1910
|
+
//mol/wire/plex/plex.ts
|
|
1888
1911
|
;
|
|
1889
1912
|
"use strict";
|
|
1890
1913
|
var $;
|
|
1891
1914
|
(function ($) {
|
|
1892
|
-
|
|
1893
|
-
|
|
1894
|
-
static bold = this.ansi(1, 22);
|
|
1895
|
-
static italic = this.ansi(3, 23);
|
|
1896
|
-
static underline = this.ansi(4, 24);
|
|
1897
|
-
static inverse = this.ansi(7, 27);
|
|
1898
|
-
static hidden = this.ansi(8, 28);
|
|
1899
|
-
static strike = this.ansi(9, 29);
|
|
1900
|
-
static gray = this.ansi(90, 39);
|
|
1901
|
-
static red = this.ansi(91, 39);
|
|
1902
|
-
static green = this.ansi(92, 39);
|
|
1903
|
-
static yellow = this.ansi(93, 39);
|
|
1904
|
-
static blue = this.ansi(94, 39);
|
|
1905
|
-
static magenta = this.ansi(95, 39);
|
|
1906
|
-
static cyan = this.ansi(96, 39);
|
|
1907
|
-
static Gray = (str) => this.inverse(this.gray(str));
|
|
1908
|
-
static Red = (str) => this.inverse(this.red(str));
|
|
1909
|
-
static Green = (str) => this.inverse(this.green(str));
|
|
1910
|
-
static Yellow = (str) => this.inverse(this.yellow(str));
|
|
1911
|
-
static Blue = (str) => this.inverse(this.blue(str));
|
|
1912
|
-
static Magenta = (str) => this.inverse(this.magenta(str));
|
|
1913
|
-
static Cyan = (str) => this.inverse(this.cyan(str));
|
|
1914
|
-
static ansi(open, close) {
|
|
1915
|
-
if (typeof process === 'undefined')
|
|
1916
|
-
return String;
|
|
1917
|
-
if (!process.stdout.isTTY)
|
|
1918
|
-
return String;
|
|
1919
|
-
const prefix = `\x1b[${open}m`;
|
|
1920
|
-
const postfix = `\x1b[${close}m`;
|
|
1921
|
-
const suffix_regexp = new RegExp(postfix.replace('[', '\\['), 'g');
|
|
1922
|
-
return function colorer(str) {
|
|
1923
|
-
str = String(str);
|
|
1924
|
-
if (str === '')
|
|
1925
|
-
return str;
|
|
1926
|
-
const suffix = str.replace(suffix_regexp, prefix);
|
|
1927
|
-
return prefix + suffix + postfix;
|
|
1928
|
-
};
|
|
1929
|
-
}
|
|
1930
|
-
}
|
|
1931
|
-
$.$mol_term_color = $mol_term_color;
|
|
1915
|
+
$.$mol_mem = $mol_wire_solo;
|
|
1916
|
+
$.$mol_mem_key = $mol_wire_plex;
|
|
1932
1917
|
})($ || ($ = {}));
|
|
1933
|
-
//mol/
|
|
1918
|
+
//mol/mem/mem.ts
|
|
1934
1919
|
;
|
|
1935
1920
|
"use strict";
|
|
1936
1921
|
var $;
|
|
1937
1922
|
(function ($) {
|
|
1938
|
-
function $mol_log3_node_make(level, output, type, color) {
|
|
1939
|
-
return function $mol_log3_logger(event) {
|
|
1940
|
-
if (!event.time)
|
|
1941
|
-
event = { time: new Date().toISOString(), ...event };
|
|
1942
|
-
let tree = this.$mol_tree2_from_json(event);
|
|
1943
|
-
tree = tree.struct(type, tree.kids);
|
|
1944
|
-
let str = color(tree.toString());
|
|
1945
|
-
this.console[level](str);
|
|
1946
|
-
const self = this;
|
|
1947
|
-
return () => self.console.groupEnd();
|
|
1948
|
-
};
|
|
1949
|
-
}
|
|
1950
|
-
$.$mol_log3_node_make = $mol_log3_node_make;
|
|
1951
|
-
$.$mol_log3_come = $mol_log3_node_make('info', 'stdout', 'come', $mol_term_color.blue);
|
|
1952
|
-
$.$mol_log3_done = $mol_log3_node_make('info', 'stdout', 'done', $mol_term_color.green);
|
|
1953
|
-
$.$mol_log3_fail = $mol_log3_node_make('error', 'stderr', 'fail', $mol_term_color.red);
|
|
1954
|
-
$.$mol_log3_warn = $mol_log3_node_make('warn', 'stderr', 'warn', $mol_term_color.yellow);
|
|
1955
|
-
$.$mol_log3_rise = $mol_log3_node_make('log', 'stdout', 'rise', $mol_term_color.magenta);
|
|
1956
|
-
$.$mol_log3_area = $mol_log3_node_make('log', 'stdout', 'area', $mol_term_color.cyan);
|
|
1957
1923
|
})($ || ($ = {}));
|
|
1958
|
-
//mol/
|
|
1924
|
+
//mol/dom/context/context.ts
|
|
1925
|
+
;
|
|
1926
|
+
"use strict";
|
|
1927
|
+
//node/node.ts
|
|
1928
|
+
;
|
|
1929
|
+
"use strict";
|
|
1930
|
+
var $node = new Proxy({ require }, {
|
|
1931
|
+
get(target, name, wrapper) {
|
|
1932
|
+
if (target[name])
|
|
1933
|
+
return target[name];
|
|
1934
|
+
const mod = target.require('module');
|
|
1935
|
+
if (mod.builtinModules.indexOf(name) >= 0)
|
|
1936
|
+
return target.require(name);
|
|
1937
|
+
if (name[0] === '.')
|
|
1938
|
+
return target.require(name);
|
|
1939
|
+
const path = target.require('path');
|
|
1940
|
+
const fs = target.require('fs');
|
|
1941
|
+
let dir = path.resolve('.');
|
|
1942
|
+
const suffix = `./node_modules/${name}`;
|
|
1943
|
+
const $$ = $;
|
|
1944
|
+
while (!fs.existsSync(path.join(dir, suffix))) {
|
|
1945
|
+
const parent = path.resolve(dir, '..');
|
|
1946
|
+
if (parent === dir) {
|
|
1947
|
+
$$.$mol_exec('.', 'npm', 'install', '--omit=dev', name);
|
|
1948
|
+
try {
|
|
1949
|
+
$$.$mol_exec('.', 'npm', 'install', '--omit=dev', '@types/' + name);
|
|
1950
|
+
}
|
|
1951
|
+
catch { }
|
|
1952
|
+
break;
|
|
1953
|
+
}
|
|
1954
|
+
else {
|
|
1955
|
+
dir = parent;
|
|
1956
|
+
}
|
|
1957
|
+
}
|
|
1958
|
+
return target.require(name);
|
|
1959
|
+
},
|
|
1960
|
+
set(target, name, value) {
|
|
1961
|
+
target[name] = value;
|
|
1962
|
+
return true;
|
|
1963
|
+
},
|
|
1964
|
+
});
|
|
1965
|
+
require = (req => Object.assign(function require(name) {
|
|
1966
|
+
return $node[name];
|
|
1967
|
+
}, req))(require);
|
|
1968
|
+
//node/node.node.ts
|
|
1959
1969
|
;
|
|
1960
1970
|
"use strict";
|
|
1961
1971
|
var $;
|
|
@@ -7060,17 +7070,6 @@ var $;
|
|
|
7060
7070
|
;
|
|
7061
7071
|
"use strict";
|
|
7062
7072
|
var $;
|
|
7063
|
-
(function ($) {
|
|
7064
|
-
function $mol_dom_serialize(node) {
|
|
7065
|
-
const serializer = new $mol_dom_context.XMLSerializer;
|
|
7066
|
-
return serializer.serializeToString(node);
|
|
7067
|
-
}
|
|
7068
|
-
$.$mol_dom_serialize = $mol_dom_serialize;
|
|
7069
|
-
})($ || ($ = {}));
|
|
7070
|
-
//mol/dom/serialize/serialize.ts
|
|
7071
|
-
;
|
|
7072
|
-
"use strict";
|
|
7073
|
-
var $;
|
|
7074
7073
|
(function ($) {
|
|
7075
7074
|
function $mol_assert_ok(value) {
|
|
7076
7075
|
if (value)
|
|
@@ -7091,14 +7090,12 @@ var $;
|
|
|
7091
7090
|
handler();
|
|
7092
7091
|
}
|
|
7093
7092
|
catch (error) {
|
|
7094
|
-
if (!ErrorRight)
|
|
7095
|
-
return error;
|
|
7096
7093
|
$.$mol_fail = fail;
|
|
7097
7094
|
if (typeof ErrorRight === 'string') {
|
|
7098
7095
|
$mol_assert_equal(error.message, ErrorRight);
|
|
7099
7096
|
}
|
|
7100
7097
|
else {
|
|
7101
|
-
$
|
|
7098
|
+
$mol_assert_equal(error instanceof ErrorRight, true);
|
|
7102
7099
|
}
|
|
7103
7100
|
return error;
|
|
7104
7101
|
}
|
|
@@ -7108,58 +7105,47 @@ var $;
|
|
|
7108
7105
|
$mol_fail(new Error('Not failed'));
|
|
7109
7106
|
}
|
|
7110
7107
|
$.$mol_assert_fail = $mol_assert_fail;
|
|
7111
|
-
function $
|
|
7112
|
-
|
|
7113
|
-
for (let j = 0; j < args.length; ++j) {
|
|
7114
|
-
if (i === j)
|
|
7115
|
-
continue;
|
|
7116
|
-
if (Number.isNaN(args[i]) && Number.isNaN(args[j]))
|
|
7117
|
-
continue;
|
|
7118
|
-
if (args[i] !== args[j])
|
|
7119
|
-
$mol_fail(new Error(`Not equal (${i + 1}:${j + 1})\n${args[i]}\n${args[j]}`));
|
|
7120
|
-
}
|
|
7121
|
-
}
|
|
7108
|
+
function $mol_assert_like(...args) {
|
|
7109
|
+
$mol_assert_equal(...args);
|
|
7122
7110
|
}
|
|
7123
|
-
$.$
|
|
7111
|
+
$.$mol_assert_like = $mol_assert_like;
|
|
7124
7112
|
function $mol_assert_unique(...args) {
|
|
7125
7113
|
for (let i = 0; i < args.length; ++i) {
|
|
7126
7114
|
for (let j = 0; j < args.length; ++j) {
|
|
7127
7115
|
if (i === j)
|
|
7128
7116
|
continue;
|
|
7129
|
-
if (
|
|
7130
|
-
|
|
7131
|
-
}
|
|
7117
|
+
if (!$mol_compare_deep(args[i], args[j]))
|
|
7118
|
+
continue;
|
|
7119
|
+
$mol_fail(new Error(`args[${i}] = args[${j}] = ${args[i]}`));
|
|
7132
7120
|
}
|
|
7133
7121
|
}
|
|
7134
7122
|
}
|
|
7135
7123
|
$.$mol_assert_unique = $mol_assert_unique;
|
|
7136
|
-
function $
|
|
7137
|
-
for (let
|
|
7138
|
-
if (
|
|
7139
|
-
|
|
7140
|
-
|
|
7141
|
-
|
|
7142
|
-
|
|
7143
|
-
return val;
|
|
7144
|
-
if ('outerHTML' in val)
|
|
7145
|
-
return val.outerHTML;
|
|
7146
|
-
try {
|
|
7147
|
-
return JSON.stringify(val, (k, v) => typeof v === 'bigint' ? String(v) : v, '\t');
|
|
7148
|
-
}
|
|
7149
|
-
catch (error) {
|
|
7150
|
-
console.error(error);
|
|
7151
|
-
return val;
|
|
7152
|
-
}
|
|
7153
|
-
};
|
|
7154
|
-
return $mol_fail(new Error(`Not like (1:${+index + 2})\n${print(head)}\n---\n${print(value)}`));
|
|
7155
|
-
}
|
|
7124
|
+
function $mol_assert_equal(...args) {
|
|
7125
|
+
for (let i = 1; i < args.length; ++i) {
|
|
7126
|
+
if ($mol_compare_deep(args[0], args[i]))
|
|
7127
|
+
continue;
|
|
7128
|
+
if (args[0] instanceof Element && args[i] instanceof Element && args[0].outerHTML === args[i].outerHTML)
|
|
7129
|
+
continue;
|
|
7130
|
+
return $mol_fail(new Error(`args[0] ≠ args[${i}]\n${print(args[0])}\n---\n${print(args[i])}`));
|
|
7156
7131
|
}
|
|
7157
7132
|
}
|
|
7158
|
-
$.$
|
|
7159
|
-
|
|
7160
|
-
|
|
7161
|
-
|
|
7162
|
-
|
|
7133
|
+
$.$mol_assert_equal = $mol_assert_equal;
|
|
7134
|
+
const print = (val) => {
|
|
7135
|
+
if (!val)
|
|
7136
|
+
return val;
|
|
7137
|
+
if (typeof val !== 'object')
|
|
7138
|
+
return val;
|
|
7139
|
+
if ('outerHTML' in val)
|
|
7140
|
+
return val.outerHTML;
|
|
7141
|
+
try {
|
|
7142
|
+
return JSON.stringify(val, (k, v) => typeof v === 'bigint' ? String(v) : v, '\t');
|
|
7143
|
+
}
|
|
7144
|
+
catch (error) {
|
|
7145
|
+
console.error(error);
|
|
7146
|
+
return val;
|
|
7147
|
+
}
|
|
7148
|
+
};
|
|
7163
7149
|
})($ || ($ = {}));
|
|
7164
7150
|
//mol/assert/assert.ts
|
|
7165
7151
|
;
|
|
@@ -7180,10 +7166,10 @@ var $;
|
|
|
7180
7166
|
$mol_assert_equal(2, 2, 2);
|
|
7181
7167
|
},
|
|
7182
7168
|
'two must be unique'() {
|
|
7183
|
-
$mol_assert_unique([
|
|
7169
|
+
$mol_assert_unique([2], [3]);
|
|
7184
7170
|
},
|
|
7185
7171
|
'three must be unique'() {
|
|
7186
|
-
$mol_assert_unique([
|
|
7172
|
+
$mol_assert_unique([1], [2], [3]);
|
|
7187
7173
|
},
|
|
7188
7174
|
'two must be alike'() {
|
|
7189
7175
|
$mol_assert_like([3], [3]);
|
|
@@ -7956,7 +7942,7 @@ var $;
|
|
|
7956
7942
|
], App, "result", null);
|
|
7957
7943
|
$mol_assert_equal(App.result(), 1);
|
|
7958
7944
|
App.condition(true);
|
|
7959
|
-
$mol_assert_fail(() => App.result());
|
|
7945
|
+
$mol_assert_fail(() => App.result(), 'test error');
|
|
7960
7946
|
App.condition(false);
|
|
7961
7947
|
$mol_assert_equal(App.result(), 1);
|
|
7962
7948
|
},
|
|
@@ -8895,14 +8881,14 @@ var $;
|
|
|
8895
8881
|
},
|
|
8896
8882
|
'slice span - out of range'($) {
|
|
8897
8883
|
const span = new $mol_span('test.ts', '', 1, 3, 5);
|
|
8898
|
-
$mol_assert_fail(() => span.slice(-1, 3));
|
|
8899
|
-
$mol_assert_fail(() => span.slice(1, 6));
|
|
8900
|
-
$mol_assert_fail(() => span.slice(1, 10));
|
|
8884
|
+
$mol_assert_fail(() => span.slice(-1, 3), `End value '3' can't be less than begin value (test.ts#1:3/5)`);
|
|
8885
|
+
$mol_assert_fail(() => span.slice(1, 6), `End value '6' out of range (test.ts#1:3/5)`);
|
|
8886
|
+
$mol_assert_fail(() => span.slice(1, 10), `End value '10' out of range (test.ts#1:3/5)`);
|
|
8901
8887
|
},
|
|
8902
8888
|
'error handling'($) {
|
|
8903
8889
|
const span = new $mol_span('test.ts', '', 1, 3, 4);
|
|
8904
|
-
const error = span.error('Some error
|
|
8905
|
-
$mol_assert_equal(error.message, 'Some error
|
|
8890
|
+
const error = span.error('Some error');
|
|
8891
|
+
$mol_assert_equal(error.message, 'Some error (test.ts#1:3/4)');
|
|
8906
8892
|
}
|
|
8907
8893
|
});
|
|
8908
8894
|
})($ || ($ = {}));
|
|
@@ -9977,279 +9963,6 @@ var $;
|
|
|
9977
9963
|
//mol/file/file.node.ts
|
|
9978
9964
|
;
|
|
9979
9965
|
"use strict";
|
|
9980
|
-
//hyoo/hyoo.ts
|
|
9981
|
-
;
|
|
9982
|
-
"use strict";
|
|
9983
|
-
var $;
|
|
9984
|
-
(function ($) {
|
|
9985
|
-
$.$mol_action = $mol_wire_method;
|
|
9986
|
-
})($ || ($ = {}));
|
|
9987
|
-
//mol/action/action.ts
|
|
9988
|
-
;
|
|
9989
|
-
"use strict";
|
|
9990
|
-
var $;
|
|
9991
|
-
(function ($) {
|
|
9992
|
-
function $mol_dom_parse(text, type = 'application/xhtml+xml') {
|
|
9993
|
-
const parser = new $mol_dom_context.DOMParser();
|
|
9994
|
-
const doc = parser.parseFromString(text, type);
|
|
9995
|
-
const error = doc.getElementsByTagName('parsererror');
|
|
9996
|
-
if (error.length)
|
|
9997
|
-
throw new Error(error[0].textContent);
|
|
9998
|
-
return doc;
|
|
9999
|
-
}
|
|
10000
|
-
$.$mol_dom_parse = $mol_dom_parse;
|
|
10001
|
-
})($ || ($ = {}));
|
|
10002
|
-
//mol/dom/parse/parse.ts
|
|
10003
|
-
;
|
|
10004
|
-
"use strict";
|
|
10005
|
-
var $;
|
|
10006
|
-
(function ($) {
|
|
10007
|
-
class $mol_fetch_response extends $mol_object2 {
|
|
10008
|
-
native;
|
|
10009
|
-
constructor(native) {
|
|
10010
|
-
super();
|
|
10011
|
-
this.native = native;
|
|
10012
|
-
}
|
|
10013
|
-
status() {
|
|
10014
|
-
const types = ['unknown', 'inform', 'success', 'redirect', 'wrong', 'failed'];
|
|
10015
|
-
return types[Math.floor(this.native.status / 100)];
|
|
10016
|
-
}
|
|
10017
|
-
code() {
|
|
10018
|
-
return this.native.status;
|
|
10019
|
-
}
|
|
10020
|
-
message() {
|
|
10021
|
-
return this.native.statusText || `HTTP Error ${this.code()}`;
|
|
10022
|
-
}
|
|
10023
|
-
headers() {
|
|
10024
|
-
return this.native.headers;
|
|
10025
|
-
}
|
|
10026
|
-
mime() {
|
|
10027
|
-
return this.headers().get('content-type');
|
|
10028
|
-
}
|
|
10029
|
-
stream() {
|
|
10030
|
-
return this.native.body;
|
|
10031
|
-
}
|
|
10032
|
-
text() {
|
|
10033
|
-
const buffer = this.buffer();
|
|
10034
|
-
const native = this.native;
|
|
10035
|
-
const mime = native.headers.get('content-type') || '';
|
|
10036
|
-
const [, charset] = /charset=(.*)/.exec(mime) || [, 'utf-8'];
|
|
10037
|
-
const decoder = new TextDecoder(charset);
|
|
10038
|
-
return decoder.decode(buffer);
|
|
10039
|
-
}
|
|
10040
|
-
json() {
|
|
10041
|
-
return $mol_wire_sync(this.native).json();
|
|
10042
|
-
}
|
|
10043
|
-
buffer() {
|
|
10044
|
-
return $mol_wire_sync(this.native).arrayBuffer();
|
|
10045
|
-
}
|
|
10046
|
-
xml() {
|
|
10047
|
-
return $mol_dom_parse(this.text(), 'application/xml');
|
|
10048
|
-
}
|
|
10049
|
-
xhtml() {
|
|
10050
|
-
return $mol_dom_parse(this.text(), 'application/xhtml+xml');
|
|
10051
|
-
}
|
|
10052
|
-
html() {
|
|
10053
|
-
return $mol_dom_parse(this.text(), 'text/html');
|
|
10054
|
-
}
|
|
10055
|
-
}
|
|
10056
|
-
__decorate([
|
|
10057
|
-
$mol_action
|
|
10058
|
-
], $mol_fetch_response.prototype, "stream", null);
|
|
10059
|
-
__decorate([
|
|
10060
|
-
$mol_action
|
|
10061
|
-
], $mol_fetch_response.prototype, "text", null);
|
|
10062
|
-
__decorate([
|
|
10063
|
-
$mol_action
|
|
10064
|
-
], $mol_fetch_response.prototype, "buffer", null);
|
|
10065
|
-
__decorate([
|
|
10066
|
-
$mol_action
|
|
10067
|
-
], $mol_fetch_response.prototype, "xml", null);
|
|
10068
|
-
__decorate([
|
|
10069
|
-
$mol_action
|
|
10070
|
-
], $mol_fetch_response.prototype, "xhtml", null);
|
|
10071
|
-
__decorate([
|
|
10072
|
-
$mol_action
|
|
10073
|
-
], $mol_fetch_response.prototype, "html", null);
|
|
10074
|
-
$.$mol_fetch_response = $mol_fetch_response;
|
|
10075
|
-
class $mol_fetch extends $mol_object2 {
|
|
10076
|
-
static request(input, init = {}) {
|
|
10077
|
-
const native = globalThis.fetch ?? $node['undici'].fetch;
|
|
10078
|
-
const controller = new AbortController();
|
|
10079
|
-
let done = false;
|
|
10080
|
-
const promise = native(input, {
|
|
10081
|
-
...init,
|
|
10082
|
-
signal: controller.signal,
|
|
10083
|
-
}).finally(() => {
|
|
10084
|
-
done = true;
|
|
10085
|
-
});
|
|
10086
|
-
return Object.assign(promise, {
|
|
10087
|
-
destructor: () => {
|
|
10088
|
-
if (!done && !controller.signal.aborted)
|
|
10089
|
-
controller.abort();
|
|
10090
|
-
},
|
|
10091
|
-
});
|
|
10092
|
-
}
|
|
10093
|
-
static response(input, init) {
|
|
10094
|
-
return new $mol_fetch_response($mol_wire_sync(this).request(input, init));
|
|
10095
|
-
}
|
|
10096
|
-
static success(input, init) {
|
|
10097
|
-
const response = this.response(input, init);
|
|
10098
|
-
if (response.status() === 'success')
|
|
10099
|
-
return response;
|
|
10100
|
-
throw new Error(response.message());
|
|
10101
|
-
}
|
|
10102
|
-
static stream(input, init) {
|
|
10103
|
-
return this.success(input, init).stream();
|
|
10104
|
-
}
|
|
10105
|
-
static text(input, init) {
|
|
10106
|
-
return this.success(input, init).text();
|
|
10107
|
-
}
|
|
10108
|
-
static json(input, init) {
|
|
10109
|
-
return this.success(input, init).json();
|
|
10110
|
-
}
|
|
10111
|
-
static buffer(input, init) {
|
|
10112
|
-
return this.success(input, init).buffer();
|
|
10113
|
-
}
|
|
10114
|
-
static xml(input, init) {
|
|
10115
|
-
return this.success(input, init).xml();
|
|
10116
|
-
}
|
|
10117
|
-
static xhtml(input, init) {
|
|
10118
|
-
return this.success(input, init).xhtml();
|
|
10119
|
-
}
|
|
10120
|
-
static html(input, init) {
|
|
10121
|
-
return this.success(input, init).html();
|
|
10122
|
-
}
|
|
10123
|
-
}
|
|
10124
|
-
__decorate([
|
|
10125
|
-
$mol_action
|
|
10126
|
-
], $mol_fetch, "response", null);
|
|
10127
|
-
__decorate([
|
|
10128
|
-
$mol_action
|
|
10129
|
-
], $mol_fetch, "success", null);
|
|
10130
|
-
__decorate([
|
|
10131
|
-
$mol_action
|
|
10132
|
-
], $mol_fetch, "stream", null);
|
|
10133
|
-
__decorate([
|
|
10134
|
-
$mol_action
|
|
10135
|
-
], $mol_fetch, "text", null);
|
|
10136
|
-
__decorate([
|
|
10137
|
-
$mol_action
|
|
10138
|
-
], $mol_fetch, "json", null);
|
|
10139
|
-
__decorate([
|
|
10140
|
-
$mol_action
|
|
10141
|
-
], $mol_fetch, "buffer", null);
|
|
10142
|
-
__decorate([
|
|
10143
|
-
$mol_action
|
|
10144
|
-
], $mol_fetch, "xml", null);
|
|
10145
|
-
__decorate([
|
|
10146
|
-
$mol_action
|
|
10147
|
-
], $mol_fetch, "xhtml", null);
|
|
10148
|
-
__decorate([
|
|
10149
|
-
$mol_action
|
|
10150
|
-
], $mol_fetch, "html", null);
|
|
10151
|
-
$.$mol_fetch = $mol_fetch;
|
|
10152
|
-
})($ || ($ = {}));
|
|
10153
|
-
//mol/fetch/fetch.ts
|
|
10154
|
-
;
|
|
10155
|
-
"use strict";
|
|
10156
|
-
var $;
|
|
10157
|
-
(function ($) {
|
|
10158
|
-
function $mol_huggingface_run(space, method, ...data) {
|
|
10159
|
-
while (true) {
|
|
10160
|
-
try {
|
|
10161
|
-
if (typeof method === 'number') {
|
|
10162
|
-
return $mol_wire_sync(this).$mol_huggingface_ws(space, method, ...data);
|
|
10163
|
-
}
|
|
10164
|
-
else {
|
|
10165
|
-
return this.$mol_huggingface_rest(space, method, ...data);
|
|
10166
|
-
}
|
|
10167
|
-
}
|
|
10168
|
-
catch (error) {
|
|
10169
|
-
if ($mol_promise_like(error))
|
|
10170
|
-
$mol_fail_hidden(error);
|
|
10171
|
-
if (error instanceof Error && error.message === `Queue full`) {
|
|
10172
|
-
$mol_fail_log(error);
|
|
10173
|
-
continue;
|
|
10174
|
-
}
|
|
10175
|
-
$mol_fail_hidden(error);
|
|
10176
|
-
}
|
|
10177
|
-
}
|
|
10178
|
-
}
|
|
10179
|
-
$.$mol_huggingface_run = $mol_huggingface_run;
|
|
10180
|
-
function $mol_huggingface_rest(space, method, ...data) {
|
|
10181
|
-
const uri = `https://${space}.hf.space/run/${method}`;
|
|
10182
|
-
const response = $mol_fetch.json(uri, {
|
|
10183
|
-
method: 'post',
|
|
10184
|
-
headers: { "Content-Type": "application/json" },
|
|
10185
|
-
body: JSON.stringify({ data }),
|
|
10186
|
-
});
|
|
10187
|
-
if ('error' in response) {
|
|
10188
|
-
$mol_fail(new Error(response.error ?? 'Unknown API error'));
|
|
10189
|
-
}
|
|
10190
|
-
return response.data;
|
|
10191
|
-
}
|
|
10192
|
-
$.$mol_huggingface_rest = $mol_huggingface_rest;
|
|
10193
|
-
function $mol_huggingface_ws(space, fn_index, ...data) {
|
|
10194
|
-
const session_hash = $mol_guid();
|
|
10195
|
-
const socket = new WebSocket(`wss://${space}.hf.space/queue/join`);
|
|
10196
|
-
const promise = new Promise((done, fail) => {
|
|
10197
|
-
socket.onclose = event => {
|
|
10198
|
-
if (event.reason)
|
|
10199
|
-
fail(new Error(event.reason));
|
|
10200
|
-
};
|
|
10201
|
-
socket.onerror = event => {
|
|
10202
|
-
fail(new Error(`Socket error`));
|
|
10203
|
-
};
|
|
10204
|
-
socket.onmessage = event => {
|
|
10205
|
-
const message = JSON.parse(event.data);
|
|
10206
|
-
switch (message.msg) {
|
|
10207
|
-
case 'send_hash':
|
|
10208
|
-
return socket.send(JSON.stringify({ session_hash, fn_index }));
|
|
10209
|
-
case 'estimation': return;
|
|
10210
|
-
case 'queue_full':
|
|
10211
|
-
fail(new Error(`Queue full`));
|
|
10212
|
-
case 'send_data':
|
|
10213
|
-
return socket.send(JSON.stringify({ session_hash, fn_index, data }));
|
|
10214
|
-
case 'process_starts': return;
|
|
10215
|
-
case 'process_completed':
|
|
10216
|
-
if (message.success) {
|
|
10217
|
-
return done(message.output.data);
|
|
10218
|
-
}
|
|
10219
|
-
else {
|
|
10220
|
-
return fail(new Error(message.output.error ?? `Unknown API error`));
|
|
10221
|
-
}
|
|
10222
|
-
default:
|
|
10223
|
-
return fail(new Error(`Unknown message type: ${message.msg}`));
|
|
10224
|
-
}
|
|
10225
|
-
};
|
|
10226
|
-
});
|
|
10227
|
-
return Object.assign(promise, {
|
|
10228
|
-
destructor: () => socket.close()
|
|
10229
|
-
});
|
|
10230
|
-
}
|
|
10231
|
-
$.$mol_huggingface_ws = $mol_huggingface_ws;
|
|
10232
|
-
})($ || ($ = {}));
|
|
10233
|
-
//mol/huggingface/huggingface.ts
|
|
10234
|
-
;
|
|
10235
|
-
"use strict";
|
|
10236
|
-
var $;
|
|
10237
|
-
(function ($) {
|
|
10238
|
-
function $hyoo_lingua_translate(lang, text) {
|
|
10239
|
-
if (!text.trim())
|
|
10240
|
-
return '';
|
|
10241
|
-
const cache_key = `$hyoo_lingua_translate(${JSON.stringify(lang)},${JSON.stringify(text)})`;
|
|
10242
|
-
const cached = this.$mol_state_local.value(cache_key);
|
|
10243
|
-
if (cached)
|
|
10244
|
-
return String(cached);
|
|
10245
|
-
const translated = this.$mol_huggingface_run('hyoo-translate', 0, lang, text)[0];
|
|
10246
|
-
return this.$mol_state_local.value(cache_key, translated);
|
|
10247
|
-
}
|
|
10248
|
-
$.$hyoo_lingua_translate = $hyoo_lingua_translate;
|
|
10249
|
-
})($ || ($ = {}));
|
|
10250
|
-
//hyoo/lingua/translate/translate.ts
|
|
10251
|
-
;
|
|
10252
|
-
"use strict";
|
|
10253
9966
|
var $;
|
|
10254
9967
|
(function ($) {
|
|
10255
9968
|
class $mol_locale extends $mol_object {
|
|
@@ -10286,12 +9999,6 @@ var $;
|
|
|
10286
9999
|
const en = this.texts('en')[key];
|
|
10287
10000
|
if (!en)
|
|
10288
10001
|
return key;
|
|
10289
|
-
try {
|
|
10290
|
-
return $mol_wire_sync($hyoo_lingua_translate).call(this.$, lang, en);
|
|
10291
|
-
}
|
|
10292
|
-
catch (error) {
|
|
10293
|
-
$mol_fail_log(error);
|
|
10294
|
-
}
|
|
10295
10002
|
return en;
|
|
10296
10003
|
}
|
|
10297
10004
|
static warn(key) {
|