marko 6.3.24 → 6.3.26

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/dist/dom.js CHANGED
@@ -4,7 +4,7 @@ let empty = [], rest = Symbol(), unsafeStyleAttrReg = /[\\;]/g, replaceUnsafeSty
4
4
  else if (Array.isArray(val)) for (let v of val) part = toDelimitedString(v, delimiter, stringify), part && (str += sep + part, sep = delimiter);
5
5
  else for (let name in val) part = stringify(name, val[name]), part && (str += sep + part, sep = delimiter);
6
6
  return str;
7
- }, decodeAccessor = (num) => (num + (num < 26 ? 10 : num < 962 ? 334 : 11998)).toString(36), delegate = (type, handler) => handler[type] ||= (document.addEventListener(type, handler, !0), 1), R = /[^\p{L}\p{N}]/gu, parsers = {}, nextScopeId = 1e6, collectingScopes, destroyNestedScopes = function destroyNestedScopes(scope) {
7
+ }, decodeAccessor = (num) => (num + (num < 26 ? 10 : num < 962 ? 334 : 11998)).toString(36), delegate = (type, handler) => handler[type] ||= (document.addEventListener(type, handler, !0), 1), parsers = {}, nextScopeId = 1e6, collectingScopes, destroyNestedScopes = function destroyNestedScopes(scope) {
8
8
  scope.H = 0, scope.D?.forEach(destroyNestedScopes), scope.B?.forEach(resetControllers);
9
9
  }, isScheduled, channel, _return = (scope, value) => scope.T?.(value), _var_change = (scope, value) => scope.U?.(value), tagIdsByGlobal = /* @__PURE__ */ new WeakMap(), walker = /* @__PURE__ */ document.createTreeWalker(document), walkInternal = function walkInternal(currentWalkIndex, walkCodes, scope) {
10
10
  let value, currentMultiplier, storedMultiplier = 0, currentScopeIndex = 0;
@@ -14,13 +14,13 @@ let empty = [], rest = Symbol(), unsafeStyleAttrReg = /[\\;]/g, replaceUnsafeSty
14
14
  } else if (value === 37 || value === 49) walker.currentNode.replaceWith(walker.currentNode = scope[decodeAccessor(currentScopeIndex++)] = new Text()), value === 49 && (scope[decodeAccessor(currentScopeIndex++)] = skipScope());
15
15
  else if (value === 38) return currentWalkIndex;
16
16
  else if (value === 47 || value === 48) currentWalkIndex = walkInternal(currentWalkIndex, walkCodes, scope[decodeAccessor(currentScopeIndex++)] = createScope(scope.$, scope.F)), value === 48 && (scope[decodeAccessor(currentScopeIndex++)] = skipScope());
17
- else if (value < 92) for (value = 20 * currentMultiplier + value - 67; value--;) walker.nextNode();
17
+ else if (value < 92) for (value = 25 * currentMultiplier + value - 67; value--;) walker.nextNode();
18
18
  else if (value < 107) for (value = 10 * currentMultiplier + value - 97; value--;) walker.nextSibling();
19
19
  else if (value < 117) {
20
20
  for (value = 10 * currentMultiplier + value - 107; value--;) walker.parentNode();
21
21
  walker.nextSibling();
22
22
  } else storedMultiplier = currentMultiplier * 10 + value - 117;
23
- }, cloneCache = {}, registeredValues = {}, curRenders, branchesEnabled, embedRenders, readyIds, isResuming, inputType = "", _dynamic_tag = function(nodeAccessor, getContent, getTagVar, inputIsArgs) {
23
+ }, registeredValues = {}, curRenders, branchesEnabled, embedRenders, readyIds, isResuming, cloneCache = {}, R = /[^\p{L}\p{N}]/gu, inputType = "", controllableScripts = {}, controllableRenders = {}, _dynamic_tag = function(nodeAccessor, getContent, getTagVar, inputIsArgs) {
24
24
  nodeAccessor = decodeAccessor(nodeAccessor);
25
25
  let childScopeAccessor = "A" + nodeAccessor, rendererAccessor = "D" + nodeAccessor;
26
26
  return enableBranches(), (scope, newRenderer, getInput) => {
@@ -33,7 +33,7 @@ let empty = [], rest = Symbol(), unsafeStyleAttrReg = /[\\;]/g, replaceUnsafeSty
33
33
  } else normalizedRenderer?.f && subscribeToScopeSet(normalizedRenderer.e, normalizedRenderer.f, scope[childScopeAccessor]);
34
34
  if (normalizedRenderer) {
35
35
  let childScope = scope[childScopeAccessor], args = getInput?.();
36
- if (typeof normalizedRenderer == "string") (getContent ? _attrs : _attrs_content)(childScope, "a", (inputIsArgs ? args[0] : args) || {}), (childScope.Ia || childScope.Ea) && queueEffect(childScope, dynamicTagScript);
36
+ if (typeof normalizedRenderer == "string") (getContent ? _attrs : _attrs_content)(childScope, "a", (inputIsArgs ? args[0] : args) || {}, controllableRenders[childScope.a.tagName]), (childScope.Ia || childScope.Ea) && queueEffect(childScope, dynamicTagScript);
37
37
  else {
38
38
  for (let accessor in normalizedRenderer.g) normalizedRenderer.g[accessor](childScope, normalizedRenderer.h[accessor]);
39
39
  if (normalizedRenderer.d) if (inputIsArgs) normalizedRenderer.d(childScope, normalizedRenderer._ ? args[0] : args);
@@ -207,19 +207,6 @@ function handleDelegated(ev) {
207
207
  for (; target;) target["$" + ev.type]?.(ev, target), target = ev.bubbles && !ev.cancelBubble && target.parentNode;
208
208
  }
209
209
  //#endregion
210
- //#region src/dom/resolve-cursor-position.ts
211
- function resolveCursorPosition(inputType, initialPosition, initialValue, updatedValue) {
212
- if ((initialPosition || initialPosition === 0) && (initialPosition !== initialValue.length || /kw/.test(inputType))) {
213
- let before = initialValue.slice(0, initialPosition), after = initialValue.slice(initialPosition);
214
- if (updatedValue.startsWith(before)) return initialPosition;
215
- if (updatedValue.endsWith(after)) return updatedValue.length - after.length;
216
- let count = before.replace(R, "").length, pos = 0;
217
- for (; count && updatedValue[pos];) updatedValue[pos++].replace(R, "") && count--;
218
- return pos;
219
- }
220
- return -1;
221
- }
222
- //#endregion
223
210
  //#region src/dom/parse-html.ts
224
211
  function parseHTML(html, ns) {
225
212
  let parser = parsers[ns] ||= document.createElementNS(ns, "template");
@@ -422,57 +409,6 @@ function walk(startNode, walkCodes, branch) {
422
409
  walker.currentNode = startNode, walkInternal(0, walkCodes, branch);
423
410
  }
424
411
  //#endregion
425
- //#region src/dom/renderer.ts
426
- function createBranch($global, renderer, parentScope, parentNode) {
427
- let branch = createScope($global);
428
- return branch._ = renderer.e || parentScope, setParentBranch(branch, parentScope?.F), renderer.b?.(branch, parentNode.namespaceURI), branch;
429
- }
430
- function setParentBranch(branch, parentBranch) {
431
- parentBranch && (branch.N = parentBranch, (parentBranch.D ||= /* @__PURE__ */ new Set()).add(branch)), branch.F = branch;
432
- }
433
- function createAndSetupBranch($global, renderer, parentScope, parentNode) {
434
- return setupBranch(renderer, createBranch($global, renderer, parentScope, parentNode));
435
- }
436
- function setupBranch(renderer, branch) {
437
- return renderer.c && queueRender(branch, renderer.c, -1), branch;
438
- }
439
- function _content(id, template, walks, setup, params, dynamicScopesAccessor) {
440
- walks = walks ? walks.replace(/[^\0-1]+$/, "") : "", setup = setup ? setup._ || setup : void 0, params ||= void 0;
441
- let clone = template ? (branch, ns) => {
442
- ((cloneCache[ns] ||= {})[template] ||= createCloneableHTML(template, ns))(branch, walks);
443
- } : (branch) => {
444
- walk(branch.S = branch.K = new Text(), walks, branch);
445
- };
446
- return (owner) => ({
447
- a: id,
448
- b: clone,
449
- e: owner,
450
- c: setup,
451
- d: params,
452
- f: dynamicScopesAccessor
453
- });
454
- }
455
- function _content_resume(id, template, walks, setup, params, dynamicScopesAccessor) {
456
- return _resume(id, _content(id, template, walks, setup, params, dynamicScopesAccessor));
457
- }
458
- function _content_closures(renderer, closureFns) {
459
- let closureSignals = {};
460
- for (let key in closureFns) closureSignals[key] = _const(+key, closureFns[key]);
461
- return (owner, closureValues) => {
462
- let instance = renderer(owner);
463
- return instance.g = closureSignals, instance.h = closureValues, instance;
464
- };
465
- }
466
- function createCloneableHTML(html, ns) {
467
- let { firstChild, lastChild } = parseHTML(html, ns), parent = document.createElementNS(ns, "t");
468
- return insertChildNodes(parent, null, firstChild, lastChild), firstChild === lastChild && firstChild.nodeType < 8 ? (branch, walks) => {
469
- walk(branch.S = branch.K = firstChild.cloneNode(!0), walks, branch);
470
- } : (branch, walks) => {
471
- let clone = parent.cloneNode(!0);
472
- walk(clone.firstChild, walks, branch), branch.S = clone.firstChild, branch.K = clone.lastChild;
473
- };
474
- }
475
- //#endregion
476
412
  //#region src/dom/resume.ts
477
413
  function enableBranches() {
478
414
  branchesEnabled || (branchesEnabled = 1, skipDestroyedRenders());
@@ -587,6 +523,210 @@ function _el(id, accessor) {
587
523
  return accessor = decodeAccessor(accessor), _resume(id, (scope) => () => scope[accessor]);
588
524
  }
589
525
  //#endregion
526
+ //#region src/dom/renderer.ts
527
+ function createBranch($global, renderer, parentScope, parentNode) {
528
+ let branch = createScope($global);
529
+ return branch._ = renderer.e || parentScope, setParentBranch(branch, parentScope?.F), renderer.b?.(branch, parentNode.namespaceURI), branch;
530
+ }
531
+ function setParentBranch(branch, parentBranch) {
532
+ parentBranch && (branch.N = parentBranch, (parentBranch.D ||= /* @__PURE__ */ new Set()).add(branch)), branch.F = branch;
533
+ }
534
+ function createAndSetupBranch($global, renderer, parentScope, parentNode) {
535
+ return setupBranch(renderer, createBranch($global, renderer, parentScope, parentNode));
536
+ }
537
+ function setupBranch(renderer, branch) {
538
+ return renderer.c && queueRender(branch, renderer.c, -1), branch;
539
+ }
540
+ function _content(id, template, walks, setup, params, dynamicScopesAccessor) {
541
+ walks = walks ? walks.replace(/[^\0-1]+$/, "") : "", setup = setup ? setup._ || setup : void 0, params ||= void 0;
542
+ let clone = template ? (branch, ns) => {
543
+ ((cloneCache[ns] ||= {})[template] ||= createCloneableHTML(template, ns))(branch, walks);
544
+ } : (branch) => {
545
+ walk(branch.S = branch.K = new Text(), walks, branch);
546
+ };
547
+ return (owner) => ({
548
+ a: id,
549
+ b: clone,
550
+ e: owner,
551
+ c: setup,
552
+ d: params,
553
+ f: dynamicScopesAccessor
554
+ });
555
+ }
556
+ function _content_resume(id, template, walks, setup, params, dynamicScopesAccessor) {
557
+ return _resume(id, _content(id, template, walks, setup, params, dynamicScopesAccessor));
558
+ }
559
+ function _content_closures(renderer, closureFns) {
560
+ let closureSignals = {};
561
+ for (let key in closureFns) closureSignals[key] = _const(+key, closureFns[key]);
562
+ return (owner, closureValues) => {
563
+ let instance = renderer(owner);
564
+ return instance.g = closureSignals, instance.h = closureValues, instance;
565
+ };
566
+ }
567
+ function createCloneableHTML(html, ns) {
568
+ let { firstChild, lastChild } = parseHTML(html, ns), parent = document.createElementNS(ns, "t");
569
+ return insertChildNodes(parent, null, firstChild, lastChild), firstChild === lastChild && firstChild.nodeType < 8 ? (branch, walks) => {
570
+ walk(branch.S = branch.K = firstChild.cloneNode(!0), walks, branch);
571
+ } : (branch, walks) => {
572
+ let clone = parent.cloneNode(!0);
573
+ walk(clone.firstChild, walks, branch), branch.S = clone.firstChild, branch.K = clone.lastChild;
574
+ };
575
+ }
576
+ //#endregion
577
+ //#region src/dom/dom.ts
578
+ function _to_text(value) {
579
+ return value || value === 0 ? value + "" : "";
580
+ }
581
+ function _attr(element, name, value) {
582
+ setAttribute(element, name, normalizeAttrValue(value));
583
+ }
584
+ function setAttribute(element, name, value) {
585
+ element.getAttribute(name) != value && (value === void 0 ? element.removeAttribute(name) : element.setAttribute(name, value));
586
+ }
587
+ function _attr_class(element, value) {
588
+ setAttribute(element, "class", toDelimitedString(value, " ", stringifyClassObject) || void 0);
589
+ }
590
+ function _attr_class_items(element, items) {
591
+ for (let key in items) _attr_class_item(element, key, items[key]);
592
+ }
593
+ function _attr_class_item(element, name, value) {
594
+ element.classList.toggle(name, !!value);
595
+ }
596
+ function _attr_style(element, value) {
597
+ setAttribute(element, "style", toDelimitedString(value, ";", stringifyStyleObject) || void 0);
598
+ }
599
+ function _attr_style_items(element, items) {
600
+ for (let key in items) _attr_style_item(element, key, items[key]);
601
+ }
602
+ function _attr_style_item(element, name, value) {
603
+ element.style.setProperty(name, _to_text(value));
604
+ }
605
+ function _style_shell(scope, nodeAccessor) {
606
+ let element = scope[nodeAccessor], id = _id(scope);
607
+ _attr_nonce(scope, nodeAccessor), element.className = id, _text_content(element, "." + id + "~*{}");
608
+ }
609
+ function _style_rule_item(element, name, value) {
610
+ let text = element.textContent, decl = name + ":" + escapeStyleValue(_to_text(value)) + ";", start = text.indexOf("{" + name + ":");
611
+ ~start || (start = text.indexOf(";" + name + ":")), _text_content(element, ~start ? text.slice(0, ++start) + decl + text.slice(text.indexOf(";", start) + 1) : text.slice(0, -1) + decl + "}");
612
+ }
613
+ function _attr_nonce(scope, nodeAccessor) {
614
+ _attr(scope[nodeAccessor], "nonce", scope.$.cspNonce);
615
+ }
616
+ function _text(node, value) {
617
+ let normalizedValue = _to_text(value);
618
+ node.data !== normalizedValue && (node.data = normalizedValue);
619
+ }
620
+ function _text_content(node, value) {
621
+ let normalizedValue = _to_text(value);
622
+ node.textContent !== normalizedValue && (node.textContent = normalizedValue);
623
+ }
624
+ function _attrs(scope, nodeAccessor, nextAttrs, controllable) {
625
+ let el = scope[nodeAccessor];
626
+ for (let i = el.attributes.length; i--;) {
627
+ let { name } = el.attributes.item(i);
628
+ nextAttrs && (name in nextAttrs || hasAttrAlias(el, name, nextAttrs)) || el.removeAttribute(name);
629
+ }
630
+ attrsInternal(scope, nodeAccessor, nextAttrs, controllable);
631
+ }
632
+ function _attrs_content(scope, nodeAccessor, nextAttrs, controllable) {
633
+ _attrs(scope, nodeAccessor, nextAttrs, controllable), _attr_content(scope, nodeAccessor, nextAttrs?.content);
634
+ }
635
+ function hasAttrAlias(element, attr, nextAttrs) {
636
+ return attr === "checked" && element.tagName === "INPUT" && "checkedValue" in nextAttrs;
637
+ }
638
+ function _attrs_partial(scope, nodeAccessor, nextAttrs, skip, controllable) {
639
+ let el = scope[nodeAccessor], partial = {};
640
+ for (let i = el.attributes.length; i--;) {
641
+ let { name } = el.attributes.item(i);
642
+ !skip[name] && !(nextAttrs && name in nextAttrs) && el.removeAttribute(name);
643
+ }
644
+ for (let name in nextAttrs) {
645
+ let key = isEventHandler(name) ? `on-${getEventHandlerName(name)}` : name;
646
+ skip[key] || (partial[key] = nextAttrs[name]);
647
+ }
648
+ attrsInternal(scope, nodeAccessor, partial, controllable);
649
+ }
650
+ function _attrs_partial_content(scope, nodeAccessor, nextAttrs, skip, controllable) {
651
+ _attrs_partial(scope, nodeAccessor, nextAttrs, skip, controllable), _attr_content(scope, nodeAccessor, nextAttrs?.content);
652
+ }
653
+ function attrsInternal(scope, nodeAccessor, nextAttrs, controllable) {
654
+ let el = scope[nodeAccessor], events = scope["I" + nodeAccessor], skip;
655
+ for (let name in events) events[name] = 0;
656
+ controllable && (scope["F" + nodeAccessor] = 5, scope["E" + nodeAccessor] = 0, nextAttrs && (skip = controllable(scope, nodeAccessor, nextAttrs)));
657
+ for (let name in nextAttrs) {
658
+ let value = nextAttrs[name];
659
+ switch (name) {
660
+ case "class":
661
+ _attr_class(el, value);
662
+ break;
663
+ case "style":
664
+ _attr_style(el, value);
665
+ break;
666
+ default:
667
+ isEventHandler(name) ? (events ||= scope["I" + nodeAccessor] = {})[getEventHandlerName(name)] = value : skip?.test(name) || name === "content" && el.tagName !== "META" || _attr(el, name, value);
668
+ break;
669
+ }
670
+ }
671
+ }
672
+ function _attr_content(scope, nodeAccessor, value) {
673
+ let content = normalizeClientRender(value);
674
+ scope["D" + nodeAccessor] !== (scope["D" + nodeAccessor] = content?.a) && (setConditionalRenderer(scope, nodeAccessor, content, createAndSetupBranch), content?.f && subscribeToScopeSet(content.e, content.f, scope["A" + nodeAccessor]));
675
+ for (let accessor in content?.g) content.g[accessor](scope["A" + nodeAccessor], content.h[accessor]);
676
+ }
677
+ function _attrs_script(scope, nodeAccessor) {
678
+ let el = scope[nodeAccessor], events = scope["I" + nodeAccessor];
679
+ controllableScripts[scope["F" + nodeAccessor]]?.(scope, nodeAccessor);
680
+ for (let name in events) _on(el, name, events[name]);
681
+ }
682
+ function _html(scope, value, accessor) {
683
+ let firstChild = scope[accessor], parentNode = firstChild.parentNode, lastChild = scope["H" + accessor] || firstChild, newContent = parseHTML(_to_text(value), parentNode.namespaceURI);
684
+ insertChildNodes(parentNode, firstChild, scope[accessor] = newContent.firstChild || newContent.appendChild(new Text()), scope["H" + accessor] = newContent.lastChild), removeChildNodes(firstChild, lastChild);
685
+ }
686
+ function normalizeClientRender(value) {
687
+ let renderer = normalizeDynamicRenderer(value);
688
+ if (renderer && renderer.a) return renderer;
689
+ }
690
+ function normalizeAttrValue(value) {
691
+ if (isNotVoid(value)) return value === !0 ? "" : value + "";
692
+ }
693
+ function _lifecycle(scope, thisObj, index = 0) {
694
+ let accessor = "K" + index, instance = scope[accessor];
695
+ instance ? (Object.assign(instance, thisObj), instance.onUpdate?.()) : (scope[accessor] = thisObj, Object.assign(thisObj, thisObj.onMount?.()), $signal(scope, accessor).onabort = () => thisObj.onDestroy?.());
696
+ }
697
+ function removeChildNodes(startNode, endNode) {
698
+ let stop = endNode.nextSibling;
699
+ for (; startNode !== stop;) {
700
+ let next = startNode.nextSibling;
701
+ startNode.remove(), startNode = next;
702
+ }
703
+ }
704
+ function insertChildNodes(parentNode, referenceNode, startNode, endNode) {
705
+ parentNode.insertBefore(toInsertNode(startNode, endNode), referenceNode);
706
+ }
707
+ function toInsertNode(startNode, endNode) {
708
+ if (startNode === endNode) return startNode;
709
+ let parent = new DocumentFragment(), stop = endNode.nextSibling;
710
+ for (; startNode !== stop;) {
711
+ let next = startNode.nextSibling;
712
+ parent.appendChild(startNode), startNode = next;
713
+ }
714
+ return parent;
715
+ }
716
+ //#endregion
717
+ //#region src/dom/resolve-cursor-position.ts
718
+ function resolveCursorPosition(inputType, initialPosition, initialValue, updatedValue) {
719
+ if ((initialPosition || initialPosition === 0) && (initialPosition !== initialValue.length || /kw/.test(inputType))) {
720
+ let before = initialValue.slice(0, initialPosition), after = initialValue.slice(initialPosition);
721
+ if (updatedValue.startsWith(before)) return initialPosition;
722
+ if (updatedValue.endsWith(after)) return updatedValue.length - after.length;
723
+ let count = before.replace(R, "").length, pos = 0;
724
+ for (; count && updatedValue[pos];) updatedValue[pos++].replace(R, "") && count--;
725
+ return pos;
726
+ }
727
+ return -1;
728
+ }
729
+ //#endregion
590
730
  //#region src/dom/controllable.ts
591
731
  function _attr_input_checked_default(scope, nodeAccessor, checked) {
592
732
  let el = scope[nodeAccessor], normalizedChecked = isNotVoid(checked);
@@ -595,6 +735,26 @@ function _attr_input_checked_default(scope, nodeAccessor, checked) {
595
735
  el.defaultChecked = normalizedChecked, restoreValue !== normalizedChecked && (el.checked = restoreValue);
596
736
  }
597
737
  }
738
+ /** Filled by the latches a compiled page emits, so a page carries only the
739
+ * control kinds its tags can be (`_attrs_script` resolves the kind at run time). */
740
+ /** The render pass equivalent, for a tag whose name is only known at run time;
741
+ * a statically named tag passes its claim to `_attrs` instead. */
742
+ function _enable_controllable_input() {
743
+ controllableScripts[0] = _attr_input_checked_script, controllableScripts[1] = _attr_input_checkedValue_script, controllableScripts[2] = _attr_input_value_script;
744
+ }
745
+ function _enable_controllable_textarea() {
746
+ controllableScripts[2] = _attr_input_value_script;
747
+ }
748
+ function _enable_controllable_select() {
749
+ controllableScripts[3] = _attr_select_value_script;
750
+ }
751
+ function _enable_controllable_open() {
752
+ controllableScripts[4] = _attr_details_or_dialog_open_script;
753
+ }
754
+ /** A run-time tag name can be any controllable, so its page enables them all. */
755
+ function _enable_controllable() {
756
+ _enable_controllable_input(), _enable_controllable_select(), _enable_controllable_open(), controllableRenders.INPUT = _controllable_input, controllableRenders.TEXTAREA = _controllable_textarea, controllableRenders.SELECT = _controllable_select, controllableRenders.DETAILS = controllableRenders.DIALOG = _controllable_open;
757
+ }
598
758
  function _attr_input_checked(scope, nodeAccessor, checked, checkedChange) {
599
759
  let el = scope[nodeAccessor], normalizedChecked = isNotVoid(checked);
600
760
  scope["E" + nodeAccessor] = checkedChange, scope["F" + nodeAccessor] = checkedChange ? 0 : 5, checkedChange && scope.H < runId ? el.checked = normalizedChecked : _attr_input_checked_default(scope, nodeAccessor, normalizedChecked);
@@ -692,12 +852,12 @@ function _attr_select_value_script(scope, nodeAccessor) {
692
852
  break;
693
853
  }
694
854
  }
695
- syncControllableFormInput(el, hasSelectChanged, onChange), new MutationObserver(() => {
696
- let value = scope["G" + nodeAccessor];
697
- (Array.isArray(value) ? value.length !== el.selectedOptions.length || value.some((_, i) => !value.includes(el.selectedOptions[i].value)) : el.value !== value) && onChange();
698
- }).observe(el, {
855
+ syncControllableFormInput(el, hasSelectChanged, onChange), observeOnce(scope, nodeAccessor, {
699
856
  childList: !0,
700
857
  subtree: !0
858
+ }, () => {
859
+ let value = scope["G" + nodeAccessor];
860
+ (Array.isArray(value) ? value.length !== el.selectedOptions.length || value.some((_, i) => !value.includes(el.selectedOptions[i].value)) : el.value !== value) && onChange();
701
861
  });
702
862
  }
703
863
  function setSelectValue(el, value, multiple) {
@@ -716,17 +876,20 @@ function _attr_details_or_dialog_open(scope, nodeAccessor, open, openChange) {
716
876
  }
717
877
  function _attr_details_or_dialog_open_script(scope, nodeAccessor) {
718
878
  let el = scope[nodeAccessor];
719
- new MutationObserver(() => {
879
+ observeOnce(scope, nodeAccessor, {
880
+ attributes: !0,
881
+ attributeFilter: ["open"]
882
+ }, () => {
720
883
  let openChange = scope["E" + nodeAccessor];
721
884
  if (openChange && el.open === !scope["G" + nodeAccessor]) {
722
885
  let newValue = el.open;
723
886
  el.open = !newValue, openChange(newValue), run();
724
887
  }
725
- }).observe(el, {
726
- attributes: !0,
727
- attributeFilter: ["open"]
728
888
  });
729
889
  }
890
+ function observeOnce(scope, nodeAccessor, init, callback) {
891
+ (scope["N" + nodeAccessor] ||= new MutationObserver(callback)).observe(scope[nodeAccessor], init);
892
+ }
730
893
  function syncControllableFormInput(el, hasChanged, onChange) {
731
894
  el._ = onChange, delegate("input", handleChange), el.form && delegate("reset", handleFormReset), isResuming && hasChanged(el) && queueMicrotask(onChange);
732
895
  }
@@ -759,175 +922,17 @@ function updateList(arr, val, push) {
759
922
  let index = arr.indexOf(val);
760
923
  return (push ? !~index && [...arr, val] : ~index && arr.slice(0, index).concat(arr.slice(index + 1))) || arr;
761
924
  }
762
- //#endregion
763
- //#region src/dom/dom.ts
764
- function _to_text(value) {
765
- return value || value === 0 ? value + "" : "";
766
- }
767
- function _attr(element, name, value) {
768
- setAttribute(element, name, normalizeAttrValue(value));
769
- }
770
- function setAttribute(element, name, value) {
771
- element.getAttribute(name) != value && (value === void 0 ? element.removeAttribute(name) : element.setAttribute(name, value));
772
- }
773
- function _attr_class(element, value) {
774
- setAttribute(element, "class", toDelimitedString(value, " ", stringifyClassObject) || void 0);
775
- }
776
- function _attr_class_items(element, items) {
777
- for (let key in items) _attr_class_item(element, key, items[key]);
778
- }
779
- function _attr_class_item(element, name, value) {
780
- element.classList.toggle(name, !!value);
781
- }
782
- function _attr_style(element, value) {
783
- setAttribute(element, "style", toDelimitedString(value, ";", stringifyStyleObject) || void 0);
784
- }
785
- function _attr_style_items(element, items) {
786
- for (let key in items) _attr_style_item(element, key, items[key]);
787
- }
788
- function _attr_style_item(element, name, value) {
789
- element.style.setProperty(name, _to_text(value));
790
- }
791
- function _style_shell(scope, nodeAccessor) {
792
- let element = scope[nodeAccessor], id = _id(scope);
793
- _attr_nonce(scope, nodeAccessor), element.className = id, _text_content(element, "." + id + "~*{}");
794
- }
795
- function _style_rule_item(element, name, value) {
796
- let text = element.textContent, decl = name + ":" + escapeStyleValue(_to_text(value)) + ";", start = text.indexOf("{" + name + ":");
797
- ~start || (start = text.indexOf(";" + name + ":")), _text_content(element, ~start ? text.slice(0, ++start) + decl + text.slice(text.indexOf(";", start) + 1) : text.slice(0, -1) + decl + "}");
798
- }
799
- function _attr_nonce(scope, nodeAccessor) {
800
- _attr(scope[nodeAccessor], "nonce", scope.$.cspNonce);
801
- }
802
- function _text(node, value) {
803
- let normalizedValue = _to_text(value);
804
- node.data !== normalizedValue && (node.data = normalizedValue);
805
- }
806
- function _text_content(node, value) {
807
- let normalizedValue = _to_text(value);
808
- node.textContent !== normalizedValue && (node.textContent = normalizedValue);
809
- }
810
- function _attrs(scope, nodeAccessor, nextAttrs) {
811
- let el = scope[nodeAccessor];
812
- for (let i = el.attributes.length; i--;) {
813
- let { name } = el.attributes.item(i);
814
- nextAttrs && (name in nextAttrs || hasAttrAlias(el, name, nextAttrs)) || el.removeAttribute(name);
815
- }
816
- attrsInternal(scope, nodeAccessor, nextAttrs);
817
- }
818
- function _attrs_content(scope, nodeAccessor, nextAttrs) {
819
- _attrs(scope, nodeAccessor, nextAttrs), _attr_content(scope, nodeAccessor, nextAttrs?.content);
820
- }
821
- function hasAttrAlias(element, attr, nextAttrs) {
822
- return attr === "checked" && element.tagName === "INPUT" && "checkedValue" in nextAttrs;
823
- }
824
- function _attrs_partial(scope, nodeAccessor, nextAttrs, skip) {
825
- let el = scope[nodeAccessor], partial = {};
826
- for (let i = el.attributes.length; i--;) {
827
- let { name } = el.attributes.item(i);
828
- !skip[name] && !(nextAttrs && name in nextAttrs) && el.removeAttribute(name);
829
- }
830
- for (let name in nextAttrs) {
831
- let key = isEventHandler(name) ? `on-${getEventHandlerName(name)}` : name;
832
- skip[key] || (partial[key] = nextAttrs[name]);
833
- }
834
- attrsInternal(scope, nodeAccessor, partial);
835
- }
836
- function _attrs_partial_content(scope, nodeAccessor, nextAttrs, skip) {
837
- _attrs_partial(scope, nodeAccessor, nextAttrs, skip), _attr_content(scope, nodeAccessor, nextAttrs?.content);
838
- }
839
- function attrsInternal(scope, nodeAccessor, nextAttrs) {
840
- let el = scope[nodeAccessor], events = scope["I" + nodeAccessor], skip;
841
- for (let name in events) events[name] = 0;
842
- switch (scope["F" + nodeAccessor] = 5, scope["E" + nodeAccessor] = 0, nextAttrs && el.tagName) {
843
- case "INPUT":
844
- "checked" in nextAttrs || "checkedChange" in nextAttrs ? (_attr_input_checked(scope, nodeAccessor, nextAttrs.checked, nextAttrs.checkedChange), skip = /^checked(?:Value)?(?:Change)?$/) : "checkedValue" in nextAttrs || "checkedValueChange" in nextAttrs ? (_attr_input_checkedValue(scope, nodeAccessor, nextAttrs.checkedValue, nextAttrs.checkedValueChange, nextAttrs.value), skip = /^(?:value|checked(?:Value)?)(?:Change)?$/) : ("value" in nextAttrs || "valueChange" in nextAttrs) && (_attr_input_value(scope, nodeAccessor, nextAttrs.value, nextAttrs.valueChange, _attr_input_value_dynamic_default), skip = /^value(?:Change)?$/);
845
- break;
846
- case "SELECT":
847
- ("value" in nextAttrs || "valueChange" in nextAttrs) && (_attr_select_value(scope, nodeAccessor, nextAttrs.value, nextAttrs.valueChange), skip = /^value(?:Change)?$/);
848
- break;
849
- case "TEXTAREA":
850
- ("value" in nextAttrs || "valueChange" in nextAttrs) && (_attr_input_value(scope, nodeAccessor, nextAttrs.value, nextAttrs.valueChange), skip = /^value(?:Change)?$/);
851
- break;
852
- case "DETAILS":
853
- case "DIALOG":
854
- ("open" in nextAttrs || "openChange" in nextAttrs) && (_attr_details_or_dialog_open(scope, nodeAccessor, nextAttrs.open, nextAttrs.openChange), skip = /^open(?:Change)?$/);
855
- break;
856
- }
857
- for (let name in nextAttrs) {
858
- let value = nextAttrs[name];
859
- switch (name) {
860
- case "class":
861
- _attr_class(el, value);
862
- break;
863
- case "style":
864
- _attr_style(el, value);
865
- break;
866
- default:
867
- isEventHandler(name) ? (events ||= scope["I" + nodeAccessor] = {})[getEventHandlerName(name)] = value : skip?.test(name) || name === "content" && el.tagName !== "META" || _attr(el, name, value);
868
- break;
869
- }
870
- }
871
- }
872
- function _attr_content(scope, nodeAccessor, value) {
873
- let content = normalizeClientRender(value);
874
- scope["D" + nodeAccessor] !== (scope["D" + nodeAccessor] = content?.a) && (setConditionalRenderer(scope, nodeAccessor, content, createAndSetupBranch), content?.f && subscribeToScopeSet(content.e, content.f, scope["A" + nodeAccessor]));
875
- for (let accessor in content?.g) content.g[accessor](scope["A" + nodeAccessor], content.h[accessor]);
925
+ function _controllable_input(scope, nodeAccessor, nextAttrs) {
926
+ return "checked" in nextAttrs || "checkedChange" in nextAttrs ? (_attr_input_checked(scope, nodeAccessor, nextAttrs.checked, nextAttrs.checkedChange), /^checked(?:Value)?(?:Change)?$/) : "checkedValue" in nextAttrs || "checkedValueChange" in nextAttrs ? (_attr_input_checkedValue(scope, nodeAccessor, nextAttrs.checkedValue, nextAttrs.checkedValueChange, nextAttrs.value), /^(?:value|checked(?:Value)?)(?:Change)?$/) : _controllable_textarea(scope, nodeAccessor, nextAttrs, _attr_input_value_dynamic_default);
876
927
  }
877
- function _attrs_script(scope, nodeAccessor) {
878
- let el = scope[nodeAccessor], events = scope["I" + nodeAccessor];
879
- switch (scope["F" + nodeAccessor]) {
880
- case 0:
881
- _attr_input_checked_script(scope, nodeAccessor);
882
- break;
883
- case 1:
884
- _attr_input_checkedValue_script(scope, nodeAccessor);
885
- break;
886
- case 2:
887
- _attr_input_value_script(scope, nodeAccessor);
888
- break;
889
- case 3:
890
- _attr_select_value_script(scope, nodeAccessor);
891
- break;
892
- case 4:
893
- _attr_details_or_dialog_open_script(scope, nodeAccessor);
894
- break;
895
- }
896
- for (let name in events) _on(el, name, events[name]);
928
+ function _controllable_textarea(scope, nodeAccessor, nextAttrs, dynamicDefault) {
929
+ if ("value" in nextAttrs || "valueChange" in nextAttrs) return _attr_input_value(scope, nodeAccessor, nextAttrs.value, nextAttrs.valueChange, dynamicDefault), /^value(?:Change)?$/;
897
930
  }
898
- function _html(scope, value, accessor) {
899
- let firstChild = scope[accessor], parentNode = firstChild.parentNode, lastChild = scope["H" + accessor] || firstChild, newContent = parseHTML(_to_text(value), parentNode.namespaceURI);
900
- insertChildNodes(parentNode, firstChild, scope[accessor] = newContent.firstChild || newContent.appendChild(new Text()), scope["H" + accessor] = newContent.lastChild), removeChildNodes(firstChild, lastChild);
931
+ function _controllable_select(scope, nodeAccessor, nextAttrs) {
932
+ if ("value" in nextAttrs || "valueChange" in nextAttrs) return _attr_select_value(scope, nodeAccessor, nextAttrs.value, nextAttrs.valueChange), /^value(?:Change)?$/;
901
933
  }
902
- function normalizeClientRender(value) {
903
- let renderer = normalizeDynamicRenderer(value);
904
- if (renderer && renderer.a) return renderer;
905
- }
906
- function normalizeAttrValue(value) {
907
- if (isNotVoid(value)) return value === !0 ? "" : value + "";
908
- }
909
- function _lifecycle(scope, thisObj, index = 0) {
910
- let accessor = "K" + index, instance = scope[accessor];
911
- instance ? (Object.assign(instance, thisObj), instance.onUpdate?.()) : (scope[accessor] = thisObj, Object.assign(thisObj, thisObj.onMount?.()), $signal(scope, accessor).onabort = () => thisObj.onDestroy?.());
912
- }
913
- function removeChildNodes(startNode, endNode) {
914
- let stop = endNode.nextSibling;
915
- for (; startNode !== stop;) {
916
- let next = startNode.nextSibling;
917
- startNode.remove(), startNode = next;
918
- }
919
- }
920
- function insertChildNodes(parentNode, referenceNode, startNode, endNode) {
921
- parentNode.insertBefore(toInsertNode(startNode, endNode), referenceNode);
922
- }
923
- function toInsertNode(startNode, endNode) {
924
- if (startNode === endNode) return startNode;
925
- let parent = new DocumentFragment(), stop = endNode.nextSibling;
926
- for (; startNode !== stop;) {
927
- let next = startNode.nextSibling;
928
- parent.appendChild(startNode), startNode = next;
929
- }
930
- return parent;
934
+ function _controllable_open(scope, nodeAccessor, nextAttrs) {
935
+ if ("open" in nextAttrs || "openChange" in nextAttrs) return _attr_details_or_dialog_open(scope, nodeAccessor, nextAttrs.open, nextAttrs.openChange), /^open(?:Change)?$/;
931
936
  }
932
937
  //#endregion
933
938
  //#region src/dom/control-flow.ts
@@ -964,7 +969,11 @@ function _await_promise(nodeAccessor, params) {
964
969
  let thisPromise = scope[promiseAccessor] = promise.then((data) => {
965
970
  if (thisPromise === scope[promiseAccessor]) {
966
971
  let referenceNode = scope[nodeAccessor];
967
- scope[promiseAccessor] = 0, queueAsyncRender(scope, () => {
972
+ if (scope[promiseAccessor] = 0, scope.F?.H === 0) {
973
+ awaitCounter.c(), run();
974
+ return;
975
+ }
976
+ queueAsyncRender(scope, () => {
968
977
  awaitBranch = resolveAwait(scope, referenceNode, data);
969
978
  let pendingRenders = awaitBranch.W;
970
979
  if (awaitBranch.W = 0, pendingRenders?.forEach(queuePendingRender), placeholderShown.add(pendingEffects), awaitCounter.c(), awaitCounter.m) {
@@ -1230,7 +1239,7 @@ function _enable_catch() {
1230
1239
  //#region src/dom/abort-signal.ts
1231
1240
  function $signalReset(scope, id) {
1232
1241
  let ctrl = scope.A?.[id];
1233
- ctrl && (queueEffect(ctrl, abort), scope.A[id] = void 0);
1242
+ ctrl && (scope.A[id] = void 0, rendering ? queueEffect(ctrl, abort) : abort(ctrl));
1234
1243
  }
1235
1244
  function $signal(scope, id) {
1236
1245
  return scope.F && (scope.F.B ||= /* @__PURE__ */ new Set()).add(scope), ((scope.A ||= {})[id] ||= new AbortController()).signal;
@@ -1276,10 +1285,10 @@ function mount(input = {}, reference, position) {
1276
1285
  set value(newValue) {
1277
1286
  _var_change(branch, newValue);
1278
1287
  },
1279
- update(newInput) {
1280
- args && runEffects(prepareEffects(() => {
1288
+ update(newInput = {}) {
1289
+ args && (newInput.$global && ({$global, ...newInput} = newInput), runEffects(prepareEffects(() => {
1281
1290
  args(branch, newInput);
1282
- }));
1291
+ })));
1283
1292
  },
1284
1293
  destroy() {
1285
1294
  removeAndDestroyBranch(branch);
@@ -1359,9 +1368,9 @@ function _load_race_trigger(...triggers) {
1359
1368
  function getSelectorOrResolve(selector, resolve) {
1360
1369
  return document.querySelector(selector) || resolve();
1361
1370
  }
1362
- exports.$signal = $signal, exports.$signalReset = $signalReset, exports._assert_hoist = _assert_hoist, exports._assert_init = _assert_init, exports._attr = _attr, exports._attr_class = _attr_class, exports._attr_class_item = _attr_class_item, exports._attr_class_items = _attr_class_items, exports._attr_content = _attr_content, exports._attr_details_open = _attr_details_or_dialog_open, exports._attr_dialog_open = _attr_details_or_dialog_open, exports._attr_details_open_default = _attr_details_or_dialog_open_default, exports._attr_dialog_open_default = _attr_details_or_dialog_open_default, exports._attr_details_open_script = _attr_details_or_dialog_open_script, exports._attr_dialog_open_script = _attr_details_or_dialog_open_script, exports._attr_input_checked = _attr_input_checked, exports._attr_input_checkedValue = _attr_input_checkedValue, exports._attr_input_checkedValue_default = _attr_input_checkedValue_default, exports._attr_input_checkedValue_script = _attr_input_checkedValue_script, exports._attr_input_checked_default = _attr_input_checked_default, exports._attr_input_checked_script = _attr_input_checked_script, exports._attr_input_value = _attr_input_value, exports._attr_textarea_value = _attr_input_value, exports._attr_input_value_attribute_default = _attr_input_value_attribute_default, exports._attr_input_value_default = _attr_input_value_default, exports._attr_textarea_value_default = _attr_input_value_default, exports._attr_input_value_dynamic_default = _attr_input_value_dynamic_default, exports._attr_input_value_script = _attr_input_value_script, exports._attr_textarea_value_script = _attr_input_value_script, exports._attr_nonce = _attr_nonce, exports._attr_select_value = _attr_select_value, exports._attr_select_value_default = _attr_select_value_default, exports._attr_select_value_script = _attr_select_value_script, exports._attr_style = _attr_style, exports._attr_style_item = _attr_style_item, exports._attr_style_items = _attr_style_items, exports._attrs = _attrs, exports._attrs_content = _attrs_content, exports._attrs_partial = _attrs_partial, exports._attrs_partial_content = _attrs_partial_content, exports._attrs_script = _attrs_script, exports._await_content = _await_content, exports._await_promise = _await_promise, exports._call = _call, exports._child_setup = _child_setup, exports._closure = _closure, exports._closure_get = _closure_get, exports._const = _const, exports._content = _content, exports._content_closures = _content_closures, exports._content_resume = _content_resume, Object.defineProperty(exports, "_dynamic_tag", {
1371
+ exports.$signal = $signal, exports.$signalReset = $signalReset, exports._assert_hoist = _assert_hoist, exports._assert_init = _assert_init, exports._attr = _attr, exports._attr_class = _attr_class, exports._attr_class_item = _attr_class_item, exports._attr_class_items = _attr_class_items, exports._attr_content = _attr_content, exports._attr_details_open = _attr_details_or_dialog_open, exports._attr_dialog_open = _attr_details_or_dialog_open, exports._attr_details_open_default = _attr_details_or_dialog_open_default, exports._attr_dialog_open_default = _attr_details_or_dialog_open_default, exports._attr_details_open_script = _attr_details_or_dialog_open_script, exports._attr_dialog_open_script = _attr_details_or_dialog_open_script, exports._attr_input_checked = _attr_input_checked, exports._attr_input_checkedValue = _attr_input_checkedValue, exports._attr_input_checkedValue_default = _attr_input_checkedValue_default, exports._attr_input_checkedValue_script = _attr_input_checkedValue_script, exports._attr_input_checked_default = _attr_input_checked_default, exports._attr_input_checked_script = _attr_input_checked_script, exports._attr_input_value = _attr_input_value, exports._attr_textarea_value = _attr_input_value, exports._attr_input_value_attribute_default = _attr_input_value_attribute_default, exports._attr_input_value_default = _attr_input_value_default, exports._attr_textarea_value_default = _attr_input_value_default, exports._attr_input_value_dynamic_default = _attr_input_value_dynamic_default, exports._attr_input_value_script = _attr_input_value_script, exports._attr_textarea_value_script = _attr_input_value_script, exports._attr_nonce = _attr_nonce, exports._attr_select_value = _attr_select_value, exports._attr_select_value_default = _attr_select_value_default, exports._attr_select_value_script = _attr_select_value_script, exports._attr_style = _attr_style, exports._attr_style_item = _attr_style_item, exports._attr_style_items = _attr_style_items, exports._attrs = _attrs, exports._attrs_content = _attrs_content, exports._attrs_partial = _attrs_partial, exports._attrs_partial_content = _attrs_partial_content, exports._attrs_script = _attrs_script, exports._await_content = _await_content, exports._await_promise = _await_promise, exports._call = _call, exports._child_setup = _child_setup, exports._closure = _closure, exports._closure_get = _closure_get, exports._const = _const, exports._content = _content, exports._content_closures = _content_closures, exports._content_resume = _content_resume, exports._controllable_input = _controllable_input, exports._controllable_open = _controllable_open, exports._controllable_select = _controllable_select, exports._controllable_textarea = _controllable_textarea, Object.defineProperty(exports, "_dynamic_tag", {
1363
1372
  enumerable: !0,
1364
1373
  get: function() {
1365
1374
  return _dynamic_tag;
1366
1375
  }
1367
- }), exports._dynamic_tag_content = _dynamic_tag_content, exports._el = _el, exports._el_read = _el_read, exports._enable_catch = _enable_catch, exports._for_closure = _for_closure, exports._for_in = _for_in, exports._for_of = _for_of, exports._for_selector = _for_selector, exports._for_to = _for_to, exports._for_until = _for_until, exports._hoist = _hoist, exports._hoist_resume = _hoist_resume, exports._html = _html, exports._id = _id, exports._if = _if, exports._if_closure = _if_closure, exports._let = _let, exports._let_change = _let_change, exports._lifecycle = _lifecycle, exports._load_event_trigger = _load_event_trigger, exports._load_idle_trigger = _load_idle_trigger, exports._load_media_trigger = _load_media_trigger, exports._load_race_trigger = _load_race_trigger, exports._load_setup = _load_setup, exports._load_signal = _load_signal, exports._load_template = _load_template, exports._load_visible_trigger = _load_visible_trigger, exports._on = _on, exports._or = _or, exports._resume = _resume, exports._resume_dynamic_tag = _resume_dynamic_tag, exports._return = _return, exports._return_change = _return_change, exports._script = _script, exports._show = _show, exports._style_rule_item = _style_rule_item, exports._style_shell = _style_shell, exports._template = _template, exports._text = _text, exports._text_content = _text_content, exports._to_text = _to_text, exports._try = _try, exports._var = _var, exports._var_change = _var_change, exports._var_resume = _var_resume, exports.attrTag = attrTag, exports.attrTags = attrTags, exports.compat = compat, exports.forIn = forIn, exports.forOf = forOf, exports.forTo = forTo, exports.forUntil = forUntil, exports.init = init, exports.initEmbedded = initEmbedded, exports.ready = ready, exports.run = run;
1376
+ }), exports._dynamic_tag_content = _dynamic_tag_content, exports._el = _el, exports._el_read = _el_read, exports._enable_catch = _enable_catch, exports._enable_controllable = _enable_controllable, exports._enable_controllable_input = _enable_controllable_input, exports._enable_controllable_open = _enable_controllable_open, exports._enable_controllable_select = _enable_controllable_select, exports._enable_controllable_textarea = _enable_controllable_textarea, exports._for_closure = _for_closure, exports._for_in = _for_in, exports._for_of = _for_of, exports._for_selector = _for_selector, exports._for_to = _for_to, exports._for_until = _for_until, exports._hoist = _hoist, exports._hoist_resume = _hoist_resume, exports._html = _html, exports._id = _id, exports._if = _if, exports._if_closure = _if_closure, exports._let = _let, exports._let_change = _let_change, exports._lifecycle = _lifecycle, exports._load_event_trigger = _load_event_trigger, exports._load_idle_trigger = _load_idle_trigger, exports._load_media_trigger = _load_media_trigger, exports._load_race_trigger = _load_race_trigger, exports._load_setup = _load_setup, exports._load_signal = _load_signal, exports._load_template = _load_template, exports._load_visible_trigger = _load_visible_trigger, exports._on = _on, exports._or = _or, exports._resume = _resume, exports._resume_dynamic_tag = _resume_dynamic_tag, exports._return = _return, exports._return_change = _return_change, exports._script = _script, exports._show = _show, exports._style_rule_item = _style_rule_item, exports._style_shell = _style_shell, exports._template = _template, exports._text = _text, exports._text_content = _text_content, exports._to_text = _to_text, exports._try = _try, exports._var = _var, exports._var_change = _var_change, exports._var_resume = _var_resume, exports.attrTag = attrTag, exports.attrTags = attrTags, exports.compat = compat, exports.forIn = forIn, exports.forOf = forOf, exports.forTo = forTo, exports.forUntil = forUntil, exports.init = init, exports.initEmbedded = initEmbedded, exports.ready = ready, exports.run = run;