mol_jsx_lib 0.0.1

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 ADDED
@@ -0,0 +1,3543 @@
1
+ "use strict";
2
+ "use strict"
3
+
4
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
5
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
6
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
7
+ else for (var i = decorators.length - 1; i >= 0; i--) if ((d = decorators[i])) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
8
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
9
+ };
10
+
11
+ var globalThis = globalThis || ( typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : this )
12
+ var $ = ( typeof module === 'object' ) ? ( module['export'+'s'] = globalThis ) : globalThis
13
+ $.$$ = $
14
+
15
+ ;
16
+ "use strict";
17
+ Error.stackTraceLimit = 50;
18
+ var $;
19
+ (function ($) {
20
+ })($ || ($ = {}));
21
+ module.exports = $;
22
+ //mam.ts
23
+ ;
24
+ "use strict";
25
+ var $;
26
+ (function ($) {
27
+ })($ || ($ = {}));
28
+ //mol/dom/context/context.ts
29
+ ;
30
+ "use strict";
31
+ //node/node.ts
32
+ ;
33
+ "use strict";
34
+ var $node = new Proxy({ require }, {
35
+ get(target, name, wrapper) {
36
+ if (target[name])
37
+ return target[name];
38
+ const mod = target.require('module');
39
+ if (mod.builtinModules.indexOf(name) >= 0)
40
+ return target.require(name);
41
+ const path = target.require('path');
42
+ const fs = target.require('fs');
43
+ let dir = path.resolve('.');
44
+ const suffix = `./node_modules/${name}`;
45
+ const $$ = $;
46
+ while (!fs.existsSync(path.join(dir, suffix))) {
47
+ const parent = path.resolve(dir, '..');
48
+ if (parent === dir) {
49
+ $$.$mol_exec('.', 'npm', 'install', name);
50
+ try {
51
+ $$.$mol_exec('.', 'npm', 'install', '@types/' + name);
52
+ }
53
+ catch { }
54
+ break;
55
+ }
56
+ else {
57
+ dir = parent;
58
+ }
59
+ }
60
+ return target.require(name);
61
+ },
62
+ set(target, name, value) {
63
+ target[name] = value;
64
+ return true;
65
+ },
66
+ });
67
+ require = (req => Object.assign(function require(name) {
68
+ return $node[name];
69
+ }, req))(require);
70
+ //node/node.node.ts
71
+ ;
72
+ "use strict";
73
+ var $;
74
+ (function ($) {
75
+ function $mol_log3_area_lazy(event) {
76
+ const self = this;
77
+ const stack = self.$mol_log3_stack;
78
+ const deep = stack.length;
79
+ let logged = false;
80
+ stack.push(() => {
81
+ logged = true;
82
+ self.$mol_log3_area.call(self, event);
83
+ });
84
+ return () => {
85
+ if (logged)
86
+ self.console.groupEnd();
87
+ if (stack.length > deep)
88
+ stack.length = deep;
89
+ };
90
+ }
91
+ $.$mol_log3_area_lazy = $mol_log3_area_lazy;
92
+ $.$mol_log3_stack = [];
93
+ })($ || ($ = {}));
94
+ //mol/log3/log3.ts
95
+ ;
96
+ "use strict";
97
+ var $;
98
+ (function ($) {
99
+ $.$mol_ambient_ref = Symbol('$mol_ambient_ref');
100
+ function $mol_ambient(overrides) {
101
+ return Object.setPrototypeOf(overrides, this || $);
102
+ }
103
+ $.$mol_ambient = $mol_ambient;
104
+ })($ || ($ = {}));
105
+ //mol/ambient/ambient.ts
106
+ ;
107
+ "use strict";
108
+ var $;
109
+ (function ($) {
110
+ const instances = new WeakSet();
111
+ function $mol_delegate(proto, target) {
112
+ const proxy = new Proxy(proto, {
113
+ get: (_, field) => {
114
+ const obj = target();
115
+ let val = Reflect.get(obj, field);
116
+ if (typeof val === 'function') {
117
+ val = val.bind(obj);
118
+ }
119
+ return val;
120
+ },
121
+ has: (_, field) => Reflect.has(target(), field),
122
+ set: (_, field, value) => Reflect.set(target(), field, value),
123
+ getOwnPropertyDescriptor: (_, field) => Reflect.getOwnPropertyDescriptor(target(), field),
124
+ ownKeys: () => Reflect.ownKeys(target()),
125
+ getPrototypeOf: () => Reflect.getPrototypeOf(target()),
126
+ setPrototypeOf: (_, donor) => Reflect.setPrototypeOf(target(), donor),
127
+ isExtensible: () => Reflect.isExtensible(target()),
128
+ preventExtensions: () => Reflect.preventExtensions(target()),
129
+ apply: (_, self, args) => Reflect.apply(target(), self, args),
130
+ construct: (_, args, retarget) => Reflect.construct(target(), args, retarget),
131
+ defineProperty: (_, field, descr) => Reflect.defineProperty(target(), field, descr),
132
+ deleteProperty: (_, field) => Reflect.deleteProperty(target(), field),
133
+ });
134
+ instances.add(proxy);
135
+ return proxy;
136
+ }
137
+ $.$mol_delegate = $mol_delegate;
138
+ Reflect.defineProperty($mol_delegate, Symbol.hasInstance, {
139
+ value: (obj) => instances.has(obj),
140
+ });
141
+ })($ || ($ = {}));
142
+ //mol/delegate/delegate.ts
143
+ ;
144
+ "use strict";
145
+ var $;
146
+ (function ($) {
147
+ $.$mol_owning_map = new WeakMap();
148
+ function $mol_owning_allow(having) {
149
+ try {
150
+ if (!having)
151
+ return false;
152
+ if (typeof having !== 'object')
153
+ return false;
154
+ if (having instanceof $mol_delegate)
155
+ return false;
156
+ if (typeof having['destructor'] !== 'function')
157
+ return false;
158
+ return true;
159
+ }
160
+ catch {
161
+ return false;
162
+ }
163
+ }
164
+ $.$mol_owning_allow = $mol_owning_allow;
165
+ function $mol_owning_get(having, Owner) {
166
+ if (!$mol_owning_allow(having))
167
+ return null;
168
+ while (true) {
169
+ const owner = $.$mol_owning_map.get(having);
170
+ if (!owner)
171
+ return owner;
172
+ if (!Owner)
173
+ return owner;
174
+ if (owner instanceof Owner)
175
+ return owner;
176
+ having = owner;
177
+ }
178
+ }
179
+ $.$mol_owning_get = $mol_owning_get;
180
+ function $mol_owning_check(owner, having) {
181
+ if (!$mol_owning_allow(having))
182
+ return false;
183
+ if ($.$mol_owning_map.get(having) !== owner)
184
+ return false;
185
+ return true;
186
+ }
187
+ $.$mol_owning_check = $mol_owning_check;
188
+ function $mol_owning_catch(owner, having) {
189
+ if (!$mol_owning_allow(having))
190
+ return false;
191
+ if ($.$mol_owning_map.get(having))
192
+ return false;
193
+ $.$mol_owning_map.set(having, owner);
194
+ return true;
195
+ }
196
+ $.$mol_owning_catch = $mol_owning_catch;
197
+ })($ || ($ = {}));
198
+ //mol/owning/owning.ts
199
+ ;
200
+ "use strict";
201
+ var $;
202
+ (function ($) {
203
+ function $mol_fail(error) {
204
+ throw error;
205
+ }
206
+ $.$mol_fail = $mol_fail;
207
+ })($ || ($ = {}));
208
+ //mol/fail/fail.ts
209
+ ;
210
+ "use strict";
211
+ var $;
212
+ (function ($) {
213
+ function $mol_fail_hidden(error) {
214
+ throw error;
215
+ }
216
+ $.$mol_fail_hidden = $mol_fail_hidden;
217
+ })($ || ($ = {}));
218
+ //mol/fail/hidden/hidden.ts
219
+ ;
220
+ "use strict";
221
+ //mol/type/writable/writable.ts
222
+ ;
223
+ "use strict";
224
+ var $;
225
+ (function ($) {
226
+ class $mol_object2 {
227
+ static $ = $;
228
+ [$mol_ambient_ref] = null;
229
+ get $() {
230
+ if (this[$mol_ambient_ref])
231
+ return this[$mol_ambient_ref];
232
+ const owner = $mol_owning_get(this);
233
+ return this[$mol_ambient_ref] = owner?.$ || $mol_object2.$;
234
+ }
235
+ set $(next) {
236
+ if (this[$mol_ambient_ref])
237
+ $mol_fail_hidden(new Error('Context already defined'));
238
+ this[$mol_ambient_ref] = next;
239
+ }
240
+ static create(init) {
241
+ const obj = new this;
242
+ if (init)
243
+ init(obj);
244
+ return obj;
245
+ }
246
+ static [Symbol.toPrimitive]() {
247
+ return this.toString();
248
+ }
249
+ static toString() {
250
+ if (Symbol.toStringTag in this)
251
+ return this[Symbol.toStringTag];
252
+ return this.name;
253
+ }
254
+ destructor() { }
255
+ toString() {
256
+ return this[Symbol.toStringTag] || this.constructor.name + '()';
257
+ }
258
+ toJSON() {
259
+ return this.toString();
260
+ }
261
+ }
262
+ $.$mol_object2 = $mol_object2;
263
+ })($ || ($ = {}));
264
+ //mol/object2/object2.ts
265
+ ;
266
+ "use strict";
267
+ var $;
268
+ (function ($) {
269
+ function $mol_deprecated(message) {
270
+ return (host, field, descr) => {
271
+ const value = descr.value;
272
+ let warned = false;
273
+ descr.value = function $mol_deprecated_wrapper(...args) {
274
+ if (!warned) {
275
+ $$.$mol_log3_warn({
276
+ place: `${host.constructor.name}::${field}`,
277
+ message: `Deprecated`,
278
+ hint: message,
279
+ });
280
+ warned = true;
281
+ }
282
+ return value.call(this, ...args);
283
+ };
284
+ };
285
+ }
286
+ $.$mol_deprecated = $mol_deprecated;
287
+ })($ || ($ = {}));
288
+ //mol/deprecated/deprecated.ts
289
+ ;
290
+ "use strict";
291
+ var $;
292
+ (function ($) {
293
+ $.$mol_tree_convert = Symbol('$mol_tree_convert');
294
+ class $mol_tree extends $mol_object2 {
295
+ type;
296
+ data;
297
+ sub;
298
+ baseUri;
299
+ row;
300
+ col;
301
+ length;
302
+ constructor(config = {}) {
303
+ super();
304
+ this.type = config.type || '';
305
+ if (config.value !== undefined) {
306
+ var sub = $mol_tree.values(config.value);
307
+ if (config.type || sub.length > 1) {
308
+ this.sub = [...sub, ...(config.sub || [])];
309
+ this.data = config.data || '';
310
+ }
311
+ else {
312
+ this.data = sub[0].data;
313
+ this.sub = config.sub || [];
314
+ }
315
+ }
316
+ else {
317
+ this.data = config.data || '';
318
+ this.sub = config.sub || [];
319
+ }
320
+ this.baseUri = config.baseUri || '';
321
+ this.row = config.row || 0;
322
+ this.col = config.col || 0;
323
+ this.length = config.length || 0;
324
+ }
325
+ static values(str, baseUri) {
326
+ return str.split('\n').map((data, index) => new $mol_tree({
327
+ data: data,
328
+ baseUri: baseUri,
329
+ row: index + 1,
330
+ length: data.length,
331
+ }));
332
+ }
333
+ clone(config = {}) {
334
+ return new $mol_tree({
335
+ type: ('type' in config) ? config.type : this.type,
336
+ data: ('data' in config) ? config.data : this.data,
337
+ sub: ('sub' in config) ? config.sub : this.sub,
338
+ baseUri: ('baseUri' in config) ? config.baseUri : this.baseUri,
339
+ row: ('row' in config) ? config.row : this.row,
340
+ col: ('col' in config) ? config.col : this.col,
341
+ length: ('length' in config) ? config.length : this.length,
342
+ value: config.value
343
+ });
344
+ }
345
+ make(config) {
346
+ return new $mol_tree({
347
+ baseUri: this.baseUri,
348
+ row: this.row,
349
+ col: this.col,
350
+ length: this.length,
351
+ ...config,
352
+ });
353
+ }
354
+ make_data(value, sub) {
355
+ return this.make({ value, sub });
356
+ }
357
+ make_struct(type, sub) {
358
+ return this.make({ type, sub });
359
+ }
360
+ static fromString(str, baseUri) {
361
+ var root = new $mol_tree({ baseUri: baseUri });
362
+ var stack = [root];
363
+ var row = 0;
364
+ var prefix = str.replace(/^\n?(\t*)[\s\S]*/, '$1');
365
+ var lines = str.replace(new RegExp('^\\t{0,' + prefix.length + '}', 'mg'), '').split('\n');
366
+ lines.forEach(line => {
367
+ ++row;
368
+ var chunks = /^(\t*)((?:[^\n\t\\ ]+ *)*)(\\[^\n]*)?(.*?)(?:$|\n)/m.exec(line);
369
+ if (!chunks || chunks[4])
370
+ return this.$.$mol_fail(new Error(`Syntax error at ${baseUri}:${row}\n${line}`));
371
+ var indent = chunks[1];
372
+ var path = chunks[2];
373
+ var data = chunks[3];
374
+ var deep = indent.length;
375
+ var types = path ? path.replace(/ $/, '').split(/ +/) : [];
376
+ if (stack.length <= deep)
377
+ return this.$.$mol_fail(new Error(`Too many tabs at ${baseUri}:${row}\n${line}`));
378
+ stack.length = deep + 1;
379
+ var parent = stack[deep];
380
+ let col = deep;
381
+ types.forEach(type => {
382
+ if (!type)
383
+ return this.$.$mol_fail(new Error(`Unexpected space symbol ${baseUri}:${row}\n${line}`));
384
+ var next = new $mol_tree({ type, baseUri, row, col, length: type.length });
385
+ const parent_sub = parent.sub;
386
+ parent_sub.push(next);
387
+ parent = next;
388
+ col += type.length + 1;
389
+ });
390
+ if (data) {
391
+ var next = new $mol_tree({ data: data.substring(1), baseUri, row, col, length: data.length });
392
+ const parent_sub = parent.sub;
393
+ parent_sub.push(next);
394
+ parent = next;
395
+ }
396
+ stack.push(parent);
397
+ });
398
+ return root;
399
+ }
400
+ static fromJSON(json, baseUri = '') {
401
+ switch (true) {
402
+ case typeof json === 'boolean':
403
+ case typeof json === 'number':
404
+ case json === null:
405
+ return new $mol_tree({
406
+ type: String(json),
407
+ baseUri: baseUri
408
+ });
409
+ case typeof json === 'string':
410
+ return new $mol_tree({
411
+ value: json,
412
+ baseUri: baseUri
413
+ });
414
+ case Array.isArray(json):
415
+ return new $mol_tree({
416
+ type: "/",
417
+ sub: json.map(json => $mol_tree.fromJSON(json, baseUri))
418
+ });
419
+ case json instanceof Date:
420
+ return new $mol_tree({
421
+ value: json.toISOString(),
422
+ baseUri: baseUri
423
+ });
424
+ default:
425
+ if (typeof json[$.$mol_tree_convert] === 'function') {
426
+ return json[$.$mol_tree_convert]();
427
+ }
428
+ if (typeof json.toJSON === 'function') {
429
+ return $mol_tree.fromJSON(json.toJSON());
430
+ }
431
+ if (json instanceof Error) {
432
+ const { name, message, stack } = json;
433
+ json = { ...json, name, message, stack };
434
+ }
435
+ var sub = [];
436
+ for (var key in json) {
437
+ if (json[key] === undefined)
438
+ continue;
439
+ const subsub = $mol_tree.fromJSON(json[key], baseUri);
440
+ if (/^[^\n\t\\ ]+$/.test(key)) {
441
+ var child = new $mol_tree({
442
+ type: key,
443
+ baseUri: baseUri,
444
+ sub: [subsub],
445
+ });
446
+ }
447
+ else {
448
+ var child = new $mol_tree({
449
+ value: key,
450
+ baseUri: baseUri,
451
+ sub: [subsub],
452
+ });
453
+ }
454
+ sub.push(child);
455
+ }
456
+ return new $mol_tree({
457
+ type: "*",
458
+ sub: sub,
459
+ baseUri: baseUri
460
+ });
461
+ }
462
+ }
463
+ get uri() {
464
+ return this.baseUri + '#' + this.row + ':' + this.col;
465
+ }
466
+ toString(prefix = '') {
467
+ var output = '';
468
+ if (this.type.length) {
469
+ if (!prefix.length) {
470
+ prefix = "\t";
471
+ }
472
+ output += this.type;
473
+ if (this.sub.length == 1) {
474
+ return output + ' ' + this.sub[0].toString(prefix);
475
+ }
476
+ output += "\n";
477
+ }
478
+ else if (this.data.length || prefix.length) {
479
+ output += "\\" + this.data + "\n";
480
+ }
481
+ for (var child of this.sub) {
482
+ output += prefix;
483
+ output += child.toString(prefix + "\t");
484
+ }
485
+ return output;
486
+ }
487
+ toJSON() {
488
+ if (!this.type)
489
+ return this.value;
490
+ if (this.type === 'true')
491
+ return true;
492
+ if (this.type === 'false')
493
+ return false;
494
+ if (this.type === 'null')
495
+ return null;
496
+ if (this.type === '*') {
497
+ var obj = {};
498
+ for (var child of this.sub) {
499
+ if (child.type === '-')
500
+ continue;
501
+ var key = child.type || child.clone({ sub: child.sub.slice(0, child.sub.length - 1) }).value;
502
+ var val = child.sub[child.sub.length - 1].toJSON();
503
+ if (val !== undefined)
504
+ obj[key] = val;
505
+ }
506
+ return obj;
507
+ }
508
+ if (this.type === '/') {
509
+ var res = [];
510
+ this.sub.forEach(child => {
511
+ if (child.type === '-')
512
+ return;
513
+ var val = child.toJSON();
514
+ if (val !== undefined)
515
+ res.push(val);
516
+ });
517
+ return res;
518
+ }
519
+ if (this.type === 'time') {
520
+ return new Date(this.value);
521
+ }
522
+ const numb = Number(this.type);
523
+ if (!Number.isNaN(numb) || this.type === 'NaN')
524
+ return numb;
525
+ throw new Error(`Unknown type (${this.type}) at ${this.uri}`);
526
+ }
527
+ get value() {
528
+ var values = [];
529
+ for (var child of this.sub) {
530
+ if (child.type)
531
+ continue;
532
+ values.push(child.value);
533
+ }
534
+ return this.data + values.join("\n");
535
+ }
536
+ insert(value, ...path) {
537
+ if (path.length === 0)
538
+ return value;
539
+ const type = path[0];
540
+ if (typeof type === 'string') {
541
+ let replaced = false;
542
+ const sub = this.sub.map((item, index) => {
543
+ if (item.type !== type)
544
+ return item;
545
+ replaced = true;
546
+ return item.insert(value, ...path.slice(1));
547
+ });
548
+ if (!replaced)
549
+ sub.push(new $mol_tree({ type }).insert(value, ...path.slice(1)));
550
+ return this.clone({ sub });
551
+ }
552
+ else if (typeof type === 'number') {
553
+ const sub = this.sub.slice();
554
+ sub[type] = (sub[type] || new $mol_tree).insert(value, ...path.slice(1));
555
+ return this.clone({ sub });
556
+ }
557
+ else {
558
+ return this.clone({ sub: ((this.sub.length === 0) ? [new $mol_tree()] : this.sub).map(item => item.insert(value, ...path.slice(1))) });
559
+ }
560
+ }
561
+ select(...path) {
562
+ var next = [this];
563
+ for (var type of path) {
564
+ if (!next.length)
565
+ break;
566
+ var prev = next;
567
+ next = [];
568
+ for (var item of prev) {
569
+ switch (typeof (type)) {
570
+ case 'string':
571
+ for (var child of item.sub) {
572
+ if (!type || (child.type == type)) {
573
+ next.push(child);
574
+ }
575
+ }
576
+ break;
577
+ case 'number':
578
+ if (type < item.sub.length)
579
+ next.push(item.sub[type]);
580
+ break;
581
+ default: next.push(...item.sub);
582
+ }
583
+ }
584
+ }
585
+ return new $mol_tree({ sub: next });
586
+ }
587
+ filter(path, value) {
588
+ var sub = this.sub.filter(function (item) {
589
+ var found = item.select(...path);
590
+ if (value == null) {
591
+ return Boolean(found.sub.length);
592
+ }
593
+ else {
594
+ return found.sub.some(child => child.value == value);
595
+ }
596
+ });
597
+ return new $mol_tree({ sub: sub });
598
+ }
599
+ transform(visit, stack = []) {
600
+ const sub_stack = [this, ...stack];
601
+ return visit(sub_stack, () => this.sub.map(node => node.transform(visit, sub_stack)).filter(n => n));
602
+ }
603
+ hack(context) {
604
+ const sub = [].concat(...this.sub.map(child => {
605
+ const handle = context[child.type] || context[''];
606
+ if (!handle)
607
+ $mol_fail(child.error('Handler not defined'));
608
+ return handle(child, context);
609
+ }));
610
+ return this.clone({ sub });
611
+ }
612
+ error(message) {
613
+ return new Error(`${message}:\n${this} ${this.baseUri}:${this.row}:${this.col}`);
614
+ }
615
+ }
616
+ __decorate([
617
+ $mol_deprecated('Use $mol_tree:hack')
618
+ ], $mol_tree.prototype, "transform", null);
619
+ $.$mol_tree = $mol_tree;
620
+ })($ || ($ = {}));
621
+ //mol/tree/tree.ts
622
+ ;
623
+ "use strict";
624
+ var $;
625
+ (function ($) {
626
+ function $mol_log3_node_make(level, output, type, color) {
627
+ return function $mol_log3_logger(event) {
628
+ if (!event.time)
629
+ event = { time: new Date().toISOString(), ...event };
630
+ const tree = this.$mol_tree.fromJSON(event).clone({ type });
631
+ let str = tree.toString();
632
+ if (process[output].isTTY) {
633
+ str = $node.colorette[color + 'Bright'](str);
634
+ }
635
+ ;
636
+ this.console[level](str);
637
+ const self = this;
638
+ return () => self.console.groupEnd();
639
+ };
640
+ }
641
+ $.$mol_log3_node_make = $mol_log3_node_make;
642
+ $.$mol_log3_come = $mol_log3_node_make('info', 'stdout', 'come', 'blue');
643
+ $.$mol_log3_done = $mol_log3_node_make('info', 'stdout', 'done', 'green');
644
+ $.$mol_log3_fail = $mol_log3_node_make('error', 'stderr', 'fail', 'red');
645
+ $.$mol_log3_warn = $mol_log3_node_make('warn', 'stderr', 'warn', 'yellow');
646
+ $.$mol_log3_rise = $mol_log3_node_make('log', 'stdout', 'rise', 'magenta');
647
+ $.$mol_log3_area = $mol_log3_node_make('log', 'stdout', 'area', 'cyan');
648
+ })($ || ($ = {}));
649
+ //mol/log3/log3.node.ts
650
+ ;
651
+ "use strict";
652
+ var $;
653
+ (function ($) {
654
+ function $mol_env() {
655
+ return {};
656
+ }
657
+ $.$mol_env = $mol_env;
658
+ })($ || ($ = {}));
659
+ //mol/env/env.ts
660
+ ;
661
+ "use strict";
662
+ var $;
663
+ (function ($) {
664
+ $.$mol_env = function $mol_env() {
665
+ return this.process.env;
666
+ };
667
+ })($ || ($ = {}));
668
+ //mol/env/env.node.ts
669
+ ;
670
+ "use strict";
671
+ var $;
672
+ (function ($) {
673
+ function $mol_exec(dir, command, ...args) {
674
+ let [app, ...args0] = command.split(' ');
675
+ args = [...args0, ...args];
676
+ this.$mol_log3_come({
677
+ place: '$mol_exec',
678
+ dir: $node.path.relative('', dir),
679
+ message: 'Run',
680
+ command: `${app} ${args.join(' ')}`,
681
+ });
682
+ var res = $node['child_process'].spawnSync(app, args, {
683
+ cwd: $node.path.resolve(dir),
684
+ shell: true,
685
+ env: this.$mol_env(),
686
+ });
687
+ if (res.status || res.error)
688
+ return $mol_fail(res.error || new Error(res.stderr.toString()));
689
+ if (!res.stdout)
690
+ res.stdout = Buffer.from([]);
691
+ return res;
692
+ }
693
+ $.$mol_exec = $mol_exec;
694
+ })($ || ($ = {}));
695
+ //mol/exec/exec.node.ts
696
+ ;
697
+ "use strict";
698
+ var $;
699
+ (function ($) {
700
+ $.$mol_dom_context = new $node.jsdom.JSDOM('', { url: 'https://localhost/' }).window;
701
+ })($ || ($ = {}));
702
+ //mol/dom/context/context.node.ts
703
+ ;
704
+ "use strict";
705
+ var $;
706
+ (function ($) {
707
+ function $mol_dom_render_children(el, childNodes) {
708
+ const node_set = new Set(childNodes);
709
+ let nextNode = el.firstChild;
710
+ for (let view of childNodes) {
711
+ if (view == null)
712
+ continue;
713
+ if (view instanceof $mol_dom_context.Node) {
714
+ while (true) {
715
+ if (!nextNode) {
716
+ el.appendChild(view);
717
+ break;
718
+ }
719
+ if (nextNode == view) {
720
+ nextNode = nextNode.nextSibling;
721
+ break;
722
+ }
723
+ else {
724
+ if (node_set.has(nextNode)) {
725
+ el.insertBefore(view, nextNode);
726
+ break;
727
+ }
728
+ else {
729
+ const nn = nextNode.nextSibling;
730
+ el.removeChild(nextNode);
731
+ nextNode = nn;
732
+ }
733
+ }
734
+ }
735
+ }
736
+ else {
737
+ if (nextNode && nextNode.nodeName === '#text') {
738
+ const str = String(view);
739
+ if (nextNode.nodeValue !== str)
740
+ nextNode.nodeValue = str;
741
+ nextNode = nextNode.nextSibling;
742
+ }
743
+ else {
744
+ const textNode = $mol_dom_context.document.createTextNode(String(view));
745
+ el.insertBefore(textNode, nextNode);
746
+ }
747
+ }
748
+ }
749
+ while (nextNode) {
750
+ const currNode = nextNode;
751
+ nextNode = currNode.nextSibling;
752
+ el.removeChild(currNode);
753
+ }
754
+ }
755
+ $.$mol_dom_render_children = $mol_dom_render_children;
756
+ })($ || ($ = {}));
757
+ //mol/dom/render/children/children.ts
758
+ ;
759
+ "use strict";
760
+ //mol/type/partial/deep/deep.ts
761
+ ;
762
+ "use strict";
763
+ var $;
764
+ (function ($) {
765
+ $.$mol_jsx_prefix = '';
766
+ $.$mol_jsx_booked = null;
767
+ $.$mol_jsx_document = {
768
+ getElementById: () => null,
769
+ createElementNS: (space, name) => $mol_dom_context.document.createElementNS(space, name),
770
+ createDocumentFragment: () => $mol_dom_context.document.createDocumentFragment(),
771
+ };
772
+ $.$mol_jsx_frag = '';
773
+ function $mol_jsx(Elem, props, ...childNodes) {
774
+ const id = props && props.id || '';
775
+ if (Elem && $.$mol_jsx_booked) {
776
+ if ($.$mol_jsx_booked.has(id)) {
777
+ $mol_fail(new Error(`JSX already has tag with id ${JSON.stringify(id)}`));
778
+ }
779
+ else {
780
+ $.$mol_jsx_booked.add(id);
781
+ }
782
+ }
783
+ const guid = $.$mol_jsx_prefix + id;
784
+ let node = guid ? $.$mol_jsx_document.getElementById(guid) : null;
785
+ if (typeof Elem !== 'string') {
786
+ if ('prototype' in Elem) {
787
+ const view = node && node[Elem] || new Elem;
788
+ Object.assign(view, props);
789
+ view[Symbol.toStringTag] = guid;
790
+ view.childNodes = childNodes;
791
+ if (!view.ownerDocument)
792
+ view.ownerDocument = $.$mol_jsx_document;
793
+ node = view.valueOf();
794
+ node[Elem] = view;
795
+ return node;
796
+ }
797
+ else {
798
+ const prefix = $.$mol_jsx_prefix;
799
+ const booked = $.$mol_jsx_booked;
800
+ try {
801
+ $.$mol_jsx_prefix = guid;
802
+ $.$mol_jsx_booked = new Set;
803
+ return Elem(props, ...childNodes);
804
+ }
805
+ finally {
806
+ $.$mol_jsx_prefix = prefix;
807
+ $.$mol_jsx_booked = booked;
808
+ }
809
+ }
810
+ }
811
+ if (!node) {
812
+ node = Elem
813
+ ? $.$mol_jsx_document.createElementNS(props?.xmlns ?? 'http://www.w3.org/1999/xhtml', Elem)
814
+ : $.$mol_jsx_document.createDocumentFragment();
815
+ }
816
+ $mol_dom_render_children(node, [].concat(...childNodes));
817
+ if (!Elem)
818
+ return node;
819
+ for (const key in props) {
820
+ if (typeof props[key] === 'string') {
821
+ ;
822
+ node.setAttribute(key, props[key]);
823
+ }
824
+ else if (props[key] &&
825
+ typeof props[key] === 'object' &&
826
+ Reflect.getPrototypeOf(props[key]) === Reflect.getPrototypeOf({})) {
827
+ if (typeof node[key] === 'object') {
828
+ Object.assign(node[key], props[key]);
829
+ continue;
830
+ }
831
+ }
832
+ else {
833
+ node[key] = props[key];
834
+ }
835
+ }
836
+ if (guid)
837
+ node.id = guid;
838
+ return node;
839
+ }
840
+ $.$mol_jsx = $mol_jsx;
841
+ })($ || ($ = {}));
842
+ //mol/jsx/jsx.ts
843
+ ;
844
+ "use strict";
845
+ var $;
846
+ (function ($) {
847
+ function $mol_jsx_attach(next, action) {
848
+ const prev = $mol_jsx_document;
849
+ try {
850
+ $mol_jsx_document = next;
851
+ return action();
852
+ }
853
+ finally {
854
+ $mol_jsx_document = prev;
855
+ }
856
+ }
857
+ $.$mol_jsx_attach = $mol_jsx_attach;
858
+ })($ || ($ = {}));
859
+ //mol/jsx/attach/attach.ts
860
+ ;
861
+ "use strict";
862
+ var $;
863
+ (function ($) {
864
+ let $mol_wire_cursor;
865
+ (function ($mol_wire_cursor) {
866
+ $mol_wire_cursor[$mol_wire_cursor["stale"] = -1] = "stale";
867
+ $mol_wire_cursor[$mol_wire_cursor["doubt"] = -2] = "doubt";
868
+ $mol_wire_cursor[$mol_wire_cursor["fresh"] = -3] = "fresh";
869
+ $mol_wire_cursor[$mol_wire_cursor["final"] = -4] = "final";
870
+ })($mol_wire_cursor = $.$mol_wire_cursor || ($.$mol_wire_cursor = {}));
871
+ })($ || ($ = {}));
872
+ //mol/wire/cursor/cursor.ts
873
+ ;
874
+ "use strict";
875
+ var $;
876
+ (function ($) {
877
+ class $mol_wire_pub extends Object {
878
+ data = [];
879
+ static get [Symbol.species]() {
880
+ return Array;
881
+ }
882
+ sub_from = 0;
883
+ get sub_list() {
884
+ const res = [];
885
+ for (let i = this.sub_from; i < this.data.length; i += 2) {
886
+ res.push(this.data[i]);
887
+ }
888
+ return res;
889
+ }
890
+ get sub_empty() {
891
+ return this.sub_from === this.data.length;
892
+ }
893
+ sub_on(sub, pub_pos) {
894
+ const pos = this.data.length;
895
+ this.data.push(sub, pub_pos);
896
+ return pos;
897
+ }
898
+ sub_off(sub_pos) {
899
+ if (!(sub_pos < this.data.length)) {
900
+ $mol_fail(new Error(`Wrong pos ${sub_pos}`));
901
+ }
902
+ const end = this.data.length - 2;
903
+ if (sub_pos !== end) {
904
+ this.peer_move(end, sub_pos);
905
+ }
906
+ this.data.pop();
907
+ this.data.pop();
908
+ if (this.data.length === this.sub_from)
909
+ this.reap();
910
+ }
911
+ reap() { }
912
+ promote() {
913
+ $mol_wire_auto()?.track_next(this);
914
+ }
915
+ refresh() { }
916
+ complete() { }
917
+ emit(quant = $mol_wire_cursor.stale) {
918
+ for (let i = this.sub_from; i < this.data.length; i += 2) {
919
+ ;
920
+ this.data[i].absorb(quant);
921
+ }
922
+ }
923
+ peer_move(from_pos, to_pos) {
924
+ const peer = this.data[from_pos];
925
+ const self_pos = this.data[from_pos + 1];
926
+ this.data[to_pos] = peer;
927
+ this.data[to_pos + 1] = self_pos;
928
+ peer.peer_repos(self_pos, to_pos);
929
+ }
930
+ peer_repos(peer_pos, self_pos) {
931
+ this.data[peer_pos + 1] = self_pos;
932
+ }
933
+ }
934
+ $.$mol_wire_pub = $mol_wire_pub;
935
+ })($ || ($ = {}));
936
+ //mol/wire/pub/pub.ts
937
+ ;
938
+ "use strict";
939
+ //mol/wire/sub/sub.ts
940
+ ;
941
+ "use strict";
942
+ var $;
943
+ (function ($) {
944
+ let auto = null;
945
+ function $mol_wire_auto(next = auto) {
946
+ return auto = next;
947
+ }
948
+ $.$mol_wire_auto = $mol_wire_auto;
949
+ $.$mol_wire_affected = [];
950
+ })($ || ($ = {}));
951
+ //mol/wire/wire.ts
952
+ ;
953
+ "use strict";
954
+ var $;
955
+ (function ($) {
956
+ $['devtoolsFormatters'] = $['devtoolsFormatters'] || [];
957
+ function $mol_dev_format_register(config) {
958
+ $['devtoolsFormatters'].push(config);
959
+ }
960
+ $.$mol_dev_format_register = $mol_dev_format_register;
961
+ $.$mol_dev_format_head = Symbol('$mol_dev_format_head');
962
+ $.$mol_dev_format_body = Symbol('$mol_dev_format_body');
963
+ $mol_dev_format_register({
964
+ header: (val, config = false) => {
965
+ if (config)
966
+ return null;
967
+ if (!val)
968
+ return null;
969
+ if ($.$mol_dev_format_head in val) {
970
+ return val[$.$mol_dev_format_head]();
971
+ }
972
+ if (typeof val === 'function') {
973
+ return $mol_dev_format_native(val);
974
+ }
975
+ return null;
976
+ },
977
+ hasBody: val => val[$.$mol_dev_format_body],
978
+ body: val => val[$.$mol_dev_format_body](),
979
+ });
980
+ function $mol_dev_format_native(obj) {
981
+ if (typeof obj === 'undefined')
982
+ return $.$mol_dev_format_shade('undefined');
983
+ if (typeof obj !== 'object' && typeof obj !== 'function')
984
+ return obj;
985
+ return [
986
+ 'object',
987
+ {
988
+ object: obj,
989
+ config: true,
990
+ },
991
+ ];
992
+ }
993
+ $.$mol_dev_format_native = $mol_dev_format_native;
994
+ function $mol_dev_format_auto(obj) {
995
+ if (obj == null)
996
+ return $.$mol_dev_format_shade(String(obj));
997
+ if (typeof obj === 'object' && $.$mol_dev_format_head in obj) {
998
+ return obj[$.$mol_dev_format_head]();
999
+ }
1000
+ return [
1001
+ 'object',
1002
+ {
1003
+ object: obj,
1004
+ config: false,
1005
+ },
1006
+ ];
1007
+ }
1008
+ $.$mol_dev_format_auto = $mol_dev_format_auto;
1009
+ function $mol_dev_format_element(element, style, ...content) {
1010
+ const styles = [];
1011
+ for (let key in style)
1012
+ styles.push(`${key} : ${style[key]}`);
1013
+ return [
1014
+ element,
1015
+ {
1016
+ style: styles.join(' ; '),
1017
+ },
1018
+ ...content,
1019
+ ];
1020
+ }
1021
+ $.$mol_dev_format_element = $mol_dev_format_element;
1022
+ function $mol_dev_format_span(style, ...content) {
1023
+ return $mol_dev_format_element('span', {
1024
+ 'vertical-align': '8%',
1025
+ ...style,
1026
+ }, ...content);
1027
+ }
1028
+ $.$mol_dev_format_span = $mol_dev_format_span;
1029
+ $.$mol_dev_format_div = $mol_dev_format_element.bind(null, 'div');
1030
+ $.$mol_dev_format_ol = $mol_dev_format_element.bind(null, 'ol');
1031
+ $.$mol_dev_format_li = $mol_dev_format_element.bind(null, 'li');
1032
+ $.$mol_dev_format_table = $mol_dev_format_element.bind(null, 'table');
1033
+ $.$mol_dev_format_tr = $mol_dev_format_element.bind(null, 'tr');
1034
+ $.$mol_dev_format_td = $mol_dev_format_element.bind(null, 'td');
1035
+ $.$mol_dev_format_accent = $mol_dev_format_span.bind(null, {
1036
+ 'color': 'magenta',
1037
+ });
1038
+ $.$mol_dev_format_strong = $mol_dev_format_span.bind(null, {
1039
+ 'font-weight': 'bold',
1040
+ });
1041
+ $.$mol_dev_format_string = $mol_dev_format_span.bind(null, {
1042
+ 'color': 'green',
1043
+ });
1044
+ $.$mol_dev_format_shade = $mol_dev_format_span.bind(null, {
1045
+ 'color': 'gray',
1046
+ });
1047
+ $.$mol_dev_format_indent = $.$mol_dev_format_div.bind(null, {
1048
+ 'margin-left': '13px'
1049
+ });
1050
+ })($ || ($ = {}));
1051
+ //mol/dev/format/format.ts
1052
+ ;
1053
+ "use strict";
1054
+ var $;
1055
+ (function ($) {
1056
+ class $mol_wire_pub_sub extends $mol_wire_pub {
1057
+ pub_from = 0;
1058
+ cursor = $mol_wire_cursor.stale;
1059
+ get pub_list() {
1060
+ const res = [];
1061
+ const max = this.cursor >= 0 ? this.cursor : this.sub_from;
1062
+ for (let i = this.pub_from; i < max; i += 2) {
1063
+ res.push(this.data[i]);
1064
+ }
1065
+ return res;
1066
+ }
1067
+ track_on() {
1068
+ this.cursor = this.pub_from;
1069
+ const sub = $mol_wire_auto();
1070
+ $mol_wire_auto(this);
1071
+ return sub;
1072
+ }
1073
+ promote() {
1074
+ if (this.cursor >= this.pub_from) {
1075
+ $mol_fail(new Error('Circular subscription'));
1076
+ }
1077
+ super.promote();
1078
+ }
1079
+ track_next(pub) {
1080
+ if (this.cursor < 0)
1081
+ $mol_fail(new Error('Promo to non begun sub'));
1082
+ if (this.cursor < this.sub_from) {
1083
+ const next = this.data[this.cursor];
1084
+ if (pub === undefined)
1085
+ return next ?? null;
1086
+ if (next === pub) {
1087
+ this.cursor += 2;
1088
+ return next;
1089
+ }
1090
+ if (next) {
1091
+ if (this.sub_from < this.data.length) {
1092
+ this.peer_move(this.sub_from, this.data.length);
1093
+ }
1094
+ this.peer_move(this.cursor, this.sub_from);
1095
+ this.sub_from += 2;
1096
+ }
1097
+ }
1098
+ else {
1099
+ if (pub === undefined)
1100
+ return null;
1101
+ if (this.sub_from < this.data.length) {
1102
+ this.peer_move(this.sub_from, this.data.length);
1103
+ }
1104
+ this.sub_from += 2;
1105
+ }
1106
+ this.data[this.cursor] = pub;
1107
+ this.data[this.cursor + 1] = pub.sub_on(this, this.cursor);
1108
+ this.cursor += 2;
1109
+ return pub;
1110
+ }
1111
+ track_off(sub) {
1112
+ $mol_wire_auto(sub);
1113
+ if (this.cursor < 0) {
1114
+ $mol_fail(new Error('End of non begun sub'));
1115
+ }
1116
+ for (let cursor = this.pub_from; cursor < this.cursor; cursor += 2) {
1117
+ const pub = this.data[cursor];
1118
+ pub.refresh();
1119
+ }
1120
+ this.cursor = $mol_wire_cursor.fresh;
1121
+ }
1122
+ pub_off(sub_pos) {
1123
+ this.data[sub_pos] = undefined;
1124
+ this.data[sub_pos + 1] = undefined;
1125
+ }
1126
+ destructor() {
1127
+ for (let cursor = this.data.length - 2; cursor >= this.sub_from; cursor -= 2) {
1128
+ const sub = this.data[cursor];
1129
+ const pos = this.data[cursor + 1];
1130
+ sub.pub_off(pos);
1131
+ this.data.pop();
1132
+ this.data.pop();
1133
+ }
1134
+ this.cursor = this.pub_from;
1135
+ this.track_cut();
1136
+ this.cursor = $mol_wire_cursor.final;
1137
+ }
1138
+ track_cut() {
1139
+ if (this.cursor < this.pub_from) {
1140
+ $mol_fail(new Error('Cut of non begun sub'));
1141
+ }
1142
+ let tail = 0;
1143
+ for (let cursor = this.cursor; cursor < this.sub_from; cursor += 2) {
1144
+ const pub = this.data[cursor];
1145
+ pub?.sub_off(this.data[cursor + 1]);
1146
+ if (this.sub_from < this.data.length) {
1147
+ this.peer_move(this.data.length - 2, cursor);
1148
+ this.data.pop();
1149
+ this.data.pop();
1150
+ }
1151
+ else {
1152
+ ++tail;
1153
+ }
1154
+ }
1155
+ for (; tail; --tail) {
1156
+ this.data.pop();
1157
+ this.data.pop();
1158
+ }
1159
+ this.sub_from = this.cursor;
1160
+ }
1161
+ complete() { }
1162
+ complete_pubs() {
1163
+ const limit = this.cursor < 0 ? this.sub_from : this.cursor;
1164
+ for (let cursor = this.pub_from; cursor < limit; cursor += 2) {
1165
+ const pub = this.data[cursor];
1166
+ pub?.complete();
1167
+ }
1168
+ }
1169
+ absorb(quant = $mol_wire_cursor.stale) {
1170
+ if (this.cursor === $mol_wire_cursor.final)
1171
+ return;
1172
+ if (this.cursor >= quant)
1173
+ return;
1174
+ this.cursor = quant;
1175
+ this.emit($mol_wire_cursor.doubt);
1176
+ }
1177
+ [$mol_dev_format_head]() {
1178
+ return $mol_dev_format_native(this);
1179
+ }
1180
+ get pub_empty() {
1181
+ return this.sub_from === this.pub_from;
1182
+ }
1183
+ }
1184
+ $.$mol_wire_pub_sub = $mol_wire_pub_sub;
1185
+ })($ || ($ = {}));
1186
+ //mol/wire/pub/sub/sub.ts
1187
+ ;
1188
+ "use strict";
1189
+ var $;
1190
+ (function ($) {
1191
+ class $mol_after_timeout extends $mol_object2 {
1192
+ delay;
1193
+ task;
1194
+ id;
1195
+ constructor(delay, task) {
1196
+ super();
1197
+ this.delay = delay;
1198
+ this.task = task;
1199
+ this.id = setTimeout(task, delay);
1200
+ }
1201
+ destructor() {
1202
+ clearTimeout(this.id);
1203
+ }
1204
+ }
1205
+ $.$mol_after_timeout = $mol_after_timeout;
1206
+ })($ || ($ = {}));
1207
+ //mol/after/timeout/timeout.ts
1208
+ ;
1209
+ "use strict";
1210
+ var $;
1211
+ (function ($) {
1212
+ class $mol_after_frame extends $mol_after_timeout {
1213
+ task;
1214
+ constructor(task) {
1215
+ super(16, task);
1216
+ this.task = task;
1217
+ }
1218
+ }
1219
+ $.$mol_after_frame = $mol_after_frame;
1220
+ })($ || ($ = {}));
1221
+ //mol/after/frame/frame.node.ts
1222
+ ;
1223
+ "use strict";
1224
+ var $;
1225
+ (function ($) {
1226
+ const handled = new WeakSet();
1227
+ class $mol_wire_fiber extends $mol_wire_pub_sub {
1228
+ task;
1229
+ host;
1230
+ static warm = true;
1231
+ static planning = new Set();
1232
+ static reaping = new Set();
1233
+ static plan_task = null;
1234
+ static plan() {
1235
+ if (this.plan_task)
1236
+ return;
1237
+ this.plan_task = new $mol_after_frame(() => {
1238
+ try {
1239
+ this.sync();
1240
+ }
1241
+ finally {
1242
+ $mol_wire_fiber.plan_task = null;
1243
+ }
1244
+ });
1245
+ }
1246
+ static sync() {
1247
+ while (this.planning.size) {
1248
+ const fibers = this.planning;
1249
+ this.planning = new Set;
1250
+ for (const fiber of fibers) {
1251
+ fiber.refresh();
1252
+ }
1253
+ }
1254
+ while (this.reaping.size) {
1255
+ const fibers = this.reaping;
1256
+ this.reaping = new Set;
1257
+ for (const fiber of fibers) {
1258
+ if (!fiber.sub_empty)
1259
+ continue;
1260
+ fiber.destructor();
1261
+ }
1262
+ }
1263
+ }
1264
+ cache = undefined;
1265
+ get args() {
1266
+ return this.data.slice(0, this.pub_from);
1267
+ }
1268
+ result() {
1269
+ if (this.cache instanceof Promise)
1270
+ return;
1271
+ if (this.cache instanceof Error)
1272
+ return;
1273
+ return this.cache;
1274
+ }
1275
+ field() {
1276
+ return this.task.name + '()';
1277
+ }
1278
+ constructor(id, task, host, ...args) {
1279
+ super();
1280
+ this.task = task;
1281
+ this.host = host;
1282
+ this.data.push(...args);
1283
+ this.pub_from = this.sub_from = args.length;
1284
+ this[Symbol.toStringTag] = id;
1285
+ }
1286
+ plan() {
1287
+ $mol_wire_fiber.planning.add(this);
1288
+ $mol_wire_fiber.plan();
1289
+ }
1290
+ reap() {
1291
+ $mol_wire_fiber.reaping.add(this);
1292
+ $mol_wire_fiber.plan();
1293
+ }
1294
+ toString() {
1295
+ return this[Symbol.toStringTag];
1296
+ }
1297
+ toJSON() {
1298
+ return this[Symbol.toStringTag];
1299
+ }
1300
+ [$mol_dev_format_head]() {
1301
+ const cursor = {
1302
+ [-1]: '🔴',
1303
+ [-2]: '🟡',
1304
+ [-3]: '🟢',
1305
+ [-4]: '🔵',
1306
+ }[this.cursor] ?? this.cursor.toString();
1307
+ return $mol_dev_format_div({}, $mol_dev_format_native(this), $mol_dev_format_shade(cursor + ' '), $mol_dev_format_auto(this.cache));
1308
+ }
1309
+ get $() {
1310
+ return (this.host ?? this.task)['$'];
1311
+ }
1312
+ emit(quant = $mol_wire_cursor.stale) {
1313
+ if (this.sub_empty)
1314
+ this.plan();
1315
+ else
1316
+ super.emit(quant);
1317
+ }
1318
+ refresh() {
1319
+ if (this.cursor === $mol_wire_cursor.fresh)
1320
+ return;
1321
+ if (this.cursor === $mol_wire_cursor.final)
1322
+ return;
1323
+ check: if (this.cursor === $mol_wire_cursor.doubt) {
1324
+ for (let i = this.pub_from; i < this.sub_from; i += 2) {
1325
+ ;
1326
+ this.data[i]?.refresh();
1327
+ if (this.cursor !== $mol_wire_cursor.doubt)
1328
+ break check;
1329
+ }
1330
+ this.cursor = $mol_wire_cursor.fresh;
1331
+ return;
1332
+ }
1333
+ const bu = this.track_on();
1334
+ let result;
1335
+ try {
1336
+ switch (this.pub_from) {
1337
+ case 0:
1338
+ result = this.task.call(this.host);
1339
+ break;
1340
+ case 1:
1341
+ result = this.task.call(this.host, this.data[0]);
1342
+ break;
1343
+ default:
1344
+ result = this.task.call(this.host, ...this.data.slice(0, this.pub_from));
1345
+ break;
1346
+ }
1347
+ if (result instanceof Promise) {
1348
+ const put = (res) => {
1349
+ if (this.cache === result)
1350
+ this.put(res);
1351
+ return res;
1352
+ };
1353
+ result = Object.assign(result.then(put, put), {
1354
+ destructor: result['destructor']
1355
+ });
1356
+ handled.add(result);
1357
+ }
1358
+ }
1359
+ catch (error) {
1360
+ if (error instanceof Error || error instanceof Promise) {
1361
+ result = error;
1362
+ }
1363
+ else {
1364
+ result = new Error(String(error), { cause: error });
1365
+ }
1366
+ if (result instanceof Promise && !handled.has(result)) {
1367
+ result = Object.assign(result.finally(() => {
1368
+ if (this.cache === result)
1369
+ this.absorb();
1370
+ }), {
1371
+ destructor: result['destructor']
1372
+ });
1373
+ handled.add(result);
1374
+ }
1375
+ }
1376
+ if (!(result instanceof Promise)) {
1377
+ this.track_cut();
1378
+ }
1379
+ this.track_off(bu);
1380
+ this.put(result);
1381
+ }
1382
+ sync() {
1383
+ if (!$mol_wire_fiber.warm) {
1384
+ return this.result();
1385
+ }
1386
+ this.promote();
1387
+ this.refresh();
1388
+ if (this.cache instanceof Error) {
1389
+ return $mol_fail_hidden(this.cache);
1390
+ }
1391
+ if (this.cache instanceof Promise) {
1392
+ return $mol_fail_hidden(this.cache);
1393
+ }
1394
+ return this.cache;
1395
+ }
1396
+ async async() {
1397
+ while (true) {
1398
+ this.refresh();
1399
+ if (this.cache instanceof Error) {
1400
+ $mol_fail_hidden(this.cache);
1401
+ }
1402
+ if (!(this.cache instanceof Promise))
1403
+ return this.cache;
1404
+ await this.cache;
1405
+ if (this.cursor === $mol_wire_cursor.final) {
1406
+ await new Promise(() => { });
1407
+ }
1408
+ }
1409
+ }
1410
+ }
1411
+ $.$mol_wire_fiber = $mol_wire_fiber;
1412
+ })($ || ($ = {}));
1413
+ //mol/wire/fiber/fiber.ts
1414
+ ;
1415
+ "use strict";
1416
+ var $;
1417
+ (function ($) {
1418
+ function $mol_guid(length = 8, exists = () => false) {
1419
+ for (;;) {
1420
+ let id = Math.random().toString(36).substring(2, length + 2).toUpperCase();
1421
+ if (exists(id))
1422
+ continue;
1423
+ return id;
1424
+ }
1425
+ }
1426
+ $.$mol_guid = $mol_guid;
1427
+ })($ || ($ = {}));
1428
+ //mol/guid/guid.ts
1429
+ ;
1430
+ "use strict";
1431
+ var $;
1432
+ (function ($) {
1433
+ $.$mol_key_store = new WeakMap();
1434
+ function $mol_key(value) {
1435
+ if (!value)
1436
+ return JSON.stringify(value);
1437
+ if (typeof value !== 'object' && typeof value !== 'function')
1438
+ return JSON.stringify(value);
1439
+ return JSON.stringify(value, (field, value) => {
1440
+ if (!value)
1441
+ return value;
1442
+ if (typeof value !== 'object' && typeof value !== 'function')
1443
+ return value;
1444
+ if (Array.isArray(value))
1445
+ return value;
1446
+ const proto = Reflect.getPrototypeOf(value);
1447
+ if (!proto)
1448
+ return value;
1449
+ if (Reflect.getPrototypeOf(proto) === null)
1450
+ return value;
1451
+ if ('toJSON' in value)
1452
+ return value;
1453
+ if (value instanceof RegExp)
1454
+ return value.toString();
1455
+ let key = $.$mol_key_store.get(value);
1456
+ if (key)
1457
+ return key;
1458
+ key = $mol_guid();
1459
+ $.$mol_key_store.set(value, key);
1460
+ return key;
1461
+ });
1462
+ }
1463
+ $.$mol_key = $mol_key;
1464
+ })($ || ($ = {}));
1465
+ //mol/key/key.ts
1466
+ ;
1467
+ "use strict";
1468
+ var $;
1469
+ (function ($) {
1470
+ $.$mol_compare_deep_cache = new WeakMap();
1471
+ function $mol_compare_deep(left, right) {
1472
+ if (Object.is(left, right))
1473
+ return true;
1474
+ if (left === null)
1475
+ return false;
1476
+ if (right === null)
1477
+ return false;
1478
+ if (typeof left !== 'object')
1479
+ return false;
1480
+ if (typeof right !== 'object')
1481
+ return false;
1482
+ const left_proto = Reflect.getPrototypeOf(left);
1483
+ const right_proto = Reflect.getPrototypeOf(right);
1484
+ if (left_proto !== right_proto)
1485
+ return false;
1486
+ if (left instanceof Boolean)
1487
+ return Object.is(left.valueOf(), right['valueOf']());
1488
+ if (left instanceof Number)
1489
+ return Object.is(left.valueOf(), right['valueOf']());
1490
+ if (left instanceof String)
1491
+ return Object.is(left.valueOf(), right['valueOf']());
1492
+ if (left instanceof Date)
1493
+ return Object.is(left.valueOf(), right['valueOf']());
1494
+ if (left instanceof RegExp)
1495
+ return left.source === right['source'] && left.flags === right['flags'];
1496
+ let left_cache = $.$mol_compare_deep_cache.get(left);
1497
+ if (left_cache) {
1498
+ const right_cache = left_cache.get(right);
1499
+ if (typeof right_cache === 'boolean')
1500
+ return right_cache;
1501
+ }
1502
+ else {
1503
+ left_cache = new WeakMap([[right, true]]);
1504
+ $.$mol_compare_deep_cache.set(left, left_cache);
1505
+ }
1506
+ let result;
1507
+ try {
1508
+ if (left_proto && !Reflect.getPrototypeOf(left_proto))
1509
+ result = compare_pojo(left, right);
1510
+ else if (Array.isArray(left))
1511
+ result = compare_array(left, right);
1512
+ else if (left instanceof Set)
1513
+ result = compare_set(left, right);
1514
+ else if (left instanceof Map)
1515
+ result = compare_map(left, right);
1516
+ else if (left instanceof Error)
1517
+ result = left.stack === right.stack;
1518
+ else if (ArrayBuffer.isView(left))
1519
+ result = compare_buffer(left, right);
1520
+ else if (Symbol.toPrimitive in left)
1521
+ result = compare_primitive(left, right);
1522
+ else
1523
+ result = false;
1524
+ }
1525
+ finally {
1526
+ left_cache.set(right, result);
1527
+ }
1528
+ return result;
1529
+ }
1530
+ $.$mol_compare_deep = $mol_compare_deep;
1531
+ function compare_array(left, right) {
1532
+ const len = left.length;
1533
+ if (len !== right.length)
1534
+ return false;
1535
+ for (let i = 0; i < len; ++i) {
1536
+ if (!$mol_compare_deep(left[i], right[i]))
1537
+ return false;
1538
+ }
1539
+ return true;
1540
+ }
1541
+ function compare_buffer(left, right) {
1542
+ const len = left.byteLength;
1543
+ if (len !== right.byteLength)
1544
+ return false;
1545
+ for (let i = 0; i < len; ++i) {
1546
+ if (left[i] !== right[i])
1547
+ return false;
1548
+ }
1549
+ return true;
1550
+ }
1551
+ function compare_iterator(left, right, compare) {
1552
+ while (true) {
1553
+ const left_next = left.next();
1554
+ const right_next = right.next();
1555
+ if (left_next.done !== right_next.done)
1556
+ return false;
1557
+ if (left_next.done)
1558
+ break;
1559
+ if (!compare(left_next.value, right_next.value))
1560
+ return false;
1561
+ }
1562
+ return true;
1563
+ }
1564
+ function compare_set(left, right) {
1565
+ if (left.size !== right.size)
1566
+ return false;
1567
+ return compare_iterator(left.values(), right.values(), $mol_compare_deep);
1568
+ }
1569
+ function compare_map(left, right) {
1570
+ if (left.size !== right.size)
1571
+ return false;
1572
+ return compare_iterator(left.keys(), right.keys(), Object.is)
1573
+ && compare_iterator(left.values(), right.values(), $mol_compare_deep);
1574
+ }
1575
+ function compare_pojo(left, right) {
1576
+ const left_keys = Object.getOwnPropertyNames(left);
1577
+ const right_keys = Object.getOwnPropertyNames(right);
1578
+ if (left_keys.length !== right_keys.length)
1579
+ return false;
1580
+ for (let key of left_keys) {
1581
+ if (!$mol_compare_deep(left[key], Reflect.get(right, key)))
1582
+ return false;
1583
+ }
1584
+ return true;
1585
+ }
1586
+ function compare_primitive(left, right) {
1587
+ return Object.is(left[Symbol.toPrimitive]('default'), right[Symbol.toPrimitive]('default'));
1588
+ }
1589
+ })($ || ($ = {}));
1590
+ //mol/compare/deep/deep.ts
1591
+ ;
1592
+ "use strict";
1593
+ var $;
1594
+ (function ($) {
1595
+ class $mol_wire_task extends $mol_wire_fiber {
1596
+ static getter(task) {
1597
+ return function $mol_wire_task_get(host, args) {
1598
+ const existen = $mol_wire_auto()?.track_next();
1599
+ reuse: if (existen) {
1600
+ if (!(existen instanceof $mol_wire_task))
1601
+ break reuse;
1602
+ if (existen.host !== host)
1603
+ break reuse;
1604
+ if (existen.task !== task)
1605
+ break reuse;
1606
+ if (!$mol_compare_deep(existen.args, args))
1607
+ break reuse;
1608
+ return existen;
1609
+ }
1610
+ return new $mol_wire_task(`${host?.[Symbol.toStringTag] ?? host}.${task.name}(#)`, task, host, ...args);
1611
+ };
1612
+ }
1613
+ complete() {
1614
+ if (this.sub_empty)
1615
+ this.destructor();
1616
+ }
1617
+ put(next) {
1618
+ const prev = this.cache;
1619
+ this.cache = next;
1620
+ if (next instanceof Promise) {
1621
+ this.cursor = $mol_wire_cursor.fresh;
1622
+ if (next !== prev)
1623
+ this.emit();
1624
+ return next;
1625
+ }
1626
+ this.cursor = $mol_wire_cursor.final;
1627
+ if (this.sub_empty)
1628
+ this.destructor();
1629
+ else if (next !== prev)
1630
+ this.emit();
1631
+ return next;
1632
+ }
1633
+ }
1634
+ $.$mol_wire_task = $mol_wire_task;
1635
+ })($ || ($ = {}));
1636
+ //mol/wire/task/task.ts
1637
+ ;
1638
+ "use strict";
1639
+ var $;
1640
+ (function ($) {
1641
+ function $mol_wire_method(host, field, descr) {
1642
+ if (!descr)
1643
+ descr = Reflect.getOwnPropertyDescriptor(host, field);
1644
+ const orig = descr?.value ?? host[field];
1645
+ const sup = Reflect.getPrototypeOf(host);
1646
+ if (typeof sup[field] === 'function') {
1647
+ Object.defineProperty(orig, 'name', { value: sup[field].name });
1648
+ }
1649
+ const temp = $mol_wire_task.getter(orig);
1650
+ const value = function (...args) {
1651
+ const fiber = temp(this ?? null, args);
1652
+ return fiber.sync();
1653
+ };
1654
+ Object.defineProperty(value, 'name', { value: orig.name + ' ' });
1655
+ Object.assign(value, { orig });
1656
+ const descr2 = { ...descr, value };
1657
+ Reflect.defineProperty(host, field, descr2);
1658
+ return descr2;
1659
+ }
1660
+ $.$mol_wire_method = $mol_wire_method;
1661
+ })($ || ($ = {}));
1662
+ //mol/wire/method/method.ts
1663
+ ;
1664
+ "use strict";
1665
+ var $;
1666
+ (function ($) {
1667
+ class $mol_wire_atom extends $mol_wire_fiber {
1668
+ static getter(task, keys) {
1669
+ const field = task.name + '()';
1670
+ if (keys) {
1671
+ return function $mol_wire_atom_get(host, args) {
1672
+ let dict, key, fiber;
1673
+ key = `${host?.[Symbol.toStringTag] ?? host}.${task.name}(${args.map(v => $mol_key(v)).join(',')})`;
1674
+ dict = Object.getOwnPropertyDescriptor(host ?? task, field)?.value;
1675
+ if (dict) {
1676
+ const existen = dict.get(key);
1677
+ if (existen)
1678
+ return existen;
1679
+ }
1680
+ else {
1681
+ dict = (host ?? task)[field] = new Map();
1682
+ }
1683
+ fiber = new $mol_wire_atom(key, task, host, ...args);
1684
+ dict.set(key, fiber);
1685
+ return fiber;
1686
+ };
1687
+ }
1688
+ else {
1689
+ return function $mol_wire_atom_get(host, args) {
1690
+ const existen = Object.getOwnPropertyDescriptor(host ?? task, field)?.value;
1691
+ if (existen)
1692
+ return existen;
1693
+ const key = `${host?.[Symbol.toStringTag] ?? host}.${field}`;
1694
+ const fiber = new $mol_wire_atom(key, task, host, ...args);
1695
+ (host ?? task)[field] = fiber;
1696
+ return fiber;
1697
+ };
1698
+ }
1699
+ }
1700
+ recall(...args) {
1701
+ if (this.cursor > $mol_wire_cursor.fresh) {
1702
+ try {
1703
+ this.once();
1704
+ }
1705
+ catch (error) {
1706
+ if (error instanceof Promise)
1707
+ $mol_fail_hidden(error);
1708
+ }
1709
+ }
1710
+ return this.put(this.task.call(this.host, ...args));
1711
+ }
1712
+ once() {
1713
+ return this.sync();
1714
+ }
1715
+ destructor() {
1716
+ super.destructor();
1717
+ const prev = this.cache;
1718
+ if ($mol_owning_check(this, prev)) {
1719
+ prev.destructor();
1720
+ }
1721
+ if (this.pub_from === 0) {
1722
+ ;
1723
+ (this.host ?? this.task)[this.field()] = null;
1724
+ }
1725
+ else {
1726
+ ;
1727
+ (this.host ?? this.task)[this.field()].delete(this[Symbol.toStringTag]);
1728
+ }
1729
+ }
1730
+ put(next) {
1731
+ const prev = this.cache;
1732
+ if (next !== prev) {
1733
+ if ($mol_owning_check(this, prev)) {
1734
+ prev.destructor();
1735
+ }
1736
+ this.cache = next;
1737
+ if ($mol_owning_catch(this, next)) {
1738
+ try {
1739
+ next[Symbol.toStringTag] = this[Symbol.toStringTag];
1740
+ }
1741
+ catch { }
1742
+ }
1743
+ if (this.sub_from < this.data.length) {
1744
+ if (!$mol_compare_deep(prev, next)) {
1745
+ this.emit();
1746
+ }
1747
+ }
1748
+ }
1749
+ this.cursor = $mol_wire_cursor.fresh;
1750
+ if (next instanceof Promise)
1751
+ return next;
1752
+ this.complete_pubs();
1753
+ return next;
1754
+ }
1755
+ }
1756
+ __decorate([
1757
+ $mol_wire_method
1758
+ ], $mol_wire_atom.prototype, "recall", null);
1759
+ __decorate([
1760
+ $mol_wire_method
1761
+ ], $mol_wire_atom.prototype, "once", null);
1762
+ $.$mol_wire_atom = $mol_wire_atom;
1763
+ })($ || ($ = {}));
1764
+ //mol/wire/atom/atom.ts
1765
+ ;
1766
+ "use strict";
1767
+ var $;
1768
+ (function ($) {
1769
+ function $mol_wire_mem(keys) {
1770
+ const wrap = $mol_wire_mem_func(keys);
1771
+ return (host, field, descr) => {
1772
+ if (!descr)
1773
+ descr = Reflect.getOwnPropertyDescriptor(host, field);
1774
+ const orig = descr?.value ?? host[field];
1775
+ const sup = Reflect.getPrototypeOf(host);
1776
+ if (typeof sup[field] === 'function') {
1777
+ Object.defineProperty(orig, 'name', { value: sup[field].name });
1778
+ }
1779
+ const descr2 = {
1780
+ ...descr,
1781
+ value: wrap(orig)
1782
+ };
1783
+ Reflect.defineProperty(host, field, descr2);
1784
+ return descr2;
1785
+ };
1786
+ }
1787
+ $.$mol_wire_mem = $mol_wire_mem;
1788
+ function $mol_wire_mem_func(keys) {
1789
+ return (func) => {
1790
+ const persist = $mol_wire_atom.getter(func, keys);
1791
+ const wrapper = function (...args) {
1792
+ let atom = persist(this, args.slice(0, keys));
1793
+ if (args.length <= keys || args[keys] === undefined) {
1794
+ if (!$mol_wire_fiber.warm)
1795
+ return atom.sync();
1796
+ if ($mol_wire_auto() instanceof $mol_wire_task) {
1797
+ return atom.once();
1798
+ }
1799
+ else {
1800
+ return atom.sync();
1801
+ }
1802
+ }
1803
+ return atom.recall(...args);
1804
+ };
1805
+ Object.defineProperty(wrapper, 'name', { value: func.name + ' ' });
1806
+ Object.assign(wrapper, { orig: func });
1807
+ return wrapper;
1808
+ };
1809
+ }
1810
+ $.$mol_wire_mem_func = $mol_wire_mem_func;
1811
+ })($ || ($ = {}));
1812
+ //mol/wire/mem/mem.ts
1813
+ ;
1814
+ "use strict";
1815
+ var $;
1816
+ (function ($) {
1817
+ $.$mol_mem = $mol_wire_mem(0);
1818
+ $.$mol_mem_key = $mol_wire_mem(1);
1819
+ $.$mol_mem_key2 = $mol_wire_mem(2);
1820
+ $.$mol_mem_key3 = $mol_wire_mem(3);
1821
+ })($ || ($ = {}));
1822
+ //mol/mem/mem.ts
1823
+ ;
1824
+ "use strict";
1825
+ var $;
1826
+ (function ($) {
1827
+ class $mol_jsx_view extends $mol_object2 {
1828
+ static of(node) {
1829
+ return node[this];
1830
+ }
1831
+ attributes;
1832
+ ownerDocument;
1833
+ get childNodes() {
1834
+ return this._kids();
1835
+ }
1836
+ set childNodes(next) {
1837
+ this._kids(next);
1838
+ }
1839
+ _kids(next = []) { return next; }
1840
+ valueOf() {
1841
+ const prefix = $mol_jsx_prefix;
1842
+ const booked = $mol_jsx_booked;
1843
+ const document = $mol_jsx_document;
1844
+ try {
1845
+ $mol_jsx_prefix = this[Symbol.toStringTag];
1846
+ $mol_jsx_booked = new Set;
1847
+ $mol_jsx_document = this.ownerDocument;
1848
+ return this.render();
1849
+ }
1850
+ finally {
1851
+ $mol_jsx_prefix = prefix;
1852
+ $mol_jsx_booked = booked;
1853
+ $mol_jsx_document = document;
1854
+ }
1855
+ }
1856
+ render() {
1857
+ return $mol_fail(new Error(`render() isn't implemented`));
1858
+ }
1859
+ }
1860
+ __decorate([
1861
+ $mol_mem
1862
+ ], $mol_jsx_view.prototype, "_kids", null);
1863
+ __decorate([
1864
+ $mol_mem
1865
+ ], $mol_jsx_view.prototype, "valueOf", null);
1866
+ $.$mol_jsx_view = $mol_jsx_view;
1867
+ })($ || ($ = {}));
1868
+ //mol/jsx/view/view.tsx
1869
+ ;
1870
+ "use strict";
1871
+ var $;
1872
+ (function ($) {
1873
+ function $mol_test_complete() {
1874
+ process.exit(0);
1875
+ }
1876
+ $.$mol_test_complete = $mol_test_complete;
1877
+ })($ || ($ = {}));
1878
+ //mol/test/test.node.test.ts
1879
+ ;
1880
+ "use strict";
1881
+ var $;
1882
+ (function ($_1) {
1883
+ function $mol_test(set) {
1884
+ for (let name in set) {
1885
+ const code = set[name];
1886
+ const test = (typeof code === 'string') ? new Function('', code) : code;
1887
+ $_1.$mol_test_all.push(test);
1888
+ }
1889
+ $mol_test_schedule();
1890
+ }
1891
+ $_1.$mol_test = $mol_test;
1892
+ $_1.$mol_test_mocks = [];
1893
+ $_1.$mol_test_all = [];
1894
+ async function $mol_test_run() {
1895
+ for (var test of $_1.$mol_test_all) {
1896
+ let context = Object.create($$);
1897
+ for (let mock of $_1.$mol_test_mocks)
1898
+ await mock(context);
1899
+ const res = test(context);
1900
+ if (res instanceof Promise) {
1901
+ await new Promise((done, fail) => {
1902
+ res.then(done, fail);
1903
+ setTimeout(() => fail(new Error('Test timeout: ' + test.name)), 1000);
1904
+ });
1905
+ }
1906
+ }
1907
+ $$.$mol_log3_done({
1908
+ place: '$mol_test',
1909
+ message: 'All tests passed',
1910
+ count: $_1.$mol_test_all.length,
1911
+ });
1912
+ }
1913
+ $_1.$mol_test_run = $mol_test_run;
1914
+ let scheduled = false;
1915
+ function $mol_test_schedule() {
1916
+ if (scheduled)
1917
+ return;
1918
+ scheduled = true;
1919
+ setTimeout(async () => {
1920
+ scheduled = false;
1921
+ try {
1922
+ await $mol_test_run();
1923
+ }
1924
+ finally {
1925
+ $$.$mol_test_complete();
1926
+ }
1927
+ }, 0);
1928
+ }
1929
+ $_1.$mol_test_schedule = $mol_test_schedule;
1930
+ $_1.$mol_test_mocks.push(context => {
1931
+ let seed = 0;
1932
+ context.Math = Object.create(Math);
1933
+ context.Math.random = () => Math.sin(seed++);
1934
+ const forbidden = ['XMLHttpRequest', 'fetch'];
1935
+ for (let api of forbidden) {
1936
+ context[api] = new Proxy(function () { }, {
1937
+ get() {
1938
+ $mol_fail_hidden(new Error(`${api} is forbidden in tests`));
1939
+ },
1940
+ apply() {
1941
+ $mol_fail_hidden(new Error(`${api} is forbidden in tests`));
1942
+ },
1943
+ });
1944
+ }
1945
+ });
1946
+ $mol_test({
1947
+ 'mocked Math.random'($) {
1948
+ console.assert($.Math.random() === 0);
1949
+ console.assert($.Math.random() === Math.sin(1));
1950
+ },
1951
+ 'forbidden XMLHttpRequest'($) {
1952
+ try {
1953
+ console.assert(void new $.XMLHttpRequest);
1954
+ }
1955
+ catch (error) {
1956
+ console.assert(error.message === 'XMLHttpRequest is forbidden in tests');
1957
+ }
1958
+ },
1959
+ 'forbidden fetch'($) {
1960
+ try {
1961
+ console.assert(void $.fetch(''));
1962
+ }
1963
+ catch (error) {
1964
+ console.assert(error.message === 'fetch is forbidden in tests');
1965
+ }
1966
+ },
1967
+ });
1968
+ })($ || ($ = {}));
1969
+ //mol/test/test.test.ts
1970
+ ;
1971
+ "use strict";
1972
+ var $;
1973
+ (function ($) {
1974
+ function $mol_dom_serialize(node) {
1975
+ const serializer = new $mol_dom_context.XMLSerializer;
1976
+ return serializer.serializeToString(node);
1977
+ }
1978
+ $.$mol_dom_serialize = $mol_dom_serialize;
1979
+ })($ || ($ = {}));
1980
+ //mol/dom/serialize/serialize.ts
1981
+ ;
1982
+ "use strict";
1983
+ var $;
1984
+ (function ($) {
1985
+ $mol_test({
1986
+ 'must be false'() {
1987
+ $mol_assert_not(0);
1988
+ },
1989
+ 'must be true'() {
1990
+ $mol_assert_ok(1);
1991
+ },
1992
+ 'two must be equal'() {
1993
+ $mol_assert_equal(2, 2);
1994
+ },
1995
+ 'three must be equal'() {
1996
+ $mol_assert_equal(2, 2, 2);
1997
+ },
1998
+ 'two must be unique'() {
1999
+ $mol_assert_unique([3], [3]);
2000
+ },
2001
+ 'three must be unique'() {
2002
+ $mol_assert_unique([3], [3], [3]);
2003
+ },
2004
+ 'two must be alike'() {
2005
+ $mol_assert_like([3], [3]);
2006
+ },
2007
+ 'three must be alike'() {
2008
+ $mol_assert_like([3], [3], [3]);
2009
+ },
2010
+ });
2011
+ })($ || ($ = {}));
2012
+ //mol/assert/assert.test.ts
2013
+ ;
2014
+ "use strict";
2015
+ var $;
2016
+ (function ($) {
2017
+ function $mol_assert_ok(value) {
2018
+ if (value)
2019
+ return;
2020
+ $mol_fail(new Error(`${value} ≠ true`));
2021
+ }
2022
+ $.$mol_assert_ok = $mol_assert_ok;
2023
+ function $mol_assert_not(value) {
2024
+ if (!value)
2025
+ return;
2026
+ $mol_fail(new Error(`${value} ≠ false`));
2027
+ }
2028
+ $.$mol_assert_not = $mol_assert_not;
2029
+ function $mol_assert_fail(handler, ErrorRight) {
2030
+ const fail = $.$mol_fail;
2031
+ try {
2032
+ $.$mol_fail = $.$mol_fail_hidden;
2033
+ handler();
2034
+ }
2035
+ catch (error) {
2036
+ if (!ErrorRight)
2037
+ return error;
2038
+ $.$mol_fail = fail;
2039
+ if (typeof ErrorRight === 'string') {
2040
+ $mol_assert_equal(error.message, ErrorRight);
2041
+ }
2042
+ else {
2043
+ $mol_assert_ok(error instanceof ErrorRight);
2044
+ }
2045
+ return error;
2046
+ }
2047
+ finally {
2048
+ $.$mol_fail = fail;
2049
+ }
2050
+ $mol_fail(new Error('Not failed'));
2051
+ }
2052
+ $.$mol_assert_fail = $mol_assert_fail;
2053
+ function $mol_assert_equal(...args) {
2054
+ for (let i = 0; i < args.length; ++i) {
2055
+ for (let j = 0; j < args.length; ++j) {
2056
+ if (i === j)
2057
+ continue;
2058
+ if (Number.isNaN(args[i]) && Number.isNaN(args[j]))
2059
+ continue;
2060
+ if (args[i] !== args[j])
2061
+ $mol_fail(new Error(`Not equal (${i + 1}:${j + 1})\n${args[i]}\n${args[j]}`));
2062
+ }
2063
+ }
2064
+ }
2065
+ $.$mol_assert_equal = $mol_assert_equal;
2066
+ function $mol_assert_unique(...args) {
2067
+ for (let i = 0; i < args.length; ++i) {
2068
+ for (let j = 0; j < args.length; ++j) {
2069
+ if (i === j)
2070
+ continue;
2071
+ if (args[i] === args[j] || (Number.isNaN(args[i]) && Number.isNaN(args[j]))) {
2072
+ $mol_fail(new Error(`args[${i}] = args[${j}] = ${args[i]}`));
2073
+ }
2074
+ }
2075
+ }
2076
+ }
2077
+ $.$mol_assert_unique = $mol_assert_unique;
2078
+ function $mol_assert_like(head, ...tail) {
2079
+ for (let [index, value] of Object.entries(tail)) {
2080
+ if (!$mol_compare_deep(value, head)) {
2081
+ const print = (val) => {
2082
+ if (!val)
2083
+ return val;
2084
+ if (typeof val !== 'object')
2085
+ return val;
2086
+ if ('outerHTML' in val)
2087
+ return val.outerHTML;
2088
+ try {
2089
+ return JSON.stringify(val);
2090
+ }
2091
+ catch (error) {
2092
+ console.error(error);
2093
+ return val;
2094
+ }
2095
+ };
2096
+ return $mol_fail(new Error(`Not like (1:${+index + 2})\n${print(head)}\n---\n${print(value)}`));
2097
+ }
2098
+ }
2099
+ }
2100
+ $.$mol_assert_like = $mol_assert_like;
2101
+ function $mol_assert_dom(left, right) {
2102
+ $mol_assert_equal($mol_dom_serialize(left), $mol_dom_serialize(right));
2103
+ }
2104
+ $.$mol_assert_dom = $mol_assert_dom;
2105
+ })($ || ($ = {}));
2106
+ //mol/assert/assert.ts
2107
+ ;
2108
+ "use strict";
2109
+ //mol/type/error/error.ts
2110
+ ;
2111
+ "use strict";
2112
+ //mol/type/assert/assert.test.ts
2113
+ ;
2114
+ "use strict";
2115
+ //mol/type/assert/assert.ts
2116
+ ;
2117
+ "use strict";
2118
+ //mol/type/equals/equals.test.ts
2119
+ ;
2120
+ "use strict";
2121
+ //mol/type/equals/equals.ts
2122
+ ;
2123
+ "use strict";
2124
+ //mol/type/partial/deep/deep.test.ts
2125
+ ;
2126
+ "use strict";
2127
+ var $;
2128
+ (function ($_1) {
2129
+ $mol_test_mocks.push($ => {
2130
+ $.$mol_log3_come = () => { };
2131
+ $.$mol_log3_done = () => { };
2132
+ $.$mol_log3_fail = () => { };
2133
+ $.$mol_log3_warn = () => { };
2134
+ $.$mol_log3_rise = () => { };
2135
+ $.$mol_log3_area = () => () => { };
2136
+ });
2137
+ })($ || ($ = {}));
2138
+ //mol/log3/log3.test.ts
2139
+ ;
2140
+ "use strict";
2141
+ var $;
2142
+ (function ($) {
2143
+ $mol_test({
2144
+ 'get'() {
2145
+ const proxy = $mol_delegate({}, () => ({ foo: 777 }));
2146
+ $mol_assert_equal(proxy.foo, 777);
2147
+ },
2148
+ 'has'() {
2149
+ const proxy = $mol_delegate({}, () => ({ foo: 777 }));
2150
+ $mol_assert_equal('foo' in proxy, true);
2151
+ },
2152
+ 'set'() {
2153
+ const target = { foo: 777 };
2154
+ const proxy = $mol_delegate({}, () => target);
2155
+ proxy.foo = 123;
2156
+ $mol_assert_equal(target.foo, 123);
2157
+ },
2158
+ 'getOwnPropertyDescriptor'() {
2159
+ const proxy = $mol_delegate({}, () => ({ foo: 777 }));
2160
+ $mol_assert_like(Object.getOwnPropertyDescriptor(proxy, 'foo'), {
2161
+ value: 777,
2162
+ writable: true,
2163
+ enumerable: true,
2164
+ configurable: true,
2165
+ });
2166
+ },
2167
+ 'ownKeys'() {
2168
+ const proxy = $mol_delegate({}, () => ({ foo: 777, [Symbol.toStringTag]: 'bar' }));
2169
+ $mol_assert_like(Reflect.ownKeys(proxy), ['foo', Symbol.toStringTag]);
2170
+ },
2171
+ 'getPrototypeOf'() {
2172
+ class Foo {
2173
+ }
2174
+ const proxy = $mol_delegate({}, () => new Foo);
2175
+ $mol_assert_equal(Object.getPrototypeOf(proxy), Foo.prototype);
2176
+ },
2177
+ 'setPrototypeOf'() {
2178
+ class Foo {
2179
+ }
2180
+ const target = {};
2181
+ const proxy = $mol_delegate({}, () => target);
2182
+ Object.setPrototypeOf(proxy, Foo.prototype);
2183
+ $mol_assert_equal(Object.getPrototypeOf(target), Foo.prototype);
2184
+ },
2185
+ 'instanceof'() {
2186
+ class Foo {
2187
+ }
2188
+ const proxy = $mol_delegate({}, () => new Foo);
2189
+ $mol_assert_ok(proxy instanceof Foo);
2190
+ $mol_assert_ok(proxy instanceof $mol_delegate);
2191
+ },
2192
+ 'autobind'() {
2193
+ class Foo {
2194
+ }
2195
+ const proxy = $mol_delegate({}, () => new Foo);
2196
+ $mol_assert_ok(proxy instanceof Foo);
2197
+ $mol_assert_ok(proxy instanceof $mol_delegate);
2198
+ },
2199
+ });
2200
+ })($ || ($ = {}));
2201
+ //mol/delegate/delegate.test.ts
2202
+ ;
2203
+ "use strict";
2204
+ //mol/type/writable/writable.test.ts
2205
+ ;
2206
+ "use strict";
2207
+ var $;
2208
+ (function ($_1) {
2209
+ $mol_test({
2210
+ 'tree parsing'() {
2211
+ $mol_assert_equal($mol_tree.fromString("foo\nbar\n").sub.length, 2);
2212
+ $mol_assert_equal($mol_tree.fromString("foo\nbar\n").sub[1].type, "bar");
2213
+ $mol_assert_equal($mol_tree.fromString("foo\n\n\n").sub.length, 1);
2214
+ $mol_assert_equal($mol_tree.fromString("=foo\n\\bar\n").sub.length, 2);
2215
+ $mol_assert_equal($mol_tree.fromString("=foo\n\\bar\n").sub[1].data, "bar");
2216
+ $mol_assert_equal($mol_tree.fromString("foo bar \\pol").sub[0].sub[0].sub[0].data, "pol");
2217
+ $mol_assert_equal($mol_tree.fromString("foo bar\n\t\\pol\n\t\\men").sub[0].sub[0].sub[1].data, "men");
2218
+ $mol_assert_equal($mol_tree.fromString('foo bar \\text\n').toString(), 'foo bar \\text\n');
2219
+ },
2220
+ 'inserting'() {
2221
+ $mol_assert_equal($mol_tree.fromString('a b c d').insert(new $mol_tree, 'a', 'b', 'c').toString(), 'a b \\\n');
2222
+ $mol_assert_equal($mol_tree.fromString('a b').insert(new $mol_tree, 'a', 'b', 'c', 'd').toString(), 'a b c \\\n');
2223
+ $mol_assert_equal($mol_tree.fromString('a b c d').insert(new $mol_tree, 0, 0, 0).toString(), 'a b \\\n');
2224
+ $mol_assert_equal($mol_tree.fromString('a b').insert(new $mol_tree, 0, 0, 0, 0).toString(), 'a b \\\n\t\\\n');
2225
+ $mol_assert_equal($mol_tree.fromString('a b c d').insert(new $mol_tree, null, null, null).toString(), 'a b \\\n');
2226
+ $mol_assert_equal($mol_tree.fromString('a b').insert(new $mol_tree, null, null, null, null).toString(), 'a b \\\n\t\\\n');
2227
+ },
2228
+ 'fromJSON'() {
2229
+ $mol_assert_equal($mol_tree.fromJSON([]).toString(), '/\n');
2230
+ $mol_assert_equal($mol_tree.fromJSON([false, true]).toString(), '/\n\tfalse\n\ttrue\n');
2231
+ $mol_assert_equal($mol_tree.fromJSON([0, 1, 2.3]).toString(), '/\n\t0\n\t1\n\t2.3\n');
2232
+ $mol_assert_equal($mol_tree.fromJSON(['', 'foo', 'bar\nbaz']).toString(), '/\n\t\\\n\t\\foo\n\t\\\n\t\t\\bar\n\t\t\\baz\n');
2233
+ $mol_assert_equal($mol_tree.fromJSON({ 'foo': false, 'bar\nbaz': 'lol' }).toString(), '*\n\tfoo false\n\t\\\n\t\t\\bar\n\t\t\\baz\n\t\t\\lol\n');
2234
+ },
2235
+ 'toJSON'() {
2236
+ $mol_assert_equal(JSON.stringify($mol_tree.fromString('/\n').sub[0]), '[]');
2237
+ $mol_assert_equal(JSON.stringify($mol_tree.fromString('/\n\tfalse\n\ttrue\n').sub[0]), '[false,true]');
2238
+ $mol_assert_equal(JSON.stringify($mol_tree.fromString('/\n\t0\n\t1\n\t2.3\n').sub[0]), '[0,1,2.3]');
2239
+ $mol_assert_equal(JSON.stringify($mol_tree.fromString('/\n\t\\\n\t\\foo\n\t\\\n\t\t\\bar\n\t\t\\baz\n').sub[0]), '["","foo","bar\\nbaz"]');
2240
+ $mol_assert_equal(JSON.stringify($mol_tree.fromString('*\n\tfoo false\n\t\\\n\t\t\\bar\n\t\t\\baz\n\t\t\\lol\n').sub[0]), '{"foo":false,"bar\\nbaz":"lol"}');
2241
+ },
2242
+ 'hack'() {
2243
+ const res = $mol_tree.fromString(`foo bar xxx`).hack({
2244
+ '': (tree, context) => [tree.hack(context)],
2245
+ 'bar': (tree, context) => [tree.hack(context).clone({ type: '777' })],
2246
+ });
2247
+ $mol_assert_equal(res.toString(), new $mol_tree({ type: 'foo 777 xxx' }).toString());
2248
+ },
2249
+ 'errors handling'($) {
2250
+ const errors = [];
2251
+ class Tree extends $mol_tree {
2252
+ static $ = $.$mol_ambient({
2253
+ $mol_fail: error => errors.push(error.message)
2254
+ });
2255
+ }
2256
+ Tree.fromString(`
2257
+ \t \tfoo
2258
+ bar \\data
2259
+ `, 'test');
2260
+ $mol_assert_like(errors, ['Syntax error at test:2\n \tfoo']);
2261
+ },
2262
+ });
2263
+ })($ || ($ = {}));
2264
+ //mol/tree/tree.test.ts
2265
+ ;
2266
+ "use strict";
2267
+ var $;
2268
+ (function ($) {
2269
+ $mol_test({
2270
+ 'Make empty div'() {
2271
+ $mol_assert_equal(($mol_jsx("div", null)).outerHTML, '<div></div>');
2272
+ },
2273
+ 'Define native field'() {
2274
+ const dom = $mol_jsx("input", { value: '123' });
2275
+ $mol_assert_equal(dom.outerHTML, '<input value="123">');
2276
+ $mol_assert_equal(dom.value, '123');
2277
+ },
2278
+ 'Define classes'() {
2279
+ const dom = $mol_jsx("div", { class: 'foo bar' });
2280
+ $mol_assert_equal(dom.outerHTML, '<div class="foo bar"></div>');
2281
+ },
2282
+ 'Define styles'() {
2283
+ const dom = $mol_jsx("div", { style: { color: 'red' } });
2284
+ $mol_assert_equal(dom.outerHTML, '<div style="color: red;"></div>');
2285
+ },
2286
+ 'Define dataset'() {
2287
+ const dom = $mol_jsx("div", { dataset: { foo: 'bar' } });
2288
+ $mol_assert_equal(dom.outerHTML, '<div data-foo="bar"></div>');
2289
+ },
2290
+ 'Define attributes'() {
2291
+ const dom = $mol_jsx("div", { lang: "ru", hidden: true });
2292
+ $mol_assert_equal(dom.outerHTML, '<div lang="ru" hidden=""></div>');
2293
+ },
2294
+ 'Define child nodes'() {
2295
+ const dom = $mol_jsx("div", null,
2296
+ "hello",
2297
+ $mol_jsx("strong", null, "world"),
2298
+ "!");
2299
+ $mol_assert_equal(dom.outerHTML, '<div>hello<strong>world</strong>!</div>');
2300
+ },
2301
+ 'Function as component'() {
2302
+ const Button = (props, target) => {
2303
+ return $mol_jsx("button", { title: props.hint }, target());
2304
+ };
2305
+ const dom = $mol_jsx(Button, { id: "/foo", hint: "click me" }, () => 'hey!');
2306
+ $mol_assert_equal(dom.outerHTML, '<button title="click me" id="/foo">hey!</button>');
2307
+ },
2308
+ 'Nested guid generation'() {
2309
+ const Foo = () => {
2310
+ return $mol_jsx("div", null,
2311
+ $mol_jsx(Bar, { id: "/bar" },
2312
+ $mol_jsx("img", { id: "/icon" })));
2313
+ };
2314
+ const Bar = (props, icon) => {
2315
+ return $mol_jsx("span", null, icon);
2316
+ };
2317
+ const dom = $mol_jsx(Foo, { id: "/foo" });
2318
+ $mol_assert_equal(dom.outerHTML, '<div id="/foo"><span id="/foo/bar"><img id="/foo/icon"></span></div>');
2319
+ },
2320
+ 'Fail on non unique ids'() {
2321
+ const App = () => {
2322
+ return $mol_jsx("div", null,
2323
+ $mol_jsx("span", { id: "/bar" }),
2324
+ $mol_jsx("span", { id: "/bar" }));
2325
+ };
2326
+ $mol_assert_fail(() => $mol_jsx(App, { id: "/foo" }), 'JSX already has tag with id "/bar"');
2327
+ },
2328
+ });
2329
+ })($ || ($ = {}));
2330
+ //mol/jsx/jsx.test.tsx
2331
+ ;
2332
+ "use strict";
2333
+ var $;
2334
+ (function ($) {
2335
+ function $mol_dom_parse(text, type = 'application/xhtml+xml') {
2336
+ const parser = new $mol_dom_context.DOMParser();
2337
+ const doc = parser.parseFromString(text, type);
2338
+ const error = doc.getElementsByTagName('parsererror');
2339
+ if (error.length)
2340
+ throw new Error(error[0].textContent);
2341
+ return doc;
2342
+ }
2343
+ $.$mol_dom_parse = $mol_dom_parse;
2344
+ })($ || ($ = {}));
2345
+ //mol/dom/parse/parse.ts
2346
+ ;
2347
+ "use strict";
2348
+ var $;
2349
+ (function ($) {
2350
+ $mol_test({
2351
+ 'Attach to document'() {
2352
+ const doc = $mol_dom_parse('<html><body id="/foo"></body></html>');
2353
+ $mol_jsx_attach(doc, () => $mol_jsx("body", { id: "/foo" }, "bar"));
2354
+ $mol_assert_equal(doc.documentElement.outerHTML, '<html><body id="/foo">bar</body></html>');
2355
+ },
2356
+ });
2357
+ })($ || ($ = {}));
2358
+ //mol/jsx/attach/attach.test.tsx
2359
+ ;
2360
+ "use strict";
2361
+ var $;
2362
+ (function ($) {
2363
+ $.$mol_after_mock_queue = [];
2364
+ function $mol_after_mock_warp() {
2365
+ const queue = $.$mol_after_mock_queue.splice(0);
2366
+ for (const task of queue)
2367
+ task();
2368
+ }
2369
+ $.$mol_after_mock_warp = $mol_after_mock_warp;
2370
+ class $mol_after_mock_commmon extends $mol_object2 {
2371
+ task;
2372
+ promise = Promise.resolve();
2373
+ cancelled = false;
2374
+ id;
2375
+ constructor(task) {
2376
+ super();
2377
+ this.task = task;
2378
+ $.$mol_after_mock_queue.push(task);
2379
+ }
2380
+ destructor() {
2381
+ const index = $.$mol_after_mock_queue.indexOf(this.task);
2382
+ if (index >= 0)
2383
+ $.$mol_after_mock_queue.splice(index, 1);
2384
+ }
2385
+ }
2386
+ $.$mol_after_mock_commmon = $mol_after_mock_commmon;
2387
+ class $mol_after_mock_timeout extends $mol_after_mock_commmon {
2388
+ delay;
2389
+ constructor(delay, task) {
2390
+ super(task);
2391
+ this.delay = delay;
2392
+ }
2393
+ }
2394
+ $.$mol_after_mock_timeout = $mol_after_mock_timeout;
2395
+ })($ || ($ = {}));
2396
+ //mol/after/mock/mock.test.ts
2397
+ ;
2398
+ "use strict";
2399
+ var $;
2400
+ (function ($_1) {
2401
+ $mol_test({
2402
+ async 'Latest Calls Wins on Concurrency'($) {
2403
+ class NameLogger extends $mol_object2 {
2404
+ static $ = $;
2405
+ static first = [];
2406
+ static last = [];
2407
+ static send(next) {
2408
+ $mol_wire_sync(this.first).push(next);
2409
+ this.$.$mol_wait_timeout(0);
2410
+ this.last.push(next);
2411
+ }
2412
+ }
2413
+ const name = $mol_wire_async(NameLogger).send;
2414
+ name('john');
2415
+ const promise = name('jin');
2416
+ $.$mol_after_mock_warp();
2417
+ await promise;
2418
+ $mol_assert_like(NameLogger.first, ['john', 'jin']);
2419
+ $mol_assert_like(NameLogger.last, ['jin']);
2420
+ },
2421
+ });
2422
+ })($ || ($ = {}));
2423
+ //mol/wire/async/async.test.ts
2424
+ ;
2425
+ "use strict";
2426
+ var $;
2427
+ (function ($) {
2428
+ function $mol_wire_async(obj) {
2429
+ return new Proxy(obj, {
2430
+ get(obj, field) {
2431
+ const val = obj[field];
2432
+ if (typeof val !== 'function')
2433
+ return val;
2434
+ let fiber;
2435
+ const temp = $mol_wire_task.getter(val);
2436
+ return function $mol_wire_async(...args) {
2437
+ fiber?.destructor();
2438
+ fiber = temp(obj, args);
2439
+ return fiber.async();
2440
+ };
2441
+ }
2442
+ });
2443
+ }
2444
+ $.$mol_wire_async = $mol_wire_async;
2445
+ })($ || ($ = {}));
2446
+ //mol/wire/async/async.ts
2447
+ ;
2448
+ "use strict";
2449
+ var $;
2450
+ (function ($_1) {
2451
+ $mol_test({
2452
+ 'Collect deps'() {
2453
+ const pub1 = new $mol_wire_pub;
2454
+ const pub2 = new $mol_wire_pub;
2455
+ const sub = new $mol_wire_pub_sub;
2456
+ const bu1 = sub.track_on();
2457
+ try {
2458
+ pub1.promote();
2459
+ pub2.promote();
2460
+ pub2.promote();
2461
+ }
2462
+ finally {
2463
+ sub.track_cut();
2464
+ sub.track_off(bu1);
2465
+ }
2466
+ pub1.emit();
2467
+ pub2.emit();
2468
+ $mol_assert_like(sub.pub_list, [pub1, pub2, pub2]);
2469
+ const bu2 = sub.track_on();
2470
+ try {
2471
+ pub1.promote();
2472
+ pub1.promote();
2473
+ pub2.promote();
2474
+ }
2475
+ finally {
2476
+ sub.track_cut();
2477
+ sub.track_off(bu2);
2478
+ }
2479
+ pub1.emit();
2480
+ pub2.emit();
2481
+ $mol_assert_like(sub.pub_list, [pub1, pub1, pub2]);
2482
+ },
2483
+ 'cyclic detection'($) {
2484
+ const sub1 = new $mol_wire_pub_sub;
2485
+ const sub2 = new $mol_wire_pub_sub;
2486
+ const bu1 = sub1.track_on();
2487
+ try {
2488
+ const bu2 = sub2.track_on();
2489
+ try {
2490
+ $mol_assert_fail(() => sub1.promote(), 'Circular subscription');
2491
+ }
2492
+ finally {
2493
+ sub2.track_cut();
2494
+ sub2.track_off(bu2);
2495
+ }
2496
+ }
2497
+ finally {
2498
+ sub1.track_cut();
2499
+ sub1.track_off(bu1);
2500
+ }
2501
+ },
2502
+ });
2503
+ })($ || ($ = {}));
2504
+ //mol/wire/pub/sub/sub.test.ts
2505
+ ;
2506
+ "use strict";
2507
+ var $;
2508
+ (function ($_1) {
2509
+ $mol_test_mocks.push($ => {
2510
+ $.$mol_after_timeout = $mol_after_mock_timeout;
2511
+ });
2512
+ })($ || ($ = {}));
2513
+ //mol/after/timeout/timeout.test.ts
2514
+ ;
2515
+ "use strict";
2516
+ var $;
2517
+ (function ($_1) {
2518
+ $mol_test_mocks.push($ => {
2519
+ $.$mol_after_frame = $mol_after_mock_commmon;
2520
+ });
2521
+ })($ || ($ = {}));
2522
+ //mol/after/frame/frame.test.ts
2523
+ ;
2524
+ "use strict";
2525
+ var $;
2526
+ (function ($) {
2527
+ $mol_test({
2528
+ 'Sync execution'() {
2529
+ class Sync extends $mol_object2 {
2530
+ static calc(a, b) {
2531
+ return a + b;
2532
+ }
2533
+ }
2534
+ __decorate([
2535
+ $mol_wire_method
2536
+ ], Sync, "calc", null);
2537
+ $mol_assert_equal(Sync.calc(1, 2), 3);
2538
+ },
2539
+ async 'async <=> sync'() {
2540
+ class SyncAsync extends $mol_object2 {
2541
+ static async val(a) {
2542
+ return a;
2543
+ }
2544
+ static sum(a, b) {
2545
+ const syn = $mol_wire_sync(this);
2546
+ return syn.val(a) + syn.val(b);
2547
+ }
2548
+ static async calc(a, b) {
2549
+ return 5 + await $mol_wire_async(this).sum(a, b);
2550
+ }
2551
+ }
2552
+ $mol_assert_equal(await SyncAsync.calc(1, 2), 8);
2553
+ },
2554
+ async 'Idempotence control'() {
2555
+ class Idempotence extends $mol_object2 {
2556
+ static logs_idemp = 0;
2557
+ static logs_unidemp = 0;
2558
+ static log_idemp() {
2559
+ this.logs_idemp += 1;
2560
+ }
2561
+ static log_unidemp() {
2562
+ this.logs_unidemp += 1;
2563
+ }
2564
+ static async val(a) {
2565
+ return a;
2566
+ }
2567
+ static sum(a, b) {
2568
+ this.log_idemp();
2569
+ this.log_unidemp();
2570
+ const syn = $mol_wire_sync(this);
2571
+ return syn.val(a) + syn.val(b);
2572
+ }
2573
+ static async calc(a, b) {
2574
+ return 5 + await $mol_wire_async(this).sum(a, b);
2575
+ }
2576
+ }
2577
+ __decorate([
2578
+ $mol_wire_method
2579
+ ], Idempotence, "log_idemp", null);
2580
+ $mol_assert_equal(await Idempotence.calc(1, 2), 8);
2581
+ $mol_assert_equal(Idempotence.logs_idemp, 1);
2582
+ $mol_assert_equal(Idempotence.logs_unidemp, 3);
2583
+ },
2584
+ async 'Error handling'() {
2585
+ class Handle extends $mol_object2 {
2586
+ static async sum(a, b) {
2587
+ $mol_fail(new Error('test error ' + (a + b)));
2588
+ }
2589
+ static check() {
2590
+ try {
2591
+ return $mol_wire_sync(Handle).sum(1, 2);
2592
+ }
2593
+ catch (error) {
2594
+ if (error instanceof Promise)
2595
+ $mol_fail_hidden(error);
2596
+ $mol_assert_equal(error.message, 'test error 3');
2597
+ }
2598
+ }
2599
+ }
2600
+ await $mol_wire_async(Handle).check();
2601
+ },
2602
+ });
2603
+ })($ || ($ = {}));
2604
+ //mol/wire/fiber/fiber.test.ts
2605
+ ;
2606
+ "use strict";
2607
+ var $;
2608
+ (function ($) {
2609
+ $mol_test({
2610
+ 'nulls & undefineds'() {
2611
+ $mol_assert_ok($mol_compare_deep(null, null));
2612
+ $mol_assert_ok($mol_compare_deep(undefined, undefined));
2613
+ $mol_assert_not($mol_compare_deep(undefined, null));
2614
+ $mol_assert_not($mol_compare_deep({}, null));
2615
+ },
2616
+ 'number'() {
2617
+ $mol_assert_ok($mol_compare_deep(1, 1));
2618
+ $mol_assert_ok($mol_compare_deep(Number.NaN, Number.NaN));
2619
+ $mol_assert_not($mol_compare_deep(1, 2));
2620
+ $mol_assert_ok($mol_compare_deep(Object(1), Object(1)));
2621
+ $mol_assert_not($mol_compare_deep(Object(1), Object(2)));
2622
+ },
2623
+ 'POJO'() {
2624
+ $mol_assert_ok($mol_compare_deep({}, {}));
2625
+ $mol_assert_not($mol_compare_deep({ a: 1 }, { b: 2 }));
2626
+ $mol_assert_not($mol_compare_deep({ a: 1 }, { a: 2 }));
2627
+ $mol_assert_not($mol_compare_deep({}, { a: undefined }));
2628
+ $mol_assert_ok($mol_compare_deep({ a: 1, b: 2 }, { b: 2, a: 1 }));
2629
+ $mol_assert_ok($mol_compare_deep({ a: { b: 1 } }, { a: { b: 1 } }));
2630
+ },
2631
+ 'Array'() {
2632
+ $mol_assert_ok($mol_compare_deep([], []));
2633
+ $mol_assert_ok($mol_compare_deep([1, [2]], [1, [2]]));
2634
+ $mol_assert_not($mol_compare_deep([1, 2], [1, 3]));
2635
+ $mol_assert_not($mol_compare_deep([1, 2,], [1, 3, undefined]));
2636
+ },
2637
+ 'Non POJO are different'() {
2638
+ class Thing extends Object {
2639
+ }
2640
+ $mol_assert_not($mol_compare_deep(new Thing, new Thing));
2641
+ $mol_assert_not($mol_compare_deep(() => 1, () => 1));
2642
+ $mol_assert_not($mol_compare_deep(new RangeError('Test error'), new RangeError('Test error')));
2643
+ },
2644
+ 'same POJOs with cyclic reference'() {
2645
+ const a = { foo: {} };
2646
+ a['self'] = a;
2647
+ const b = { foo: {} };
2648
+ b['self'] = b;
2649
+ $mol_assert_ok($mol_compare_deep(a, b));
2650
+ },
2651
+ 'Date'() {
2652
+ $mol_assert_ok($mol_compare_deep(new Date(12345), new Date(12345)));
2653
+ $mol_assert_not($mol_compare_deep(new Date(12345), new Date(12346)));
2654
+ },
2655
+ 'RegExp'() {
2656
+ $mol_assert_ok($mol_compare_deep(/\x22/mig, /\x22/mig));
2657
+ $mol_assert_not($mol_compare_deep(/\x22/mig, /\x21/mig));
2658
+ $mol_assert_not($mol_compare_deep(/\x22/mig, /\x22/mg));
2659
+ },
2660
+ 'Error'() {
2661
+ $mol_assert_not($mol_compare_deep(new Error('xxx'), new Error('xxx')));
2662
+ const fail = (message) => new Error(message);
2663
+ $mol_assert_ok($mol_compare_deep(...['xxx', 'xxx'].map(msg => new Error(msg))));
2664
+ $mol_assert_not($mol_compare_deep(...['xxx', 'yyy'].map(msg => new Error(msg))));
2665
+ },
2666
+ 'Map'() {
2667
+ $mol_assert_ok($mol_compare_deep(new Map, new Map));
2668
+ $mol_assert_ok($mol_compare_deep(new Map([[1, [2]]]), new Map([[1, [2]]])));
2669
+ $mol_assert_not($mol_compare_deep(new Map([[1, 2]]), new Map([[1, 3]])));
2670
+ $mol_assert_not($mol_compare_deep(new Map([[[1], 2]]), new Map([[[1], 2]])));
2671
+ },
2672
+ 'Set'() {
2673
+ $mol_assert_ok($mol_compare_deep(new Set, new Set));
2674
+ $mol_assert_ok($mol_compare_deep(new Set([1, [2]]), new Set([1, [2]])));
2675
+ $mol_assert_not($mol_compare_deep(new Set([1]), new Set([2])));
2676
+ },
2677
+ 'Uint8Array'() {
2678
+ $mol_assert_ok($mol_compare_deep(new Uint8Array, new Uint8Array));
2679
+ $mol_assert_ok($mol_compare_deep(new Uint8Array([0]), new Uint8Array([0])));
2680
+ $mol_assert_not($mol_compare_deep(new Uint8Array([0]), new Uint8Array([1])));
2681
+ },
2682
+ 'Custom comparator'() {
2683
+ class User {
2684
+ name;
2685
+ rand;
2686
+ constructor(name, rand = Math.random()) {
2687
+ this.name = name;
2688
+ this.rand = rand;
2689
+ }
2690
+ [Symbol.toPrimitive](mode) {
2691
+ return this.name;
2692
+ }
2693
+ }
2694
+ $mol_assert_ok($mol_compare_deep(new User('Jin'), new User('Jin')));
2695
+ $mol_assert_not($mol_compare_deep(new User('Jin'), new User('John')));
2696
+ },
2697
+ });
2698
+ })($ || ($ = {}));
2699
+ //mol/compare/deep/deep.test.tsx
2700
+ ;
2701
+ "use strict";
2702
+ var $;
2703
+ (function ($) {
2704
+ function $mol_wire_sync(obj) {
2705
+ return new Proxy(obj, {
2706
+ get(obj, field) {
2707
+ const val = obj[field];
2708
+ if (typeof val !== 'function')
2709
+ return val;
2710
+ const temp = $mol_wire_task.getter(val);
2711
+ return function $mol_wire_sync(...args) {
2712
+ const fiber = temp(obj, args);
2713
+ return fiber.sync();
2714
+ };
2715
+ }
2716
+ });
2717
+ }
2718
+ $.$mol_wire_sync = $mol_wire_sync;
2719
+ })($ || ($ = {}));
2720
+ //mol/wire/sync/sync.ts
2721
+ ;
2722
+ "use strict";
2723
+ var $;
2724
+ (function ($) {
2725
+ function $mol_promise() {
2726
+ let done;
2727
+ let fail;
2728
+ const promise = new Promise((d, f) => {
2729
+ done = d;
2730
+ fail = f;
2731
+ });
2732
+ return Object.assign(promise, {
2733
+ done,
2734
+ fail,
2735
+ });
2736
+ }
2737
+ $.$mol_promise = $mol_promise;
2738
+ })($ || ($ = {}));
2739
+ //mol/promise/promise.ts
2740
+ ;
2741
+ "use strict";
2742
+ var $;
2743
+ (function ($) {
2744
+ function $mol_wait_timeout_async(timeout) {
2745
+ const promise = $mol_promise();
2746
+ const task = new this.$mol_after_timeout(timeout, () => promise.done());
2747
+ return Object.assign(promise, {
2748
+ destructor: () => task.destructor()
2749
+ });
2750
+ }
2751
+ $.$mol_wait_timeout_async = $mol_wait_timeout_async;
2752
+ function $mol_wait_timeout(timeout) {
2753
+ return this.$mol_wire_sync(this).$mol_wait_timeout_async(timeout);
2754
+ }
2755
+ $.$mol_wait_timeout = $mol_wait_timeout;
2756
+ })($ || ($ = {}));
2757
+ //mol/wait/timeout/timeout.ts
2758
+ ;
2759
+ "use strict";
2760
+ var $;
2761
+ (function ($_1) {
2762
+ $mol_test({
2763
+ 'Cached channel'($) {
2764
+ class App extends $mol_object2 {
2765
+ static $ = $;
2766
+ static value(next = 1) {
2767
+ return next + 1;
2768
+ }
2769
+ }
2770
+ __decorate([
2771
+ $mol_wire_mem(0)
2772
+ ], App, "value", null);
2773
+ $mol_assert_equal(App.value(), 2);
2774
+ App.value(2);
2775
+ $mol_assert_equal(App.value(), 3);
2776
+ },
2777
+ 'Mem overrides mem'($) {
2778
+ class Base extends $mol_object2 {
2779
+ static $ = $;
2780
+ static value(next = 1) {
2781
+ return next + 1;
2782
+ }
2783
+ }
2784
+ __decorate([
2785
+ $mol_wire_mem(0)
2786
+ ], Base, "value", null);
2787
+ class Middle extends Base {
2788
+ static value(next) {
2789
+ return super.value(next) + 1;
2790
+ }
2791
+ }
2792
+ __decorate([
2793
+ $mol_wire_mem(0)
2794
+ ], Middle, "value", null);
2795
+ class App extends Middle {
2796
+ static value(next) {
2797
+ return super.value(next) * 3;
2798
+ }
2799
+ }
2800
+ __decorate([
2801
+ $mol_wire_mem(0)
2802
+ ], App, "value", null);
2803
+ $mol_assert_equal(App.value(), 9);
2804
+ $mol_assert_equal(App.value(5), 21);
2805
+ $mol_assert_equal(App.value(), 21);
2806
+ },
2807
+ 'Auto recalculation of cached values'($) {
2808
+ class App extends $mol_object2 {
2809
+ static $ = $;
2810
+ static xxx(next) {
2811
+ return next || 1;
2812
+ }
2813
+ static yyy() {
2814
+ return this.xxx() + 1;
2815
+ }
2816
+ static zzz() {
2817
+ return this.yyy() + 1;
2818
+ }
2819
+ }
2820
+ __decorate([
2821
+ $mol_wire_mem(0)
2822
+ ], App, "xxx", null);
2823
+ __decorate([
2824
+ $mol_wire_mem(0)
2825
+ ], App, "yyy", null);
2826
+ __decorate([
2827
+ $mol_wire_mem(0)
2828
+ ], App, "zzz", null);
2829
+ $mol_assert_equal(App.yyy(), 2);
2830
+ $mol_assert_equal(App.zzz(), 3);
2831
+ App.xxx(5);
2832
+ $mol_assert_equal(App.zzz(), 7);
2833
+ },
2834
+ 'Skip recalculation when actually no dependency changes'($) {
2835
+ const log = [];
2836
+ class App extends $mol_object2 {
2837
+ static $ = $;
2838
+ static xxx(next) {
2839
+ log.push('xxx');
2840
+ return next || 1;
2841
+ }
2842
+ static yyy() {
2843
+ log.push('yyy');
2844
+ return [Math.sign(this.xxx())];
2845
+ }
2846
+ static zzz() {
2847
+ log.push('zzz');
2848
+ return this.yyy()[0] + 1;
2849
+ }
2850
+ }
2851
+ __decorate([
2852
+ $mol_wire_mem(0)
2853
+ ], App, "xxx", null);
2854
+ __decorate([
2855
+ $mol_wire_mem(0)
2856
+ ], App, "yyy", null);
2857
+ __decorate([
2858
+ $mol_wire_mem(0)
2859
+ ], App, "zzz", null);
2860
+ App.zzz();
2861
+ $mol_assert_like(log, ['zzz', 'yyy', 'xxx']);
2862
+ App.xxx(5);
2863
+ $mol_assert_like(log, ['zzz', 'yyy', 'xxx', 'xxx']);
2864
+ App.zzz();
2865
+ $mol_assert_like(log, ['zzz', 'yyy', 'xxx', 'xxx', 'yyy']);
2866
+ },
2867
+ 'Flow: Auto'($) {
2868
+ class App extends $mol_object2 {
2869
+ static get $() { return $; }
2870
+ static first(next = 1) { return next; }
2871
+ static second(next = 2) { return next; }
2872
+ static condition(next = true) { return next; }
2873
+ static counter = 0;
2874
+ static result() {
2875
+ const res = this.condition() ? this.first() : this.second();
2876
+ return res + this.counter++;
2877
+ }
2878
+ }
2879
+ __decorate([
2880
+ $mol_wire_mem(0)
2881
+ ], App, "first", null);
2882
+ __decorate([
2883
+ $mol_wire_mem(0)
2884
+ ], App, "second", null);
2885
+ __decorate([
2886
+ $mol_wire_mem(0)
2887
+ ], App, "condition", null);
2888
+ __decorate([
2889
+ $mol_wire_mem(0)
2890
+ ], App, "result", null);
2891
+ $mol_assert_equal(App.result(), 1);
2892
+ $mol_assert_equal(App.counter, 1);
2893
+ App.condition(false);
2894
+ $mol_assert_equal(App.result(), 3);
2895
+ $mol_assert_equal(App.counter, 2);
2896
+ App.first(10);
2897
+ $mol_assert_equal(App.result(), 3);
2898
+ $mol_assert_equal(App.counter, 2);
2899
+ },
2900
+ 'Dupes: Equality'($) {
2901
+ let counter = 0;
2902
+ class App extends $mol_object2 {
2903
+ static $ = $;
2904
+ static foo(next) {
2905
+ return next ?? { numbs: [1] };
2906
+ }
2907
+ static bar() {
2908
+ return { ...this.foo(), count: ++counter };
2909
+ }
2910
+ }
2911
+ __decorate([
2912
+ $mol_wire_mem(0)
2913
+ ], App, "foo", null);
2914
+ __decorate([
2915
+ $mol_wire_mem(0)
2916
+ ], App, "bar", null);
2917
+ $mol_assert_like(App.bar(), { numbs: [1], count: 1 });
2918
+ App.foo({ numbs: [1] });
2919
+ $mol_assert_like(App.bar(), { numbs: [1], count: 1 });
2920
+ App.foo({ numbs: [2] });
2921
+ $mol_assert_like(App.bar(), { numbs: [2], count: 2 });
2922
+ },
2923
+ 'Cycle: Fail'($) {
2924
+ class App extends $mol_object2 {
2925
+ static $ = $;
2926
+ static foo() {
2927
+ return this.bar() + 1;
2928
+ }
2929
+ static bar() {
2930
+ return this.foo() + 1;
2931
+ }
2932
+ static test() {
2933
+ $mol_assert_fail(() => App.foo(), 'Circular subscription');
2934
+ }
2935
+ }
2936
+ __decorate([
2937
+ $mol_wire_mem(0)
2938
+ ], App, "foo", null);
2939
+ __decorate([
2940
+ $mol_wire_mem(0)
2941
+ ], App, "bar", null);
2942
+ __decorate([
2943
+ $mol_wire_method
2944
+ ], App, "test", null);
2945
+ App.test();
2946
+ },
2947
+ 'Different order of pull and push'($) {
2948
+ class App extends $mol_object2 {
2949
+ static $ = $;
2950
+ static store(next = 0) {
2951
+ return next;
2952
+ }
2953
+ static fast(next) {
2954
+ return this.store(next);
2955
+ }
2956
+ static slow(next) {
2957
+ return this.store(next);
2958
+ }
2959
+ }
2960
+ __decorate([
2961
+ $mol_wire_mem(0)
2962
+ ], App, "store", null);
2963
+ __decorate([
2964
+ $mol_wire_mem(0)
2965
+ ], App, "fast", null);
2966
+ __decorate([
2967
+ $mol_wire_mem(0)
2968
+ ], App, "slow", null);
2969
+ App.fast();
2970
+ $mol_assert_equal(App.slow(666), 666);
2971
+ $mol_assert_equal(App.fast(), App.slow(), 666);
2972
+ App.store(777);
2973
+ $mol_assert_equal(App.fast(), App.slow(), 777);
2974
+ },
2975
+ 'Actions inside invariant'($) {
2976
+ class App extends $mol_object2 {
2977
+ static $ = $;
2978
+ static count(next = 0) {
2979
+ return next;
2980
+ }
2981
+ static count2() {
2982
+ return this.count();
2983
+ }
2984
+ static res() {
2985
+ const count = this.count2();
2986
+ if (!count)
2987
+ this.count(count + 1);
2988
+ return count + 1;
2989
+ }
2990
+ }
2991
+ __decorate([
2992
+ $mol_wire_mem(0)
2993
+ ], App, "count", null);
2994
+ __decorate([
2995
+ $mol_wire_mem(0)
2996
+ ], App, "count2", null);
2997
+ __decorate([
2998
+ $mol_wire_mem(0)
2999
+ ], App, "res", null);
3000
+ $mol_assert_like(App.res(), 1);
3001
+ App.count(5);
3002
+ $mol_assert_like(App.res(), 6);
3003
+ },
3004
+ async 'Toggle with async'($) {
3005
+ class App extends $mol_object2 {
3006
+ static $ = $;
3007
+ static checked(next = false) {
3008
+ $$.$mol_wait_timeout(0);
3009
+ return next;
3010
+ }
3011
+ static toggle() {
3012
+ const prev = this.checked();
3013
+ $mol_assert_unique(this.checked(!prev), prev);
3014
+ }
3015
+ static res() {
3016
+ return this.checked();
3017
+ }
3018
+ static test() {
3019
+ $mol_assert_equal(App.res(), false);
3020
+ App.toggle();
3021
+ $mol_assert_equal(App.res(), true);
3022
+ }
3023
+ }
3024
+ __decorate([
3025
+ $mol_wire_mem(0)
3026
+ ], App, "checked", null);
3027
+ __decorate([
3028
+ $mol_wire_method
3029
+ ], App, "toggle", null);
3030
+ __decorate([
3031
+ $mol_wire_mem(0)
3032
+ ], App, "res", null);
3033
+ __decorate([
3034
+ $mol_wire_method
3035
+ ], App, "test", null);
3036
+ await $mol_wire_async(App).test();
3037
+ },
3038
+ 'Restore after error'($) {
3039
+ class App extends $mol_object2 {
3040
+ static get $() { return $; }
3041
+ static condition(next = false) { return next; }
3042
+ static broken() {
3043
+ if (this.condition()) {
3044
+ $mol_fail(new Error('test error'));
3045
+ }
3046
+ return 1;
3047
+ }
3048
+ static result() {
3049
+ return this.broken();
3050
+ }
3051
+ }
3052
+ __decorate([
3053
+ $mol_wire_mem(0)
3054
+ ], App, "condition", null);
3055
+ __decorate([
3056
+ $mol_wire_mem(0)
3057
+ ], App, "broken", null);
3058
+ __decorate([
3059
+ $mol_wire_mem(0)
3060
+ ], App, "result", null);
3061
+ $mol_assert_equal(App.result(), 1);
3062
+ App.condition(true);
3063
+ $mol_assert_fail(() => App.result());
3064
+ App.condition(false);
3065
+ $mol_assert_equal(App.result(), 1);
3066
+ },
3067
+ async 'Wait for data'($) {
3068
+ class App extends $mol_object2 {
3069
+ static $ = $;
3070
+ static async source() {
3071
+ return 'Jin';
3072
+ }
3073
+ static middle() {
3074
+ return $mol_wire_sync(this).source();
3075
+ }
3076
+ static target() {
3077
+ return this.middle();
3078
+ }
3079
+ static test() {
3080
+ $mol_assert_equal(App.target(), 'Jin');
3081
+ }
3082
+ }
3083
+ __decorate([
3084
+ $mol_wire_mem(0)
3085
+ ], App, "middle", null);
3086
+ __decorate([
3087
+ $mol_wire_mem(0)
3088
+ ], App, "target", null);
3089
+ __decorate([
3090
+ $mol_wire_method
3091
+ ], App, "test", null);
3092
+ await $mol_wire_async(App).test();
3093
+ },
3094
+ 'Auto destroy on long alone'($) {
3095
+ let destroyed = false;
3096
+ class App extends $mol_object2 {
3097
+ static $ = $;
3098
+ static showing(next = true) {
3099
+ return next;
3100
+ }
3101
+ static details() {
3102
+ return {
3103
+ destructor() {
3104
+ destroyed = true;
3105
+ }
3106
+ };
3107
+ }
3108
+ static render() {
3109
+ return this.showing() ? this.details() : null;
3110
+ }
3111
+ }
3112
+ __decorate([
3113
+ $mol_wire_mem(0)
3114
+ ], App, "showing", null);
3115
+ __decorate([
3116
+ $mol_wire_mem(0)
3117
+ ], App, "details", null);
3118
+ __decorate([
3119
+ $mol_wire_mem(0)
3120
+ ], App, "render", null);
3121
+ const details = App.render();
3122
+ $mol_assert_ok(details);
3123
+ App.showing(false);
3124
+ $mol_assert_not(App.render());
3125
+ App.showing(true);
3126
+ $mol_assert_equal(App.render(), details);
3127
+ $mol_wire_fiber.sync();
3128
+ $mol_assert_not(destroyed);
3129
+ App.showing(false);
3130
+ $mol_wire_fiber.sync();
3131
+ $mol_assert_ok(destroyed);
3132
+ App.showing(true);
3133
+ $mol_assert_unique(App.render(), details);
3134
+ },
3135
+ async 'Hold pubs while wait async task'($) {
3136
+ class App extends $mol_object2 {
3137
+ static $ = $;
3138
+ static counter = 0;
3139
+ static resets(next) {
3140
+ return ($mol_wire_probe(() => this.resets()) ?? -1) + 1;
3141
+ }
3142
+ static async wait() { }
3143
+ static value() {
3144
+ return ++this.counter;
3145
+ }
3146
+ static result() {
3147
+ if (this.resets())
3148
+ $mol_wire_sync(this).wait();
3149
+ return this.value();
3150
+ }
3151
+ static test() {
3152
+ }
3153
+ }
3154
+ __decorate([
3155
+ $mol_wire_mem(0)
3156
+ ], App, "resets", null);
3157
+ __decorate([
3158
+ $mol_wire_mem(0)
3159
+ ], App, "value", null);
3160
+ __decorate([
3161
+ $mol_wire_mem(0)
3162
+ ], App, "result", null);
3163
+ __decorate([
3164
+ $mol_wire_method
3165
+ ], App, "test", null);
3166
+ $mol_assert_equal(App.result(), 1);
3167
+ App.resets(null);
3168
+ $mol_wire_fiber.sync();
3169
+ $mol_assert_equal(await $mol_wire_async(App).result(), 1);
3170
+ },
3171
+ 'Memoize by single simple key'($) {
3172
+ class Team extends $mol_object2 {
3173
+ static $ = $;
3174
+ static user_name(user, next) {
3175
+ return next ?? user;
3176
+ }
3177
+ static user_names() {
3178
+ return [
3179
+ this.user_name('jin'),
3180
+ this.user_name('john'),
3181
+ ];
3182
+ }
3183
+ static test() {
3184
+ }
3185
+ }
3186
+ __decorate([
3187
+ $mol_wire_mem(1)
3188
+ ], Team, "user_name", null);
3189
+ __decorate([
3190
+ $mol_wire_mem(1)
3191
+ ], Team, "user_names", null);
3192
+ __decorate([
3193
+ $mol_wire_method
3194
+ ], Team, "test", null);
3195
+ $mol_assert_like(Team.user_names(), ['jin', 'john']);
3196
+ Team.user_name('jin', 'JIN');
3197
+ $mol_assert_like(Team.user_names(), ['JIN', 'john']);
3198
+ },
3199
+ 'Memoize by single complex key'($) {
3200
+ class Map extends $mol_object2 {
3201
+ static $ = $;
3202
+ static tile(pos) {
3203
+ return new String(`/tile=${pos}`);
3204
+ }
3205
+ static test() {
3206
+ $mol_assert_like(this.tile([0, 1]), new String('/tile=0,1'));
3207
+ $mol_assert_equal(this.tile([0, 1]), this.tile([0, 1]));
3208
+ }
3209
+ }
3210
+ __decorate([
3211
+ $mol_wire_mem(1)
3212
+ ], Map, "tile", null);
3213
+ __decorate([
3214
+ $mol_wire_method
3215
+ ], Map, "test", null);
3216
+ Map.test();
3217
+ },
3218
+ 'Memoize by multiple keys'($) {
3219
+ class Map extends $mol_object2 {
3220
+ static $ = $;
3221
+ static tile(x, y) {
3222
+ return new String(`/tile=${x},${y}`);
3223
+ }
3224
+ static test() {
3225
+ $mol_assert_like(this.tile(0, 1), new String('/tile=0,1'));
3226
+ $mol_assert_equal(this.tile(0, 1), this.tile(0, 1));
3227
+ }
3228
+ }
3229
+ __decorate([
3230
+ $mol_wire_mem(2)
3231
+ ], Map, "tile", null);
3232
+ __decorate([
3233
+ $mol_wire_method
3234
+ ], Map, "test", null);
3235
+ Map.test();
3236
+ },
3237
+ 'Owned value has js-path name'() {
3238
+ class App extends $mol_object2 {
3239
+ static title() {
3240
+ return new $mol_object2;
3241
+ }
3242
+ static like(friend) {
3243
+ return new $mol_object2;
3244
+ }
3245
+ static relation(friend, props) {
3246
+ return new $mol_object2;
3247
+ }
3248
+ }
3249
+ __decorate([
3250
+ $mol_wire_mem(0)
3251
+ ], App, "title", null);
3252
+ __decorate([
3253
+ $mol_wire_mem(1)
3254
+ ], App, "like", null);
3255
+ __decorate([
3256
+ $mol_wire_mem(2)
3257
+ ], App, "relation", null);
3258
+ $mol_assert_equal(`${App.title()}`, 'App.title()');
3259
+ $mol_assert_equal(`${App.like(123)}`, 'App.like(123)');
3260
+ $mol_assert_equal(`${App.relation(123, [456])}`, 'App.relation(123,[456])');
3261
+ },
3262
+ 'Deep deps'($) {
3263
+ class Fib extends $mol_object2 {
3264
+ static $ = $;
3265
+ static sums = 0;
3266
+ static value(index, next) {
3267
+ if (next)
3268
+ return next;
3269
+ if (index < 2)
3270
+ return 1;
3271
+ ++this.sums;
3272
+ return this.value(index - 1) + this.value(index - 2);
3273
+ }
3274
+ }
3275
+ __decorate([
3276
+ $mol_wire_mem(1)
3277
+ ], Fib, "value", null);
3278
+ $mol_assert_equal(Fib.value(4), 5);
3279
+ $mol_assert_equal(Fib.sums, 3);
3280
+ Fib.value(1, 2);
3281
+ $mol_assert_equal(Fib.value(4), 8);
3282
+ $mol_assert_equal(Fib.sums, 6);
3283
+ },
3284
+ });
3285
+ })($ || ($ = {}));
3286
+ //mol/wire/mem/mem.test.ts
3287
+ ;
3288
+ "use strict";
3289
+ var $;
3290
+ (function ($) {
3291
+ $mol_test({
3292
+ 'Previous value'() {
3293
+ class Cache extends $mol_object2 {
3294
+ static store(next) {
3295
+ if (!next)
3296
+ return {};
3297
+ return {
3298
+ ...$mol_wire_probe(() => this.store()) ?? {},
3299
+ ...next,
3300
+ };
3301
+ }
3302
+ }
3303
+ __decorate([
3304
+ $mol_wire_mem(0)
3305
+ ], Cache, "store", null);
3306
+ $mol_assert_like(Cache.store(), {});
3307
+ $mol_assert_like(Cache.store({ foo: 666 }), { foo: 666 });
3308
+ $mol_assert_like(Cache.store({ bar: 777 }), { foo: 666, bar: 777 });
3309
+ },
3310
+ });
3311
+ })($ || ($ = {}));
3312
+ //mol/wire/probe/probe.test.ts
3313
+ ;
3314
+ "use strict";
3315
+ var $;
3316
+ (function ($) {
3317
+ function $mol_wire_probe(task, next) {
3318
+ const warm = $mol_wire_fiber.warm;
3319
+ try {
3320
+ $mol_wire_fiber.warm = false;
3321
+ return task();
3322
+ }
3323
+ finally {
3324
+ $mol_wire_fiber.warm = warm;
3325
+ }
3326
+ }
3327
+ $.$mol_wire_probe = $mol_wire_probe;
3328
+ })($ || ($ = {}));
3329
+ //mol/wire/probe/probe.ts
3330
+ ;
3331
+ "use strict";
3332
+ var $;
3333
+ (function ($) {
3334
+ class $mol_wire_log extends $mol_object2 {
3335
+ static watch(task) {
3336
+ return task;
3337
+ }
3338
+ static track(fiber) {
3339
+ const prev = $mol_wire_probe(() => this.track(fiber));
3340
+ let next;
3341
+ try {
3342
+ next = fiber.sync();
3343
+ }
3344
+ finally {
3345
+ for (const pub of fiber.pub_list) {
3346
+ if (pub instanceof $mol_wire_fiber) {
3347
+ this.track(pub);
3348
+ }
3349
+ }
3350
+ }
3351
+ if (prev !== undefined && !$mol_compare_deep(prev, next)) {
3352
+ this.$.$mol_log3_rise({
3353
+ message: 'Changed',
3354
+ place: fiber,
3355
+ });
3356
+ }
3357
+ return next;
3358
+ }
3359
+ static active() {
3360
+ try {
3361
+ this.watch()?.();
3362
+ }
3363
+ finally {
3364
+ for (const pub of $mol_wire_auto().pub_list) {
3365
+ if (pub instanceof $mol_wire_fiber) {
3366
+ this.track(pub);
3367
+ }
3368
+ }
3369
+ }
3370
+ }
3371
+ }
3372
+ __decorate([
3373
+ $mol_mem
3374
+ ], $mol_wire_log, "watch", null);
3375
+ __decorate([
3376
+ $mol_mem_key
3377
+ ], $mol_wire_log, "track", null);
3378
+ __decorate([
3379
+ $mol_mem
3380
+ ], $mol_wire_log, "active", null);
3381
+ $.$mol_wire_log = $mol_wire_log;
3382
+ })($ || ($ = {}));
3383
+ //mol/wire/log/log.ts
3384
+ ;
3385
+ "use strict";
3386
+ var $;
3387
+ (function ($) {
3388
+ $mol_test({
3389
+ 'Primitives'() {
3390
+ $mol_assert_equal($mol_key(null), 'null');
3391
+ $mol_assert_equal($mol_key(false), 'false');
3392
+ $mol_assert_equal($mol_key(true), 'true');
3393
+ $mol_assert_equal($mol_key(0), '0');
3394
+ $mol_assert_equal($mol_key(''), '""');
3395
+ },
3396
+ 'Array & POJO'() {
3397
+ $mol_assert_equal($mol_key([null]), '[null]');
3398
+ $mol_assert_equal($mol_key({ foo: 0 }), '{"foo":0}');
3399
+ $mol_assert_equal($mol_key({ foo: [false] }), '{"foo":[false]}');
3400
+ },
3401
+ 'Function'() {
3402
+ const func = () => { };
3403
+ $mol_assert_equal($mol_key(func), $mol_key(func));
3404
+ $mol_assert_unique($mol_key(func), $mol_key(() => { }));
3405
+ },
3406
+ 'Objects'() {
3407
+ class User {
3408
+ }
3409
+ const jin = new User();
3410
+ $mol_assert_equal($mol_key(jin), $mol_key(jin));
3411
+ $mol_assert_unique($mol_key(jin), $mol_key(new User()));
3412
+ },
3413
+ 'Elements'() {
3414
+ const foo = $mol_jsx("div", null, "bar");
3415
+ $mol_assert_equal($mol_key(foo), $mol_key(foo));
3416
+ $mol_assert_unique($mol_key(foo), $mol_key($mol_jsx("div", null, "bar")));
3417
+ },
3418
+ 'Custom JSON representation'() {
3419
+ class User {
3420
+ name;
3421
+ age;
3422
+ constructor(name, age) {
3423
+ this.name = name;
3424
+ this.age = age;
3425
+ }
3426
+ toJSON() { return { name: this.name }; }
3427
+ }
3428
+ $mol_assert_equal($mol_key(new User('jin', 18)), '{"name":"jin"}');
3429
+ },
3430
+ 'Special native classes'() {
3431
+ $mol_assert_equal($mol_key(new Date('xyz')), 'null');
3432
+ $mol_assert_equal($mol_key(new Date('2001-01-02T03:04:05.678Z')), '"2001-01-02T03:04:05.678Z"');
3433
+ $mol_assert_equal($mol_key(/./), '"/./"');
3434
+ $mol_assert_equal($mol_key(/\./gimsu), '"/\\\\./gimsu"');
3435
+ },
3436
+ });
3437
+ })($ || ($ = {}));
3438
+ //mol/key/key.test.tsx
3439
+ ;
3440
+ "use strict";
3441
+ var $;
3442
+ (function ($) {
3443
+ $mol_wire_log.active();
3444
+ })($ || ($ = {}));
3445
+ //mol/wire/atom/atom.test.ts
3446
+ ;
3447
+ "use strict";
3448
+ var $;
3449
+ (function ($_1) {
3450
+ $mol_test({
3451
+ 'Class as component'() {
3452
+ class Foo extends $mol_jsx_view {
3453
+ title = '';
3454
+ render() {
3455
+ return $mol_jsx("div", null,
3456
+ this.title,
3457
+ " ",
3458
+ this.childNodes.join('-'));
3459
+ }
3460
+ }
3461
+ const dom = $mol_jsx(Foo, { id: "/foo", title: "bar" },
3462
+ "xxx",
3463
+ 123);
3464
+ $mol_assert_equal(dom.outerHTML, '<div id="/foo">bar xxx-123</div>');
3465
+ },
3466
+ 'View by element'() {
3467
+ let br;
3468
+ let brr;
3469
+ class Br extends $mol_jsx_view {
3470
+ render() {
3471
+ br = this;
3472
+ return $mol_jsx("br", { id: "/foo" });
3473
+ }
3474
+ }
3475
+ class Brr extends $mol_jsx_view {
3476
+ render() {
3477
+ brr = this;
3478
+ return $mol_jsx(Br, null);
3479
+ }
3480
+ }
3481
+ $mol_assert_equal(Br.of($mol_jsx(Brr, null)), br);
3482
+ $mol_assert_equal(Brr.of($mol_jsx(Brr, null)), brr);
3483
+ },
3484
+ async 'Attached view rerender'() {
3485
+ const doc = $mol_dom_parse('<html><body id="/foo"></body></html>');
3486
+ class Title extends $mol_jsx_view {
3487
+ value(next = 'foo') { return next; }
3488
+ render() {
3489
+ return $mol_jsx("div", null, this.value());
3490
+ }
3491
+ }
3492
+ __decorate([
3493
+ $mol_mem
3494
+ ], Title.prototype, "value", null);
3495
+ const dom = $mol_jsx_attach(doc, () => $mol_jsx(Title, { id: "/foo" }));
3496
+ const title = Title.of(dom);
3497
+ $mol_assert_equal(title.ownerDocument, doc);
3498
+ $mol_assert_equal(doc.documentElement.outerHTML, '<html><body id="/foo">foo</body></html>');
3499
+ title.value('bar');
3500
+ await $mol_wire_fiber.sync();
3501
+ $mol_assert_equal(doc.documentElement.outerHTML, '<html><body id="/foo">bar</body></html>');
3502
+ },
3503
+ async 'Nested bound views'($) {
3504
+ class Task extends $mol_jsx_view {
3505
+ title(next = 'foo') { return next; }
3506
+ render() {
3507
+ return $mol_jsx("h1", null, this.title());
3508
+ }
3509
+ }
3510
+ __decorate([
3511
+ $mol_mem
3512
+ ], Task.prototype, "title", null);
3513
+ class List extends $mol_jsx_view {
3514
+ render() {
3515
+ return $mol_jsx("div", { class: "list" }, ...this.childNodes);
3516
+ }
3517
+ }
3518
+ class App extends $mol_jsx_view {
3519
+ title(next = '') { return next; }
3520
+ render() {
3521
+ return ($mol_jsx(List, null, this.title() && $mol_jsx(Task, { id: "/task", title: next => this.title(next) })));
3522
+ }
3523
+ }
3524
+ __decorate([
3525
+ $mol_mem
3526
+ ], App.prototype, "title", null);
3527
+ const doc = $mol_dom_parse('<html xmlns="http://www.w3.org/1999/xhtml"><body id="/root"></body></html>');
3528
+ const root = $.$mol_jsx_attach(doc, () => $mol_jsx(App, { "$": $, id: "/root" }));
3529
+ $mol_assert_equal($mol_dom_serialize(doc.documentElement), '<html xmlns="http://www.w3.org/1999/xhtml"><body id="/root" class="list"></body></html>');
3530
+ App.of(root).title('barbar');
3531
+ await $mol_wire_fiber.sync();
3532
+ $mol_assert_equal(Task.of(root.firstElementChild).title(), 'barbar');
3533
+ $mol_assert_equal(doc.documentElement.outerHTML, '<html xmlns="http://www.w3.org/1999/xhtml"><body id="/root" class="list"><h1 id="/root/task">barbar</h1></body></html>');
3534
+ Task.of(root.firstElementChild).title('foofoo');
3535
+ await $mol_wire_fiber.sync();
3536
+ $mol_assert_equal(App.of(root).title(), 'foofoo');
3537
+ $mol_assert_equal(doc.documentElement.outerHTML, '<html xmlns="http://www.w3.org/1999/xhtml"><body id="/root" class="list"><h1 id="/root/task">foofoo</h1></body></html>');
3538
+ },
3539
+ });
3540
+ })($ || ($ = {}));
3541
+ //mol/jsx/view/view.test.tsx
3542
+
3543
+ //# sourceMappingURL=node.test.js.map