mol_db 0.0.1006 → 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.test.js CHANGED
@@ -42,124 +42,341 @@ var $;
42
42
  "use strict";
43
43
  var $;
44
44
  (function ($) {
45
- function $mol_promise_like(val) {
46
- return val && typeof val === 'object' && 'then' in val && typeof val.then === 'function';
47
- }
48
- $.$mol_promise_like = $mol_promise_like;
45
+ let $mol_wire_cursor;
46
+ (function ($mol_wire_cursor) {
47
+ $mol_wire_cursor[$mol_wire_cursor["stale"] = -1] = "stale";
48
+ $mol_wire_cursor[$mol_wire_cursor["doubt"] = -2] = "doubt";
49
+ $mol_wire_cursor[$mol_wire_cursor["fresh"] = -3] = "fresh";
50
+ $mol_wire_cursor[$mol_wire_cursor["final"] = -4] = "final";
51
+ })($mol_wire_cursor = $.$mol_wire_cursor || ($.$mol_wire_cursor = {}));
49
52
  })($ || ($ = {}));
50
53
 
51
54
  ;
52
55
  "use strict";
53
56
  var $;
54
57
  (function ($) {
55
- function $mol_fail_hidden(error) {
56
- throw error;
58
+ class $mol_wire_pub extends Object {
59
+ data = [];
60
+ static get [Symbol.species]() {
61
+ return Array;
62
+ }
63
+ sub_from = 0;
64
+ get sub_list() {
65
+ const res = [];
66
+ for (let i = this.sub_from; i < this.data.length; i += 2) {
67
+ res.push(this.data[i]);
68
+ }
69
+ return res;
70
+ }
71
+ get sub_empty() {
72
+ return this.sub_from === this.data.length;
73
+ }
74
+ sub_on(sub, pub_pos) {
75
+ const pos = this.data.length;
76
+ this.data.push(sub, pub_pos);
77
+ return pos;
78
+ }
79
+ sub_off(sub_pos) {
80
+ if (!(sub_pos < this.data.length)) {
81
+ $mol_fail(new Error(`Wrong pos ${sub_pos}`));
82
+ }
83
+ const end = this.data.length - 2;
84
+ if (sub_pos !== end) {
85
+ this.peer_move(end, sub_pos);
86
+ }
87
+ this.data.pop();
88
+ this.data.pop();
89
+ if (this.data.length === this.sub_from)
90
+ this.reap();
91
+ }
92
+ reap() { }
93
+ promote() {
94
+ $mol_wire_auto()?.track_next(this);
95
+ }
96
+ fresh() { }
97
+ complete() { }
98
+ get incompleted() {
99
+ return false;
100
+ }
101
+ emit(quant = $mol_wire_cursor.stale) {
102
+ for (let i = this.sub_from; i < this.data.length; i += 2) {
103
+ ;
104
+ this.data[i].absorb(quant);
105
+ }
106
+ }
107
+ peer_move(from_pos, to_pos) {
108
+ const peer = this.data[from_pos];
109
+ const self_pos = this.data[from_pos + 1];
110
+ this.data[to_pos] = peer;
111
+ this.data[to_pos + 1] = self_pos;
112
+ peer.peer_repos(self_pos, to_pos);
113
+ }
114
+ peer_repos(peer_pos, self_pos) {
115
+ this.data[peer_pos + 1] = self_pos;
116
+ }
57
117
  }
58
- $.$mol_fail_hidden = $mol_fail_hidden;
118
+ $.$mol_wire_pub = $mol_wire_pub;
59
119
  })($ || ($ = {}));
60
120
 
121
+ ;
122
+ "use strict";
123
+
61
124
  ;
62
125
  "use strict";
63
126
  var $;
64
127
  (function ($) {
65
- const catched = new WeakMap();
66
- function $mol_fail_catch(error) {
67
- if (typeof error !== 'object')
68
- return false;
69
- if ($mol_promise_like(error))
70
- $mol_fail_hidden(error);
71
- if (catched.get(error))
72
- return false;
73
- catched.set(error, true);
74
- return true;
128
+ $.$mol_wire_auto_sub = null;
129
+ function $mol_wire_auto(next = $.$mol_wire_auto_sub) {
130
+ return $.$mol_wire_auto_sub = next;
75
131
  }
76
- $.$mol_fail_catch = $mol_fail_catch;
132
+ $.$mol_wire_auto = $mol_wire_auto;
133
+ $.$mol_wire_affected = [];
77
134
  })($ || ($ = {}));
78
135
 
79
136
  ;
80
137
  "use strict";
81
138
  var $;
82
139
  (function ($) {
83
- function $mol_fail_log(error) {
84
- if ($mol_promise_like(error))
85
- return false;
86
- if (!$mol_fail_catch(error))
87
- return false;
88
- console.error(error);
89
- return true;
140
+ $['devtoolsFormatters'] ||= [];
141
+ function $mol_dev_format_register(config) {
142
+ $['devtoolsFormatters'].push(config);
90
143
  }
91
- $.$mol_fail_log = $mol_fail_log;
144
+ $.$mol_dev_format_register = $mol_dev_format_register;
145
+ $.$mol_dev_format_head = Symbol('$mol_dev_format_head');
146
+ $.$mol_dev_format_body = Symbol('$mol_dev_format_body');
147
+ $mol_dev_format_register({
148
+ header: (val, config = false) => {
149
+ if (config)
150
+ return null;
151
+ if (!val)
152
+ return null;
153
+ if ($.$mol_dev_format_head in val) {
154
+ try {
155
+ return val[$.$mol_dev_format_head]();
156
+ }
157
+ catch (error) {
158
+ return $.$mol_dev_format_accent($mol_dev_format_native(val), '💨', $mol_dev_format_native(error), '');
159
+ }
160
+ }
161
+ if (typeof val === 'function') {
162
+ return $mol_dev_format_native(val);
163
+ }
164
+ if (Symbol.toStringTag in val) {
165
+ return $mol_dev_format_native(val);
166
+ }
167
+ return null;
168
+ },
169
+ hasBody: val => val[$.$mol_dev_format_body],
170
+ body: val => val[$.$mol_dev_format_body](),
171
+ });
172
+ function $mol_dev_format_native(obj) {
173
+ if (typeof obj === 'undefined')
174
+ return $.$mol_dev_format_shade('undefined');
175
+ return [
176
+ 'object',
177
+ {
178
+ object: obj,
179
+ config: true,
180
+ },
181
+ ];
182
+ }
183
+ $.$mol_dev_format_native = $mol_dev_format_native;
184
+ function $mol_dev_format_auto(obj) {
185
+ if (obj == null)
186
+ return $.$mol_dev_format_shade(String(obj));
187
+ return [
188
+ 'object',
189
+ {
190
+ object: obj,
191
+ config: false,
192
+ },
193
+ ];
194
+ }
195
+ $.$mol_dev_format_auto = $mol_dev_format_auto;
196
+ function $mol_dev_format_element(element, style, ...content) {
197
+ const styles = [];
198
+ for (let key in style)
199
+ styles.push(`${key} : ${style[key]}`);
200
+ return [
201
+ element,
202
+ {
203
+ style: styles.join(' ; '),
204
+ },
205
+ ...content,
206
+ ];
207
+ }
208
+ $.$mol_dev_format_element = $mol_dev_format_element;
209
+ function $mol_dev_format_span(style, ...content) {
210
+ return $mol_dev_format_element('span', {
211
+ ...style,
212
+ }, ...content);
213
+ }
214
+ $.$mol_dev_format_span = $mol_dev_format_span;
215
+ $.$mol_dev_format_div = $mol_dev_format_element.bind(null, 'div');
216
+ $.$mol_dev_format_ol = $mol_dev_format_element.bind(null, 'ol');
217
+ $.$mol_dev_format_li = $mol_dev_format_element.bind(null, 'li');
218
+ $.$mol_dev_format_table = $mol_dev_format_element.bind(null, 'table');
219
+ $.$mol_dev_format_tr = $mol_dev_format_element.bind(null, 'tr');
220
+ $.$mol_dev_format_td = $mol_dev_format_element.bind(null, 'td');
221
+ $.$mol_dev_format_accent = $mol_dev_format_span.bind(null, {
222
+ 'color': 'magenta',
223
+ });
224
+ $.$mol_dev_format_strong = $mol_dev_format_span.bind(null, {
225
+ 'font-weight': 'bold',
226
+ });
227
+ $.$mol_dev_format_string = $mol_dev_format_span.bind(null, {
228
+ 'color': 'green',
229
+ });
230
+ $.$mol_dev_format_shade = $mol_dev_format_span.bind(null, {
231
+ 'color': 'gray',
232
+ });
233
+ $.$mol_dev_format_indent = $.$mol_dev_format_div.bind(null, {
234
+ 'margin-left': '13px'
235
+ });
92
236
  })($ || ($ = {}));
93
237
 
94
238
  ;
95
239
  "use strict";
96
- var $node = new Proxy({ require }, {
97
- get(target, name, wrapper) {
98
- if (target[name])
99
- return target[name];
100
- const mod = target.require('module');
101
- if (mod.builtinModules.indexOf(name) >= 0)
102
- return target.require(name);
103
- if (name[0] === '.')
104
- return target.require(name);
105
- const path = target.require('path');
106
- const fs = target.require('fs');
107
- let dir = path.resolve('.');
108
- const suffix = `./node_modules/${name}`;
109
- const $$ = $;
110
- while (!fs.existsSync(path.join(dir, suffix))) {
111
- const parent = path.resolve(dir, '..');
112
- if (parent === dir) {
113
- $$.$mol_exec('.', 'npm', 'install', '--omit=dev', name);
114
- try {
115
- $$.$mol_exec('.', 'npm', 'install', '--omit=dev', '@types/' + name);
240
+ var $;
241
+ (function ($) {
242
+ class $mol_wire_pub_sub extends $mol_wire_pub {
243
+ pub_from = 0;
244
+ cursor = $mol_wire_cursor.stale;
245
+ get temp() {
246
+ return false;
247
+ }
248
+ get pub_list() {
249
+ const res = [];
250
+ const max = this.cursor >= 0 ? this.cursor : this.sub_from;
251
+ for (let i = this.pub_from; i < max; i += 2) {
252
+ if (this.data[i])
253
+ res.push(this.data[i]);
254
+ }
255
+ return res;
256
+ }
257
+ track_on() {
258
+ this.cursor = this.pub_from;
259
+ const sub = $mol_wire_auto();
260
+ $mol_wire_auto(this);
261
+ return sub;
262
+ }
263
+ promote() {
264
+ if (this.cursor >= this.pub_from) {
265
+ $mol_fail(new Error('Circular subscription'));
266
+ }
267
+ super.promote();
268
+ }
269
+ track_next(pub) {
270
+ if (this.cursor < 0)
271
+ $mol_fail(new Error('Promo to non begun sub'));
272
+ if (this.cursor < this.sub_from) {
273
+ const next = this.data[this.cursor];
274
+ if (pub === undefined)
275
+ return next ?? null;
276
+ if (next === pub) {
277
+ this.cursor += 2;
278
+ return next;
279
+ }
280
+ if (next) {
281
+ if (this.sub_from < this.data.length) {
282
+ this.peer_move(this.sub_from, this.data.length);
283
+ }
284
+ this.peer_move(this.cursor, this.sub_from);
285
+ this.sub_from += 2;
116
286
  }
117
- catch { }
118
- break;
119
287
  }
120
288
  else {
121
- dir = parent;
289
+ if (pub === undefined)
290
+ return null;
291
+ if (this.sub_from < this.data.length) {
292
+ this.peer_move(this.sub_from, this.data.length);
293
+ }
294
+ this.sub_from += 2;
122
295
  }
296
+ this.data[this.cursor] = pub;
297
+ this.data[this.cursor + 1] = pub.sub_on(this, this.cursor);
298
+ this.cursor += 2;
299
+ return pub;
123
300
  }
124
- try {
125
- return target.require(name);
301
+ track_off(sub) {
302
+ $mol_wire_auto(sub);
303
+ if (this.cursor < 0) {
304
+ $mol_fail(new Error('End of non begun sub'));
305
+ }
306
+ for (let cursor = this.pub_from; cursor < this.cursor; cursor += 2) {
307
+ const pub = this.data[cursor];
308
+ pub.fresh();
309
+ }
310
+ this.cursor = $mol_wire_cursor.fresh;
126
311
  }
127
- catch (error) {
128
- $.$mol_fail_log(error);
129
- return null;
312
+ pub_off(sub_pos) {
313
+ this.data[sub_pos] = undefined;
314
+ this.data[sub_pos + 1] = undefined;
315
+ }
316
+ destructor() {
317
+ for (let cursor = this.data.length - 2; cursor >= this.sub_from; cursor -= 2) {
318
+ const sub = this.data[cursor];
319
+ const pos = this.data[cursor + 1];
320
+ sub.pub_off(pos);
321
+ this.data.pop();
322
+ this.data.pop();
323
+ }
324
+ this.cursor = this.pub_from;
325
+ this.track_cut();
326
+ this.cursor = $mol_wire_cursor.final;
327
+ }
328
+ track_cut() {
329
+ if (this.cursor < this.pub_from) {
330
+ $mol_fail(new Error('Cut of non begun sub'));
331
+ }
332
+ let tail = 0;
333
+ for (let cursor = this.cursor; cursor < this.sub_from; cursor += 2) {
334
+ const pub = this.data[cursor];
335
+ pub?.sub_off(this.data[cursor + 1]);
336
+ if (this.sub_from < this.data.length) {
337
+ this.peer_move(this.data.length - 2, cursor);
338
+ this.data.pop();
339
+ this.data.pop();
340
+ }
341
+ else {
342
+ ++tail;
343
+ }
344
+ }
345
+ for (; tail; --tail) {
346
+ this.data.pop();
347
+ this.data.pop();
348
+ }
349
+ this.sub_from = this.cursor;
350
+ }
351
+ complete() { }
352
+ complete_pubs() {
353
+ const limit = this.cursor < 0 ? this.sub_from : this.cursor;
354
+ for (let cursor = this.pub_from; cursor < limit; cursor += 2) {
355
+ const pub = this.data[cursor];
356
+ if (pub?.incompleted)
357
+ return;
358
+ }
359
+ for (let cursor = this.pub_from; cursor < limit; cursor += 2) {
360
+ const pub = this.data[cursor];
361
+ pub?.complete();
362
+ }
363
+ }
364
+ absorb(quant = $mol_wire_cursor.stale) {
365
+ if (this.cursor === $mol_wire_cursor.final)
366
+ return;
367
+ if (this.cursor >= quant)
368
+ return;
369
+ this.cursor = quant;
370
+ this.emit($mol_wire_cursor.doubt);
371
+ }
372
+ [$mol_dev_format_head]() {
373
+ return $mol_dev_format_native(this);
374
+ }
375
+ get pub_empty() {
376
+ return this.sub_from === this.pub_from;
130
377
  }
131
- },
132
- set(target, name, value) {
133
- target[name] = value;
134
- return true;
135
- },
136
- });
137
- require = (req => Object.assign(function require(name) {
138
- return $node[name];
139
- }, req))(require);
140
-
141
- ;
142
- "use strict";
143
- var $;
144
- (function ($) {
145
- function $mol_log3_area_lazy(event) {
146
- const self = this;
147
- const stack = self.$mol_log3_stack;
148
- const deep = stack.length;
149
- let logged = false;
150
- stack.push(() => {
151
- logged = true;
152
- self.$mol_log3_area.call(self, event);
153
- });
154
- return () => {
155
- if (logged)
156
- self.console.groupEnd();
157
- if (stack.length > deep)
158
- stack.length = deep;
159
- };
160
378
  }
161
- $.$mol_log3_area_lazy = $mol_log3_area_lazy;
162
- $.$mol_log3_stack = [];
379
+ $.$mol_wire_pub_sub = $mol_wire_pub_sub;
163
380
  })($ || ($ = {}));
164
381
 
165
382
  ;
@@ -254,94 +471,537 @@ var $;
254
471
  return false;
255
472
  return true;
256
473
  }
257
- $.$mol_owning_check = $mol_owning_check;
258
- function $mol_owning_catch(owner, having) {
259
- if (!$mol_owning_allow(having))
474
+ $.$mol_owning_check = $mol_owning_check;
475
+ function $mol_owning_catch(owner, having) {
476
+ if (!$mol_owning_allow(having))
477
+ return false;
478
+ if ($.$mol_owning_map.get(having))
479
+ return false;
480
+ $.$mol_owning_map.set(having, owner);
481
+ return true;
482
+ }
483
+ $.$mol_owning_catch = $mol_owning_catch;
484
+ })($ || ($ = {}));
485
+
486
+ ;
487
+ "use strict";
488
+ var $;
489
+ (function ($) {
490
+ function $mol_fail_hidden(error) {
491
+ throw error;
492
+ }
493
+ $.$mol_fail_hidden = $mol_fail_hidden;
494
+ })($ || ($ = {}));
495
+
496
+ ;
497
+ "use strict";
498
+
499
+ ;
500
+ "use strict";
501
+ var $;
502
+ (function ($) {
503
+ const named = new WeakSet();
504
+ function $mol_func_name(func) {
505
+ let name = func.name;
506
+ if (name?.length > 1)
507
+ return name;
508
+ if (named.has(func))
509
+ return name;
510
+ for (let key in this) {
511
+ try {
512
+ if (this[key] !== func)
513
+ continue;
514
+ name = key;
515
+ Object.defineProperty(func, 'name', { value: name });
516
+ break;
517
+ }
518
+ catch { }
519
+ }
520
+ named.add(func);
521
+ return name;
522
+ }
523
+ $.$mol_func_name = $mol_func_name;
524
+ function $mol_func_name_from(target, source) {
525
+ Object.defineProperty(target, 'name', { value: source.name });
526
+ return target;
527
+ }
528
+ $.$mol_func_name_from = $mol_func_name_from;
529
+ })($ || ($ = {}));
530
+
531
+ ;
532
+ "use strict";
533
+ var $;
534
+ (function ($) {
535
+ class $mol_object2 {
536
+ static $ = $;
537
+ [Symbol.toStringTag];
538
+ [$mol_ambient_ref] = null;
539
+ get $() {
540
+ if (this[$mol_ambient_ref])
541
+ return this[$mol_ambient_ref];
542
+ const owner = $mol_owning_get(this);
543
+ return this[$mol_ambient_ref] = owner?.$ || $mol_object2.$;
544
+ }
545
+ set $(next) {
546
+ if (this[$mol_ambient_ref])
547
+ $mol_fail_hidden(new Error('Context already defined'));
548
+ this[$mol_ambient_ref] = next;
549
+ }
550
+ static create(init) {
551
+ const obj = new this;
552
+ if (init)
553
+ init(obj);
554
+ return obj;
555
+ }
556
+ static [Symbol.toPrimitive]() {
557
+ return this.toString();
558
+ }
559
+ static toString() {
560
+ return this[Symbol.toStringTag] || this.$.$mol_func_name(this);
561
+ }
562
+ static toJSON() {
563
+ return this.toString();
564
+ }
565
+ destructor() { }
566
+ static destructor() { }
567
+ toString() {
568
+ return this[Symbol.toStringTag] || this.constructor.name + '<>';
569
+ }
570
+ }
571
+ $.$mol_object2 = $mol_object2;
572
+ })($ || ($ = {}));
573
+
574
+ ;
575
+ "use strict";
576
+ var $;
577
+ (function ($) {
578
+ class $mol_after_timeout extends $mol_object2 {
579
+ delay;
580
+ task;
581
+ id;
582
+ constructor(delay, task) {
583
+ super();
584
+ this.delay = delay;
585
+ this.task = task;
586
+ this.id = setTimeout(task, delay);
587
+ }
588
+ destructor() {
589
+ clearTimeout(this.id);
590
+ }
591
+ }
592
+ $.$mol_after_timeout = $mol_after_timeout;
593
+ })($ || ($ = {}));
594
+
595
+ ;
596
+ "use strict";
597
+ var $;
598
+ (function ($) {
599
+ class $mol_after_frame extends $mol_after_timeout {
600
+ task;
601
+ constructor(task) {
602
+ super(16, task);
603
+ this.task = task;
604
+ }
605
+ }
606
+ $.$mol_after_frame = $mol_after_frame;
607
+ })($ || ($ = {}));
608
+
609
+ ;
610
+ "use strict";
611
+ var $;
612
+ (function ($) {
613
+ function $mol_promise_like(val) {
614
+ return val && typeof val === 'object' && 'then' in val && typeof val.then === 'function';
615
+ }
616
+ $.$mol_promise_like = $mol_promise_like;
617
+ })($ || ($ = {}));
618
+
619
+ ;
620
+ "use strict";
621
+ var $;
622
+ (function ($) {
623
+ const handled = new WeakSet();
624
+ class $mol_wire_fiber extends $mol_wire_pub_sub {
625
+ task;
626
+ host;
627
+ static warm = true;
628
+ static planning = new Set();
629
+ static reaping = new Set();
630
+ static plan_task = null;
631
+ static plan() {
632
+ if (this.plan_task)
633
+ return;
634
+ this.plan_task = new $mol_after_frame(() => {
635
+ try {
636
+ this.sync();
637
+ }
638
+ finally {
639
+ $mol_wire_fiber.plan_task = null;
640
+ }
641
+ });
642
+ }
643
+ static sync() {
644
+ while (this.planning.size) {
645
+ for (const fiber of this.planning) {
646
+ this.planning.delete(fiber);
647
+ if (fiber.cursor >= 0)
648
+ continue;
649
+ if (fiber.cursor === $mol_wire_cursor.final)
650
+ continue;
651
+ fiber.fresh();
652
+ }
653
+ }
654
+ while (this.reaping.size) {
655
+ const fibers = this.reaping;
656
+ this.reaping = new Set;
657
+ for (const fiber of fibers) {
658
+ if (!fiber.sub_empty)
659
+ continue;
660
+ fiber.destructor();
661
+ }
662
+ }
663
+ }
664
+ [Symbol.toStringTag];
665
+ cache = undefined;
666
+ get args() {
667
+ return this.data.slice(0, this.pub_from);
668
+ }
669
+ result() {
670
+ if ($mol_promise_like(this.cache))
671
+ return;
672
+ if (this.cache instanceof Error)
673
+ return;
674
+ return this.cache;
675
+ }
676
+ get incompleted() {
677
+ return $mol_promise_like(this.cache);
678
+ }
679
+ field() {
680
+ return this.task.name + '<>';
681
+ }
682
+ constructor(id, task, host, args) {
683
+ super();
684
+ this.task = task;
685
+ this.host = host;
686
+ if (args)
687
+ this.data.push(...args);
688
+ this.pub_from = this.sub_from = args?.length ?? 0;
689
+ this[Symbol.toStringTag] = id;
690
+ }
691
+ plan() {
692
+ $mol_wire_fiber.planning.add(this);
693
+ $mol_wire_fiber.plan();
694
+ }
695
+ reap() {
696
+ $mol_wire_fiber.reaping.add(this);
697
+ $mol_wire_fiber.plan();
698
+ }
699
+ toString() {
700
+ return this[Symbol.toStringTag];
701
+ }
702
+ toJSON() {
703
+ return this[Symbol.toStringTag];
704
+ }
705
+ [$mol_dev_format_head]() {
706
+ const cursor = {
707
+ [$mol_wire_cursor.stale]: '🔴',
708
+ [$mol_wire_cursor.doubt]: '🟡',
709
+ [$mol_wire_cursor.fresh]: '🟢',
710
+ [$mol_wire_cursor.final]: '🔵',
711
+ }[this.cursor] ?? this.cursor.toString();
712
+ return $mol_dev_format_div({}, $mol_owning_check(this, this.cache)
713
+ ? $mol_dev_format_auto({
714
+ [$mol_dev_format_head]: () => $mol_dev_format_shade(cursor),
715
+ [$mol_dev_format_body]: () => $mol_dev_format_native(this),
716
+ })
717
+ : $mol_dev_format_shade($mol_dev_format_native(this), cursor), $mol_dev_format_auto(this.cache));
718
+ }
719
+ get $() {
720
+ return (this.host ?? this.task)['$'];
721
+ }
722
+ emit(quant = $mol_wire_cursor.stale) {
723
+ if (this.sub_empty)
724
+ this.plan();
725
+ else
726
+ super.emit(quant);
727
+ }
728
+ fresh() {
729
+ if (this.cursor === $mol_wire_cursor.fresh)
730
+ return;
731
+ if (this.cursor === $mol_wire_cursor.final)
732
+ return;
733
+ check: if (this.cursor === $mol_wire_cursor.doubt) {
734
+ for (let i = this.pub_from; i < this.sub_from; i += 2) {
735
+ ;
736
+ this.data[i]?.fresh();
737
+ if (this.cursor !== $mol_wire_cursor.doubt)
738
+ break check;
739
+ }
740
+ this.cursor = $mol_wire_cursor.fresh;
741
+ return;
742
+ }
743
+ const bu = this.track_on();
744
+ let result;
745
+ try {
746
+ switch (this.pub_from) {
747
+ case 0:
748
+ result = this.task.call(this.host);
749
+ break;
750
+ case 1:
751
+ result = this.task.call(this.host, this.data[0]);
752
+ break;
753
+ default:
754
+ result = this.task.call(this.host, ...this.args);
755
+ break;
756
+ }
757
+ if ($mol_promise_like(result) && !handled.has(result)) {
758
+ const put = (res) => {
759
+ if (this.cache === result)
760
+ this.put(res);
761
+ return res;
762
+ };
763
+ result = result.then(put, put);
764
+ }
765
+ }
766
+ catch (error) {
767
+ if (error instanceof Error || $mol_promise_like(error)) {
768
+ result = error;
769
+ }
770
+ else {
771
+ result = new Error(String(error), { cause: error });
772
+ }
773
+ if ($mol_promise_like(result) && !handled.has(result)) {
774
+ result = result.finally(() => {
775
+ if (this.cache === result)
776
+ this.absorb();
777
+ });
778
+ }
779
+ }
780
+ if ($mol_promise_like(result) && !handled.has(result)) {
781
+ result = Object.assign(result, {
782
+ destructor: result['destructor'] ?? (() => { })
783
+ });
784
+ handled.add(result);
785
+ const error = new Error(`Promise in ${this}`);
786
+ Object.defineProperty(result, 'stack', { get: () => error.stack });
787
+ }
788
+ if (!$mol_promise_like(result)) {
789
+ this.track_cut();
790
+ }
791
+ this.track_off(bu);
792
+ this.put(result);
793
+ }
794
+ refresh() {
795
+ this.cursor = $mol_wire_cursor.stale;
796
+ this.fresh();
797
+ }
798
+ sync() {
799
+ if (!$mol_wire_fiber.warm) {
800
+ return this.result();
801
+ }
802
+ this.promote();
803
+ this.fresh();
804
+ if (this.cache instanceof Error) {
805
+ return $mol_fail_hidden(this.cache);
806
+ }
807
+ if ($mol_promise_like(this.cache)) {
808
+ return $mol_fail_hidden(this.cache);
809
+ }
810
+ return this.cache;
811
+ }
812
+ async async() {
813
+ while (true) {
814
+ this.fresh();
815
+ if (this.cache instanceof Error) {
816
+ $mol_fail_hidden(this.cache);
817
+ }
818
+ if (!$mol_promise_like(this.cache))
819
+ return this.cache;
820
+ await Promise.race([this.cache, this.step()]);
821
+ if (!$mol_promise_like(this.cache))
822
+ return this.cache;
823
+ if (this.cursor === $mol_wire_cursor.final) {
824
+ await new Promise(() => { });
825
+ }
826
+ }
827
+ }
828
+ step() {
829
+ return new Promise(done => {
830
+ const sub = new $mol_wire_pub_sub;
831
+ const prev = sub.track_on();
832
+ sub.track_next(this);
833
+ sub.track_off(prev);
834
+ sub.absorb = () => {
835
+ done(null);
836
+ sub.destructor();
837
+ };
838
+ });
839
+ }
840
+ }
841
+ $.$mol_wire_fiber = $mol_wire_fiber;
842
+ })($ || ($ = {}));
843
+
844
+ ;
845
+ "use strict";
846
+ var $;
847
+ (function ($) {
848
+ $.$mol_compare_deep_cache = new WeakMap();
849
+ function $mol_compare_deep(left, right) {
850
+ if (Object.is(left, right))
851
+ return true;
852
+ if (left === null)
853
+ return false;
854
+ if (right === null)
855
+ return false;
856
+ if (typeof left !== 'object')
857
+ return false;
858
+ if (typeof right !== 'object')
859
+ return false;
860
+ const left_proto = Reflect.getPrototypeOf(left);
861
+ const right_proto = Reflect.getPrototypeOf(right);
862
+ if (left_proto !== right_proto)
863
+ return false;
864
+ if (left instanceof Boolean)
865
+ return Object.is(left.valueOf(), right['valueOf']());
866
+ if (left instanceof Number)
867
+ return Object.is(left.valueOf(), right['valueOf']());
868
+ if (left instanceof String)
869
+ return Object.is(left.valueOf(), right['valueOf']());
870
+ if (left instanceof Date)
871
+ return Object.is(left.valueOf(), right['valueOf']());
872
+ if (left instanceof RegExp)
873
+ return left.source === right.source && left.flags === right.flags;
874
+ if (left instanceof Error)
875
+ return left.message === right.message && left.stack === right.stack;
876
+ let left_cache = $.$mol_compare_deep_cache.get(left);
877
+ if (left_cache) {
878
+ const right_cache = left_cache.get(right);
879
+ if (typeof right_cache === 'boolean')
880
+ return right_cache;
881
+ }
882
+ else {
883
+ left_cache = new WeakMap([[right, true]]);
884
+ $.$mol_compare_deep_cache.set(left, left_cache);
885
+ }
886
+ let result;
887
+ try {
888
+ if (!left_proto)
889
+ result = compare_pojo(left, right);
890
+ else if (!Reflect.getPrototypeOf(left_proto))
891
+ result = compare_pojo(left, right);
892
+ else if (Symbol.toPrimitive in left)
893
+ result = compare_primitive(left, right);
894
+ else if (Array.isArray(left))
895
+ result = compare_array(left, right);
896
+ else if (left instanceof Set)
897
+ result = compare_set(left, right);
898
+ else if (left instanceof Map)
899
+ result = compare_map(left, right);
900
+ else if (ArrayBuffer.isView(left))
901
+ result = compare_buffer(left, right);
902
+ else if (Symbol.iterator in left)
903
+ result = compare_iterator(left[Symbol.iterator](), right[Symbol.iterator]());
904
+ else
905
+ result = false;
906
+ }
907
+ finally {
908
+ left_cache.set(right, result);
909
+ }
910
+ return result;
911
+ }
912
+ $.$mol_compare_deep = $mol_compare_deep;
913
+ function compare_array(left, right) {
914
+ const len = left.length;
915
+ if (len !== right.length)
916
+ return false;
917
+ for (let i = 0; i < len; ++i) {
918
+ if (!$mol_compare_deep(left[i], right[i]))
919
+ return false;
920
+ }
921
+ return true;
922
+ }
923
+ function compare_buffer(left, right) {
924
+ const len = left.byteLength;
925
+ if (len !== right.byteLength)
926
+ return false;
927
+ if (left instanceof DataView)
928
+ return compare_buffer(new Uint8Array(left.buffer, left.byteOffset, left.byteLength), new Uint8Array(right.buffer, left.byteOffset, left.byteLength));
929
+ for (let i = 0; i < len; ++i) {
930
+ if (left[i] !== right[i])
931
+ return false;
932
+ }
933
+ return true;
934
+ }
935
+ function compare_iterator(left, right) {
936
+ while (true) {
937
+ const left_next = left.next();
938
+ const right_next = right.next();
939
+ if (left_next.done !== right_next.done)
940
+ return false;
941
+ if (left_next.done)
942
+ break;
943
+ if (!$mol_compare_deep(left_next.value, right_next.value))
944
+ return false;
945
+ }
946
+ return true;
947
+ }
948
+ function compare_set(left, right) {
949
+ if (left.size !== right.size)
950
+ return false;
951
+ return compare_iterator(left.values(), right.values());
952
+ }
953
+ function compare_map(left, right) {
954
+ if (left.size !== right.size)
955
+ return false;
956
+ return compare_iterator(left.keys(), right.keys())
957
+ && compare_iterator(left.values(), right.values());
958
+ }
959
+ function compare_pojo(left, right) {
960
+ const left_keys = Object.getOwnPropertyNames(left);
961
+ const right_keys = Object.getOwnPropertyNames(right);
962
+ if (!compare_array(left_keys, right_keys))
260
963
  return false;
261
- if ($.$mol_owning_map.get(having))
964
+ for (let key of left_keys) {
965
+ if (!$mol_compare_deep(left[key], right[key]))
966
+ return false;
967
+ }
968
+ const left_syms = Object.getOwnPropertySymbols(left);
969
+ const right_syms = Object.getOwnPropertySymbols(right);
970
+ if (!compare_array(left_syms, right_syms))
262
971
  return false;
263
- $.$mol_owning_map.set(having, owner);
264
- return true;
265
- }
266
- $.$mol_owning_catch = $mol_owning_catch;
267
- })($ || ($ = {}));
268
-
269
- ;
270
- "use strict";
271
-
272
- ;
273
- "use strict";
274
- var $;
275
- (function ($) {
276
- const named = new WeakSet();
277
- function $mol_func_name(func) {
278
- let name = func.name;
279
- if (name?.length > 1)
280
- return name;
281
- if (named.has(func))
282
- return name;
283
- for (let key in this) {
284
- try {
285
- if (this[key] !== func)
286
- continue;
287
- name = key;
288
- Object.defineProperty(func, 'name', { value: name });
289
- break;
290
- }
291
- catch { }
972
+ for (let key of left_syms) {
973
+ if (!$mol_compare_deep(left[key], right[key]))
974
+ return false;
292
975
  }
293
- named.add(func);
294
- return name;
976
+ return true;
295
977
  }
296
- $.$mol_func_name = $mol_func_name;
297
- function $mol_func_name_from(target, source) {
298
- Object.defineProperty(target, 'name', { value: source.name });
299
- return target;
978
+ function compare_primitive(left, right) {
979
+ return Object.is(left[Symbol.toPrimitive]('default'), right[Symbol.toPrimitive]('default'));
300
980
  }
301
- $.$mol_func_name_from = $mol_func_name_from;
302
981
  })($ || ($ = {}));
303
982
 
304
983
  ;
305
984
  "use strict";
306
985
  var $;
307
986
  (function ($) {
308
- class $mol_object2 {
309
- static $ = $;
310
- [Symbol.toStringTag];
311
- [$mol_ambient_ref] = null;
312
- get $() {
313
- if (this[$mol_ambient_ref])
314
- return this[$mol_ambient_ref];
315
- const owner = $mol_owning_get(this);
316
- return this[$mol_ambient_ref] = owner?.$ || $mol_object2.$;
317
- }
318
- set $(next) {
319
- if (this[$mol_ambient_ref])
320
- $mol_fail_hidden(new Error('Context already defined'));
321
- this[$mol_ambient_ref] = next;
322
- }
323
- static create(init) {
324
- const obj = new this;
325
- if (init)
326
- init(obj);
327
- return obj;
328
- }
329
- static [Symbol.toPrimitive]() {
330
- return this.toString();
331
- }
332
- static toString() {
333
- return this[Symbol.toStringTag] || this.$.$mol_func_name(this);
334
- }
335
- static toJSON() {
336
- return this.toString();
337
- }
338
- destructor() { }
339
- static destructor() { }
340
- toString() {
341
- return this[Symbol.toStringTag] || this.constructor.name + '<>';
342
- }
987
+ function $mol_log3_area_lazy(event) {
988
+ const self = this;
989
+ const stack = self.$mol_log3_stack;
990
+ const deep = stack.length;
991
+ let logged = false;
992
+ stack.push(() => {
993
+ logged = true;
994
+ self.$mol_log3_area.call(self, event);
995
+ });
996
+ return () => {
997
+ if (logged)
998
+ self.console.groupEnd();
999
+ if (stack.length > deep)
1000
+ stack.length = deep;
1001
+ };
343
1002
  }
344
- $.$mol_object2 = $mol_object2;
1003
+ $.$mol_log3_area_lazy = $mol_log3_area_lazy;
1004
+ $.$mol_log3_stack = [];
345
1005
  })($ || ($ = {}));
346
1006
 
347
1007
  ;
@@ -837,6 +1497,178 @@ var $;
837
1497
  $.$mol_log3_area = $mol_log3_node_make('log', 'stdout', 'area', $mol_term_color.cyan);
838
1498
  })($ || ($ = {}));
839
1499
 
1500
+ ;
1501
+ "use strict";
1502
+ var $;
1503
+ (function ($) {
1504
+ class $mol_wire_task extends $mol_wire_fiber {
1505
+ static getter(task) {
1506
+ return function $mol_wire_task_get(host, args) {
1507
+ const sub = $mol_wire_auto();
1508
+ const existen = sub?.track_next();
1509
+ reuse: if (existen) {
1510
+ if (!existen.temp)
1511
+ break reuse;
1512
+ if (existen.host !== host)
1513
+ break reuse;
1514
+ if (existen.task !== task)
1515
+ break reuse;
1516
+ if (!$mol_compare_deep(existen.args, args))
1517
+ break reuse;
1518
+ return existen;
1519
+ }
1520
+ const next = new $mol_wire_task(`${host?.[Symbol.toStringTag] ?? host}.${task.name}<#>`, task, host, args);
1521
+ if (existen?.temp) {
1522
+ $$.$mol_log3_warn({
1523
+ place: '$mol_wire_task',
1524
+ message: `Non idempotency`,
1525
+ existen,
1526
+ next,
1527
+ hint: 'Ignore it',
1528
+ });
1529
+ }
1530
+ return next;
1531
+ };
1532
+ }
1533
+ get temp() {
1534
+ return true;
1535
+ }
1536
+ complete() {
1537
+ if ($mol_promise_like(this.cache))
1538
+ return;
1539
+ this.destructor();
1540
+ }
1541
+ put(next) {
1542
+ const prev = this.cache;
1543
+ this.cache = next;
1544
+ if ($mol_promise_like(next)) {
1545
+ this.cursor = $mol_wire_cursor.fresh;
1546
+ if (next !== prev)
1547
+ this.emit();
1548
+ return next;
1549
+ }
1550
+ this.cursor = $mol_wire_cursor.final;
1551
+ if (this.sub_empty)
1552
+ this.destructor();
1553
+ else if (next !== prev)
1554
+ this.emit();
1555
+ return next;
1556
+ }
1557
+ }
1558
+ $.$mol_wire_task = $mol_wire_task;
1559
+ })($ || ($ = {}));
1560
+
1561
+ ;
1562
+ "use strict";
1563
+ var $;
1564
+ (function ($) {
1565
+ function $mol_wire_sync(obj) {
1566
+ return new Proxy(obj, {
1567
+ get(obj, field) {
1568
+ const val = obj[field];
1569
+ if (typeof val !== 'function')
1570
+ return val;
1571
+ const temp = $mol_wire_task.getter(val);
1572
+ return function $mol_wire_sync(...args) {
1573
+ const fiber = temp(obj, args);
1574
+ return fiber.sync();
1575
+ };
1576
+ },
1577
+ apply(obj, self, args) {
1578
+ const temp = $mol_wire_task.getter(obj);
1579
+ const fiber = temp(self, args);
1580
+ return fiber.sync();
1581
+ },
1582
+ });
1583
+ }
1584
+ $.$mol_wire_sync = $mol_wire_sync;
1585
+ })($ || ($ = {}));
1586
+
1587
+ ;
1588
+ "use strict";
1589
+ var $;
1590
+ (function ($) {
1591
+ const catched = new WeakMap();
1592
+ function $mol_fail_catch(error) {
1593
+ if (typeof error !== 'object')
1594
+ return false;
1595
+ if ($mol_promise_like(error))
1596
+ $mol_fail_hidden(error);
1597
+ if (catched.get(error))
1598
+ return false;
1599
+ catched.set(error, true);
1600
+ return true;
1601
+ }
1602
+ $.$mol_fail_catch = $mol_fail_catch;
1603
+ })($ || ($ = {}));
1604
+
1605
+ ;
1606
+ "use strict";
1607
+ var $;
1608
+ (function ($) {
1609
+ function $mol_fail_log(error) {
1610
+ if ($mol_promise_like(error))
1611
+ return false;
1612
+ if (!$mol_fail_catch(error))
1613
+ return false;
1614
+ console.error(error);
1615
+ return true;
1616
+ }
1617
+ $.$mol_fail_log = $mol_fail_log;
1618
+ })($ || ($ = {}));
1619
+
1620
+ ;
1621
+ "use strict";
1622
+ var $node = new Proxy({ require }, {
1623
+ get(target, name, wrapper) {
1624
+ if (target[name])
1625
+ return target[name];
1626
+ const mod = target.require('module');
1627
+ if (mod.builtinModules.indexOf(name) >= 0)
1628
+ return target.require(name);
1629
+ if (name[0] === '.')
1630
+ return target.require(name);
1631
+ const path = target.require('path');
1632
+ const fs = target.require('fs');
1633
+ let dir = path.resolve('.');
1634
+ const suffix = `./node_modules/${name}`;
1635
+ const $$ = $;
1636
+ while (!fs.existsSync(path.join(dir, suffix))) {
1637
+ const parent = path.resolve(dir, '..');
1638
+ if (parent === dir) {
1639
+ $$.$mol_exec('.', 'npm', 'install', '--omit=dev', name);
1640
+ try {
1641
+ $$.$mol_exec('.', 'npm', 'install', '--omit=dev', '@types/' + name);
1642
+ }
1643
+ catch { }
1644
+ break;
1645
+ }
1646
+ else {
1647
+ dir = parent;
1648
+ }
1649
+ }
1650
+ try {
1651
+ return $.$mol_wire_sync(target).require(name);
1652
+ }
1653
+ catch (error) {
1654
+ if (error.code === 'ERR_REQUIRE_ESM') {
1655
+ return importSync(name);
1656
+ }
1657
+ $.$mol_fail_log(error);
1658
+ return null;
1659
+ }
1660
+ },
1661
+ set(target, name, value) {
1662
+ target[name] = value;
1663
+ return true;
1664
+ },
1665
+ });
1666
+ const importAsync = async (uri) => import(uri);
1667
+ const importSync = $.$mol_wire_sync(importAsync);
1668
+ require = (req => Object.assign(function require(name) {
1669
+ return $node[name];
1670
+ }, req))(require);
1671
+
840
1672
  ;
841
1673
  "use strict";
842
1674
  var $;
@@ -1230,6 +2062,33 @@ var $;
1230
2062
  $.$mol_test_complete = $mol_test_complete;
1231
2063
  })($ || ($ = {}));
1232
2064
 
2065
+ ;
2066
+ "use strict";
2067
+
2068
+ ;
2069
+ "use strict";
2070
+
2071
+ ;
2072
+ "use strict";
2073
+
2074
+ ;
2075
+ "use strict";
2076
+ var $;
2077
+ (function ($_1) {
2078
+ $mol_test({
2079
+ 'test types'($) {
2080
+ class A {
2081
+ static a() {
2082
+ return Promise.resolve('');
2083
+ }
2084
+ static b() {
2085
+ return $mol_wire_sync(this).a();
2086
+ }
2087
+ }
2088
+ },
2089
+ });
2090
+ })($ || ($ = {}));
2091
+
1233
2092
  ;
1234
2093
  "use strict";
1235
2094
  var $;
@@ -1283,23 +2142,14 @@ var $;
1283
2142
  }
1284
2143
  }
1285
2144
  }
1286
- while (nextNode) {
1287
- const currNode = nextNode;
1288
- nextNode = currNode.nextSibling;
1289
- el.removeChild(currNode);
1290
- }
1291
- }
1292
- $.$mol_dom_render_children = $mol_dom_render_children;
1293
- })($ || ($ = {}));
1294
-
1295
- ;
1296
- "use strict";
1297
-
1298
- ;
1299
- "use strict";
1300
-
1301
- ;
1302
- "use strict";
2145
+ while (nextNode) {
2146
+ const currNode = nextNode;
2147
+ nextNode = currNode.nextSibling;
2148
+ el.removeChild(currNode);
2149
+ }
2150
+ }
2151
+ $.$mol_dom_render_children = $mol_dom_render_children;
2152
+ })($ || ($ = {}));
1303
2153
 
1304
2154
  ;
1305
2155
  "use strict";
@@ -1701,260 +2551,121 @@ var $;
1701
2551
  let log = '';
1702
2552
  for (let i in $mol_range2(i => i, () => 5)) {
1703
2553
  log += i;
1704
- }
1705
- $mol_assert_equal(log, '01234');
1706
- },
1707
- 'forEach'() {
1708
- let log = '';
1709
- $mol_range2(i => i, () => 5).forEach(i => log += i);
1710
- $mol_assert_equal(log, '01234');
1711
- },
1712
- 'reduce'() {
1713
- let calls = 0;
1714
- const list = $mol_range2().slice(1, 6);
1715
- $mol_assert_equal(list.reduce((s, v) => s + v), 15);
1716
- $mol_assert_equal(list.reduce((s, v) => s + v, 5), 20);
1717
- },
1718
- 'lazy concat'() {
1719
- let calls1 = 0;
1720
- let calls2 = 0;
1721
- const list = $mol_range2(index => (++calls1, index), () => 5).concat([0, 1, 2, 3, 4], $mol_range2(index => (++calls2, index), () => 5));
1722
- $mol_assert_equal(true, list instanceof Array);
1723
- $mol_assert_equal(list.length, 15);
1724
- $mol_assert_equal(list[0], 0);
1725
- $mol_assert_equal(list[4], 4);
1726
- $mol_assert_equal(list[5], 0);
1727
- $mol_assert_equal(list[9], 4);
1728
- $mol_assert_equal(list[10], 0);
1729
- $mol_assert_equal(list[14], 4);
1730
- $mol_assert_equal(list[15], undefined);
1731
- $mol_assert_equal(calls1, 2);
1732
- $mol_assert_equal(calls2, 2);
1733
- },
1734
- 'lazy filter'() {
1735
- let calls = 0;
1736
- const list = $mol_range2(index => (++calls, index), () => 15).filter(v => v % 2).slice(0, 3);
1737
- $mol_assert_equal(true, list instanceof Array);
1738
- $mol_assert_equal(list.length, 3);
1739
- $mol_assert_equal(list[0], 1);
1740
- $mol_assert_equal(list[2], 5);
1741
- $mol_assert_equal(list[3], undefined);
1742
- $mol_assert_equal(calls, 8);
1743
- },
1744
- 'lazy reverse'() {
1745
- let calls = 0;
1746
- const list = $mol_range2(index => (++calls, index), () => 10).toReversed().slice(0, 3);
1747
- $mol_assert_equal(true, list instanceof Array);
1748
- $mol_assert_equal(list.length, 3);
1749
- $mol_assert_equal(list[0], 9);
1750
- $mol_assert_equal(list[2], 7);
1751
- $mol_assert_equal(list[3], undefined);
1752
- $mol_assert_equal(calls, 2);
1753
- },
1754
- 'lazy map'() {
1755
- let calls1 = 0;
1756
- let calls2 = 0;
1757
- const source = $mol_range2(index => (++calls1, index), () => 5);
1758
- const target = source.map((item, index, self) => {
1759
- ++calls2;
1760
- $mol_assert_equal(source, self);
1761
- return index + 10;
1762
- }, () => 5);
1763
- $mol_assert_equal(true, target instanceof Array);
1764
- $mol_assert_equal(target.length, 5);
1765
- $mol_assert_equal(target[0], 10);
1766
- $mol_assert_equal(target[4], 14);
1767
- $mol_assert_equal(target[5], undefined);
1768
- $mol_assert_equal(calls1, 2);
1769
- $mol_assert_equal(calls2, 2);
1770
- },
1771
- 'lazy slice'() {
1772
- let calls = 0;
1773
- const list = $mol_range2(index => (++calls, index), () => 10).slice(3, 7);
1774
- $mol_assert_equal(true, list instanceof Array);
1775
- $mol_assert_equal(list.length, 4);
1776
- $mol_assert_equal(list[0], 3);
1777
- $mol_assert_equal(list[3], 6);
1778
- $mol_assert_equal(list[4], undefined);
1779
- $mol_assert_equal(calls, 2);
1780
- },
1781
- 'lazy some'() {
1782
- let calls = 0;
1783
- $mol_assert_equal(true, $mol_range2(index => (++calls, index), () => 5).some(v => v >= 2));
1784
- $mol_assert_equal(calls, 3);
1785
- $mol_assert_equal(false, $mol_range2(i => i, () => 0).some(v => true));
1786
- $mol_assert_equal(true, $mol_range2(i => i).some(v => v > 5));
1787
- },
1788
- 'lazy every'() {
1789
- let calls = 0;
1790
- $mol_assert_equal(false, $mol_range2(index => (++calls, index), () => 5).every(v => v < 2));
1791
- $mol_assert_equal(calls, 3);
1792
- $mol_assert_equal(true, $mol_range2(i => i, () => 0).every(v => false));
1793
- $mol_assert_equal(false, $mol_range2(i => i).every(v => v < 5));
1794
- },
1795
- 'lazyfy'() {
1796
- let calls = 0;
1797
- const list = $mol_range2([0, 1, 2, 3, 4, 5]).map(i => (++calls, i + 10)).slice(2);
1798
- $mol_assert_equal(true, list instanceof Array);
1799
- $mol_assert_equal(list.length, 4);
1800
- $mol_assert_equal(calls, 0);
1801
- $mol_assert_equal(list[0], 12);
1802
- $mol_assert_equal(list[3], 15);
1803
- $mol_assert_equal(list[4], undefined);
1804
- $mol_assert_equal(calls, 2);
1805
- },
1806
- 'prevent modification'() {
1807
- const list = $mol_range2(i => i, () => 5);
1808
- $mol_assert_fail(() => list.push(4), TypeError);
1809
- $mol_assert_fail(() => list.pop(), TypeError);
1810
- $mol_assert_fail(() => list.unshift(4), TypeError);
1811
- $mol_assert_fail(() => list.shift(), TypeError);
1812
- $mol_assert_fail(() => list.splice(1, 2), TypeError);
1813
- $mol_assert_fail(() => list[1] = 2, TypeError);
1814
- $mol_assert_fail(() => list.reverse(), TypeError);
1815
- $mol_assert_fail(() => list.sort(), TypeError);
1816
- $mol_assert_equal(list.toString(), '0,1,2,3,4');
1817
- }
1818
- });
1819
- })($ || ($ = {}));
1820
-
1821
- ;
1822
- "use strict";
1823
- var $;
1824
- (function ($) {
1825
- $.$mol_compare_deep_cache = new WeakMap();
1826
- function $mol_compare_deep(left, right) {
1827
- if (Object.is(left, right))
1828
- return true;
1829
- if (left === null)
1830
- return false;
1831
- if (right === null)
1832
- return false;
1833
- if (typeof left !== 'object')
1834
- return false;
1835
- if (typeof right !== 'object')
1836
- return false;
1837
- const left_proto = Reflect.getPrototypeOf(left);
1838
- const right_proto = Reflect.getPrototypeOf(right);
1839
- if (left_proto !== right_proto)
1840
- return false;
1841
- if (left instanceof Boolean)
1842
- return Object.is(left.valueOf(), right['valueOf']());
1843
- if (left instanceof Number)
1844
- return Object.is(left.valueOf(), right['valueOf']());
1845
- if (left instanceof String)
1846
- return Object.is(left.valueOf(), right['valueOf']());
1847
- if (left instanceof Date)
1848
- return Object.is(left.valueOf(), right['valueOf']());
1849
- if (left instanceof RegExp)
1850
- return left.source === right.source && left.flags === right.flags;
1851
- if (left instanceof Error)
1852
- return left.message === right.message && left.stack === right.stack;
1853
- let left_cache = $.$mol_compare_deep_cache.get(left);
1854
- if (left_cache) {
1855
- const right_cache = left_cache.get(right);
1856
- if (typeof right_cache === 'boolean')
1857
- return right_cache;
1858
- }
1859
- else {
1860
- left_cache = new WeakMap([[right, true]]);
1861
- $.$mol_compare_deep_cache.set(left, left_cache);
1862
- }
1863
- let result;
1864
- try {
1865
- if (!left_proto)
1866
- result = compare_pojo(left, right);
1867
- else if (!Reflect.getPrototypeOf(left_proto))
1868
- result = compare_pojo(left, right);
1869
- else if (Symbol.toPrimitive in left)
1870
- result = compare_primitive(left, right);
1871
- else if (Array.isArray(left))
1872
- result = compare_array(left, right);
1873
- else if (left instanceof Set)
1874
- result = compare_set(left, right);
1875
- else if (left instanceof Map)
1876
- result = compare_map(left, right);
1877
- else if (ArrayBuffer.isView(left))
1878
- result = compare_buffer(left, right);
1879
- else if (Symbol.iterator in left)
1880
- result = compare_iterator(left[Symbol.iterator](), right[Symbol.iterator]());
1881
- else
1882
- result = false;
1883
- }
1884
- finally {
1885
- left_cache.set(right, result);
1886
- }
1887
- return result;
1888
- }
1889
- $.$mol_compare_deep = $mol_compare_deep;
1890
- function compare_array(left, right) {
1891
- const len = left.length;
1892
- if (len !== right.length)
1893
- return false;
1894
- for (let i = 0; i < len; ++i) {
1895
- if (!$mol_compare_deep(left[i], right[i]))
1896
- return false;
1897
- }
1898
- return true;
1899
- }
1900
- function compare_buffer(left, right) {
1901
- const len = left.byteLength;
1902
- if (len !== right.byteLength)
1903
- return false;
1904
- if (left instanceof DataView)
1905
- return compare_buffer(new Uint8Array(left.buffer, left.byteOffset, left.byteLength), new Uint8Array(right.buffer, left.byteOffset, left.byteLength));
1906
- for (let i = 0; i < len; ++i) {
1907
- if (left[i] !== right[i])
1908
- return false;
1909
- }
1910
- return true;
1911
- }
1912
- function compare_iterator(left, right) {
1913
- while (true) {
1914
- const left_next = left.next();
1915
- const right_next = right.next();
1916
- if (left_next.done !== right_next.done)
1917
- return false;
1918
- if (left_next.done)
1919
- break;
1920
- if (!$mol_compare_deep(left_next.value, right_next.value))
1921
- return false;
1922
- }
1923
- return true;
1924
- }
1925
- function compare_set(left, right) {
1926
- if (left.size !== right.size)
1927
- return false;
1928
- return compare_iterator(left.values(), right.values());
1929
- }
1930
- function compare_map(left, right) {
1931
- if (left.size !== right.size)
1932
- return false;
1933
- return compare_iterator(left.keys(), right.keys())
1934
- && compare_iterator(left.values(), right.values());
1935
- }
1936
- function compare_pojo(left, right) {
1937
- const left_keys = Object.getOwnPropertyNames(left);
1938
- const right_keys = Object.getOwnPropertyNames(right);
1939
- if (!compare_array(left_keys, right_keys))
1940
- return false;
1941
- for (let key of left_keys) {
1942
- if (!$mol_compare_deep(left[key], right[key]))
1943
- return false;
1944
- }
1945
- const left_syms = Object.getOwnPropertySymbols(left);
1946
- const right_syms = Object.getOwnPropertySymbols(right);
1947
- if (!compare_array(left_syms, right_syms))
1948
- return false;
1949
- for (let key of left_syms) {
1950
- if (!$mol_compare_deep(left[key], right[key]))
1951
- return false;
2554
+ }
2555
+ $mol_assert_equal(log, '01234');
2556
+ },
2557
+ 'forEach'() {
2558
+ let log = '';
2559
+ $mol_range2(i => i, () => 5).forEach(i => log += i);
2560
+ $mol_assert_equal(log, '01234');
2561
+ },
2562
+ 'reduce'() {
2563
+ let calls = 0;
2564
+ const list = $mol_range2().slice(1, 6);
2565
+ $mol_assert_equal(list.reduce((s, v) => s + v), 15);
2566
+ $mol_assert_equal(list.reduce((s, v) => s + v, 5), 20);
2567
+ },
2568
+ 'lazy concat'() {
2569
+ let calls1 = 0;
2570
+ let calls2 = 0;
2571
+ const list = $mol_range2(index => (++calls1, index), () => 5).concat([0, 1, 2, 3, 4], $mol_range2(index => (++calls2, index), () => 5));
2572
+ $mol_assert_equal(true, list instanceof Array);
2573
+ $mol_assert_equal(list.length, 15);
2574
+ $mol_assert_equal(list[0], 0);
2575
+ $mol_assert_equal(list[4], 4);
2576
+ $mol_assert_equal(list[5], 0);
2577
+ $mol_assert_equal(list[9], 4);
2578
+ $mol_assert_equal(list[10], 0);
2579
+ $mol_assert_equal(list[14], 4);
2580
+ $mol_assert_equal(list[15], undefined);
2581
+ $mol_assert_equal(calls1, 2);
2582
+ $mol_assert_equal(calls2, 2);
2583
+ },
2584
+ 'lazy filter'() {
2585
+ let calls = 0;
2586
+ const list = $mol_range2(index => (++calls, index), () => 15).filter(v => v % 2).slice(0, 3);
2587
+ $mol_assert_equal(true, list instanceof Array);
2588
+ $mol_assert_equal(list.length, 3);
2589
+ $mol_assert_equal(list[0], 1);
2590
+ $mol_assert_equal(list[2], 5);
2591
+ $mol_assert_equal(list[3], undefined);
2592
+ $mol_assert_equal(calls, 8);
2593
+ },
2594
+ 'lazy reverse'() {
2595
+ let calls = 0;
2596
+ const list = $mol_range2(index => (++calls, index), () => 10).toReversed().slice(0, 3);
2597
+ $mol_assert_equal(true, list instanceof Array);
2598
+ $mol_assert_equal(list.length, 3);
2599
+ $mol_assert_equal(list[0], 9);
2600
+ $mol_assert_equal(list[2], 7);
2601
+ $mol_assert_equal(list[3], undefined);
2602
+ $mol_assert_equal(calls, 2);
2603
+ },
2604
+ 'lazy map'() {
2605
+ let calls1 = 0;
2606
+ let calls2 = 0;
2607
+ const source = $mol_range2(index => (++calls1, index), () => 5);
2608
+ const target = source.map((item, index, self) => {
2609
+ ++calls2;
2610
+ $mol_assert_equal(source, self);
2611
+ return index + 10;
2612
+ }, () => 5);
2613
+ $mol_assert_equal(true, target instanceof Array);
2614
+ $mol_assert_equal(target.length, 5);
2615
+ $mol_assert_equal(target[0], 10);
2616
+ $mol_assert_equal(target[4], 14);
2617
+ $mol_assert_equal(target[5], undefined);
2618
+ $mol_assert_equal(calls1, 2);
2619
+ $mol_assert_equal(calls2, 2);
2620
+ },
2621
+ 'lazy slice'() {
2622
+ let calls = 0;
2623
+ const list = $mol_range2(index => (++calls, index), () => 10).slice(3, 7);
2624
+ $mol_assert_equal(true, list instanceof Array);
2625
+ $mol_assert_equal(list.length, 4);
2626
+ $mol_assert_equal(list[0], 3);
2627
+ $mol_assert_equal(list[3], 6);
2628
+ $mol_assert_equal(list[4], undefined);
2629
+ $mol_assert_equal(calls, 2);
2630
+ },
2631
+ 'lazy some'() {
2632
+ let calls = 0;
2633
+ $mol_assert_equal(true, $mol_range2(index => (++calls, index), () => 5).some(v => v >= 2));
2634
+ $mol_assert_equal(calls, 3);
2635
+ $mol_assert_equal(false, $mol_range2(i => i, () => 0).some(v => true));
2636
+ $mol_assert_equal(true, $mol_range2(i => i).some(v => v > 5));
2637
+ },
2638
+ 'lazy every'() {
2639
+ let calls = 0;
2640
+ $mol_assert_equal(false, $mol_range2(index => (++calls, index), () => 5).every(v => v < 2));
2641
+ $mol_assert_equal(calls, 3);
2642
+ $mol_assert_equal(true, $mol_range2(i => i, () => 0).every(v => false));
2643
+ $mol_assert_equal(false, $mol_range2(i => i).every(v => v < 5));
2644
+ },
2645
+ 'lazyfy'() {
2646
+ let calls = 0;
2647
+ const list = $mol_range2([0, 1, 2, 3, 4, 5]).map(i => (++calls, i + 10)).slice(2);
2648
+ $mol_assert_equal(true, list instanceof Array);
2649
+ $mol_assert_equal(list.length, 4);
2650
+ $mol_assert_equal(calls, 0);
2651
+ $mol_assert_equal(list[0], 12);
2652
+ $mol_assert_equal(list[3], 15);
2653
+ $mol_assert_equal(list[4], undefined);
2654
+ $mol_assert_equal(calls, 2);
2655
+ },
2656
+ 'prevent modification'() {
2657
+ const list = $mol_range2(i => i, () => 5);
2658
+ $mol_assert_fail(() => list.push(4), TypeError);
2659
+ $mol_assert_fail(() => list.pop(), TypeError);
2660
+ $mol_assert_fail(() => list.unshift(4), TypeError);
2661
+ $mol_assert_fail(() => list.shift(), TypeError);
2662
+ $mol_assert_fail(() => list.splice(1, 2), TypeError);
2663
+ $mol_assert_fail(() => list[1] = 2, TypeError);
2664
+ $mol_assert_fail(() => list.reverse(), TypeError);
2665
+ $mol_assert_fail(() => list.sort(), TypeError);
2666
+ $mol_assert_equal(list.toString(), '0,1,2,3,4');
1952
2667
  }
1953
- return true;
1954
- }
1955
- function compare_primitive(left, right) {
1956
- return Object.is(left[Symbol.toPrimitive]('default'), right[Symbol.toPrimitive]('default'));
1957
- }
2668
+ });
1958
2669
  })($ || ($ = {}));
1959
2670
 
1960
2671
  ;
@@ -2526,6 +3237,348 @@ var $;
2526
3237
  });
2527
3238
  })($ || ($ = {}));
2528
3239
 
3240
+ ;
3241
+ "use strict";
3242
+ var $;
3243
+ (function ($_1) {
3244
+ $mol_test({
3245
+ 'Collect deps'() {
3246
+ const pub1 = new $mol_wire_pub;
3247
+ const pub2 = new $mol_wire_pub;
3248
+ const sub = new $mol_wire_pub_sub;
3249
+ const bu1 = sub.track_on();
3250
+ try {
3251
+ pub1.promote();
3252
+ pub2.promote();
3253
+ pub2.promote();
3254
+ }
3255
+ finally {
3256
+ sub.track_cut();
3257
+ sub.track_off(bu1);
3258
+ }
3259
+ pub1.emit();
3260
+ pub2.emit();
3261
+ $mol_assert_like(sub.pub_list, [pub1, pub2, pub2]);
3262
+ const bu2 = sub.track_on();
3263
+ try {
3264
+ pub1.promote();
3265
+ pub1.promote();
3266
+ pub2.promote();
3267
+ }
3268
+ finally {
3269
+ sub.track_cut();
3270
+ sub.track_off(bu2);
3271
+ }
3272
+ pub1.emit();
3273
+ pub2.emit();
3274
+ $mol_assert_like(sub.pub_list, [pub1, pub1, pub2]);
3275
+ },
3276
+ 'cyclic detection'($) {
3277
+ const sub1 = new $mol_wire_pub_sub;
3278
+ const sub2 = new $mol_wire_pub_sub;
3279
+ const bu1 = sub1.track_on();
3280
+ try {
3281
+ const bu2 = sub2.track_on();
3282
+ try {
3283
+ $mol_assert_fail(() => sub1.promote(), 'Circular subscription');
3284
+ }
3285
+ finally {
3286
+ sub2.track_cut();
3287
+ sub2.track_off(bu2);
3288
+ }
3289
+ }
3290
+ finally {
3291
+ sub1.track_cut();
3292
+ sub1.track_off(bu1);
3293
+ }
3294
+ },
3295
+ });
3296
+ })($ || ($ = {}));
3297
+
3298
+ ;
3299
+ "use strict";
3300
+ var $;
3301
+ (function ($) {
3302
+ $.$mol_after_mock_queue = [];
3303
+ function $mol_after_mock_warp() {
3304
+ const queue = $.$mol_after_mock_queue.splice(0);
3305
+ for (const task of queue)
3306
+ task();
3307
+ }
3308
+ $.$mol_after_mock_warp = $mol_after_mock_warp;
3309
+ class $mol_after_mock_commmon extends $mol_object2 {
3310
+ task;
3311
+ promise = Promise.resolve();
3312
+ cancelled = false;
3313
+ id;
3314
+ constructor(task) {
3315
+ super();
3316
+ this.task = task;
3317
+ $.$mol_after_mock_queue.push(task);
3318
+ }
3319
+ destructor() {
3320
+ const index = $.$mol_after_mock_queue.indexOf(this.task);
3321
+ if (index >= 0)
3322
+ $.$mol_after_mock_queue.splice(index, 1);
3323
+ }
3324
+ }
3325
+ $.$mol_after_mock_commmon = $mol_after_mock_commmon;
3326
+ class $mol_after_mock_timeout extends $mol_after_mock_commmon {
3327
+ delay;
3328
+ constructor(delay, task) {
3329
+ super(task);
3330
+ this.delay = delay;
3331
+ }
3332
+ }
3333
+ $.$mol_after_mock_timeout = $mol_after_mock_timeout;
3334
+ })($ || ($ = {}));
3335
+
3336
+ ;
3337
+ "use strict";
3338
+ var $;
3339
+ (function ($_1) {
3340
+ $mol_test_mocks.push($ => {
3341
+ $.$mol_after_timeout = $mol_after_mock_timeout;
3342
+ });
3343
+ })($ || ($ = {}));
3344
+
3345
+ ;
3346
+ "use strict";
3347
+ var $;
3348
+ (function ($_1) {
3349
+ $mol_test_mocks.push($ => {
3350
+ $.$mol_after_frame = $mol_after_mock_commmon;
3351
+ });
3352
+ })($ || ($ = {}));
3353
+
3354
+ ;
3355
+ "use strict";
3356
+ var $;
3357
+ (function ($) {
3358
+ $mol_test({
3359
+ 'Sync execution'() {
3360
+ class Sync extends $mol_object2 {
3361
+ static calc(a, b) {
3362
+ return a + b;
3363
+ }
3364
+ }
3365
+ __decorate([
3366
+ $mol_wire_method
3367
+ ], Sync, "calc", null);
3368
+ $mol_assert_equal(Sync.calc(1, 2), 3);
3369
+ },
3370
+ async 'async <=> sync'() {
3371
+ class SyncAsync extends $mol_object2 {
3372
+ static async val(a) {
3373
+ return a;
3374
+ }
3375
+ static sum(a, b) {
3376
+ const syn = $mol_wire_sync(this);
3377
+ return syn.val(a) + syn.val(b);
3378
+ }
3379
+ static async calc(a, b) {
3380
+ return 5 + await $mol_wire_async(this).sum(a, b);
3381
+ }
3382
+ }
3383
+ $mol_assert_equal(await SyncAsync.calc(1, 2), 8);
3384
+ },
3385
+ async 'Idempotence control'() {
3386
+ class Idempotence extends $mol_object2 {
3387
+ static logs_idemp = 0;
3388
+ static logs_unidemp = 0;
3389
+ static log_idemp() {
3390
+ this.logs_idemp += 1;
3391
+ }
3392
+ static log_unidemp() {
3393
+ this.logs_unidemp += 1;
3394
+ }
3395
+ static async val(a) {
3396
+ return a;
3397
+ }
3398
+ static sum(a, b) {
3399
+ this.log_idemp();
3400
+ this.log_unidemp();
3401
+ const syn = $mol_wire_sync(this);
3402
+ return syn.val(a) + syn.val(b);
3403
+ }
3404
+ static async calc(a, b) {
3405
+ return 5 + await $mol_wire_async(this).sum(a, b);
3406
+ }
3407
+ }
3408
+ __decorate([
3409
+ $mol_wire_method
3410
+ ], Idempotence, "log_idemp", null);
3411
+ $mol_assert_equal(await Idempotence.calc(1, 2), 8);
3412
+ $mol_assert_equal(Idempotence.logs_idemp, 1);
3413
+ $mol_assert_equal(Idempotence.logs_unidemp, 3);
3414
+ },
3415
+ async 'Error handling'() {
3416
+ class Handle extends $mol_object2 {
3417
+ static async sum(a, b) {
3418
+ $mol_fail(new Error('test error ' + (a + b)));
3419
+ }
3420
+ static check() {
3421
+ try {
3422
+ return $mol_wire_sync(Handle).sum(1, 2);
3423
+ }
3424
+ catch (error) {
3425
+ if ($mol_promise_like(error))
3426
+ $mol_fail_hidden(error);
3427
+ $mol_assert_equal(error.message, 'test error 3');
3428
+ }
3429
+ }
3430
+ }
3431
+ await $mol_wire_async(Handle).check();
3432
+ },
3433
+ });
3434
+ })($ || ($ = {}));
3435
+
3436
+ ;
3437
+ "use strict";
3438
+ var $;
3439
+ (function ($) {
3440
+ function $mol_wire_method(host, field, descr) {
3441
+ if (!descr)
3442
+ descr = Reflect.getOwnPropertyDescriptor(host, field);
3443
+ const orig = descr?.value ?? host[field];
3444
+ const sup = Reflect.getPrototypeOf(host);
3445
+ if (typeof sup[field] === 'function') {
3446
+ Object.defineProperty(orig, 'name', { value: sup[field].name });
3447
+ }
3448
+ const temp = $mol_wire_task.getter(orig);
3449
+ const value = function (...args) {
3450
+ const fiber = temp(this ?? null, args);
3451
+ return fiber.sync();
3452
+ };
3453
+ Object.defineProperty(value, 'name', { value: orig.name + ' ' });
3454
+ Object.assign(value, { orig });
3455
+ const descr2 = { ...descr, value };
3456
+ Reflect.defineProperty(host, field, descr2);
3457
+ return descr2;
3458
+ }
3459
+ $.$mol_wire_method = $mol_wire_method;
3460
+ })($ || ($ = {}));
3461
+
3462
+ ;
3463
+ "use strict";
3464
+ var $;
3465
+ (function ($) {
3466
+ function $mol_promise() {
3467
+ let done;
3468
+ let fail;
3469
+ const promise = new Promise((d, f) => {
3470
+ done = d;
3471
+ fail = f;
3472
+ });
3473
+ return Object.assign(promise, {
3474
+ done,
3475
+ fail,
3476
+ });
3477
+ }
3478
+ $.$mol_promise = $mol_promise;
3479
+ })($ || ($ = {}));
3480
+
3481
+ ;
3482
+ "use strict";
3483
+ var $;
3484
+ (function ($) {
3485
+ function $mol_wait_timeout_async(timeout) {
3486
+ const promise = $mol_promise();
3487
+ const task = new this.$mol_after_timeout(timeout, () => promise.done());
3488
+ return Object.assign(promise, {
3489
+ destructor: () => task.destructor()
3490
+ });
3491
+ }
3492
+ $.$mol_wait_timeout_async = $mol_wait_timeout_async;
3493
+ function $mol_wait_timeout(timeout) {
3494
+ return this.$mol_wire_sync(this).$mol_wait_timeout_async(timeout);
3495
+ }
3496
+ $.$mol_wait_timeout = $mol_wait_timeout;
3497
+ })($ || ($ = {}));
3498
+
3499
+ ;
3500
+ "use strict";
3501
+ var $;
3502
+ (function ($) {
3503
+ function $mol_wire_async(obj) {
3504
+ let fiber;
3505
+ const temp = $mol_wire_task.getter(obj);
3506
+ return new Proxy(obj, {
3507
+ get(obj, field) {
3508
+ const val = obj[field];
3509
+ if (typeof val !== 'function')
3510
+ return val;
3511
+ let fiber;
3512
+ const temp = $mol_wire_task.getter(val);
3513
+ return function $mol_wire_async(...args) {
3514
+ fiber?.destructor();
3515
+ fiber = temp(obj, args);
3516
+ return fiber.async();
3517
+ };
3518
+ },
3519
+ apply(obj, self, args) {
3520
+ fiber?.destructor();
3521
+ fiber = temp(self, args);
3522
+ return fiber.async();
3523
+ },
3524
+ });
3525
+ }
3526
+ $.$mol_wire_async = $mol_wire_async;
3527
+ })($ || ($ = {}));
3528
+
3529
+ ;
3530
+ "use strict";
3531
+ var $;
3532
+ (function ($_1) {
3533
+ $mol_test({
3534
+ 'test types'($) {
3535
+ class A {
3536
+ static a() {
3537
+ return '';
3538
+ }
3539
+ static b() {
3540
+ return $mol_wire_async(this).a();
3541
+ }
3542
+ }
3543
+ },
3544
+ async 'Latest method calls wins'($) {
3545
+ class NameLogger extends $mol_object2 {
3546
+ static $ = $;
3547
+ static first = [];
3548
+ static last = [];
3549
+ static send(next) {
3550
+ $mol_wire_sync(this.first).push(next);
3551
+ this.$.$mol_wait_timeout(0);
3552
+ this.last.push(next);
3553
+ }
3554
+ }
3555
+ const name = $mol_wire_async(NameLogger).send;
3556
+ name('john');
3557
+ const promise = name('jin');
3558
+ $.$mol_after_mock_warp();
3559
+ await promise;
3560
+ $mol_assert_like(NameLogger.first, ['john', 'jin']);
3561
+ $mol_assert_like(NameLogger.last, ['jin']);
3562
+ },
3563
+ async 'Latest function calls wins'($) {
3564
+ const first = [];
3565
+ const last = [];
3566
+ function send_name(next) {
3567
+ $mol_wire_sync(first).push(next);
3568
+ $.$mol_wait_timeout(0);
3569
+ last.push(next);
3570
+ }
3571
+ const name = $mol_wire_async(send_name);
3572
+ name('john');
3573
+ const promise = name('jin');
3574
+ $.$mol_after_mock_warp();
3575
+ await promise;
3576
+ $mol_assert_like(first, ['john', 'jin']);
3577
+ $mol_assert_like(last, ['jin']);
3578
+ },
3579
+ });
3580
+ })($ || ($ = {}));
3581
+
2529
3582
  ;
2530
3583
  "use strict";
2531
3584
  var $;