mol_db 0.0.1005 → 0.0.1007
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 +201 -30
- package/node.d.ts.map +1 -1
- package/node.deps.json +1 -1
- package/node.js +917 -85
- package/node.js.map +1 -1
- package/node.mjs +917 -85
- package/node.test.js +1484 -431
- package/node.test.js.map +1 -1
- package/package.json +17 -2
package/node.js
CHANGED
|
@@ -51,124 +51,341 @@ var $;
|
|
|
51
51
|
"use strict";
|
|
52
52
|
var $;
|
|
53
53
|
(function ($) {
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
54
|
+
let $mol_wire_cursor;
|
|
55
|
+
(function ($mol_wire_cursor) {
|
|
56
|
+
$mol_wire_cursor[$mol_wire_cursor["stale"] = -1] = "stale";
|
|
57
|
+
$mol_wire_cursor[$mol_wire_cursor["doubt"] = -2] = "doubt";
|
|
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 = {}));
|
|
58
61
|
})($ || ($ = {}));
|
|
59
62
|
|
|
60
63
|
;
|
|
61
64
|
"use strict";
|
|
62
65
|
var $;
|
|
63
66
|
(function ($) {
|
|
64
|
-
|
|
65
|
-
|
|
67
|
+
class $mol_wire_pub extends Object {
|
|
68
|
+
data = [];
|
|
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
|
+
}
|
|
66
126
|
}
|
|
67
|
-
$.$
|
|
127
|
+
$.$mol_wire_pub = $mol_wire_pub;
|
|
68
128
|
})($ || ($ = {}));
|
|
69
129
|
|
|
130
|
+
;
|
|
131
|
+
"use strict";
|
|
132
|
+
|
|
70
133
|
;
|
|
71
134
|
"use strict";
|
|
72
135
|
var $;
|
|
73
136
|
(function ($) {
|
|
74
|
-
|
|
75
|
-
function $
|
|
76
|
-
|
|
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;
|
|
137
|
+
$.$mol_wire_auto_sub = null;
|
|
138
|
+
function $mol_wire_auto(next = $.$mol_wire_auto_sub) {
|
|
139
|
+
return $.$mol_wire_auto_sub = next;
|
|
84
140
|
}
|
|
85
|
-
$.$
|
|
141
|
+
$.$mol_wire_auto = $mol_wire_auto;
|
|
142
|
+
$.$mol_wire_affected = [];
|
|
86
143
|
})($ || ($ = {}));
|
|
87
144
|
|
|
88
145
|
;
|
|
89
146
|
"use strict";
|
|
90
147
|
var $;
|
|
91
148
|
(function ($) {
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
if (!$mol_fail_catch(error))
|
|
96
|
-
return false;
|
|
97
|
-
console.error(error);
|
|
98
|
-
return true;
|
|
149
|
+
$['devtoolsFormatters'] ||= [];
|
|
150
|
+
function $mol_dev_format_register(config) {
|
|
151
|
+
$['devtoolsFormatters'].push(config);
|
|
99
152
|
}
|
|
100
|
-
$.$
|
|
153
|
+
$.$mol_dev_format_register = $mol_dev_format_register;
|
|
154
|
+
$.$mol_dev_format_head = Symbol('$mol_dev_format_head');
|
|
155
|
+
$.$mol_dev_format_body = Symbol('$mol_dev_format_body');
|
|
156
|
+
$mol_dev_format_register({
|
|
157
|
+
header: (val, config = false) => {
|
|
158
|
+
if (config)
|
|
159
|
+
return null;
|
|
160
|
+
if (!val)
|
|
161
|
+
return null;
|
|
162
|
+
if ($.$mol_dev_format_head in val) {
|
|
163
|
+
try {
|
|
164
|
+
return val[$.$mol_dev_format_head]();
|
|
165
|
+
}
|
|
166
|
+
catch (error) {
|
|
167
|
+
return $.$mol_dev_format_accent($mol_dev_format_native(val), '💨', $mol_dev_format_native(error), '');
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
if (typeof val === 'function') {
|
|
171
|
+
return $mol_dev_format_native(val);
|
|
172
|
+
}
|
|
173
|
+
if (Symbol.toStringTag in val) {
|
|
174
|
+
return $mol_dev_format_native(val);
|
|
175
|
+
}
|
|
176
|
+
return null;
|
|
177
|
+
},
|
|
178
|
+
hasBody: val => val[$.$mol_dev_format_body],
|
|
179
|
+
body: val => val[$.$mol_dev_format_body](),
|
|
180
|
+
});
|
|
181
|
+
function $mol_dev_format_native(obj) {
|
|
182
|
+
if (typeof obj === 'undefined')
|
|
183
|
+
return $.$mol_dev_format_shade('undefined');
|
|
184
|
+
return [
|
|
185
|
+
'object',
|
|
186
|
+
{
|
|
187
|
+
object: obj,
|
|
188
|
+
config: true,
|
|
189
|
+
},
|
|
190
|
+
];
|
|
191
|
+
}
|
|
192
|
+
$.$mol_dev_format_native = $mol_dev_format_native;
|
|
193
|
+
function $mol_dev_format_auto(obj) {
|
|
194
|
+
if (obj == null)
|
|
195
|
+
return $.$mol_dev_format_shade(String(obj));
|
|
196
|
+
return [
|
|
197
|
+
'object',
|
|
198
|
+
{
|
|
199
|
+
object: obj,
|
|
200
|
+
config: false,
|
|
201
|
+
},
|
|
202
|
+
];
|
|
203
|
+
}
|
|
204
|
+
$.$mol_dev_format_auto = $mol_dev_format_auto;
|
|
205
|
+
function $mol_dev_format_element(element, style, ...content) {
|
|
206
|
+
const styles = [];
|
|
207
|
+
for (let key in style)
|
|
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);
|
|
222
|
+
}
|
|
223
|
+
$.$mol_dev_format_span = $mol_dev_format_span;
|
|
224
|
+
$.$mol_dev_format_div = $mol_dev_format_element.bind(null, 'div');
|
|
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
|
+
});
|
|
101
245
|
})($ || ($ = {}));
|
|
102
246
|
|
|
103
247
|
;
|
|
104
248
|
"use strict";
|
|
105
|
-
var
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
return
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
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;
|
|
125
295
|
}
|
|
126
|
-
catch { }
|
|
127
|
-
break;
|
|
128
296
|
}
|
|
129
297
|
else {
|
|
130
|
-
|
|
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;
|
|
131
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;
|
|
132
320
|
}
|
|
133
|
-
|
|
134
|
-
|
|
321
|
+
pub_off(sub_pos) {
|
|
322
|
+
this.data[sub_pos] = undefined;
|
|
323
|
+
this.data[sub_pos + 1] = undefined;
|
|
135
324
|
}
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
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;
|
|
139
386
|
}
|
|
140
|
-
},
|
|
141
|
-
set(target, name, value) {
|
|
142
|
-
target[name] = value;
|
|
143
|
-
return true;
|
|
144
|
-
},
|
|
145
|
-
});
|
|
146
|
-
require = (req => Object.assign(function require(name) {
|
|
147
|
-
return $node[name];
|
|
148
|
-
}, req))(require);
|
|
149
|
-
|
|
150
|
-
;
|
|
151
|
-
"use strict";
|
|
152
|
-
var $;
|
|
153
|
-
(function ($) {
|
|
154
|
-
function $mol_log3_area_lazy(event) {
|
|
155
|
-
const self = this;
|
|
156
|
-
const stack = self.$mol_log3_stack;
|
|
157
|
-
const deep = stack.length;
|
|
158
|
-
let logged = false;
|
|
159
|
-
stack.push(() => {
|
|
160
|
-
logged = true;
|
|
161
|
-
self.$mol_log3_area.call(self, event);
|
|
162
|
-
});
|
|
163
|
-
return () => {
|
|
164
|
-
if (logged)
|
|
165
|
-
self.console.groupEnd();
|
|
166
|
-
if (stack.length > deep)
|
|
167
|
-
stack.length = deep;
|
|
168
|
-
};
|
|
169
387
|
}
|
|
170
|
-
$.$
|
|
171
|
-
$.$mol_log3_stack = [];
|
|
388
|
+
$.$mol_wire_pub_sub = $mol_wire_pub_sub;
|
|
172
389
|
})($ || ($ = {}));
|
|
173
390
|
|
|
174
391
|
;
|
|
@@ -275,6 +492,16 @@ var $;
|
|
|
275
492
|
$.$mol_owning_catch = $mol_owning_catch;
|
|
276
493
|
})($ || ($ = {}));
|
|
277
494
|
|
|
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
|
+
|
|
278
505
|
;
|
|
279
506
|
"use strict";
|
|
280
507
|
|
|
@@ -353,6 +580,439 @@ var $;
|
|
|
353
580
|
$.$mol_object2 = $mol_object2;
|
|
354
581
|
})($ || ($ = {}));
|
|
355
582
|
|
|
583
|
+
;
|
|
584
|
+
"use strict";
|
|
585
|
+
var $;
|
|
586
|
+
(function ($) {
|
|
587
|
+
class $mol_after_timeout extends $mol_object2 {
|
|
588
|
+
delay;
|
|
589
|
+
task;
|
|
590
|
+
id;
|
|
591
|
+
constructor(delay, task) {
|
|
592
|
+
super();
|
|
593
|
+
this.delay = delay;
|
|
594
|
+
this.task = task;
|
|
595
|
+
this.id = setTimeout(task, delay);
|
|
596
|
+
}
|
|
597
|
+
destructor() {
|
|
598
|
+
clearTimeout(this.id);
|
|
599
|
+
}
|
|
600
|
+
}
|
|
601
|
+
$.$mol_after_timeout = $mol_after_timeout;
|
|
602
|
+
})($ || ($ = {}));
|
|
603
|
+
|
|
604
|
+
;
|
|
605
|
+
"use strict";
|
|
606
|
+
var $;
|
|
607
|
+
(function ($) {
|
|
608
|
+
class $mol_after_frame extends $mol_after_timeout {
|
|
609
|
+
task;
|
|
610
|
+
constructor(task) {
|
|
611
|
+
super(16, task);
|
|
612
|
+
this.task = task;
|
|
613
|
+
}
|
|
614
|
+
}
|
|
615
|
+
$.$mol_after_frame = $mol_after_frame;
|
|
616
|
+
})($ || ($ = {}));
|
|
617
|
+
|
|
618
|
+
;
|
|
619
|
+
"use strict";
|
|
620
|
+
var $;
|
|
621
|
+
(function ($) {
|
|
622
|
+
function $mol_promise_like(val) {
|
|
623
|
+
return val && typeof val === 'object' && 'then' in val && typeof val.then === 'function';
|
|
624
|
+
}
|
|
625
|
+
$.$mol_promise_like = $mol_promise_like;
|
|
626
|
+
})($ || ($ = {}));
|
|
627
|
+
|
|
628
|
+
;
|
|
629
|
+
"use strict";
|
|
630
|
+
var $;
|
|
631
|
+
(function ($) {
|
|
632
|
+
const handled = new WeakSet();
|
|
633
|
+
class $mol_wire_fiber extends $mol_wire_pub_sub {
|
|
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;
|
|
684
|
+
}
|
|
685
|
+
get incompleted() {
|
|
686
|
+
return $mol_promise_like(this.cache);
|
|
687
|
+
}
|
|
688
|
+
field() {
|
|
689
|
+
return this.task.name + '<>';
|
|
690
|
+
}
|
|
691
|
+
constructor(id, task, host, args) {
|
|
692
|
+
super();
|
|
693
|
+
this.task = task;
|
|
694
|
+
this.host = host;
|
|
695
|
+
if (args)
|
|
696
|
+
this.data.push(...args);
|
|
697
|
+
this.pub_from = this.sub_from = args?.length ?? 0;
|
|
698
|
+
this[Symbol.toStringTag] = id;
|
|
699
|
+
}
|
|
700
|
+
plan() {
|
|
701
|
+
$mol_wire_fiber.planning.add(this);
|
|
702
|
+
$mol_wire_fiber.plan();
|
|
703
|
+
}
|
|
704
|
+
reap() {
|
|
705
|
+
$mol_wire_fiber.reaping.add(this);
|
|
706
|
+
$mol_wire_fiber.plan();
|
|
707
|
+
}
|
|
708
|
+
toString() {
|
|
709
|
+
return this[Symbol.toStringTag];
|
|
710
|
+
}
|
|
711
|
+
toJSON() {
|
|
712
|
+
return this[Symbol.toStringTag];
|
|
713
|
+
}
|
|
714
|
+
[$mol_dev_format_head]() {
|
|
715
|
+
const cursor = {
|
|
716
|
+
[$mol_wire_cursor.stale]: '🔴',
|
|
717
|
+
[$mol_wire_cursor.doubt]: '🟡',
|
|
718
|
+
[$mol_wire_cursor.fresh]: '🟢',
|
|
719
|
+
[$mol_wire_cursor.final]: '🔵',
|
|
720
|
+
}[this.cursor] ?? this.cursor.toString();
|
|
721
|
+
return $mol_dev_format_div({}, $mol_owning_check(this, this.cache)
|
|
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));
|
|
727
|
+
}
|
|
728
|
+
get $() {
|
|
729
|
+
return (this.host ?? this.task)['$'];
|
|
730
|
+
}
|
|
731
|
+
emit(quant = $mol_wire_cursor.stale) {
|
|
732
|
+
if (this.sub_empty)
|
|
733
|
+
this.plan();
|
|
734
|
+
else
|
|
735
|
+
super.emit(quant);
|
|
736
|
+
}
|
|
737
|
+
fresh() {
|
|
738
|
+
if (this.cursor === $mol_wire_cursor.fresh)
|
|
739
|
+
return;
|
|
740
|
+
if (this.cursor === $mol_wire_cursor.final)
|
|
741
|
+
return;
|
|
742
|
+
check: if (this.cursor === $mol_wire_cursor.doubt) {
|
|
743
|
+
for (let i = this.pub_from; i < this.sub_from; i += 2) {
|
|
744
|
+
;
|
|
745
|
+
this.data[i]?.fresh();
|
|
746
|
+
if (this.cursor !== $mol_wire_cursor.doubt)
|
|
747
|
+
break check;
|
|
748
|
+
}
|
|
749
|
+
this.cursor = $mol_wire_cursor.fresh;
|
|
750
|
+
return;
|
|
751
|
+
}
|
|
752
|
+
const bu = this.track_on();
|
|
753
|
+
let result;
|
|
754
|
+
try {
|
|
755
|
+
switch (this.pub_from) {
|
|
756
|
+
case 0:
|
|
757
|
+
result = this.task.call(this.host);
|
|
758
|
+
break;
|
|
759
|
+
case 1:
|
|
760
|
+
result = this.task.call(this.host, this.data[0]);
|
|
761
|
+
break;
|
|
762
|
+
default:
|
|
763
|
+
result = this.task.call(this.host, ...this.args);
|
|
764
|
+
break;
|
|
765
|
+
}
|
|
766
|
+
if ($mol_promise_like(result) && !handled.has(result)) {
|
|
767
|
+
const put = (res) => {
|
|
768
|
+
if (this.cache === result)
|
|
769
|
+
this.put(res);
|
|
770
|
+
return res;
|
|
771
|
+
};
|
|
772
|
+
result = result.then(put, put);
|
|
773
|
+
}
|
|
774
|
+
}
|
|
775
|
+
catch (error) {
|
|
776
|
+
if (error instanceof Error || $mol_promise_like(error)) {
|
|
777
|
+
result = error;
|
|
778
|
+
}
|
|
779
|
+
else {
|
|
780
|
+
result = new Error(String(error), { cause: error });
|
|
781
|
+
}
|
|
782
|
+
if ($mol_promise_like(result) && !handled.has(result)) {
|
|
783
|
+
result = result.finally(() => {
|
|
784
|
+
if (this.cache === result)
|
|
785
|
+
this.absorb();
|
|
786
|
+
});
|
|
787
|
+
}
|
|
788
|
+
}
|
|
789
|
+
if ($mol_promise_like(result) && !handled.has(result)) {
|
|
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();
|
|
806
|
+
}
|
|
807
|
+
sync() {
|
|
808
|
+
if (!$mol_wire_fiber.warm) {
|
|
809
|
+
return this.result();
|
|
810
|
+
}
|
|
811
|
+
this.promote();
|
|
812
|
+
this.fresh();
|
|
813
|
+
if (this.cache instanceof Error) {
|
|
814
|
+
return $mol_fail_hidden(this.cache);
|
|
815
|
+
}
|
|
816
|
+
if ($mol_promise_like(this.cache)) {
|
|
817
|
+
return $mol_fail_hidden(this.cache);
|
|
818
|
+
}
|
|
819
|
+
return this.cache;
|
|
820
|
+
}
|
|
821
|
+
async async() {
|
|
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
|
+
}
|
|
835
|
+
}
|
|
836
|
+
}
|
|
837
|
+
step() {
|
|
838
|
+
return new Promise(done => {
|
|
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;
|
|
941
|
+
}
|
|
942
|
+
return true;
|
|
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;
|
|
954
|
+
}
|
|
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
|
+
}
|
|
968
|
+
function compare_pojo(left, right) {
|
|
969
|
+
const left_keys = Object.getOwnPropertyNames(left);
|
|
970
|
+
const right_keys = Object.getOwnPropertyNames(right);
|
|
971
|
+
if (!compare_array(left_keys, right_keys))
|
|
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;
|
|
984
|
+
}
|
|
985
|
+
return true;
|
|
986
|
+
}
|
|
987
|
+
function compare_primitive(left, right) {
|
|
988
|
+
return Object.is(left[Symbol.toPrimitive]('default'), right[Symbol.toPrimitive]('default'));
|
|
989
|
+
}
|
|
990
|
+
})($ || ($ = {}));
|
|
991
|
+
|
|
992
|
+
;
|
|
993
|
+
"use strict";
|
|
994
|
+
var $;
|
|
995
|
+
(function ($) {
|
|
996
|
+
function $mol_log3_area_lazy(event) {
|
|
997
|
+
const self = this;
|
|
998
|
+
const stack = self.$mol_log3_stack;
|
|
999
|
+
const deep = stack.length;
|
|
1000
|
+
let logged = false;
|
|
1001
|
+
stack.push(() => {
|
|
1002
|
+
logged = true;
|
|
1003
|
+
self.$mol_log3_area.call(self, event);
|
|
1004
|
+
});
|
|
1005
|
+
return () => {
|
|
1006
|
+
if (logged)
|
|
1007
|
+
self.console.groupEnd();
|
|
1008
|
+
if (stack.length > deep)
|
|
1009
|
+
stack.length = deep;
|
|
1010
|
+
};
|
|
1011
|
+
}
|
|
1012
|
+
$.$mol_log3_area_lazy = $mol_log3_area_lazy;
|
|
1013
|
+
$.$mol_log3_stack = [];
|
|
1014
|
+
})($ || ($ = {}));
|
|
1015
|
+
|
|
356
1016
|
;
|
|
357
1017
|
"use strict";
|
|
358
1018
|
var $;
|
|
@@ -846,6 +1506,178 @@ var $;
|
|
|
846
1506
|
$.$mol_log3_area = $mol_log3_node_make('log', 'stdout', 'area', $mol_term_color.cyan);
|
|
847
1507
|
})($ || ($ = {}));
|
|
848
1508
|
|
|
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
|
+
|
|
849
1681
|
;
|
|
850
1682
|
"use strict";
|
|
851
1683
|
var $;
|