mol_plot_all 1.2.1691 → 1.2.1692

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
@@ -2395,6 +2395,250 @@ var $;
2395
2395
 
2396
2396
  ;
2397
2397
  "use strict";
2398
+ var $;
2399
+ (function ($) {
2400
+ $.$mol_theme = $mol_style_prop('mol_theme', [
2401
+ 'back',
2402
+ 'hover',
2403
+ 'card',
2404
+ 'current',
2405
+ 'special',
2406
+ 'text',
2407
+ 'control',
2408
+ 'shade',
2409
+ 'line',
2410
+ 'focus',
2411
+ 'field',
2412
+ 'image',
2413
+ 'spirit',
2414
+ ]);
2415
+ })($ || ($ = {}));
2416
+
2417
+ ;
2418
+ "use strict";
2419
+ var $;
2420
+ (function ($) {
2421
+ $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:root, :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( 50% 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");
2422
+ })($ || ($ = {}));
2423
+
2424
+ ;
2425
+ "use strict";
2426
+
2427
+ ;
2428
+ "use strict";
2429
+ var $;
2430
+ (function ($) {
2431
+ $.$mol_gap = $mol_style_prop('mol_gap', [
2432
+ 'page',
2433
+ 'block',
2434
+ 'text',
2435
+ 'emoji',
2436
+ 'round',
2437
+ 'space',
2438
+ 'blur',
2439
+ ]);
2440
+ })($ || ($ = {}));
2441
+
2442
+ ;
2443
+ "use strict";
2444
+ var $;
2445
+ (function ($) {
2446
+ $mol_style_attach("mol/gap/gap.css", ":root {\n\t--mol_gap_page: 3rem;\n\t--mol_gap_block: .75rem;\n\t--mol_gap_text: .5rem .75rem;\n\t--mol_gap_emoji: .5rem;\n\t--mol_gap_round: .25rem;\n\t--mol_gap_space: .25rem;\n\t--mol_gap_blur: .5rem;\n}\n");
2447
+ })($ || ($ = {}));
2448
+
2449
+ ;
2450
+ "use strict";
2451
+ var $;
2452
+ (function ($) {
2453
+ function $mol_dom_render_children(el, childNodes) {
2454
+ const node_set = new Set(childNodes);
2455
+ let nextNode = el.firstChild;
2456
+ for (let view of childNodes) {
2457
+ if (view == null)
2458
+ continue;
2459
+ if (view instanceof $mol_dom_context.Node) {
2460
+ while (true) {
2461
+ if (!nextNode) {
2462
+ el.appendChild(view);
2463
+ break;
2464
+ }
2465
+ if (nextNode == view) {
2466
+ nextNode = nextNode.nextSibling;
2467
+ break;
2468
+ }
2469
+ else {
2470
+ if (node_set.has(nextNode)) {
2471
+ el.insertBefore(view, nextNode);
2472
+ break;
2473
+ }
2474
+ else {
2475
+ const nn = nextNode.nextSibling;
2476
+ el.removeChild(nextNode);
2477
+ nextNode = nn;
2478
+ }
2479
+ }
2480
+ }
2481
+ }
2482
+ else {
2483
+ if (nextNode && nextNode.nodeName === '#text') {
2484
+ const str = String(view);
2485
+ if (nextNode.nodeValue !== str)
2486
+ nextNode.nodeValue = str;
2487
+ nextNode = nextNode.nextSibling;
2488
+ }
2489
+ else {
2490
+ const textNode = $mol_dom_context.document.createTextNode(String(view));
2491
+ el.insertBefore(textNode, nextNode);
2492
+ }
2493
+ }
2494
+ }
2495
+ while (nextNode) {
2496
+ const currNode = nextNode;
2497
+ nextNode = currNode.nextSibling;
2498
+ el.removeChild(currNode);
2499
+ }
2500
+ }
2501
+ $.$mol_dom_render_children = $mol_dom_render_children;
2502
+ })($ || ($ = {}));
2503
+
2504
+ ;
2505
+ "use strict";
2506
+
2507
+ ;
2508
+ "use strict";
2509
+ var $;
2510
+ (function ($) {
2511
+ $.$mol_jsx_prefix = '';
2512
+ $.$mol_jsx_crumbs = '';
2513
+ $.$mol_jsx_booked = null;
2514
+ $.$mol_jsx_document = {
2515
+ getElementById: () => null,
2516
+ createElementNS: (space, name) => $mol_dom_context.document.createElementNS(space, name),
2517
+ createDocumentFragment: () => $mol_dom_context.document.createDocumentFragment(),
2518
+ };
2519
+ $.$mol_jsx_frag = '';
2520
+ function $mol_jsx(Elem, props, ...childNodes) {
2521
+ const id = props && props.id || '';
2522
+ const guid = id ? $.$mol_jsx_prefix ? $.$mol_jsx_prefix + '/' + id : id : $.$mol_jsx_prefix;
2523
+ const crumbs_self = id ? $.$mol_jsx_crumbs.replace(/(\S+)/g, `$1_${id.replace(/\/.*/i, '')}`) : $.$mol_jsx_crumbs;
2524
+ if (Elem && $.$mol_jsx_booked) {
2525
+ if ($.$mol_jsx_booked.has(id)) {
2526
+ $mol_fail(new Error(`JSX already has tag with id ${JSON.stringify(guid)}`));
2527
+ }
2528
+ else {
2529
+ $.$mol_jsx_booked.add(id);
2530
+ }
2531
+ }
2532
+ let node = guid ? $.$mol_jsx_document.getElementById(guid) : null;
2533
+ if ($.$mol_jsx_prefix) {
2534
+ const prefix_ext = $.$mol_jsx_prefix;
2535
+ const booked_ext = $.$mol_jsx_booked;
2536
+ const crumbs_ext = $.$mol_jsx_crumbs;
2537
+ for (const field in props) {
2538
+ const func = props[field];
2539
+ if (typeof func !== 'function')
2540
+ continue;
2541
+ const wrapper = function (...args) {
2542
+ const prefix = $.$mol_jsx_prefix;
2543
+ const booked = $.$mol_jsx_booked;
2544
+ const crumbs = $.$mol_jsx_crumbs;
2545
+ try {
2546
+ $.$mol_jsx_prefix = prefix_ext;
2547
+ $.$mol_jsx_booked = booked_ext;
2548
+ $.$mol_jsx_crumbs = crumbs_ext;
2549
+ return func.call(this, ...args);
2550
+ }
2551
+ finally {
2552
+ $.$mol_jsx_prefix = prefix;
2553
+ $.$mol_jsx_booked = booked;
2554
+ $.$mol_jsx_crumbs = crumbs;
2555
+ }
2556
+ };
2557
+ $mol_func_name_from(wrapper, func);
2558
+ props[field] = wrapper;
2559
+ }
2560
+ }
2561
+ if (typeof Elem !== 'string') {
2562
+ if ('prototype' in Elem) {
2563
+ const view = node && node[String(Elem)] || new Elem;
2564
+ Object.assign(view, props);
2565
+ view[Symbol.toStringTag] = guid;
2566
+ view.childNodes = childNodes;
2567
+ if (!view.ownerDocument)
2568
+ view.ownerDocument = $.$mol_jsx_document;
2569
+ view.className = (crumbs_self ? crumbs_self + ' ' : '') + (Elem['name'] || Elem);
2570
+ node = view.valueOf();
2571
+ node[String(Elem)] = view;
2572
+ return node;
2573
+ }
2574
+ else {
2575
+ const prefix = $.$mol_jsx_prefix;
2576
+ const booked = $.$mol_jsx_booked;
2577
+ const crumbs = $.$mol_jsx_crumbs;
2578
+ try {
2579
+ $.$mol_jsx_prefix = guid;
2580
+ $.$mol_jsx_booked = new Set;
2581
+ $.$mol_jsx_crumbs = (crumbs_self ? crumbs_self + ' ' : '') + (Elem['name'] || Elem);
2582
+ return Elem(props, ...childNodes);
2583
+ }
2584
+ finally {
2585
+ $.$mol_jsx_prefix = prefix;
2586
+ $.$mol_jsx_booked = booked;
2587
+ $.$mol_jsx_crumbs = crumbs;
2588
+ }
2589
+ }
2590
+ }
2591
+ if (!node) {
2592
+ node = Elem
2593
+ ? $.$mol_jsx_document.createElementNS(props?.xmlns ?? 'http://www.w3.org/1999/xhtml', Elem)
2594
+ : $.$mol_jsx_document.createDocumentFragment();
2595
+ }
2596
+ $mol_dom_render_children(node, [].concat(...childNodes));
2597
+ if (!Elem)
2598
+ return node;
2599
+ if (guid)
2600
+ node.id = guid;
2601
+ for (const key in props) {
2602
+ if (key === 'id')
2603
+ continue;
2604
+ if (typeof props[key] === 'string') {
2605
+ if (typeof node[key] === 'string')
2606
+ node[key] = props[key];
2607
+ node.setAttribute(key, props[key]);
2608
+ }
2609
+ else if (props[key] &&
2610
+ typeof props[key] === 'object' &&
2611
+ Reflect.getPrototypeOf(props[key]) === Reflect.getPrototypeOf({})) {
2612
+ if (typeof node[key] === 'object') {
2613
+ Object.assign(node[key], props[key]);
2614
+ continue;
2615
+ }
2616
+ }
2617
+ else {
2618
+ node[key] = props[key];
2619
+ }
2620
+ }
2621
+ if ($.$mol_jsx_crumbs)
2622
+ node.className = (props?.['class'] ? props['class'] + ' ' : '') + crumbs_self;
2623
+ return node;
2624
+ }
2625
+ $.$mol_jsx = $mol_jsx;
2626
+ })($ || ($ = {}));
2627
+
2628
+ ;
2629
+ "use strict";
2630
+ var $;
2631
+ (function ($) {
2632
+ class $mol_window extends $mol_object {
2633
+ static size() {
2634
+ return {
2635
+ width: 1024,
2636
+ height: 768,
2637
+ };
2638
+ }
2639
+ }
2640
+ $.$mol_window = $mol_window;
2641
+ })($ || ($ = {}));
2398
2642
 
2399
2643
  ;
2400
2644
  "use strict";
@@ -2742,1421 +2986,10 @@ var $;
2742
2986
  "use strict";
2743
2987
  var $;
2744
2988
  (function ($) {
2745
- $.$mol_action = $mol_wire_method;
2746
- })($ || ($ = {}));
2747
-
2748
- ;
2749
- "use strict";
2750
- var $;
2751
- (function ($) {
2752
- class $mol_state_arg extends $mol_object {
2753
- prefix;
2754
- static prolog = '';
2755
- static separator = ' ';
2756
- static href(next) {
2757
- return next || process.argv.slice(2).join(' ');
2758
- }
2759
- static href_normal() {
2760
- return this.link({});
2761
- }
2762
- static dict(next) {
2763
- if (next !== void 0)
2764
- this.href(this.make_link(next));
2765
- var href = this.href();
2766
- var chunks = href.split(' ');
2767
- var params = {};
2768
- chunks.forEach(chunk => {
2769
- if (!chunk)
2770
- return;
2771
- var vals = chunk.split('=').map(decodeURIComponent);
2772
- params[vals.shift()] = vals.join('=');
2773
- });
2774
- return params;
2775
- }
2776
- static value(key, next) {
2777
- if (next === void 0)
2778
- return this.dict()[key] ?? null;
2779
- this.href(this.link({ [key]: next }));
2780
- return next;
2781
- }
2782
- static link(next) {
2783
- const params = {};
2784
- var prev = this.dict();
2785
- for (var key in prev) {
2786
- params[key] = prev[key];
2787
- }
2788
- for (var key in next) {
2789
- params[key] = next[key];
2790
- }
2791
- return this.make_link(params);
2792
- }
2793
- static make_link(next) {
2794
- const chunks = [];
2795
- for (const key in next) {
2796
- if (next[key] !== null) {
2797
- chunks.push([key, next[key]].map(encodeURIComponent).join('='));
2798
- }
2799
- }
2800
- return chunks.join(' ');
2801
- }
2802
- static go(next) {
2803
- this.href(this.link(next));
2804
- }
2805
- static commit() { }
2806
- constructor(prefix = '') {
2807
- super();
2808
- this.prefix = prefix;
2809
- }
2810
- value(key, next) {
2811
- return this.constructor.value(this.prefix + key, next);
2812
- }
2813
- sub(postfix) {
2814
- return new this.constructor(this.prefix + postfix + '.');
2815
- }
2816
- link(next) {
2817
- const prefix = this.prefix;
2818
- const dict = {};
2819
- for (var key in next) {
2820
- dict[prefix + key] = next[key];
2821
- }
2822
- return this.constructor.link(dict);
2823
- }
2824
- }
2825
- __decorate([
2826
- $mol_mem
2827
- ], $mol_state_arg, "href", null);
2828
- __decorate([
2829
- $mol_mem
2830
- ], $mol_state_arg, "href_normal", null);
2831
- __decorate([
2832
- $mol_mem
2833
- ], $mol_state_arg, "dict", null);
2834
- __decorate([
2835
- $mol_mem_key
2836
- ], $mol_state_arg, "value", null);
2837
- __decorate([
2838
- $mol_action
2839
- ], $mol_state_arg, "go", null);
2840
- $.$mol_state_arg = $mol_state_arg;
2841
- })($ || ($ = {}));
2842
-
2843
- ;
2844
- "use strict";
2845
- var $;
2846
- (function ($) {
2847
- class $mol_media extends $mol_object2 {
2848
- static match(query, next) {
2849
- if (next !== undefined)
2850
- return next;
2851
- const res = this.$.$mol_dom_context.matchMedia?.(query) ?? {};
2852
- res.onchange = () => this.match(query, res.matches);
2853
- return res.matches;
2854
- }
2855
- }
2856
- __decorate([
2857
- $mol_mem_key
2858
- ], $mol_media, "match", null);
2859
- $.$mol_media = $mol_media;
2860
- })($ || ($ = {}));
2861
-
2862
- ;
2863
- "use strict";
2864
- var $;
2865
- (function ($) {
2866
- function $mol_wire_solid() {
2867
- let current = $mol_wire_auto();
2868
- if (current.temp)
2869
- current = current.host;
2870
- if (current.reap !== nothing) {
2871
- current?.sub_on(sub, sub.data.length);
2872
- }
2873
- current.reap = nothing;
2874
- }
2875
- $.$mol_wire_solid = $mol_wire_solid;
2876
- const nothing = () => { };
2877
- const sub = new $mol_wire_pub_sub;
2878
- })($ || ($ = {}));
2879
-
2880
- ;
2881
- "use strict";
2882
- var $;
2883
- (function ($) {
2884
- $.$mol_mem_persist = $mol_wire_solid;
2885
- })($ || ($ = {}));
2886
-
2887
- ;
2888
- "use strict";
2889
- var $;
2890
- (function ($) {
2891
- function $mol_wire_probe(task, def) {
2892
- const warm = $mol_wire_fiber.warm;
2893
- try {
2894
- $mol_wire_fiber.warm = false;
2895
- const res = task();
2896
- if (res === undefined)
2897
- return def;
2898
- return res;
2899
- }
2900
- finally {
2901
- $mol_wire_fiber.warm = warm;
2902
- }
2903
- }
2904
- $.$mol_wire_probe = $mol_wire_probe;
2905
- })($ || ($ = {}));
2906
-
2907
- ;
2908
- "use strict";
2909
- var $;
2910
- (function ($) {
2911
- $.$mol_mem_cached = $mol_wire_probe;
2912
- })($ || ($ = {}));
2913
-
2914
- ;
2915
- "use strict";
2916
- var $;
2917
- (function ($) {
2918
- function $mol_wait_user_async() {
2919
- return new Promise(done => $mol_dom.addEventListener('click', function onclick() {
2920
- $mol_dom.removeEventListener('click', onclick);
2921
- done(null);
2922
- }));
2923
- }
2924
- $.$mol_wait_user_async = $mol_wait_user_async;
2925
- function $mol_wait_user() {
2926
- return this.$mol_wire_sync(this).$mol_wait_user_async();
2927
- }
2928
- $.$mol_wait_user = $mol_wait_user;
2929
- })($ || ($ = {}));
2930
-
2931
- ;
2932
- "use strict";
2933
- var $;
2934
- (function ($) {
2935
- class $mol_storage extends $mol_object2 {
2936
- static native() {
2937
- return this.$.$mol_dom_context.navigator.storage ?? {
2938
- persisted: async () => false,
2939
- persist: async () => false,
2940
- estimate: async () => ({}),
2941
- getDirectory: async () => null,
2942
- };
2943
- }
2944
- static persisted(next, cache) {
2945
- $mol_mem_persist();
2946
- if (cache)
2947
- return Boolean(next);
2948
- const native = this.native();
2949
- if (next && !$mol_mem_cached(() => this.persisted())) {
2950
- this.$.$mol_wait_user_async()
2951
- .then(() => native.persist())
2952
- .then(actual => {
2953
- setTimeout(() => this.persisted(actual, 'cache'), 5000);
2954
- if (actual)
2955
- this.$.$mol_log3_done({ place: `$mol_storage`, message: `Persist: Yes` });
2956
- else
2957
- this.$.$mol_log3_fail({ place: `$mol_storage`, message: `Persist: No` });
2958
- });
2959
- }
2960
- return next ?? $mol_wire_sync(native).persisted();
2961
- }
2962
- static estimate() {
2963
- return $mol_wire_sync(this.native() ?? {}).estimate();
2964
- }
2965
- static dir() {
2966
- return $mol_wire_sync(this.native()).getDirectory();
2967
- }
2968
- }
2969
- __decorate([
2970
- $mol_mem
2971
- ], $mol_storage, "native", null);
2972
- __decorate([
2973
- $mol_mem
2974
- ], $mol_storage, "persisted", null);
2975
- $.$mol_storage = $mol_storage;
2976
- })($ || ($ = {}));
2977
-
2978
- ;
2979
- "use strict";
2980
- var $;
2981
- (function ($) {
2982
- class $mol_state_local extends $mol_object {
2983
- static 'native()';
2984
- static native() {
2985
- if (this['native()'])
2986
- return this['native()'];
2987
- check: try {
2988
- const native = $mol_dom_context.localStorage;
2989
- if (!native)
2990
- break check;
2991
- native.setItem('', '');
2992
- native.removeItem('');
2993
- return this['native()'] = native;
2994
- }
2995
- catch (error) {
2996
- console.warn(error);
2997
- }
2998
- return this['native()'] = {
2999
- getItem(key) {
3000
- return this[':' + key];
3001
- },
3002
- setItem(key, value) {
3003
- this[':' + key] = value;
3004
- },
3005
- removeItem(key) {
3006
- this[':' + key] = void 0;
3007
- }
3008
- };
3009
- }
3010
- static changes(next) { return next; }
3011
- static value(key, next) {
3012
- this.changes();
3013
- if (next === void 0)
3014
- return JSON.parse(this.native().getItem(key) || 'null');
3015
- if (next === null) {
3016
- this.native().removeItem(key);
3017
- }
3018
- else {
3019
- this.native().setItem(key, JSON.stringify(next));
3020
- this.$.$mol_storage.persisted(true);
3021
- }
3022
- return next;
3023
- }
3024
- prefix() { return ''; }
3025
- value(key, next) {
3026
- return $mol_state_local.value(this.prefix() + '.' + key, next);
3027
- }
3028
- }
3029
- __decorate([
3030
- $mol_mem
3031
- ], $mol_state_local, "changes", null);
3032
- __decorate([
3033
- $mol_mem_key
3034
- ], $mol_state_local, "value", null);
3035
- $.$mol_state_local = $mol_state_local;
3036
- })($ || ($ = {}));
3037
-
3038
- ;
3039
- "use strict";
3040
- var $;
3041
- (function ($) {
3042
- function $mol_const(value) {
3043
- const getter = (() => value);
3044
- getter['()'] = value;
3045
- getter[Symbol.toStringTag] = value;
3046
- getter[$mol_dev_format_head] = () => $mol_dev_format_span({}, '()=> ', $mol_dev_format_auto(value));
3047
- return getter;
3048
- }
3049
- $.$mol_const = $mol_const;
3050
- })($ || ($ = {}));
3051
-
3052
- ;
3053
- "use strict";
3054
- var $;
3055
- (function ($) {
3056
- function $mol_wire_async(obj) {
3057
- let fiber;
3058
- const temp = $mol_wire_task.getter(obj);
3059
- return new Proxy(obj, {
3060
- get(obj, field) {
3061
- const val = obj[field];
3062
- if (typeof val !== 'function')
3063
- return val;
3064
- let fiber;
3065
- const temp = $mol_wire_task.getter(val);
3066
- return function $mol_wire_async(...args) {
3067
- fiber?.destructor();
3068
- fiber = temp(obj, args);
3069
- return fiber.async();
3070
- };
3071
- },
3072
- apply(obj, self, args) {
3073
- fiber?.destructor();
3074
- fiber = temp(self, args);
3075
- return fiber.async();
3076
- },
3077
- });
3078
- }
3079
- $.$mol_wire_async = $mol_wire_async;
3080
- })($ || ($ = {}));
3081
-
3082
- ;
3083
- "use strict";
3084
- var $;
3085
- (function ($) {
3086
- class $mol_lock extends $mol_object {
3087
- promise = null;
3088
- async wait() {
3089
- let next = () => { };
3090
- let destructed = false;
3091
- const task = $mol_wire_auto();
3092
- if (!task)
3093
- return next;
3094
- const destructor = task.destructor.bind(task);
3095
- task.destructor = () => {
3096
- destructor();
3097
- destructed = true;
3098
- next();
3099
- };
3100
- let promise;
3101
- do {
3102
- promise = this.promise;
3103
- await promise;
3104
- if (destructed)
3105
- return next;
3106
- } while (promise !== this.promise);
3107
- this.promise = new Promise(done => { next = done; });
3108
- return next;
3109
- }
3110
- grab() { return $mol_wire_sync(this).wait(); }
3111
- }
3112
- $.$mol_lock = $mol_lock;
3113
- })($ || ($ = {}));
3114
-
3115
- ;
3116
- "use strict";
3117
- var $;
3118
- (function ($) {
3119
- function $mol_compare_array(a, b) {
3120
- if (a === b)
3121
- return true;
3122
- if (Object.getPrototypeOf(a) !== Object.getPrototypeOf(b))
3123
- return false;
3124
- if (a.length !== b.length)
3125
- return false;
3126
- for (let i = 0; i < a.length; i++)
3127
- if (a[i] !== b[i])
3128
- return false;
3129
- return true;
3130
- }
3131
- $.$mol_compare_array = $mol_compare_array;
3132
- })($ || ($ = {}));
3133
-
3134
- ;
3135
- "use strict";
3136
-
3137
- ;
3138
- "use strict";
3139
- var $;
3140
- (function ($) {
3141
- const decoders = {};
3142
- function $mol_charset_decode(buffer, encoding = 'utf8') {
3143
- let decoder = decoders[encoding];
3144
- if (!decoder)
3145
- decoder = decoders[encoding] = new TextDecoder(encoding);
3146
- return decoder.decode(buffer);
3147
- }
3148
- $.$mol_charset_decode = $mol_charset_decode;
3149
- })($ || ($ = {}));
3150
-
3151
- ;
3152
- "use strict";
3153
- var $;
3154
- (function ($) {
3155
- let buf = new Uint8Array(2 ** 12);
3156
- function $mol_charset_buffer(size) {
3157
- if (buf.byteLength < size)
3158
- buf = new Uint8Array(size);
3159
- return buf;
3160
- }
3161
- $.$mol_charset_buffer = $mol_charset_buffer;
3162
- })($ || ($ = {}));
3163
-
3164
- ;
3165
- "use strict";
3166
- var $;
3167
- (function ($) {
3168
- function $mol_charset_encode(str) {
3169
- const buf = $mol_charset_buffer(str.length * 3);
3170
- return buf.slice(0, $mol_charset_encode_to(str, buf));
3171
- }
3172
- $.$mol_charset_encode = $mol_charset_encode;
3173
- function $mol_charset_encode_to(str, buf, from = 0) {
3174
- let pos = from;
3175
- for (let i = 0; i < str.length; i++) {
3176
- let code = str.charCodeAt(i);
3177
- if (code < 0x80) {
3178
- buf[pos++] = code;
3179
- }
3180
- else if (code < 0x800) {
3181
- buf[pos++] = 0xc0 | (code >> 6);
3182
- buf[pos++] = 0x80 | (code & 0x3f);
3183
- }
3184
- else if (code < 0xd800 || code >= 0xe000) {
3185
- buf[pos++] = 0xe0 | (code >> 12);
3186
- buf[pos++] = 0x80 | ((code >> 6) & 0x3f);
3187
- buf[pos++] = 0x80 | (code & 0x3f);
3188
- }
3189
- else {
3190
- const point = ((code - 0xd800) << 10) + str.charCodeAt(++i) + 0x2400;
3191
- buf[pos++] = 0xf0 | (point >> 18);
3192
- buf[pos++] = 0x80 | ((point >> 12) & 0x3f);
3193
- buf[pos++] = 0x80 | ((point >> 6) & 0x3f);
3194
- buf[pos++] = 0x80 | (point & 0x3f);
3195
- }
3196
- }
3197
- return pos - from;
3198
- }
3199
- $.$mol_charset_encode_to = $mol_charset_encode_to;
3200
- function $mol_charset_encode_size(str) {
3201
- let size = 0;
3202
- for (let i = 0; i < str.length; i++) {
3203
- let code = str.charCodeAt(i);
3204
- if (code < 0x80)
3205
- size += 1;
3206
- else if (code < 0x800)
3207
- size += 2;
3208
- else if (code < 0xd800 || code >= 0xe000)
3209
- size += 3;
3210
- else
3211
- size += 4;
3212
- }
3213
- return size;
3214
- }
3215
- $.$mol_charset_encode_size = $mol_charset_encode_size;
3216
- })($ || ($ = {}));
3217
-
3218
- ;
3219
- "use strict";
3220
- var $;
3221
- (function ($) {
3222
- class $mol_file_transaction extends $mol_object {
3223
- path() { return ''; }
3224
- modes() { return []; }
3225
- write(options) {
3226
- throw new Error('Not implemented');
3227
- }
3228
- read() {
3229
- throw new Error('Not implemented');
3230
- }
3231
- truncate(size) {
3232
- throw new Error('Not implemented');
3233
- }
3234
- flush() {
3235
- throw new Error('Not implemented');
3236
- }
3237
- close() {
3238
- throw new Error('Not implemented');
3239
- }
3240
- destructor() {
3241
- this.close();
3242
- }
3243
- }
3244
- $.$mol_file_transaction = $mol_file_transaction;
3245
- })($ || ($ = {}));
3246
-
3247
- ;
3248
- "use strict";
3249
- var $;
3250
- (function ($) {
3251
- let file_modes;
3252
- (function (file_modes) {
3253
- file_modes[file_modes["create"] = $node.fs.constants.O_CREAT] = "create";
3254
- file_modes[file_modes["exists_truncate"] = $node.fs.constants.O_TRUNC] = "exists_truncate";
3255
- file_modes[file_modes["exists_fail"] = $node.fs.constants.O_EXCL] = "exists_fail";
3256
- file_modes[file_modes["read_only"] = $node.fs.constants.O_RDONLY] = "read_only";
3257
- file_modes[file_modes["write_only"] = $node.fs.constants.O_WRONLY] = "write_only";
3258
- file_modes[file_modes["read_write"] = $node.fs.constants.O_RDWR] = "read_write";
3259
- file_modes[file_modes["append"] = $node.fs.constants.O_APPEND] = "append";
3260
- })(file_modes || (file_modes = {}));
3261
- function mode_mask(modes) {
3262
- return modes.reduce((res, mode) => res | file_modes[mode], 0);
3263
- }
3264
- class $mol_file_transaction_node extends $mol_file_transaction {
3265
- descr() {
3266
- $mol_wire_solid();
3267
- return $node.fs.openSync(this.path(), mode_mask(this.modes()));
3268
- }
3269
- write({ buffer, offset = 0, length, position = null }) {
3270
- if (Array.isArray(buffer)) {
3271
- return $node.fs.writevSync(this.descr(), buffer, position ?? undefined);
3272
- }
3273
- if (typeof buffer === 'string') {
3274
- return $node.fs.writeSync(this.descr(), buffer, position);
3275
- }
3276
- length = length ?? buffer.byteLength;
3277
- return $node.fs.writeSync(this.descr(), buffer, offset, length, position);
3278
- }
3279
- truncate(size) {
3280
- $node.fs.ftruncateSync(this.descr());
3281
- }
3282
- read() {
3283
- return $mol_file_node_buffer_normalize($node.fs.readFileSync(this.descr()));
3284
- }
3285
- flush() {
3286
- $node.fs.fsyncSync(this.descr());
3287
- }
3288
- close() {
3289
- $node.fs.closeSync(this.descr());
3290
- }
3291
- }
3292
- __decorate([
3293
- $mol_mem
3294
- ], $mol_file_transaction_node.prototype, "descr", null);
3295
- $.$mol_file_transaction_node = $mol_file_transaction_node;
3296
- $.$mol_file_transaction = $mol_file_transaction_node;
3297
- })($ || ($ = {}));
3298
-
3299
- ;
3300
- "use strict";
3301
- var $;
3302
- (function ($) {
3303
- class $mol_file_base extends $mol_object {
3304
- static absolute(path) {
3305
- return this.make({
3306
- path: $mol_const(path)
3307
- });
3308
- }
3309
- static relative(path) {
3310
- throw new Error('Not implemented yet');
3311
- }
3312
- static base = '';
3313
- path() {
3314
- return '.';
3315
- }
3316
- parent() {
3317
- return this.resolve('..');
3318
- }
3319
- exists_cut() { return this.exists(); }
3320
- root() {
3321
- const path = this.path();
3322
- const base = this.constructor.base;
3323
- return base.startsWith(path) || this == this.parent();
3324
- }
3325
- stat(next, virt) {
3326
- const path = this.path();
3327
- const parent = this.parent();
3328
- if (!this.root()) {
3329
- parent.version();
3330
- }
3331
- parent.watcher();
3332
- if (virt)
3333
- return next ?? null;
3334
- return next ?? this.info(path);
3335
- }
3336
- static changed = new Set;
3337
- static frame = null;
3338
- static changed_add(type, path) {
3339
- if (/([\/\\]\.|___$)/.test(path))
3340
- return;
3341
- const file = this.relative(path.at(-1) === '/' ? path.slice(0, -1) : path);
3342
- this.changed.add(file);
3343
- if (!this.watching)
3344
- return;
3345
- this.frame?.destructor();
3346
- this.frame = new this.$.$mol_after_timeout(this.watch_debounce(), () => {
3347
- if (!this.watching)
3348
- return;
3349
- this.watching = false;
3350
- $mol_wire_async(this).flush();
3351
- });
3352
- }
3353
- static watch_debounce() { return 500; }
3354
- static flush() {
3355
- for (const file of this.changed) {
3356
- const parent = file.parent();
3357
- try {
3358
- if ($mol_wire_probe(() => parent.sub()))
3359
- parent.sub(null);
3360
- file.reset();
3361
- }
3362
- catch (error) {
3363
- if ($mol_fail_catch(error))
3364
- $mol_fail_log(error);
3365
- }
3366
- }
3367
- this.changed.clear();
3368
- this.watching = true;
3369
- }
3370
- static watching = true;
3371
- static lock = new $mol_lock;
3372
- static watch_off(path) {
3373
- this.watching = false;
3374
- this.flush();
3375
- this.watching = false;
3376
- this.changed.add(this.absolute(path));
3377
- }
3378
- static unwatched(side_effect, affected_dir) {
3379
- const unlock = this.lock.grab();
3380
- this.watch_off(affected_dir);
3381
- try {
3382
- const result = side_effect();
3383
- this.flush();
3384
- unlock();
3385
- return result;
3386
- }
3387
- catch (e) {
3388
- if (!$mol_promise_like(e)) {
3389
- this.flush();
3390
- unlock();
3391
- }
3392
- $mol_fail_hidden(e);
3393
- }
3394
- }
3395
- reset() {
3396
- this.stat(null);
3397
- }
3398
- modified() { return this.stat()?.mtime ?? null; }
3399
- version() {
3400
- const next = this.stat()?.mtime.getTime().toString(36).toUpperCase() ?? '';
3401
- return next;
3402
- }
3403
- info(path) { return null; }
3404
- ensure() { }
3405
- drop() { }
3406
- copy(to) { }
3407
- read() { return new Uint8Array; }
3408
- write(buffer) { }
3409
- kids() {
3410
- return [];
3411
- }
3412
- readable(opts) {
3413
- return new ReadableStream;
3414
- }
3415
- writable(opts) {
3416
- return new WritableStream;
3417
- }
3418
- buffer(next) {
3419
- let readed = new Uint8Array();
3420
- if (next === undefined) {
3421
- if (this.version())
3422
- readed = this.read();
3423
- }
3424
- const prev = $mol_mem_cached(() => this.buffer());
3425
- const changed = prev === undefined || !$mol_compare_array(prev, next ?? readed);
3426
- if (prev !== undefined && changed) {
3427
- this.$.$mol_log3_rise({
3428
- place: `$mol_file_node.buffer()`,
3429
- message: 'Changed',
3430
- path: this.relate(),
3431
- });
3432
- }
3433
- if (next === undefined)
3434
- return changed ? readed : prev;
3435
- if (!changed && this.exists())
3436
- return prev;
3437
- this.parent().exists(true);
3438
- this.stat(this.stat_make(next.length), 'virt');
3439
- this.write(next);
3440
- return next;
3441
- }
3442
- stat_make(size) {
3443
- const now = new Date();
3444
- return {
3445
- type: 'file',
3446
- size,
3447
- atime: now,
3448
- mtime: now,
3449
- ctime: now,
3450
- };
3451
- }
3452
- clone(to) {
3453
- if (!this.exists())
3454
- return null;
3455
- const target = this.constructor.absolute(to);
3456
- try {
3457
- this.version();
3458
- target.parent().exists(true);
3459
- this.copy(to);
3460
- target.reset();
3461
- return target;
3462
- }
3463
- catch (error) {
3464
- if ($mol_fail_catch(error)) {
3465
- console.error(error);
3466
- }
3467
- }
3468
- return null;
3469
- }
3470
- watcher() {
3471
- return {
3472
- destructor() { }
3473
- };
3474
- }
3475
- exists(next) {
3476
- const exists = Boolean(this.stat());
3477
- if (next === undefined)
3478
- return exists;
3479
- if (next === exists)
3480
- return exists;
3481
- if (next) {
3482
- this.parent().exists(true);
3483
- this.ensure();
3484
- }
3485
- else {
3486
- this.drop();
3487
- }
3488
- this.reset();
3489
- return next;
3490
- }
3491
- type() {
3492
- return this.stat()?.type ?? '';
3493
- }
3494
- name() {
3495
- return this.path().replace(/^.*\//, '');
3496
- }
3497
- ext() {
3498
- const match = /((?:\.\w+)+)$/.exec(this.path());
3499
- return match ? match[1].substring(1) : '';
3500
- }
3501
- text(next, virt) {
3502
- if (next !== undefined)
3503
- this.exists();
3504
- return this.text_int(next, virt);
3505
- }
3506
- text_int(next, virt) {
3507
- if (virt) {
3508
- this.stat(this.stat_make(0), 'virt');
3509
- return next;
3510
- }
3511
- if (next === undefined) {
3512
- return $mol_charset_decode(this.buffer());
3513
- }
3514
- else {
3515
- const buffer = $mol_charset_encode(next);
3516
- this.buffer(buffer);
3517
- return next;
3518
- }
3519
- }
3520
- sub(reset) {
3521
- if (!this.exists())
3522
- return [];
3523
- if (this.type() !== 'dir')
3524
- return [];
3525
- this.version();
3526
- return this.kids().filter(file => file.exists());
3527
- }
3528
- resolve(path) {
3529
- throw new Error('implement');
3530
- }
3531
- relate(base = this.constructor.relative('.')) {
3532
- const base_path = base.path();
3533
- const path = this.path();
3534
- return path.startsWith(base_path) ? path.slice(base_path.length) : path;
3535
- }
3536
- find(include, exclude) {
3537
- const found = [];
3538
- const sub = this.sub();
3539
- for (const child of sub) {
3540
- const child_path = child.path();
3541
- if (exclude && child_path.match(exclude))
3542
- continue;
3543
- if (!include || child_path.match(include))
3544
- found.push(child);
3545
- if (child.type() === 'dir') {
3546
- const sub_child = child.find(include, exclude);
3547
- for (const child of sub_child)
3548
- found.push(child);
3549
- }
3550
- }
3551
- return found;
3552
- }
3553
- size() {
3554
- switch (this.type()) {
3555
- case 'file': return this.stat()?.size ?? 0;
3556
- default: return 0;
3557
- }
3558
- }
3559
- toJSON() {
3560
- return this.path();
3561
- }
3562
- open(...modes) {
3563
- return this.$.$mol_file_transaction.make({
3564
- path: () => this.path(),
3565
- modes: () => modes
3566
- });
3567
- }
3568
- }
3569
- __decorate([
3570
- $mol_action
3571
- ], $mol_file_base.prototype, "exists_cut", null);
3572
- __decorate([
3573
- $mol_mem
3574
- ], $mol_file_base.prototype, "stat", null);
3575
- __decorate([
3576
- $mol_mem
3577
- ], $mol_file_base.prototype, "modified", null);
3578
- __decorate([
3579
- $mol_mem
3580
- ], $mol_file_base.prototype, "version", null);
3581
- __decorate([
3582
- $mol_mem_key
3583
- ], $mol_file_base.prototype, "readable", null);
3584
- __decorate([
3585
- $mol_mem_key
3586
- ], $mol_file_base.prototype, "writable", null);
3587
- __decorate([
3588
- $mol_mem
3589
- ], $mol_file_base.prototype, "buffer", null);
3590
- __decorate([
3591
- $mol_action
3592
- ], $mol_file_base.prototype, "stat_make", null);
3593
- __decorate([
3594
- $mol_mem_key
3595
- ], $mol_file_base.prototype, "clone", null);
3596
- __decorate([
3597
- $mol_mem
3598
- ], $mol_file_base.prototype, "exists", null);
3599
- __decorate([
3600
- $mol_mem
3601
- ], $mol_file_base.prototype, "type", null);
3602
- __decorate([
3603
- $mol_mem
3604
- ], $mol_file_base.prototype, "text_int", null);
3605
- __decorate([
3606
- $mol_mem
3607
- ], $mol_file_base.prototype, "sub", null);
3608
- __decorate([
3609
- $mol_mem
3610
- ], $mol_file_base.prototype, "size", null);
3611
- __decorate([
3612
- $mol_action
3613
- ], $mol_file_base.prototype, "open", null);
3614
- __decorate([
3615
- $mol_mem_key
3616
- ], $mol_file_base, "absolute", null);
3617
- __decorate([
3618
- $mol_action
3619
- ], $mol_file_base, "flush", null);
3620
- __decorate([
3621
- $mol_action
3622
- ], $mol_file_base, "watch_off", null);
3623
- $.$mol_file_base = $mol_file_base;
3624
- })($ || ($ = {}));
3625
-
3626
- ;
3627
- "use strict";
3628
- var $;
3629
- (function ($) {
3630
- class $mol_file extends $mol_file_base {
3631
- }
3632
- $.$mol_file = $mol_file;
3633
- })($ || ($ = {}));
3634
-
3635
- ;
3636
- "use strict";
3637
- var $;
3638
- (function ($) {
3639
- function stat_convert(stat) {
3640
- if (!stat)
3641
- return null;
3642
- let type;
3643
- if (stat.isDirectory())
3644
- type = 'dir';
3645
- if (stat.isFile())
3646
- type = 'file';
3647
- if (stat.isSymbolicLink())
3648
- type = 'link';
3649
- if (!type)
3650
- return $mol_fail(new Error(`Unsupported file type`));
3651
- return {
3652
- type,
3653
- size: Number(stat.size),
3654
- atime: stat.atime,
3655
- mtime: stat.mtime,
3656
- ctime: stat.ctime
3657
- };
3658
- }
3659
- function $mol_file_node_buffer_normalize(buf) {
3660
- return new Uint8Array(buf.buffer, buf.byteOffset, buf.byteLength);
3661
- }
3662
- $.$mol_file_node_buffer_normalize = $mol_file_node_buffer_normalize;
3663
- class $mol_file_node extends $mol_file {
3664
- static relative(path) {
3665
- return this.absolute($node.path.resolve(this.base, path).replace(/\\/g, '/'));
3666
- }
3667
- watcher(reset) {
3668
- const path = this.path();
3669
- const root = this.root();
3670
- if (!root && !this.exists())
3671
- return super.watcher();
3672
- let watcher;
3673
- try {
3674
- watcher = $node.fs.watch(path);
3675
- }
3676
- catch (error) {
3677
- if (!(error instanceof Error))
3678
- error = new Error('Unknown watch error', { cause: error });
3679
- error.message += '\n' + path;
3680
- if (root || error.code !== 'ENOENT') {
3681
- this.$.$mol_fail_log(error);
3682
- }
3683
- return super.watcher();
3684
- }
3685
- watcher.on('change', (type, name) => {
3686
- if (!name)
3687
- return;
3688
- const path = $node.path.join(this.path(), name.toString());
3689
- this.constructor.changed_add(type, path);
3690
- });
3691
- watcher.on('error', e => this.$.$mol_fail_log(e));
3692
- let destructed = false;
3693
- watcher.on('close', () => {
3694
- if (!destructed)
3695
- setTimeout(() => $mol_wire_async(this).watcher(null), 500);
3696
- });
3697
- return {
3698
- destructor() {
3699
- destructed = true;
3700
- watcher.close();
3701
- }
3702
- };
3703
- }
3704
- info(path) {
3705
- try {
3706
- return stat_convert($node.fs.statSync(path));
3707
- }
3708
- catch (error) {
3709
- if (this.$.$mol_fail_catch(error)) {
3710
- if (error.code === 'ENOENT')
3711
- return null;
3712
- if (error.code === 'EPERM')
3713
- return null;
3714
- error.message += '\n' + path;
3715
- this.$.$mol_fail_hidden(error);
3716
- }
3717
- }
3718
- return null;
3719
- }
3720
- ensure() {
3721
- const path = this.path();
3722
- try {
3723
- $node.fs.mkdirSync(path, { recursive: true });
3724
- return null;
3725
- }
3726
- catch (e) {
3727
- if (this.$.$mol_fail_catch(e)) {
3728
- if (e.code === 'EEXIST')
3729
- return null;
3730
- e.message += '\n' + path;
3731
- this.$.$mol_fail_hidden(e);
3732
- }
3733
- }
3734
- }
3735
- copy(to) {
3736
- $node.fs.copyFileSync(this.path(), to);
3737
- }
3738
- drop() {
3739
- $node.fs.unlinkSync(this.path());
3740
- }
3741
- read() {
3742
- const path = this.path();
3743
- try {
3744
- return $mol_file_node_buffer_normalize($node.fs.readFileSync(path));
3745
- }
3746
- catch (error) {
3747
- if (!$mol_promise_like(error)) {
3748
- error.message += '\n' + path;
3749
- }
3750
- $mol_fail_hidden(error);
3751
- }
3752
- }
3753
- write(buffer) {
3754
- const path = this.path();
3755
- try {
3756
- $node.fs.writeFileSync(path, buffer);
3757
- }
3758
- catch (error) {
3759
- if (this.$.$mol_fail_catch(error)) {
3760
- error.message += '\n' + path;
3761
- }
3762
- return this.$.$mol_fail_hidden(error);
3763
- }
3764
- }
3765
- kids() {
3766
- const path = this.path();
3767
- try {
3768
- const kids = $node.fs.readdirSync(path)
3769
- .filter(name => !/^\.+$/.test(name))
3770
- .map(name => this.resolve(name));
3771
- return kids;
3772
- }
3773
- catch (e) {
3774
- if (this.$.$mol_fail_catch(e)) {
3775
- if (e.code === 'ENOENT')
3776
- return [];
3777
- e.message += '\n' + path;
3778
- }
3779
- $mol_fail_hidden(e);
3780
- }
3781
- }
3782
- resolve(path) {
3783
- return this.constructor
3784
- .relative($node.path.join(this.path(), path));
3785
- }
3786
- relate(base = this.constructor.relative('.')) {
3787
- return $node.path.relative(base.path(), this.path()).replace(/\\/g, '/');
3788
- }
3789
- readable(opts) {
3790
- const { Readable } = $node['node:stream'];
3791
- const stream = $node.fs.createReadStream(this.path(), {
3792
- flags: 'r',
3793
- autoClose: true,
3794
- start: opts?.start,
3795
- end: opts?.end,
3796
- encoding: 'binary',
3797
- });
3798
- return Readable.toWeb(stream);
3799
- }
3800
- writable(opts) {
3801
- const { Writable } = $node['node:stream'];
3802
- const stream = $node.fs.createWriteStream(this.path(), {
3803
- flags: 'w+',
3804
- autoClose: true,
3805
- start: opts?.start,
3806
- encoding: 'binary',
3807
- });
3808
- return Writable.toWeb(stream);
3809
- }
3810
- }
3811
- __decorate([
3812
- $mol_mem
3813
- ], $mol_file_node.prototype, "watcher", null);
3814
- __decorate([
3815
- $mol_action
3816
- ], $mol_file_node.prototype, "info", null);
3817
- __decorate([
3818
- $mol_action
3819
- ], $mol_file_node.prototype, "ensure", null);
3820
- __decorate([
3821
- $mol_action
3822
- ], $mol_file_node.prototype, "copy", null);
3823
- __decorate([
3824
- $mol_action
3825
- ], $mol_file_node.prototype, "drop", null);
3826
- __decorate([
3827
- $mol_action
3828
- ], $mol_file_node.prototype, "read", null);
3829
- __decorate([
3830
- $mol_action
3831
- ], $mol_file_node.prototype, "write", null);
3832
- __decorate([
3833
- $mol_mem_key
3834
- ], $mol_file_node.prototype, "readable", null);
3835
- __decorate([
3836
- $mol_mem
3837
- ], $mol_file_node.prototype, "writable", null);
3838
- $.$mol_file_node = $mol_file_node;
3839
- $.$mol_file = $mol_file_node;
3840
- })($ || ($ = {}));
3841
-
3842
- ;
3843
- "use strict";
3844
- var $;
3845
- (function ($) {
3846
- class $mol_state_local_node extends $mol_state_local {
3847
- static dir() {
3848
- const base = process.env.XDG_DATA_HOME || ($node.os.homedir() + '/.local/share');
3849
- return $mol_file.absolute(base).resolve('./mol_state_local');
3850
- }
3851
- static value(key, next) {
3852
- const file = this.dir().resolve(encodeURIComponent(key) + '.json');
3853
- if (next === null) {
3854
- file.exists(false);
3855
- return null;
3856
- }
3857
- const arg = next === undefined ? undefined : JSON.stringify(next);
3858
- return JSON.parse(file.text(arg) || 'null');
3859
- }
3860
- }
3861
- __decorate([
3862
- $mol_mem
3863
- ], $mol_state_local_node, "dir", null);
3864
- __decorate([
3865
- $mol_mem_key
3866
- ], $mol_state_local_node, "value", null);
3867
- $.$mol_state_local_node = $mol_state_local_node;
3868
- $.$mol_state_local = $mol_state_local_node;
3869
- })($ || ($ = {}));
3870
-
3871
- ;
3872
- "use strict";
3873
- var $;
3874
- (function ($) {
3875
- function parse(theme) {
3876
- if (theme === 'true')
3877
- return true;
3878
- if (theme === 'false')
3879
- return false;
3880
- return null;
3881
- }
3882
- function $mol_lights(next) {
3883
- const arg = parse(this.$mol_state_arg.value('mol_lights'));
3884
- const base = this.$mol_media.match('(prefers-color-scheme: light)');
3885
- if (next === undefined) {
3886
- return arg ?? this.$mol_state_local.value('$mol_lights') ?? base;
3887
- }
3888
- else {
3889
- if (arg === null) {
3890
- this.$mol_state_local.value('$mol_lights', next === base ? null : next);
3891
- }
3892
- else {
3893
- this.$mol_state_arg.value('mol_lights', String(next));
3894
- }
3895
- return next;
3896
- }
3897
- }
3898
- $.$mol_lights = $mol_lights;
3899
- })($ || ($ = {}));
3900
-
3901
- ;
3902
- "use strict";
3903
- var $;
3904
- (function ($) {
3905
- $.$mol_theme = $mol_style_prop('mol_theme', [
3906
- 'back',
3907
- 'hover',
3908
- 'card',
3909
- 'current',
3910
- 'special',
3911
- 'text',
3912
- 'control',
3913
- 'shade',
3914
- 'line',
3915
- 'focus',
3916
- 'field',
3917
- 'image',
3918
- 'spirit',
3919
- ]);
3920
- })($ || ($ = {}));
3921
-
3922
- ;
3923
- "use strict";
3924
- var $;
3925
- (function ($) {
3926
- $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( 50% 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");
3927
- })($ || ($ = {}));
3928
-
3929
- ;
3930
- "use strict";
3931
- var $;
3932
- (function ($) {
3933
- $mol_style_attach('$mol_theme_lights', `:root { --mol_theme_back: oklch( ${$$.$mol_lights() ? 92 : 20}% .01 var(--mol_theme_hue) ) }`);
3934
- })($ || ($ = {}));
3935
-
3936
- ;
3937
- "use strict";
3938
- var $;
3939
- (function ($) {
3940
- $.$mol_gap = $mol_style_prop('mol_gap', [
3941
- 'page',
3942
- 'block',
3943
- 'text',
3944
- 'emoji',
3945
- 'round',
3946
- 'space',
3947
- 'blur',
3948
- ]);
3949
- })($ || ($ = {}));
3950
-
3951
- ;
3952
- "use strict";
3953
- var $;
3954
- (function ($) {
3955
- $mol_style_attach("mol/gap/gap.css", ":root {\n\t--mol_gap_page: 3rem;\n\t--mol_gap_block: .75rem;\n\t--mol_gap_text: .5rem .75rem;\n\t--mol_gap_emoji: .5rem;\n\t--mol_gap_round: .25rem;\n\t--mol_gap_space: .25rem;\n\t--mol_gap_blur: .5rem;\n}\n");
3956
- })($ || ($ = {}));
3957
-
3958
- ;
3959
- "use strict";
3960
- var $;
3961
- (function ($) {
3962
- function $mol_dom_render_children(el, childNodes) {
3963
- const node_set = new Set(childNodes);
3964
- let nextNode = el.firstChild;
3965
- for (let view of childNodes) {
3966
- if (view == null)
3967
- continue;
3968
- if (view instanceof $mol_dom_context.Node) {
3969
- while (true) {
3970
- if (!nextNode) {
3971
- el.appendChild(view);
3972
- break;
3973
- }
3974
- if (nextNode == view) {
3975
- nextNode = nextNode.nextSibling;
3976
- break;
3977
- }
3978
- else {
3979
- if (node_set.has(nextNode)) {
3980
- el.insertBefore(view, nextNode);
3981
- break;
3982
- }
3983
- else {
3984
- const nn = nextNode.nextSibling;
3985
- el.removeChild(nextNode);
3986
- nextNode = nn;
3987
- }
3988
- }
3989
- }
3990
- }
3991
- else {
3992
- if (nextNode && nextNode.nodeName === '#text') {
3993
- const str = String(view);
3994
- if (nextNode.nodeValue !== str)
3995
- nextNode.nodeValue = str;
3996
- nextNode = nextNode.nextSibling;
3997
- }
3998
- else {
3999
- const textNode = $mol_dom_context.document.createTextNode(String(view));
4000
- el.insertBefore(textNode, nextNode);
4001
- }
4002
- }
4003
- }
4004
- while (nextNode) {
4005
- const currNode = nextNode;
4006
- nextNode = currNode.nextSibling;
4007
- el.removeChild(currNode);
4008
- }
4009
- }
4010
- $.$mol_dom_render_children = $mol_dom_render_children;
4011
- })($ || ($ = {}));
4012
-
4013
- ;
4014
- "use strict";
4015
-
4016
- ;
4017
- "use strict";
4018
- var $;
4019
- (function ($) {
4020
- $.$mol_jsx_prefix = '';
4021
- $.$mol_jsx_crumbs = '';
4022
- $.$mol_jsx_booked = null;
4023
- $.$mol_jsx_document = {
4024
- getElementById: () => null,
4025
- createElementNS: (space, name) => $mol_dom_context.document.createElementNS(space, name),
4026
- createDocumentFragment: () => $mol_dom_context.document.createDocumentFragment(),
4027
- };
4028
- $.$mol_jsx_frag = '';
4029
- function $mol_jsx(Elem, props, ...childNodes) {
4030
- const id = props && props.id || '';
4031
- const guid = id ? $.$mol_jsx_prefix ? $.$mol_jsx_prefix + '/' + id : id : $.$mol_jsx_prefix;
4032
- const crumbs_self = id ? $.$mol_jsx_crumbs.replace(/(\S+)/g, `$1_${id.replace(/\/.*/i, '')}`) : $.$mol_jsx_crumbs;
4033
- if (Elem && $.$mol_jsx_booked) {
4034
- if ($.$mol_jsx_booked.has(id)) {
4035
- $mol_fail(new Error(`JSX already has tag with id ${JSON.stringify(guid)}`));
4036
- }
4037
- else {
4038
- $.$mol_jsx_booked.add(id);
4039
- }
4040
- }
4041
- let node = guid ? $.$mol_jsx_document.getElementById(guid) : null;
4042
- if ($.$mol_jsx_prefix) {
4043
- const prefix_ext = $.$mol_jsx_prefix;
4044
- const booked_ext = $.$mol_jsx_booked;
4045
- const crumbs_ext = $.$mol_jsx_crumbs;
4046
- for (const field in props) {
4047
- const func = props[field];
4048
- if (typeof func !== 'function')
4049
- continue;
4050
- const wrapper = function (...args) {
4051
- const prefix = $.$mol_jsx_prefix;
4052
- const booked = $.$mol_jsx_booked;
4053
- const crumbs = $.$mol_jsx_crumbs;
4054
- try {
4055
- $.$mol_jsx_prefix = prefix_ext;
4056
- $.$mol_jsx_booked = booked_ext;
4057
- $.$mol_jsx_crumbs = crumbs_ext;
4058
- return func.call(this, ...args);
4059
- }
4060
- finally {
4061
- $.$mol_jsx_prefix = prefix;
4062
- $.$mol_jsx_booked = booked;
4063
- $.$mol_jsx_crumbs = crumbs;
4064
- }
4065
- };
4066
- $mol_func_name_from(wrapper, func);
4067
- props[field] = wrapper;
4068
- }
4069
- }
4070
- if (typeof Elem !== 'string') {
4071
- if ('prototype' in Elem) {
4072
- const view = node && node[String(Elem)] || new Elem;
4073
- Object.assign(view, props);
4074
- view[Symbol.toStringTag] = guid;
4075
- view.childNodes = childNodes;
4076
- if (!view.ownerDocument)
4077
- view.ownerDocument = $.$mol_jsx_document;
4078
- view.className = (crumbs_self ? crumbs_self + ' ' : '') + (Elem['name'] || Elem);
4079
- node = view.valueOf();
4080
- node[String(Elem)] = view;
4081
- return node;
4082
- }
4083
- else {
4084
- const prefix = $.$mol_jsx_prefix;
4085
- const booked = $.$mol_jsx_booked;
4086
- const crumbs = $.$mol_jsx_crumbs;
4087
- try {
4088
- $.$mol_jsx_prefix = guid;
4089
- $.$mol_jsx_booked = new Set;
4090
- $.$mol_jsx_crumbs = (crumbs_self ? crumbs_self + ' ' : '') + (Elem['name'] || Elem);
4091
- return Elem(props, ...childNodes);
4092
- }
4093
- finally {
4094
- $.$mol_jsx_prefix = prefix;
4095
- $.$mol_jsx_booked = booked;
4096
- $.$mol_jsx_crumbs = crumbs;
4097
- }
4098
- }
4099
- }
4100
- if (!node) {
4101
- node = Elem
4102
- ? $.$mol_jsx_document.createElementNS(props?.xmlns ?? 'http://www.w3.org/1999/xhtml', Elem)
4103
- : $.$mol_jsx_document.createDocumentFragment();
4104
- }
4105
- $mol_dom_render_children(node, [].concat(...childNodes));
4106
- if (!Elem)
4107
- return node;
4108
- if (guid)
4109
- node.id = guid;
4110
- for (const key in props) {
4111
- if (key === 'id')
4112
- continue;
4113
- if (typeof props[key] === 'string') {
4114
- if (typeof node[key] === 'string')
4115
- node[key] = props[key];
4116
- node.setAttribute(key, props[key]);
4117
- }
4118
- else if (props[key] &&
4119
- typeof props[key] === 'object' &&
4120
- Reflect.getPrototypeOf(props[key]) === Reflect.getPrototypeOf({})) {
4121
- if (typeof node[key] === 'object') {
4122
- Object.assign(node[key], props[key]);
4123
- continue;
4124
- }
4125
- }
4126
- else {
4127
- node[key] = props[key];
4128
- }
4129
- }
4130
- if ($.$mol_jsx_crumbs)
4131
- node.className = (props?.['class'] ? props['class'] + ' ' : '') + crumbs_self;
4132
- return node;
4133
- }
4134
- $.$mol_jsx = $mol_jsx;
4135
- })($ || ($ = {}));
4136
-
4137
- ;
4138
- "use strict";
4139
- var $;
4140
- (function ($) {
4141
- class $mol_window extends $mol_object {
4142
- static size() {
4143
- return {
4144
- width: 1024,
4145
- height: 768,
4146
- };
4147
- }
4148
- }
4149
- $.$mol_window = $mol_window;
4150
- })($ || ($ = {}));
4151
-
4152
- ;
4153
- "use strict";
4154
- var $;
4155
- (function ($) {
4156
- function $mol_guard_defined(value) {
4157
- return value !== null && value !== undefined;
4158
- }
4159
- $.$mol_guard_defined = $mol_guard_defined;
2989
+ function $mol_guard_defined(value) {
2990
+ return value !== null && value !== undefined;
2991
+ }
2992
+ $.$mol_guard_defined = $mol_guard_defined;
4160
2993
  })($ || ($ = {}));
4161
2994
 
4162
2995
  ;
@@ -4265,6 +3098,26 @@ var $;
4265
3098
  $.$mol_dom_qname = $mol_dom_qname;
4266
3099
  })($ || ($ = {}));
4267
3100
 
3101
+ ;
3102
+ "use strict";
3103
+ var $;
3104
+ (function ($) {
3105
+ function $mol_wire_probe(task, def) {
3106
+ const warm = $mol_wire_fiber.warm;
3107
+ try {
3108
+ $mol_wire_fiber.warm = false;
3109
+ const res = task();
3110
+ if (res === undefined)
3111
+ return def;
3112
+ return res;
3113
+ }
3114
+ finally {
3115
+ $mol_wire_fiber.warm = warm;
3116
+ }
3117
+ }
3118
+ $.$mol_wire_probe = $mol_wire_probe;
3119
+ })($ || ($ = {}));
3120
+
4268
3121
  ;
4269
3122
  "use strict";
4270
3123
  var $;
@@ -4281,6 +3134,38 @@ var $;
4281
3134
  $.$mol_wire_watch = $mol_wire_watch;
4282
3135
  })($ || ($ = {}));
4283
3136
 
3137
+ ;
3138
+ "use strict";
3139
+ var $;
3140
+ (function ($) {
3141
+ function $mol_const(value) {
3142
+ const getter = (() => value);
3143
+ getter['()'] = value;
3144
+ getter[Symbol.toStringTag] = value;
3145
+ getter[$mol_dev_format_head] = () => $mol_dev_format_span({}, '()=> ', $mol_dev_format_auto(value));
3146
+ return getter;
3147
+ }
3148
+ $.$mol_const = $mol_const;
3149
+ })($ || ($ = {}));
3150
+
3151
+ ;
3152
+ "use strict";
3153
+ var $;
3154
+ (function ($) {
3155
+ function $mol_wire_solid() {
3156
+ let current = $mol_wire_auto();
3157
+ if (current.temp)
3158
+ current = current.host;
3159
+ if (current.reap !== nothing) {
3160
+ current?.sub_on(sub, sub.data.length);
3161
+ }
3162
+ current.reap = nothing;
3163
+ }
3164
+ $.$mol_wire_solid = $mol_wire_solid;
3165
+ const nothing = () => { };
3166
+ const sub = new $mol_wire_pub_sub;
3167
+ })($ || ($ = {}));
3168
+
4284
3169
  ;
4285
3170
  "use strict";
4286
3171
  var $;
@@ -4366,6 +3251,36 @@ var $;
4366
3251
  $.$mol_dom_render_fields = $mol_dom_render_fields;
4367
3252
  })($ || ($ = {}));
4368
3253
 
3254
+ ;
3255
+ "use strict";
3256
+ var $;
3257
+ (function ($) {
3258
+ function $mol_wire_async(obj) {
3259
+ let fiber;
3260
+ const temp = $mol_wire_task.getter(obj);
3261
+ return new Proxy(obj, {
3262
+ get(obj, field) {
3263
+ const val = obj[field];
3264
+ if (typeof val !== 'function')
3265
+ return val;
3266
+ let fiber;
3267
+ const temp = $mol_wire_task.getter(val);
3268
+ return function $mol_wire_async(...args) {
3269
+ fiber?.destructor();
3270
+ fiber = temp(obj, args);
3271
+ return fiber.async();
3272
+ };
3273
+ },
3274
+ apply(obj, self, args) {
3275
+ fiber?.destructor();
3276
+ fiber = temp(self, args);
3277
+ return fiber.async();
3278
+ },
3279
+ });
3280
+ }
3281
+ $.$mol_wire_async = $mol_wire_async;
3282
+ })($ || ($ = {}));
3283
+
4369
3284
  ;
4370
3285
  "use strict";
4371
3286
 
@@ -5745,6 +4660,13 @@ var $;
5745
4660
  ($mol_mem(($.$mol_plot_pane.prototype), "dimensions_viewport"));
5746
4661
 
5747
4662
 
4663
+ ;
4664
+ "use strict";
4665
+ var $;
4666
+ (function ($) {
4667
+ $.$mol_mem_cached = $mol_wire_probe;
4668
+ })($ || ($ = {}));
4669
+
5748
4670
  ;
5749
4671
  ($.$mol_svg_group) = class $mol_svg_group extends ($.$mol_svg) {
5750
4672
  dom_name(){
@@ -10009,14 +8931,158 @@ var $;
10009
8931
  return this.value(index - 1) + this.value(index - 2);
10010
8932
  }
10011
8933
  }
10012
- __decorate([
10013
- $mol_wire_plex
10014
- ], Fib, "value", null);
10015
- $mol_assert_equal(Fib.value(4), 5);
10016
- $mol_assert_equal(Fib.sums, 3);
10017
- Fib.value(1, 2);
10018
- $mol_assert_equal(Fib.value(4), 8);
10019
- $mol_assert_equal(Fib.sums, 6);
8934
+ __decorate([
8935
+ $mol_wire_plex
8936
+ ], Fib, "value", null);
8937
+ $mol_assert_equal(Fib.value(4), 5);
8938
+ $mol_assert_equal(Fib.sums, 3);
8939
+ Fib.value(1, 2);
8940
+ $mol_assert_equal(Fib.value(4), 8);
8941
+ $mol_assert_equal(Fib.sums, 6);
8942
+ },
8943
+ });
8944
+ })($ || ($ = {}));
8945
+
8946
+ ;
8947
+ "use strict";
8948
+ var $;
8949
+ (function ($) {
8950
+ $mol_test({
8951
+ 'Previous value'() {
8952
+ class Cache extends $mol_object2 {
8953
+ static store(next) {
8954
+ if (!next)
8955
+ return {};
8956
+ return {
8957
+ ...$mol_wire_probe(() => this.store()) ?? {},
8958
+ ...next,
8959
+ };
8960
+ }
8961
+ }
8962
+ __decorate([
8963
+ $mol_wire_solo
8964
+ ], Cache, "store", null);
8965
+ $mol_assert_like(Cache.store(), {});
8966
+ $mol_assert_like(Cache.store({ foo: 666 }), { foo: 666 });
8967
+ $mol_assert_like(Cache.store({ bar: 777 }), { foo: 666, bar: 777 });
8968
+ },
8969
+ });
8970
+ })($ || ($ = {}));
8971
+
8972
+ ;
8973
+ "use strict";
8974
+ var $;
8975
+ (function ($) {
8976
+ $mol_test({
8977
+ 'run callback'() {
8978
+ class Plus1 extends $mol_wrapper {
8979
+ static wrap(task) {
8980
+ return function (...args) {
8981
+ return task.call(this, ...args) + 1;
8982
+ };
8983
+ }
8984
+ }
8985
+ $mol_assert_equal(Plus1.run(() => 2), 3);
8986
+ },
8987
+ 'wrap function'() {
8988
+ class Plus1 extends $mol_wrapper {
8989
+ static wrap(task) {
8990
+ return function (...args) {
8991
+ return task.call(this, ...args) + 1;
8992
+ };
8993
+ }
8994
+ }
8995
+ const obj = {
8996
+ level: 2,
8997
+ pow: Plus1.func(function (a) {
8998
+ return a ** this.level;
8999
+ })
9000
+ };
9001
+ $mol_assert_equal(obj.pow(2), 5);
9002
+ },
9003
+ 'decorate field getter'() {
9004
+ class Plus1 extends $mol_wrapper {
9005
+ static last = 0;
9006
+ static wrap(task) {
9007
+ return function (...args) {
9008
+ return Plus1.last = (task.call(this, ...args) || 0) + 1;
9009
+ };
9010
+ }
9011
+ }
9012
+ class Foo {
9013
+ static get two() {
9014
+ return 1;
9015
+ }
9016
+ static set two(next) { }
9017
+ }
9018
+ __decorate([
9019
+ Plus1.field
9020
+ ], Foo, "two", null);
9021
+ $mol_assert_equal(Foo.two, 2);
9022
+ Foo.two = 3;
9023
+ $mol_assert_equal(Plus1.last, 2);
9024
+ $mol_assert_equal(Foo.two, 2);
9025
+ },
9026
+ 'decorate instance method'() {
9027
+ class Plus1 extends $mol_wrapper {
9028
+ static wrap(task) {
9029
+ return function (...args) {
9030
+ return task.call(this, ...args) + 1;
9031
+ };
9032
+ }
9033
+ }
9034
+ class Foo1 {
9035
+ level = 2;
9036
+ pow(a) {
9037
+ return a ** this.level;
9038
+ }
9039
+ }
9040
+ __decorate([
9041
+ Plus1.method
9042
+ ], Foo1.prototype, "pow", null);
9043
+ const Foo2 = Foo1;
9044
+ const foo = new Foo2;
9045
+ $mol_assert_equal(foo.pow(2), 5);
9046
+ },
9047
+ 'decorate static method'() {
9048
+ class Plus1 extends $mol_wrapper {
9049
+ static wrap(task) {
9050
+ return function (...args) {
9051
+ return task.call(this, ...args) + 1;
9052
+ };
9053
+ }
9054
+ }
9055
+ class Foo {
9056
+ static level = 2;
9057
+ static pow(a) {
9058
+ return a ** this.level;
9059
+ }
9060
+ }
9061
+ __decorate([
9062
+ Plus1.method
9063
+ ], Foo, "pow", null);
9064
+ $mol_assert_equal(Foo.pow(2), 5);
9065
+ },
9066
+ 'decorate class'() {
9067
+ class BarInc extends $mol_wrapper {
9068
+ static wrap(task) {
9069
+ return function (...args) {
9070
+ const foo = task.call(this, ...args);
9071
+ foo.bar++;
9072
+ return foo;
9073
+ };
9074
+ }
9075
+ }
9076
+ let Foo = class Foo {
9077
+ bar;
9078
+ constructor(bar) {
9079
+ this.bar = bar;
9080
+ }
9081
+ };
9082
+ Foo = __decorate([
9083
+ BarInc.class
9084
+ ], Foo);
9085
+ $mol_assert_equal(new Foo(2).bar, 3);
10020
9086
  },
10021
9087
  });
10022
9088
  })($ || ($ = {}));
@@ -10026,23 +9092,22 @@ var $;
10026
9092
  var $;
10027
9093
  (function ($) {
10028
9094
  $mol_test({
10029
- 'Previous value'() {
10030
- class Cache extends $mol_object2 {
10031
- static store(next) {
10032
- if (!next)
10033
- return {};
10034
- return {
10035
- ...$mol_wire_probe(() => this.store()) ?? {},
10036
- ...next,
10037
- };
9095
+ 'memoize field'() {
9096
+ class Foo {
9097
+ static one = 1;
9098
+ static get two() {
9099
+ return ++this.one;
10038
9100
  }
9101
+ static set two(next) { }
10039
9102
  }
10040
9103
  __decorate([
10041
- $mol_wire_solo
10042
- ], Cache, "store", null);
10043
- $mol_assert_like(Cache.store(), {});
10044
- $mol_assert_like(Cache.store({ foo: 666 }), { foo: 666 });
10045
- $mol_assert_like(Cache.store({ bar: 777 }), { foo: 666, bar: 777 });
9104
+ $mol_memo.field
9105
+ ], Foo, "two", null);
9106
+ $mol_assert_equal(Foo.two, 2);
9107
+ $mol_assert_equal(Foo.two, 2);
9108
+ Foo.two = 3;
9109
+ $mol_assert_equal(Foo.two, 3);
9110
+ $mol_assert_equal(Foo.two, 3);
10046
9111
  },
10047
9112
  });
10048
9113
  })($ || ($ = {}));
@@ -10199,28 +9264,6 @@ var $;
10199
9264
  $mol_wire_log.active();
10200
9265
  })($ || ($ = {}));
10201
9266
 
10202
- ;
10203
- "use strict";
10204
- var $;
10205
- (function ($) {
10206
- $mol_test_mocks.push(context => {
10207
- class $mol_state_arg_mock extends $mol_state_arg {
10208
- static $ = context;
10209
- static href(next) { return next || ''; }
10210
- static go(next) {
10211
- this.href(this.link(next));
10212
- }
10213
- }
10214
- __decorate([
10215
- $mol_mem
10216
- ], $mol_state_arg_mock, "href", null);
10217
- __decorate([
10218
- $mol_action
10219
- ], $mol_state_arg_mock, "go", null);
10220
- context.$mol_state_arg = $mol_state_arg_mock;
10221
- });
10222
- })($ || ($ = {}));
10223
-
10224
9267
  ;
10225
9268
  "use strict";
10226
9269
  var $;
@@ -10234,245 +9277,6 @@ var $;
10234
9277
  });
10235
9278
  })($ || ($ = {}));
10236
9279
 
10237
- ;
10238
- "use strict";
10239
- var $;
10240
- (function ($) {
10241
- class TestClass extends Uint8Array {
10242
- }
10243
- $mol_test({
10244
- 'Uint8Array vs itself'() {
10245
- $mol_assert_ok($mol_compare_array(new Uint8Array, new Uint8Array));
10246
- $mol_assert_ok($mol_compare_array(new Uint8Array([0]), new Uint8Array([0])));
10247
- $mol_assert_not($mol_compare_array(new Uint8Array([0]), new Uint8Array([1])));
10248
- },
10249
- 'Uint8Array vs subclassed array'() {
10250
- $mol_assert_not($mol_compare_array(new Uint8Array, new TestClass));
10251
- },
10252
- });
10253
- })($ || ($ = {}));
10254
-
10255
- ;
10256
- "use strict";
10257
- var $;
10258
- (function ($) {
10259
- $mol_test({
10260
- 'decode utf8 string'() {
10261
- const str = 'Hello, ΧΨΩЫ';
10262
- const encoded = new Uint8Array([72, 101, 108, 108, 111, 44, 32, 206, 167, 206, 168, 206, 169, 208, 171]);
10263
- $mol_assert_equal($mol_charset_decode(encoded), str);
10264
- $mol_assert_equal($mol_charset_decode(encoded, 'utf8'), str);
10265
- },
10266
- 'decode empty string'() {
10267
- const encoded = new Uint8Array([]);
10268
- $mol_assert_equal($mol_charset_decode(encoded), '');
10269
- },
10270
- });
10271
- })($ || ($ = {}));
10272
-
10273
- ;
10274
- "use strict";
10275
- var $;
10276
- (function ($) {
10277
- $mol_test({
10278
- 'encode empty'() {
10279
- $mol_assert_equal($mol_charset_encode(''), new Uint8Array([]));
10280
- },
10281
- 'encode 1 octet'() {
10282
- $mol_assert_equal($mol_charset_encode('F'), new Uint8Array([0x46]));
10283
- },
10284
- 'encode 2 octet'() {
10285
- $mol_assert_equal($mol_charset_encode('Б'), new Uint8Array([0xd0, 0x91]));
10286
- },
10287
- 'encode 3 octet'() {
10288
- $mol_assert_equal($mol_charset_encode('ह'), new Uint8Array([0xe0, 0xa4, 0xb9]));
10289
- },
10290
- 'encode 4 octet'() {
10291
- $mol_assert_equal($mol_charset_encode('𐍈'), new Uint8Array([0xf0, 0x90, 0x8d, 0x88]));
10292
- },
10293
- 'encode surrogate pair'() {
10294
- $mol_assert_equal($mol_charset_encode('😀'), new Uint8Array([0xf0, 0x9f, 0x98, 0x80]));
10295
- },
10296
- });
10297
- })($ || ($ = {}));
10298
-
10299
- ;
10300
- "use strict";
10301
- var $;
10302
- (function ($) {
10303
- $mol_test({
10304
- 'local get set delete'() {
10305
- var key = '$mol_state_local_test:' + Math.random();
10306
- $mol_assert_equal($mol_state_local.value(key), null);
10307
- $mol_state_local.value(key, 123);
10308
- $mol_assert_equal($mol_state_local.value(key), 123);
10309
- $mol_state_local.value(key, null);
10310
- $mol_assert_equal($mol_state_local.value(key), null);
10311
- },
10312
- });
10313
- })($ || ($ = {}));
10314
-
10315
- ;
10316
- "use strict";
10317
- var $;
10318
- (function ($) {
10319
- $mol_test_mocks.push(context => {
10320
- class $mol_state_local_mock extends $mol_state_local {
10321
- static state = {};
10322
- static value(key, next = this.state[key]) {
10323
- return this.state[key] = (next || null);
10324
- }
10325
- }
10326
- __decorate([
10327
- $mol_mem_key
10328
- ], $mol_state_local_mock, "value", null);
10329
- context.$mol_state_local = $mol_state_local_mock;
10330
- });
10331
- })($ || ($ = {}));
10332
-
10333
- ;
10334
- "use strict";
10335
- var $;
10336
- (function ($) {
10337
- $mol_test({
10338
- 'run callback'() {
10339
- class Plus1 extends $mol_wrapper {
10340
- static wrap(task) {
10341
- return function (...args) {
10342
- return task.call(this, ...args) + 1;
10343
- };
10344
- }
10345
- }
10346
- $mol_assert_equal(Plus1.run(() => 2), 3);
10347
- },
10348
- 'wrap function'() {
10349
- class Plus1 extends $mol_wrapper {
10350
- static wrap(task) {
10351
- return function (...args) {
10352
- return task.call(this, ...args) + 1;
10353
- };
10354
- }
10355
- }
10356
- const obj = {
10357
- level: 2,
10358
- pow: Plus1.func(function (a) {
10359
- return a ** this.level;
10360
- })
10361
- };
10362
- $mol_assert_equal(obj.pow(2), 5);
10363
- },
10364
- 'decorate field getter'() {
10365
- class Plus1 extends $mol_wrapper {
10366
- static last = 0;
10367
- static wrap(task) {
10368
- return function (...args) {
10369
- return Plus1.last = (task.call(this, ...args) || 0) + 1;
10370
- };
10371
- }
10372
- }
10373
- class Foo {
10374
- static get two() {
10375
- return 1;
10376
- }
10377
- static set two(next) { }
10378
- }
10379
- __decorate([
10380
- Plus1.field
10381
- ], Foo, "two", null);
10382
- $mol_assert_equal(Foo.two, 2);
10383
- Foo.two = 3;
10384
- $mol_assert_equal(Plus1.last, 2);
10385
- $mol_assert_equal(Foo.two, 2);
10386
- },
10387
- 'decorate instance method'() {
10388
- class Plus1 extends $mol_wrapper {
10389
- static wrap(task) {
10390
- return function (...args) {
10391
- return task.call(this, ...args) + 1;
10392
- };
10393
- }
10394
- }
10395
- class Foo1 {
10396
- level = 2;
10397
- pow(a) {
10398
- return a ** this.level;
10399
- }
10400
- }
10401
- __decorate([
10402
- Plus1.method
10403
- ], Foo1.prototype, "pow", null);
10404
- const Foo2 = Foo1;
10405
- const foo = new Foo2;
10406
- $mol_assert_equal(foo.pow(2), 5);
10407
- },
10408
- 'decorate static method'() {
10409
- class Plus1 extends $mol_wrapper {
10410
- static wrap(task) {
10411
- return function (...args) {
10412
- return task.call(this, ...args) + 1;
10413
- };
10414
- }
10415
- }
10416
- class Foo {
10417
- static level = 2;
10418
- static pow(a) {
10419
- return a ** this.level;
10420
- }
10421
- }
10422
- __decorate([
10423
- Plus1.method
10424
- ], Foo, "pow", null);
10425
- $mol_assert_equal(Foo.pow(2), 5);
10426
- },
10427
- 'decorate class'() {
10428
- class BarInc extends $mol_wrapper {
10429
- static wrap(task) {
10430
- return function (...args) {
10431
- const foo = task.call(this, ...args);
10432
- foo.bar++;
10433
- return foo;
10434
- };
10435
- }
10436
- }
10437
- let Foo = class Foo {
10438
- bar;
10439
- constructor(bar) {
10440
- this.bar = bar;
10441
- }
10442
- };
10443
- Foo = __decorate([
10444
- BarInc.class
10445
- ], Foo);
10446
- $mol_assert_equal(new Foo(2).bar, 3);
10447
- },
10448
- });
10449
- })($ || ($ = {}));
10450
-
10451
- ;
10452
- "use strict";
10453
- var $;
10454
- (function ($) {
10455
- $mol_test({
10456
- 'memoize field'() {
10457
- class Foo {
10458
- static one = 1;
10459
- static get two() {
10460
- return ++this.one;
10461
- }
10462
- static set two(next) { }
10463
- }
10464
- __decorate([
10465
- $mol_memo.field
10466
- ], Foo, "two", null);
10467
- $mol_assert_equal(Foo.two, 2);
10468
- $mol_assert_equal(Foo.two, 2);
10469
- Foo.two = 3;
10470
- $mol_assert_equal(Foo.two, 3);
10471
- $mol_assert_equal(Foo.two, 3);
10472
- },
10473
- });
10474
- })($ || ($ = {}));
10475
-
10476
9280
  ;
10477
9281
  "use strict";
10478
9282