mol_plot_all 1.2.1491 → 1.2.1492

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/node.test.js CHANGED
@@ -2347,245 +2347,6 @@ var $;
2347
2347
 
2348
2348
  ;
2349
2349
  "use strict";
2350
- var $;
2351
- (function ($) {
2352
- $.$mol_theme = $mol_style_prop('mol_theme', [
2353
- 'back',
2354
- 'hover',
2355
- 'card',
2356
- 'current',
2357
- 'special',
2358
- 'text',
2359
- 'control',
2360
- 'shade',
2361
- 'line',
2362
- 'focus',
2363
- 'field',
2364
- 'image',
2365
- 'spirit',
2366
- ]);
2367
- })($ || ($ = {}));
2368
-
2369
- ;
2370
- "use strict";
2371
- var $;
2372
- (function ($) {
2373
- $mol_style_attach("mol/theme/theme.css", ":root {\n\t--mol_theme_hue: 240deg;\n\t--mol_theme_hue_spread: 90deg;\n\tcolor-scheme: dark light;\n}\n\n:where([mol_theme]) {\n\tcolor: var(--mol_theme_text);\n\tfill: var(--mol_theme_text);\n\tbackground-color: var(--mol_theme_back);\n}\n\t\n:root, [mol_theme=\"$mol_theme_dark\"], :where([mol_theme=\"$mol_theme_dark\"]) [mol_theme] {\n\n\t--mol_theme_luma: -1;\n\t--mol_theme_image: invert(1) hue-rotate( 180deg );\n\t--mol_theme_spirit: hsl( 0deg, 0%, 0%, .75 );\n\n\t--mol_theme_back: hsl( var(--mol_theme_hue), 20%, 10% );\n\t--mol_theme_card: hsl( var(--mol_theme_hue), 50%, 20%, .25 );\n\t--mol_theme_field: hsl( var(--mol_theme_hue), 50%, 8%, .25 );\n\t--mol_theme_hover: hsl( var(--mol_theme_hue), 0%, 50%, .1 );\n\t\n\t--mol_theme_text: hsl( var(--mol_theme_hue), 0%, 80% );\n\t--mol_theme_shade: hsl( var(--mol_theme_hue), 0%, 60%, 1 );\n\t--mol_theme_line: hsl( var(--mol_theme_hue), 0%, 50%, .25 );\n\t--mol_theme_focus: hsl( calc( var(--mol_theme_hue) + 180deg ), 100%, 65% );\n\t\n\t--mol_theme_control: hsl( var(--mol_theme_hue), 60%, 65% );\n\t--mol_theme_current: hsl( calc( var(--mol_theme_hue) - var(--mol_theme_hue_spread) ), 60%, 65% );\n\t--mol_theme_special: hsl( calc( var(--mol_theme_hue) + var(--mol_theme_hue_spread) ), 60%, 65% );\n\n} @supports( color: oklch( 0% 0 0deg ) ) {\n:root, [mol_theme=\"$mol_theme_dark\"], :where([mol_theme=\"$mol_theme_dark\"]) [mol_theme] {\n\t\n\t--mol_theme_back: oklch( 20% .03 var(--mol_theme_hue) );\n\t--mol_theme_card: oklch( 30% .05 var(--mol_theme_hue) / .25 );\n\t--mol_theme_field: oklch( 15% 0 var(--mol_theme_hue) / .25 );\n\t--mol_theme_hover: oklch( 70% 0 var(--mol_theme_hue) / .1 );\n\t\n\t--mol_theme_text: oklch( 80% 0 var(--mol_theme_hue) );\n\t--mol_theme_shade: oklch( 60% 0 var(--mol_theme_hue) );\n\t--mol_theme_line: oklch( 60% 0 var(--mol_theme_hue) / .25 );\n\t--mol_theme_focus: oklch( 80% .2 calc( var(--mol_theme_hue) + 180deg ) );\n\t\n\t--mol_theme_control: oklch( 70% .1 var(--mol_theme_hue) );\n\t--mol_theme_current: oklch( 70% .2 calc( var(--mol_theme_hue) - var(--mol_theme_hue_spread) ) );\n\t--mol_theme_special: oklch( 70% .2 calc( var(--mol_theme_hue) + var(--mol_theme_hue_spread) ) );\n\n} }\n\n[mol_theme=\"$mol_theme_light\"], :where([mol_theme=\"$mol_theme_light\"]) [mol_theme] {\n\t\n\t--mol_theme_luma: 1;\n\t--mol_theme_image: none;\n\t--mol_theme_spirit: hsl( 0deg, 0%, 100%, .75 );\n\t\n\t--mol_theme_back: hsl( var(--mol_theme_hue), 20%, 92% );\n\t--mol_theme_card: hsl( var(--mol_theme_hue), 50%, 100%, .5 );\n\t--mol_theme_field: hsl( var(--mol_theme_hue), 50%, 100%, .75 );\n\t--mol_theme_hover: hsl( var(--mol_theme_hue), 0%, 50%, .1 );\n\t\n\t--mol_theme_text: hsl( var(--mol_theme_hue), 0%, 0% );\n\t--mol_theme_shade: hsl( var(--mol_theme_hue), 0%, 40%, 1 );\n\t--mol_theme_line: hsl( var(--mol_theme_hue), 0%, 50%, .25 );\n\t--mol_theme_focus: hsl( calc( var(--mol_theme_hue) + 180deg ), 100%, 40% );\n\t\n\t--mol_theme_control: hsl( var(--mol_theme_hue), 80%, 30% );\n\t--mol_theme_current: hsl( calc( var(--mol_theme_hue) - var(--mol_theme_hue_spread) ), 80%, 30% );\n\t--mol_theme_special: hsl( calc( var(--mol_theme_hue) + var(--mol_theme_hue_spread) ), 80%, 30% );\n\n} @supports( color: oklch( 0% 0 0deg ) ) {\n[mol_theme=\"$mol_theme_light\"], :where([mol_theme=\"$mol_theme_light\"]) [mol_theme] {\n\t--mol_theme_back: oklch( 92% .01 var(--mol_theme_hue) );\n\t--mol_theme_card: oklch( 99% .01 var(--mol_theme_hue) / .5 );\n\t--mol_theme_field: oklch( 100% 0 var(--mol_theme_hue) / .5 );\n\t--mol_theme_hover: oklch( 70% 0 var(--mol_theme_hue) / .1 );\n\t\n\t--mol_theme_text: oklch( 20% 0 var(--mol_theme_hue) );\n\t--mol_theme_shade: oklch( 60% 0 var(--mol_theme_hue) );\n\t--mol_theme_line: oklch( 50% 0 var(--mol_theme_hue) / .25 );\n\t--mol_theme_focus: oklch( 60% .2 calc( var(--mol_theme_hue) + 180deg ) );\n\t\n\t--mol_theme_control: oklch( 40% .15 var(--mol_theme_hue) );\n\t--mol_theme_current: oklch( 50% .2 calc( var(--mol_theme_hue) - var(--mol_theme_hue_spread) ) );\n\t--mol_theme_special: oklch( 50% .2 calc( var(--mol_theme_hue) + var(--mol_theme_hue_spread) ) );\n\n} }\n\n:where( :root, [mol_theme=\"$mol_theme_dark\"] ) [mol_theme=\"$mol_theme_base\"] {\n\t--mol_theme_back: oklch( 25% .075 var(--mol_theme_hue) );\n\t--mol_theme_card: oklch( 35% .1 var(--mol_theme_hue) / .25 );\n}\n:where( [mol_theme=\"$mol_theme_light\"] ) [mol_theme=\"$mol_theme_base\"] {\n\t--mol_theme_back: oklch( 85% .075 var(--mol_theme_hue) );\n\t--mol_theme_card: oklch( 98% .03 var(--mol_theme_hue) / .25 );\n}\n\n:where( :root, [mol_theme=\"$mol_theme_dark\"] ) [mol_theme=\"$mol_theme_current\"] {\n\t--mol_theme_back: oklch( 25% .05 calc( var(--mol_theme_hue) - var(--mol_theme_hue_spread) ) );\n\t--mol_theme_card: oklch( 35% .1 calc( var(--mol_theme_hue) - var(--mol_theme_hue_spread) ) / .25 );\n}\n:where( [mol_theme=\"$mol_theme_light\"] ) [mol_theme=\"$mol_theme_current\"] {\n\t--mol_theme_back: oklch( 85% .05 calc( var(--mol_theme_hue) - var(--mol_theme_hue_spread) ) );\n\t--mol_theme_card: oklch( 98% .03 calc( var(--mol_theme_hue) - var(--mol_theme_hue_spread) ) / .25 );\n}\n\n:where( :root, [mol_theme=\"$mol_theme_dark\"] ) [mol_theme=\"$mol_theme_special\"] {\n\t--mol_theme_back: oklch( 25% .05 calc( var(--mol_theme_hue) + var(--mol_theme_hue_spread) ) );\n\t--mol_theme_card: oklch( 35% .1 calc( var(--mol_theme_hue) + var(--mol_theme_hue_spread) ) / .25 );\n}\n:where( [mol_theme=\"$mol_theme_light\"] ) [mol_theme=\"$mol_theme_special\"] {\n\t--mol_theme_back: oklch( 85% .05 calc( var(--mol_theme_hue) + var(--mol_theme_hue_spread) ) );\n\t--mol_theme_card: oklch( 98% .03 calc( var(--mol_theme_hue) + var(--mol_theme_hue_spread) ) / .25 );\n}\n\n:where( :root, [mol_theme=\"$mol_theme_dark\"] ) [mol_theme=\"$mol_theme_accent\"] {\n\t--mol_theme_back: oklch( 35% .1 calc( var(--mol_theme_hue) + 180deg ) );\n\t--mol_theme_card: oklch( 45% .15 calc( var(--mol_theme_hue) + 180deg ) / .25 );\n}\n:where( [mol_theme=\"$mol_theme_light\"] ) [mol_theme=\"$mol_theme_accent\"] {\n\t--mol_theme_back: oklch( 83% .1 calc( var(--mol_theme_hue) + 180deg ) );\n\t--mol_theme_card: oklch( 98% .03 calc( var(--mol_theme_hue) + 180deg ) / .25 );\n}\n\n");
2374
- })($ || ($ = {}));
2375
-
2376
- ;
2377
- "use strict";
2378
- var $;
2379
- (function ($) {
2380
- $.$mol_gap = $mol_style_prop('mol_gap', [
2381
- 'block',
2382
- 'text',
2383
- 'round',
2384
- 'space',
2385
- 'blur',
2386
- ]);
2387
- })($ || ($ = {}));
2388
-
2389
- ;
2390
- "use strict";
2391
- var $;
2392
- (function ($) {
2393
- $mol_style_attach("mol/gap/gap.css", ":root {\n\t--mol_gap_block: .75rem;\n\t--mol_gap_text: .5rem .75rem;\n\t--mol_gap_round: .25rem;\n\t--mol_gap_space: .25rem;\n\t--mol_gap_blur: .5rem;\n}\n");
2394
- })($ || ($ = {}));
2395
-
2396
- ;
2397
- "use strict";
2398
- var $;
2399
- (function ($) {
2400
- function $mol_dom_render_children(el, childNodes) {
2401
- const node_set = new Set(childNodes);
2402
- let nextNode = el.firstChild;
2403
- for (let view of childNodes) {
2404
- if (view == null)
2405
- continue;
2406
- if (view instanceof $mol_dom_context.Node) {
2407
- while (true) {
2408
- if (!nextNode) {
2409
- el.appendChild(view);
2410
- break;
2411
- }
2412
- if (nextNode == view) {
2413
- nextNode = nextNode.nextSibling;
2414
- break;
2415
- }
2416
- else {
2417
- if (node_set.has(nextNode)) {
2418
- el.insertBefore(view, nextNode);
2419
- break;
2420
- }
2421
- else {
2422
- const nn = nextNode.nextSibling;
2423
- el.removeChild(nextNode);
2424
- nextNode = nn;
2425
- }
2426
- }
2427
- }
2428
- }
2429
- else {
2430
- if (nextNode && nextNode.nodeName === '#text') {
2431
- const str = String(view);
2432
- if (nextNode.nodeValue !== str)
2433
- nextNode.nodeValue = str;
2434
- nextNode = nextNode.nextSibling;
2435
- }
2436
- else {
2437
- const textNode = $mol_dom_context.document.createTextNode(String(view));
2438
- el.insertBefore(textNode, nextNode);
2439
- }
2440
- }
2441
- }
2442
- while (nextNode) {
2443
- const currNode = nextNode;
2444
- nextNode = currNode.nextSibling;
2445
- el.removeChild(currNode);
2446
- }
2447
- }
2448
- $.$mol_dom_render_children = $mol_dom_render_children;
2449
- })($ || ($ = {}));
2450
-
2451
- ;
2452
- "use strict";
2453
-
2454
- ;
2455
- "use strict";
2456
- var $;
2457
- (function ($) {
2458
- $.$mol_jsx_prefix = '';
2459
- $.$mol_jsx_crumbs = '';
2460
- $.$mol_jsx_booked = null;
2461
- $.$mol_jsx_document = {
2462
- getElementById: () => null,
2463
- createElementNS: (space, name) => $mol_dom_context.document.createElementNS(space, name),
2464
- createDocumentFragment: () => $mol_dom_context.document.createDocumentFragment(),
2465
- };
2466
- $.$mol_jsx_frag = '';
2467
- function $mol_jsx(Elem, props, ...childNodes) {
2468
- const id = props && props.id || '';
2469
- const guid = id ? $.$mol_jsx_prefix ? $.$mol_jsx_prefix + '/' + id : id : $.$mol_jsx_prefix;
2470
- const crumbs_self = id ? $.$mol_jsx_crumbs.replace(/(\S+)/g, `$1_${id.replace(/\/.*/i, '')}`) : $.$mol_jsx_crumbs;
2471
- if (Elem && $.$mol_jsx_booked) {
2472
- if ($.$mol_jsx_booked.has(id)) {
2473
- $mol_fail(new Error(`JSX already has tag with id ${JSON.stringify(guid)}`));
2474
- }
2475
- else {
2476
- $.$mol_jsx_booked.add(id);
2477
- }
2478
- }
2479
- let node = guid ? $.$mol_jsx_document.getElementById(guid) : null;
2480
- if ($.$mol_jsx_prefix) {
2481
- const prefix_ext = $.$mol_jsx_prefix;
2482
- const booked_ext = $.$mol_jsx_booked;
2483
- const crumbs_ext = $.$mol_jsx_crumbs;
2484
- for (const field in props) {
2485
- const func = props[field];
2486
- if (typeof func !== 'function')
2487
- continue;
2488
- const wrapper = function (...args) {
2489
- const prefix = $.$mol_jsx_prefix;
2490
- const booked = $.$mol_jsx_booked;
2491
- const crumbs = $.$mol_jsx_crumbs;
2492
- try {
2493
- $.$mol_jsx_prefix = prefix_ext;
2494
- $.$mol_jsx_booked = booked_ext;
2495
- $.$mol_jsx_crumbs = crumbs_ext;
2496
- return func.call(this, ...args);
2497
- }
2498
- finally {
2499
- $.$mol_jsx_prefix = prefix;
2500
- $.$mol_jsx_booked = booked;
2501
- $.$mol_jsx_crumbs = crumbs;
2502
- }
2503
- };
2504
- $mol_func_name_from(wrapper, func);
2505
- props[field] = wrapper;
2506
- }
2507
- }
2508
- if (typeof Elem !== 'string') {
2509
- if ('prototype' in Elem) {
2510
- const view = node && node[String(Elem)] || new Elem;
2511
- Object.assign(view, props);
2512
- view[Symbol.toStringTag] = guid;
2513
- view.childNodes = childNodes;
2514
- if (!view.ownerDocument)
2515
- view.ownerDocument = $.$mol_jsx_document;
2516
- view.className = (crumbs_self ? crumbs_self + ' ' : '') + (Elem['name'] || Elem);
2517
- node = view.valueOf();
2518
- node[String(Elem)] = view;
2519
- return node;
2520
- }
2521
- else {
2522
- const prefix = $.$mol_jsx_prefix;
2523
- const booked = $.$mol_jsx_booked;
2524
- const crumbs = $.$mol_jsx_crumbs;
2525
- try {
2526
- $.$mol_jsx_prefix = guid;
2527
- $.$mol_jsx_booked = new Set;
2528
- $.$mol_jsx_crumbs = (crumbs_self ? crumbs_self + ' ' : '') + (Elem['name'] || Elem);
2529
- return Elem(props, ...childNodes);
2530
- }
2531
- finally {
2532
- $.$mol_jsx_prefix = prefix;
2533
- $.$mol_jsx_booked = booked;
2534
- $.$mol_jsx_crumbs = crumbs;
2535
- }
2536
- }
2537
- }
2538
- if (!node) {
2539
- node = Elem
2540
- ? $.$mol_jsx_document.createElementNS(props?.xmlns ?? 'http://www.w3.org/1999/xhtml', Elem)
2541
- : $.$mol_jsx_document.createDocumentFragment();
2542
- }
2543
- $mol_dom_render_children(node, [].concat(...childNodes));
2544
- if (!Elem)
2545
- return node;
2546
- if (guid)
2547
- node.id = guid;
2548
- for (const key in props) {
2549
- if (key === 'id')
2550
- continue;
2551
- if (typeof props[key] === 'string') {
2552
- if (typeof node[key] === 'string')
2553
- node[key] = props[key];
2554
- node.setAttribute(key, props[key]);
2555
- }
2556
- else if (props[key] &&
2557
- typeof props[key] === 'object' &&
2558
- Reflect.getPrototypeOf(props[key]) === Reflect.getPrototypeOf({})) {
2559
- if (typeof node[key] === 'object') {
2560
- Object.assign(node[key], props[key]);
2561
- continue;
2562
- }
2563
- }
2564
- else {
2565
- node[key] = props[key];
2566
- }
2567
- }
2568
- if ($.$mol_jsx_crumbs)
2569
- node.className = (props?.['class'] ? props['class'] + ' ' : '') + crumbs_self;
2570
- return node;
2571
- }
2572
- $.$mol_jsx = $mol_jsx;
2573
- })($ || ($ = {}));
2574
-
2575
- ;
2576
- "use strict";
2577
- var $;
2578
- (function ($) {
2579
- class $mol_window extends $mol_object {
2580
- static size() {
2581
- return {
2582
- width: 1024,
2583
- height: 768,
2584
- };
2585
- }
2586
- }
2587
- $.$mol_window = $mol_window;
2588
- })($ || ($ = {}));
2589
2350
 
2590
2351
  ;
2591
2352
  "use strict";
@@ -2916,22 +2677,1345 @@ var $;
2916
2677
  "use strict";
2917
2678
  var $;
2918
2679
  (function ($) {
2919
- function $mol_guard_defined(value) {
2920
- return value !== null && value !== undefined;
2921
- }
2922
- $.$mol_guard_defined = $mol_guard_defined;
2680
+ $.$mol_action = $mol_wire_method;
2923
2681
  })($ || ($ = {}));
2924
2682
 
2925
2683
  ;
2926
2684
  "use strict";
2927
2685
  var $;
2928
2686
  (function ($) {
2929
- class $mol_view_selection extends $mol_object {
2930
- static focused(next, notify) {
2931
- const parents = [];
2932
- let element = next?.[0] ?? $mol_dom_context.document.activeElement;
2933
- while (element?.shadowRoot) {
2934
- element = element.shadowRoot.activeElement;
2687
+ class $mol_state_arg extends $mol_object {
2688
+ prefix;
2689
+ static prolog = '';
2690
+ static separator = ' ';
2691
+ static href(next) {
2692
+ return next || process.argv.slice(2).join(' ');
2693
+ }
2694
+ static href_normal() {
2695
+ return this.link({});
2696
+ }
2697
+ static dict(next) {
2698
+ if (next !== void 0)
2699
+ this.href(this.make_link(next));
2700
+ var href = this.href();
2701
+ var chunks = href.split(' ');
2702
+ var params = {};
2703
+ chunks.forEach(chunk => {
2704
+ if (!chunk)
2705
+ return;
2706
+ var vals = chunk.split('=').map(decodeURIComponent);
2707
+ params[vals.shift()] = vals.join('=');
2708
+ });
2709
+ return params;
2710
+ }
2711
+ static value(key, next) {
2712
+ if (next === void 0)
2713
+ return this.dict()[key] ?? null;
2714
+ this.href(this.link({ [key]: next }));
2715
+ return next;
2716
+ }
2717
+ static link(next) {
2718
+ const params = {};
2719
+ var prev = this.dict();
2720
+ for (var key in prev) {
2721
+ params[key] = prev[key];
2722
+ }
2723
+ for (var key in next) {
2724
+ params[key] = next[key];
2725
+ }
2726
+ return this.make_link(params);
2727
+ }
2728
+ static make_link(next) {
2729
+ const chunks = [];
2730
+ for (const key in next) {
2731
+ if (next[key] !== null) {
2732
+ chunks.push([key, next[key]].map(encodeURIComponent).join('='));
2733
+ }
2734
+ }
2735
+ return chunks.join(' ');
2736
+ }
2737
+ static go(next) {
2738
+ this.href(this.link(next));
2739
+ }
2740
+ static commit() { }
2741
+ constructor(prefix = '') {
2742
+ super();
2743
+ this.prefix = prefix;
2744
+ }
2745
+ value(key, next) {
2746
+ return this.constructor.value(this.prefix + key, next);
2747
+ }
2748
+ sub(postfix) {
2749
+ return new this.constructor(this.prefix + postfix + '.');
2750
+ }
2751
+ link(next) {
2752
+ const prefix = this.prefix;
2753
+ const dict = {};
2754
+ for (var key in next) {
2755
+ dict[prefix + key] = next[key];
2756
+ }
2757
+ return this.constructor.link(dict);
2758
+ }
2759
+ }
2760
+ __decorate([
2761
+ $mol_mem
2762
+ ], $mol_state_arg, "href", null);
2763
+ __decorate([
2764
+ $mol_mem
2765
+ ], $mol_state_arg, "href_normal", null);
2766
+ __decorate([
2767
+ $mol_mem
2768
+ ], $mol_state_arg, "dict", null);
2769
+ __decorate([
2770
+ $mol_mem_key
2771
+ ], $mol_state_arg, "value", null);
2772
+ __decorate([
2773
+ $mol_action
2774
+ ], $mol_state_arg, "go", null);
2775
+ $.$mol_state_arg = $mol_state_arg;
2776
+ })($ || ($ = {}));
2777
+
2778
+ ;
2779
+ "use strict";
2780
+ var $;
2781
+ (function ($) {
2782
+ class $mol_media extends $mol_object2 {
2783
+ static match(query, next) {
2784
+ if (next !== undefined)
2785
+ return next;
2786
+ const res = this.$.$mol_dom_context.matchMedia?.(query) ?? {};
2787
+ res.onchange = () => this.match(query, res.matches);
2788
+ return res.matches;
2789
+ }
2790
+ }
2791
+ __decorate([
2792
+ $mol_mem_key
2793
+ ], $mol_media, "match", null);
2794
+ $.$mol_media = $mol_media;
2795
+ })($ || ($ = {}));
2796
+
2797
+ ;
2798
+ "use strict";
2799
+ var $;
2800
+ (function ($) {
2801
+ function $mol_wire_solid() {
2802
+ let current = $mol_wire_auto();
2803
+ if (current.temp)
2804
+ current = current.host;
2805
+ if (current.reap !== nothing) {
2806
+ current?.sub_on(sub, sub.data.length);
2807
+ }
2808
+ current.reap = nothing;
2809
+ }
2810
+ $.$mol_wire_solid = $mol_wire_solid;
2811
+ const nothing = () => { };
2812
+ const sub = new $mol_wire_pub_sub;
2813
+ })($ || ($ = {}));
2814
+
2815
+ ;
2816
+ "use strict";
2817
+ var $;
2818
+ (function ($) {
2819
+ $.$mol_mem_persist = $mol_wire_solid;
2820
+ })($ || ($ = {}));
2821
+
2822
+ ;
2823
+ "use strict";
2824
+ var $;
2825
+ (function ($) {
2826
+ function $mol_wire_probe(task, def) {
2827
+ const warm = $mol_wire_fiber.warm;
2828
+ try {
2829
+ $mol_wire_fiber.warm = false;
2830
+ const res = task();
2831
+ if (res === undefined)
2832
+ return def;
2833
+ return res;
2834
+ }
2835
+ finally {
2836
+ $mol_wire_fiber.warm = warm;
2837
+ }
2838
+ }
2839
+ $.$mol_wire_probe = $mol_wire_probe;
2840
+ })($ || ($ = {}));
2841
+
2842
+ ;
2843
+ "use strict";
2844
+ var $;
2845
+ (function ($) {
2846
+ $.$mol_mem_cached = $mol_wire_probe;
2847
+ })($ || ($ = {}));
2848
+
2849
+ ;
2850
+ "use strict";
2851
+ var $;
2852
+ (function ($) {
2853
+ class $mol_storage extends $mol_object2 {
2854
+ static native() {
2855
+ return this.$.$mol_dom_context.navigator.storage ?? {
2856
+ persisted: async () => false,
2857
+ persist: async () => false,
2858
+ estimate: async () => ({}),
2859
+ getDirectory: async () => null,
2860
+ };
2861
+ }
2862
+ static persisted(next, cache) {
2863
+ $mol_mem_persist();
2864
+ if (cache)
2865
+ return Boolean(next);
2866
+ const native = this.native();
2867
+ if (next && !$mol_mem_cached(() => this.persisted())) {
2868
+ native.persist().then(actual => {
2869
+ setTimeout(() => this.persisted(actual, 'cache'), 5000);
2870
+ if (actual)
2871
+ this.$.$mol_log3_done({ place: `$mol_storage`, message: `Persist: Yes` });
2872
+ else
2873
+ this.$.$mol_log3_fail({ place: `$mol_storage`, message: `Persist: No` });
2874
+ });
2875
+ }
2876
+ return next ?? $mol_wire_sync(native).persisted();
2877
+ }
2878
+ static estimate() {
2879
+ return $mol_wire_sync(this.native() ?? {}).estimate();
2880
+ }
2881
+ static dir() {
2882
+ return $mol_wire_sync(this.native()).getDirectory();
2883
+ }
2884
+ }
2885
+ __decorate([
2886
+ $mol_mem
2887
+ ], $mol_storage, "native", null);
2888
+ __decorate([
2889
+ $mol_mem
2890
+ ], $mol_storage, "persisted", null);
2891
+ $.$mol_storage = $mol_storage;
2892
+ })($ || ($ = {}));
2893
+
2894
+ ;
2895
+ "use strict";
2896
+ var $;
2897
+ (function ($) {
2898
+ class $mol_state_local extends $mol_object {
2899
+ static 'native()';
2900
+ static native() {
2901
+ if (this['native()'])
2902
+ return this['native()'];
2903
+ check: try {
2904
+ const native = $mol_dom_context.localStorage;
2905
+ if (!native)
2906
+ break check;
2907
+ native.setItem('', '');
2908
+ native.removeItem('');
2909
+ return this['native()'] = native;
2910
+ }
2911
+ catch (error) {
2912
+ console.warn(error);
2913
+ }
2914
+ return this['native()'] = {
2915
+ getItem(key) {
2916
+ return this[':' + key];
2917
+ },
2918
+ setItem(key, value) {
2919
+ this[':' + key] = value;
2920
+ },
2921
+ removeItem(key) {
2922
+ this[':' + key] = void 0;
2923
+ }
2924
+ };
2925
+ }
2926
+ static changes(next) { return next; }
2927
+ static value(key, next) {
2928
+ this.changes();
2929
+ if (next === void 0)
2930
+ return JSON.parse(this.native().getItem(key) || 'null');
2931
+ if (next === null) {
2932
+ this.native().removeItem(key);
2933
+ }
2934
+ else {
2935
+ this.native().setItem(key, JSON.stringify(next));
2936
+ this.$.$mol_storage.persisted(true);
2937
+ }
2938
+ return next;
2939
+ }
2940
+ prefix() { return ''; }
2941
+ value(key, next) {
2942
+ return $mol_state_local.value(this.prefix() + '.' + key, next);
2943
+ }
2944
+ }
2945
+ __decorate([
2946
+ $mol_mem
2947
+ ], $mol_state_local, "changes", null);
2948
+ __decorate([
2949
+ $mol_mem_key
2950
+ ], $mol_state_local, "value", null);
2951
+ $.$mol_state_local = $mol_state_local;
2952
+ })($ || ($ = {}));
2953
+
2954
+ ;
2955
+ "use strict";
2956
+ var $;
2957
+ (function ($) {
2958
+ function $mol_const(value) {
2959
+ const getter = (() => value);
2960
+ getter['()'] = value;
2961
+ getter[Symbol.toStringTag] = value;
2962
+ getter[$mol_dev_format_head] = () => $mol_dev_format_span({}, '()=> ', $mol_dev_format_auto(value));
2963
+ return getter;
2964
+ }
2965
+ $.$mol_const = $mol_const;
2966
+ })($ || ($ = {}));
2967
+
2968
+ ;
2969
+ "use strict";
2970
+ var $;
2971
+ (function ($) {
2972
+ function $mol_wire_async(obj) {
2973
+ let fiber;
2974
+ const temp = $mol_wire_task.getter(obj);
2975
+ return new Proxy(obj, {
2976
+ get(obj, field) {
2977
+ const val = obj[field];
2978
+ if (typeof val !== 'function')
2979
+ return val;
2980
+ let fiber;
2981
+ const temp = $mol_wire_task.getter(val);
2982
+ return function $mol_wire_async(...args) {
2983
+ fiber?.destructor();
2984
+ fiber = temp(obj, args);
2985
+ return fiber.async();
2986
+ };
2987
+ },
2988
+ apply(obj, self, args) {
2989
+ fiber?.destructor();
2990
+ fiber = temp(self, args);
2991
+ return fiber.async();
2992
+ },
2993
+ });
2994
+ }
2995
+ $.$mol_wire_async = $mol_wire_async;
2996
+ })($ || ($ = {}));
2997
+
2998
+ ;
2999
+ "use strict";
3000
+ var $;
3001
+ (function ($) {
3002
+ class $mol_lock extends $mol_object {
3003
+ promise = null;
3004
+ async wait() {
3005
+ let next = () => { };
3006
+ let destructed = false;
3007
+ const task = $mol_wire_auto();
3008
+ if (!task)
3009
+ return next;
3010
+ const destructor = task.destructor.bind(task);
3011
+ task.destructor = () => {
3012
+ destructor();
3013
+ destructed = true;
3014
+ next();
3015
+ };
3016
+ let promise;
3017
+ do {
3018
+ promise = this.promise;
3019
+ await promise;
3020
+ if (destructed)
3021
+ return next;
3022
+ } while (promise !== this.promise);
3023
+ this.promise = new Promise(done => { next = done; });
3024
+ return next;
3025
+ }
3026
+ grab() { return $mol_wire_sync(this).wait(); }
3027
+ }
3028
+ $.$mol_lock = $mol_lock;
3029
+ })($ || ($ = {}));
3030
+
3031
+ ;
3032
+ "use strict";
3033
+ var $;
3034
+ (function ($) {
3035
+ function $mol_compare_array(a, b) {
3036
+ if (a === b)
3037
+ return true;
3038
+ if (Object.getPrototypeOf(a) !== Object.getPrototypeOf(b))
3039
+ return false;
3040
+ if (a.length !== b.length)
3041
+ return false;
3042
+ for (let i = 0; i < a.length; i++)
3043
+ if (a[i] !== b[i])
3044
+ return false;
3045
+ return true;
3046
+ }
3047
+ $.$mol_compare_array = $mol_compare_array;
3048
+ })($ || ($ = {}));
3049
+
3050
+ ;
3051
+ "use strict";
3052
+
3053
+ ;
3054
+ "use strict";
3055
+ var $;
3056
+ (function ($) {
3057
+ const decoders = {};
3058
+ function $mol_charset_decode(buffer, encoding = 'utf8') {
3059
+ let decoder = decoders[encoding];
3060
+ if (!decoder)
3061
+ decoder = decoders[encoding] = new TextDecoder(encoding);
3062
+ return decoder.decode(buffer);
3063
+ }
3064
+ $.$mol_charset_decode = $mol_charset_decode;
3065
+ })($ || ($ = {}));
3066
+
3067
+ ;
3068
+ "use strict";
3069
+ var $;
3070
+ (function ($) {
3071
+ const TextEncoder = globalThis.TextEncoder ?? $node.util.TextEncoder;
3072
+ const encoder = new TextEncoder();
3073
+ function $mol_charset_encode(value) {
3074
+ return encoder.encode(value);
3075
+ }
3076
+ $.$mol_charset_encode = $mol_charset_encode;
3077
+ })($ || ($ = {}));
3078
+
3079
+ ;
3080
+ "use strict";
3081
+ var $;
3082
+ (function ($) {
3083
+ class $mol_file_transaction extends $mol_object {
3084
+ path() { return ''; }
3085
+ modes() { return []; }
3086
+ write(options) {
3087
+ return 0;
3088
+ }
3089
+ read() {
3090
+ return new Uint8Array();
3091
+ }
3092
+ truncate(size) { }
3093
+ close() { }
3094
+ destructor() {
3095
+ this.close();
3096
+ }
3097
+ }
3098
+ $.$mol_file_transaction = $mol_file_transaction;
3099
+ })($ || ($ = {}));
3100
+
3101
+ ;
3102
+ "use strict";
3103
+ var $;
3104
+ (function ($) {
3105
+ let file_modes;
3106
+ (function (file_modes) {
3107
+ file_modes[file_modes["create"] = $node.fs.constants.O_CREAT] = "create";
3108
+ file_modes[file_modes["exists_truncate"] = $node.fs.constants.O_TRUNC] = "exists_truncate";
3109
+ file_modes[file_modes["exists_fail"] = $node.fs.constants.O_EXCL] = "exists_fail";
3110
+ file_modes[file_modes["read_only"] = $node.fs.constants.O_RDONLY] = "read_only";
3111
+ file_modes[file_modes["write_only"] = $node.fs.constants.O_WRONLY] = "write_only";
3112
+ file_modes[file_modes["read_write"] = $node.fs.constants.O_RDWR] = "read_write";
3113
+ file_modes[file_modes["append"] = $node.fs.constants.O_APPEND] = "append";
3114
+ })(file_modes || (file_modes = {}));
3115
+ function mode_mask(modes) {
3116
+ return modes.reduce((res, mode) => res | file_modes[mode], 0);
3117
+ }
3118
+ class $mol_file_transaction_node extends $mol_file_transaction {
3119
+ descr() {
3120
+ $mol_wire_solid();
3121
+ return $node.fs.openSync(this.path(), mode_mask(this.modes()));
3122
+ }
3123
+ write({ buffer, offset = 0, length, position = null }) {
3124
+ if (Array.isArray(buffer)) {
3125
+ return $node.fs.writevSync(this.descr(), buffer, position ?? undefined);
3126
+ }
3127
+ if (typeof buffer === 'string') {
3128
+ return $node.fs.writeSync(this.descr(), buffer, position);
3129
+ }
3130
+ length = length ?? buffer.byteLength;
3131
+ return $node.fs.writeSync(this.descr(), buffer, offset, length, position);
3132
+ }
3133
+ truncate(size) {
3134
+ $node.fs.ftruncateSync(this.descr());
3135
+ }
3136
+ read() {
3137
+ return $mol_file_node_buffer_normalize($node.fs.readFileSync(this.descr()));
3138
+ }
3139
+ close() {
3140
+ $node.fs.closeSync(this.descr());
3141
+ }
3142
+ }
3143
+ __decorate([
3144
+ $mol_mem
3145
+ ], $mol_file_transaction_node.prototype, "descr", null);
3146
+ $.$mol_file_transaction_node = $mol_file_transaction_node;
3147
+ $.$mol_file_transaction = $mol_file_transaction_node;
3148
+ })($ || ($ = {}));
3149
+
3150
+ ;
3151
+ "use strict";
3152
+ var $;
3153
+ (function ($) {
3154
+ class $mol_file_base extends $mol_object {
3155
+ static absolute(path) {
3156
+ return this.make({
3157
+ path: $mol_const(path)
3158
+ });
3159
+ }
3160
+ static relative(path) {
3161
+ throw new Error('Not implemented yet');
3162
+ }
3163
+ static base = '';
3164
+ path() {
3165
+ return '.';
3166
+ }
3167
+ parent() {
3168
+ return this.resolve('..');
3169
+ }
3170
+ exists_cut() { return this.exists(); }
3171
+ root() {
3172
+ const path = this.path();
3173
+ const base = this.constructor.base;
3174
+ return base.startsWith(path) || this == this.parent();
3175
+ }
3176
+ stat(next, virt) {
3177
+ const path = this.path();
3178
+ const parent = this.parent();
3179
+ if (!this.root()) {
3180
+ parent.version();
3181
+ }
3182
+ parent.watcher();
3183
+ if (virt)
3184
+ return next ?? null;
3185
+ return next ?? this.info(path);
3186
+ }
3187
+ static changed = new Set;
3188
+ static frame = null;
3189
+ static changed_add(type, path) {
3190
+ if (/([\/\\]\.|___$)/.test(path))
3191
+ return;
3192
+ const file = this.relative(path.at(-1) === '/' ? path.slice(0, -1) : path);
3193
+ this.changed.add(file);
3194
+ if (!this.watching)
3195
+ return;
3196
+ this.frame?.destructor();
3197
+ this.frame = new this.$.$mol_after_timeout(this.watch_debounce(), () => {
3198
+ if (!this.watching)
3199
+ return;
3200
+ this.watching = false;
3201
+ $mol_wire_async(this).flush();
3202
+ });
3203
+ }
3204
+ static watch_debounce() { return 500; }
3205
+ static flush() {
3206
+ for (const file of this.changed) {
3207
+ const parent = file.parent();
3208
+ try {
3209
+ if ($mol_wire_probe(() => parent.sub()))
3210
+ parent.sub(null);
3211
+ file.reset();
3212
+ }
3213
+ catch (error) {
3214
+ if ($mol_fail_catch(error))
3215
+ $mol_fail_log(error);
3216
+ }
3217
+ }
3218
+ this.changed.clear();
3219
+ this.watching = true;
3220
+ }
3221
+ static watching = true;
3222
+ static lock = new $mol_lock;
3223
+ static watch_off(path) {
3224
+ this.watching = false;
3225
+ this.flush();
3226
+ this.watching = false;
3227
+ this.changed.add(this.absolute(path));
3228
+ }
3229
+ static unwatched(side_effect, affected_dir) {
3230
+ const unlock = this.lock.grab();
3231
+ this.watch_off(affected_dir);
3232
+ try {
3233
+ const result = side_effect();
3234
+ this.flush();
3235
+ unlock();
3236
+ return result;
3237
+ }
3238
+ catch (e) {
3239
+ if (!$mol_promise_like(e)) {
3240
+ this.flush();
3241
+ unlock();
3242
+ }
3243
+ $mol_fail_hidden(e);
3244
+ }
3245
+ }
3246
+ reset() {
3247
+ this.stat(null);
3248
+ }
3249
+ modified() { return this.stat()?.mtime ?? null; }
3250
+ version() {
3251
+ const next = this.stat()?.mtime.getTime().toString(36).toUpperCase() ?? '';
3252
+ return next;
3253
+ }
3254
+ info(path) { return null; }
3255
+ ensure() { }
3256
+ drop() { }
3257
+ copy(to) { }
3258
+ read() { return new Uint8Array; }
3259
+ write(buffer) { }
3260
+ kids() {
3261
+ return [];
3262
+ }
3263
+ readable(opts) {
3264
+ return new ReadableStream;
3265
+ }
3266
+ writable(opts) {
3267
+ return new WritableStream;
3268
+ }
3269
+ buffer(next) {
3270
+ let readed = new Uint8Array();
3271
+ if (next === undefined) {
3272
+ if (this.version())
3273
+ readed = this.read();
3274
+ }
3275
+ const prev = $mol_mem_cached(() => this.buffer());
3276
+ const changed = prev === undefined || !$mol_compare_array(prev, next ?? readed);
3277
+ if (prev !== undefined && changed) {
3278
+ this.$.$mol_log3_rise({
3279
+ place: `$mol_file_node.buffer()`,
3280
+ message: 'Changed',
3281
+ path: this.relate(),
3282
+ });
3283
+ }
3284
+ if (next === undefined)
3285
+ return changed ? readed : prev;
3286
+ if (!changed && this.exists())
3287
+ return prev;
3288
+ this.parent().exists(true);
3289
+ this.stat(this.stat_make(next.length), 'virt');
3290
+ this.write(next);
3291
+ return next;
3292
+ }
3293
+ stat_make(size) {
3294
+ const now = new Date();
3295
+ return {
3296
+ type: 'file',
3297
+ size,
3298
+ atime: now,
3299
+ mtime: now,
3300
+ ctime: now,
3301
+ };
3302
+ }
3303
+ clone(to) {
3304
+ if (!this.exists())
3305
+ return null;
3306
+ const target = this.constructor.absolute(to);
3307
+ try {
3308
+ this.version();
3309
+ target.parent().exists(true);
3310
+ this.copy(to);
3311
+ target.reset();
3312
+ return target;
3313
+ }
3314
+ catch (error) {
3315
+ if ($mol_fail_catch(error)) {
3316
+ console.error(error);
3317
+ }
3318
+ }
3319
+ return null;
3320
+ }
3321
+ watcher() {
3322
+ return {
3323
+ destructor() { }
3324
+ };
3325
+ }
3326
+ exists(next) {
3327
+ const exists = Boolean(this.stat());
3328
+ if (next === undefined)
3329
+ return exists;
3330
+ if (next === exists)
3331
+ return exists;
3332
+ if (next) {
3333
+ this.parent().exists(true);
3334
+ this.ensure();
3335
+ }
3336
+ else {
3337
+ this.drop();
3338
+ }
3339
+ this.reset();
3340
+ return next;
3341
+ }
3342
+ type() {
3343
+ return this.stat()?.type ?? '';
3344
+ }
3345
+ name() {
3346
+ return this.path().replace(/^.*\//, '');
3347
+ }
3348
+ ext() {
3349
+ const match = /((?:\.\w+)+)$/.exec(this.path());
3350
+ return match ? match[1].substring(1) : '';
3351
+ }
3352
+ text(next, virt) {
3353
+ if (next !== undefined)
3354
+ this.exists();
3355
+ return this.text_int(next, virt);
3356
+ }
3357
+ text_int(next, virt) {
3358
+ if (virt) {
3359
+ this.stat(this.stat_make(0), 'virt');
3360
+ return next;
3361
+ }
3362
+ if (next === undefined) {
3363
+ return $mol_charset_decode(this.buffer());
3364
+ }
3365
+ else {
3366
+ const buffer = $mol_charset_encode(next);
3367
+ this.buffer(buffer);
3368
+ return next;
3369
+ }
3370
+ }
3371
+ sub(reset) {
3372
+ if (!this.exists())
3373
+ return [];
3374
+ if (this.type() !== 'dir')
3375
+ return [];
3376
+ this.version();
3377
+ return this.kids().filter(file => file.exists());
3378
+ }
3379
+ resolve(path) {
3380
+ throw new Error('implement');
3381
+ }
3382
+ relate(base = this.constructor.relative('.')) {
3383
+ const base_path = base.path();
3384
+ const path = this.path();
3385
+ return path.startsWith(base_path) ? path.slice(base_path.length) : path;
3386
+ }
3387
+ find(include, exclude) {
3388
+ const found = [];
3389
+ const sub = this.sub();
3390
+ for (const child of sub) {
3391
+ const child_path = child.path();
3392
+ if (exclude && child_path.match(exclude))
3393
+ continue;
3394
+ if (!include || child_path.match(include))
3395
+ found.push(child);
3396
+ if (child.type() === 'dir') {
3397
+ const sub_child = child.find(include, exclude);
3398
+ for (const child of sub_child)
3399
+ found.push(child);
3400
+ }
3401
+ }
3402
+ return found;
3403
+ }
3404
+ size() {
3405
+ switch (this.type()) {
3406
+ case 'file': return this.stat()?.size ?? 0;
3407
+ default: return 0;
3408
+ }
3409
+ }
3410
+ toJSON() {
3411
+ return this.path();
3412
+ }
3413
+ open(...modes) {
3414
+ return this.$.$mol_file_transaction.make({
3415
+ path: () => this.path(),
3416
+ modes: () => modes
3417
+ });
3418
+ }
3419
+ }
3420
+ __decorate([
3421
+ $mol_action
3422
+ ], $mol_file_base.prototype, "exists_cut", null);
3423
+ __decorate([
3424
+ $mol_mem
3425
+ ], $mol_file_base.prototype, "stat", null);
3426
+ __decorate([
3427
+ $mol_mem
3428
+ ], $mol_file_base.prototype, "modified", null);
3429
+ __decorate([
3430
+ $mol_mem
3431
+ ], $mol_file_base.prototype, "version", null);
3432
+ __decorate([
3433
+ $mol_mem_key
3434
+ ], $mol_file_base.prototype, "readable", null);
3435
+ __decorate([
3436
+ $mol_mem_key
3437
+ ], $mol_file_base.prototype, "writable", null);
3438
+ __decorate([
3439
+ $mol_mem
3440
+ ], $mol_file_base.prototype, "buffer", null);
3441
+ __decorate([
3442
+ $mol_action
3443
+ ], $mol_file_base.prototype, "stat_make", null);
3444
+ __decorate([
3445
+ $mol_mem_key
3446
+ ], $mol_file_base.prototype, "clone", null);
3447
+ __decorate([
3448
+ $mol_mem
3449
+ ], $mol_file_base.prototype, "exists", null);
3450
+ __decorate([
3451
+ $mol_mem
3452
+ ], $mol_file_base.prototype, "type", null);
3453
+ __decorate([
3454
+ $mol_mem
3455
+ ], $mol_file_base.prototype, "text_int", null);
3456
+ __decorate([
3457
+ $mol_mem
3458
+ ], $mol_file_base.prototype, "sub", null);
3459
+ __decorate([
3460
+ $mol_mem
3461
+ ], $mol_file_base.prototype, "size", null);
3462
+ __decorate([
3463
+ $mol_action
3464
+ ], $mol_file_base.prototype, "open", null);
3465
+ __decorate([
3466
+ $mol_mem_key
3467
+ ], $mol_file_base, "absolute", null);
3468
+ __decorate([
3469
+ $mol_action
3470
+ ], $mol_file_base, "flush", null);
3471
+ __decorate([
3472
+ $mol_action
3473
+ ], $mol_file_base, "watch_off", null);
3474
+ $.$mol_file_base = $mol_file_base;
3475
+ })($ || ($ = {}));
3476
+
3477
+ ;
3478
+ "use strict";
3479
+ var $;
3480
+ (function ($) {
3481
+ class $mol_file extends $mol_file_base {
3482
+ }
3483
+ $.$mol_file = $mol_file;
3484
+ })($ || ($ = {}));
3485
+
3486
+ ;
3487
+ "use strict";
3488
+ var $;
3489
+ (function ($) {
3490
+ function stat_convert(stat) {
3491
+ if (!stat)
3492
+ return null;
3493
+ let type;
3494
+ if (stat.isDirectory())
3495
+ type = 'dir';
3496
+ if (stat.isFile())
3497
+ type = 'file';
3498
+ if (stat.isSymbolicLink())
3499
+ type = 'link';
3500
+ if (!type)
3501
+ return $mol_fail(new Error(`Unsupported file type`));
3502
+ return {
3503
+ type,
3504
+ size: Number(stat.size),
3505
+ atime: stat.atime,
3506
+ mtime: stat.mtime,
3507
+ ctime: stat.ctime
3508
+ };
3509
+ }
3510
+ function $mol_file_node_buffer_normalize(buf) {
3511
+ return new Uint8Array(buf.buffer, buf.byteOffset, buf.byteLength);
3512
+ }
3513
+ $.$mol_file_node_buffer_normalize = $mol_file_node_buffer_normalize;
3514
+ class $mol_file_node extends $mol_file {
3515
+ static relative(path) {
3516
+ return this.absolute($node.path.resolve(this.base, path).replace(/\\/g, '/'));
3517
+ }
3518
+ watcher(reset) {
3519
+ const path = this.path();
3520
+ const root = this.root();
3521
+ if (!root && !this.exists())
3522
+ return super.watcher();
3523
+ let watcher;
3524
+ try {
3525
+ watcher = $node.fs.watch(path);
3526
+ }
3527
+ catch (error) {
3528
+ if (!(error instanceof Error))
3529
+ error = new Error('Unknown watch error', { cause: error });
3530
+ error.message += '\n' + path;
3531
+ if (root || error.code !== 'ENOENT') {
3532
+ this.$.$mol_fail_log(error);
3533
+ }
3534
+ return super.watcher();
3535
+ }
3536
+ watcher.on('change', (type, name) => {
3537
+ if (!name)
3538
+ return;
3539
+ const path = $node.path.join(this.path(), name.toString());
3540
+ this.constructor.changed_add(type, path);
3541
+ });
3542
+ watcher.on('error', e => this.$.$mol_fail_log(e));
3543
+ let destructed = false;
3544
+ watcher.on('close', () => {
3545
+ if (!destructed)
3546
+ setTimeout(() => $mol_wire_async(this).watcher(null), 500);
3547
+ });
3548
+ return {
3549
+ destructor() {
3550
+ destructed = true;
3551
+ watcher.close();
3552
+ }
3553
+ };
3554
+ }
3555
+ info(path) {
3556
+ try {
3557
+ return stat_convert($node.fs.statSync(path));
3558
+ }
3559
+ catch (error) {
3560
+ if (this.$.$mol_fail_catch(error)) {
3561
+ if (error.code === 'ENOENT')
3562
+ return null;
3563
+ error.message += '\n' + path;
3564
+ this.$.$mol_fail_hidden(error);
3565
+ }
3566
+ }
3567
+ return null;
3568
+ }
3569
+ ensure() {
3570
+ const path = this.path();
3571
+ try {
3572
+ $node.fs.mkdirSync(path, { recursive: true });
3573
+ return null;
3574
+ }
3575
+ catch (e) {
3576
+ if (this.$.$mol_fail_catch(e)) {
3577
+ if (e.code === 'EEXIST')
3578
+ return null;
3579
+ e.message += '\n' + path;
3580
+ this.$.$mol_fail_hidden(e);
3581
+ }
3582
+ }
3583
+ }
3584
+ copy(to) {
3585
+ $node.fs.copyFileSync(this.path(), to);
3586
+ }
3587
+ drop() {
3588
+ $node.fs.unlinkSync(this.path());
3589
+ }
3590
+ read() {
3591
+ const path = this.path();
3592
+ try {
3593
+ return $mol_file_node_buffer_normalize($node.fs.readFileSync(path));
3594
+ }
3595
+ catch (error) {
3596
+ if (!$mol_promise_like(error)) {
3597
+ error.message += '\n' + path;
3598
+ }
3599
+ $mol_fail_hidden(error);
3600
+ }
3601
+ }
3602
+ write(buffer) {
3603
+ const path = this.path();
3604
+ try {
3605
+ $node.fs.writeFileSync(path, buffer);
3606
+ }
3607
+ catch (error) {
3608
+ if (this.$.$mol_fail_catch(error)) {
3609
+ error.message += '\n' + path;
3610
+ }
3611
+ return this.$.$mol_fail_hidden(error);
3612
+ }
3613
+ }
3614
+ kids() {
3615
+ const path = this.path();
3616
+ try {
3617
+ const kids = $node.fs.readdirSync(path)
3618
+ .filter(name => !/^\.+$/.test(name))
3619
+ .map(name => this.resolve(name));
3620
+ return kids;
3621
+ }
3622
+ catch (e) {
3623
+ if (this.$.$mol_fail_catch(e)) {
3624
+ if (e.code === 'ENOENT')
3625
+ return [];
3626
+ e.message += '\n' + path;
3627
+ }
3628
+ $mol_fail_hidden(e);
3629
+ }
3630
+ }
3631
+ resolve(path) {
3632
+ return this.constructor
3633
+ .relative($node.path.join(this.path(), path));
3634
+ }
3635
+ relate(base = this.constructor.relative('.')) {
3636
+ return $node.path.relative(base.path(), this.path()).replace(/\\/g, '/');
3637
+ }
3638
+ readable(opts) {
3639
+ const { Readable } = $node['node:stream'];
3640
+ const stream = $node.fs.createReadStream(this.path(), {
3641
+ flags: 'r',
3642
+ autoClose: true,
3643
+ start: opts?.start,
3644
+ end: opts?.end,
3645
+ encoding: 'binary',
3646
+ });
3647
+ return Readable.toWeb(stream);
3648
+ }
3649
+ writable(opts) {
3650
+ const { Writable } = $node['node:stream'];
3651
+ const stream = $node.fs.createWriteStream(this.path(), {
3652
+ flags: 'w+',
3653
+ autoClose: true,
3654
+ start: opts?.start,
3655
+ encoding: 'binary',
3656
+ });
3657
+ return Writable.toWeb(stream);
3658
+ }
3659
+ }
3660
+ __decorate([
3661
+ $mol_mem
3662
+ ], $mol_file_node.prototype, "watcher", null);
3663
+ __decorate([
3664
+ $mol_action
3665
+ ], $mol_file_node.prototype, "info", null);
3666
+ __decorate([
3667
+ $mol_action
3668
+ ], $mol_file_node.prototype, "ensure", null);
3669
+ __decorate([
3670
+ $mol_action
3671
+ ], $mol_file_node.prototype, "copy", null);
3672
+ __decorate([
3673
+ $mol_action
3674
+ ], $mol_file_node.prototype, "drop", null);
3675
+ __decorate([
3676
+ $mol_action
3677
+ ], $mol_file_node.prototype, "read", null);
3678
+ __decorate([
3679
+ $mol_action
3680
+ ], $mol_file_node.prototype, "write", null);
3681
+ __decorate([
3682
+ $mol_mem_key
3683
+ ], $mol_file_node.prototype, "readable", null);
3684
+ __decorate([
3685
+ $mol_mem
3686
+ ], $mol_file_node.prototype, "writable", null);
3687
+ $.$mol_file_node = $mol_file_node;
3688
+ $.$mol_file = $mol_file_node;
3689
+ })($ || ($ = {}));
3690
+
3691
+ ;
3692
+ "use strict";
3693
+ var $;
3694
+ (function ($) {
3695
+ class $mol_state_local_node extends $mol_state_local {
3696
+ static dir() {
3697
+ const base = process.env.XDG_DATA_HOME || ($node.os.homedir() + '/.local/share');
3698
+ return $mol_file.absolute(base).resolve('./mol_state_local');
3699
+ }
3700
+ static value(key, next) {
3701
+ const file = this.dir().resolve(encodeURIComponent(key) + '.json');
3702
+ if (next === null) {
3703
+ file.exists(false);
3704
+ return null;
3705
+ }
3706
+ const arg = next === undefined ? undefined : JSON.stringify(next);
3707
+ return JSON.parse(file.text(arg) || 'null');
3708
+ }
3709
+ }
3710
+ __decorate([
3711
+ $mol_mem
3712
+ ], $mol_state_local_node, "dir", null);
3713
+ __decorate([
3714
+ $mol_mem_key
3715
+ ], $mol_state_local_node, "value", null);
3716
+ $.$mol_state_local_node = $mol_state_local_node;
3717
+ $.$mol_state_local = $mol_state_local_node;
3718
+ })($ || ($ = {}));
3719
+
3720
+ ;
3721
+ "use strict";
3722
+ var $;
3723
+ (function ($) {
3724
+ function parse(theme) {
3725
+ if (theme === 'true')
3726
+ return true;
3727
+ if (theme === 'false')
3728
+ return false;
3729
+ return null;
3730
+ }
3731
+ function $mol_lights(next) {
3732
+ const arg = parse(this.$mol_state_arg.value('mol_lights'));
3733
+ const base = this.$mol_media.match('(prefers-color-scheme: light)');
3734
+ if (next === undefined) {
3735
+ return arg ?? this.$mol_state_local.value('$mol_lights') ?? base;
3736
+ }
3737
+ else {
3738
+ if (arg === null) {
3739
+ this.$mol_state_local.value('$mol_lights', next === base ? null : next);
3740
+ }
3741
+ else {
3742
+ this.$mol_state_arg.value('mol_lights', String(next));
3743
+ }
3744
+ return next;
3745
+ }
3746
+ }
3747
+ $.$mol_lights = $mol_lights;
3748
+ })($ || ($ = {}));
3749
+
3750
+ ;
3751
+ "use strict";
3752
+ var $;
3753
+ (function ($) {
3754
+ $.$mol_theme = $mol_style_prop('mol_theme', [
3755
+ 'back',
3756
+ 'hover',
3757
+ 'card',
3758
+ 'current',
3759
+ 'special',
3760
+ 'text',
3761
+ 'control',
3762
+ 'shade',
3763
+ 'line',
3764
+ 'focus',
3765
+ 'field',
3766
+ 'image',
3767
+ 'spirit',
3768
+ ]);
3769
+ })($ || ($ = {}));
3770
+
3771
+ ;
3772
+ "use strict";
3773
+ var $;
3774
+ (function ($) {
3775
+ $mol_style_attach("mol/theme/theme.css", ":root {\n\t--mol_theme_hue: 240deg;\n\t--mol_theme_hue_spread: 90deg;\n\tcolor-scheme: dark light;\n}\n\n:where([mol_theme]) {\n\tcolor: var(--mol_theme_text);\n\tfill: var(--mol_theme_text);\n\tbackground-color: var(--mol_theme_back);\n}\n\t\n:root, [mol_theme=\"$mol_theme_dark\"], :where([mol_theme=\"$mol_theme_dark\"]) [mol_theme] {\n\n\t--mol_theme_luma: -1;\n\t--mol_theme_image: invert(1) hue-rotate( 180deg );\n\t--mol_theme_spirit: hsl( 0deg, 0%, 0%, .75 );\n\n\t--mol_theme_back: hsl( var(--mol_theme_hue), 20%, 10% );\n\t--mol_theme_card: hsl( var(--mol_theme_hue), 50%, 20%, .25 );\n\t--mol_theme_field: hsl( var(--mol_theme_hue), 50%, 8%, .25 );\n\t--mol_theme_hover: hsl( var(--mol_theme_hue), 0%, 50%, .1 );\n\t\n\t--mol_theme_text: hsl( var(--mol_theme_hue), 0%, 80% );\n\t--mol_theme_shade: hsl( var(--mol_theme_hue), 0%, 60%, 1 );\n\t--mol_theme_line: hsl( var(--mol_theme_hue), 0%, 50%, .25 );\n\t--mol_theme_focus: hsl( calc( var(--mol_theme_hue) + 180deg ), 100%, 65% );\n\t\n\t--mol_theme_control: hsl( var(--mol_theme_hue), 60%, 65% );\n\t--mol_theme_current: hsl( calc( var(--mol_theme_hue) - var(--mol_theme_hue_spread) ), 60%, 65% );\n\t--mol_theme_special: hsl( calc( var(--mol_theme_hue) + var(--mol_theme_hue_spread) ), 60%, 65% );\n\n} @supports( color: oklch( 0% 0 0deg ) ) {\n:root, [mol_theme=\"$mol_theme_dark\"], :where([mol_theme=\"$mol_theme_dark\"]) [mol_theme] {\n\t\n\t--mol_theme_back: oklch( 20% .03 var(--mol_theme_hue) );\n\t--mol_theme_card: oklch( 30% .05 var(--mol_theme_hue) / .25 );\n\t--mol_theme_field: oklch( 15% 0 var(--mol_theme_hue) / .25 );\n\t--mol_theme_hover: oklch( 70% 0 var(--mol_theme_hue) / .1 );\n\t\n\t--mol_theme_text: oklch( 80% 0 var(--mol_theme_hue) );\n\t--mol_theme_shade: oklch( 60% 0 var(--mol_theme_hue) );\n\t--mol_theme_line: oklch( 60% 0 var(--mol_theme_hue) / .25 );\n\t--mol_theme_focus: oklch( 80% .2 calc( var(--mol_theme_hue) + 180deg ) );\n\t\n\t--mol_theme_control: oklch( 70% .1 var(--mol_theme_hue) );\n\t--mol_theme_current: oklch( 70% .2 calc( var(--mol_theme_hue) - var(--mol_theme_hue_spread) ) );\n\t--mol_theme_special: oklch( 70% .2 calc( var(--mol_theme_hue) + var(--mol_theme_hue_spread) ) );\n\n} }\n\n[mol_theme=\"$mol_theme_light\"], :where([mol_theme=\"$mol_theme_light\"]) [mol_theme] {\n\t\n\t--mol_theme_luma: 1;\n\t--mol_theme_image: none;\n\t--mol_theme_spirit: hsl( 0deg, 0%, 100%, .75 );\n\t\n\t--mol_theme_back: hsl( var(--mol_theme_hue), 20%, 92% );\n\t--mol_theme_card: hsl( var(--mol_theme_hue), 50%, 100%, .5 );\n\t--mol_theme_field: hsl( var(--mol_theme_hue), 50%, 100%, .75 );\n\t--mol_theme_hover: hsl( var(--mol_theme_hue), 0%, 50%, .1 );\n\t\n\t--mol_theme_text: hsl( var(--mol_theme_hue), 0%, 0% );\n\t--mol_theme_shade: hsl( var(--mol_theme_hue), 0%, 40%, 1 );\n\t--mol_theme_line: hsl( var(--mol_theme_hue), 0%, 50%, .25 );\n\t--mol_theme_focus: hsl( calc( var(--mol_theme_hue) + 180deg ), 100%, 40% );\n\t\n\t--mol_theme_control: hsl( var(--mol_theme_hue), 80%, 30% );\n\t--mol_theme_current: hsl( calc( var(--mol_theme_hue) - var(--mol_theme_hue_spread) ), 80%, 30% );\n\t--mol_theme_special: hsl( calc( var(--mol_theme_hue) + var(--mol_theme_hue_spread) ), 80%, 30% );\n\n} @supports( color: oklch( 0% 0 0deg ) ) {\n[mol_theme=\"$mol_theme_light\"], :where([mol_theme=\"$mol_theme_light\"]) [mol_theme] {\n\t--mol_theme_back: oklch( 92% .01 var(--mol_theme_hue) );\n\t--mol_theme_card: oklch( 99% .01 var(--mol_theme_hue) / .5 );\n\t--mol_theme_field: oklch( 100% 0 var(--mol_theme_hue) / .5 );\n\t--mol_theme_hover: oklch( 70% 0 var(--mol_theme_hue) / .1 );\n\t\n\t--mol_theme_text: oklch( 20% 0 var(--mol_theme_hue) );\n\t--mol_theme_shade: oklch( 60% 0 var(--mol_theme_hue) );\n\t--mol_theme_line: oklch( 50% 0 var(--mol_theme_hue) / .25 );\n\t--mol_theme_focus: oklch( 60% .2 calc( var(--mol_theme_hue) + 180deg ) );\n\t\n\t--mol_theme_control: oklch( 40% .15 var(--mol_theme_hue) );\n\t--mol_theme_current: oklch( 50% .2 calc( var(--mol_theme_hue) - var(--mol_theme_hue_spread) ) );\n\t--mol_theme_special: oklch( 50% .2 calc( var(--mol_theme_hue) + var(--mol_theme_hue_spread) ) );\n\n} }\n\n:where( :root, [mol_theme=\"$mol_theme_dark\"] ) [mol_theme=\"$mol_theme_base\"] {\n\t--mol_theme_back: oklch( 25% .075 var(--mol_theme_hue) );\n\t--mol_theme_card: oklch( 35% .1 var(--mol_theme_hue) / .25 );\n}\n:where( [mol_theme=\"$mol_theme_light\"] ) [mol_theme=\"$mol_theme_base\"] {\n\t--mol_theme_back: oklch( 85% .075 var(--mol_theme_hue) );\n\t--mol_theme_card: oklch( 98% .03 var(--mol_theme_hue) / .25 );\n}\n\n:where( :root, [mol_theme=\"$mol_theme_dark\"] ) [mol_theme=\"$mol_theme_current\"] {\n\t--mol_theme_back: oklch( 25% .05 calc( var(--mol_theme_hue) - var(--mol_theme_hue_spread) ) );\n\t--mol_theme_card: oklch( 35% .1 calc( var(--mol_theme_hue) - var(--mol_theme_hue_spread) ) / .25 );\n}\n:where( [mol_theme=\"$mol_theme_light\"] ) [mol_theme=\"$mol_theme_current\"] {\n\t--mol_theme_back: oklch( 85% .05 calc( var(--mol_theme_hue) - var(--mol_theme_hue_spread) ) );\n\t--mol_theme_card: oklch( 98% .03 calc( var(--mol_theme_hue) - var(--mol_theme_hue_spread) ) / .25 );\n}\n\n:where( :root, [mol_theme=\"$mol_theme_dark\"] ) [mol_theme=\"$mol_theme_special\"] {\n\t--mol_theme_back: oklch( 25% .05 calc( var(--mol_theme_hue) + var(--mol_theme_hue_spread) ) );\n\t--mol_theme_card: oklch( 35% .1 calc( var(--mol_theme_hue) + var(--mol_theme_hue_spread) ) / .25 );\n}\n:where( [mol_theme=\"$mol_theme_light\"] ) [mol_theme=\"$mol_theme_special\"] {\n\t--mol_theme_back: oklch( 85% .05 calc( var(--mol_theme_hue) + var(--mol_theme_hue_spread) ) );\n\t--mol_theme_card: oklch( 98% .03 calc( var(--mol_theme_hue) + var(--mol_theme_hue_spread) ) / .25 );\n}\n\n:where( :root, [mol_theme=\"$mol_theme_dark\"] ) [mol_theme=\"$mol_theme_accent\"] {\n\t--mol_theme_back: oklch( 35% .1 calc( var(--mol_theme_hue) + 180deg ) );\n\t--mol_theme_card: oklch( 45% .15 calc( var(--mol_theme_hue) + 180deg ) / .25 );\n}\n:where( [mol_theme=\"$mol_theme_light\"] ) [mol_theme=\"$mol_theme_accent\"] {\n\t--mol_theme_back: oklch( 83% .1 calc( var(--mol_theme_hue) + 180deg ) );\n\t--mol_theme_card: oklch( 98% .03 calc( var(--mol_theme_hue) + 180deg ) / .25 );\n}\n\n");
3776
+ })($ || ($ = {}));
3777
+
3778
+ ;
3779
+ "use strict";
3780
+ var $;
3781
+ (function ($) {
3782
+ $mol_style_attach('$mol_theme_lights', `:root { --mol_theme_back: oklch( ${$$.$mol_lights() ? 92 : 20}% .01 var(--mol_theme_hue) ) }`);
3783
+ })($ || ($ = {}));
3784
+
3785
+ ;
3786
+ "use strict";
3787
+ var $;
3788
+ (function ($) {
3789
+ $.$mol_gap = $mol_style_prop('mol_gap', [
3790
+ 'block',
3791
+ 'text',
3792
+ 'round',
3793
+ 'space',
3794
+ 'blur',
3795
+ ]);
3796
+ })($ || ($ = {}));
3797
+
3798
+ ;
3799
+ "use strict";
3800
+ var $;
3801
+ (function ($) {
3802
+ $mol_style_attach("mol/gap/gap.css", ":root {\n\t--mol_gap_block: .75rem;\n\t--mol_gap_text: .5rem .75rem;\n\t--mol_gap_round: .25rem;\n\t--mol_gap_space: .25rem;\n\t--mol_gap_blur: .5rem;\n}\n");
3803
+ })($ || ($ = {}));
3804
+
3805
+ ;
3806
+ "use strict";
3807
+ var $;
3808
+ (function ($) {
3809
+ function $mol_dom_render_children(el, childNodes) {
3810
+ const node_set = new Set(childNodes);
3811
+ let nextNode = el.firstChild;
3812
+ for (let view of childNodes) {
3813
+ if (view == null)
3814
+ continue;
3815
+ if (view instanceof $mol_dom_context.Node) {
3816
+ while (true) {
3817
+ if (!nextNode) {
3818
+ el.appendChild(view);
3819
+ break;
3820
+ }
3821
+ if (nextNode == view) {
3822
+ nextNode = nextNode.nextSibling;
3823
+ break;
3824
+ }
3825
+ else {
3826
+ if (node_set.has(nextNode)) {
3827
+ el.insertBefore(view, nextNode);
3828
+ break;
3829
+ }
3830
+ else {
3831
+ const nn = nextNode.nextSibling;
3832
+ el.removeChild(nextNode);
3833
+ nextNode = nn;
3834
+ }
3835
+ }
3836
+ }
3837
+ }
3838
+ else {
3839
+ if (nextNode && nextNode.nodeName === '#text') {
3840
+ const str = String(view);
3841
+ if (nextNode.nodeValue !== str)
3842
+ nextNode.nodeValue = str;
3843
+ nextNode = nextNode.nextSibling;
3844
+ }
3845
+ else {
3846
+ const textNode = $mol_dom_context.document.createTextNode(String(view));
3847
+ el.insertBefore(textNode, nextNode);
3848
+ }
3849
+ }
3850
+ }
3851
+ while (nextNode) {
3852
+ const currNode = nextNode;
3853
+ nextNode = currNode.nextSibling;
3854
+ el.removeChild(currNode);
3855
+ }
3856
+ }
3857
+ $.$mol_dom_render_children = $mol_dom_render_children;
3858
+ })($ || ($ = {}));
3859
+
3860
+ ;
3861
+ "use strict";
3862
+
3863
+ ;
3864
+ "use strict";
3865
+ var $;
3866
+ (function ($) {
3867
+ $.$mol_jsx_prefix = '';
3868
+ $.$mol_jsx_crumbs = '';
3869
+ $.$mol_jsx_booked = null;
3870
+ $.$mol_jsx_document = {
3871
+ getElementById: () => null,
3872
+ createElementNS: (space, name) => $mol_dom_context.document.createElementNS(space, name),
3873
+ createDocumentFragment: () => $mol_dom_context.document.createDocumentFragment(),
3874
+ };
3875
+ $.$mol_jsx_frag = '';
3876
+ function $mol_jsx(Elem, props, ...childNodes) {
3877
+ const id = props && props.id || '';
3878
+ const guid = id ? $.$mol_jsx_prefix ? $.$mol_jsx_prefix + '/' + id : id : $.$mol_jsx_prefix;
3879
+ const crumbs_self = id ? $.$mol_jsx_crumbs.replace(/(\S+)/g, `$1_${id.replace(/\/.*/i, '')}`) : $.$mol_jsx_crumbs;
3880
+ if (Elem && $.$mol_jsx_booked) {
3881
+ if ($.$mol_jsx_booked.has(id)) {
3882
+ $mol_fail(new Error(`JSX already has tag with id ${JSON.stringify(guid)}`));
3883
+ }
3884
+ else {
3885
+ $.$mol_jsx_booked.add(id);
3886
+ }
3887
+ }
3888
+ let node = guid ? $.$mol_jsx_document.getElementById(guid) : null;
3889
+ if ($.$mol_jsx_prefix) {
3890
+ const prefix_ext = $.$mol_jsx_prefix;
3891
+ const booked_ext = $.$mol_jsx_booked;
3892
+ const crumbs_ext = $.$mol_jsx_crumbs;
3893
+ for (const field in props) {
3894
+ const func = props[field];
3895
+ if (typeof func !== 'function')
3896
+ continue;
3897
+ const wrapper = function (...args) {
3898
+ const prefix = $.$mol_jsx_prefix;
3899
+ const booked = $.$mol_jsx_booked;
3900
+ const crumbs = $.$mol_jsx_crumbs;
3901
+ try {
3902
+ $.$mol_jsx_prefix = prefix_ext;
3903
+ $.$mol_jsx_booked = booked_ext;
3904
+ $.$mol_jsx_crumbs = crumbs_ext;
3905
+ return func.call(this, ...args);
3906
+ }
3907
+ finally {
3908
+ $.$mol_jsx_prefix = prefix;
3909
+ $.$mol_jsx_booked = booked;
3910
+ $.$mol_jsx_crumbs = crumbs;
3911
+ }
3912
+ };
3913
+ $mol_func_name_from(wrapper, func);
3914
+ props[field] = wrapper;
3915
+ }
3916
+ }
3917
+ if (typeof Elem !== 'string') {
3918
+ if ('prototype' in Elem) {
3919
+ const view = node && node[String(Elem)] || new Elem;
3920
+ Object.assign(view, props);
3921
+ view[Symbol.toStringTag] = guid;
3922
+ view.childNodes = childNodes;
3923
+ if (!view.ownerDocument)
3924
+ view.ownerDocument = $.$mol_jsx_document;
3925
+ view.className = (crumbs_self ? crumbs_self + ' ' : '') + (Elem['name'] || Elem);
3926
+ node = view.valueOf();
3927
+ node[String(Elem)] = view;
3928
+ return node;
3929
+ }
3930
+ else {
3931
+ const prefix = $.$mol_jsx_prefix;
3932
+ const booked = $.$mol_jsx_booked;
3933
+ const crumbs = $.$mol_jsx_crumbs;
3934
+ try {
3935
+ $.$mol_jsx_prefix = guid;
3936
+ $.$mol_jsx_booked = new Set;
3937
+ $.$mol_jsx_crumbs = (crumbs_self ? crumbs_self + ' ' : '') + (Elem['name'] || Elem);
3938
+ return Elem(props, ...childNodes);
3939
+ }
3940
+ finally {
3941
+ $.$mol_jsx_prefix = prefix;
3942
+ $.$mol_jsx_booked = booked;
3943
+ $.$mol_jsx_crumbs = crumbs;
3944
+ }
3945
+ }
3946
+ }
3947
+ if (!node) {
3948
+ node = Elem
3949
+ ? $.$mol_jsx_document.createElementNS(props?.xmlns ?? 'http://www.w3.org/1999/xhtml', Elem)
3950
+ : $.$mol_jsx_document.createDocumentFragment();
3951
+ }
3952
+ $mol_dom_render_children(node, [].concat(...childNodes));
3953
+ if (!Elem)
3954
+ return node;
3955
+ if (guid)
3956
+ node.id = guid;
3957
+ for (const key in props) {
3958
+ if (key === 'id')
3959
+ continue;
3960
+ if (typeof props[key] === 'string') {
3961
+ if (typeof node[key] === 'string')
3962
+ node[key] = props[key];
3963
+ node.setAttribute(key, props[key]);
3964
+ }
3965
+ else if (props[key] &&
3966
+ typeof props[key] === 'object' &&
3967
+ Reflect.getPrototypeOf(props[key]) === Reflect.getPrototypeOf({})) {
3968
+ if (typeof node[key] === 'object') {
3969
+ Object.assign(node[key], props[key]);
3970
+ continue;
3971
+ }
3972
+ }
3973
+ else {
3974
+ node[key] = props[key];
3975
+ }
3976
+ }
3977
+ if ($.$mol_jsx_crumbs)
3978
+ node.className = (props?.['class'] ? props['class'] + ' ' : '') + crumbs_self;
3979
+ return node;
3980
+ }
3981
+ $.$mol_jsx = $mol_jsx;
3982
+ })($ || ($ = {}));
3983
+
3984
+ ;
3985
+ "use strict";
3986
+ var $;
3987
+ (function ($) {
3988
+ class $mol_window extends $mol_object {
3989
+ static size() {
3990
+ return {
3991
+ width: 1024,
3992
+ height: 768,
3993
+ };
3994
+ }
3995
+ }
3996
+ $.$mol_window = $mol_window;
3997
+ })($ || ($ = {}));
3998
+
3999
+ ;
4000
+ "use strict";
4001
+ var $;
4002
+ (function ($) {
4003
+ function $mol_guard_defined(value) {
4004
+ return value !== null && value !== undefined;
4005
+ }
4006
+ $.$mol_guard_defined = $mol_guard_defined;
4007
+ })($ || ($ = {}));
4008
+
4009
+ ;
4010
+ "use strict";
4011
+ var $;
4012
+ (function ($) {
4013
+ class $mol_view_selection extends $mol_object {
4014
+ static focused(next, notify) {
4015
+ const parents = [];
4016
+ let element = next?.[0] ?? $mol_dom_context.document.activeElement;
4017
+ while (element?.shadowRoot) {
4018
+ element = element.shadowRoot.activeElement;
2935
4019
  }
2936
4020
  while (element) {
2937
4021
  parents.push(element);
@@ -3028,26 +4112,6 @@ var $;
3028
4112
  $.$mol_dom_qname = $mol_dom_qname;
3029
4113
  })($ || ($ = {}));
3030
4114
 
3031
- ;
3032
- "use strict";
3033
- var $;
3034
- (function ($) {
3035
- function $mol_wire_probe(task, def) {
3036
- const warm = $mol_wire_fiber.warm;
3037
- try {
3038
- $mol_wire_fiber.warm = false;
3039
- const res = task();
3040
- if (res === undefined)
3041
- return def;
3042
- return res;
3043
- }
3044
- finally {
3045
- $mol_wire_fiber.warm = warm;
3046
- }
3047
- }
3048
- $.$mol_wire_probe = $mol_wire_probe;
3049
- })($ || ($ = {}));
3050
-
3051
4115
  ;
3052
4116
  "use strict";
3053
4117
  var $;
@@ -3064,38 +4128,6 @@ var $;
3064
4128
  $.$mol_wire_watch = $mol_wire_watch;
3065
4129
  })($ || ($ = {}));
3066
4130
 
3067
- ;
3068
- "use strict";
3069
- var $;
3070
- (function ($) {
3071
- function $mol_const(value) {
3072
- const getter = (() => value);
3073
- getter['()'] = value;
3074
- getter[Symbol.toStringTag] = value;
3075
- getter[$mol_dev_format_head] = () => $mol_dev_format_span({}, '()=> ', $mol_dev_format_auto(value));
3076
- return getter;
3077
- }
3078
- $.$mol_const = $mol_const;
3079
- })($ || ($ = {}));
3080
-
3081
- ;
3082
- "use strict";
3083
- var $;
3084
- (function ($) {
3085
- function $mol_wire_solid() {
3086
- let current = $mol_wire_auto();
3087
- if (current.temp)
3088
- current = current.host;
3089
- if (current.reap !== nothing) {
3090
- current?.sub_on(sub, sub.data.length);
3091
- }
3092
- current.reap = nothing;
3093
- }
3094
- $.$mol_wire_solid = $mol_wire_solid;
3095
- const nothing = () => { };
3096
- const sub = new $mol_wire_pub_sub;
3097
- })($ || ($ = {}));
3098
-
3099
4131
  ;
3100
4132
  "use strict";
3101
4133
  var $;
@@ -3171,36 +4203,6 @@ var $;
3171
4203
  $.$mol_dom_render_fields = $mol_dom_render_fields;
3172
4204
  })($ || ($ = {}));
3173
4205
 
3174
- ;
3175
- "use strict";
3176
- var $;
3177
- (function ($) {
3178
- function $mol_wire_async(obj) {
3179
- let fiber;
3180
- const temp = $mol_wire_task.getter(obj);
3181
- return new Proxy(obj, {
3182
- get(obj, field) {
3183
- const val = obj[field];
3184
- if (typeof val !== 'function')
3185
- return val;
3186
- let fiber;
3187
- const temp = $mol_wire_task.getter(val);
3188
- return function $mol_wire_async(...args) {
3189
- fiber?.destructor();
3190
- fiber = temp(obj, args);
3191
- return fiber.async();
3192
- };
3193
- },
3194
- apply(obj, self, args) {
3195
- fiber?.destructor();
3196
- fiber = temp(self, args);
3197
- return fiber.async();
3198
- },
3199
- });
3200
- }
3201
- $.$mol_wire_async = $mol_wire_async;
3202
- })($ || ($ = {}));
3203
-
3204
4206
  ;
3205
4207
  "use strict";
3206
4208
 
@@ -3211,7 +4213,7 @@ var $;
3211
4213
  "use strict";
3212
4214
  var $;
3213
4215
  (function ($) {
3214
- $mol_style_attach("mol/view/view/view.css", "[mol_view] {\n\ttransition-property: height, width, min-height, min-width, max-width, max-height, transform;\n\ttransition-duration: .2s;\n\ttransition-timing-function: ease-out;\n\t-webkit-appearance: none;\n\tbox-sizing: border-box;\n\tdisplay: flex;\n\tflex-shrink: 0;\n\tcontain: style;\n\tscrollbar-color: var(--mol_theme_line) transparent;\n\tscrollbar-width: thin;\n}\t\n\n[mol_view]::selection {\n\tbackground: var(--mol_theme_line);\n}\t\n\n[mol_view]::-webkit-scrollbar {\n\twidth: .25rem;\n\theight: .25rem;\n}\n\n[mol_view]::-webkit-scrollbar-corner {\n\tbackground-color: var(--mol_theme_line);\n}\n\n[mol_view]::-webkit-scrollbar-track {\n\tbackground-color: transparent;\n}\n\n[mol_view]::-webkit-scrollbar-thumb {\n\tbackground-color: var(--mol_theme_line);\n\tborder-radius: var(--mol_gap_round);\n}\n\n[mol_view] > * {\n\tword-break: inherit;\n}\n\n[mol_view_root] {\n\tmargin: 0;\n\tpadding: 0;\n\twidth: 100%;\n\theight: 100%;\n\tbox-sizing: border-box;\n\tfont-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;\n\tfont-size: 1rem;\n\tline-height: 1.5rem;\n\tbackground: var(--mol_theme_back);\n\tcolor: var(--mol_theme_text);\n\tcontain: unset; /** Fixes bg ignoring when applied to body on Chrome */\n\ttab-size: 4;\n\toverscroll-behavior: contain; /** Disable navigation gestures **/\n}\n\n@media print {\n\t[mol_view_root] {\n\t\theight: auto;\n\t}\n}\n[mol_view][mol_view_error]:not([mol_view_error=\"Promise\"], [mol_view_error=\"$mol_promise_blocker\"]) {\n\tbackground-image: repeating-linear-gradient(\n\t\t-45deg,\n\t\t#f92323,\n\t\t#f92323 .5rem,\n\t\t#ff3d3d .5rem,\n\t\t#ff3d3d 1.5rem\n\t);\n\tcolor: black;\n\talign-items: center;\n\tjustify-content: center;\n}\n\n@keyframes mol_view_wait {\n\tfrom {\n\t\topacity: .25;\n\t}\n\t20% {\n\t\topacity: .75;\n\t}\n\tto {\n\t\topacity: .25;\n\t}\n}\n\n:where([mol_view][mol_view_error=\"$mol_promise_blocker\"]),\n:where([mol_view][mol_view_error=\"Promise\"]) {\n\tbackground: var(--mol_theme_hover);\n}\n\n[mol_view][mol_view_error=\"Promise\"] {\n\tanimation: mol_view_wait 1s steps(20,end) infinite;\n}\n");
4216
+ $mol_style_attach("mol/view/view/view.css", "[mol_view] {\n\ttransition-property: height, width, min-height, min-width, max-width, max-height, transform;\n\ttransition-duration: .2s;\n\ttransition-timing-function: ease-out;\n\t-webkit-appearance: none;\n\tbox-sizing: border-box;\n\tdisplay: flex;\n\tflex-shrink: 0;\n\tcontain: style;\n\tscrollbar-color: var(--mol_theme_line) transparent;\n\tscrollbar-width: thin;\n}\t\n\n[mol_view]::selection {\n\tbackground: var(--mol_theme_line);\n}\t\n\n[mol_view]::-webkit-scrollbar {\n\twidth: .25rem;\n\theight: .25rem;\n}\n\n[mol_view]::-webkit-scrollbar-corner {\n\tbackground-color: var(--mol_theme_line);\n}\n\n[mol_view]::-webkit-scrollbar-track {\n\tbackground-color: transparent;\n}\n\n[mol_view]::-webkit-scrollbar-thumb {\n\tbackground-color: var(--mol_theme_line);\n\tborder-radius: var(--mol_gap_round);\n}\n\n[mol_view] > * {\n\tword-break: inherit;\n}\n\n[mol_view_root] {\n\tmargin: 0;\n\tpadding: 0;\n\twidth: 100%;\n\theight: 100%;\n\tbox-sizing: border-box;\n\tfont-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;\n\tfont-size: 1rem;\n\tline-height: 1.5rem;\n\t/* background: var(--mol_theme_back);\n\tcolor: var(--mol_theme_text); */\n\tcontain: unset; /** Fixes bg ignoring when applied to body on Chrome */\n\ttab-size: 4;\n\toverscroll-behavior: contain; /** Disable navigation gestures **/\n}\n\n@media print {\n\t[mol_view_root] {\n\t\theight: auto;\n\t}\n}\n[mol_view][mol_view_error]:not([mol_view_error=\"Promise\"], [mol_view_error=\"$mol_promise_blocker\"]) {\n\tbackground-image: repeating-linear-gradient(\n\t\t-45deg,\n\t\t#f92323,\n\t\t#f92323 .5rem,\n\t\t#ff3d3d .5rem,\n\t\t#ff3d3d 1.5rem\n\t);\n\tcolor: black;\n\talign-items: center;\n\tjustify-content: center;\n}\n\n@keyframes mol_view_wait {\n\tfrom {\n\t\topacity: .25;\n\t}\n\t20% {\n\t\topacity: .75;\n\t}\n\tto {\n\t\topacity: .25;\n\t}\n}\n\n:where([mol_view][mol_view_error=\"$mol_promise_blocker\"]),\n:where([mol_view][mol_view_error=\"Promise\"]) {\n\tbackground: var(--mol_theme_hover);\n}\n\n[mol_view][mol_view_error=\"Promise\"] {\n\tanimation: mol_view_wait 1s steps(20,end) infinite;\n}\n");
3215
4217
  })($ || ($ = {}));
3216
4218
 
3217
4219
  ;
@@ -4590,13 +5592,6 @@ var $;
4590
5592
  ($mol_mem(($.$mol_plot_pane.prototype), "dimensions_viewport"));
4591
5593
 
4592
5594
 
4593
- ;
4594
- "use strict";
4595
- var $;
4596
- (function ($) {
4597
- $.$mol_mem_cached = $mol_wire_probe;
4598
- })($ || ($ = {}));
4599
-
4600
5595
  ;
4601
5596
  ($.$mol_svg_group) = class $mol_svg_group extends ($.$mol_svg) {
4602
5597
  dom_name(){
@@ -8822,166 +9817,22 @@ var $;
8822
9817
  static $ = $;
8823
9818
  static sums = 0;
8824
9819
  static value(index, next) {
8825
- if (next)
8826
- return next;
8827
- if (index < 2)
8828
- return 1;
8829
- ++this.sums;
8830
- return this.value(index - 1) + this.value(index - 2);
8831
- }
8832
- }
8833
- __decorate([
8834
- $mol_wire_plex
8835
- ], Fib, "value", null);
8836
- $mol_assert_equal(Fib.value(4), 5);
8837
- $mol_assert_equal(Fib.sums, 3);
8838
- Fib.value(1, 2);
8839
- $mol_assert_equal(Fib.value(4), 8);
8840
- $mol_assert_equal(Fib.sums, 6);
8841
- },
8842
- });
8843
- })($ || ($ = {}));
8844
-
8845
- ;
8846
- "use strict";
8847
- var $;
8848
- (function ($) {
8849
- $mol_test({
8850
- 'Previous value'() {
8851
- class Cache extends $mol_object2 {
8852
- static store(next) {
8853
- if (!next)
8854
- return {};
8855
- return {
8856
- ...$mol_wire_probe(() => this.store()) ?? {},
8857
- ...next,
8858
- };
8859
- }
8860
- }
8861
- __decorate([
8862
- $mol_wire_solo
8863
- ], Cache, "store", null);
8864
- $mol_assert_like(Cache.store(), {});
8865
- $mol_assert_like(Cache.store({ foo: 666 }), { foo: 666 });
8866
- $mol_assert_like(Cache.store({ bar: 777 }), { foo: 666, bar: 777 });
8867
- },
8868
- });
8869
- })($ || ($ = {}));
8870
-
8871
- ;
8872
- "use strict";
8873
- var $;
8874
- (function ($) {
8875
- $mol_test({
8876
- 'run callback'() {
8877
- class Plus1 extends $mol_wrapper {
8878
- static wrap(task) {
8879
- return function (...args) {
8880
- return task.call(this, ...args) + 1;
8881
- };
8882
- }
8883
- }
8884
- $mol_assert_equal(Plus1.run(() => 2), 3);
8885
- },
8886
- 'wrap function'() {
8887
- class Plus1 extends $mol_wrapper {
8888
- static wrap(task) {
8889
- return function (...args) {
8890
- return task.call(this, ...args) + 1;
8891
- };
8892
- }
8893
- }
8894
- const obj = {
8895
- level: 2,
8896
- pow: Plus1.func(function (a) {
8897
- return a ** this.level;
8898
- })
8899
- };
8900
- $mol_assert_equal(obj.pow(2), 5);
8901
- },
8902
- 'decorate field getter'() {
8903
- class Plus1 extends $mol_wrapper {
8904
- static last = 0;
8905
- static wrap(task) {
8906
- return function (...args) {
8907
- return Plus1.last = (task.call(this, ...args) || 0) + 1;
8908
- };
8909
- }
8910
- }
8911
- class Foo {
8912
- static get two() {
8913
- return 1;
8914
- }
8915
- static set two(next) { }
8916
- }
8917
- __decorate([
8918
- Plus1.field
8919
- ], Foo, "two", null);
8920
- $mol_assert_equal(Foo.two, 2);
8921
- Foo.two = 3;
8922
- $mol_assert_equal(Plus1.last, 2);
8923
- $mol_assert_equal(Foo.two, 2);
8924
- },
8925
- 'decorate instance method'() {
8926
- class Plus1 extends $mol_wrapper {
8927
- static wrap(task) {
8928
- return function (...args) {
8929
- return task.call(this, ...args) + 1;
8930
- };
8931
- }
8932
- }
8933
- class Foo1 {
8934
- level = 2;
8935
- pow(a) {
8936
- return a ** this.level;
8937
- }
8938
- }
8939
- __decorate([
8940
- Plus1.method
8941
- ], Foo1.prototype, "pow", null);
8942
- const Foo2 = Foo1;
8943
- const foo = new Foo2;
8944
- $mol_assert_equal(foo.pow(2), 5);
8945
- },
8946
- 'decorate static method'() {
8947
- class Plus1 extends $mol_wrapper {
8948
- static wrap(task) {
8949
- return function (...args) {
8950
- return task.call(this, ...args) + 1;
8951
- };
8952
- }
8953
- }
8954
- class Foo {
8955
- static level = 2;
8956
- static pow(a) {
8957
- return a ** this.level;
8958
- }
8959
- }
8960
- __decorate([
8961
- Plus1.method
8962
- ], Foo, "pow", null);
8963
- $mol_assert_equal(Foo.pow(2), 5);
8964
- },
8965
- 'decorate class'() {
8966
- class BarInc extends $mol_wrapper {
8967
- static wrap(task) {
8968
- return function (...args) {
8969
- const foo = task.call(this, ...args);
8970
- foo.bar++;
8971
- return foo;
8972
- };
9820
+ if (next)
9821
+ return next;
9822
+ if (index < 2)
9823
+ return 1;
9824
+ ++this.sums;
9825
+ return this.value(index - 1) + this.value(index - 2);
8973
9826
  }
8974
9827
  }
8975
- let Foo = class Foo {
8976
- bar;
8977
- constructor(bar) {
8978
- this.bar = bar;
8979
- }
8980
- };
8981
- Foo = __decorate([
8982
- BarInc.class
8983
- ], Foo);
8984
- $mol_assert_equal(new Foo(2).bar, 3);
9828
+ __decorate([
9829
+ $mol_wire_plex
9830
+ ], Fib, "value", null);
9831
+ $mol_assert_equal(Fib.value(4), 5);
9832
+ $mol_assert_equal(Fib.sums, 3);
9833
+ Fib.value(1, 2);
9834
+ $mol_assert_equal(Fib.value(4), 8);
9835
+ $mol_assert_equal(Fib.sums, 6);
8985
9836
  },
8986
9837
  });
8987
9838
  })($ || ($ = {}));
@@ -8991,22 +9842,23 @@ var $;
8991
9842
  var $;
8992
9843
  (function ($) {
8993
9844
  $mol_test({
8994
- 'memoize field'() {
8995
- class Foo {
8996
- static one = 1;
8997
- static get two() {
8998
- return ++this.one;
9845
+ 'Previous value'() {
9846
+ class Cache extends $mol_object2 {
9847
+ static store(next) {
9848
+ if (!next)
9849
+ return {};
9850
+ return {
9851
+ ...$mol_wire_probe(() => this.store()) ?? {},
9852
+ ...next,
9853
+ };
8999
9854
  }
9000
- static set two(next) { }
9001
9855
  }
9002
9856
  __decorate([
9003
- $mol_memo.field
9004
- ], Foo, "two", null);
9005
- $mol_assert_equal(Foo.two, 2);
9006
- $mol_assert_equal(Foo.two, 2);
9007
- Foo.two = 3;
9008
- $mol_assert_equal(Foo.two, 3);
9009
- $mol_assert_equal(Foo.two, 3);
9857
+ $mol_wire_solo
9858
+ ], Cache, "store", null);
9859
+ $mol_assert_like(Cache.store(), {});
9860
+ $mol_assert_like(Cache.store({ foo: 666 }), { foo: 666 });
9861
+ $mol_assert_like(Cache.store({ bar: 777 }), { foo: 666, bar: 777 });
9010
9862
  },
9011
9863
  });
9012
9864
  })($ || ($ = {}));
@@ -9157,6 +10009,28 @@ var $;
9157
10009
  $mol_wire_log.active();
9158
10010
  })($ || ($ = {}));
9159
10011
 
10012
+ ;
10013
+ "use strict";
10014
+ var $;
10015
+ (function ($) {
10016
+ $mol_test_mocks.push(context => {
10017
+ class $mol_state_arg_mock extends $mol_state_arg {
10018
+ static $ = context;
10019
+ static href(next) { return next || ''; }
10020
+ static go(next) {
10021
+ this.href(this.link(next));
10022
+ }
10023
+ }
10024
+ __decorate([
10025
+ $mol_mem
10026
+ ], $mol_state_arg_mock, "href", null);
10027
+ __decorate([
10028
+ $mol_action
10029
+ ], $mol_state_arg_mock, "go", null);
10030
+ context.$mol_state_arg = $mol_state_arg_mock;
10031
+ });
10032
+ })($ || ($ = {}));
10033
+
9160
10034
  ;
9161
10035
  "use strict";
9162
10036
  var $;
@@ -9170,6 +10044,232 @@ var $;
9170
10044
  });
9171
10045
  })($ || ($ = {}));
9172
10046
 
10047
+ ;
10048
+ "use strict";
10049
+ var $;
10050
+ (function ($) {
10051
+ class TestClass extends Uint8Array {
10052
+ }
10053
+ $mol_test({
10054
+ 'Uint8Array vs itself'() {
10055
+ $mol_assert_ok($mol_compare_array(new Uint8Array, new Uint8Array));
10056
+ $mol_assert_ok($mol_compare_array(new Uint8Array([0]), new Uint8Array([0])));
10057
+ $mol_assert_not($mol_compare_array(new Uint8Array([0]), new Uint8Array([1])));
10058
+ },
10059
+ 'Uint8Array vs subclassed array'() {
10060
+ $mol_assert_not($mol_compare_array(new Uint8Array, new TestClass));
10061
+ },
10062
+ });
10063
+ })($ || ($ = {}));
10064
+
10065
+ ;
10066
+ "use strict";
10067
+ var $;
10068
+ (function ($) {
10069
+ $mol_test({
10070
+ 'decode utf8 string'() {
10071
+ const str = 'Hello, ΧΨΩЫ';
10072
+ const encoded = new Uint8Array([72, 101, 108, 108, 111, 44, 32, 206, 167, 206, 168, 206, 169, 208, 171]);
10073
+ $mol_assert_equal($mol_charset_decode(encoded), str);
10074
+ $mol_assert_equal($mol_charset_decode(encoded, 'utf8'), str);
10075
+ },
10076
+ 'decode empty string'() {
10077
+ const encoded = new Uint8Array([]);
10078
+ $mol_assert_equal($mol_charset_decode(encoded), '');
10079
+ },
10080
+ });
10081
+ })($ || ($ = {}));
10082
+
10083
+ ;
10084
+ "use strict";
10085
+ var $;
10086
+ (function ($) {
10087
+ $mol_test({
10088
+ 'encode utf8 string'() {
10089
+ const str = 'Hello, ΧΨΩЫ';
10090
+ const encoded = new Uint8Array([72, 101, 108, 108, 111, 44, 32, 206, 167, 206, 168, 206, 169, 208, 171]);
10091
+ $mol_assert_like($mol_charset_encode(str), encoded);
10092
+ },
10093
+ });
10094
+ })($ || ($ = {}));
10095
+
10096
+ ;
10097
+ "use strict";
10098
+ var $;
10099
+ (function ($) {
10100
+ $mol_test({
10101
+ 'local get set delete'() {
10102
+ var key = '$mol_state_local_test:' + Math.random();
10103
+ $mol_assert_equal($mol_state_local.value(key), null);
10104
+ $mol_state_local.value(key, 123);
10105
+ $mol_assert_equal($mol_state_local.value(key), 123);
10106
+ $mol_state_local.value(key, null);
10107
+ $mol_assert_equal($mol_state_local.value(key), null);
10108
+ },
10109
+ });
10110
+ })($ || ($ = {}));
10111
+
10112
+ ;
10113
+ "use strict";
10114
+ var $;
10115
+ (function ($) {
10116
+ $mol_test_mocks.push(context => {
10117
+ class $mol_state_local_mock extends $mol_state_local {
10118
+ static state = {};
10119
+ static value(key, next = this.state[key]) {
10120
+ return this.state[key] = (next || null);
10121
+ }
10122
+ }
10123
+ __decorate([
10124
+ $mol_mem_key
10125
+ ], $mol_state_local_mock, "value", null);
10126
+ context.$mol_state_local = $mol_state_local_mock;
10127
+ });
10128
+ })($ || ($ = {}));
10129
+
10130
+ ;
10131
+ "use strict";
10132
+ var $;
10133
+ (function ($) {
10134
+ $mol_test({
10135
+ 'run callback'() {
10136
+ class Plus1 extends $mol_wrapper {
10137
+ static wrap(task) {
10138
+ return function (...args) {
10139
+ return task.call(this, ...args) + 1;
10140
+ };
10141
+ }
10142
+ }
10143
+ $mol_assert_equal(Plus1.run(() => 2), 3);
10144
+ },
10145
+ 'wrap function'() {
10146
+ class Plus1 extends $mol_wrapper {
10147
+ static wrap(task) {
10148
+ return function (...args) {
10149
+ return task.call(this, ...args) + 1;
10150
+ };
10151
+ }
10152
+ }
10153
+ const obj = {
10154
+ level: 2,
10155
+ pow: Plus1.func(function (a) {
10156
+ return a ** this.level;
10157
+ })
10158
+ };
10159
+ $mol_assert_equal(obj.pow(2), 5);
10160
+ },
10161
+ 'decorate field getter'() {
10162
+ class Plus1 extends $mol_wrapper {
10163
+ static last = 0;
10164
+ static wrap(task) {
10165
+ return function (...args) {
10166
+ return Plus1.last = (task.call(this, ...args) || 0) + 1;
10167
+ };
10168
+ }
10169
+ }
10170
+ class Foo {
10171
+ static get two() {
10172
+ return 1;
10173
+ }
10174
+ static set two(next) { }
10175
+ }
10176
+ __decorate([
10177
+ Plus1.field
10178
+ ], Foo, "two", null);
10179
+ $mol_assert_equal(Foo.two, 2);
10180
+ Foo.two = 3;
10181
+ $mol_assert_equal(Plus1.last, 2);
10182
+ $mol_assert_equal(Foo.two, 2);
10183
+ },
10184
+ 'decorate instance method'() {
10185
+ class Plus1 extends $mol_wrapper {
10186
+ static wrap(task) {
10187
+ return function (...args) {
10188
+ return task.call(this, ...args) + 1;
10189
+ };
10190
+ }
10191
+ }
10192
+ class Foo1 {
10193
+ level = 2;
10194
+ pow(a) {
10195
+ return a ** this.level;
10196
+ }
10197
+ }
10198
+ __decorate([
10199
+ Plus1.method
10200
+ ], Foo1.prototype, "pow", null);
10201
+ const Foo2 = Foo1;
10202
+ const foo = new Foo2;
10203
+ $mol_assert_equal(foo.pow(2), 5);
10204
+ },
10205
+ 'decorate static method'() {
10206
+ class Plus1 extends $mol_wrapper {
10207
+ static wrap(task) {
10208
+ return function (...args) {
10209
+ return task.call(this, ...args) + 1;
10210
+ };
10211
+ }
10212
+ }
10213
+ class Foo {
10214
+ static level = 2;
10215
+ static pow(a) {
10216
+ return a ** this.level;
10217
+ }
10218
+ }
10219
+ __decorate([
10220
+ Plus1.method
10221
+ ], Foo, "pow", null);
10222
+ $mol_assert_equal(Foo.pow(2), 5);
10223
+ },
10224
+ 'decorate class'() {
10225
+ class BarInc extends $mol_wrapper {
10226
+ static wrap(task) {
10227
+ return function (...args) {
10228
+ const foo = task.call(this, ...args);
10229
+ foo.bar++;
10230
+ return foo;
10231
+ };
10232
+ }
10233
+ }
10234
+ let Foo = class Foo {
10235
+ bar;
10236
+ constructor(bar) {
10237
+ this.bar = bar;
10238
+ }
10239
+ };
10240
+ Foo = __decorate([
10241
+ BarInc.class
10242
+ ], Foo);
10243
+ $mol_assert_equal(new Foo(2).bar, 3);
10244
+ },
10245
+ });
10246
+ })($ || ($ = {}));
10247
+
10248
+ ;
10249
+ "use strict";
10250
+ var $;
10251
+ (function ($) {
10252
+ $mol_test({
10253
+ 'memoize field'() {
10254
+ class Foo {
10255
+ static one = 1;
10256
+ static get two() {
10257
+ return ++this.one;
10258
+ }
10259
+ static set two(next) { }
10260
+ }
10261
+ __decorate([
10262
+ $mol_memo.field
10263
+ ], Foo, "two", null);
10264
+ $mol_assert_equal(Foo.two, 2);
10265
+ $mol_assert_equal(Foo.two, 2);
10266
+ Foo.two = 3;
10267
+ $mol_assert_equal(Foo.two, 3);
10268
+ $mol_assert_equal(Foo.two, 3);
10269
+ },
10270
+ });
10271
+ })($ || ($ = {}));
10272
+
9173
10273
  ;
9174
10274
  "use strict";
9175
10275