mol_crypto_lib 0.1.1078 → 0.1.1079
Sign up to get free protection for your applications and to get access to all the features.
- 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 +2780 -1727
- package/node.test.js.map +1 -1
- package/package.json +17 -2
package/node.js
CHANGED
@@ -45,124 +45,341 @@ var $;
|
|
45
45
|
"use strict";
|
46
46
|
var $;
|
47
47
|
(function ($) {
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
48
|
+
let $mol_wire_cursor;
|
49
|
+
(function ($mol_wire_cursor) {
|
50
|
+
$mol_wire_cursor[$mol_wire_cursor["stale"] = -1] = "stale";
|
51
|
+
$mol_wire_cursor[$mol_wire_cursor["doubt"] = -2] = "doubt";
|
52
|
+
$mol_wire_cursor[$mol_wire_cursor["fresh"] = -3] = "fresh";
|
53
|
+
$mol_wire_cursor[$mol_wire_cursor["final"] = -4] = "final";
|
54
|
+
})($mol_wire_cursor = $.$mol_wire_cursor || ($.$mol_wire_cursor = {}));
|
52
55
|
})($ || ($ = {}));
|
53
56
|
|
54
57
|
;
|
55
58
|
"use strict";
|
56
59
|
var $;
|
57
60
|
(function ($) {
|
58
|
-
|
59
|
-
|
61
|
+
class $mol_wire_pub extends Object {
|
62
|
+
data = [];
|
63
|
+
static get [Symbol.species]() {
|
64
|
+
return Array;
|
65
|
+
}
|
66
|
+
sub_from = 0;
|
67
|
+
get sub_list() {
|
68
|
+
const res = [];
|
69
|
+
for (let i = this.sub_from; i < this.data.length; i += 2) {
|
70
|
+
res.push(this.data[i]);
|
71
|
+
}
|
72
|
+
return res;
|
73
|
+
}
|
74
|
+
get sub_empty() {
|
75
|
+
return this.sub_from === this.data.length;
|
76
|
+
}
|
77
|
+
sub_on(sub, pub_pos) {
|
78
|
+
const pos = this.data.length;
|
79
|
+
this.data.push(sub, pub_pos);
|
80
|
+
return pos;
|
81
|
+
}
|
82
|
+
sub_off(sub_pos) {
|
83
|
+
if (!(sub_pos < this.data.length)) {
|
84
|
+
$mol_fail(new Error(`Wrong pos ${sub_pos}`));
|
85
|
+
}
|
86
|
+
const end = this.data.length - 2;
|
87
|
+
if (sub_pos !== end) {
|
88
|
+
this.peer_move(end, sub_pos);
|
89
|
+
}
|
90
|
+
this.data.pop();
|
91
|
+
this.data.pop();
|
92
|
+
if (this.data.length === this.sub_from)
|
93
|
+
this.reap();
|
94
|
+
}
|
95
|
+
reap() { }
|
96
|
+
promote() {
|
97
|
+
$mol_wire_auto()?.track_next(this);
|
98
|
+
}
|
99
|
+
fresh() { }
|
100
|
+
complete() { }
|
101
|
+
get incompleted() {
|
102
|
+
return false;
|
103
|
+
}
|
104
|
+
emit(quant = $mol_wire_cursor.stale) {
|
105
|
+
for (let i = this.sub_from; i < this.data.length; i += 2) {
|
106
|
+
;
|
107
|
+
this.data[i].absorb(quant);
|
108
|
+
}
|
109
|
+
}
|
110
|
+
peer_move(from_pos, to_pos) {
|
111
|
+
const peer = this.data[from_pos];
|
112
|
+
const self_pos = this.data[from_pos + 1];
|
113
|
+
this.data[to_pos] = peer;
|
114
|
+
this.data[to_pos + 1] = self_pos;
|
115
|
+
peer.peer_repos(self_pos, to_pos);
|
116
|
+
}
|
117
|
+
peer_repos(peer_pos, self_pos) {
|
118
|
+
this.data[peer_pos + 1] = self_pos;
|
119
|
+
}
|
60
120
|
}
|
61
|
-
$.$
|
121
|
+
$.$mol_wire_pub = $mol_wire_pub;
|
62
122
|
})($ || ($ = {}));
|
63
123
|
|
124
|
+
;
|
125
|
+
"use strict";
|
126
|
+
|
64
127
|
;
|
65
128
|
"use strict";
|
66
129
|
var $;
|
67
130
|
(function ($) {
|
68
|
-
|
69
|
-
function $
|
70
|
-
|
71
|
-
return false;
|
72
|
-
if ($mol_promise_like(error))
|
73
|
-
$mol_fail_hidden(error);
|
74
|
-
if (catched.get(error))
|
75
|
-
return false;
|
76
|
-
catched.set(error, true);
|
77
|
-
return true;
|
131
|
+
$.$mol_wire_auto_sub = null;
|
132
|
+
function $mol_wire_auto(next = $.$mol_wire_auto_sub) {
|
133
|
+
return $.$mol_wire_auto_sub = next;
|
78
134
|
}
|
79
|
-
$.$
|
135
|
+
$.$mol_wire_auto = $mol_wire_auto;
|
136
|
+
$.$mol_wire_affected = [];
|
80
137
|
})($ || ($ = {}));
|
81
138
|
|
82
139
|
;
|
83
140
|
"use strict";
|
84
141
|
var $;
|
85
142
|
(function ($) {
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
if (!$mol_fail_catch(error))
|
90
|
-
return false;
|
91
|
-
console.error(error);
|
92
|
-
return true;
|
143
|
+
$['devtoolsFormatters'] ||= [];
|
144
|
+
function $mol_dev_format_register(config) {
|
145
|
+
$['devtoolsFormatters'].push(config);
|
93
146
|
}
|
94
|
-
$.$
|
147
|
+
$.$mol_dev_format_register = $mol_dev_format_register;
|
148
|
+
$.$mol_dev_format_head = Symbol('$mol_dev_format_head');
|
149
|
+
$.$mol_dev_format_body = Symbol('$mol_dev_format_body');
|
150
|
+
$mol_dev_format_register({
|
151
|
+
header: (val, config = false) => {
|
152
|
+
if (config)
|
153
|
+
return null;
|
154
|
+
if (!val)
|
155
|
+
return null;
|
156
|
+
if ($.$mol_dev_format_head in val) {
|
157
|
+
try {
|
158
|
+
return val[$.$mol_dev_format_head]();
|
159
|
+
}
|
160
|
+
catch (error) {
|
161
|
+
return $.$mol_dev_format_accent($mol_dev_format_native(val), '💨', $mol_dev_format_native(error), '');
|
162
|
+
}
|
163
|
+
}
|
164
|
+
if (typeof val === 'function') {
|
165
|
+
return $mol_dev_format_native(val);
|
166
|
+
}
|
167
|
+
if (Symbol.toStringTag in val) {
|
168
|
+
return $mol_dev_format_native(val);
|
169
|
+
}
|
170
|
+
return null;
|
171
|
+
},
|
172
|
+
hasBody: val => val[$.$mol_dev_format_body],
|
173
|
+
body: val => val[$.$mol_dev_format_body](),
|
174
|
+
});
|
175
|
+
function $mol_dev_format_native(obj) {
|
176
|
+
if (typeof obj === 'undefined')
|
177
|
+
return $.$mol_dev_format_shade('undefined');
|
178
|
+
return [
|
179
|
+
'object',
|
180
|
+
{
|
181
|
+
object: obj,
|
182
|
+
config: true,
|
183
|
+
},
|
184
|
+
];
|
185
|
+
}
|
186
|
+
$.$mol_dev_format_native = $mol_dev_format_native;
|
187
|
+
function $mol_dev_format_auto(obj) {
|
188
|
+
if (obj == null)
|
189
|
+
return $.$mol_dev_format_shade(String(obj));
|
190
|
+
return [
|
191
|
+
'object',
|
192
|
+
{
|
193
|
+
object: obj,
|
194
|
+
config: false,
|
195
|
+
},
|
196
|
+
];
|
197
|
+
}
|
198
|
+
$.$mol_dev_format_auto = $mol_dev_format_auto;
|
199
|
+
function $mol_dev_format_element(element, style, ...content) {
|
200
|
+
const styles = [];
|
201
|
+
for (let key in style)
|
202
|
+
styles.push(`${key} : ${style[key]}`);
|
203
|
+
return [
|
204
|
+
element,
|
205
|
+
{
|
206
|
+
style: styles.join(' ; '),
|
207
|
+
},
|
208
|
+
...content,
|
209
|
+
];
|
210
|
+
}
|
211
|
+
$.$mol_dev_format_element = $mol_dev_format_element;
|
212
|
+
function $mol_dev_format_span(style, ...content) {
|
213
|
+
return $mol_dev_format_element('span', {
|
214
|
+
...style,
|
215
|
+
}, ...content);
|
216
|
+
}
|
217
|
+
$.$mol_dev_format_span = $mol_dev_format_span;
|
218
|
+
$.$mol_dev_format_div = $mol_dev_format_element.bind(null, 'div');
|
219
|
+
$.$mol_dev_format_ol = $mol_dev_format_element.bind(null, 'ol');
|
220
|
+
$.$mol_dev_format_li = $mol_dev_format_element.bind(null, 'li');
|
221
|
+
$.$mol_dev_format_table = $mol_dev_format_element.bind(null, 'table');
|
222
|
+
$.$mol_dev_format_tr = $mol_dev_format_element.bind(null, 'tr');
|
223
|
+
$.$mol_dev_format_td = $mol_dev_format_element.bind(null, 'td');
|
224
|
+
$.$mol_dev_format_accent = $mol_dev_format_span.bind(null, {
|
225
|
+
'color': 'magenta',
|
226
|
+
});
|
227
|
+
$.$mol_dev_format_strong = $mol_dev_format_span.bind(null, {
|
228
|
+
'font-weight': 'bold',
|
229
|
+
});
|
230
|
+
$.$mol_dev_format_string = $mol_dev_format_span.bind(null, {
|
231
|
+
'color': 'green',
|
232
|
+
});
|
233
|
+
$.$mol_dev_format_shade = $mol_dev_format_span.bind(null, {
|
234
|
+
'color': 'gray',
|
235
|
+
});
|
236
|
+
$.$mol_dev_format_indent = $.$mol_dev_format_div.bind(null, {
|
237
|
+
'margin-left': '13px'
|
238
|
+
});
|
95
239
|
})($ || ($ = {}));
|
96
240
|
|
97
241
|
;
|
98
242
|
"use strict";
|
99
|
-
var
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
return
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
243
|
+
var $;
|
244
|
+
(function ($) {
|
245
|
+
class $mol_wire_pub_sub extends $mol_wire_pub {
|
246
|
+
pub_from = 0;
|
247
|
+
cursor = $mol_wire_cursor.stale;
|
248
|
+
get temp() {
|
249
|
+
return false;
|
250
|
+
}
|
251
|
+
get pub_list() {
|
252
|
+
const res = [];
|
253
|
+
const max = this.cursor >= 0 ? this.cursor : this.sub_from;
|
254
|
+
for (let i = this.pub_from; i < max; i += 2) {
|
255
|
+
if (this.data[i])
|
256
|
+
res.push(this.data[i]);
|
257
|
+
}
|
258
|
+
return res;
|
259
|
+
}
|
260
|
+
track_on() {
|
261
|
+
this.cursor = this.pub_from;
|
262
|
+
const sub = $mol_wire_auto();
|
263
|
+
$mol_wire_auto(this);
|
264
|
+
return sub;
|
265
|
+
}
|
266
|
+
promote() {
|
267
|
+
if (this.cursor >= this.pub_from) {
|
268
|
+
$mol_fail(new Error('Circular subscription'));
|
269
|
+
}
|
270
|
+
super.promote();
|
271
|
+
}
|
272
|
+
track_next(pub) {
|
273
|
+
if (this.cursor < 0)
|
274
|
+
$mol_fail(new Error('Promo to non begun sub'));
|
275
|
+
if (this.cursor < this.sub_from) {
|
276
|
+
const next = this.data[this.cursor];
|
277
|
+
if (pub === undefined)
|
278
|
+
return next ?? null;
|
279
|
+
if (next === pub) {
|
280
|
+
this.cursor += 2;
|
281
|
+
return next;
|
282
|
+
}
|
283
|
+
if (next) {
|
284
|
+
if (this.sub_from < this.data.length) {
|
285
|
+
this.peer_move(this.sub_from, this.data.length);
|
286
|
+
}
|
287
|
+
this.peer_move(this.cursor, this.sub_from);
|
288
|
+
this.sub_from += 2;
|
119
289
|
}
|
120
|
-
catch { }
|
121
|
-
break;
|
122
290
|
}
|
123
291
|
else {
|
124
|
-
|
292
|
+
if (pub === undefined)
|
293
|
+
return null;
|
294
|
+
if (this.sub_from < this.data.length) {
|
295
|
+
this.peer_move(this.sub_from, this.data.length);
|
296
|
+
}
|
297
|
+
this.sub_from += 2;
|
298
|
+
}
|
299
|
+
this.data[this.cursor] = pub;
|
300
|
+
this.data[this.cursor + 1] = pub.sub_on(this, this.cursor);
|
301
|
+
this.cursor += 2;
|
302
|
+
return pub;
|
303
|
+
}
|
304
|
+
track_off(sub) {
|
305
|
+
$mol_wire_auto(sub);
|
306
|
+
if (this.cursor < 0) {
|
307
|
+
$mol_fail(new Error('End of non begun sub'));
|
125
308
|
}
|
309
|
+
for (let cursor = this.pub_from; cursor < this.cursor; cursor += 2) {
|
310
|
+
const pub = this.data[cursor];
|
311
|
+
pub.fresh();
|
312
|
+
}
|
313
|
+
this.cursor = $mol_wire_cursor.fresh;
|
314
|
+
}
|
315
|
+
pub_off(sub_pos) {
|
316
|
+
this.data[sub_pos] = undefined;
|
317
|
+
this.data[sub_pos + 1] = undefined;
|
318
|
+
}
|
319
|
+
destructor() {
|
320
|
+
for (let cursor = this.data.length - 2; cursor >= this.sub_from; cursor -= 2) {
|
321
|
+
const sub = this.data[cursor];
|
322
|
+
const pos = this.data[cursor + 1];
|
323
|
+
sub.pub_off(pos);
|
324
|
+
this.data.pop();
|
325
|
+
this.data.pop();
|
326
|
+
}
|
327
|
+
this.cursor = this.pub_from;
|
328
|
+
this.track_cut();
|
329
|
+
this.cursor = $mol_wire_cursor.final;
|
126
330
|
}
|
127
|
-
|
128
|
-
|
331
|
+
track_cut() {
|
332
|
+
if (this.cursor < this.pub_from) {
|
333
|
+
$mol_fail(new Error('Cut of non begun sub'));
|
334
|
+
}
|
335
|
+
let tail = 0;
|
336
|
+
for (let cursor = this.cursor; cursor < this.sub_from; cursor += 2) {
|
337
|
+
const pub = this.data[cursor];
|
338
|
+
pub?.sub_off(this.data[cursor + 1]);
|
339
|
+
if (this.sub_from < this.data.length) {
|
340
|
+
this.peer_move(this.data.length - 2, cursor);
|
341
|
+
this.data.pop();
|
342
|
+
this.data.pop();
|
343
|
+
}
|
344
|
+
else {
|
345
|
+
++tail;
|
346
|
+
}
|
347
|
+
}
|
348
|
+
for (; tail; --tail) {
|
349
|
+
this.data.pop();
|
350
|
+
this.data.pop();
|
351
|
+
}
|
352
|
+
this.sub_from = this.cursor;
|
353
|
+
}
|
354
|
+
complete() { }
|
355
|
+
complete_pubs() {
|
356
|
+
const limit = this.cursor < 0 ? this.sub_from : this.cursor;
|
357
|
+
for (let cursor = this.pub_from; cursor < limit; cursor += 2) {
|
358
|
+
const pub = this.data[cursor];
|
359
|
+
if (pub?.incompleted)
|
360
|
+
return;
|
361
|
+
}
|
362
|
+
for (let cursor = this.pub_from; cursor < limit; cursor += 2) {
|
363
|
+
const pub = this.data[cursor];
|
364
|
+
pub?.complete();
|
365
|
+
}
|
129
366
|
}
|
130
|
-
|
131
|
-
|
132
|
-
|
367
|
+
absorb(quant = $mol_wire_cursor.stale) {
|
368
|
+
if (this.cursor === $mol_wire_cursor.final)
|
369
|
+
return;
|
370
|
+
if (this.cursor >= quant)
|
371
|
+
return;
|
372
|
+
this.cursor = quant;
|
373
|
+
this.emit($mol_wire_cursor.doubt);
|
374
|
+
}
|
375
|
+
[$mol_dev_format_head]() {
|
376
|
+
return $mol_dev_format_native(this);
|
377
|
+
}
|
378
|
+
get pub_empty() {
|
379
|
+
return this.sub_from === this.pub_from;
|
133
380
|
}
|
134
|
-
},
|
135
|
-
set(target, name, value) {
|
136
|
-
target[name] = value;
|
137
|
-
return true;
|
138
|
-
},
|
139
|
-
});
|
140
|
-
require = (req => Object.assign(function require(name) {
|
141
|
-
return $node[name];
|
142
|
-
}, req))(require);
|
143
|
-
|
144
|
-
;
|
145
|
-
"use strict";
|
146
|
-
var $;
|
147
|
-
(function ($) {
|
148
|
-
function $mol_log3_area_lazy(event) {
|
149
|
-
const self = this;
|
150
|
-
const stack = self.$mol_log3_stack;
|
151
|
-
const deep = stack.length;
|
152
|
-
let logged = false;
|
153
|
-
stack.push(() => {
|
154
|
-
logged = true;
|
155
|
-
self.$mol_log3_area.call(self, event);
|
156
|
-
});
|
157
|
-
return () => {
|
158
|
-
if (logged)
|
159
|
-
self.console.groupEnd();
|
160
|
-
if (stack.length > deep)
|
161
|
-
stack.length = deep;
|
162
|
-
};
|
163
381
|
}
|
164
|
-
$.$
|
165
|
-
$.$mol_log3_stack = [];
|
382
|
+
$.$mol_wire_pub_sub = $mol_wire_pub_sub;
|
166
383
|
})($ || ($ = {}));
|
167
384
|
|
168
385
|
;
|
@@ -269,6 +486,16 @@ var $;
|
|
269
486
|
$.$mol_owning_catch = $mol_owning_catch;
|
270
487
|
})($ || ($ = {}));
|
271
488
|
|
489
|
+
;
|
490
|
+
"use strict";
|
491
|
+
var $;
|
492
|
+
(function ($) {
|
493
|
+
function $mol_fail_hidden(error) {
|
494
|
+
throw error;
|
495
|
+
}
|
496
|
+
$.$mol_fail_hidden = $mol_fail_hidden;
|
497
|
+
})($ || ($ = {}));
|
498
|
+
|
272
499
|
;
|
273
500
|
"use strict";
|
274
501
|
|
@@ -347,6 +574,439 @@ var $;
|
|
347
574
|
$.$mol_object2 = $mol_object2;
|
348
575
|
})($ || ($ = {}));
|
349
576
|
|
577
|
+
;
|
578
|
+
"use strict";
|
579
|
+
var $;
|
580
|
+
(function ($) {
|
581
|
+
class $mol_after_timeout extends $mol_object2 {
|
582
|
+
delay;
|
583
|
+
task;
|
584
|
+
id;
|
585
|
+
constructor(delay, task) {
|
586
|
+
super();
|
587
|
+
this.delay = delay;
|
588
|
+
this.task = task;
|
589
|
+
this.id = setTimeout(task, delay);
|
590
|
+
}
|
591
|
+
destructor() {
|
592
|
+
clearTimeout(this.id);
|
593
|
+
}
|
594
|
+
}
|
595
|
+
$.$mol_after_timeout = $mol_after_timeout;
|
596
|
+
})($ || ($ = {}));
|
597
|
+
|
598
|
+
;
|
599
|
+
"use strict";
|
600
|
+
var $;
|
601
|
+
(function ($) {
|
602
|
+
class $mol_after_frame extends $mol_after_timeout {
|
603
|
+
task;
|
604
|
+
constructor(task) {
|
605
|
+
super(16, task);
|
606
|
+
this.task = task;
|
607
|
+
}
|
608
|
+
}
|
609
|
+
$.$mol_after_frame = $mol_after_frame;
|
610
|
+
})($ || ($ = {}));
|
611
|
+
|
612
|
+
;
|
613
|
+
"use strict";
|
614
|
+
var $;
|
615
|
+
(function ($) {
|
616
|
+
function $mol_promise_like(val) {
|
617
|
+
return val && typeof val === 'object' && 'then' in val && typeof val.then === 'function';
|
618
|
+
}
|
619
|
+
$.$mol_promise_like = $mol_promise_like;
|
620
|
+
})($ || ($ = {}));
|
621
|
+
|
622
|
+
;
|
623
|
+
"use strict";
|
624
|
+
var $;
|
625
|
+
(function ($) {
|
626
|
+
const handled = new WeakSet();
|
627
|
+
class $mol_wire_fiber extends $mol_wire_pub_sub {
|
628
|
+
task;
|
629
|
+
host;
|
630
|
+
static warm = true;
|
631
|
+
static planning = new Set();
|
632
|
+
static reaping = new Set();
|
633
|
+
static plan_task = null;
|
634
|
+
static plan() {
|
635
|
+
if (this.plan_task)
|
636
|
+
return;
|
637
|
+
this.plan_task = new $mol_after_frame(() => {
|
638
|
+
try {
|
639
|
+
this.sync();
|
640
|
+
}
|
641
|
+
finally {
|
642
|
+
$mol_wire_fiber.plan_task = null;
|
643
|
+
}
|
644
|
+
});
|
645
|
+
}
|
646
|
+
static sync() {
|
647
|
+
while (this.planning.size) {
|
648
|
+
for (const fiber of this.planning) {
|
649
|
+
this.planning.delete(fiber);
|
650
|
+
if (fiber.cursor >= 0)
|
651
|
+
continue;
|
652
|
+
if (fiber.cursor === $mol_wire_cursor.final)
|
653
|
+
continue;
|
654
|
+
fiber.fresh();
|
655
|
+
}
|
656
|
+
}
|
657
|
+
while (this.reaping.size) {
|
658
|
+
const fibers = this.reaping;
|
659
|
+
this.reaping = new Set;
|
660
|
+
for (const fiber of fibers) {
|
661
|
+
if (!fiber.sub_empty)
|
662
|
+
continue;
|
663
|
+
fiber.destructor();
|
664
|
+
}
|
665
|
+
}
|
666
|
+
}
|
667
|
+
[Symbol.toStringTag];
|
668
|
+
cache = undefined;
|
669
|
+
get args() {
|
670
|
+
return this.data.slice(0, this.pub_from);
|
671
|
+
}
|
672
|
+
result() {
|
673
|
+
if ($mol_promise_like(this.cache))
|
674
|
+
return;
|
675
|
+
if (this.cache instanceof Error)
|
676
|
+
return;
|
677
|
+
return this.cache;
|
678
|
+
}
|
679
|
+
get incompleted() {
|
680
|
+
return $mol_promise_like(this.cache);
|
681
|
+
}
|
682
|
+
field() {
|
683
|
+
return this.task.name + '<>';
|
684
|
+
}
|
685
|
+
constructor(id, task, host, args) {
|
686
|
+
super();
|
687
|
+
this.task = task;
|
688
|
+
this.host = host;
|
689
|
+
if (args)
|
690
|
+
this.data.push(...args);
|
691
|
+
this.pub_from = this.sub_from = args?.length ?? 0;
|
692
|
+
this[Symbol.toStringTag] = id;
|
693
|
+
}
|
694
|
+
plan() {
|
695
|
+
$mol_wire_fiber.planning.add(this);
|
696
|
+
$mol_wire_fiber.plan();
|
697
|
+
}
|
698
|
+
reap() {
|
699
|
+
$mol_wire_fiber.reaping.add(this);
|
700
|
+
$mol_wire_fiber.plan();
|
701
|
+
}
|
702
|
+
toString() {
|
703
|
+
return this[Symbol.toStringTag];
|
704
|
+
}
|
705
|
+
toJSON() {
|
706
|
+
return this[Symbol.toStringTag];
|
707
|
+
}
|
708
|
+
[$mol_dev_format_head]() {
|
709
|
+
const cursor = {
|
710
|
+
[$mol_wire_cursor.stale]: '🔴',
|
711
|
+
[$mol_wire_cursor.doubt]: '🟡',
|
712
|
+
[$mol_wire_cursor.fresh]: '🟢',
|
713
|
+
[$mol_wire_cursor.final]: '🔵',
|
714
|
+
}[this.cursor] ?? this.cursor.toString();
|
715
|
+
return $mol_dev_format_div({}, $mol_owning_check(this, this.cache)
|
716
|
+
? $mol_dev_format_auto({
|
717
|
+
[$mol_dev_format_head]: () => $mol_dev_format_shade(cursor),
|
718
|
+
[$mol_dev_format_body]: () => $mol_dev_format_native(this),
|
719
|
+
})
|
720
|
+
: $mol_dev_format_shade($mol_dev_format_native(this), cursor), $mol_dev_format_auto(this.cache));
|
721
|
+
}
|
722
|
+
get $() {
|
723
|
+
return (this.host ?? this.task)['$'];
|
724
|
+
}
|
725
|
+
emit(quant = $mol_wire_cursor.stale) {
|
726
|
+
if (this.sub_empty)
|
727
|
+
this.plan();
|
728
|
+
else
|
729
|
+
super.emit(quant);
|
730
|
+
}
|
731
|
+
fresh() {
|
732
|
+
if (this.cursor === $mol_wire_cursor.fresh)
|
733
|
+
return;
|
734
|
+
if (this.cursor === $mol_wire_cursor.final)
|
735
|
+
return;
|
736
|
+
check: if (this.cursor === $mol_wire_cursor.doubt) {
|
737
|
+
for (let i = this.pub_from; i < this.sub_from; i += 2) {
|
738
|
+
;
|
739
|
+
this.data[i]?.fresh();
|
740
|
+
if (this.cursor !== $mol_wire_cursor.doubt)
|
741
|
+
break check;
|
742
|
+
}
|
743
|
+
this.cursor = $mol_wire_cursor.fresh;
|
744
|
+
return;
|
745
|
+
}
|
746
|
+
const bu = this.track_on();
|
747
|
+
let result;
|
748
|
+
try {
|
749
|
+
switch (this.pub_from) {
|
750
|
+
case 0:
|
751
|
+
result = this.task.call(this.host);
|
752
|
+
break;
|
753
|
+
case 1:
|
754
|
+
result = this.task.call(this.host, this.data[0]);
|
755
|
+
break;
|
756
|
+
default:
|
757
|
+
result = this.task.call(this.host, ...this.args);
|
758
|
+
break;
|
759
|
+
}
|
760
|
+
if ($mol_promise_like(result) && !handled.has(result)) {
|
761
|
+
const put = (res) => {
|
762
|
+
if (this.cache === result)
|
763
|
+
this.put(res);
|
764
|
+
return res;
|
765
|
+
};
|
766
|
+
result = result.then(put, put);
|
767
|
+
}
|
768
|
+
}
|
769
|
+
catch (error) {
|
770
|
+
if (error instanceof Error || $mol_promise_like(error)) {
|
771
|
+
result = error;
|
772
|
+
}
|
773
|
+
else {
|
774
|
+
result = new Error(String(error), { cause: error });
|
775
|
+
}
|
776
|
+
if ($mol_promise_like(result) && !handled.has(result)) {
|
777
|
+
result = result.finally(() => {
|
778
|
+
if (this.cache === result)
|
779
|
+
this.absorb();
|
780
|
+
});
|
781
|
+
}
|
782
|
+
}
|
783
|
+
if ($mol_promise_like(result) && !handled.has(result)) {
|
784
|
+
result = Object.assign(result, {
|
785
|
+
destructor: result['destructor'] ?? (() => { })
|
786
|
+
});
|
787
|
+
handled.add(result);
|
788
|
+
const error = new Error(`Promise in ${this}`);
|
789
|
+
Object.defineProperty(result, 'stack', { get: () => error.stack });
|
790
|
+
}
|
791
|
+
if (!$mol_promise_like(result)) {
|
792
|
+
this.track_cut();
|
793
|
+
}
|
794
|
+
this.track_off(bu);
|
795
|
+
this.put(result);
|
796
|
+
}
|
797
|
+
refresh() {
|
798
|
+
this.cursor = $mol_wire_cursor.stale;
|
799
|
+
this.fresh();
|
800
|
+
}
|
801
|
+
sync() {
|
802
|
+
if (!$mol_wire_fiber.warm) {
|
803
|
+
return this.result();
|
804
|
+
}
|
805
|
+
this.promote();
|
806
|
+
this.fresh();
|
807
|
+
if (this.cache instanceof Error) {
|
808
|
+
return $mol_fail_hidden(this.cache);
|
809
|
+
}
|
810
|
+
if ($mol_promise_like(this.cache)) {
|
811
|
+
return $mol_fail_hidden(this.cache);
|
812
|
+
}
|
813
|
+
return this.cache;
|
814
|
+
}
|
815
|
+
async async() {
|
816
|
+
while (true) {
|
817
|
+
this.fresh();
|
818
|
+
if (this.cache instanceof Error) {
|
819
|
+
$mol_fail_hidden(this.cache);
|
820
|
+
}
|
821
|
+
if (!$mol_promise_like(this.cache))
|
822
|
+
return this.cache;
|
823
|
+
await Promise.race([this.cache, this.step()]);
|
824
|
+
if (!$mol_promise_like(this.cache))
|
825
|
+
return this.cache;
|
826
|
+
if (this.cursor === $mol_wire_cursor.final) {
|
827
|
+
await new Promise(() => { });
|
828
|
+
}
|
829
|
+
}
|
830
|
+
}
|
831
|
+
step() {
|
832
|
+
return new Promise(done => {
|
833
|
+
const sub = new $mol_wire_pub_sub;
|
834
|
+
const prev = sub.track_on();
|
835
|
+
sub.track_next(this);
|
836
|
+
sub.track_off(prev);
|
837
|
+
sub.absorb = () => {
|
838
|
+
done(null);
|
839
|
+
sub.destructor();
|
840
|
+
};
|
841
|
+
});
|
842
|
+
}
|
843
|
+
}
|
844
|
+
$.$mol_wire_fiber = $mol_wire_fiber;
|
845
|
+
})($ || ($ = {}));
|
846
|
+
|
847
|
+
;
|
848
|
+
"use strict";
|
849
|
+
var $;
|
850
|
+
(function ($) {
|
851
|
+
$.$mol_compare_deep_cache = new WeakMap();
|
852
|
+
function $mol_compare_deep(left, right) {
|
853
|
+
if (Object.is(left, right))
|
854
|
+
return true;
|
855
|
+
if (left === null)
|
856
|
+
return false;
|
857
|
+
if (right === null)
|
858
|
+
return false;
|
859
|
+
if (typeof left !== 'object')
|
860
|
+
return false;
|
861
|
+
if (typeof right !== 'object')
|
862
|
+
return false;
|
863
|
+
const left_proto = Reflect.getPrototypeOf(left);
|
864
|
+
const right_proto = Reflect.getPrototypeOf(right);
|
865
|
+
if (left_proto !== right_proto)
|
866
|
+
return false;
|
867
|
+
if (left instanceof Boolean)
|
868
|
+
return Object.is(left.valueOf(), right['valueOf']());
|
869
|
+
if (left instanceof Number)
|
870
|
+
return Object.is(left.valueOf(), right['valueOf']());
|
871
|
+
if (left instanceof String)
|
872
|
+
return Object.is(left.valueOf(), right['valueOf']());
|
873
|
+
if (left instanceof Date)
|
874
|
+
return Object.is(left.valueOf(), right['valueOf']());
|
875
|
+
if (left instanceof RegExp)
|
876
|
+
return left.source === right.source && left.flags === right.flags;
|
877
|
+
if (left instanceof Error)
|
878
|
+
return left.message === right.message && left.stack === right.stack;
|
879
|
+
let left_cache = $.$mol_compare_deep_cache.get(left);
|
880
|
+
if (left_cache) {
|
881
|
+
const right_cache = left_cache.get(right);
|
882
|
+
if (typeof right_cache === 'boolean')
|
883
|
+
return right_cache;
|
884
|
+
}
|
885
|
+
else {
|
886
|
+
left_cache = new WeakMap([[right, true]]);
|
887
|
+
$.$mol_compare_deep_cache.set(left, left_cache);
|
888
|
+
}
|
889
|
+
let result;
|
890
|
+
try {
|
891
|
+
if (!left_proto)
|
892
|
+
result = compare_pojo(left, right);
|
893
|
+
else if (!Reflect.getPrototypeOf(left_proto))
|
894
|
+
result = compare_pojo(left, right);
|
895
|
+
else if (Symbol.toPrimitive in left)
|
896
|
+
result = compare_primitive(left, right);
|
897
|
+
else if (Array.isArray(left))
|
898
|
+
result = compare_array(left, right);
|
899
|
+
else if (left instanceof Set)
|
900
|
+
result = compare_set(left, right);
|
901
|
+
else if (left instanceof Map)
|
902
|
+
result = compare_map(left, right);
|
903
|
+
else if (ArrayBuffer.isView(left))
|
904
|
+
result = compare_buffer(left, right);
|
905
|
+
else if (Symbol.iterator in left)
|
906
|
+
result = compare_iterator(left[Symbol.iterator](), right[Symbol.iterator]());
|
907
|
+
else
|
908
|
+
result = false;
|
909
|
+
}
|
910
|
+
finally {
|
911
|
+
left_cache.set(right, result);
|
912
|
+
}
|
913
|
+
return result;
|
914
|
+
}
|
915
|
+
$.$mol_compare_deep = $mol_compare_deep;
|
916
|
+
function compare_array(left, right) {
|
917
|
+
const len = left.length;
|
918
|
+
if (len !== right.length)
|
919
|
+
return false;
|
920
|
+
for (let i = 0; i < len; ++i) {
|
921
|
+
if (!$mol_compare_deep(left[i], right[i]))
|
922
|
+
return false;
|
923
|
+
}
|
924
|
+
return true;
|
925
|
+
}
|
926
|
+
function compare_buffer(left, right) {
|
927
|
+
const len = left.byteLength;
|
928
|
+
if (len !== right.byteLength)
|
929
|
+
return false;
|
930
|
+
if (left instanceof DataView)
|
931
|
+
return compare_buffer(new Uint8Array(left.buffer, left.byteOffset, left.byteLength), new Uint8Array(right.buffer, left.byteOffset, left.byteLength));
|
932
|
+
for (let i = 0; i < len; ++i) {
|
933
|
+
if (left[i] !== right[i])
|
934
|
+
return false;
|
935
|
+
}
|
936
|
+
return true;
|
937
|
+
}
|
938
|
+
function compare_iterator(left, right) {
|
939
|
+
while (true) {
|
940
|
+
const left_next = left.next();
|
941
|
+
const right_next = right.next();
|
942
|
+
if (left_next.done !== right_next.done)
|
943
|
+
return false;
|
944
|
+
if (left_next.done)
|
945
|
+
break;
|
946
|
+
if (!$mol_compare_deep(left_next.value, right_next.value))
|
947
|
+
return false;
|
948
|
+
}
|
949
|
+
return true;
|
950
|
+
}
|
951
|
+
function compare_set(left, right) {
|
952
|
+
if (left.size !== right.size)
|
953
|
+
return false;
|
954
|
+
return compare_iterator(left.values(), right.values());
|
955
|
+
}
|
956
|
+
function compare_map(left, right) {
|
957
|
+
if (left.size !== right.size)
|
958
|
+
return false;
|
959
|
+
return compare_iterator(left.keys(), right.keys())
|
960
|
+
&& compare_iterator(left.values(), right.values());
|
961
|
+
}
|
962
|
+
function compare_pojo(left, right) {
|
963
|
+
const left_keys = Object.getOwnPropertyNames(left);
|
964
|
+
const right_keys = Object.getOwnPropertyNames(right);
|
965
|
+
if (!compare_array(left_keys, right_keys))
|
966
|
+
return false;
|
967
|
+
for (let key of left_keys) {
|
968
|
+
if (!$mol_compare_deep(left[key], right[key]))
|
969
|
+
return false;
|
970
|
+
}
|
971
|
+
const left_syms = Object.getOwnPropertySymbols(left);
|
972
|
+
const right_syms = Object.getOwnPropertySymbols(right);
|
973
|
+
if (!compare_array(left_syms, right_syms))
|
974
|
+
return false;
|
975
|
+
for (let key of left_syms) {
|
976
|
+
if (!$mol_compare_deep(left[key], right[key]))
|
977
|
+
return false;
|
978
|
+
}
|
979
|
+
return true;
|
980
|
+
}
|
981
|
+
function compare_primitive(left, right) {
|
982
|
+
return Object.is(left[Symbol.toPrimitive]('default'), right[Symbol.toPrimitive]('default'));
|
983
|
+
}
|
984
|
+
})($ || ($ = {}));
|
985
|
+
|
986
|
+
;
|
987
|
+
"use strict";
|
988
|
+
var $;
|
989
|
+
(function ($) {
|
990
|
+
function $mol_log3_area_lazy(event) {
|
991
|
+
const self = this;
|
992
|
+
const stack = self.$mol_log3_stack;
|
993
|
+
const deep = stack.length;
|
994
|
+
let logged = false;
|
995
|
+
stack.push(() => {
|
996
|
+
logged = true;
|
997
|
+
self.$mol_log3_area.call(self, event);
|
998
|
+
});
|
999
|
+
return () => {
|
1000
|
+
if (logged)
|
1001
|
+
self.console.groupEnd();
|
1002
|
+
if (stack.length > deep)
|
1003
|
+
stack.length = deep;
|
1004
|
+
};
|
1005
|
+
}
|
1006
|
+
$.$mol_log3_area_lazy = $mol_log3_area_lazy;
|
1007
|
+
$.$mol_log3_stack = [];
|
1008
|
+
})($ || ($ = {}));
|
1009
|
+
|
350
1010
|
;
|
351
1011
|
"use strict";
|
352
1012
|
var $;
|
@@ -840,6 +1500,178 @@ var $;
|
|
840
1500
|
$.$mol_log3_area = $mol_log3_node_make('log', 'stdout', 'area', $mol_term_color.cyan);
|
841
1501
|
})($ || ($ = {}));
|
842
1502
|
|
1503
|
+
;
|
1504
|
+
"use strict";
|
1505
|
+
var $;
|
1506
|
+
(function ($) {
|
1507
|
+
class $mol_wire_task extends $mol_wire_fiber {
|
1508
|
+
static getter(task) {
|
1509
|
+
return function $mol_wire_task_get(host, args) {
|
1510
|
+
const sub = $mol_wire_auto();
|
1511
|
+
const existen = sub?.track_next();
|
1512
|
+
reuse: if (existen) {
|
1513
|
+
if (!existen.temp)
|
1514
|
+
break reuse;
|
1515
|
+
if (existen.host !== host)
|
1516
|
+
break reuse;
|
1517
|
+
if (existen.task !== task)
|
1518
|
+
break reuse;
|
1519
|
+
if (!$mol_compare_deep(existen.args, args))
|
1520
|
+
break reuse;
|
1521
|
+
return existen;
|
1522
|
+
}
|
1523
|
+
const next = new $mol_wire_task(`${host?.[Symbol.toStringTag] ?? host}.${task.name}<#>`, task, host, args);
|
1524
|
+
if (existen?.temp) {
|
1525
|
+
$$.$mol_log3_warn({
|
1526
|
+
place: '$mol_wire_task',
|
1527
|
+
message: `Non idempotency`,
|
1528
|
+
existen,
|
1529
|
+
next,
|
1530
|
+
hint: 'Ignore it',
|
1531
|
+
});
|
1532
|
+
}
|
1533
|
+
return next;
|
1534
|
+
};
|
1535
|
+
}
|
1536
|
+
get temp() {
|
1537
|
+
return true;
|
1538
|
+
}
|
1539
|
+
complete() {
|
1540
|
+
if ($mol_promise_like(this.cache))
|
1541
|
+
return;
|
1542
|
+
this.destructor();
|
1543
|
+
}
|
1544
|
+
put(next) {
|
1545
|
+
const prev = this.cache;
|
1546
|
+
this.cache = next;
|
1547
|
+
if ($mol_promise_like(next)) {
|
1548
|
+
this.cursor = $mol_wire_cursor.fresh;
|
1549
|
+
if (next !== prev)
|
1550
|
+
this.emit();
|
1551
|
+
return next;
|
1552
|
+
}
|
1553
|
+
this.cursor = $mol_wire_cursor.final;
|
1554
|
+
if (this.sub_empty)
|
1555
|
+
this.destructor();
|
1556
|
+
else if (next !== prev)
|
1557
|
+
this.emit();
|
1558
|
+
return next;
|
1559
|
+
}
|
1560
|
+
}
|
1561
|
+
$.$mol_wire_task = $mol_wire_task;
|
1562
|
+
})($ || ($ = {}));
|
1563
|
+
|
1564
|
+
;
|
1565
|
+
"use strict";
|
1566
|
+
var $;
|
1567
|
+
(function ($) {
|
1568
|
+
function $mol_wire_sync(obj) {
|
1569
|
+
return new Proxy(obj, {
|
1570
|
+
get(obj, field) {
|
1571
|
+
const val = obj[field];
|
1572
|
+
if (typeof val !== 'function')
|
1573
|
+
return val;
|
1574
|
+
const temp = $mol_wire_task.getter(val);
|
1575
|
+
return function $mol_wire_sync(...args) {
|
1576
|
+
const fiber = temp(obj, args);
|
1577
|
+
return fiber.sync();
|
1578
|
+
};
|
1579
|
+
},
|
1580
|
+
apply(obj, self, args) {
|
1581
|
+
const temp = $mol_wire_task.getter(obj);
|
1582
|
+
const fiber = temp(self, args);
|
1583
|
+
return fiber.sync();
|
1584
|
+
},
|
1585
|
+
});
|
1586
|
+
}
|
1587
|
+
$.$mol_wire_sync = $mol_wire_sync;
|
1588
|
+
})($ || ($ = {}));
|
1589
|
+
|
1590
|
+
;
|
1591
|
+
"use strict";
|
1592
|
+
var $;
|
1593
|
+
(function ($) {
|
1594
|
+
const catched = new WeakMap();
|
1595
|
+
function $mol_fail_catch(error) {
|
1596
|
+
if (typeof error !== 'object')
|
1597
|
+
return false;
|
1598
|
+
if ($mol_promise_like(error))
|
1599
|
+
$mol_fail_hidden(error);
|
1600
|
+
if (catched.get(error))
|
1601
|
+
return false;
|
1602
|
+
catched.set(error, true);
|
1603
|
+
return true;
|
1604
|
+
}
|
1605
|
+
$.$mol_fail_catch = $mol_fail_catch;
|
1606
|
+
})($ || ($ = {}));
|
1607
|
+
|
1608
|
+
;
|
1609
|
+
"use strict";
|
1610
|
+
var $;
|
1611
|
+
(function ($) {
|
1612
|
+
function $mol_fail_log(error) {
|
1613
|
+
if ($mol_promise_like(error))
|
1614
|
+
return false;
|
1615
|
+
if (!$mol_fail_catch(error))
|
1616
|
+
return false;
|
1617
|
+
console.error(error);
|
1618
|
+
return true;
|
1619
|
+
}
|
1620
|
+
$.$mol_fail_log = $mol_fail_log;
|
1621
|
+
})($ || ($ = {}));
|
1622
|
+
|
1623
|
+
;
|
1624
|
+
"use strict";
|
1625
|
+
var $node = new Proxy({ require }, {
|
1626
|
+
get(target, name, wrapper) {
|
1627
|
+
if (target[name])
|
1628
|
+
return target[name];
|
1629
|
+
const mod = target.require('module');
|
1630
|
+
if (mod.builtinModules.indexOf(name) >= 0)
|
1631
|
+
return target.require(name);
|
1632
|
+
if (name[0] === '.')
|
1633
|
+
return target.require(name);
|
1634
|
+
const path = target.require('path');
|
1635
|
+
const fs = target.require('fs');
|
1636
|
+
let dir = path.resolve('.');
|
1637
|
+
const suffix = `./node_modules/${name}`;
|
1638
|
+
const $$ = $;
|
1639
|
+
while (!fs.existsSync(path.join(dir, suffix))) {
|
1640
|
+
const parent = path.resolve(dir, '..');
|
1641
|
+
if (parent === dir) {
|
1642
|
+
$$.$mol_exec('.', 'npm', 'install', '--omit=dev', name);
|
1643
|
+
try {
|
1644
|
+
$$.$mol_exec('.', 'npm', 'install', '--omit=dev', '@types/' + name);
|
1645
|
+
}
|
1646
|
+
catch { }
|
1647
|
+
break;
|
1648
|
+
}
|
1649
|
+
else {
|
1650
|
+
dir = parent;
|
1651
|
+
}
|
1652
|
+
}
|
1653
|
+
try {
|
1654
|
+
return $.$mol_wire_sync(target).require(name);
|
1655
|
+
}
|
1656
|
+
catch (error) {
|
1657
|
+
if (error.code === 'ERR_REQUIRE_ESM') {
|
1658
|
+
return importSync(name);
|
1659
|
+
}
|
1660
|
+
$.$mol_fail_log(error);
|
1661
|
+
return null;
|
1662
|
+
}
|
1663
|
+
},
|
1664
|
+
set(target, name, value) {
|
1665
|
+
target[name] = value;
|
1666
|
+
return true;
|
1667
|
+
},
|
1668
|
+
});
|
1669
|
+
const importAsync = async (uri) => import(uri);
|
1670
|
+
const importSync = $.$mol_wire_sync(importAsync);
|
1671
|
+
require = (req => Object.assign(function require(name) {
|
1672
|
+
return $node[name];
|
1673
|
+
}, req))(require);
|
1674
|
+
|
843
1675
|
;
|
844
1676
|
"use strict";
|
845
1677
|
var $;
|