mol_crypto_lib 0.1.1083 → 0.1.1085
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 +31 -200
- package/node.d.ts.map +1 -1
- package/node.deps.json +1 -1
- package/node.js +92 -919
- package/node.js.map +1 -1
- package/node.mjs +92 -919
- package/node.test.js +313 -1361
- package/node.test.js.map +1 -1
- package/package.json +2 -17
package/node.test.js
CHANGED
@@ -36,341 +36,131 @@ var $;
|
|
36
36
|
"use strict";
|
37
37
|
var $;
|
38
38
|
(function ($) {
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
$mol_wire_cursor[$mol_wire_cursor["fresh"] = -3] = "fresh";
|
44
|
-
$mol_wire_cursor[$mol_wire_cursor["final"] = -4] = "final";
|
45
|
-
})($mol_wire_cursor = $.$mol_wire_cursor || ($.$mol_wire_cursor = {}));
|
39
|
+
function $mol_promise_like(val) {
|
40
|
+
return val && typeof val === 'object' && 'then' in val && typeof val.then === 'function';
|
41
|
+
}
|
42
|
+
$.$mol_promise_like = $mol_promise_like;
|
46
43
|
})($ || ($ = {}));
|
47
44
|
|
48
45
|
;
|
49
46
|
"use strict";
|
50
47
|
var $;
|
51
48
|
(function ($) {
|
52
|
-
|
53
|
-
|
54
|
-
static get [Symbol.species]() {
|
55
|
-
return Array;
|
56
|
-
}
|
57
|
-
sub_from = 0;
|
58
|
-
get sub_list() {
|
59
|
-
const res = [];
|
60
|
-
for (let i = this.sub_from; i < this.data.length; i += 2) {
|
61
|
-
res.push(this.data[i]);
|
62
|
-
}
|
63
|
-
return res;
|
64
|
-
}
|
65
|
-
get sub_empty() {
|
66
|
-
return this.sub_from === this.data.length;
|
67
|
-
}
|
68
|
-
sub_on(sub, pub_pos) {
|
69
|
-
const pos = this.data.length;
|
70
|
-
this.data.push(sub, pub_pos);
|
71
|
-
return pos;
|
72
|
-
}
|
73
|
-
sub_off(sub_pos) {
|
74
|
-
if (!(sub_pos < this.data.length)) {
|
75
|
-
$mol_fail(new Error(`Wrong pos ${sub_pos}`));
|
76
|
-
}
|
77
|
-
const end = this.data.length - 2;
|
78
|
-
if (sub_pos !== end) {
|
79
|
-
this.peer_move(end, sub_pos);
|
80
|
-
}
|
81
|
-
this.data.pop();
|
82
|
-
this.data.pop();
|
83
|
-
if (this.data.length === this.sub_from)
|
84
|
-
this.reap();
|
85
|
-
}
|
86
|
-
reap() { }
|
87
|
-
promote() {
|
88
|
-
$mol_wire_auto()?.track_next(this);
|
89
|
-
}
|
90
|
-
fresh() { }
|
91
|
-
complete() { }
|
92
|
-
get incompleted() {
|
93
|
-
return false;
|
94
|
-
}
|
95
|
-
emit(quant = $mol_wire_cursor.stale) {
|
96
|
-
for (let i = this.sub_from; i < this.data.length; i += 2) {
|
97
|
-
;
|
98
|
-
this.data[i].absorb(quant);
|
99
|
-
}
|
100
|
-
}
|
101
|
-
peer_move(from_pos, to_pos) {
|
102
|
-
const peer = this.data[from_pos];
|
103
|
-
const self_pos = this.data[from_pos + 1];
|
104
|
-
this.data[to_pos] = peer;
|
105
|
-
this.data[to_pos + 1] = self_pos;
|
106
|
-
peer.peer_repos(self_pos, to_pos);
|
107
|
-
}
|
108
|
-
peer_repos(peer_pos, self_pos) {
|
109
|
-
this.data[peer_pos + 1] = self_pos;
|
110
|
-
}
|
49
|
+
function $mol_fail_hidden(error) {
|
50
|
+
throw error;
|
111
51
|
}
|
112
|
-
$.$
|
52
|
+
$.$mol_fail_hidden = $mol_fail_hidden;
|
113
53
|
})($ || ($ = {}));
|
114
54
|
|
115
|
-
;
|
116
|
-
"use strict";
|
117
|
-
|
118
55
|
;
|
119
56
|
"use strict";
|
120
57
|
var $;
|
121
58
|
(function ($) {
|
122
|
-
|
123
|
-
function $
|
124
|
-
|
59
|
+
const catched = new WeakMap();
|
60
|
+
function $mol_fail_catch(error) {
|
61
|
+
if (typeof error !== 'object')
|
62
|
+
return false;
|
63
|
+
if ($mol_promise_like(error))
|
64
|
+
$mol_fail_hidden(error);
|
65
|
+
if (catched.get(error))
|
66
|
+
return false;
|
67
|
+
catched.set(error, true);
|
68
|
+
return true;
|
125
69
|
}
|
126
|
-
$.$
|
127
|
-
$.$mol_wire_affected = [];
|
70
|
+
$.$mol_fail_catch = $mol_fail_catch;
|
128
71
|
})($ || ($ = {}));
|
129
72
|
|
130
73
|
;
|
131
74
|
"use strict";
|
132
75
|
var $;
|
133
76
|
(function ($) {
|
134
|
-
$
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
$mol_dev_format_register({
|
142
|
-
header: (val, config = false) => {
|
143
|
-
if (config)
|
144
|
-
return null;
|
145
|
-
if (!val)
|
146
|
-
return null;
|
147
|
-
if ($.$mol_dev_format_head in val) {
|
148
|
-
try {
|
149
|
-
return val[$.$mol_dev_format_head]();
|
150
|
-
}
|
151
|
-
catch (error) {
|
152
|
-
return $.$mol_dev_format_accent($mol_dev_format_native(val), '💨', $mol_dev_format_native(error), '');
|
153
|
-
}
|
154
|
-
}
|
155
|
-
if (typeof val === 'function') {
|
156
|
-
return $mol_dev_format_native(val);
|
157
|
-
}
|
158
|
-
if (Symbol.toStringTag in val) {
|
159
|
-
return $mol_dev_format_native(val);
|
160
|
-
}
|
161
|
-
return null;
|
162
|
-
},
|
163
|
-
hasBody: val => val[$.$mol_dev_format_body],
|
164
|
-
body: val => val[$.$mol_dev_format_body](),
|
165
|
-
});
|
166
|
-
function $mol_dev_format_native(obj) {
|
167
|
-
if (typeof obj === 'undefined')
|
168
|
-
return $.$mol_dev_format_shade('undefined');
|
169
|
-
return [
|
170
|
-
'object',
|
171
|
-
{
|
172
|
-
object: obj,
|
173
|
-
config: true,
|
174
|
-
},
|
175
|
-
];
|
176
|
-
}
|
177
|
-
$.$mol_dev_format_native = $mol_dev_format_native;
|
178
|
-
function $mol_dev_format_auto(obj) {
|
179
|
-
if (obj == null)
|
180
|
-
return $.$mol_dev_format_shade(String(obj));
|
181
|
-
return [
|
182
|
-
'object',
|
183
|
-
{
|
184
|
-
object: obj,
|
185
|
-
config: false,
|
186
|
-
},
|
187
|
-
];
|
188
|
-
}
|
189
|
-
$.$mol_dev_format_auto = $mol_dev_format_auto;
|
190
|
-
function $mol_dev_format_element(element, style, ...content) {
|
191
|
-
const styles = [];
|
192
|
-
for (let key in style)
|
193
|
-
styles.push(`${key} : ${style[key]}`);
|
194
|
-
return [
|
195
|
-
element,
|
196
|
-
{
|
197
|
-
style: styles.join(' ; '),
|
198
|
-
},
|
199
|
-
...content,
|
200
|
-
];
|
201
|
-
}
|
202
|
-
$.$mol_dev_format_element = $mol_dev_format_element;
|
203
|
-
function $mol_dev_format_span(style, ...content) {
|
204
|
-
return $mol_dev_format_element('span', {
|
205
|
-
...style,
|
206
|
-
}, ...content);
|
77
|
+
function $mol_fail_log(error) {
|
78
|
+
if ($mol_promise_like(error))
|
79
|
+
return false;
|
80
|
+
if (!$mol_fail_catch(error))
|
81
|
+
return false;
|
82
|
+
console.error(error);
|
83
|
+
return true;
|
207
84
|
}
|
208
|
-
$.$
|
209
|
-
$.$mol_dev_format_div = $mol_dev_format_element.bind(null, 'div');
|
210
|
-
$.$mol_dev_format_ol = $mol_dev_format_element.bind(null, 'ol');
|
211
|
-
$.$mol_dev_format_li = $mol_dev_format_element.bind(null, 'li');
|
212
|
-
$.$mol_dev_format_table = $mol_dev_format_element.bind(null, 'table');
|
213
|
-
$.$mol_dev_format_tr = $mol_dev_format_element.bind(null, 'tr');
|
214
|
-
$.$mol_dev_format_td = $mol_dev_format_element.bind(null, 'td');
|
215
|
-
$.$mol_dev_format_accent = $mol_dev_format_span.bind(null, {
|
216
|
-
'color': 'magenta',
|
217
|
-
});
|
218
|
-
$.$mol_dev_format_strong = $mol_dev_format_span.bind(null, {
|
219
|
-
'font-weight': 'bold',
|
220
|
-
});
|
221
|
-
$.$mol_dev_format_string = $mol_dev_format_span.bind(null, {
|
222
|
-
'color': 'green',
|
223
|
-
});
|
224
|
-
$.$mol_dev_format_shade = $mol_dev_format_span.bind(null, {
|
225
|
-
'color': 'gray',
|
226
|
-
});
|
227
|
-
$.$mol_dev_format_indent = $.$mol_dev_format_div.bind(null, {
|
228
|
-
'margin-left': '13px'
|
229
|
-
});
|
85
|
+
$.$mol_fail_log = $mol_fail_log;
|
230
86
|
})($ || ($ = {}));
|
231
87
|
|
232
88
|
;
|
233
89
|
"use strict";
|
234
|
-
var
|
235
|
-
(
|
236
|
-
|
237
|
-
|
238
|
-
|
239
|
-
|
240
|
-
return
|
241
|
-
|
242
|
-
|
243
|
-
|
244
|
-
|
245
|
-
|
246
|
-
|
247
|
-
|
248
|
-
|
249
|
-
|
250
|
-
|
251
|
-
|
252
|
-
|
253
|
-
|
254
|
-
$mol_wire_auto(this);
|
255
|
-
return sub;
|
256
|
-
}
|
257
|
-
promote() {
|
258
|
-
if (this.cursor >= this.pub_from) {
|
259
|
-
$mol_fail(new Error('Circular subscription'));
|
260
|
-
}
|
261
|
-
super.promote();
|
262
|
-
}
|
263
|
-
track_next(pub) {
|
264
|
-
if (this.cursor < 0)
|
265
|
-
$mol_fail(new Error('Promo to non begun sub'));
|
266
|
-
if (this.cursor < this.sub_from) {
|
267
|
-
const next = this.data[this.cursor];
|
268
|
-
if (pub === undefined)
|
269
|
-
return next ?? null;
|
270
|
-
if (next === pub) {
|
271
|
-
this.cursor += 2;
|
272
|
-
return next;
|
273
|
-
}
|
274
|
-
if (next) {
|
275
|
-
if (this.sub_from < this.data.length) {
|
276
|
-
this.peer_move(this.sub_from, this.data.length);
|
277
|
-
}
|
278
|
-
this.peer_move(this.cursor, this.sub_from);
|
279
|
-
this.sub_from += 2;
|
90
|
+
var $node = new Proxy({ require }, {
|
91
|
+
get(target, name, wrapper) {
|
92
|
+
if (target[name])
|
93
|
+
return target[name];
|
94
|
+
const mod = target.require('module');
|
95
|
+
if (mod.builtinModules.indexOf(name) >= 0)
|
96
|
+
return target.require(name);
|
97
|
+
if (name[0] === '.')
|
98
|
+
return target.require(name);
|
99
|
+
const path = target.require('path');
|
100
|
+
const fs = target.require('fs');
|
101
|
+
let dir = path.resolve('.');
|
102
|
+
const suffix = `./node_modules/${name}`;
|
103
|
+
const $$ = $;
|
104
|
+
while (!fs.existsSync(path.join(dir, suffix))) {
|
105
|
+
const parent = path.resolve(dir, '..');
|
106
|
+
if (parent === dir) {
|
107
|
+
$$.$mol_exec('.', 'npm', 'install', '--omit=dev', name);
|
108
|
+
try {
|
109
|
+
$$.$mol_exec('.', 'npm', 'install', '--omit=dev', '@types/' + name);
|
280
110
|
}
|
111
|
+
catch { }
|
112
|
+
break;
|
281
113
|
}
|
282
114
|
else {
|
283
|
-
|
284
|
-
return null;
|
285
|
-
if (this.sub_from < this.data.length) {
|
286
|
-
this.peer_move(this.sub_from, this.data.length);
|
287
|
-
}
|
288
|
-
this.sub_from += 2;
|
289
|
-
}
|
290
|
-
this.data[this.cursor] = pub;
|
291
|
-
this.data[this.cursor + 1] = pub.sub_on(this, this.cursor);
|
292
|
-
this.cursor += 2;
|
293
|
-
return pub;
|
294
|
-
}
|
295
|
-
track_off(sub) {
|
296
|
-
$mol_wire_auto(sub);
|
297
|
-
if (this.cursor < 0) {
|
298
|
-
$mol_fail(new Error('End of non begun sub'));
|
299
|
-
}
|
300
|
-
for (let cursor = this.pub_from; cursor < this.cursor; cursor += 2) {
|
301
|
-
const pub = this.data[cursor];
|
302
|
-
pub.fresh();
|
303
|
-
}
|
304
|
-
this.cursor = $mol_wire_cursor.fresh;
|
305
|
-
}
|
306
|
-
pub_off(sub_pos) {
|
307
|
-
this.data[sub_pos] = undefined;
|
308
|
-
this.data[sub_pos + 1] = undefined;
|
309
|
-
}
|
310
|
-
destructor() {
|
311
|
-
for (let cursor = this.data.length - 2; cursor >= this.sub_from; cursor -= 2) {
|
312
|
-
const sub = this.data[cursor];
|
313
|
-
const pos = this.data[cursor + 1];
|
314
|
-
sub.pub_off(pos);
|
315
|
-
this.data.pop();
|
316
|
-
this.data.pop();
|
317
|
-
}
|
318
|
-
this.cursor = this.pub_from;
|
319
|
-
this.track_cut();
|
320
|
-
this.cursor = $mol_wire_cursor.final;
|
321
|
-
}
|
322
|
-
track_cut() {
|
323
|
-
if (this.cursor < this.pub_from) {
|
324
|
-
$mol_fail(new Error('Cut of non begun sub'));
|
325
|
-
}
|
326
|
-
let tail = 0;
|
327
|
-
for (let cursor = this.cursor; cursor < this.sub_from; cursor += 2) {
|
328
|
-
const pub = this.data[cursor];
|
329
|
-
pub?.sub_off(this.data[cursor + 1]);
|
330
|
-
if (this.sub_from < this.data.length) {
|
331
|
-
this.peer_move(this.data.length - 2, cursor);
|
332
|
-
this.data.pop();
|
333
|
-
this.data.pop();
|
334
|
-
}
|
335
|
-
else {
|
336
|
-
++tail;
|
337
|
-
}
|
338
|
-
}
|
339
|
-
for (; tail; --tail) {
|
340
|
-
this.data.pop();
|
341
|
-
this.data.pop();
|
342
|
-
}
|
343
|
-
this.sub_from = this.cursor;
|
344
|
-
}
|
345
|
-
complete() { }
|
346
|
-
complete_pubs() {
|
347
|
-
const limit = this.cursor < 0 ? this.sub_from : this.cursor;
|
348
|
-
for (let cursor = this.pub_from; cursor < limit; cursor += 2) {
|
349
|
-
const pub = this.data[cursor];
|
350
|
-
if (pub?.incompleted)
|
351
|
-
return;
|
352
|
-
}
|
353
|
-
for (let cursor = this.pub_from; cursor < limit; cursor += 2) {
|
354
|
-
const pub = this.data[cursor];
|
355
|
-
pub?.complete();
|
115
|
+
dir = parent;
|
356
116
|
}
|
357
117
|
}
|
358
|
-
|
359
|
-
|
360
|
-
return;
|
361
|
-
if (this.cursor >= quant)
|
362
|
-
return;
|
363
|
-
this.cursor = quant;
|
364
|
-
this.emit($mol_wire_cursor.doubt);
|
365
|
-
}
|
366
|
-
[$mol_dev_format_head]() {
|
367
|
-
return $mol_dev_format_native(this);
|
118
|
+
try {
|
119
|
+
return target.require(name);
|
368
120
|
}
|
369
|
-
|
370
|
-
|
121
|
+
catch (error) {
|
122
|
+
if (error.code === 'ERR_REQUIRE_ESM') {
|
123
|
+
const module = cache.get(name);
|
124
|
+
if (module)
|
125
|
+
return module;
|
126
|
+
throw import(name).then(module => cache.set(name, module));
|
127
|
+
}
|
128
|
+
$.$mol_fail_log(error);
|
129
|
+
return null;
|
371
130
|
}
|
131
|
+
},
|
132
|
+
set(target, name, value) {
|
133
|
+
target[name] = value;
|
134
|
+
return true;
|
135
|
+
},
|
136
|
+
});
|
137
|
+
const cache = new Map();
|
138
|
+
require = (req => Object.assign(function require(name) {
|
139
|
+
return $node[name];
|
140
|
+
}, req))(require);
|
141
|
+
|
142
|
+
;
|
143
|
+
"use strict";
|
144
|
+
var $;
|
145
|
+
(function ($) {
|
146
|
+
function $mol_log3_area_lazy(event) {
|
147
|
+
const self = this;
|
148
|
+
const stack = self.$mol_log3_stack;
|
149
|
+
const deep = stack.length;
|
150
|
+
let logged = false;
|
151
|
+
stack.push(() => {
|
152
|
+
logged = true;
|
153
|
+
self.$mol_log3_area.call(self, event);
|
154
|
+
});
|
155
|
+
return () => {
|
156
|
+
if (logged)
|
157
|
+
self.console.groupEnd();
|
158
|
+
if (stack.length > deep)
|
159
|
+
stack.length = deep;
|
160
|
+
};
|
372
161
|
}
|
373
|
-
$.$
|
162
|
+
$.$mol_log3_area_lazy = $mol_log3_area_lazy;
|
163
|
+
$.$mol_log3_stack = [];
|
374
164
|
})($ || ($ = {}));
|
375
165
|
|
376
166
|
;
|
@@ -471,531 +261,88 @@ var $;
|
|
471
261
|
return false;
|
472
262
|
if ($.$mol_owning_map.get(having))
|
473
263
|
return false;
|
474
|
-
$.$mol_owning_map.set(having, owner);
|
475
|
-
return true;
|
476
|
-
}
|
477
|
-
$.$mol_owning_catch = $mol_owning_catch;
|
478
|
-
})($ || ($ = {}));
|
479
|
-
|
480
|
-
;
|
481
|
-
"use strict";
|
482
|
-
var $;
|
483
|
-
(function ($) {
|
484
|
-
function $mol_fail_hidden(error) {
|
485
|
-
throw error;
|
486
|
-
}
|
487
|
-
$.$mol_fail_hidden = $mol_fail_hidden;
|
488
|
-
})($ || ($ = {}));
|
489
|
-
|
490
|
-
;
|
491
|
-
"use strict";
|
492
|
-
|
493
|
-
;
|
494
|
-
"use strict";
|
495
|
-
var $;
|
496
|
-
(function ($) {
|
497
|
-
const named = new WeakSet();
|
498
|
-
function $mol_func_name(func) {
|
499
|
-
let name = func.name;
|
500
|
-
if (name?.length > 1)
|
501
|
-
return name;
|
502
|
-
if (named.has(func))
|
503
|
-
return name;
|
504
|
-
for (let key in this) {
|
505
|
-
try {
|
506
|
-
if (this[key] !== func)
|
507
|
-
continue;
|
508
|
-
name = key;
|
509
|
-
Object.defineProperty(func, 'name', { value: name });
|
510
|
-
break;
|
511
|
-
}
|
512
|
-
catch { }
|
513
|
-
}
|
514
|
-
named.add(func);
|
515
|
-
return name;
|
516
|
-
}
|
517
|
-
$.$mol_func_name = $mol_func_name;
|
518
|
-
function $mol_func_name_from(target, source) {
|
519
|
-
Object.defineProperty(target, 'name', { value: source.name });
|
520
|
-
return target;
|
521
|
-
}
|
522
|
-
$.$mol_func_name_from = $mol_func_name_from;
|
523
|
-
})($ || ($ = {}));
|
524
|
-
|
525
|
-
;
|
526
|
-
"use strict";
|
527
|
-
var $;
|
528
|
-
(function ($) {
|
529
|
-
class $mol_object2 {
|
530
|
-
static $ = $;
|
531
|
-
[Symbol.toStringTag];
|
532
|
-
[$mol_ambient_ref] = null;
|
533
|
-
get $() {
|
534
|
-
if (this[$mol_ambient_ref])
|
535
|
-
return this[$mol_ambient_ref];
|
536
|
-
const owner = $mol_owning_get(this);
|
537
|
-
return this[$mol_ambient_ref] = owner?.$ || $mol_object2.$;
|
538
|
-
}
|
539
|
-
set $(next) {
|
540
|
-
if (this[$mol_ambient_ref])
|
541
|
-
$mol_fail_hidden(new Error('Context already defined'));
|
542
|
-
this[$mol_ambient_ref] = next;
|
543
|
-
}
|
544
|
-
static create(init) {
|
545
|
-
const obj = new this;
|
546
|
-
if (init)
|
547
|
-
init(obj);
|
548
|
-
return obj;
|
549
|
-
}
|
550
|
-
static [Symbol.toPrimitive]() {
|
551
|
-
return this.toString();
|
552
|
-
}
|
553
|
-
static toString() {
|
554
|
-
return this[Symbol.toStringTag] || this.$.$mol_func_name(this);
|
555
|
-
}
|
556
|
-
static toJSON() {
|
557
|
-
return this.toString();
|
558
|
-
}
|
559
|
-
destructor() { }
|
560
|
-
static destructor() { }
|
561
|
-
toString() {
|
562
|
-
return this[Symbol.toStringTag] || this.constructor.name + '<>';
|
563
|
-
}
|
564
|
-
}
|
565
|
-
$.$mol_object2 = $mol_object2;
|
566
|
-
})($ || ($ = {}));
|
567
|
-
|
568
|
-
;
|
569
|
-
"use strict";
|
570
|
-
var $;
|
571
|
-
(function ($) {
|
572
|
-
class $mol_after_timeout extends $mol_object2 {
|
573
|
-
delay;
|
574
|
-
task;
|
575
|
-
id;
|
576
|
-
constructor(delay, task) {
|
577
|
-
super();
|
578
|
-
this.delay = delay;
|
579
|
-
this.task = task;
|
580
|
-
this.id = setTimeout(task, delay);
|
581
|
-
}
|
582
|
-
destructor() {
|
583
|
-
clearTimeout(this.id);
|
584
|
-
}
|
585
|
-
}
|
586
|
-
$.$mol_after_timeout = $mol_after_timeout;
|
587
|
-
})($ || ($ = {}));
|
588
|
-
|
589
|
-
;
|
590
|
-
"use strict";
|
591
|
-
var $;
|
592
|
-
(function ($) {
|
593
|
-
class $mol_after_frame extends $mol_after_timeout {
|
594
|
-
task;
|
595
|
-
constructor(task) {
|
596
|
-
super(16, task);
|
597
|
-
this.task = task;
|
598
|
-
}
|
599
|
-
}
|
600
|
-
$.$mol_after_frame = $mol_after_frame;
|
601
|
-
})($ || ($ = {}));
|
602
|
-
|
603
|
-
;
|
604
|
-
"use strict";
|
605
|
-
var $;
|
606
|
-
(function ($) {
|
607
|
-
function $mol_promise_like(val) {
|
608
|
-
return val && typeof val === 'object' && 'then' in val && typeof val.then === 'function';
|
609
|
-
}
|
610
|
-
$.$mol_promise_like = $mol_promise_like;
|
611
|
-
})($ || ($ = {}));
|
612
|
-
|
613
|
-
;
|
614
|
-
"use strict";
|
615
|
-
var $;
|
616
|
-
(function ($) {
|
617
|
-
const handled = new WeakSet();
|
618
|
-
class $mol_wire_fiber extends $mol_wire_pub_sub {
|
619
|
-
task;
|
620
|
-
host;
|
621
|
-
static warm = true;
|
622
|
-
static planning = new Set();
|
623
|
-
static reaping = new Set();
|
624
|
-
static plan_task = null;
|
625
|
-
static plan() {
|
626
|
-
if (this.plan_task)
|
627
|
-
return;
|
628
|
-
this.plan_task = new $mol_after_frame(() => {
|
629
|
-
try {
|
630
|
-
this.sync();
|
631
|
-
}
|
632
|
-
finally {
|
633
|
-
$mol_wire_fiber.plan_task = null;
|
634
|
-
}
|
635
|
-
});
|
636
|
-
}
|
637
|
-
static sync() {
|
638
|
-
while (this.planning.size) {
|
639
|
-
for (const fiber of this.planning) {
|
640
|
-
this.planning.delete(fiber);
|
641
|
-
if (fiber.cursor >= 0)
|
642
|
-
continue;
|
643
|
-
if (fiber.cursor === $mol_wire_cursor.final)
|
644
|
-
continue;
|
645
|
-
fiber.fresh();
|
646
|
-
}
|
647
|
-
}
|
648
|
-
while (this.reaping.size) {
|
649
|
-
const fibers = this.reaping;
|
650
|
-
this.reaping = new Set;
|
651
|
-
for (const fiber of fibers) {
|
652
|
-
if (!fiber.sub_empty)
|
653
|
-
continue;
|
654
|
-
fiber.destructor();
|
655
|
-
}
|
656
|
-
}
|
657
|
-
}
|
658
|
-
[Symbol.toStringTag];
|
659
|
-
cache = undefined;
|
660
|
-
get args() {
|
661
|
-
return this.data.slice(0, this.pub_from);
|
662
|
-
}
|
663
|
-
result() {
|
664
|
-
if ($mol_promise_like(this.cache))
|
665
|
-
return;
|
666
|
-
if (this.cache instanceof Error)
|
667
|
-
return;
|
668
|
-
return this.cache;
|
669
|
-
}
|
670
|
-
get incompleted() {
|
671
|
-
return $mol_promise_like(this.cache);
|
672
|
-
}
|
673
|
-
field() {
|
674
|
-
return this.task.name + '<>';
|
675
|
-
}
|
676
|
-
constructor(id, task, host, args) {
|
677
|
-
super();
|
678
|
-
this.task = task;
|
679
|
-
this.host = host;
|
680
|
-
if (args)
|
681
|
-
this.data.push(...args);
|
682
|
-
this.pub_from = this.sub_from = args?.length ?? 0;
|
683
|
-
this[Symbol.toStringTag] = id;
|
684
|
-
}
|
685
|
-
plan() {
|
686
|
-
$mol_wire_fiber.planning.add(this);
|
687
|
-
$mol_wire_fiber.plan();
|
688
|
-
}
|
689
|
-
reap() {
|
690
|
-
$mol_wire_fiber.reaping.add(this);
|
691
|
-
$mol_wire_fiber.plan();
|
692
|
-
}
|
693
|
-
toString() {
|
694
|
-
return this[Symbol.toStringTag];
|
695
|
-
}
|
696
|
-
toJSON() {
|
697
|
-
return this[Symbol.toStringTag];
|
698
|
-
}
|
699
|
-
[$mol_dev_format_head]() {
|
700
|
-
const cursor = {
|
701
|
-
[$mol_wire_cursor.stale]: '🔴',
|
702
|
-
[$mol_wire_cursor.doubt]: '🟡',
|
703
|
-
[$mol_wire_cursor.fresh]: '🟢',
|
704
|
-
[$mol_wire_cursor.final]: '🔵',
|
705
|
-
}[this.cursor] ?? this.cursor.toString();
|
706
|
-
return $mol_dev_format_div({}, $mol_owning_check(this, this.cache)
|
707
|
-
? $mol_dev_format_auto({
|
708
|
-
[$mol_dev_format_head]: () => $mol_dev_format_shade(cursor),
|
709
|
-
[$mol_dev_format_body]: () => $mol_dev_format_native(this),
|
710
|
-
})
|
711
|
-
: $mol_dev_format_shade($mol_dev_format_native(this), cursor), $mol_dev_format_auto(this.cache));
|
712
|
-
}
|
713
|
-
get $() {
|
714
|
-
return (this.host ?? this.task)['$'];
|
715
|
-
}
|
716
|
-
emit(quant = $mol_wire_cursor.stale) {
|
717
|
-
if (this.sub_empty)
|
718
|
-
this.plan();
|
719
|
-
else
|
720
|
-
super.emit(quant);
|
721
|
-
}
|
722
|
-
fresh() {
|
723
|
-
if (this.cursor === $mol_wire_cursor.fresh)
|
724
|
-
return;
|
725
|
-
if (this.cursor === $mol_wire_cursor.final)
|
726
|
-
return;
|
727
|
-
check: if (this.cursor === $mol_wire_cursor.doubt) {
|
728
|
-
for (let i = this.pub_from; i < this.sub_from; i += 2) {
|
729
|
-
;
|
730
|
-
this.data[i]?.fresh();
|
731
|
-
if (this.cursor !== $mol_wire_cursor.doubt)
|
732
|
-
break check;
|
733
|
-
}
|
734
|
-
this.cursor = $mol_wire_cursor.fresh;
|
735
|
-
return;
|
736
|
-
}
|
737
|
-
const bu = this.track_on();
|
738
|
-
let result;
|
739
|
-
try {
|
740
|
-
switch (this.pub_from) {
|
741
|
-
case 0:
|
742
|
-
result = this.task.call(this.host);
|
743
|
-
break;
|
744
|
-
case 1:
|
745
|
-
result = this.task.call(this.host, this.data[0]);
|
746
|
-
break;
|
747
|
-
default:
|
748
|
-
result = this.task.call(this.host, ...this.args);
|
749
|
-
break;
|
750
|
-
}
|
751
|
-
if ($mol_promise_like(result) && !handled.has(result)) {
|
752
|
-
const put = (res) => {
|
753
|
-
if (this.cache === result)
|
754
|
-
this.put(res);
|
755
|
-
return res;
|
756
|
-
};
|
757
|
-
result = result.then(put, put);
|
758
|
-
}
|
759
|
-
}
|
760
|
-
catch (error) {
|
761
|
-
if (error instanceof Error || $mol_promise_like(error)) {
|
762
|
-
result = error;
|
763
|
-
}
|
764
|
-
else {
|
765
|
-
result = new Error(String(error), { cause: error });
|
766
|
-
}
|
767
|
-
if ($mol_promise_like(result) && !handled.has(result)) {
|
768
|
-
result = result.finally(() => {
|
769
|
-
if (this.cache === result)
|
770
|
-
this.absorb();
|
771
|
-
});
|
772
|
-
}
|
773
|
-
}
|
774
|
-
if ($mol_promise_like(result) && !handled.has(result)) {
|
775
|
-
result = Object.assign(result, {
|
776
|
-
destructor: result['destructor'] ?? (() => { })
|
777
|
-
});
|
778
|
-
handled.add(result);
|
779
|
-
const error = new Error(`Promise in ${this}`);
|
780
|
-
Object.defineProperty(result, 'stack', { get: () => error.stack });
|
781
|
-
}
|
782
|
-
if (!$mol_promise_like(result)) {
|
783
|
-
this.track_cut();
|
784
|
-
}
|
785
|
-
this.track_off(bu);
|
786
|
-
this.put(result);
|
787
|
-
}
|
788
|
-
refresh() {
|
789
|
-
this.cursor = $mol_wire_cursor.stale;
|
790
|
-
this.fresh();
|
791
|
-
}
|
792
|
-
sync() {
|
793
|
-
if (!$mol_wire_fiber.warm) {
|
794
|
-
return this.result();
|
795
|
-
}
|
796
|
-
this.promote();
|
797
|
-
this.fresh();
|
798
|
-
if (this.cache instanceof Error) {
|
799
|
-
return $mol_fail_hidden(this.cache);
|
800
|
-
}
|
801
|
-
if ($mol_promise_like(this.cache)) {
|
802
|
-
return $mol_fail_hidden(this.cache);
|
803
|
-
}
|
804
|
-
return this.cache;
|
805
|
-
}
|
806
|
-
async async() {
|
807
|
-
while (true) {
|
808
|
-
this.fresh();
|
809
|
-
if (this.cache instanceof Error) {
|
810
|
-
$mol_fail_hidden(this.cache);
|
811
|
-
}
|
812
|
-
if (!$mol_promise_like(this.cache))
|
813
|
-
return this.cache;
|
814
|
-
await Promise.race([this.cache, this.step()]);
|
815
|
-
if (!$mol_promise_like(this.cache))
|
816
|
-
return this.cache;
|
817
|
-
if (this.cursor === $mol_wire_cursor.final) {
|
818
|
-
await new Promise(() => { });
|
819
|
-
}
|
820
|
-
}
|
821
|
-
}
|
822
|
-
step() {
|
823
|
-
return new Promise(done => {
|
824
|
-
const sub = new $mol_wire_pub_sub;
|
825
|
-
const prev = sub.track_on();
|
826
|
-
sub.track_next(this);
|
827
|
-
sub.track_off(prev);
|
828
|
-
sub.absorb = () => {
|
829
|
-
done(null);
|
830
|
-
sub.destructor();
|
831
|
-
};
|
832
|
-
});
|
833
|
-
}
|
834
|
-
}
|
835
|
-
$.$mol_wire_fiber = $mol_wire_fiber;
|
836
|
-
})($ || ($ = {}));
|
837
|
-
|
838
|
-
;
|
839
|
-
"use strict";
|
840
|
-
var $;
|
841
|
-
(function ($) {
|
842
|
-
$.$mol_compare_deep_cache = new WeakMap();
|
843
|
-
function $mol_compare_deep(left, right) {
|
844
|
-
if (Object.is(left, right))
|
845
|
-
return true;
|
846
|
-
if (left === null)
|
847
|
-
return false;
|
848
|
-
if (right === null)
|
849
|
-
return false;
|
850
|
-
if (typeof left !== 'object')
|
851
|
-
return false;
|
852
|
-
if (typeof right !== 'object')
|
853
|
-
return false;
|
854
|
-
const left_proto = Reflect.getPrototypeOf(left);
|
855
|
-
const right_proto = Reflect.getPrototypeOf(right);
|
856
|
-
if (left_proto !== right_proto)
|
857
|
-
return false;
|
858
|
-
if (left instanceof Boolean)
|
859
|
-
return Object.is(left.valueOf(), right['valueOf']());
|
860
|
-
if (left instanceof Number)
|
861
|
-
return Object.is(left.valueOf(), right['valueOf']());
|
862
|
-
if (left instanceof String)
|
863
|
-
return Object.is(left.valueOf(), right['valueOf']());
|
864
|
-
if (left instanceof Date)
|
865
|
-
return Object.is(left.valueOf(), right['valueOf']());
|
866
|
-
if (left instanceof RegExp)
|
867
|
-
return left.source === right.source && left.flags === right.flags;
|
868
|
-
if (left instanceof Error)
|
869
|
-
return left.message === right.message && left.stack === right.stack;
|
870
|
-
let left_cache = $.$mol_compare_deep_cache.get(left);
|
871
|
-
if (left_cache) {
|
872
|
-
const right_cache = left_cache.get(right);
|
873
|
-
if (typeof right_cache === 'boolean')
|
874
|
-
return right_cache;
|
875
|
-
}
|
876
|
-
else {
|
877
|
-
left_cache = new WeakMap([[right, true]]);
|
878
|
-
$.$mol_compare_deep_cache.set(left, left_cache);
|
879
|
-
}
|
880
|
-
let result;
|
881
|
-
try {
|
882
|
-
if (!left_proto)
|
883
|
-
result = compare_pojo(left, right);
|
884
|
-
else if (!Reflect.getPrototypeOf(left_proto))
|
885
|
-
result = compare_pojo(left, right);
|
886
|
-
else if (Symbol.toPrimitive in left)
|
887
|
-
result = compare_primitive(left, right);
|
888
|
-
else if (Array.isArray(left))
|
889
|
-
result = compare_array(left, right);
|
890
|
-
else if (left instanceof Set)
|
891
|
-
result = compare_set(left, right);
|
892
|
-
else if (left instanceof Map)
|
893
|
-
result = compare_map(left, right);
|
894
|
-
else if (ArrayBuffer.isView(left))
|
895
|
-
result = compare_buffer(left, right);
|
896
|
-
else if (Symbol.iterator in left)
|
897
|
-
result = compare_iterator(left[Symbol.iterator](), right[Symbol.iterator]());
|
898
|
-
else
|
899
|
-
result = false;
|
900
|
-
}
|
901
|
-
finally {
|
902
|
-
left_cache.set(right, result);
|
903
|
-
}
|
904
|
-
return result;
|
905
|
-
}
|
906
|
-
$.$mol_compare_deep = $mol_compare_deep;
|
907
|
-
function compare_array(left, right) {
|
908
|
-
const len = left.length;
|
909
|
-
if (len !== right.length)
|
910
|
-
return false;
|
911
|
-
for (let i = 0; i < len; ++i) {
|
912
|
-
if (!$mol_compare_deep(left[i], right[i]))
|
913
|
-
return false;
|
914
|
-
}
|
915
|
-
return true;
|
916
|
-
}
|
917
|
-
function compare_buffer(left, right) {
|
918
|
-
const len = left.byteLength;
|
919
|
-
if (len !== right.byteLength)
|
920
|
-
return false;
|
921
|
-
if (left instanceof DataView)
|
922
|
-
return compare_buffer(new Uint8Array(left.buffer, left.byteOffset, left.byteLength), new Uint8Array(right.buffer, left.byteOffset, left.byteLength));
|
923
|
-
for (let i = 0; i < len; ++i) {
|
924
|
-
if (left[i] !== right[i])
|
925
|
-
return false;
|
926
|
-
}
|
927
|
-
return true;
|
928
|
-
}
|
929
|
-
function compare_iterator(left, right) {
|
930
|
-
while (true) {
|
931
|
-
const left_next = left.next();
|
932
|
-
const right_next = right.next();
|
933
|
-
if (left_next.done !== right_next.done)
|
934
|
-
return false;
|
935
|
-
if (left_next.done)
|
936
|
-
break;
|
937
|
-
if (!$mol_compare_deep(left_next.value, right_next.value))
|
938
|
-
return false;
|
939
|
-
}
|
940
|
-
return true;
|
941
|
-
}
|
942
|
-
function compare_set(left, right) {
|
943
|
-
if (left.size !== right.size)
|
944
|
-
return false;
|
945
|
-
return compare_iterator(left.values(), right.values());
|
946
|
-
}
|
947
|
-
function compare_map(left, right) {
|
948
|
-
if (left.size !== right.size)
|
949
|
-
return false;
|
950
|
-
return compare_iterator(left.keys(), right.keys())
|
951
|
-
&& compare_iterator(left.values(), right.values());
|
952
|
-
}
|
953
|
-
function compare_pojo(left, right) {
|
954
|
-
const left_keys = Object.getOwnPropertyNames(left);
|
955
|
-
const right_keys = Object.getOwnPropertyNames(right);
|
956
|
-
if (!compare_array(left_keys, right_keys))
|
957
|
-
return false;
|
958
|
-
for (let key of left_keys) {
|
959
|
-
if (!$mol_compare_deep(left[key], right[key]))
|
960
|
-
return false;
|
961
|
-
}
|
962
|
-
const left_syms = Object.getOwnPropertySymbols(left);
|
963
|
-
const right_syms = Object.getOwnPropertySymbols(right);
|
964
|
-
if (!compare_array(left_syms, right_syms))
|
965
|
-
return false;
|
966
|
-
for (let key of left_syms) {
|
967
|
-
if (!$mol_compare_deep(left[key], right[key]))
|
968
|
-
return false;
|
969
|
-
}
|
264
|
+
$.$mol_owning_map.set(having, owner);
|
970
265
|
return true;
|
971
266
|
}
|
972
|
-
|
973
|
-
|
267
|
+
$.$mol_owning_catch = $mol_owning_catch;
|
268
|
+
})($ || ($ = {}));
|
269
|
+
|
270
|
+
;
|
271
|
+
"use strict";
|
272
|
+
|
273
|
+
;
|
274
|
+
"use strict";
|
275
|
+
var $;
|
276
|
+
(function ($) {
|
277
|
+
const named = new WeakSet();
|
278
|
+
function $mol_func_name(func) {
|
279
|
+
let name = func.name;
|
280
|
+
if (name?.length > 1)
|
281
|
+
return name;
|
282
|
+
if (named.has(func))
|
283
|
+
return name;
|
284
|
+
for (let key in this) {
|
285
|
+
try {
|
286
|
+
if (this[key] !== func)
|
287
|
+
continue;
|
288
|
+
name = key;
|
289
|
+
Object.defineProperty(func, 'name', { value: name });
|
290
|
+
break;
|
291
|
+
}
|
292
|
+
catch { }
|
293
|
+
}
|
294
|
+
named.add(func);
|
295
|
+
return name;
|
974
296
|
}
|
297
|
+
$.$mol_func_name = $mol_func_name;
|
298
|
+
function $mol_func_name_from(target, source) {
|
299
|
+
Object.defineProperty(target, 'name', { value: source.name });
|
300
|
+
return target;
|
301
|
+
}
|
302
|
+
$.$mol_func_name_from = $mol_func_name_from;
|
975
303
|
})($ || ($ = {}));
|
976
304
|
|
977
305
|
;
|
978
306
|
"use strict";
|
979
307
|
var $;
|
980
308
|
(function ($) {
|
981
|
-
|
982
|
-
|
983
|
-
|
984
|
-
|
985
|
-
|
986
|
-
|
987
|
-
|
988
|
-
|
989
|
-
|
990
|
-
|
991
|
-
|
992
|
-
|
993
|
-
|
994
|
-
|
995
|
-
}
|
309
|
+
class $mol_object2 {
|
310
|
+
static $ = $;
|
311
|
+
[Symbol.toStringTag];
|
312
|
+
[$mol_ambient_ref] = null;
|
313
|
+
get $() {
|
314
|
+
if (this[$mol_ambient_ref])
|
315
|
+
return this[$mol_ambient_ref];
|
316
|
+
const owner = $mol_owning_get(this);
|
317
|
+
return this[$mol_ambient_ref] = owner?.$ || $mol_object2.$;
|
318
|
+
}
|
319
|
+
set $(next) {
|
320
|
+
if (this[$mol_ambient_ref])
|
321
|
+
$mol_fail_hidden(new Error('Context already defined'));
|
322
|
+
this[$mol_ambient_ref] = next;
|
323
|
+
}
|
324
|
+
static create(init) {
|
325
|
+
const obj = new this;
|
326
|
+
if (init)
|
327
|
+
init(obj);
|
328
|
+
return obj;
|
329
|
+
}
|
330
|
+
static [Symbol.toPrimitive]() {
|
331
|
+
return this.toString();
|
332
|
+
}
|
333
|
+
static toString() {
|
334
|
+
return this[Symbol.toStringTag] || this.$.$mol_func_name(this);
|
335
|
+
}
|
336
|
+
static toJSON() {
|
337
|
+
return this.toString();
|
338
|
+
}
|
339
|
+
destructor() { }
|
340
|
+
static destructor() { }
|
341
|
+
toString() {
|
342
|
+
return this[Symbol.toStringTag] || this.constructor.name + '<>';
|
343
|
+
}
|
996
344
|
}
|
997
|
-
$.$
|
998
|
-
$.$mol_log3_stack = [];
|
345
|
+
$.$mol_object2 = $mol_object2;
|
999
346
|
})($ || ($ = {}));
|
1000
347
|
|
1001
348
|
;
|
@@ -1491,180 +838,6 @@ var $;
|
|
1491
838
|
$.$mol_log3_area = $mol_log3_node_make('log', 'stdout', 'area', $mol_term_color.cyan);
|
1492
839
|
})($ || ($ = {}));
|
1493
840
|
|
1494
|
-
;
|
1495
|
-
"use strict";
|
1496
|
-
var $;
|
1497
|
-
(function ($) {
|
1498
|
-
class $mol_wire_task extends $mol_wire_fiber {
|
1499
|
-
static getter(task) {
|
1500
|
-
return function $mol_wire_task_get(host, args) {
|
1501
|
-
const sub = $mol_wire_auto();
|
1502
|
-
const existen = sub?.track_next();
|
1503
|
-
reuse: if (existen) {
|
1504
|
-
if (!existen.temp)
|
1505
|
-
break reuse;
|
1506
|
-
if (existen.host !== host)
|
1507
|
-
break reuse;
|
1508
|
-
if (existen.task !== task)
|
1509
|
-
break reuse;
|
1510
|
-
if (!$mol_compare_deep(existen.args, args))
|
1511
|
-
break reuse;
|
1512
|
-
return existen;
|
1513
|
-
}
|
1514
|
-
const next = new $mol_wire_task(`${host?.[Symbol.toStringTag] ?? host}.${task.name}<#>`, task, host, args);
|
1515
|
-
if (existen?.temp) {
|
1516
|
-
$$.$mol_log3_warn({
|
1517
|
-
place: '$mol_wire_task',
|
1518
|
-
message: `Non idempotency`,
|
1519
|
-
existen,
|
1520
|
-
next,
|
1521
|
-
hint: 'Ignore it',
|
1522
|
-
});
|
1523
|
-
}
|
1524
|
-
return next;
|
1525
|
-
};
|
1526
|
-
}
|
1527
|
-
get temp() {
|
1528
|
-
return true;
|
1529
|
-
}
|
1530
|
-
complete() {
|
1531
|
-
if ($mol_promise_like(this.cache))
|
1532
|
-
return;
|
1533
|
-
this.destructor();
|
1534
|
-
}
|
1535
|
-
put(next) {
|
1536
|
-
const prev = this.cache;
|
1537
|
-
this.cache = next;
|
1538
|
-
if ($mol_promise_like(next)) {
|
1539
|
-
this.cursor = $mol_wire_cursor.fresh;
|
1540
|
-
if (next !== prev)
|
1541
|
-
this.emit();
|
1542
|
-
return next;
|
1543
|
-
}
|
1544
|
-
this.cursor = $mol_wire_cursor.final;
|
1545
|
-
if (this.sub_empty)
|
1546
|
-
this.destructor();
|
1547
|
-
else if (next !== prev)
|
1548
|
-
this.emit();
|
1549
|
-
return next;
|
1550
|
-
}
|
1551
|
-
}
|
1552
|
-
$.$mol_wire_task = $mol_wire_task;
|
1553
|
-
})($ || ($ = {}));
|
1554
|
-
|
1555
|
-
;
|
1556
|
-
"use strict";
|
1557
|
-
var $;
|
1558
|
-
(function ($) {
|
1559
|
-
function $mol_wire_sync(obj) {
|
1560
|
-
return new Proxy(obj, {
|
1561
|
-
get(obj, field) {
|
1562
|
-
const val = obj[field];
|
1563
|
-
if (typeof val !== 'function')
|
1564
|
-
return val;
|
1565
|
-
const temp = $mol_wire_task.getter(val);
|
1566
|
-
return function $mol_wire_sync(...args) {
|
1567
|
-
const fiber = temp(obj, args);
|
1568
|
-
return fiber.sync();
|
1569
|
-
};
|
1570
|
-
},
|
1571
|
-
apply(obj, self, args) {
|
1572
|
-
const temp = $mol_wire_task.getter(obj);
|
1573
|
-
const fiber = temp(self, args);
|
1574
|
-
return fiber.sync();
|
1575
|
-
},
|
1576
|
-
});
|
1577
|
-
}
|
1578
|
-
$.$mol_wire_sync = $mol_wire_sync;
|
1579
|
-
})($ || ($ = {}));
|
1580
|
-
|
1581
|
-
;
|
1582
|
-
"use strict";
|
1583
|
-
var $;
|
1584
|
-
(function ($) {
|
1585
|
-
const catched = new WeakMap();
|
1586
|
-
function $mol_fail_catch(error) {
|
1587
|
-
if (typeof error !== 'object')
|
1588
|
-
return false;
|
1589
|
-
if ($mol_promise_like(error))
|
1590
|
-
$mol_fail_hidden(error);
|
1591
|
-
if (catched.get(error))
|
1592
|
-
return false;
|
1593
|
-
catched.set(error, true);
|
1594
|
-
return true;
|
1595
|
-
}
|
1596
|
-
$.$mol_fail_catch = $mol_fail_catch;
|
1597
|
-
})($ || ($ = {}));
|
1598
|
-
|
1599
|
-
;
|
1600
|
-
"use strict";
|
1601
|
-
var $;
|
1602
|
-
(function ($) {
|
1603
|
-
function $mol_fail_log(error) {
|
1604
|
-
if ($mol_promise_like(error))
|
1605
|
-
return false;
|
1606
|
-
if (!$mol_fail_catch(error))
|
1607
|
-
return false;
|
1608
|
-
console.error(error);
|
1609
|
-
return true;
|
1610
|
-
}
|
1611
|
-
$.$mol_fail_log = $mol_fail_log;
|
1612
|
-
})($ || ($ = {}));
|
1613
|
-
|
1614
|
-
;
|
1615
|
-
"use strict";
|
1616
|
-
var $node = new Proxy({ require }, {
|
1617
|
-
get(target, name, wrapper) {
|
1618
|
-
if (target[name])
|
1619
|
-
return target[name];
|
1620
|
-
const mod = target.require('module');
|
1621
|
-
if (mod.builtinModules.indexOf(name) >= 0)
|
1622
|
-
return target.require(name);
|
1623
|
-
if (name[0] === '.')
|
1624
|
-
return target.require(name);
|
1625
|
-
const path = target.require('path');
|
1626
|
-
const fs = target.require('fs');
|
1627
|
-
let dir = path.resolve('.');
|
1628
|
-
const suffix = `./node_modules/${name}`;
|
1629
|
-
const $$ = $;
|
1630
|
-
while (!fs.existsSync(path.join(dir, suffix))) {
|
1631
|
-
const parent = path.resolve(dir, '..');
|
1632
|
-
if (parent === dir) {
|
1633
|
-
$$.$mol_exec('.', 'npm', 'install', '--omit=dev', name);
|
1634
|
-
try {
|
1635
|
-
$$.$mol_exec('.', 'npm', 'install', '--omit=dev', '@types/' + name);
|
1636
|
-
}
|
1637
|
-
catch { }
|
1638
|
-
break;
|
1639
|
-
}
|
1640
|
-
else {
|
1641
|
-
dir = parent;
|
1642
|
-
}
|
1643
|
-
}
|
1644
|
-
try {
|
1645
|
-
return $.$mol_wire_sync(target).require(name);
|
1646
|
-
}
|
1647
|
-
catch (error) {
|
1648
|
-
if (error.code === 'ERR_REQUIRE_ESM') {
|
1649
|
-
const module = cache.get(name);
|
1650
|
-
if (module)
|
1651
|
-
return module;
|
1652
|
-
throw import(name).then(module => cache.set(name, module));
|
1653
|
-
}
|
1654
|
-
$.$mol_fail_log(error);
|
1655
|
-
return null;
|
1656
|
-
}
|
1657
|
-
},
|
1658
|
-
set(target, name, value) {
|
1659
|
-
target[name] = value;
|
1660
|
-
return true;
|
1661
|
-
},
|
1662
|
-
});
|
1663
|
-
const cache = new Map();
|
1664
|
-
require = (req => Object.assign(function require(name) {
|
1665
|
-
return $node[name];
|
1666
|
-
}, req))(require);
|
1667
|
-
|
1668
841
|
;
|
1669
842
|
"use strict";
|
1670
843
|
var $;
|
@@ -2384,33 +1557,6 @@ var $;
|
|
2384
1557
|
$.$mol_test_complete = $mol_test_complete;
|
2385
1558
|
})($ || ($ = {}));
|
2386
1559
|
|
2387
|
-
;
|
2388
|
-
"use strict";
|
2389
|
-
|
2390
|
-
;
|
2391
|
-
"use strict";
|
2392
|
-
|
2393
|
-
;
|
2394
|
-
"use strict";
|
2395
|
-
|
2396
|
-
;
|
2397
|
-
"use strict";
|
2398
|
-
var $;
|
2399
|
-
(function ($_1) {
|
2400
|
-
$mol_test({
|
2401
|
-
'test types'($) {
|
2402
|
-
class A {
|
2403
|
-
static a() {
|
2404
|
-
return Promise.resolve('');
|
2405
|
-
}
|
2406
|
-
static b() {
|
2407
|
-
return $mol_wire_sync(this).a();
|
2408
|
-
}
|
2409
|
-
}
|
2410
|
-
},
|
2411
|
-
});
|
2412
|
-
})($ || ($ = {}));
|
2413
|
-
|
2414
1560
|
;
|
2415
1561
|
"use strict";
|
2416
1562
|
var $;
|
@@ -2441,6 +1587,15 @@ var $;
|
|
2441
1587
|
;
|
2442
1588
|
"use strict";
|
2443
1589
|
|
1590
|
+
;
|
1591
|
+
"use strict";
|
1592
|
+
|
1593
|
+
;
|
1594
|
+
"use strict";
|
1595
|
+
|
1596
|
+
;
|
1597
|
+
"use strict";
|
1598
|
+
|
2444
1599
|
;
|
2445
1600
|
"use strict";
|
2446
1601
|
var $;
|
@@ -3010,7 +2165,146 @@ var $;
|
|
3010
2165
|
$mol_assert_fail(() => list.sort(), TypeError);
|
3011
2166
|
$mol_assert_equal(list.toString(), '0,1,2,3,4');
|
3012
2167
|
}
|
3013
|
-
});
|
2168
|
+
});
|
2169
|
+
})($ || ($ = {}));
|
2170
|
+
|
2171
|
+
;
|
2172
|
+
"use strict";
|
2173
|
+
var $;
|
2174
|
+
(function ($) {
|
2175
|
+
$.$mol_compare_deep_cache = new WeakMap();
|
2176
|
+
function $mol_compare_deep(left, right) {
|
2177
|
+
if (Object.is(left, right))
|
2178
|
+
return true;
|
2179
|
+
if (left === null)
|
2180
|
+
return false;
|
2181
|
+
if (right === null)
|
2182
|
+
return false;
|
2183
|
+
if (typeof left !== 'object')
|
2184
|
+
return false;
|
2185
|
+
if (typeof right !== 'object')
|
2186
|
+
return false;
|
2187
|
+
const left_proto = Reflect.getPrototypeOf(left);
|
2188
|
+
const right_proto = Reflect.getPrototypeOf(right);
|
2189
|
+
if (left_proto !== right_proto)
|
2190
|
+
return false;
|
2191
|
+
if (left instanceof Boolean)
|
2192
|
+
return Object.is(left.valueOf(), right['valueOf']());
|
2193
|
+
if (left instanceof Number)
|
2194
|
+
return Object.is(left.valueOf(), right['valueOf']());
|
2195
|
+
if (left instanceof String)
|
2196
|
+
return Object.is(left.valueOf(), right['valueOf']());
|
2197
|
+
if (left instanceof Date)
|
2198
|
+
return Object.is(left.valueOf(), right['valueOf']());
|
2199
|
+
if (left instanceof RegExp)
|
2200
|
+
return left.source === right.source && left.flags === right.flags;
|
2201
|
+
if (left instanceof Error)
|
2202
|
+
return left.message === right.message && left.stack === right.stack;
|
2203
|
+
let left_cache = $.$mol_compare_deep_cache.get(left);
|
2204
|
+
if (left_cache) {
|
2205
|
+
const right_cache = left_cache.get(right);
|
2206
|
+
if (typeof right_cache === 'boolean')
|
2207
|
+
return right_cache;
|
2208
|
+
}
|
2209
|
+
else {
|
2210
|
+
left_cache = new WeakMap([[right, true]]);
|
2211
|
+
$.$mol_compare_deep_cache.set(left, left_cache);
|
2212
|
+
}
|
2213
|
+
let result;
|
2214
|
+
try {
|
2215
|
+
if (!left_proto)
|
2216
|
+
result = compare_pojo(left, right);
|
2217
|
+
else if (!Reflect.getPrototypeOf(left_proto))
|
2218
|
+
result = compare_pojo(left, right);
|
2219
|
+
else if (Symbol.toPrimitive in left)
|
2220
|
+
result = compare_primitive(left, right);
|
2221
|
+
else if (Array.isArray(left))
|
2222
|
+
result = compare_array(left, right);
|
2223
|
+
else if (left instanceof Set)
|
2224
|
+
result = compare_set(left, right);
|
2225
|
+
else if (left instanceof Map)
|
2226
|
+
result = compare_map(left, right);
|
2227
|
+
else if (ArrayBuffer.isView(left))
|
2228
|
+
result = compare_buffer(left, right);
|
2229
|
+
else if (Symbol.iterator in left)
|
2230
|
+
result = compare_iterator(left[Symbol.iterator](), right[Symbol.iterator]());
|
2231
|
+
else
|
2232
|
+
result = false;
|
2233
|
+
}
|
2234
|
+
finally {
|
2235
|
+
left_cache.set(right, result);
|
2236
|
+
}
|
2237
|
+
return result;
|
2238
|
+
}
|
2239
|
+
$.$mol_compare_deep = $mol_compare_deep;
|
2240
|
+
function compare_array(left, right) {
|
2241
|
+
const len = left.length;
|
2242
|
+
if (len !== right.length)
|
2243
|
+
return false;
|
2244
|
+
for (let i = 0; i < len; ++i) {
|
2245
|
+
if (!$mol_compare_deep(left[i], right[i]))
|
2246
|
+
return false;
|
2247
|
+
}
|
2248
|
+
return true;
|
2249
|
+
}
|
2250
|
+
function compare_buffer(left, right) {
|
2251
|
+
const len = left.byteLength;
|
2252
|
+
if (len !== right.byteLength)
|
2253
|
+
return false;
|
2254
|
+
if (left instanceof DataView)
|
2255
|
+
return compare_buffer(new Uint8Array(left.buffer, left.byteOffset, left.byteLength), new Uint8Array(right.buffer, left.byteOffset, left.byteLength));
|
2256
|
+
for (let i = 0; i < len; ++i) {
|
2257
|
+
if (left[i] !== right[i])
|
2258
|
+
return false;
|
2259
|
+
}
|
2260
|
+
return true;
|
2261
|
+
}
|
2262
|
+
function compare_iterator(left, right) {
|
2263
|
+
while (true) {
|
2264
|
+
const left_next = left.next();
|
2265
|
+
const right_next = right.next();
|
2266
|
+
if (left_next.done !== right_next.done)
|
2267
|
+
return false;
|
2268
|
+
if (left_next.done)
|
2269
|
+
break;
|
2270
|
+
if (!$mol_compare_deep(left_next.value, right_next.value))
|
2271
|
+
return false;
|
2272
|
+
}
|
2273
|
+
return true;
|
2274
|
+
}
|
2275
|
+
function compare_set(left, right) {
|
2276
|
+
if (left.size !== right.size)
|
2277
|
+
return false;
|
2278
|
+
return compare_iterator(left.values(), right.values());
|
2279
|
+
}
|
2280
|
+
function compare_map(left, right) {
|
2281
|
+
if (left.size !== right.size)
|
2282
|
+
return false;
|
2283
|
+
return compare_iterator(left.keys(), right.keys())
|
2284
|
+
&& compare_iterator(left.values(), right.values());
|
2285
|
+
}
|
2286
|
+
function compare_pojo(left, right) {
|
2287
|
+
const left_keys = Object.getOwnPropertyNames(left);
|
2288
|
+
const right_keys = Object.getOwnPropertyNames(right);
|
2289
|
+
if (!compare_array(left_keys, right_keys))
|
2290
|
+
return false;
|
2291
|
+
for (let key of left_keys) {
|
2292
|
+
if (!$mol_compare_deep(left[key], right[key]))
|
2293
|
+
return false;
|
2294
|
+
}
|
2295
|
+
const left_syms = Object.getOwnPropertySymbols(left);
|
2296
|
+
const right_syms = Object.getOwnPropertySymbols(right);
|
2297
|
+
if (!compare_array(left_syms, right_syms))
|
2298
|
+
return false;
|
2299
|
+
for (let key of left_syms) {
|
2300
|
+
if (!$mol_compare_deep(left[key], right[key]))
|
2301
|
+
return false;
|
2302
|
+
}
|
2303
|
+
return true;
|
2304
|
+
}
|
2305
|
+
function compare_primitive(left, right) {
|
2306
|
+
return Object.is(left[Symbol.toPrimitive]('default'), right[Symbol.toPrimitive]('default'));
|
2307
|
+
}
|
3014
2308
|
})($ || ($ = {}));
|
3015
2309
|
|
3016
2310
|
;
|
@@ -3508,348 +2802,6 @@ var $;
|
|
3508
2802
|
});
|
3509
2803
|
})($ || ($ = {}));
|
3510
2804
|
|
3511
|
-
;
|
3512
|
-
"use strict";
|
3513
|
-
var $;
|
3514
|
-
(function ($_1) {
|
3515
|
-
$mol_test({
|
3516
|
-
'Collect deps'() {
|
3517
|
-
const pub1 = new $mol_wire_pub;
|
3518
|
-
const pub2 = new $mol_wire_pub;
|
3519
|
-
const sub = new $mol_wire_pub_sub;
|
3520
|
-
const bu1 = sub.track_on();
|
3521
|
-
try {
|
3522
|
-
pub1.promote();
|
3523
|
-
pub2.promote();
|
3524
|
-
pub2.promote();
|
3525
|
-
}
|
3526
|
-
finally {
|
3527
|
-
sub.track_cut();
|
3528
|
-
sub.track_off(bu1);
|
3529
|
-
}
|
3530
|
-
pub1.emit();
|
3531
|
-
pub2.emit();
|
3532
|
-
$mol_assert_like(sub.pub_list, [pub1, pub2, pub2]);
|
3533
|
-
const bu2 = sub.track_on();
|
3534
|
-
try {
|
3535
|
-
pub1.promote();
|
3536
|
-
pub1.promote();
|
3537
|
-
pub2.promote();
|
3538
|
-
}
|
3539
|
-
finally {
|
3540
|
-
sub.track_cut();
|
3541
|
-
sub.track_off(bu2);
|
3542
|
-
}
|
3543
|
-
pub1.emit();
|
3544
|
-
pub2.emit();
|
3545
|
-
$mol_assert_like(sub.pub_list, [pub1, pub1, pub2]);
|
3546
|
-
},
|
3547
|
-
'cyclic detection'($) {
|
3548
|
-
const sub1 = new $mol_wire_pub_sub;
|
3549
|
-
const sub2 = new $mol_wire_pub_sub;
|
3550
|
-
const bu1 = sub1.track_on();
|
3551
|
-
try {
|
3552
|
-
const bu2 = sub2.track_on();
|
3553
|
-
try {
|
3554
|
-
$mol_assert_fail(() => sub1.promote(), 'Circular subscription');
|
3555
|
-
}
|
3556
|
-
finally {
|
3557
|
-
sub2.track_cut();
|
3558
|
-
sub2.track_off(bu2);
|
3559
|
-
}
|
3560
|
-
}
|
3561
|
-
finally {
|
3562
|
-
sub1.track_cut();
|
3563
|
-
sub1.track_off(bu1);
|
3564
|
-
}
|
3565
|
-
},
|
3566
|
-
});
|
3567
|
-
})($ || ($ = {}));
|
3568
|
-
|
3569
|
-
;
|
3570
|
-
"use strict";
|
3571
|
-
var $;
|
3572
|
-
(function ($) {
|
3573
|
-
$.$mol_after_mock_queue = [];
|
3574
|
-
function $mol_after_mock_warp() {
|
3575
|
-
const queue = $.$mol_after_mock_queue.splice(0);
|
3576
|
-
for (const task of queue)
|
3577
|
-
task();
|
3578
|
-
}
|
3579
|
-
$.$mol_after_mock_warp = $mol_after_mock_warp;
|
3580
|
-
class $mol_after_mock_commmon extends $mol_object2 {
|
3581
|
-
task;
|
3582
|
-
promise = Promise.resolve();
|
3583
|
-
cancelled = false;
|
3584
|
-
id;
|
3585
|
-
constructor(task) {
|
3586
|
-
super();
|
3587
|
-
this.task = task;
|
3588
|
-
$.$mol_after_mock_queue.push(task);
|
3589
|
-
}
|
3590
|
-
destructor() {
|
3591
|
-
const index = $.$mol_after_mock_queue.indexOf(this.task);
|
3592
|
-
if (index >= 0)
|
3593
|
-
$.$mol_after_mock_queue.splice(index, 1);
|
3594
|
-
}
|
3595
|
-
}
|
3596
|
-
$.$mol_after_mock_commmon = $mol_after_mock_commmon;
|
3597
|
-
class $mol_after_mock_timeout extends $mol_after_mock_commmon {
|
3598
|
-
delay;
|
3599
|
-
constructor(delay, task) {
|
3600
|
-
super(task);
|
3601
|
-
this.delay = delay;
|
3602
|
-
}
|
3603
|
-
}
|
3604
|
-
$.$mol_after_mock_timeout = $mol_after_mock_timeout;
|
3605
|
-
})($ || ($ = {}));
|
3606
|
-
|
3607
|
-
;
|
3608
|
-
"use strict";
|
3609
|
-
var $;
|
3610
|
-
(function ($_1) {
|
3611
|
-
$mol_test_mocks.push($ => {
|
3612
|
-
$.$mol_after_timeout = $mol_after_mock_timeout;
|
3613
|
-
});
|
3614
|
-
})($ || ($ = {}));
|
3615
|
-
|
3616
|
-
;
|
3617
|
-
"use strict";
|
3618
|
-
var $;
|
3619
|
-
(function ($_1) {
|
3620
|
-
$mol_test_mocks.push($ => {
|
3621
|
-
$.$mol_after_frame = $mol_after_mock_commmon;
|
3622
|
-
});
|
3623
|
-
})($ || ($ = {}));
|
3624
|
-
|
3625
|
-
;
|
3626
|
-
"use strict";
|
3627
|
-
var $;
|
3628
|
-
(function ($) {
|
3629
|
-
$mol_test({
|
3630
|
-
'Sync execution'() {
|
3631
|
-
class Sync extends $mol_object2 {
|
3632
|
-
static calc(a, b) {
|
3633
|
-
return a + b;
|
3634
|
-
}
|
3635
|
-
}
|
3636
|
-
__decorate([
|
3637
|
-
$mol_wire_method
|
3638
|
-
], Sync, "calc", null);
|
3639
|
-
$mol_assert_equal(Sync.calc(1, 2), 3);
|
3640
|
-
},
|
3641
|
-
async 'async <=> sync'() {
|
3642
|
-
class SyncAsync extends $mol_object2 {
|
3643
|
-
static async val(a) {
|
3644
|
-
return a;
|
3645
|
-
}
|
3646
|
-
static sum(a, b) {
|
3647
|
-
const syn = $mol_wire_sync(this);
|
3648
|
-
return syn.val(a) + syn.val(b);
|
3649
|
-
}
|
3650
|
-
static async calc(a, b) {
|
3651
|
-
return 5 + await $mol_wire_async(this).sum(a, b);
|
3652
|
-
}
|
3653
|
-
}
|
3654
|
-
$mol_assert_equal(await SyncAsync.calc(1, 2), 8);
|
3655
|
-
},
|
3656
|
-
async 'Idempotence control'() {
|
3657
|
-
class Idempotence extends $mol_object2 {
|
3658
|
-
static logs_idemp = 0;
|
3659
|
-
static logs_unidemp = 0;
|
3660
|
-
static log_idemp() {
|
3661
|
-
this.logs_idemp += 1;
|
3662
|
-
}
|
3663
|
-
static log_unidemp() {
|
3664
|
-
this.logs_unidemp += 1;
|
3665
|
-
}
|
3666
|
-
static async val(a) {
|
3667
|
-
return a;
|
3668
|
-
}
|
3669
|
-
static sum(a, b) {
|
3670
|
-
this.log_idemp();
|
3671
|
-
this.log_unidemp();
|
3672
|
-
const syn = $mol_wire_sync(this);
|
3673
|
-
return syn.val(a) + syn.val(b);
|
3674
|
-
}
|
3675
|
-
static async calc(a, b) {
|
3676
|
-
return 5 + await $mol_wire_async(this).sum(a, b);
|
3677
|
-
}
|
3678
|
-
}
|
3679
|
-
__decorate([
|
3680
|
-
$mol_wire_method
|
3681
|
-
], Idempotence, "log_idemp", null);
|
3682
|
-
$mol_assert_equal(await Idempotence.calc(1, 2), 8);
|
3683
|
-
$mol_assert_equal(Idempotence.logs_idemp, 1);
|
3684
|
-
$mol_assert_equal(Idempotence.logs_unidemp, 3);
|
3685
|
-
},
|
3686
|
-
async 'Error handling'() {
|
3687
|
-
class Handle extends $mol_object2 {
|
3688
|
-
static async sum(a, b) {
|
3689
|
-
$mol_fail(new Error('test error ' + (a + b)));
|
3690
|
-
}
|
3691
|
-
static check() {
|
3692
|
-
try {
|
3693
|
-
return $mol_wire_sync(Handle).sum(1, 2);
|
3694
|
-
}
|
3695
|
-
catch (error) {
|
3696
|
-
if ($mol_promise_like(error))
|
3697
|
-
$mol_fail_hidden(error);
|
3698
|
-
$mol_assert_equal(error.message, 'test error 3');
|
3699
|
-
}
|
3700
|
-
}
|
3701
|
-
}
|
3702
|
-
await $mol_wire_async(Handle).check();
|
3703
|
-
},
|
3704
|
-
});
|
3705
|
-
})($ || ($ = {}));
|
3706
|
-
|
3707
|
-
;
|
3708
|
-
"use strict";
|
3709
|
-
var $;
|
3710
|
-
(function ($) {
|
3711
|
-
function $mol_wire_method(host, field, descr) {
|
3712
|
-
if (!descr)
|
3713
|
-
descr = Reflect.getOwnPropertyDescriptor(host, field);
|
3714
|
-
const orig = descr?.value ?? host[field];
|
3715
|
-
const sup = Reflect.getPrototypeOf(host);
|
3716
|
-
if (typeof sup[field] === 'function') {
|
3717
|
-
Object.defineProperty(orig, 'name', { value: sup[field].name });
|
3718
|
-
}
|
3719
|
-
const temp = $mol_wire_task.getter(orig);
|
3720
|
-
const value = function (...args) {
|
3721
|
-
const fiber = temp(this ?? null, args);
|
3722
|
-
return fiber.sync();
|
3723
|
-
};
|
3724
|
-
Object.defineProperty(value, 'name', { value: orig.name + ' ' });
|
3725
|
-
Object.assign(value, { orig });
|
3726
|
-
const descr2 = { ...descr, value };
|
3727
|
-
Reflect.defineProperty(host, field, descr2);
|
3728
|
-
return descr2;
|
3729
|
-
}
|
3730
|
-
$.$mol_wire_method = $mol_wire_method;
|
3731
|
-
})($ || ($ = {}));
|
3732
|
-
|
3733
|
-
;
|
3734
|
-
"use strict";
|
3735
|
-
var $;
|
3736
|
-
(function ($) {
|
3737
|
-
function $mol_promise() {
|
3738
|
-
let done;
|
3739
|
-
let fail;
|
3740
|
-
const promise = new Promise((d, f) => {
|
3741
|
-
done = d;
|
3742
|
-
fail = f;
|
3743
|
-
});
|
3744
|
-
return Object.assign(promise, {
|
3745
|
-
done,
|
3746
|
-
fail,
|
3747
|
-
});
|
3748
|
-
}
|
3749
|
-
$.$mol_promise = $mol_promise;
|
3750
|
-
})($ || ($ = {}));
|
3751
|
-
|
3752
|
-
;
|
3753
|
-
"use strict";
|
3754
|
-
var $;
|
3755
|
-
(function ($) {
|
3756
|
-
function $mol_wait_timeout_async(timeout) {
|
3757
|
-
const promise = $mol_promise();
|
3758
|
-
const task = new this.$mol_after_timeout(timeout, () => promise.done());
|
3759
|
-
return Object.assign(promise, {
|
3760
|
-
destructor: () => task.destructor()
|
3761
|
-
});
|
3762
|
-
}
|
3763
|
-
$.$mol_wait_timeout_async = $mol_wait_timeout_async;
|
3764
|
-
function $mol_wait_timeout(timeout) {
|
3765
|
-
return this.$mol_wire_sync(this).$mol_wait_timeout_async(timeout);
|
3766
|
-
}
|
3767
|
-
$.$mol_wait_timeout = $mol_wait_timeout;
|
3768
|
-
})($ || ($ = {}));
|
3769
|
-
|
3770
|
-
;
|
3771
|
-
"use strict";
|
3772
|
-
var $;
|
3773
|
-
(function ($) {
|
3774
|
-
function $mol_wire_async(obj) {
|
3775
|
-
let fiber;
|
3776
|
-
const temp = $mol_wire_task.getter(obj);
|
3777
|
-
return new Proxy(obj, {
|
3778
|
-
get(obj, field) {
|
3779
|
-
const val = obj[field];
|
3780
|
-
if (typeof val !== 'function')
|
3781
|
-
return val;
|
3782
|
-
let fiber;
|
3783
|
-
const temp = $mol_wire_task.getter(val);
|
3784
|
-
return function $mol_wire_async(...args) {
|
3785
|
-
fiber?.destructor();
|
3786
|
-
fiber = temp(obj, args);
|
3787
|
-
return fiber.async();
|
3788
|
-
};
|
3789
|
-
},
|
3790
|
-
apply(obj, self, args) {
|
3791
|
-
fiber?.destructor();
|
3792
|
-
fiber = temp(self, args);
|
3793
|
-
return fiber.async();
|
3794
|
-
},
|
3795
|
-
});
|
3796
|
-
}
|
3797
|
-
$.$mol_wire_async = $mol_wire_async;
|
3798
|
-
})($ || ($ = {}));
|
3799
|
-
|
3800
|
-
;
|
3801
|
-
"use strict";
|
3802
|
-
var $;
|
3803
|
-
(function ($_1) {
|
3804
|
-
$mol_test({
|
3805
|
-
'test types'($) {
|
3806
|
-
class A {
|
3807
|
-
static a() {
|
3808
|
-
return '';
|
3809
|
-
}
|
3810
|
-
static b() {
|
3811
|
-
return $mol_wire_async(this).a();
|
3812
|
-
}
|
3813
|
-
}
|
3814
|
-
},
|
3815
|
-
async 'Latest method calls wins'($) {
|
3816
|
-
class NameLogger extends $mol_object2 {
|
3817
|
-
static $ = $;
|
3818
|
-
static first = [];
|
3819
|
-
static last = [];
|
3820
|
-
static send(next) {
|
3821
|
-
$mol_wire_sync(this.first).push(next);
|
3822
|
-
this.$.$mol_wait_timeout(0);
|
3823
|
-
this.last.push(next);
|
3824
|
-
}
|
3825
|
-
}
|
3826
|
-
const name = $mol_wire_async(NameLogger).send;
|
3827
|
-
name('john');
|
3828
|
-
const promise = name('jin');
|
3829
|
-
$.$mol_after_mock_warp();
|
3830
|
-
await promise;
|
3831
|
-
$mol_assert_like(NameLogger.first, ['john', 'jin']);
|
3832
|
-
$mol_assert_like(NameLogger.last, ['jin']);
|
3833
|
-
},
|
3834
|
-
async 'Latest function calls wins'($) {
|
3835
|
-
const first = [];
|
3836
|
-
const last = [];
|
3837
|
-
function send_name(next) {
|
3838
|
-
$mol_wire_sync(first).push(next);
|
3839
|
-
$.$mol_wait_timeout(0);
|
3840
|
-
last.push(next);
|
3841
|
-
}
|
3842
|
-
const name = $mol_wire_async(send_name);
|
3843
|
-
name('john');
|
3844
|
-
const promise = name('jin');
|
3845
|
-
$.$mol_after_mock_warp();
|
3846
|
-
await promise;
|
3847
|
-
$mol_assert_like(first, ['john', 'jin']);
|
3848
|
-
$mol_assert_like(last, ['jin']);
|
3849
|
-
},
|
3850
|
-
});
|
3851
|
-
})($ || ($ = {}));
|
3852
|
-
|
3853
2805
|
;
|
3854
2806
|
"use strict";
|
3855
2807
|
var $;
|