mol_jsx_lib 0.0.840 → 0.0.842
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/node.d.ts +195 -196
- package/node.d.ts.map +1 -1
- package/node.deps.json +1 -1
- package/node.js +1270 -1268
- package/node.js.map +1 -1
- package/node.mjs +1270 -1268
- package/node.test.js +1846 -1844
- package/node.test.js.map +1 -1
- package/package.json +17 -17
package/node.mjs
CHANGED
|
@@ -51,341 +51,131 @@ var $;
|
|
|
51
51
|
"use strict";
|
|
52
52
|
var $;
|
|
53
53
|
(function ($) {
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
$mol_wire_cursor[$mol_wire_cursor["fresh"] = -3] = "fresh";
|
|
59
|
-
$mol_wire_cursor[$mol_wire_cursor["final"] = -4] = "final";
|
|
60
|
-
})($mol_wire_cursor = $.$mol_wire_cursor || ($.$mol_wire_cursor = {}));
|
|
54
|
+
function $mol_promise_like(val) {
|
|
55
|
+
return val && typeof val === 'object' && 'then' in val && typeof val.then === 'function';
|
|
56
|
+
}
|
|
57
|
+
$.$mol_promise_like = $mol_promise_like;
|
|
61
58
|
})($ || ($ = {}));
|
|
62
59
|
|
|
63
60
|
;
|
|
64
61
|
"use strict";
|
|
65
62
|
var $;
|
|
66
63
|
(function ($) {
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
static get [Symbol.species]() {
|
|
70
|
-
return Array;
|
|
71
|
-
}
|
|
72
|
-
sub_from = 0;
|
|
73
|
-
get sub_list() {
|
|
74
|
-
const res = [];
|
|
75
|
-
for (let i = this.sub_from; i < this.data.length; i += 2) {
|
|
76
|
-
res.push(this.data[i]);
|
|
77
|
-
}
|
|
78
|
-
return res;
|
|
79
|
-
}
|
|
80
|
-
get sub_empty() {
|
|
81
|
-
return this.sub_from === this.data.length;
|
|
82
|
-
}
|
|
83
|
-
sub_on(sub, pub_pos) {
|
|
84
|
-
const pos = this.data.length;
|
|
85
|
-
this.data.push(sub, pub_pos);
|
|
86
|
-
return pos;
|
|
87
|
-
}
|
|
88
|
-
sub_off(sub_pos) {
|
|
89
|
-
if (!(sub_pos < this.data.length)) {
|
|
90
|
-
$mol_fail(new Error(`Wrong pos ${sub_pos}`));
|
|
91
|
-
}
|
|
92
|
-
const end = this.data.length - 2;
|
|
93
|
-
if (sub_pos !== end) {
|
|
94
|
-
this.peer_move(end, sub_pos);
|
|
95
|
-
}
|
|
96
|
-
this.data.pop();
|
|
97
|
-
this.data.pop();
|
|
98
|
-
if (this.data.length === this.sub_from)
|
|
99
|
-
this.reap();
|
|
100
|
-
}
|
|
101
|
-
reap() { }
|
|
102
|
-
promote() {
|
|
103
|
-
$mol_wire_auto()?.track_next(this);
|
|
104
|
-
}
|
|
105
|
-
fresh() { }
|
|
106
|
-
complete() { }
|
|
107
|
-
get incompleted() {
|
|
108
|
-
return false;
|
|
109
|
-
}
|
|
110
|
-
emit(quant = $mol_wire_cursor.stale) {
|
|
111
|
-
for (let i = this.sub_from; i < this.data.length; i += 2) {
|
|
112
|
-
;
|
|
113
|
-
this.data[i].absorb(quant);
|
|
114
|
-
}
|
|
115
|
-
}
|
|
116
|
-
peer_move(from_pos, to_pos) {
|
|
117
|
-
const peer = this.data[from_pos];
|
|
118
|
-
const self_pos = this.data[from_pos + 1];
|
|
119
|
-
this.data[to_pos] = peer;
|
|
120
|
-
this.data[to_pos + 1] = self_pos;
|
|
121
|
-
peer.peer_repos(self_pos, to_pos);
|
|
122
|
-
}
|
|
123
|
-
peer_repos(peer_pos, self_pos) {
|
|
124
|
-
this.data[peer_pos + 1] = self_pos;
|
|
125
|
-
}
|
|
64
|
+
function $mol_fail_hidden(error) {
|
|
65
|
+
throw error;
|
|
126
66
|
}
|
|
127
|
-
$.$
|
|
67
|
+
$.$mol_fail_hidden = $mol_fail_hidden;
|
|
128
68
|
})($ || ($ = {}));
|
|
129
69
|
|
|
130
|
-
;
|
|
131
|
-
"use strict";
|
|
132
|
-
|
|
133
70
|
;
|
|
134
71
|
"use strict";
|
|
135
72
|
var $;
|
|
136
73
|
(function ($) {
|
|
137
|
-
|
|
138
|
-
function $
|
|
139
|
-
|
|
74
|
+
const catched = new WeakMap();
|
|
75
|
+
function $mol_fail_catch(error) {
|
|
76
|
+
if (typeof error !== 'object')
|
|
77
|
+
return false;
|
|
78
|
+
if ($mol_promise_like(error))
|
|
79
|
+
$mol_fail_hidden(error);
|
|
80
|
+
if (catched.get(error))
|
|
81
|
+
return false;
|
|
82
|
+
catched.set(error, true);
|
|
83
|
+
return true;
|
|
140
84
|
}
|
|
141
|
-
$.$
|
|
142
|
-
$.$mol_wire_affected = [];
|
|
85
|
+
$.$mol_fail_catch = $mol_fail_catch;
|
|
143
86
|
})($ || ($ = {}));
|
|
144
87
|
|
|
145
88
|
;
|
|
146
89
|
"use strict";
|
|
147
90
|
var $;
|
|
148
91
|
(function ($) {
|
|
149
|
-
$
|
|
150
|
-
|
|
151
|
-
|
|
92
|
+
function $mol_fail_log(error) {
|
|
93
|
+
if ($mol_promise_like(error))
|
|
94
|
+
return false;
|
|
95
|
+
if (!$mol_fail_catch(error))
|
|
96
|
+
return false;
|
|
97
|
+
console.error(error);
|
|
98
|
+
return true;
|
|
152
99
|
}
|
|
153
|
-
$.$
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
100
|
+
$.$mol_fail_log = $mol_fail_log;
|
|
101
|
+
})($ || ($ = {}));
|
|
102
|
+
|
|
103
|
+
;
|
|
104
|
+
"use strict";
|
|
105
|
+
var $node = new Proxy({ require }, {
|
|
106
|
+
get(target, name, wrapper) {
|
|
107
|
+
if (target[name])
|
|
108
|
+
return target[name];
|
|
109
|
+
const mod = target.require('module');
|
|
110
|
+
if (mod.builtinModules.indexOf(name) >= 0)
|
|
111
|
+
return target.require(name);
|
|
112
|
+
if (name[0] === '.')
|
|
113
|
+
return target.require(name);
|
|
114
|
+
const path = target.require('path');
|
|
115
|
+
const fs = target.require('fs');
|
|
116
|
+
let dir = path.resolve('.');
|
|
117
|
+
const suffix = `./node_modules/${name}`;
|
|
118
|
+
const $$ = $;
|
|
119
|
+
while (!fs.existsSync(path.join(dir, suffix))) {
|
|
120
|
+
const parent = path.resolve(dir, '..');
|
|
121
|
+
if (parent === dir) {
|
|
122
|
+
$$.$mol_exec('.', 'npm', 'install', '--omit=dev', name);
|
|
163
123
|
try {
|
|
164
|
-
|
|
165
|
-
}
|
|
166
|
-
catch (error) {
|
|
167
|
-
return $.$mol_dev_format_accent($mol_dev_format_native(val), '💨', $mol_dev_format_native(error), '');
|
|
124
|
+
$$.$mol_exec('.', 'npm', 'install', '--omit=dev', '@types/' + name);
|
|
168
125
|
}
|
|
126
|
+
catch { }
|
|
127
|
+
break;
|
|
169
128
|
}
|
|
170
|
-
|
|
171
|
-
|
|
129
|
+
else {
|
|
130
|
+
dir = parent;
|
|
172
131
|
}
|
|
173
|
-
|
|
174
|
-
|
|
132
|
+
}
|
|
133
|
+
try {
|
|
134
|
+
return target.require(name);
|
|
135
|
+
}
|
|
136
|
+
catch (error) {
|
|
137
|
+
if (error.code === 'ERR_REQUIRE_ESM') {
|
|
138
|
+
const module = cache.get(name);
|
|
139
|
+
if (module)
|
|
140
|
+
return module;
|
|
141
|
+
throw import(name).then(module => cache.set(name, module));
|
|
175
142
|
}
|
|
143
|
+
$.$mol_fail_log(error);
|
|
176
144
|
return null;
|
|
177
|
-
}
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
function $
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
styles.push(`${key} : ${style[key]}`);
|
|
209
|
-
return [
|
|
210
|
-
element,
|
|
211
|
-
{
|
|
212
|
-
style: styles.join(' ; '),
|
|
213
|
-
},
|
|
214
|
-
...content,
|
|
215
|
-
];
|
|
216
|
-
}
|
|
217
|
-
$.$mol_dev_format_element = $mol_dev_format_element;
|
|
218
|
-
function $mol_dev_format_span(style, ...content) {
|
|
219
|
-
return $mol_dev_format_element('span', {
|
|
220
|
-
...style,
|
|
221
|
-
}, ...content);
|
|
145
|
+
}
|
|
146
|
+
},
|
|
147
|
+
set(target, name, value) {
|
|
148
|
+
target[name] = value;
|
|
149
|
+
return true;
|
|
150
|
+
},
|
|
151
|
+
});
|
|
152
|
+
const cache = new Map();
|
|
153
|
+
require = (req => Object.assign(function require(name) {
|
|
154
|
+
return $node[name];
|
|
155
|
+
}, req))(require);
|
|
156
|
+
|
|
157
|
+
;
|
|
158
|
+
"use strict";
|
|
159
|
+
var $;
|
|
160
|
+
(function ($) {
|
|
161
|
+
function $mol_log3_area_lazy(event) {
|
|
162
|
+
const self = this;
|
|
163
|
+
const stack = self.$mol_log3_stack;
|
|
164
|
+
const deep = stack.length;
|
|
165
|
+
let logged = false;
|
|
166
|
+
stack.push(() => {
|
|
167
|
+
logged = true;
|
|
168
|
+
self.$mol_log3_area.call(self, event);
|
|
169
|
+
});
|
|
170
|
+
return () => {
|
|
171
|
+
if (logged)
|
|
172
|
+
self.console.groupEnd();
|
|
173
|
+
if (stack.length > deep)
|
|
174
|
+
stack.length = deep;
|
|
175
|
+
};
|
|
222
176
|
}
|
|
223
|
-
$.$
|
|
224
|
-
$.$
|
|
225
|
-
$.$mol_dev_format_ol = $mol_dev_format_element.bind(null, 'ol');
|
|
226
|
-
$.$mol_dev_format_li = $mol_dev_format_element.bind(null, 'li');
|
|
227
|
-
$.$mol_dev_format_table = $mol_dev_format_element.bind(null, 'table');
|
|
228
|
-
$.$mol_dev_format_tr = $mol_dev_format_element.bind(null, 'tr');
|
|
229
|
-
$.$mol_dev_format_td = $mol_dev_format_element.bind(null, 'td');
|
|
230
|
-
$.$mol_dev_format_accent = $mol_dev_format_span.bind(null, {
|
|
231
|
-
'color': 'magenta',
|
|
232
|
-
});
|
|
233
|
-
$.$mol_dev_format_strong = $mol_dev_format_span.bind(null, {
|
|
234
|
-
'font-weight': 'bold',
|
|
235
|
-
});
|
|
236
|
-
$.$mol_dev_format_string = $mol_dev_format_span.bind(null, {
|
|
237
|
-
'color': 'green',
|
|
238
|
-
});
|
|
239
|
-
$.$mol_dev_format_shade = $mol_dev_format_span.bind(null, {
|
|
240
|
-
'color': 'gray',
|
|
241
|
-
});
|
|
242
|
-
$.$mol_dev_format_indent = $.$mol_dev_format_div.bind(null, {
|
|
243
|
-
'margin-left': '13px'
|
|
244
|
-
});
|
|
245
|
-
})($ || ($ = {}));
|
|
246
|
-
|
|
247
|
-
;
|
|
248
|
-
"use strict";
|
|
249
|
-
var $;
|
|
250
|
-
(function ($) {
|
|
251
|
-
class $mol_wire_pub_sub extends $mol_wire_pub {
|
|
252
|
-
pub_from = 0;
|
|
253
|
-
cursor = $mol_wire_cursor.stale;
|
|
254
|
-
get temp() {
|
|
255
|
-
return false;
|
|
256
|
-
}
|
|
257
|
-
get pub_list() {
|
|
258
|
-
const res = [];
|
|
259
|
-
const max = this.cursor >= 0 ? this.cursor : this.sub_from;
|
|
260
|
-
for (let i = this.pub_from; i < max; i += 2) {
|
|
261
|
-
if (this.data[i])
|
|
262
|
-
res.push(this.data[i]);
|
|
263
|
-
}
|
|
264
|
-
return res;
|
|
265
|
-
}
|
|
266
|
-
track_on() {
|
|
267
|
-
this.cursor = this.pub_from;
|
|
268
|
-
const sub = $mol_wire_auto();
|
|
269
|
-
$mol_wire_auto(this);
|
|
270
|
-
return sub;
|
|
271
|
-
}
|
|
272
|
-
promote() {
|
|
273
|
-
if (this.cursor >= this.pub_from) {
|
|
274
|
-
$mol_fail(new Error('Circular subscription'));
|
|
275
|
-
}
|
|
276
|
-
super.promote();
|
|
277
|
-
}
|
|
278
|
-
track_next(pub) {
|
|
279
|
-
if (this.cursor < 0)
|
|
280
|
-
$mol_fail(new Error('Promo to non begun sub'));
|
|
281
|
-
if (this.cursor < this.sub_from) {
|
|
282
|
-
const next = this.data[this.cursor];
|
|
283
|
-
if (pub === undefined)
|
|
284
|
-
return next ?? null;
|
|
285
|
-
if (next === pub) {
|
|
286
|
-
this.cursor += 2;
|
|
287
|
-
return next;
|
|
288
|
-
}
|
|
289
|
-
if (next) {
|
|
290
|
-
if (this.sub_from < this.data.length) {
|
|
291
|
-
this.peer_move(this.sub_from, this.data.length);
|
|
292
|
-
}
|
|
293
|
-
this.peer_move(this.cursor, this.sub_from);
|
|
294
|
-
this.sub_from += 2;
|
|
295
|
-
}
|
|
296
|
-
}
|
|
297
|
-
else {
|
|
298
|
-
if (pub === undefined)
|
|
299
|
-
return null;
|
|
300
|
-
if (this.sub_from < this.data.length) {
|
|
301
|
-
this.peer_move(this.sub_from, this.data.length);
|
|
302
|
-
}
|
|
303
|
-
this.sub_from += 2;
|
|
304
|
-
}
|
|
305
|
-
this.data[this.cursor] = pub;
|
|
306
|
-
this.data[this.cursor + 1] = pub.sub_on(this, this.cursor);
|
|
307
|
-
this.cursor += 2;
|
|
308
|
-
return pub;
|
|
309
|
-
}
|
|
310
|
-
track_off(sub) {
|
|
311
|
-
$mol_wire_auto(sub);
|
|
312
|
-
if (this.cursor < 0) {
|
|
313
|
-
$mol_fail(new Error('End of non begun sub'));
|
|
314
|
-
}
|
|
315
|
-
for (let cursor = this.pub_from; cursor < this.cursor; cursor += 2) {
|
|
316
|
-
const pub = this.data[cursor];
|
|
317
|
-
pub.fresh();
|
|
318
|
-
}
|
|
319
|
-
this.cursor = $mol_wire_cursor.fresh;
|
|
320
|
-
}
|
|
321
|
-
pub_off(sub_pos) {
|
|
322
|
-
this.data[sub_pos] = undefined;
|
|
323
|
-
this.data[sub_pos + 1] = undefined;
|
|
324
|
-
}
|
|
325
|
-
destructor() {
|
|
326
|
-
for (let cursor = this.data.length - 2; cursor >= this.sub_from; cursor -= 2) {
|
|
327
|
-
const sub = this.data[cursor];
|
|
328
|
-
const pos = this.data[cursor + 1];
|
|
329
|
-
sub.pub_off(pos);
|
|
330
|
-
this.data.pop();
|
|
331
|
-
this.data.pop();
|
|
332
|
-
}
|
|
333
|
-
this.cursor = this.pub_from;
|
|
334
|
-
this.track_cut();
|
|
335
|
-
this.cursor = $mol_wire_cursor.final;
|
|
336
|
-
}
|
|
337
|
-
track_cut() {
|
|
338
|
-
if (this.cursor < this.pub_from) {
|
|
339
|
-
$mol_fail(new Error('Cut of non begun sub'));
|
|
340
|
-
}
|
|
341
|
-
let tail = 0;
|
|
342
|
-
for (let cursor = this.cursor; cursor < this.sub_from; cursor += 2) {
|
|
343
|
-
const pub = this.data[cursor];
|
|
344
|
-
pub?.sub_off(this.data[cursor + 1]);
|
|
345
|
-
if (this.sub_from < this.data.length) {
|
|
346
|
-
this.peer_move(this.data.length - 2, cursor);
|
|
347
|
-
this.data.pop();
|
|
348
|
-
this.data.pop();
|
|
349
|
-
}
|
|
350
|
-
else {
|
|
351
|
-
++tail;
|
|
352
|
-
}
|
|
353
|
-
}
|
|
354
|
-
for (; tail; --tail) {
|
|
355
|
-
this.data.pop();
|
|
356
|
-
this.data.pop();
|
|
357
|
-
}
|
|
358
|
-
this.sub_from = this.cursor;
|
|
359
|
-
}
|
|
360
|
-
complete() { }
|
|
361
|
-
complete_pubs() {
|
|
362
|
-
const limit = this.cursor < 0 ? this.sub_from : this.cursor;
|
|
363
|
-
for (let cursor = this.pub_from; cursor < limit; cursor += 2) {
|
|
364
|
-
const pub = this.data[cursor];
|
|
365
|
-
if (pub?.incompleted)
|
|
366
|
-
return;
|
|
367
|
-
}
|
|
368
|
-
for (let cursor = this.pub_from; cursor < limit; cursor += 2) {
|
|
369
|
-
const pub = this.data[cursor];
|
|
370
|
-
pub?.complete();
|
|
371
|
-
}
|
|
372
|
-
}
|
|
373
|
-
absorb(quant = $mol_wire_cursor.stale) {
|
|
374
|
-
if (this.cursor === $mol_wire_cursor.final)
|
|
375
|
-
return;
|
|
376
|
-
if (this.cursor >= quant)
|
|
377
|
-
return;
|
|
378
|
-
this.cursor = quant;
|
|
379
|
-
this.emit($mol_wire_cursor.doubt);
|
|
380
|
-
}
|
|
381
|
-
[$mol_dev_format_head]() {
|
|
382
|
-
return $mol_dev_format_native(this);
|
|
383
|
-
}
|
|
384
|
-
get pub_empty() {
|
|
385
|
-
return this.sub_from === this.pub_from;
|
|
386
|
-
}
|
|
387
|
-
}
|
|
388
|
-
$.$mol_wire_pub_sub = $mol_wire_pub_sub;
|
|
177
|
+
$.$mol_log3_area_lazy = $mol_log3_area_lazy;
|
|
178
|
+
$.$mol_log3_stack = [];
|
|
389
179
|
})($ || ($ = {}));
|
|
390
180
|
|
|
391
181
|
;
|
|
@@ -492,16 +282,6 @@ var $;
|
|
|
492
282
|
$.$mol_owning_catch = $mol_owning_catch;
|
|
493
283
|
})($ || ($ = {}));
|
|
494
284
|
|
|
495
|
-
;
|
|
496
|
-
"use strict";
|
|
497
|
-
var $;
|
|
498
|
-
(function ($) {
|
|
499
|
-
function $mol_fail_hidden(error) {
|
|
500
|
-
throw error;
|
|
501
|
-
}
|
|
502
|
-
$.$mol_fail_hidden = $mol_fail_hidden;
|
|
503
|
-
})($ || ($ = {}));
|
|
504
|
-
|
|
505
285
|
;
|
|
506
286
|
"use strict";
|
|
507
287
|
|
|
@@ -584,850 +364,417 @@ var $;
|
|
|
584
364
|
"use strict";
|
|
585
365
|
var $;
|
|
586
366
|
(function ($) {
|
|
587
|
-
class $
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
367
|
+
class $mol_span extends $mol_object2 {
|
|
368
|
+
uri;
|
|
369
|
+
source;
|
|
370
|
+
row;
|
|
371
|
+
col;
|
|
372
|
+
length;
|
|
373
|
+
constructor(uri, source, row, col, length) {
|
|
592
374
|
super();
|
|
593
|
-
this.
|
|
594
|
-
this.
|
|
595
|
-
this.
|
|
375
|
+
this.uri = uri;
|
|
376
|
+
this.source = source;
|
|
377
|
+
this.row = row;
|
|
378
|
+
this.col = col;
|
|
379
|
+
this.length = length;
|
|
380
|
+
this[Symbol.toStringTag] = `${this.uri}#${this.row}:${this.col}/${this.length}`;
|
|
596
381
|
}
|
|
597
|
-
|
|
598
|
-
|
|
382
|
+
static unknown = $mol_span.begin('?');
|
|
383
|
+
static begin(uri, source = '') {
|
|
384
|
+
return new $mol_span(uri, source, 1, 1, 0);
|
|
385
|
+
}
|
|
386
|
+
static end(uri, source) {
|
|
387
|
+
return new $mol_span(uri, source, 1, source.length + 1, 0);
|
|
388
|
+
}
|
|
389
|
+
static entire(uri, source) {
|
|
390
|
+
return new $mol_span(uri, source, 1, 1, source.length);
|
|
391
|
+
}
|
|
392
|
+
toString() {
|
|
393
|
+
return this[Symbol.toStringTag];
|
|
394
|
+
}
|
|
395
|
+
toJSON() {
|
|
396
|
+
return {
|
|
397
|
+
uri: this.uri,
|
|
398
|
+
row: this.row,
|
|
399
|
+
col: this.col,
|
|
400
|
+
length: this.length
|
|
401
|
+
};
|
|
402
|
+
}
|
|
403
|
+
error(message, Class = Error) {
|
|
404
|
+
return new Class(`${message} (${this})`);
|
|
405
|
+
}
|
|
406
|
+
span(row, col, length) {
|
|
407
|
+
return new $mol_span(this.uri, this.source, row, col, length);
|
|
408
|
+
}
|
|
409
|
+
after(length = 0) {
|
|
410
|
+
return new $mol_span(this.uri, this.source, this.row, this.col + this.length, length);
|
|
411
|
+
}
|
|
412
|
+
slice(begin, end = -1) {
|
|
413
|
+
let len = this.length;
|
|
414
|
+
if (begin < 0)
|
|
415
|
+
begin += len;
|
|
416
|
+
if (end < 0)
|
|
417
|
+
end += len;
|
|
418
|
+
if (begin < 0 || begin > len)
|
|
419
|
+
this.$.$mol_fail(this.error(`Begin value '${begin}' out of range`, RangeError));
|
|
420
|
+
if (end < 0 || end > len)
|
|
421
|
+
this.$.$mol_fail(this.error(`End value '${end}' out of range`, RangeError));
|
|
422
|
+
if (end < begin)
|
|
423
|
+
this.$.$mol_fail(this.error(`End value '${end}' can't be less than begin value`, RangeError));
|
|
424
|
+
return this.span(this.row, this.col + begin, end - begin);
|
|
599
425
|
}
|
|
600
426
|
}
|
|
601
|
-
$.$
|
|
427
|
+
$.$mol_span = $mol_span;
|
|
602
428
|
})($ || ($ = {}));
|
|
603
429
|
|
|
604
430
|
;
|
|
605
431
|
"use strict";
|
|
606
432
|
var $;
|
|
607
433
|
(function ($) {
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
434
|
+
function $mol_tree2_to_string(tree) {
|
|
435
|
+
let output = [];
|
|
436
|
+
function dump(tree, prefix = '') {
|
|
437
|
+
if (tree.type.length) {
|
|
438
|
+
if (!prefix.length) {
|
|
439
|
+
prefix = "\t";
|
|
440
|
+
}
|
|
441
|
+
output.push(tree.type);
|
|
442
|
+
if (tree.kids.length == 1) {
|
|
443
|
+
output.push(' ');
|
|
444
|
+
dump(tree.kids[0], prefix);
|
|
445
|
+
return;
|
|
446
|
+
}
|
|
447
|
+
output.push("\n");
|
|
448
|
+
}
|
|
449
|
+
else if (tree.value.length || prefix.length) {
|
|
450
|
+
output.push("\\" + tree.value + "\n");
|
|
451
|
+
}
|
|
452
|
+
for (const kid of tree.kids) {
|
|
453
|
+
output.push(prefix);
|
|
454
|
+
dump(kid, prefix + "\t");
|
|
455
|
+
}
|
|
613
456
|
}
|
|
457
|
+
dump(tree);
|
|
458
|
+
return output.join('');
|
|
614
459
|
}
|
|
615
|
-
$.$
|
|
460
|
+
$.$mol_tree2_to_string = $mol_tree2_to_string;
|
|
616
461
|
})($ || ($ = {}));
|
|
617
462
|
|
|
618
463
|
;
|
|
619
464
|
"use strict";
|
|
620
465
|
var $;
|
|
621
466
|
(function ($) {
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
;
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
task;
|
|
635
|
-
host;
|
|
636
|
-
static warm = true;
|
|
637
|
-
static planning = new Set();
|
|
638
|
-
static reaping = new Set();
|
|
639
|
-
static plan_task = null;
|
|
640
|
-
static plan() {
|
|
641
|
-
if (this.plan_task)
|
|
642
|
-
return;
|
|
643
|
-
this.plan_task = new $mol_after_frame(() => {
|
|
644
|
-
try {
|
|
645
|
-
this.sync();
|
|
646
|
-
}
|
|
647
|
-
finally {
|
|
648
|
-
$mol_wire_fiber.plan_task = null;
|
|
649
|
-
}
|
|
650
|
-
});
|
|
651
|
-
}
|
|
652
|
-
static sync() {
|
|
653
|
-
while (this.planning.size) {
|
|
654
|
-
for (const fiber of this.planning) {
|
|
655
|
-
this.planning.delete(fiber);
|
|
656
|
-
if (fiber.cursor >= 0)
|
|
657
|
-
continue;
|
|
658
|
-
if (fiber.cursor === $mol_wire_cursor.final)
|
|
659
|
-
continue;
|
|
660
|
-
fiber.fresh();
|
|
661
|
-
}
|
|
662
|
-
}
|
|
663
|
-
while (this.reaping.size) {
|
|
664
|
-
const fibers = this.reaping;
|
|
665
|
-
this.reaping = new Set;
|
|
666
|
-
for (const fiber of fibers) {
|
|
667
|
-
if (!fiber.sub_empty)
|
|
668
|
-
continue;
|
|
669
|
-
fiber.destructor();
|
|
670
|
-
}
|
|
671
|
-
}
|
|
672
|
-
}
|
|
673
|
-
[Symbol.toStringTag];
|
|
674
|
-
cache = undefined;
|
|
675
|
-
get args() {
|
|
676
|
-
return this.data.slice(0, this.pub_from);
|
|
677
|
-
}
|
|
678
|
-
result() {
|
|
679
|
-
if ($mol_promise_like(this.cache))
|
|
680
|
-
return;
|
|
681
|
-
if (this.cache instanceof Error)
|
|
682
|
-
return;
|
|
683
|
-
return this.cache;
|
|
467
|
+
class $mol_tree2 extends Object {
|
|
468
|
+
type;
|
|
469
|
+
value;
|
|
470
|
+
kids;
|
|
471
|
+
span;
|
|
472
|
+
constructor(type, value, kids, span) {
|
|
473
|
+
super();
|
|
474
|
+
this.type = type;
|
|
475
|
+
this.value = value;
|
|
476
|
+
this.kids = kids;
|
|
477
|
+
this.span = span;
|
|
478
|
+
this[Symbol.toStringTag] = type || '\\' + value;
|
|
684
479
|
}
|
|
685
|
-
|
|
686
|
-
return $
|
|
480
|
+
static list(kids, span = $mol_span.unknown) {
|
|
481
|
+
return new $mol_tree2('', '', kids, span);
|
|
687
482
|
}
|
|
688
|
-
|
|
689
|
-
return this.
|
|
483
|
+
list(kids) {
|
|
484
|
+
return $mol_tree2.list(kids, this.span);
|
|
690
485
|
}
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
486
|
+
static data(value, kids = [], span = $mol_span.unknown) {
|
|
487
|
+
const chunks = value.split('\n');
|
|
488
|
+
if (chunks.length > 1) {
|
|
489
|
+
let kid_span = span.span(span.row, span.col, 0);
|
|
490
|
+
const data = chunks.map(chunk => {
|
|
491
|
+
kid_span = kid_span.after(chunk.length);
|
|
492
|
+
return new $mol_tree2('', chunk, [], kid_span);
|
|
493
|
+
});
|
|
494
|
+
kids = [...data, ...kids];
|
|
495
|
+
value = '';
|
|
496
|
+
}
|
|
497
|
+
return new $mol_tree2('', value, kids, span);
|
|
699
498
|
}
|
|
700
|
-
|
|
701
|
-
$
|
|
702
|
-
$mol_wire_fiber.plan();
|
|
499
|
+
data(value, kids = []) {
|
|
500
|
+
return $mol_tree2.data(value, kids, this.span);
|
|
703
501
|
}
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
502
|
+
static struct(type, kids = [], span = $mol_span.unknown) {
|
|
503
|
+
if (/[ \n\t\\]/.test(type)) {
|
|
504
|
+
$$.$mol_fail(span.error(`Wrong type ${JSON.stringify(type)}`));
|
|
505
|
+
}
|
|
506
|
+
return new $mol_tree2(type, '', kids, span);
|
|
707
507
|
}
|
|
708
|
-
|
|
709
|
-
return this
|
|
508
|
+
struct(type, kids = []) {
|
|
509
|
+
return $mol_tree2.struct(type, kids, this.span);
|
|
710
510
|
}
|
|
711
|
-
|
|
712
|
-
return this
|
|
511
|
+
clone(kids, span = this.span) {
|
|
512
|
+
return new $mol_tree2(this.type, this.value, kids, span);
|
|
713
513
|
}
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
}
|
|
721
|
-
return
|
|
722
|
-
? $mol_dev_format_auto({
|
|
723
|
-
[$mol_dev_format_head]: () => $mol_dev_format_shade(cursor),
|
|
724
|
-
[$mol_dev_format_body]: () => $mol_dev_format_native(this),
|
|
725
|
-
})
|
|
726
|
-
: $mol_dev_format_shade($mol_dev_format_native(this), cursor), $mol_dev_format_auto(this.cache));
|
|
514
|
+
text() {
|
|
515
|
+
var values = [];
|
|
516
|
+
for (var kid of this.kids) {
|
|
517
|
+
if (kid.type)
|
|
518
|
+
continue;
|
|
519
|
+
values.push(kid.value);
|
|
520
|
+
}
|
|
521
|
+
return this.value + values.join('\n');
|
|
727
522
|
}
|
|
728
|
-
|
|
729
|
-
return (
|
|
523
|
+
static fromString(str, uri = 'unknown') {
|
|
524
|
+
return $$.$mol_tree2_from_string(str, uri);
|
|
730
525
|
}
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
this.plan();
|
|
734
|
-
else
|
|
735
|
-
super.emit(quant);
|
|
526
|
+
toString() {
|
|
527
|
+
return $$.$mol_tree2_to_string(this);
|
|
736
528
|
}
|
|
737
|
-
|
|
738
|
-
if (
|
|
739
|
-
return;
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
529
|
+
insert(value, ...path) {
|
|
530
|
+
if (path.length === 0)
|
|
531
|
+
return value;
|
|
532
|
+
const type = path[0];
|
|
533
|
+
if (typeof type === 'string') {
|
|
534
|
+
let replaced = false;
|
|
535
|
+
const sub = this.kids.map((item, index) => {
|
|
536
|
+
if (item.type !== type)
|
|
537
|
+
return item;
|
|
538
|
+
replaced = true;
|
|
539
|
+
return item.insert(value, ...path.slice(1));
|
|
540
|
+
}).filter(Boolean);
|
|
541
|
+
if (!replaced && value) {
|
|
542
|
+
sub.push(this.struct(type, []).insert(value, ...path.slice(1)));
|
|
748
543
|
}
|
|
749
|
-
this.
|
|
750
|
-
return;
|
|
544
|
+
return this.clone(sub);
|
|
751
545
|
}
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
546
|
+
else if (typeof type === 'number') {
|
|
547
|
+
const sub = this.kids.slice();
|
|
548
|
+
sub[type] = (sub[type] || this.list([]))
|
|
549
|
+
.insert(value, ...path.slice(1));
|
|
550
|
+
return this.clone(sub.filter(Boolean));
|
|
551
|
+
}
|
|
552
|
+
else {
|
|
553
|
+
const kids = ((this.kids.length === 0) ? [this.list([])] : this.kids)
|
|
554
|
+
.map(item => item.insert(value, ...path.slice(1)))
|
|
555
|
+
.filter(Boolean);
|
|
556
|
+
return this.clone(kids);
|
|
557
|
+
}
|
|
558
|
+
}
|
|
559
|
+
select(...path) {
|
|
560
|
+
let next = [this];
|
|
561
|
+
for (const type of path) {
|
|
562
|
+
if (!next.length)
|
|
563
|
+
break;
|
|
564
|
+
const prev = next;
|
|
565
|
+
next = [];
|
|
566
|
+
for (var item of prev) {
|
|
567
|
+
switch (typeof (type)) {
|
|
568
|
+
case 'string':
|
|
569
|
+
for (var child of item.kids) {
|
|
570
|
+
if (child.type == type) {
|
|
571
|
+
next.push(child);
|
|
572
|
+
}
|
|
573
|
+
}
|
|
574
|
+
break;
|
|
575
|
+
case 'number':
|
|
576
|
+
if (type < item.kids.length)
|
|
577
|
+
next.push(item.kids[type]);
|
|
578
|
+
break;
|
|
579
|
+
default: next.push(...item.kids);
|
|
580
|
+
}
|
|
773
581
|
}
|
|
774
582
|
}
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
583
|
+
return this.list(next);
|
|
584
|
+
}
|
|
585
|
+
filter(path, value) {
|
|
586
|
+
const sub = this.kids.filter(item => {
|
|
587
|
+
var found = item.select(...path);
|
|
588
|
+
if (value === undefined) {
|
|
589
|
+
return Boolean(found.kids.length);
|
|
778
590
|
}
|
|
779
591
|
else {
|
|
780
|
-
|
|
781
|
-
}
|
|
782
|
-
if ($mol_promise_like(result) && !handled.has(result)) {
|
|
783
|
-
result = result.finally(() => {
|
|
784
|
-
if (this.cache === result)
|
|
785
|
-
this.absorb();
|
|
786
|
-
});
|
|
592
|
+
return found.kids.some(child => child.value == value);
|
|
787
593
|
}
|
|
788
|
-
}
|
|
789
|
-
|
|
790
|
-
result = Object.assign(result, {
|
|
791
|
-
destructor: result['destructor'] ?? (() => { })
|
|
792
|
-
});
|
|
793
|
-
handled.add(result);
|
|
794
|
-
const error = new Error(`Promise in ${this}`);
|
|
795
|
-
Object.defineProperty(result, 'stack', { get: () => error.stack });
|
|
796
|
-
}
|
|
797
|
-
if (!$mol_promise_like(result)) {
|
|
798
|
-
this.track_cut();
|
|
799
|
-
}
|
|
800
|
-
this.track_off(bu);
|
|
801
|
-
this.put(result);
|
|
802
|
-
}
|
|
803
|
-
refresh() {
|
|
804
|
-
this.cursor = $mol_wire_cursor.stale;
|
|
805
|
-
this.fresh();
|
|
594
|
+
});
|
|
595
|
+
return this.clone(sub);
|
|
806
596
|
}
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
if (this.cache instanceof Error) {
|
|
814
|
-
return $mol_fail_hidden(this.cache);
|
|
597
|
+
hack_self(belt, context = {}) {
|
|
598
|
+
let handle = belt[this.type] || belt[''];
|
|
599
|
+
if (!handle || handle === Object.prototype[this.type]) {
|
|
600
|
+
handle = (input, belt, context) => [
|
|
601
|
+
input.clone(input.hack(belt, context), context.span)
|
|
602
|
+
];
|
|
815
603
|
}
|
|
816
|
-
|
|
817
|
-
return
|
|
604
|
+
try {
|
|
605
|
+
return handle(this, belt, context);
|
|
818
606
|
}
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
while (true) {
|
|
823
|
-
this.fresh();
|
|
824
|
-
if (this.cache instanceof Error) {
|
|
825
|
-
$mol_fail_hidden(this.cache);
|
|
826
|
-
}
|
|
827
|
-
if (!$mol_promise_like(this.cache))
|
|
828
|
-
return this.cache;
|
|
829
|
-
await Promise.race([this.cache, this.step()]);
|
|
830
|
-
if (!$mol_promise_like(this.cache))
|
|
831
|
-
return this.cache;
|
|
832
|
-
if (this.cursor === $mol_wire_cursor.final) {
|
|
833
|
-
await new Promise(() => { });
|
|
834
|
-
}
|
|
607
|
+
catch (error) {
|
|
608
|
+
error.message += `\n${this.clone([])}${this.span}`;
|
|
609
|
+
$mol_fail_hidden(error);
|
|
835
610
|
}
|
|
836
611
|
}
|
|
837
|
-
|
|
838
|
-
return
|
|
839
|
-
const sub = new $mol_wire_pub_sub;
|
|
840
|
-
const prev = sub.track_on();
|
|
841
|
-
sub.track_next(this);
|
|
842
|
-
sub.track_off(prev);
|
|
843
|
-
sub.absorb = () => {
|
|
844
|
-
done(null);
|
|
845
|
-
sub.destructor();
|
|
846
|
-
};
|
|
847
|
-
});
|
|
848
|
-
}
|
|
849
|
-
}
|
|
850
|
-
$.$mol_wire_fiber = $mol_wire_fiber;
|
|
851
|
-
})($ || ($ = {}));
|
|
852
|
-
|
|
853
|
-
;
|
|
854
|
-
"use strict";
|
|
855
|
-
var $;
|
|
856
|
-
(function ($) {
|
|
857
|
-
$.$mol_compare_deep_cache = new WeakMap();
|
|
858
|
-
function $mol_compare_deep(left, right) {
|
|
859
|
-
if (Object.is(left, right))
|
|
860
|
-
return true;
|
|
861
|
-
if (left === null)
|
|
862
|
-
return false;
|
|
863
|
-
if (right === null)
|
|
864
|
-
return false;
|
|
865
|
-
if (typeof left !== 'object')
|
|
866
|
-
return false;
|
|
867
|
-
if (typeof right !== 'object')
|
|
868
|
-
return false;
|
|
869
|
-
const left_proto = Reflect.getPrototypeOf(left);
|
|
870
|
-
const right_proto = Reflect.getPrototypeOf(right);
|
|
871
|
-
if (left_proto !== right_proto)
|
|
872
|
-
return false;
|
|
873
|
-
if (left instanceof Boolean)
|
|
874
|
-
return Object.is(left.valueOf(), right['valueOf']());
|
|
875
|
-
if (left instanceof Number)
|
|
876
|
-
return Object.is(left.valueOf(), right['valueOf']());
|
|
877
|
-
if (left instanceof String)
|
|
878
|
-
return Object.is(left.valueOf(), right['valueOf']());
|
|
879
|
-
if (left instanceof Date)
|
|
880
|
-
return Object.is(left.valueOf(), right['valueOf']());
|
|
881
|
-
if (left instanceof RegExp)
|
|
882
|
-
return left.source === right.source && left.flags === right.flags;
|
|
883
|
-
if (left instanceof Error)
|
|
884
|
-
return left.message === right.message && left.stack === right.stack;
|
|
885
|
-
let left_cache = $.$mol_compare_deep_cache.get(left);
|
|
886
|
-
if (left_cache) {
|
|
887
|
-
const right_cache = left_cache.get(right);
|
|
888
|
-
if (typeof right_cache === 'boolean')
|
|
889
|
-
return right_cache;
|
|
890
|
-
}
|
|
891
|
-
else {
|
|
892
|
-
left_cache = new WeakMap([[right, true]]);
|
|
893
|
-
$.$mol_compare_deep_cache.set(left, left_cache);
|
|
894
|
-
}
|
|
895
|
-
let result;
|
|
896
|
-
try {
|
|
897
|
-
if (!left_proto)
|
|
898
|
-
result = compare_pojo(left, right);
|
|
899
|
-
else if (!Reflect.getPrototypeOf(left_proto))
|
|
900
|
-
result = compare_pojo(left, right);
|
|
901
|
-
else if (Symbol.toPrimitive in left)
|
|
902
|
-
result = compare_primitive(left, right);
|
|
903
|
-
else if (Array.isArray(left))
|
|
904
|
-
result = compare_array(left, right);
|
|
905
|
-
else if (left instanceof Set)
|
|
906
|
-
result = compare_set(left, right);
|
|
907
|
-
else if (left instanceof Map)
|
|
908
|
-
result = compare_map(left, right);
|
|
909
|
-
else if (ArrayBuffer.isView(left))
|
|
910
|
-
result = compare_buffer(left, right);
|
|
911
|
-
else if (Symbol.iterator in left)
|
|
912
|
-
result = compare_iterator(left[Symbol.iterator](), right[Symbol.iterator]());
|
|
913
|
-
else
|
|
914
|
-
result = false;
|
|
915
|
-
}
|
|
916
|
-
finally {
|
|
917
|
-
left_cache.set(right, result);
|
|
918
|
-
}
|
|
919
|
-
return result;
|
|
920
|
-
}
|
|
921
|
-
$.$mol_compare_deep = $mol_compare_deep;
|
|
922
|
-
function compare_array(left, right) {
|
|
923
|
-
const len = left.length;
|
|
924
|
-
if (len !== right.length)
|
|
925
|
-
return false;
|
|
926
|
-
for (let i = 0; i < len; ++i) {
|
|
927
|
-
if (!$mol_compare_deep(left[i], right[i]))
|
|
928
|
-
return false;
|
|
929
|
-
}
|
|
930
|
-
return true;
|
|
931
|
-
}
|
|
932
|
-
function compare_buffer(left, right) {
|
|
933
|
-
const len = left.byteLength;
|
|
934
|
-
if (len !== right.byteLength)
|
|
935
|
-
return false;
|
|
936
|
-
if (left instanceof DataView)
|
|
937
|
-
return compare_buffer(new Uint8Array(left.buffer, left.byteOffset, left.byteLength), new Uint8Array(right.buffer, left.byteOffset, left.byteLength));
|
|
938
|
-
for (let i = 0; i < len; ++i) {
|
|
939
|
-
if (left[i] !== right[i])
|
|
940
|
-
return false;
|
|
612
|
+
hack(belt, context = {}) {
|
|
613
|
+
return [].concat(...this.kids.map(child => child.hack_self(belt, context)));
|
|
941
614
|
}
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
function compare_iterator(left, right) {
|
|
945
|
-
while (true) {
|
|
946
|
-
const left_next = left.next();
|
|
947
|
-
const right_next = right.next();
|
|
948
|
-
if (left_next.done !== right_next.done)
|
|
949
|
-
return false;
|
|
950
|
-
if (left_next.done)
|
|
951
|
-
break;
|
|
952
|
-
if (!$mol_compare_deep(left_next.value, right_next.value))
|
|
953
|
-
return false;
|
|
615
|
+
error(message, Class = Error) {
|
|
616
|
+
return this.span.error(`${message}\n${this.clone([])}`, Class);
|
|
954
617
|
}
|
|
955
|
-
return true;
|
|
956
|
-
}
|
|
957
|
-
function compare_set(left, right) {
|
|
958
|
-
if (left.size !== right.size)
|
|
959
|
-
return false;
|
|
960
|
-
return compare_iterator(left.values(), right.values());
|
|
961
|
-
}
|
|
962
|
-
function compare_map(left, right) {
|
|
963
|
-
if (left.size !== right.size)
|
|
964
|
-
return false;
|
|
965
|
-
return compare_iterator(left.keys(), right.keys())
|
|
966
|
-
&& compare_iterator(left.values(), right.values());
|
|
967
618
|
}
|
|
968
|
-
|
|
969
|
-
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
return false;
|
|
973
|
-
for (let key of left_keys) {
|
|
974
|
-
if (!$mol_compare_deep(left[key], right[key]))
|
|
975
|
-
return false;
|
|
976
|
-
}
|
|
977
|
-
const left_syms = Object.getOwnPropertySymbols(left);
|
|
978
|
-
const right_syms = Object.getOwnPropertySymbols(right);
|
|
979
|
-
if (!compare_array(left_syms, right_syms))
|
|
980
|
-
return false;
|
|
981
|
-
for (let key of left_syms) {
|
|
982
|
-
if (!$mol_compare_deep(left[key], right[key]))
|
|
983
|
-
return false;
|
|
619
|
+
$.$mol_tree2 = $mol_tree2;
|
|
620
|
+
class $mol_tree2_empty extends $mol_tree2 {
|
|
621
|
+
constructor() {
|
|
622
|
+
super('', '', [], $mol_span.unknown);
|
|
984
623
|
}
|
|
985
|
-
return true;
|
|
986
|
-
}
|
|
987
|
-
function compare_primitive(left, right) {
|
|
988
|
-
return Object.is(left[Symbol.toPrimitive]('default'), right[Symbol.toPrimitive]('default'));
|
|
989
624
|
}
|
|
625
|
+
$.$mol_tree2_empty = $mol_tree2_empty;
|
|
990
626
|
})($ || ($ = {}));
|
|
991
627
|
|
|
992
628
|
;
|
|
993
629
|
"use strict";
|
|
994
630
|
var $;
|
|
995
631
|
(function ($) {
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
|
|
1006
|
-
if (logged)
|
|
1007
|
-
self.console.groupEnd();
|
|
1008
|
-
if (stack.length > deep)
|
|
1009
|
-
stack.length = deep;
|
|
1010
|
-
};
|
|
632
|
+
class $mol_error_syntax extends SyntaxError {
|
|
633
|
+
reason;
|
|
634
|
+
line;
|
|
635
|
+
span;
|
|
636
|
+
constructor(reason, line, span) {
|
|
637
|
+
super(`${reason}\n${span}\n${line.substring(0, span.col - 1).replace(/\S/g, ' ')}${''.padEnd(span.length, '!')}\n${line}`);
|
|
638
|
+
this.reason = reason;
|
|
639
|
+
this.line = line;
|
|
640
|
+
this.span = span;
|
|
641
|
+
}
|
|
1011
642
|
}
|
|
1012
|
-
$.$
|
|
1013
|
-
$.$mol_log3_stack = [];
|
|
643
|
+
$.$mol_error_syntax = $mol_error_syntax;
|
|
1014
644
|
})($ || ($ = {}));
|
|
1015
645
|
|
|
1016
646
|
;
|
|
1017
647
|
"use strict";
|
|
1018
648
|
var $;
|
|
1019
649
|
(function ($) {
|
|
1020
|
-
|
|
1021
|
-
uri;
|
|
1022
|
-
|
|
1023
|
-
|
|
1024
|
-
|
|
1025
|
-
length
|
|
1026
|
-
|
|
1027
|
-
|
|
1028
|
-
|
|
1029
|
-
|
|
1030
|
-
|
|
1031
|
-
|
|
1032
|
-
|
|
1033
|
-
|
|
1034
|
-
|
|
1035
|
-
|
|
1036
|
-
|
|
1037
|
-
|
|
1038
|
-
|
|
1039
|
-
|
|
1040
|
-
|
|
1041
|
-
}
|
|
1042
|
-
static entire(uri, source) {
|
|
1043
|
-
return new $mol_span(uri, source, 1, 1, source.length);
|
|
1044
|
-
}
|
|
1045
|
-
toString() {
|
|
1046
|
-
return this[Symbol.toStringTag];
|
|
1047
|
-
}
|
|
1048
|
-
toJSON() {
|
|
1049
|
-
return {
|
|
1050
|
-
uri: this.uri,
|
|
1051
|
-
row: this.row,
|
|
1052
|
-
col: this.col,
|
|
1053
|
-
length: this.length
|
|
1054
|
-
};
|
|
1055
|
-
}
|
|
1056
|
-
error(message, Class = Error) {
|
|
1057
|
-
return new Class(`${message} (${this})`);
|
|
1058
|
-
}
|
|
1059
|
-
span(row, col, length) {
|
|
1060
|
-
return new $mol_span(this.uri, this.source, row, col, length);
|
|
1061
|
-
}
|
|
1062
|
-
after(length = 0) {
|
|
1063
|
-
return new $mol_span(this.uri, this.source, this.row, this.col + this.length, length);
|
|
1064
|
-
}
|
|
1065
|
-
slice(begin, end = -1) {
|
|
1066
|
-
let len = this.length;
|
|
1067
|
-
if (begin < 0)
|
|
1068
|
-
begin += len;
|
|
1069
|
-
if (end < 0)
|
|
1070
|
-
end += len;
|
|
1071
|
-
if (begin < 0 || begin > len)
|
|
1072
|
-
this.$.$mol_fail(this.error(`Begin value '${begin}' out of range`, RangeError));
|
|
1073
|
-
if (end < 0 || end > len)
|
|
1074
|
-
this.$.$mol_fail(this.error(`End value '${end}' out of range`, RangeError));
|
|
1075
|
-
if (end < begin)
|
|
1076
|
-
this.$.$mol_fail(this.error(`End value '${end}' can't be less than begin value`, RangeError));
|
|
1077
|
-
return this.span(this.row, this.col + begin, end - begin);
|
|
1078
|
-
}
|
|
1079
|
-
}
|
|
1080
|
-
$.$mol_span = $mol_span;
|
|
1081
|
-
})($ || ($ = {}));
|
|
1082
|
-
|
|
1083
|
-
;
|
|
1084
|
-
"use strict";
|
|
1085
|
-
var $;
|
|
1086
|
-
(function ($) {
|
|
1087
|
-
function $mol_tree2_to_string(tree) {
|
|
1088
|
-
let output = [];
|
|
1089
|
-
function dump(tree, prefix = '') {
|
|
1090
|
-
if (tree.type.length) {
|
|
1091
|
-
if (!prefix.length) {
|
|
1092
|
-
prefix = "\t";
|
|
650
|
+
function $mol_tree2_from_string(str, uri = '?') {
|
|
651
|
+
const span = $mol_span.entire(uri, str);
|
|
652
|
+
var root = $mol_tree2.list([], span);
|
|
653
|
+
var stack = [root];
|
|
654
|
+
var pos = 0, row = 0, min_indent = 0;
|
|
655
|
+
while (str.length > pos) {
|
|
656
|
+
var indent = 0;
|
|
657
|
+
var line_start = pos;
|
|
658
|
+
row++;
|
|
659
|
+
while (str.length > pos && str[pos] == '\t') {
|
|
660
|
+
indent++;
|
|
661
|
+
pos++;
|
|
662
|
+
}
|
|
663
|
+
if (!root.kids.length) {
|
|
664
|
+
min_indent = indent;
|
|
665
|
+
}
|
|
666
|
+
indent -= min_indent;
|
|
667
|
+
if (indent < 0 || indent >= stack.length) {
|
|
668
|
+
const sp = span.span(row, 1, pos - line_start);
|
|
669
|
+
while (str.length > pos && str[pos] != '\n') {
|
|
670
|
+
pos++;
|
|
1093
671
|
}
|
|
1094
|
-
|
|
1095
|
-
|
|
1096
|
-
|
|
1097
|
-
|
|
1098
|
-
|
|
672
|
+
if (indent < 0) {
|
|
673
|
+
if (str.length > pos) {
|
|
674
|
+
this.$mol_fail(new this.$mol_error_syntax(`Too few tabs`, str.substring(line_start, pos), sp));
|
|
675
|
+
}
|
|
676
|
+
}
|
|
677
|
+
else {
|
|
678
|
+
this.$mol_fail(new this.$mol_error_syntax(`Too many tabs`, str.substring(line_start, pos), sp));
|
|
1099
679
|
}
|
|
1100
|
-
output.push("\n");
|
|
1101
680
|
}
|
|
1102
|
-
|
|
1103
|
-
|
|
681
|
+
stack.length = indent + 1;
|
|
682
|
+
var parent = stack[indent];
|
|
683
|
+
while (str.length > pos && str[pos] != '\\' && str[pos] != '\n') {
|
|
684
|
+
var error_start = pos;
|
|
685
|
+
while (str.length > pos && (str[pos] == ' ' || str[pos] == '\t')) {
|
|
686
|
+
pos++;
|
|
687
|
+
}
|
|
688
|
+
if (pos > error_start) {
|
|
689
|
+
let line_end = str.indexOf('\n', pos);
|
|
690
|
+
if (line_end === -1)
|
|
691
|
+
line_end = str.length;
|
|
692
|
+
const sp = span.span(row, error_start - line_start + 1, pos - error_start);
|
|
693
|
+
this.$mol_fail(new this.$mol_error_syntax(`Wrong nodes separator`, str.substring(line_start, line_end), sp));
|
|
694
|
+
}
|
|
695
|
+
var type_start = pos;
|
|
696
|
+
while (str.length > pos &&
|
|
697
|
+
str[pos] != '\\' &&
|
|
698
|
+
str[pos] != ' ' &&
|
|
699
|
+
str[pos] != '\t' &&
|
|
700
|
+
str[pos] != '\n') {
|
|
701
|
+
pos++;
|
|
702
|
+
}
|
|
703
|
+
if (pos > type_start) {
|
|
704
|
+
let next = new $mol_tree2(str.slice(type_start, pos), '', [], span.span(row, type_start - line_start + 1, pos - type_start));
|
|
705
|
+
const parent_kids = parent.kids;
|
|
706
|
+
parent_kids.push(next);
|
|
707
|
+
parent = next;
|
|
708
|
+
}
|
|
709
|
+
if (str.length > pos && str[pos] == ' ') {
|
|
710
|
+
pos++;
|
|
711
|
+
}
|
|
1104
712
|
}
|
|
1105
|
-
|
|
1106
|
-
|
|
1107
|
-
|
|
713
|
+
if (str.length > pos && str[pos] == '\\') {
|
|
714
|
+
var data_start = pos;
|
|
715
|
+
while (str.length > pos && str[pos] != '\n') {
|
|
716
|
+
pos++;
|
|
717
|
+
}
|
|
718
|
+
let next = new $mol_tree2('', str.slice(data_start + 1, pos), [], span.span(row, data_start - line_start + 2, pos - data_start - 1));
|
|
719
|
+
const parent_kids = parent.kids;
|
|
720
|
+
parent_kids.push(next);
|
|
721
|
+
parent = next;
|
|
722
|
+
}
|
|
723
|
+
if (str.length === pos && stack.length > 0) {
|
|
724
|
+
const sp = span.span(row, pos - line_start + 1, 1);
|
|
725
|
+
this.$mol_fail(new this.$mol_error_syntax(`Unexpected EOF, LF required`, str.substring(line_start, str.length), sp));
|
|
1108
726
|
}
|
|
727
|
+
stack.push(parent);
|
|
728
|
+
pos++;
|
|
1109
729
|
}
|
|
1110
|
-
|
|
1111
|
-
return output.join('');
|
|
730
|
+
return root;
|
|
1112
731
|
}
|
|
1113
|
-
$.$
|
|
732
|
+
$.$mol_tree2_from_string = $mol_tree2_from_string;
|
|
1114
733
|
})($ || ($ = {}));
|
|
1115
734
|
|
|
1116
735
|
;
|
|
1117
736
|
"use strict";
|
|
1118
737
|
var $;
|
|
1119
738
|
(function ($) {
|
|
1120
|
-
|
|
1121
|
-
|
|
1122
|
-
|
|
1123
|
-
kids;
|
|
1124
|
-
span;
|
|
1125
|
-
constructor(type, value, kids, span) {
|
|
1126
|
-
super();
|
|
1127
|
-
this.type = type;
|
|
1128
|
-
this.value = value;
|
|
1129
|
-
this.kids = kids;
|
|
1130
|
-
this.span = span;
|
|
1131
|
-
this[Symbol.toStringTag] = type || '\\' + value;
|
|
1132
|
-
}
|
|
1133
|
-
static list(kids, span = $mol_span.unknown) {
|
|
1134
|
-
return new $mol_tree2('', '', kids, span);
|
|
1135
|
-
}
|
|
1136
|
-
list(kids) {
|
|
1137
|
-
return $mol_tree2.list(kids, this.span);
|
|
1138
|
-
}
|
|
1139
|
-
static data(value, kids = [], span = $mol_span.unknown) {
|
|
1140
|
-
const chunks = value.split('\n');
|
|
1141
|
-
if (chunks.length > 1) {
|
|
1142
|
-
let kid_span = span.span(span.row, span.col, 0);
|
|
1143
|
-
const data = chunks.map(chunk => {
|
|
1144
|
-
kid_span = kid_span.after(chunk.length);
|
|
1145
|
-
return new $mol_tree2('', chunk, [], kid_span);
|
|
1146
|
-
});
|
|
1147
|
-
kids = [...data, ...kids];
|
|
1148
|
-
value = '';
|
|
1149
|
-
}
|
|
1150
|
-
return new $mol_tree2('', value, kids, span);
|
|
739
|
+
function $mol_tree2_from_json(json, span = $mol_span.unknown) {
|
|
740
|
+
if (typeof json === 'boolean' || typeof json === 'number' || json === null) {
|
|
741
|
+
return new $mol_tree2(String(json), '', [], span);
|
|
1151
742
|
}
|
|
1152
|
-
|
|
1153
|
-
return $mol_tree2.data(
|
|
743
|
+
if (typeof json === 'string') {
|
|
744
|
+
return $mol_tree2.data(json, [], span);
|
|
1154
745
|
}
|
|
1155
|
-
|
|
1156
|
-
|
|
1157
|
-
|
|
1158
|
-
}
|
|
1159
|
-
return new $mol_tree2(type, '', kids, span);
|
|
746
|
+
if (Array.isArray(json)) {
|
|
747
|
+
const sub = json.map(json => $mol_tree2_from_json(json, span));
|
|
748
|
+
return new $mol_tree2('/', '', sub, span);
|
|
1160
749
|
}
|
|
1161
|
-
|
|
1162
|
-
|
|
750
|
+
if (ArrayBuffer.isView(json)) {
|
|
751
|
+
const buf = new Uint8Array(json.buffer, json.byteOffset, json.byteLength);
|
|
752
|
+
return $mol_tree2.data(String.fromCharCode(...buf), [], span);
|
|
1163
753
|
}
|
|
1164
|
-
|
|
1165
|
-
return new $mol_tree2(
|
|
754
|
+
if (json instanceof Date) {
|
|
755
|
+
return new $mol_tree2('', json.toISOString(), [], span);
|
|
1166
756
|
}
|
|
1167
|
-
|
|
1168
|
-
|
|
1169
|
-
for (var kid of this.kids) {
|
|
1170
|
-
if (kid.type)
|
|
1171
|
-
continue;
|
|
1172
|
-
values.push(kid.value);
|
|
1173
|
-
}
|
|
1174
|
-
return this.value + values.join('\n');
|
|
757
|
+
if (typeof json.toJSON === 'function') {
|
|
758
|
+
return $mol_tree2_from_json(json.toJSON());
|
|
1175
759
|
}
|
|
1176
|
-
|
|
1177
|
-
return
|
|
760
|
+
if (json.toString !== Object.prototype.toString) {
|
|
761
|
+
return $mol_tree2.data(json.toString(), [], span);
|
|
1178
762
|
}
|
|
1179
|
-
|
|
1180
|
-
|
|
763
|
+
if (json instanceof Error) {
|
|
764
|
+
const { name, message, stack } = json;
|
|
765
|
+
json = { ...json, name, message, stack };
|
|
1181
766
|
}
|
|
1182
|
-
|
|
1183
|
-
|
|
1184
|
-
|
|
1185
|
-
|
|
1186
|
-
|
|
1187
|
-
|
|
1188
|
-
|
|
1189
|
-
|
|
1190
|
-
return item;
|
|
1191
|
-
replaced = true;
|
|
1192
|
-
return item.insert(value, ...path.slice(1));
|
|
1193
|
-
}).filter(Boolean);
|
|
1194
|
-
if (!replaced && value) {
|
|
1195
|
-
sub.push(this.struct(type, []).insert(value, ...path.slice(1)));
|
|
1196
|
-
}
|
|
1197
|
-
return this.clone(sub);
|
|
1198
|
-
}
|
|
1199
|
-
else if (typeof type === 'number') {
|
|
1200
|
-
const sub = this.kids.slice();
|
|
1201
|
-
sub[type] = (sub[type] || this.list([]))
|
|
1202
|
-
.insert(value, ...path.slice(1));
|
|
1203
|
-
return this.clone(sub.filter(Boolean));
|
|
767
|
+
const sub = [];
|
|
768
|
+
for (var key in json) {
|
|
769
|
+
const val = json[key];
|
|
770
|
+
if (val === undefined)
|
|
771
|
+
continue;
|
|
772
|
+
const subsub = $mol_tree2_from_json(val, span);
|
|
773
|
+
if (/^[^\n\t\\ ]+$/.test(key)) {
|
|
774
|
+
sub.push(new $mol_tree2(key, '', [subsub], span));
|
|
1204
775
|
}
|
|
1205
776
|
else {
|
|
1206
|
-
|
|
1207
|
-
.map(item => item.insert(value, ...path.slice(1)))
|
|
1208
|
-
.filter(Boolean);
|
|
1209
|
-
return this.clone(kids);
|
|
1210
|
-
}
|
|
1211
|
-
}
|
|
1212
|
-
select(...path) {
|
|
1213
|
-
let next = [this];
|
|
1214
|
-
for (const type of path) {
|
|
1215
|
-
if (!next.length)
|
|
1216
|
-
break;
|
|
1217
|
-
const prev = next;
|
|
1218
|
-
next = [];
|
|
1219
|
-
for (var item of prev) {
|
|
1220
|
-
switch (typeof (type)) {
|
|
1221
|
-
case 'string':
|
|
1222
|
-
for (var child of item.kids) {
|
|
1223
|
-
if (child.type == type) {
|
|
1224
|
-
next.push(child);
|
|
1225
|
-
}
|
|
1226
|
-
}
|
|
1227
|
-
break;
|
|
1228
|
-
case 'number':
|
|
1229
|
-
if (type < item.kids.length)
|
|
1230
|
-
next.push(item.kids[type]);
|
|
1231
|
-
break;
|
|
1232
|
-
default: next.push(...item.kids);
|
|
1233
|
-
}
|
|
1234
|
-
}
|
|
1235
|
-
}
|
|
1236
|
-
return this.list(next);
|
|
1237
|
-
}
|
|
1238
|
-
filter(path, value) {
|
|
1239
|
-
const sub = this.kids.filter(item => {
|
|
1240
|
-
var found = item.select(...path);
|
|
1241
|
-
if (value === undefined) {
|
|
1242
|
-
return Boolean(found.kids.length);
|
|
1243
|
-
}
|
|
1244
|
-
else {
|
|
1245
|
-
return found.kids.some(child => child.value == value);
|
|
1246
|
-
}
|
|
1247
|
-
});
|
|
1248
|
-
return this.clone(sub);
|
|
1249
|
-
}
|
|
1250
|
-
hack_self(belt, context = {}) {
|
|
1251
|
-
let handle = belt[this.type] || belt[''];
|
|
1252
|
-
if (!handle || handle === Object.prototype[this.type]) {
|
|
1253
|
-
handle = (input, belt, context) => [
|
|
1254
|
-
input.clone(input.hack(belt, context), context.span)
|
|
1255
|
-
];
|
|
1256
|
-
}
|
|
1257
|
-
try {
|
|
1258
|
-
return handle(this, belt, context);
|
|
1259
|
-
}
|
|
1260
|
-
catch (error) {
|
|
1261
|
-
error.message += `\n${this.clone([])}${this.span}`;
|
|
1262
|
-
$mol_fail_hidden(error);
|
|
1263
|
-
}
|
|
1264
|
-
}
|
|
1265
|
-
hack(belt, context = {}) {
|
|
1266
|
-
return [].concat(...this.kids.map(child => child.hack_self(belt, context)));
|
|
1267
|
-
}
|
|
1268
|
-
error(message, Class = Error) {
|
|
1269
|
-
return this.span.error(`${message}\n${this.clone([])}`, Class);
|
|
1270
|
-
}
|
|
1271
|
-
}
|
|
1272
|
-
$.$mol_tree2 = $mol_tree2;
|
|
1273
|
-
class $mol_tree2_empty extends $mol_tree2 {
|
|
1274
|
-
constructor() {
|
|
1275
|
-
super('', '', [], $mol_span.unknown);
|
|
1276
|
-
}
|
|
1277
|
-
}
|
|
1278
|
-
$.$mol_tree2_empty = $mol_tree2_empty;
|
|
1279
|
-
})($ || ($ = {}));
|
|
1280
|
-
|
|
1281
|
-
;
|
|
1282
|
-
"use strict";
|
|
1283
|
-
var $;
|
|
1284
|
-
(function ($) {
|
|
1285
|
-
class $mol_error_syntax extends SyntaxError {
|
|
1286
|
-
reason;
|
|
1287
|
-
line;
|
|
1288
|
-
span;
|
|
1289
|
-
constructor(reason, line, span) {
|
|
1290
|
-
super(`${reason}\n${span}\n${line.substring(0, span.col - 1).replace(/\S/g, ' ')}${''.padEnd(span.length, '!')}\n${line}`);
|
|
1291
|
-
this.reason = reason;
|
|
1292
|
-
this.line = line;
|
|
1293
|
-
this.span = span;
|
|
1294
|
-
}
|
|
1295
|
-
}
|
|
1296
|
-
$.$mol_error_syntax = $mol_error_syntax;
|
|
1297
|
-
})($ || ($ = {}));
|
|
1298
|
-
|
|
1299
|
-
;
|
|
1300
|
-
"use strict";
|
|
1301
|
-
var $;
|
|
1302
|
-
(function ($) {
|
|
1303
|
-
function $mol_tree2_from_string(str, uri = '?') {
|
|
1304
|
-
const span = $mol_span.entire(uri, str);
|
|
1305
|
-
var root = $mol_tree2.list([], span);
|
|
1306
|
-
var stack = [root];
|
|
1307
|
-
var pos = 0, row = 0, min_indent = 0;
|
|
1308
|
-
while (str.length > pos) {
|
|
1309
|
-
var indent = 0;
|
|
1310
|
-
var line_start = pos;
|
|
1311
|
-
row++;
|
|
1312
|
-
while (str.length > pos && str[pos] == '\t') {
|
|
1313
|
-
indent++;
|
|
1314
|
-
pos++;
|
|
1315
|
-
}
|
|
1316
|
-
if (!root.kids.length) {
|
|
1317
|
-
min_indent = indent;
|
|
1318
|
-
}
|
|
1319
|
-
indent -= min_indent;
|
|
1320
|
-
if (indent < 0 || indent >= stack.length) {
|
|
1321
|
-
const sp = span.span(row, 1, pos - line_start);
|
|
1322
|
-
while (str.length > pos && str[pos] != '\n') {
|
|
1323
|
-
pos++;
|
|
1324
|
-
}
|
|
1325
|
-
if (indent < 0) {
|
|
1326
|
-
if (str.length > pos) {
|
|
1327
|
-
this.$mol_fail(new this.$mol_error_syntax(`Too few tabs`, str.substring(line_start, pos), sp));
|
|
1328
|
-
}
|
|
1329
|
-
}
|
|
1330
|
-
else {
|
|
1331
|
-
this.$mol_fail(new this.$mol_error_syntax(`Too many tabs`, str.substring(line_start, pos), sp));
|
|
1332
|
-
}
|
|
1333
|
-
}
|
|
1334
|
-
stack.length = indent + 1;
|
|
1335
|
-
var parent = stack[indent];
|
|
1336
|
-
while (str.length > pos && str[pos] != '\\' && str[pos] != '\n') {
|
|
1337
|
-
var error_start = pos;
|
|
1338
|
-
while (str.length > pos && (str[pos] == ' ' || str[pos] == '\t')) {
|
|
1339
|
-
pos++;
|
|
1340
|
-
}
|
|
1341
|
-
if (pos > error_start) {
|
|
1342
|
-
let line_end = str.indexOf('\n', pos);
|
|
1343
|
-
if (line_end === -1)
|
|
1344
|
-
line_end = str.length;
|
|
1345
|
-
const sp = span.span(row, error_start - line_start + 1, pos - error_start);
|
|
1346
|
-
this.$mol_fail(new this.$mol_error_syntax(`Wrong nodes separator`, str.substring(line_start, line_end), sp));
|
|
1347
|
-
}
|
|
1348
|
-
var type_start = pos;
|
|
1349
|
-
while (str.length > pos &&
|
|
1350
|
-
str[pos] != '\\' &&
|
|
1351
|
-
str[pos] != ' ' &&
|
|
1352
|
-
str[pos] != '\t' &&
|
|
1353
|
-
str[pos] != '\n') {
|
|
1354
|
-
pos++;
|
|
1355
|
-
}
|
|
1356
|
-
if (pos > type_start) {
|
|
1357
|
-
let next = new $mol_tree2(str.slice(type_start, pos), '', [], span.span(row, type_start - line_start + 1, pos - type_start));
|
|
1358
|
-
const parent_kids = parent.kids;
|
|
1359
|
-
parent_kids.push(next);
|
|
1360
|
-
parent = next;
|
|
1361
|
-
}
|
|
1362
|
-
if (str.length > pos && str[pos] == ' ') {
|
|
1363
|
-
pos++;
|
|
1364
|
-
}
|
|
1365
|
-
}
|
|
1366
|
-
if (str.length > pos && str[pos] == '\\') {
|
|
1367
|
-
var data_start = pos;
|
|
1368
|
-
while (str.length > pos && str[pos] != '\n') {
|
|
1369
|
-
pos++;
|
|
1370
|
-
}
|
|
1371
|
-
let next = new $mol_tree2('', str.slice(data_start + 1, pos), [], span.span(row, data_start - line_start + 2, pos - data_start - 1));
|
|
1372
|
-
const parent_kids = parent.kids;
|
|
1373
|
-
parent_kids.push(next);
|
|
1374
|
-
parent = next;
|
|
1375
|
-
}
|
|
1376
|
-
if (str.length === pos && stack.length > 0) {
|
|
1377
|
-
const sp = span.span(row, pos - line_start + 1, 1);
|
|
1378
|
-
this.$mol_fail(new this.$mol_error_syntax(`Unexpected EOF, LF required`, str.substring(line_start, str.length), sp));
|
|
1379
|
-
}
|
|
1380
|
-
stack.push(parent);
|
|
1381
|
-
pos++;
|
|
1382
|
-
}
|
|
1383
|
-
return root;
|
|
1384
|
-
}
|
|
1385
|
-
$.$mol_tree2_from_string = $mol_tree2_from_string;
|
|
1386
|
-
})($ || ($ = {}));
|
|
1387
|
-
|
|
1388
|
-
;
|
|
1389
|
-
"use strict";
|
|
1390
|
-
var $;
|
|
1391
|
-
(function ($) {
|
|
1392
|
-
function $mol_tree2_from_json(json, span = $mol_span.unknown) {
|
|
1393
|
-
if (typeof json === 'boolean' || typeof json === 'number' || json === null) {
|
|
1394
|
-
return new $mol_tree2(String(json), '', [], span);
|
|
1395
|
-
}
|
|
1396
|
-
if (typeof json === 'string') {
|
|
1397
|
-
return $mol_tree2.data(json, [], span);
|
|
1398
|
-
}
|
|
1399
|
-
if (Array.isArray(json)) {
|
|
1400
|
-
const sub = json.map(json => $mol_tree2_from_json(json, span));
|
|
1401
|
-
return new $mol_tree2('/', '', sub, span);
|
|
1402
|
-
}
|
|
1403
|
-
if (ArrayBuffer.isView(json)) {
|
|
1404
|
-
const buf = new Uint8Array(json.buffer, json.byteOffset, json.byteLength);
|
|
1405
|
-
return $mol_tree2.data(String.fromCharCode(...buf), [], span);
|
|
1406
|
-
}
|
|
1407
|
-
if (json instanceof Date) {
|
|
1408
|
-
return new $mol_tree2('', json.toISOString(), [], span);
|
|
1409
|
-
}
|
|
1410
|
-
if (typeof json.toJSON === 'function') {
|
|
1411
|
-
return $mol_tree2_from_json(json.toJSON());
|
|
1412
|
-
}
|
|
1413
|
-
if (json.toString !== Object.prototype.toString) {
|
|
1414
|
-
return $mol_tree2.data(json.toString(), [], span);
|
|
1415
|
-
}
|
|
1416
|
-
if (json instanceof Error) {
|
|
1417
|
-
const { name, message, stack } = json;
|
|
1418
|
-
json = { ...json, name, message, stack };
|
|
1419
|
-
}
|
|
1420
|
-
const sub = [];
|
|
1421
|
-
for (var key in json) {
|
|
1422
|
-
const val = json[key];
|
|
1423
|
-
if (val === undefined)
|
|
1424
|
-
continue;
|
|
1425
|
-
const subsub = $mol_tree2_from_json(val, span);
|
|
1426
|
-
if (/^[^\n\t\\ ]+$/.test(key)) {
|
|
1427
|
-
sub.push(new $mol_tree2(key, '', [subsub], span));
|
|
1428
|
-
}
|
|
1429
|
-
else {
|
|
1430
|
-
sub.push($mol_tree2.data(key, [subsub], span));
|
|
777
|
+
sub.push($mol_tree2.data(key, [subsub], span));
|
|
1431
778
|
}
|
|
1432
779
|
}
|
|
1433
780
|
return new $mol_tree2('*', '', sub, span);
|
|
@@ -1506,178 +853,6 @@ var $;
|
|
|
1506
853
|
$.$mol_log3_area = $mol_log3_node_make('log', 'stdout', 'area', $mol_term_color.cyan);
|
|
1507
854
|
})($ || ($ = {}));
|
|
1508
855
|
|
|
1509
|
-
;
|
|
1510
|
-
"use strict";
|
|
1511
|
-
var $;
|
|
1512
|
-
(function ($) {
|
|
1513
|
-
class $mol_wire_task extends $mol_wire_fiber {
|
|
1514
|
-
static getter(task) {
|
|
1515
|
-
return function $mol_wire_task_get(host, args) {
|
|
1516
|
-
const sub = $mol_wire_auto();
|
|
1517
|
-
const existen = sub?.track_next();
|
|
1518
|
-
reuse: if (existen) {
|
|
1519
|
-
if (!existen.temp)
|
|
1520
|
-
break reuse;
|
|
1521
|
-
if (existen.host !== host)
|
|
1522
|
-
break reuse;
|
|
1523
|
-
if (existen.task !== task)
|
|
1524
|
-
break reuse;
|
|
1525
|
-
if (!$mol_compare_deep(existen.args, args))
|
|
1526
|
-
break reuse;
|
|
1527
|
-
return existen;
|
|
1528
|
-
}
|
|
1529
|
-
const next = new $mol_wire_task(`${host?.[Symbol.toStringTag] ?? host}.${task.name}<#>`, task, host, args);
|
|
1530
|
-
if (existen?.temp) {
|
|
1531
|
-
$$.$mol_log3_warn({
|
|
1532
|
-
place: '$mol_wire_task',
|
|
1533
|
-
message: `Non idempotency`,
|
|
1534
|
-
existen,
|
|
1535
|
-
next,
|
|
1536
|
-
hint: 'Ignore it',
|
|
1537
|
-
});
|
|
1538
|
-
}
|
|
1539
|
-
return next;
|
|
1540
|
-
};
|
|
1541
|
-
}
|
|
1542
|
-
get temp() {
|
|
1543
|
-
return true;
|
|
1544
|
-
}
|
|
1545
|
-
complete() {
|
|
1546
|
-
if ($mol_promise_like(this.cache))
|
|
1547
|
-
return;
|
|
1548
|
-
this.destructor();
|
|
1549
|
-
}
|
|
1550
|
-
put(next) {
|
|
1551
|
-
const prev = this.cache;
|
|
1552
|
-
this.cache = next;
|
|
1553
|
-
if ($mol_promise_like(next)) {
|
|
1554
|
-
this.cursor = $mol_wire_cursor.fresh;
|
|
1555
|
-
if (next !== prev)
|
|
1556
|
-
this.emit();
|
|
1557
|
-
return next;
|
|
1558
|
-
}
|
|
1559
|
-
this.cursor = $mol_wire_cursor.final;
|
|
1560
|
-
if (this.sub_empty)
|
|
1561
|
-
this.destructor();
|
|
1562
|
-
else if (next !== prev)
|
|
1563
|
-
this.emit();
|
|
1564
|
-
return next;
|
|
1565
|
-
}
|
|
1566
|
-
}
|
|
1567
|
-
$.$mol_wire_task = $mol_wire_task;
|
|
1568
|
-
})($ || ($ = {}));
|
|
1569
|
-
|
|
1570
|
-
;
|
|
1571
|
-
"use strict";
|
|
1572
|
-
var $;
|
|
1573
|
-
(function ($) {
|
|
1574
|
-
function $mol_wire_sync(obj) {
|
|
1575
|
-
return new Proxy(obj, {
|
|
1576
|
-
get(obj, field) {
|
|
1577
|
-
const val = obj[field];
|
|
1578
|
-
if (typeof val !== 'function')
|
|
1579
|
-
return val;
|
|
1580
|
-
const temp = $mol_wire_task.getter(val);
|
|
1581
|
-
return function $mol_wire_sync(...args) {
|
|
1582
|
-
const fiber = temp(obj, args);
|
|
1583
|
-
return fiber.sync();
|
|
1584
|
-
};
|
|
1585
|
-
},
|
|
1586
|
-
apply(obj, self, args) {
|
|
1587
|
-
const temp = $mol_wire_task.getter(obj);
|
|
1588
|
-
const fiber = temp(self, args);
|
|
1589
|
-
return fiber.sync();
|
|
1590
|
-
},
|
|
1591
|
-
});
|
|
1592
|
-
}
|
|
1593
|
-
$.$mol_wire_sync = $mol_wire_sync;
|
|
1594
|
-
})($ || ($ = {}));
|
|
1595
|
-
|
|
1596
|
-
;
|
|
1597
|
-
"use strict";
|
|
1598
|
-
var $;
|
|
1599
|
-
(function ($) {
|
|
1600
|
-
const catched = new WeakMap();
|
|
1601
|
-
function $mol_fail_catch(error) {
|
|
1602
|
-
if (typeof error !== 'object')
|
|
1603
|
-
return false;
|
|
1604
|
-
if ($mol_promise_like(error))
|
|
1605
|
-
$mol_fail_hidden(error);
|
|
1606
|
-
if (catched.get(error))
|
|
1607
|
-
return false;
|
|
1608
|
-
catched.set(error, true);
|
|
1609
|
-
return true;
|
|
1610
|
-
}
|
|
1611
|
-
$.$mol_fail_catch = $mol_fail_catch;
|
|
1612
|
-
})($ || ($ = {}));
|
|
1613
|
-
|
|
1614
|
-
;
|
|
1615
|
-
"use strict";
|
|
1616
|
-
var $;
|
|
1617
|
-
(function ($) {
|
|
1618
|
-
function $mol_fail_log(error) {
|
|
1619
|
-
if ($mol_promise_like(error))
|
|
1620
|
-
return false;
|
|
1621
|
-
if (!$mol_fail_catch(error))
|
|
1622
|
-
return false;
|
|
1623
|
-
console.error(error);
|
|
1624
|
-
return true;
|
|
1625
|
-
}
|
|
1626
|
-
$.$mol_fail_log = $mol_fail_log;
|
|
1627
|
-
})($ || ($ = {}));
|
|
1628
|
-
|
|
1629
|
-
;
|
|
1630
|
-
"use strict";
|
|
1631
|
-
var $node = new Proxy({ require }, {
|
|
1632
|
-
get(target, name, wrapper) {
|
|
1633
|
-
if (target[name])
|
|
1634
|
-
return target[name];
|
|
1635
|
-
const mod = target.require('module');
|
|
1636
|
-
if (mod.builtinModules.indexOf(name) >= 0)
|
|
1637
|
-
return target.require(name);
|
|
1638
|
-
if (name[0] === '.')
|
|
1639
|
-
return target.require(name);
|
|
1640
|
-
const path = target.require('path');
|
|
1641
|
-
const fs = target.require('fs');
|
|
1642
|
-
let dir = path.resolve('.');
|
|
1643
|
-
const suffix = `./node_modules/${name}`;
|
|
1644
|
-
const $$ = $;
|
|
1645
|
-
while (!fs.existsSync(path.join(dir, suffix))) {
|
|
1646
|
-
const parent = path.resolve(dir, '..');
|
|
1647
|
-
if (parent === dir) {
|
|
1648
|
-
$$.$mol_exec('.', 'npm', 'install', '--omit=dev', name);
|
|
1649
|
-
try {
|
|
1650
|
-
$$.$mol_exec('.', 'npm', 'install', '--omit=dev', '@types/' + name);
|
|
1651
|
-
}
|
|
1652
|
-
catch { }
|
|
1653
|
-
break;
|
|
1654
|
-
}
|
|
1655
|
-
else {
|
|
1656
|
-
dir = parent;
|
|
1657
|
-
}
|
|
1658
|
-
}
|
|
1659
|
-
try {
|
|
1660
|
-
return $.$mol_wire_sync(target).require(name);
|
|
1661
|
-
}
|
|
1662
|
-
catch (error) {
|
|
1663
|
-
if (error.code === 'ERR_REQUIRE_ESM') {
|
|
1664
|
-
return importSync(name);
|
|
1665
|
-
}
|
|
1666
|
-
$.$mol_fail_log(error);
|
|
1667
|
-
return null;
|
|
1668
|
-
}
|
|
1669
|
-
},
|
|
1670
|
-
set(target, name, value) {
|
|
1671
|
-
target[name] = value;
|
|
1672
|
-
return true;
|
|
1673
|
-
},
|
|
1674
|
-
});
|
|
1675
|
-
const importAsync = async (uri) => import(uri);
|
|
1676
|
-
const importSync = $.$mol_wire_sync(importAsync);
|
|
1677
|
-
require = (req => Object.assign(function require(name) {
|
|
1678
|
-
return $node[name];
|
|
1679
|
-
}, req))(require);
|
|
1680
|
-
|
|
1681
856
|
;
|
|
1682
857
|
"use strict";
|
|
1683
858
|
var $;
|
|
@@ -1921,25 +1096,626 @@ var $;
|
|
|
1921
1096
|
$mol_jsx_document = next;
|
|
1922
1097
|
return action();
|
|
1923
1098
|
}
|
|
1924
|
-
finally {
|
|
1925
|
-
$mol_jsx_document = prev;
|
|
1099
|
+
finally {
|
|
1100
|
+
$mol_jsx_document = prev;
|
|
1101
|
+
}
|
|
1102
|
+
}
|
|
1103
|
+
$.$mol_jsx_attach = $mol_jsx_attach;
|
|
1104
|
+
})($ || ($ = {}));
|
|
1105
|
+
|
|
1106
|
+
;
|
|
1107
|
+
"use strict";
|
|
1108
|
+
var $;
|
|
1109
|
+
(function ($) {
|
|
1110
|
+
let $mol_wire_cursor;
|
|
1111
|
+
(function ($mol_wire_cursor) {
|
|
1112
|
+
$mol_wire_cursor[$mol_wire_cursor["stale"] = -1] = "stale";
|
|
1113
|
+
$mol_wire_cursor[$mol_wire_cursor["doubt"] = -2] = "doubt";
|
|
1114
|
+
$mol_wire_cursor[$mol_wire_cursor["fresh"] = -3] = "fresh";
|
|
1115
|
+
$mol_wire_cursor[$mol_wire_cursor["final"] = -4] = "final";
|
|
1116
|
+
})($mol_wire_cursor = $.$mol_wire_cursor || ($.$mol_wire_cursor = {}));
|
|
1117
|
+
})($ || ($ = {}));
|
|
1118
|
+
|
|
1119
|
+
;
|
|
1120
|
+
"use strict";
|
|
1121
|
+
var $;
|
|
1122
|
+
(function ($) {
|
|
1123
|
+
class $mol_wire_pub extends Object {
|
|
1124
|
+
data = [];
|
|
1125
|
+
static get [Symbol.species]() {
|
|
1126
|
+
return Array;
|
|
1127
|
+
}
|
|
1128
|
+
sub_from = 0;
|
|
1129
|
+
get sub_list() {
|
|
1130
|
+
const res = [];
|
|
1131
|
+
for (let i = this.sub_from; i < this.data.length; i += 2) {
|
|
1132
|
+
res.push(this.data[i]);
|
|
1133
|
+
}
|
|
1134
|
+
return res;
|
|
1135
|
+
}
|
|
1136
|
+
get sub_empty() {
|
|
1137
|
+
return this.sub_from === this.data.length;
|
|
1138
|
+
}
|
|
1139
|
+
sub_on(sub, pub_pos) {
|
|
1140
|
+
const pos = this.data.length;
|
|
1141
|
+
this.data.push(sub, pub_pos);
|
|
1142
|
+
return pos;
|
|
1143
|
+
}
|
|
1144
|
+
sub_off(sub_pos) {
|
|
1145
|
+
if (!(sub_pos < this.data.length)) {
|
|
1146
|
+
$mol_fail(new Error(`Wrong pos ${sub_pos}`));
|
|
1147
|
+
}
|
|
1148
|
+
const end = this.data.length - 2;
|
|
1149
|
+
if (sub_pos !== end) {
|
|
1150
|
+
this.peer_move(end, sub_pos);
|
|
1151
|
+
}
|
|
1152
|
+
this.data.pop();
|
|
1153
|
+
this.data.pop();
|
|
1154
|
+
if (this.data.length === this.sub_from)
|
|
1155
|
+
this.reap();
|
|
1156
|
+
}
|
|
1157
|
+
reap() { }
|
|
1158
|
+
promote() {
|
|
1159
|
+
$mol_wire_auto()?.track_next(this);
|
|
1160
|
+
}
|
|
1161
|
+
fresh() { }
|
|
1162
|
+
complete() { }
|
|
1163
|
+
get incompleted() {
|
|
1164
|
+
return false;
|
|
1165
|
+
}
|
|
1166
|
+
emit(quant = $mol_wire_cursor.stale) {
|
|
1167
|
+
for (let i = this.sub_from; i < this.data.length; i += 2) {
|
|
1168
|
+
;
|
|
1169
|
+
this.data[i].absorb(quant);
|
|
1170
|
+
}
|
|
1171
|
+
}
|
|
1172
|
+
peer_move(from_pos, to_pos) {
|
|
1173
|
+
const peer = this.data[from_pos];
|
|
1174
|
+
const self_pos = this.data[from_pos + 1];
|
|
1175
|
+
this.data[to_pos] = peer;
|
|
1176
|
+
this.data[to_pos + 1] = self_pos;
|
|
1177
|
+
peer.peer_repos(self_pos, to_pos);
|
|
1178
|
+
}
|
|
1179
|
+
peer_repos(peer_pos, self_pos) {
|
|
1180
|
+
this.data[peer_pos + 1] = self_pos;
|
|
1181
|
+
}
|
|
1182
|
+
}
|
|
1183
|
+
$.$mol_wire_pub = $mol_wire_pub;
|
|
1184
|
+
})($ || ($ = {}));
|
|
1185
|
+
|
|
1186
|
+
;
|
|
1187
|
+
"use strict";
|
|
1188
|
+
|
|
1189
|
+
;
|
|
1190
|
+
"use strict";
|
|
1191
|
+
var $;
|
|
1192
|
+
(function ($) {
|
|
1193
|
+
$.$mol_wire_auto_sub = null;
|
|
1194
|
+
function $mol_wire_auto(next = $.$mol_wire_auto_sub) {
|
|
1195
|
+
return $.$mol_wire_auto_sub = next;
|
|
1196
|
+
}
|
|
1197
|
+
$.$mol_wire_auto = $mol_wire_auto;
|
|
1198
|
+
$.$mol_wire_affected = [];
|
|
1199
|
+
})($ || ($ = {}));
|
|
1200
|
+
|
|
1201
|
+
;
|
|
1202
|
+
"use strict";
|
|
1203
|
+
var $;
|
|
1204
|
+
(function ($) {
|
|
1205
|
+
$['devtoolsFormatters'] ||= [];
|
|
1206
|
+
function $mol_dev_format_register(config) {
|
|
1207
|
+
$['devtoolsFormatters'].push(config);
|
|
1208
|
+
}
|
|
1209
|
+
$.$mol_dev_format_register = $mol_dev_format_register;
|
|
1210
|
+
$.$mol_dev_format_head = Symbol('$mol_dev_format_head');
|
|
1211
|
+
$.$mol_dev_format_body = Symbol('$mol_dev_format_body');
|
|
1212
|
+
$mol_dev_format_register({
|
|
1213
|
+
header: (val, config = false) => {
|
|
1214
|
+
if (config)
|
|
1215
|
+
return null;
|
|
1216
|
+
if (!val)
|
|
1217
|
+
return null;
|
|
1218
|
+
if ($.$mol_dev_format_head in val) {
|
|
1219
|
+
try {
|
|
1220
|
+
return val[$.$mol_dev_format_head]();
|
|
1221
|
+
}
|
|
1222
|
+
catch (error) {
|
|
1223
|
+
return $.$mol_dev_format_accent($mol_dev_format_native(val), '💨', $mol_dev_format_native(error), '');
|
|
1224
|
+
}
|
|
1225
|
+
}
|
|
1226
|
+
if (typeof val === 'function') {
|
|
1227
|
+
return $mol_dev_format_native(val);
|
|
1228
|
+
}
|
|
1229
|
+
if (Symbol.toStringTag in val) {
|
|
1230
|
+
return $mol_dev_format_native(val);
|
|
1231
|
+
}
|
|
1232
|
+
return null;
|
|
1233
|
+
},
|
|
1234
|
+
hasBody: val => val[$.$mol_dev_format_body],
|
|
1235
|
+
body: val => val[$.$mol_dev_format_body](),
|
|
1236
|
+
});
|
|
1237
|
+
function $mol_dev_format_native(obj) {
|
|
1238
|
+
if (typeof obj === 'undefined')
|
|
1239
|
+
return $.$mol_dev_format_shade('undefined');
|
|
1240
|
+
return [
|
|
1241
|
+
'object',
|
|
1242
|
+
{
|
|
1243
|
+
object: obj,
|
|
1244
|
+
config: true,
|
|
1245
|
+
},
|
|
1246
|
+
];
|
|
1247
|
+
}
|
|
1248
|
+
$.$mol_dev_format_native = $mol_dev_format_native;
|
|
1249
|
+
function $mol_dev_format_auto(obj) {
|
|
1250
|
+
if (obj == null)
|
|
1251
|
+
return $.$mol_dev_format_shade(String(obj));
|
|
1252
|
+
return [
|
|
1253
|
+
'object',
|
|
1254
|
+
{
|
|
1255
|
+
object: obj,
|
|
1256
|
+
config: false,
|
|
1257
|
+
},
|
|
1258
|
+
];
|
|
1259
|
+
}
|
|
1260
|
+
$.$mol_dev_format_auto = $mol_dev_format_auto;
|
|
1261
|
+
function $mol_dev_format_element(element, style, ...content) {
|
|
1262
|
+
const styles = [];
|
|
1263
|
+
for (let key in style)
|
|
1264
|
+
styles.push(`${key} : ${style[key]}`);
|
|
1265
|
+
return [
|
|
1266
|
+
element,
|
|
1267
|
+
{
|
|
1268
|
+
style: styles.join(' ; '),
|
|
1269
|
+
},
|
|
1270
|
+
...content,
|
|
1271
|
+
];
|
|
1272
|
+
}
|
|
1273
|
+
$.$mol_dev_format_element = $mol_dev_format_element;
|
|
1274
|
+
function $mol_dev_format_span(style, ...content) {
|
|
1275
|
+
return $mol_dev_format_element('span', {
|
|
1276
|
+
...style,
|
|
1277
|
+
}, ...content);
|
|
1278
|
+
}
|
|
1279
|
+
$.$mol_dev_format_span = $mol_dev_format_span;
|
|
1280
|
+
$.$mol_dev_format_div = $mol_dev_format_element.bind(null, 'div');
|
|
1281
|
+
$.$mol_dev_format_ol = $mol_dev_format_element.bind(null, 'ol');
|
|
1282
|
+
$.$mol_dev_format_li = $mol_dev_format_element.bind(null, 'li');
|
|
1283
|
+
$.$mol_dev_format_table = $mol_dev_format_element.bind(null, 'table');
|
|
1284
|
+
$.$mol_dev_format_tr = $mol_dev_format_element.bind(null, 'tr');
|
|
1285
|
+
$.$mol_dev_format_td = $mol_dev_format_element.bind(null, 'td');
|
|
1286
|
+
$.$mol_dev_format_accent = $mol_dev_format_span.bind(null, {
|
|
1287
|
+
'color': 'magenta',
|
|
1288
|
+
});
|
|
1289
|
+
$.$mol_dev_format_strong = $mol_dev_format_span.bind(null, {
|
|
1290
|
+
'font-weight': 'bold',
|
|
1291
|
+
});
|
|
1292
|
+
$.$mol_dev_format_string = $mol_dev_format_span.bind(null, {
|
|
1293
|
+
'color': 'green',
|
|
1294
|
+
});
|
|
1295
|
+
$.$mol_dev_format_shade = $mol_dev_format_span.bind(null, {
|
|
1296
|
+
'color': 'gray',
|
|
1297
|
+
});
|
|
1298
|
+
$.$mol_dev_format_indent = $.$mol_dev_format_div.bind(null, {
|
|
1299
|
+
'margin-left': '13px'
|
|
1300
|
+
});
|
|
1301
|
+
})($ || ($ = {}));
|
|
1302
|
+
|
|
1303
|
+
;
|
|
1304
|
+
"use strict";
|
|
1305
|
+
var $;
|
|
1306
|
+
(function ($) {
|
|
1307
|
+
function $mol_const(value) {
|
|
1308
|
+
const getter = (() => value);
|
|
1309
|
+
getter['()'] = value;
|
|
1310
|
+
getter[Symbol.toStringTag] = value;
|
|
1311
|
+
getter[$mol_dev_format_head] = () => $mol_dev_format_span({}, '()=> ', $mol_dev_format_auto(value));
|
|
1312
|
+
return getter;
|
|
1313
|
+
}
|
|
1314
|
+
$.$mol_const = $mol_const;
|
|
1315
|
+
})($ || ($ = {}));
|
|
1316
|
+
|
|
1317
|
+
;
|
|
1318
|
+
"use strict";
|
|
1319
|
+
var $;
|
|
1320
|
+
(function ($) {
|
|
1321
|
+
class $mol_wire_pub_sub extends $mol_wire_pub {
|
|
1322
|
+
pub_from = 0;
|
|
1323
|
+
cursor = $mol_wire_cursor.stale;
|
|
1324
|
+
get temp() {
|
|
1325
|
+
return false;
|
|
1326
|
+
}
|
|
1327
|
+
get pub_list() {
|
|
1328
|
+
const res = [];
|
|
1329
|
+
const max = this.cursor >= 0 ? this.cursor : this.sub_from;
|
|
1330
|
+
for (let i = this.pub_from; i < max; i += 2) {
|
|
1331
|
+
if (this.data[i])
|
|
1332
|
+
res.push(this.data[i]);
|
|
1333
|
+
}
|
|
1334
|
+
return res;
|
|
1335
|
+
}
|
|
1336
|
+
track_on() {
|
|
1337
|
+
this.cursor = this.pub_from;
|
|
1338
|
+
const sub = $mol_wire_auto();
|
|
1339
|
+
$mol_wire_auto(this);
|
|
1340
|
+
return sub;
|
|
1341
|
+
}
|
|
1342
|
+
promote() {
|
|
1343
|
+
if (this.cursor >= this.pub_from) {
|
|
1344
|
+
$mol_fail(new Error('Circular subscription'));
|
|
1345
|
+
}
|
|
1346
|
+
super.promote();
|
|
1347
|
+
}
|
|
1348
|
+
track_next(pub) {
|
|
1349
|
+
if (this.cursor < 0)
|
|
1350
|
+
$mol_fail(new Error('Promo to non begun sub'));
|
|
1351
|
+
if (this.cursor < this.sub_from) {
|
|
1352
|
+
const next = this.data[this.cursor];
|
|
1353
|
+
if (pub === undefined)
|
|
1354
|
+
return next ?? null;
|
|
1355
|
+
if (next === pub) {
|
|
1356
|
+
this.cursor += 2;
|
|
1357
|
+
return next;
|
|
1358
|
+
}
|
|
1359
|
+
if (next) {
|
|
1360
|
+
if (this.sub_from < this.data.length) {
|
|
1361
|
+
this.peer_move(this.sub_from, this.data.length);
|
|
1362
|
+
}
|
|
1363
|
+
this.peer_move(this.cursor, this.sub_from);
|
|
1364
|
+
this.sub_from += 2;
|
|
1365
|
+
}
|
|
1366
|
+
}
|
|
1367
|
+
else {
|
|
1368
|
+
if (pub === undefined)
|
|
1369
|
+
return null;
|
|
1370
|
+
if (this.sub_from < this.data.length) {
|
|
1371
|
+
this.peer_move(this.sub_from, this.data.length);
|
|
1372
|
+
}
|
|
1373
|
+
this.sub_from += 2;
|
|
1374
|
+
}
|
|
1375
|
+
this.data[this.cursor] = pub;
|
|
1376
|
+
this.data[this.cursor + 1] = pub.sub_on(this, this.cursor);
|
|
1377
|
+
this.cursor += 2;
|
|
1378
|
+
return pub;
|
|
1379
|
+
}
|
|
1380
|
+
track_off(sub) {
|
|
1381
|
+
$mol_wire_auto(sub);
|
|
1382
|
+
if (this.cursor < 0) {
|
|
1383
|
+
$mol_fail(new Error('End of non begun sub'));
|
|
1384
|
+
}
|
|
1385
|
+
for (let cursor = this.pub_from; cursor < this.cursor; cursor += 2) {
|
|
1386
|
+
const pub = this.data[cursor];
|
|
1387
|
+
pub.fresh();
|
|
1388
|
+
}
|
|
1389
|
+
this.cursor = $mol_wire_cursor.fresh;
|
|
1390
|
+
}
|
|
1391
|
+
pub_off(sub_pos) {
|
|
1392
|
+
this.data[sub_pos] = undefined;
|
|
1393
|
+
this.data[sub_pos + 1] = undefined;
|
|
1394
|
+
}
|
|
1395
|
+
destructor() {
|
|
1396
|
+
for (let cursor = this.data.length - 2; cursor >= this.sub_from; cursor -= 2) {
|
|
1397
|
+
const sub = this.data[cursor];
|
|
1398
|
+
const pos = this.data[cursor + 1];
|
|
1399
|
+
sub.pub_off(pos);
|
|
1400
|
+
this.data.pop();
|
|
1401
|
+
this.data.pop();
|
|
1402
|
+
}
|
|
1403
|
+
this.cursor = this.pub_from;
|
|
1404
|
+
this.track_cut();
|
|
1405
|
+
this.cursor = $mol_wire_cursor.final;
|
|
1406
|
+
}
|
|
1407
|
+
track_cut() {
|
|
1408
|
+
if (this.cursor < this.pub_from) {
|
|
1409
|
+
$mol_fail(new Error('Cut of non begun sub'));
|
|
1410
|
+
}
|
|
1411
|
+
let tail = 0;
|
|
1412
|
+
for (let cursor = this.cursor; cursor < this.sub_from; cursor += 2) {
|
|
1413
|
+
const pub = this.data[cursor];
|
|
1414
|
+
pub?.sub_off(this.data[cursor + 1]);
|
|
1415
|
+
if (this.sub_from < this.data.length) {
|
|
1416
|
+
this.peer_move(this.data.length - 2, cursor);
|
|
1417
|
+
this.data.pop();
|
|
1418
|
+
this.data.pop();
|
|
1419
|
+
}
|
|
1420
|
+
else {
|
|
1421
|
+
++tail;
|
|
1422
|
+
}
|
|
1423
|
+
}
|
|
1424
|
+
for (; tail; --tail) {
|
|
1425
|
+
this.data.pop();
|
|
1426
|
+
this.data.pop();
|
|
1427
|
+
}
|
|
1428
|
+
this.sub_from = this.cursor;
|
|
1429
|
+
}
|
|
1430
|
+
complete() { }
|
|
1431
|
+
complete_pubs() {
|
|
1432
|
+
const limit = this.cursor < 0 ? this.sub_from : this.cursor;
|
|
1433
|
+
for (let cursor = this.pub_from; cursor < limit; cursor += 2) {
|
|
1434
|
+
const pub = this.data[cursor];
|
|
1435
|
+
if (pub?.incompleted)
|
|
1436
|
+
return;
|
|
1437
|
+
}
|
|
1438
|
+
for (let cursor = this.pub_from; cursor < limit; cursor += 2) {
|
|
1439
|
+
const pub = this.data[cursor];
|
|
1440
|
+
pub?.complete();
|
|
1441
|
+
}
|
|
1442
|
+
}
|
|
1443
|
+
absorb(quant = $mol_wire_cursor.stale) {
|
|
1444
|
+
if (this.cursor === $mol_wire_cursor.final)
|
|
1445
|
+
return;
|
|
1446
|
+
if (this.cursor >= quant)
|
|
1447
|
+
return;
|
|
1448
|
+
this.cursor = quant;
|
|
1449
|
+
this.emit($mol_wire_cursor.doubt);
|
|
1450
|
+
}
|
|
1451
|
+
[$mol_dev_format_head]() {
|
|
1452
|
+
return $mol_dev_format_native(this);
|
|
1453
|
+
}
|
|
1454
|
+
get pub_empty() {
|
|
1455
|
+
return this.sub_from === this.pub_from;
|
|
1456
|
+
}
|
|
1457
|
+
}
|
|
1458
|
+
$.$mol_wire_pub_sub = $mol_wire_pub_sub;
|
|
1459
|
+
})($ || ($ = {}));
|
|
1460
|
+
|
|
1461
|
+
;
|
|
1462
|
+
"use strict";
|
|
1463
|
+
var $;
|
|
1464
|
+
(function ($) {
|
|
1465
|
+
class $mol_after_timeout extends $mol_object2 {
|
|
1466
|
+
delay;
|
|
1467
|
+
task;
|
|
1468
|
+
id;
|
|
1469
|
+
constructor(delay, task) {
|
|
1470
|
+
super();
|
|
1471
|
+
this.delay = delay;
|
|
1472
|
+
this.task = task;
|
|
1473
|
+
this.id = setTimeout(task, delay);
|
|
1474
|
+
}
|
|
1475
|
+
destructor() {
|
|
1476
|
+
clearTimeout(this.id);
|
|
1477
|
+
}
|
|
1478
|
+
}
|
|
1479
|
+
$.$mol_after_timeout = $mol_after_timeout;
|
|
1480
|
+
})($ || ($ = {}));
|
|
1481
|
+
|
|
1482
|
+
;
|
|
1483
|
+
"use strict";
|
|
1484
|
+
var $;
|
|
1485
|
+
(function ($) {
|
|
1486
|
+
class $mol_after_frame extends $mol_after_timeout {
|
|
1487
|
+
task;
|
|
1488
|
+
constructor(task) {
|
|
1489
|
+
super(16, task);
|
|
1490
|
+
this.task = task;
|
|
1491
|
+
}
|
|
1492
|
+
}
|
|
1493
|
+
$.$mol_after_frame = $mol_after_frame;
|
|
1494
|
+
})($ || ($ = {}));
|
|
1495
|
+
|
|
1496
|
+
;
|
|
1497
|
+
"use strict";
|
|
1498
|
+
var $;
|
|
1499
|
+
(function ($) {
|
|
1500
|
+
const handled = new WeakSet();
|
|
1501
|
+
class $mol_wire_fiber extends $mol_wire_pub_sub {
|
|
1502
|
+
task;
|
|
1503
|
+
host;
|
|
1504
|
+
static warm = true;
|
|
1505
|
+
static planning = new Set();
|
|
1506
|
+
static reaping = new Set();
|
|
1507
|
+
static plan_task = null;
|
|
1508
|
+
static plan() {
|
|
1509
|
+
if (this.plan_task)
|
|
1510
|
+
return;
|
|
1511
|
+
this.plan_task = new $mol_after_frame(() => {
|
|
1512
|
+
try {
|
|
1513
|
+
this.sync();
|
|
1514
|
+
}
|
|
1515
|
+
finally {
|
|
1516
|
+
$mol_wire_fiber.plan_task = null;
|
|
1517
|
+
}
|
|
1518
|
+
});
|
|
1519
|
+
}
|
|
1520
|
+
static sync() {
|
|
1521
|
+
while (this.planning.size) {
|
|
1522
|
+
for (const fiber of this.planning) {
|
|
1523
|
+
this.planning.delete(fiber);
|
|
1524
|
+
if (fiber.cursor >= 0)
|
|
1525
|
+
continue;
|
|
1526
|
+
if (fiber.cursor === $mol_wire_cursor.final)
|
|
1527
|
+
continue;
|
|
1528
|
+
fiber.fresh();
|
|
1529
|
+
}
|
|
1530
|
+
}
|
|
1531
|
+
while (this.reaping.size) {
|
|
1532
|
+
const fibers = this.reaping;
|
|
1533
|
+
this.reaping = new Set;
|
|
1534
|
+
for (const fiber of fibers) {
|
|
1535
|
+
if (!fiber.sub_empty)
|
|
1536
|
+
continue;
|
|
1537
|
+
fiber.destructor();
|
|
1538
|
+
}
|
|
1539
|
+
}
|
|
1540
|
+
}
|
|
1541
|
+
[Symbol.toStringTag];
|
|
1542
|
+
cache = undefined;
|
|
1543
|
+
get args() {
|
|
1544
|
+
return this.data.slice(0, this.pub_from);
|
|
1545
|
+
}
|
|
1546
|
+
result() {
|
|
1547
|
+
if ($mol_promise_like(this.cache))
|
|
1548
|
+
return;
|
|
1549
|
+
if (this.cache instanceof Error)
|
|
1550
|
+
return;
|
|
1551
|
+
return this.cache;
|
|
1552
|
+
}
|
|
1553
|
+
get incompleted() {
|
|
1554
|
+
return $mol_promise_like(this.cache);
|
|
1555
|
+
}
|
|
1556
|
+
field() {
|
|
1557
|
+
return this.task.name + '<>';
|
|
1558
|
+
}
|
|
1559
|
+
constructor(id, task, host, args) {
|
|
1560
|
+
super();
|
|
1561
|
+
this.task = task;
|
|
1562
|
+
this.host = host;
|
|
1563
|
+
if (args)
|
|
1564
|
+
this.data.push(...args);
|
|
1565
|
+
this.pub_from = this.sub_from = args?.length ?? 0;
|
|
1566
|
+
this[Symbol.toStringTag] = id;
|
|
1567
|
+
}
|
|
1568
|
+
plan() {
|
|
1569
|
+
$mol_wire_fiber.planning.add(this);
|
|
1570
|
+
$mol_wire_fiber.plan();
|
|
1571
|
+
}
|
|
1572
|
+
reap() {
|
|
1573
|
+
$mol_wire_fiber.reaping.add(this);
|
|
1574
|
+
$mol_wire_fiber.plan();
|
|
1575
|
+
}
|
|
1576
|
+
toString() {
|
|
1577
|
+
return this[Symbol.toStringTag];
|
|
1578
|
+
}
|
|
1579
|
+
toJSON() {
|
|
1580
|
+
return this[Symbol.toStringTag];
|
|
1581
|
+
}
|
|
1582
|
+
[$mol_dev_format_head]() {
|
|
1583
|
+
const cursor = {
|
|
1584
|
+
[$mol_wire_cursor.stale]: '🔴',
|
|
1585
|
+
[$mol_wire_cursor.doubt]: '🟡',
|
|
1586
|
+
[$mol_wire_cursor.fresh]: '🟢',
|
|
1587
|
+
[$mol_wire_cursor.final]: '🔵',
|
|
1588
|
+
}[this.cursor] ?? this.cursor.toString();
|
|
1589
|
+
return $mol_dev_format_div({}, $mol_owning_check(this, this.cache)
|
|
1590
|
+
? $mol_dev_format_auto({
|
|
1591
|
+
[$mol_dev_format_head]: () => $mol_dev_format_shade(cursor),
|
|
1592
|
+
[$mol_dev_format_body]: () => $mol_dev_format_native(this),
|
|
1593
|
+
})
|
|
1594
|
+
: $mol_dev_format_shade($mol_dev_format_native(this), cursor), $mol_dev_format_auto(this.cache));
|
|
1595
|
+
}
|
|
1596
|
+
get $() {
|
|
1597
|
+
return (this.host ?? this.task)['$'];
|
|
1598
|
+
}
|
|
1599
|
+
emit(quant = $mol_wire_cursor.stale) {
|
|
1600
|
+
if (this.sub_empty)
|
|
1601
|
+
this.plan();
|
|
1602
|
+
else
|
|
1603
|
+
super.emit(quant);
|
|
1604
|
+
}
|
|
1605
|
+
fresh() {
|
|
1606
|
+
if (this.cursor === $mol_wire_cursor.fresh)
|
|
1607
|
+
return;
|
|
1608
|
+
if (this.cursor === $mol_wire_cursor.final)
|
|
1609
|
+
return;
|
|
1610
|
+
check: if (this.cursor === $mol_wire_cursor.doubt) {
|
|
1611
|
+
for (let i = this.pub_from; i < this.sub_from; i += 2) {
|
|
1612
|
+
;
|
|
1613
|
+
this.data[i]?.fresh();
|
|
1614
|
+
if (this.cursor !== $mol_wire_cursor.doubt)
|
|
1615
|
+
break check;
|
|
1616
|
+
}
|
|
1617
|
+
this.cursor = $mol_wire_cursor.fresh;
|
|
1618
|
+
return;
|
|
1619
|
+
}
|
|
1620
|
+
const bu = this.track_on();
|
|
1621
|
+
let result;
|
|
1622
|
+
try {
|
|
1623
|
+
switch (this.pub_from) {
|
|
1624
|
+
case 0:
|
|
1625
|
+
result = this.task.call(this.host);
|
|
1626
|
+
break;
|
|
1627
|
+
case 1:
|
|
1628
|
+
result = this.task.call(this.host, this.data[0]);
|
|
1629
|
+
break;
|
|
1630
|
+
default:
|
|
1631
|
+
result = this.task.call(this.host, ...this.args);
|
|
1632
|
+
break;
|
|
1633
|
+
}
|
|
1634
|
+
if ($mol_promise_like(result) && !handled.has(result)) {
|
|
1635
|
+
const put = (res) => {
|
|
1636
|
+
if (this.cache === result)
|
|
1637
|
+
this.put(res);
|
|
1638
|
+
return res;
|
|
1639
|
+
};
|
|
1640
|
+
result = result.then(put, put);
|
|
1641
|
+
}
|
|
1642
|
+
}
|
|
1643
|
+
catch (error) {
|
|
1644
|
+
if (error instanceof Error || $mol_promise_like(error)) {
|
|
1645
|
+
result = error;
|
|
1646
|
+
}
|
|
1647
|
+
else {
|
|
1648
|
+
result = new Error(String(error), { cause: error });
|
|
1649
|
+
}
|
|
1650
|
+
if ($mol_promise_like(result) && !handled.has(result)) {
|
|
1651
|
+
result = result.finally(() => {
|
|
1652
|
+
if (this.cache === result)
|
|
1653
|
+
this.absorb();
|
|
1654
|
+
});
|
|
1655
|
+
}
|
|
1656
|
+
}
|
|
1657
|
+
if ($mol_promise_like(result) && !handled.has(result)) {
|
|
1658
|
+
result = Object.assign(result, {
|
|
1659
|
+
destructor: result['destructor'] ?? (() => { })
|
|
1660
|
+
});
|
|
1661
|
+
handled.add(result);
|
|
1662
|
+
const error = new Error(`Promise in ${this}`);
|
|
1663
|
+
Object.defineProperty(result, 'stack', { get: () => error.stack });
|
|
1664
|
+
}
|
|
1665
|
+
if (!$mol_promise_like(result)) {
|
|
1666
|
+
this.track_cut();
|
|
1667
|
+
}
|
|
1668
|
+
this.track_off(bu);
|
|
1669
|
+
this.put(result);
|
|
1670
|
+
}
|
|
1671
|
+
refresh() {
|
|
1672
|
+
this.cursor = $mol_wire_cursor.stale;
|
|
1673
|
+
this.fresh();
|
|
1674
|
+
}
|
|
1675
|
+
sync() {
|
|
1676
|
+
if (!$mol_wire_fiber.warm) {
|
|
1677
|
+
return this.result();
|
|
1678
|
+
}
|
|
1679
|
+
this.promote();
|
|
1680
|
+
this.fresh();
|
|
1681
|
+
if (this.cache instanceof Error) {
|
|
1682
|
+
return $mol_fail_hidden(this.cache);
|
|
1683
|
+
}
|
|
1684
|
+
if ($mol_promise_like(this.cache)) {
|
|
1685
|
+
return $mol_fail_hidden(this.cache);
|
|
1686
|
+
}
|
|
1687
|
+
return this.cache;
|
|
1688
|
+
}
|
|
1689
|
+
async async() {
|
|
1690
|
+
while (true) {
|
|
1691
|
+
this.fresh();
|
|
1692
|
+
if (this.cache instanceof Error) {
|
|
1693
|
+
$mol_fail_hidden(this.cache);
|
|
1694
|
+
}
|
|
1695
|
+
if (!$mol_promise_like(this.cache))
|
|
1696
|
+
return this.cache;
|
|
1697
|
+
await Promise.race([this.cache, this.step()]);
|
|
1698
|
+
if (!$mol_promise_like(this.cache))
|
|
1699
|
+
return this.cache;
|
|
1700
|
+
if (this.cursor === $mol_wire_cursor.final) {
|
|
1701
|
+
await new Promise(() => { });
|
|
1702
|
+
}
|
|
1703
|
+
}
|
|
1704
|
+
}
|
|
1705
|
+
step() {
|
|
1706
|
+
return new Promise(done => {
|
|
1707
|
+
const sub = new $mol_wire_pub_sub;
|
|
1708
|
+
const prev = sub.track_on();
|
|
1709
|
+
sub.track_next(this);
|
|
1710
|
+
sub.track_off(prev);
|
|
1711
|
+
sub.absorb = () => {
|
|
1712
|
+
done(null);
|
|
1713
|
+
sub.destructor();
|
|
1714
|
+
};
|
|
1715
|
+
});
|
|
1926
1716
|
}
|
|
1927
1717
|
}
|
|
1928
|
-
$.$
|
|
1929
|
-
})($ || ($ = {}));
|
|
1930
|
-
|
|
1931
|
-
;
|
|
1932
|
-
"use strict";
|
|
1933
|
-
var $;
|
|
1934
|
-
(function ($) {
|
|
1935
|
-
function $mol_const(value) {
|
|
1936
|
-
const getter = (() => value);
|
|
1937
|
-
getter['()'] = value;
|
|
1938
|
-
getter[Symbol.toStringTag] = value;
|
|
1939
|
-
getter[$mol_dev_format_head] = () => $mol_dev_format_span({}, '()=> ', $mol_dev_format_auto(value));
|
|
1940
|
-
return getter;
|
|
1941
|
-
}
|
|
1942
|
-
$.$mol_const = $mol_const;
|
|
1718
|
+
$.$mol_wire_fiber = $mol_wire_fiber;
|
|
1943
1719
|
})($ || ($ = {}));
|
|
1944
1720
|
|
|
1945
1721
|
;
|
|
@@ -2004,6 +1780,206 @@ var $;
|
|
|
2004
1780
|
$.$mol_key = $mol_key;
|
|
2005
1781
|
})($ || ($ = {}));
|
|
2006
1782
|
|
|
1783
|
+
;
|
|
1784
|
+
"use strict";
|
|
1785
|
+
var $;
|
|
1786
|
+
(function ($) {
|
|
1787
|
+
$.$mol_compare_deep_cache = new WeakMap();
|
|
1788
|
+
function $mol_compare_deep(left, right) {
|
|
1789
|
+
if (Object.is(left, right))
|
|
1790
|
+
return true;
|
|
1791
|
+
if (left === null)
|
|
1792
|
+
return false;
|
|
1793
|
+
if (right === null)
|
|
1794
|
+
return false;
|
|
1795
|
+
if (typeof left !== 'object')
|
|
1796
|
+
return false;
|
|
1797
|
+
if (typeof right !== 'object')
|
|
1798
|
+
return false;
|
|
1799
|
+
const left_proto = Reflect.getPrototypeOf(left);
|
|
1800
|
+
const right_proto = Reflect.getPrototypeOf(right);
|
|
1801
|
+
if (left_proto !== right_proto)
|
|
1802
|
+
return false;
|
|
1803
|
+
if (left instanceof Boolean)
|
|
1804
|
+
return Object.is(left.valueOf(), right['valueOf']());
|
|
1805
|
+
if (left instanceof Number)
|
|
1806
|
+
return Object.is(left.valueOf(), right['valueOf']());
|
|
1807
|
+
if (left instanceof String)
|
|
1808
|
+
return Object.is(left.valueOf(), right['valueOf']());
|
|
1809
|
+
if (left instanceof Date)
|
|
1810
|
+
return Object.is(left.valueOf(), right['valueOf']());
|
|
1811
|
+
if (left instanceof RegExp)
|
|
1812
|
+
return left.source === right.source && left.flags === right.flags;
|
|
1813
|
+
if (left instanceof Error)
|
|
1814
|
+
return left.message === right.message && left.stack === right.stack;
|
|
1815
|
+
let left_cache = $.$mol_compare_deep_cache.get(left);
|
|
1816
|
+
if (left_cache) {
|
|
1817
|
+
const right_cache = left_cache.get(right);
|
|
1818
|
+
if (typeof right_cache === 'boolean')
|
|
1819
|
+
return right_cache;
|
|
1820
|
+
}
|
|
1821
|
+
else {
|
|
1822
|
+
left_cache = new WeakMap([[right, true]]);
|
|
1823
|
+
$.$mol_compare_deep_cache.set(left, left_cache);
|
|
1824
|
+
}
|
|
1825
|
+
let result;
|
|
1826
|
+
try {
|
|
1827
|
+
if (!left_proto)
|
|
1828
|
+
result = compare_pojo(left, right);
|
|
1829
|
+
else if (!Reflect.getPrototypeOf(left_proto))
|
|
1830
|
+
result = compare_pojo(left, right);
|
|
1831
|
+
else if (Symbol.toPrimitive in left)
|
|
1832
|
+
result = compare_primitive(left, right);
|
|
1833
|
+
else if (Array.isArray(left))
|
|
1834
|
+
result = compare_array(left, right);
|
|
1835
|
+
else if (left instanceof Set)
|
|
1836
|
+
result = compare_set(left, right);
|
|
1837
|
+
else if (left instanceof Map)
|
|
1838
|
+
result = compare_map(left, right);
|
|
1839
|
+
else if (ArrayBuffer.isView(left))
|
|
1840
|
+
result = compare_buffer(left, right);
|
|
1841
|
+
else if (Symbol.iterator in left)
|
|
1842
|
+
result = compare_iterator(left[Symbol.iterator](), right[Symbol.iterator]());
|
|
1843
|
+
else
|
|
1844
|
+
result = false;
|
|
1845
|
+
}
|
|
1846
|
+
finally {
|
|
1847
|
+
left_cache.set(right, result);
|
|
1848
|
+
}
|
|
1849
|
+
return result;
|
|
1850
|
+
}
|
|
1851
|
+
$.$mol_compare_deep = $mol_compare_deep;
|
|
1852
|
+
function compare_array(left, right) {
|
|
1853
|
+
const len = left.length;
|
|
1854
|
+
if (len !== right.length)
|
|
1855
|
+
return false;
|
|
1856
|
+
for (let i = 0; i < len; ++i) {
|
|
1857
|
+
if (!$mol_compare_deep(left[i], right[i]))
|
|
1858
|
+
return false;
|
|
1859
|
+
}
|
|
1860
|
+
return true;
|
|
1861
|
+
}
|
|
1862
|
+
function compare_buffer(left, right) {
|
|
1863
|
+
const len = left.byteLength;
|
|
1864
|
+
if (len !== right.byteLength)
|
|
1865
|
+
return false;
|
|
1866
|
+
if (left instanceof DataView)
|
|
1867
|
+
return compare_buffer(new Uint8Array(left.buffer, left.byteOffset, left.byteLength), new Uint8Array(right.buffer, left.byteOffset, left.byteLength));
|
|
1868
|
+
for (let i = 0; i < len; ++i) {
|
|
1869
|
+
if (left[i] !== right[i])
|
|
1870
|
+
return false;
|
|
1871
|
+
}
|
|
1872
|
+
return true;
|
|
1873
|
+
}
|
|
1874
|
+
function compare_iterator(left, right) {
|
|
1875
|
+
while (true) {
|
|
1876
|
+
const left_next = left.next();
|
|
1877
|
+
const right_next = right.next();
|
|
1878
|
+
if (left_next.done !== right_next.done)
|
|
1879
|
+
return false;
|
|
1880
|
+
if (left_next.done)
|
|
1881
|
+
break;
|
|
1882
|
+
if (!$mol_compare_deep(left_next.value, right_next.value))
|
|
1883
|
+
return false;
|
|
1884
|
+
}
|
|
1885
|
+
return true;
|
|
1886
|
+
}
|
|
1887
|
+
function compare_set(left, right) {
|
|
1888
|
+
if (left.size !== right.size)
|
|
1889
|
+
return false;
|
|
1890
|
+
return compare_iterator(left.values(), right.values());
|
|
1891
|
+
}
|
|
1892
|
+
function compare_map(left, right) {
|
|
1893
|
+
if (left.size !== right.size)
|
|
1894
|
+
return false;
|
|
1895
|
+
return compare_iterator(left.keys(), right.keys())
|
|
1896
|
+
&& compare_iterator(left.values(), right.values());
|
|
1897
|
+
}
|
|
1898
|
+
function compare_pojo(left, right) {
|
|
1899
|
+
const left_keys = Object.getOwnPropertyNames(left);
|
|
1900
|
+
const right_keys = Object.getOwnPropertyNames(right);
|
|
1901
|
+
if (!compare_array(left_keys, right_keys))
|
|
1902
|
+
return false;
|
|
1903
|
+
for (let key of left_keys) {
|
|
1904
|
+
if (!$mol_compare_deep(left[key], right[key]))
|
|
1905
|
+
return false;
|
|
1906
|
+
}
|
|
1907
|
+
const left_syms = Object.getOwnPropertySymbols(left);
|
|
1908
|
+
const right_syms = Object.getOwnPropertySymbols(right);
|
|
1909
|
+
if (!compare_array(left_syms, right_syms))
|
|
1910
|
+
return false;
|
|
1911
|
+
for (let key of left_syms) {
|
|
1912
|
+
if (!$mol_compare_deep(left[key], right[key]))
|
|
1913
|
+
return false;
|
|
1914
|
+
}
|
|
1915
|
+
return true;
|
|
1916
|
+
}
|
|
1917
|
+
function compare_primitive(left, right) {
|
|
1918
|
+
return Object.is(left[Symbol.toPrimitive]('default'), right[Symbol.toPrimitive]('default'));
|
|
1919
|
+
}
|
|
1920
|
+
})($ || ($ = {}));
|
|
1921
|
+
|
|
1922
|
+
;
|
|
1923
|
+
"use strict";
|
|
1924
|
+
var $;
|
|
1925
|
+
(function ($) {
|
|
1926
|
+
class $mol_wire_task extends $mol_wire_fiber {
|
|
1927
|
+
static getter(task) {
|
|
1928
|
+
return function $mol_wire_task_get(host, args) {
|
|
1929
|
+
const sub = $mol_wire_auto();
|
|
1930
|
+
const existen = sub?.track_next();
|
|
1931
|
+
reuse: if (existen) {
|
|
1932
|
+
if (!existen.temp)
|
|
1933
|
+
break reuse;
|
|
1934
|
+
if (existen.host !== host)
|
|
1935
|
+
break reuse;
|
|
1936
|
+
if (existen.task !== task)
|
|
1937
|
+
break reuse;
|
|
1938
|
+
if (!$mol_compare_deep(existen.args, args))
|
|
1939
|
+
break reuse;
|
|
1940
|
+
return existen;
|
|
1941
|
+
}
|
|
1942
|
+
const next = new $mol_wire_task(`${host?.[Symbol.toStringTag] ?? host}.${task.name}<#>`, task, host, args);
|
|
1943
|
+
if (existen?.temp) {
|
|
1944
|
+
$$.$mol_log3_warn({
|
|
1945
|
+
place: '$mol_wire_task',
|
|
1946
|
+
message: `Non idempotency`,
|
|
1947
|
+
existen,
|
|
1948
|
+
next,
|
|
1949
|
+
hint: 'Ignore it',
|
|
1950
|
+
});
|
|
1951
|
+
}
|
|
1952
|
+
return next;
|
|
1953
|
+
};
|
|
1954
|
+
}
|
|
1955
|
+
get temp() {
|
|
1956
|
+
return true;
|
|
1957
|
+
}
|
|
1958
|
+
complete() {
|
|
1959
|
+
if ($mol_promise_like(this.cache))
|
|
1960
|
+
return;
|
|
1961
|
+
this.destructor();
|
|
1962
|
+
}
|
|
1963
|
+
put(next) {
|
|
1964
|
+
const prev = this.cache;
|
|
1965
|
+
this.cache = next;
|
|
1966
|
+
if ($mol_promise_like(next)) {
|
|
1967
|
+
this.cursor = $mol_wire_cursor.fresh;
|
|
1968
|
+
if (next !== prev)
|
|
1969
|
+
this.emit();
|
|
1970
|
+
return next;
|
|
1971
|
+
}
|
|
1972
|
+
this.cursor = $mol_wire_cursor.final;
|
|
1973
|
+
if (this.sub_empty)
|
|
1974
|
+
this.destructor();
|
|
1975
|
+
else if (next !== prev)
|
|
1976
|
+
this.emit();
|
|
1977
|
+
return next;
|
|
1978
|
+
}
|
|
1979
|
+
}
|
|
1980
|
+
$.$mol_wire_task = $mol_wire_task;
|
|
1981
|
+
})($ || ($ = {}));
|
|
1982
|
+
|
|
2007
1983
|
;
|
|
2008
1984
|
"use strict";
|
|
2009
1985
|
var $;
|
|
@@ -2380,6 +2356,32 @@ var $;
|
|
|
2380
2356
|
$.$mol_wire_watch = $mol_wire_watch;
|
|
2381
2357
|
})($ || ($ = {}));
|
|
2382
2358
|
|
|
2359
|
+
;
|
|
2360
|
+
"use strict";
|
|
2361
|
+
var $;
|
|
2362
|
+
(function ($) {
|
|
2363
|
+
function $mol_wire_sync(obj) {
|
|
2364
|
+
return new Proxy(obj, {
|
|
2365
|
+
get(obj, field) {
|
|
2366
|
+
const val = obj[field];
|
|
2367
|
+
if (typeof val !== 'function')
|
|
2368
|
+
return val;
|
|
2369
|
+
const temp = $mol_wire_task.getter(val);
|
|
2370
|
+
return function $mol_wire_sync(...args) {
|
|
2371
|
+
const fiber = temp(obj, args);
|
|
2372
|
+
return fiber.sync();
|
|
2373
|
+
};
|
|
2374
|
+
},
|
|
2375
|
+
apply(obj, self, args) {
|
|
2376
|
+
const temp = $mol_wire_task.getter(obj);
|
|
2377
|
+
const fiber = temp(self, args);
|
|
2378
|
+
return fiber.sync();
|
|
2379
|
+
},
|
|
2380
|
+
});
|
|
2381
|
+
}
|
|
2382
|
+
$.$mol_wire_sync = $mol_wire_sync;
|
|
2383
|
+
})($ || ($ = {}));
|
|
2384
|
+
|
|
2383
2385
|
;
|
|
2384
2386
|
"use strict";
|
|
2385
2387
|
var $;
|