marko 6.3.25 → 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.mjs 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;
@@ -20,7 +20,7 @@ let empty = [], rest = Symbol(), unsafeStyleAttrReg = /[\\;]/g, replaceUnsafeSty
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 = "", controllableScripts = {}, controllableRenders = {}, _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);
@@ -206,19 +206,6 @@ function handleDelegated(ev) {
206
206
  for (; target;) target["$" + ev.type]?.(ev, target), target = ev.bubbles && !ev.cancelBubble && target.parentNode;
207
207
  }
208
208
  //#endregion
209
- //#region src/dom/resolve-cursor-position.ts
210
- function resolveCursorPosition(inputType, initialPosition, initialValue, updatedValue) {
211
- if ((initialPosition || initialPosition === 0) && (initialPosition !== initialValue.length || /kw/.test(inputType))) {
212
- let before = initialValue.slice(0, initialPosition), after = initialValue.slice(initialPosition);
213
- if (updatedValue.startsWith(before)) return initialPosition;
214
- if (updatedValue.endsWith(after)) return updatedValue.length - after.length;
215
- let count = before.replace(R, "").length, pos = 0;
216
- for (; count && updatedValue[pos];) updatedValue[pos++].replace(R, "") && count--;
217
- return pos;
218
- }
219
- return -1;
220
- }
221
- //#endregion
222
209
  //#region src/dom/parse-html.ts
223
210
  function parseHTML(html, ns) {
224
211
  let parser = parsers[ns] ||= document.createElementNS(ns, "template");
@@ -421,57 +408,6 @@ function walk(startNode, walkCodes, branch) {
421
408
  walker.currentNode = startNode, walkInternal(0, walkCodes, branch);
422
409
  }
423
410
  //#endregion
424
- //#region src/dom/renderer.ts
425
- function createBranch($global, renderer, parentScope, parentNode) {
426
- let branch = createScope($global);
427
- return branch._ = renderer.e || parentScope, setParentBranch(branch, parentScope?.F), renderer.b?.(branch, parentNode.namespaceURI), branch;
428
- }
429
- function setParentBranch(branch, parentBranch) {
430
- parentBranch && (branch.N = parentBranch, (parentBranch.D ||= /* @__PURE__ */ new Set()).add(branch)), branch.F = branch;
431
- }
432
- function createAndSetupBranch($global, renderer, parentScope, parentNode) {
433
- return setupBranch(renderer, createBranch($global, renderer, parentScope, parentNode));
434
- }
435
- function setupBranch(renderer, branch) {
436
- return renderer.c && queueRender(branch, renderer.c, -1), branch;
437
- }
438
- function _content(id, template, walks, setup, params, dynamicScopesAccessor) {
439
- walks = walks ? walks.replace(/[^\0-1]+$/, "") : "", setup = setup ? setup._ || setup : void 0, params ||= void 0;
440
- let clone = template ? (branch, ns) => {
441
- ((cloneCache[ns] ||= {})[template] ||= createCloneableHTML(template, ns))(branch, walks);
442
- } : (branch) => {
443
- walk(branch.S = branch.K = new Text(), walks, branch);
444
- };
445
- return (owner) => ({
446
- a: id,
447
- b: clone,
448
- e: owner,
449
- c: setup,
450
- d: params,
451
- f: dynamicScopesAccessor
452
- });
453
- }
454
- function _content_resume(id, template, walks, setup, params, dynamicScopesAccessor) {
455
- return _resume(id, _content(id, template, walks, setup, params, dynamicScopesAccessor));
456
- }
457
- function _content_closures(renderer, closureFns) {
458
- let closureSignals = {};
459
- for (let key in closureFns) closureSignals[key] = _const(+key, closureFns[key]);
460
- return (owner, closureValues) => {
461
- let instance = renderer(owner);
462
- return instance.g = closureSignals, instance.h = closureValues, instance;
463
- };
464
- }
465
- function createCloneableHTML(html, ns) {
466
- let { firstChild, lastChild } = parseHTML(html, ns), parent = document.createElementNS(ns, "t");
467
- return insertChildNodes(parent, null, firstChild, lastChild), firstChild === lastChild && firstChild.nodeType < 8 ? (branch, walks) => {
468
- walk(branch.S = branch.K = firstChild.cloneNode(!0), walks, branch);
469
- } : (branch, walks) => {
470
- let clone = parent.cloneNode(!0);
471
- walk(clone.firstChild, walks, branch), branch.S = clone.firstChild, branch.K = clone.lastChild;
472
- };
473
- }
474
- //#endregion
475
411
  //#region src/dom/resume.ts
476
412
  function enableBranches() {
477
413
  branchesEnabled || (branchesEnabled = 1, skipDestroyedRenders());
@@ -586,6 +522,210 @@ function _el(id, accessor) {
586
522
  return accessor = decodeAccessor(accessor), _resume(id, (scope) => () => scope[accessor]);
587
523
  }
588
524
  //#endregion
525
+ //#region src/dom/renderer.ts
526
+ function createBranch($global, renderer, parentScope, parentNode) {
527
+ let branch = createScope($global);
528
+ return branch._ = renderer.e || parentScope, setParentBranch(branch, parentScope?.F), renderer.b?.(branch, parentNode.namespaceURI), branch;
529
+ }
530
+ function setParentBranch(branch, parentBranch) {
531
+ parentBranch && (branch.N = parentBranch, (parentBranch.D ||= /* @__PURE__ */ new Set()).add(branch)), branch.F = branch;
532
+ }
533
+ function createAndSetupBranch($global, renderer, parentScope, parentNode) {
534
+ return setupBranch(renderer, createBranch($global, renderer, parentScope, parentNode));
535
+ }
536
+ function setupBranch(renderer, branch) {
537
+ return renderer.c && queueRender(branch, renderer.c, -1), branch;
538
+ }
539
+ function _content(id, template, walks, setup, params, dynamicScopesAccessor) {
540
+ walks = walks ? walks.replace(/[^\0-1]+$/, "") : "", setup = setup ? setup._ || setup : void 0, params ||= void 0;
541
+ let clone = template ? (branch, ns) => {
542
+ ((cloneCache[ns] ||= {})[template] ||= createCloneableHTML(template, ns))(branch, walks);
543
+ } : (branch) => {
544
+ walk(branch.S = branch.K = new Text(), walks, branch);
545
+ };
546
+ return (owner) => ({
547
+ a: id,
548
+ b: clone,
549
+ e: owner,
550
+ c: setup,
551
+ d: params,
552
+ f: dynamicScopesAccessor
553
+ });
554
+ }
555
+ function _content_resume(id, template, walks, setup, params, dynamicScopesAccessor) {
556
+ return _resume(id, _content(id, template, walks, setup, params, dynamicScopesAccessor));
557
+ }
558
+ function _content_closures(renderer, closureFns) {
559
+ let closureSignals = {};
560
+ for (let key in closureFns) closureSignals[key] = _const(+key, closureFns[key]);
561
+ return (owner, closureValues) => {
562
+ let instance = renderer(owner);
563
+ return instance.g = closureSignals, instance.h = closureValues, instance;
564
+ };
565
+ }
566
+ function createCloneableHTML(html, ns) {
567
+ let { firstChild, lastChild } = parseHTML(html, ns), parent = document.createElementNS(ns, "t");
568
+ return insertChildNodes(parent, null, firstChild, lastChild), firstChild === lastChild && firstChild.nodeType < 8 ? (branch, walks) => {
569
+ walk(branch.S = branch.K = firstChild.cloneNode(!0), walks, branch);
570
+ } : (branch, walks) => {
571
+ let clone = parent.cloneNode(!0);
572
+ walk(clone.firstChild, walks, branch), branch.S = clone.firstChild, branch.K = clone.lastChild;
573
+ };
574
+ }
575
+ //#endregion
576
+ //#region src/dom/dom.ts
577
+ function _to_text(value) {
578
+ return value || value === 0 ? value + "" : "";
579
+ }
580
+ function _attr(element, name, value) {
581
+ setAttribute(element, name, normalizeAttrValue(value));
582
+ }
583
+ function setAttribute(element, name, value) {
584
+ element.getAttribute(name) != value && (value === void 0 ? element.removeAttribute(name) : element.setAttribute(name, value));
585
+ }
586
+ function _attr_class(element, value) {
587
+ setAttribute(element, "class", toDelimitedString(value, " ", stringifyClassObject) || void 0);
588
+ }
589
+ function _attr_class_items(element, items) {
590
+ for (let key in items) _attr_class_item(element, key, items[key]);
591
+ }
592
+ function _attr_class_item(element, name, value) {
593
+ element.classList.toggle(name, !!value);
594
+ }
595
+ function _attr_style(element, value) {
596
+ setAttribute(element, "style", toDelimitedString(value, ";", stringifyStyleObject) || void 0);
597
+ }
598
+ function _attr_style_items(element, items) {
599
+ for (let key in items) _attr_style_item(element, key, items[key]);
600
+ }
601
+ function _attr_style_item(element, name, value) {
602
+ element.style.setProperty(name, _to_text(value));
603
+ }
604
+ function _style_shell(scope, nodeAccessor) {
605
+ let element = scope[nodeAccessor], id = _id(scope);
606
+ _attr_nonce(scope, nodeAccessor), element.className = id, _text_content(element, "." + id + "~*{}");
607
+ }
608
+ function _style_rule_item(element, name, value) {
609
+ let text = element.textContent, decl = name + ":" + escapeStyleValue(_to_text(value)) + ";", start = text.indexOf("{" + name + ":");
610
+ ~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 + "}");
611
+ }
612
+ function _attr_nonce(scope, nodeAccessor) {
613
+ _attr(scope[nodeAccessor], "nonce", scope.$.cspNonce);
614
+ }
615
+ function _text(node, value) {
616
+ let normalizedValue = _to_text(value);
617
+ node.data !== normalizedValue && (node.data = normalizedValue);
618
+ }
619
+ function _text_content(node, value) {
620
+ let normalizedValue = _to_text(value);
621
+ node.textContent !== normalizedValue && (node.textContent = normalizedValue);
622
+ }
623
+ function _attrs(scope, nodeAccessor, nextAttrs, controllable) {
624
+ let el = scope[nodeAccessor];
625
+ for (let i = el.attributes.length; i--;) {
626
+ let { name } = el.attributes.item(i);
627
+ nextAttrs && (name in nextAttrs || hasAttrAlias(el, name, nextAttrs)) || el.removeAttribute(name);
628
+ }
629
+ attrsInternal(scope, nodeAccessor, nextAttrs, controllable);
630
+ }
631
+ function _attrs_content(scope, nodeAccessor, nextAttrs, controllable) {
632
+ _attrs(scope, nodeAccessor, nextAttrs, controllable), _attr_content(scope, nodeAccessor, nextAttrs?.content);
633
+ }
634
+ function hasAttrAlias(element, attr, nextAttrs) {
635
+ return attr === "checked" && element.tagName === "INPUT" && "checkedValue" in nextAttrs;
636
+ }
637
+ function _attrs_partial(scope, nodeAccessor, nextAttrs, skip, controllable) {
638
+ let el = scope[nodeAccessor], partial = {};
639
+ for (let i = el.attributes.length; i--;) {
640
+ let { name } = el.attributes.item(i);
641
+ !skip[name] && !(nextAttrs && name in nextAttrs) && el.removeAttribute(name);
642
+ }
643
+ for (let name in nextAttrs) {
644
+ let key = isEventHandler(name) ? `on-${getEventHandlerName(name)}` : name;
645
+ skip[key] || (partial[key] = nextAttrs[name]);
646
+ }
647
+ attrsInternal(scope, nodeAccessor, partial, controllable);
648
+ }
649
+ function _attrs_partial_content(scope, nodeAccessor, nextAttrs, skip, controllable) {
650
+ _attrs_partial(scope, nodeAccessor, nextAttrs, skip, controllable), _attr_content(scope, nodeAccessor, nextAttrs?.content);
651
+ }
652
+ function attrsInternal(scope, nodeAccessor, nextAttrs, controllable) {
653
+ let el = scope[nodeAccessor], events = scope["I" + nodeAccessor], skip;
654
+ for (let name in events) events[name] = 0;
655
+ controllable && (scope["F" + nodeAccessor] = 5, scope["E" + nodeAccessor] = 0, nextAttrs && (skip = controllable(scope, nodeAccessor, nextAttrs)));
656
+ for (let name in nextAttrs) {
657
+ let value = nextAttrs[name];
658
+ switch (name) {
659
+ case "class":
660
+ _attr_class(el, value);
661
+ break;
662
+ case "style":
663
+ _attr_style(el, value);
664
+ break;
665
+ default:
666
+ isEventHandler(name) ? (events ||= scope["I" + nodeAccessor] = {})[getEventHandlerName(name)] = value : skip?.test(name) || name === "content" && el.tagName !== "META" || _attr(el, name, value);
667
+ break;
668
+ }
669
+ }
670
+ }
671
+ function _attr_content(scope, nodeAccessor, value) {
672
+ let content = normalizeClientRender(value);
673
+ scope["D" + nodeAccessor] !== (scope["D" + nodeAccessor] = content?.a) && (setConditionalRenderer(scope, nodeAccessor, content, createAndSetupBranch), content?.f && subscribeToScopeSet(content.e, content.f, scope["A" + nodeAccessor]));
674
+ for (let accessor in content?.g) content.g[accessor](scope["A" + nodeAccessor], content.h[accessor]);
675
+ }
676
+ function _attrs_script(scope, nodeAccessor) {
677
+ let el = scope[nodeAccessor], events = scope["I" + nodeAccessor];
678
+ controllableScripts[scope["F" + nodeAccessor]]?.(scope, nodeAccessor);
679
+ for (let name in events) _on(el, name, events[name]);
680
+ }
681
+ function _html(scope, value, accessor) {
682
+ let firstChild = scope[accessor], parentNode = firstChild.parentNode, lastChild = scope["H" + accessor] || firstChild, newContent = parseHTML(_to_text(value), parentNode.namespaceURI);
683
+ insertChildNodes(parentNode, firstChild, scope[accessor] = newContent.firstChild || newContent.appendChild(new Text()), scope["H" + accessor] = newContent.lastChild), removeChildNodes(firstChild, lastChild);
684
+ }
685
+ function normalizeClientRender(value) {
686
+ let renderer = normalizeDynamicRenderer(value);
687
+ if (renderer && renderer.a) return renderer;
688
+ }
689
+ function normalizeAttrValue(value) {
690
+ if (isNotVoid(value)) return value === !0 ? "" : value + "";
691
+ }
692
+ function _lifecycle(scope, thisObj, index = 0) {
693
+ let accessor = "K" + index, instance = scope[accessor];
694
+ instance ? (Object.assign(instance, thisObj), instance.onUpdate?.()) : (scope[accessor] = thisObj, Object.assign(thisObj, thisObj.onMount?.()), $signal(scope, accessor).onabort = () => thisObj.onDestroy?.());
695
+ }
696
+ function removeChildNodes(startNode, endNode) {
697
+ let stop = endNode.nextSibling;
698
+ for (; startNode !== stop;) {
699
+ let next = startNode.nextSibling;
700
+ startNode.remove(), startNode = next;
701
+ }
702
+ }
703
+ function insertChildNodes(parentNode, referenceNode, startNode, endNode) {
704
+ parentNode.insertBefore(toInsertNode(startNode, endNode), referenceNode);
705
+ }
706
+ function toInsertNode(startNode, endNode) {
707
+ if (startNode === endNode) return startNode;
708
+ let parent = new DocumentFragment(), stop = endNode.nextSibling;
709
+ for (; startNode !== stop;) {
710
+ let next = startNode.nextSibling;
711
+ parent.appendChild(startNode), startNode = next;
712
+ }
713
+ return parent;
714
+ }
715
+ //#endregion
716
+ //#region src/dom/resolve-cursor-position.ts
717
+ function resolveCursorPosition(inputType, initialPosition, initialValue, updatedValue) {
718
+ if ((initialPosition || initialPosition === 0) && (initialPosition !== initialValue.length || /kw/.test(inputType))) {
719
+ let before = initialValue.slice(0, initialPosition), after = initialValue.slice(initialPosition);
720
+ if (updatedValue.startsWith(before)) return initialPosition;
721
+ if (updatedValue.endsWith(after)) return updatedValue.length - after.length;
722
+ let count = before.replace(R, "").length, pos = 0;
723
+ for (; count && updatedValue[pos];) updatedValue[pos++].replace(R, "") && count--;
724
+ return pos;
725
+ }
726
+ return -1;
727
+ }
728
+ //#endregion
589
729
  //#region src/dom/controllable.ts
590
730
  function _attr_input_checked_default(scope, nodeAccessor, checked) {
591
731
  let el = scope[nodeAccessor], normalizedChecked = isNotVoid(checked);
@@ -794,147 +934,6 @@ function _controllable_open(scope, nodeAccessor, nextAttrs) {
794
934
  if ("open" in nextAttrs || "openChange" in nextAttrs) return _attr_details_or_dialog_open(scope, nodeAccessor, nextAttrs.open, nextAttrs.openChange), /^open(?:Change)?$/;
795
935
  }
796
936
  //#endregion
797
- //#region src/dom/dom.ts
798
- function _to_text(value) {
799
- return value || value === 0 ? value + "" : "";
800
- }
801
- function _attr(element, name, value) {
802
- setAttribute(element, name, normalizeAttrValue(value));
803
- }
804
- function setAttribute(element, name, value) {
805
- element.getAttribute(name) != value && (value === void 0 ? element.removeAttribute(name) : element.setAttribute(name, value));
806
- }
807
- function _attr_class(element, value) {
808
- setAttribute(element, "class", toDelimitedString(value, " ", stringifyClassObject) || void 0);
809
- }
810
- function _attr_class_items(element, items) {
811
- for (let key in items) _attr_class_item(element, key, items[key]);
812
- }
813
- function _attr_class_item(element, name, value) {
814
- element.classList.toggle(name, !!value);
815
- }
816
- function _attr_style(element, value) {
817
- setAttribute(element, "style", toDelimitedString(value, ";", stringifyStyleObject) || void 0);
818
- }
819
- function _attr_style_items(element, items) {
820
- for (let key in items) _attr_style_item(element, key, items[key]);
821
- }
822
- function _attr_style_item(element, name, value) {
823
- element.style.setProperty(name, _to_text(value));
824
- }
825
- function _style_shell(scope, nodeAccessor) {
826
- let element = scope[nodeAccessor], id = _id(scope);
827
- _attr_nonce(scope, nodeAccessor), element.className = id, _text_content(element, "." + id + "~*{}");
828
- }
829
- function _style_rule_item(element, name, value) {
830
- let text = element.textContent, decl = name + ":" + escapeStyleValue(_to_text(value)) + ";", start = text.indexOf("{" + name + ":");
831
- ~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 + "}");
832
- }
833
- function _attr_nonce(scope, nodeAccessor) {
834
- _attr(scope[nodeAccessor], "nonce", scope.$.cspNonce);
835
- }
836
- function _text(node, value) {
837
- let normalizedValue = _to_text(value);
838
- node.data !== normalizedValue && (node.data = normalizedValue);
839
- }
840
- function _text_content(node, value) {
841
- let normalizedValue = _to_text(value);
842
- node.textContent !== normalizedValue && (node.textContent = normalizedValue);
843
- }
844
- function _attrs(scope, nodeAccessor, nextAttrs, controllable) {
845
- let el = scope[nodeAccessor];
846
- for (let i = el.attributes.length; i--;) {
847
- let { name } = el.attributes.item(i);
848
- nextAttrs && (name in nextAttrs || hasAttrAlias(el, name, nextAttrs)) || el.removeAttribute(name);
849
- }
850
- attrsInternal(scope, nodeAccessor, nextAttrs, controllable);
851
- }
852
- function _attrs_content(scope, nodeAccessor, nextAttrs, controllable) {
853
- _attrs(scope, nodeAccessor, nextAttrs, controllable), _attr_content(scope, nodeAccessor, nextAttrs?.content);
854
- }
855
- function hasAttrAlias(element, attr, nextAttrs) {
856
- return attr === "checked" && element.tagName === "INPUT" && "checkedValue" in nextAttrs;
857
- }
858
- function _attrs_partial(scope, nodeAccessor, nextAttrs, skip, controllable) {
859
- let el = scope[nodeAccessor], partial = {};
860
- for (let i = el.attributes.length; i--;) {
861
- let { name } = el.attributes.item(i);
862
- !skip[name] && !(nextAttrs && name in nextAttrs) && el.removeAttribute(name);
863
- }
864
- for (let name in nextAttrs) {
865
- let key = isEventHandler(name) ? `on-${getEventHandlerName(name)}` : name;
866
- skip[key] || (partial[key] = nextAttrs[name]);
867
- }
868
- attrsInternal(scope, nodeAccessor, partial, controllable);
869
- }
870
- function _attrs_partial_content(scope, nodeAccessor, nextAttrs, skip, controllable) {
871
- _attrs_partial(scope, nodeAccessor, nextAttrs, skip, controllable), _attr_content(scope, nodeAccessor, nextAttrs?.content);
872
- }
873
- function attrsInternal(scope, nodeAccessor, nextAttrs, controllable) {
874
- let el = scope[nodeAccessor], events = scope["I" + nodeAccessor];
875
- for (let name in events) events[name] = 0;
876
- scope["F" + nodeAccessor] = 5, scope["E" + nodeAccessor] = 0;
877
- let skip = nextAttrs && (controllable || controllableRenders[el.tagName])?.(scope, nodeAccessor, nextAttrs);
878
- for (let name in nextAttrs) {
879
- let value = nextAttrs[name];
880
- switch (name) {
881
- case "class":
882
- _attr_class(el, value);
883
- break;
884
- case "style":
885
- _attr_style(el, value);
886
- break;
887
- default:
888
- isEventHandler(name) ? (events ||= scope["I" + nodeAccessor] = {})[getEventHandlerName(name)] = value : skip?.test(name) || name === "content" && el.tagName !== "META" || _attr(el, name, value);
889
- break;
890
- }
891
- }
892
- }
893
- function _attr_content(scope, nodeAccessor, value) {
894
- let content = normalizeClientRender(value);
895
- scope["D" + nodeAccessor] !== (scope["D" + nodeAccessor] = content?.a) && (setConditionalRenderer(scope, nodeAccessor, content, createAndSetupBranch), content?.f && subscribeToScopeSet(content.e, content.f, scope["A" + nodeAccessor]));
896
- for (let accessor in content?.g) content.g[accessor](scope["A" + nodeAccessor], content.h[accessor]);
897
- }
898
- function _attrs_script(scope, nodeAccessor) {
899
- let el = scope[nodeAccessor], events = scope["I" + nodeAccessor];
900
- controllableScripts[scope["F" + nodeAccessor]]?.(scope, nodeAccessor);
901
- for (let name in events) _on(el, name, events[name]);
902
- }
903
- function _html(scope, value, accessor) {
904
- let firstChild = scope[accessor], parentNode = firstChild.parentNode, lastChild = scope["H" + accessor] || firstChild, newContent = parseHTML(_to_text(value), parentNode.namespaceURI);
905
- insertChildNodes(parentNode, firstChild, scope[accessor] = newContent.firstChild || newContent.appendChild(new Text()), scope["H" + accessor] = newContent.lastChild), removeChildNodes(firstChild, lastChild);
906
- }
907
- function normalizeClientRender(value) {
908
- let renderer = normalizeDynamicRenderer(value);
909
- if (renderer && renderer.a) return renderer;
910
- }
911
- function normalizeAttrValue(value) {
912
- if (isNotVoid(value)) return value === !0 ? "" : value + "";
913
- }
914
- function _lifecycle(scope, thisObj, index = 0) {
915
- let accessor = "K" + index, instance = scope[accessor];
916
- instance ? (Object.assign(instance, thisObj), instance.onUpdate?.()) : (scope[accessor] = thisObj, Object.assign(thisObj, thisObj.onMount?.()), $signal(scope, accessor).onabort = () => thisObj.onDestroy?.());
917
- }
918
- function removeChildNodes(startNode, endNode) {
919
- let stop = endNode.nextSibling;
920
- for (; startNode !== stop;) {
921
- let next = startNode.nextSibling;
922
- startNode.remove(), startNode = next;
923
- }
924
- }
925
- function insertChildNodes(parentNode, referenceNode, startNode, endNode) {
926
- parentNode.insertBefore(toInsertNode(startNode, endNode), referenceNode);
927
- }
928
- function toInsertNode(startNode, endNode) {
929
- if (startNode === endNode) return startNode;
930
- let parent = new DocumentFragment(), stop = endNode.nextSibling;
931
- for (; startNode !== stop;) {
932
- let next = startNode.nextSibling;
933
- parent.appendChild(startNode), startNode = next;
934
- }
935
- return parent;
936
- }
937
- //#endregion
938
937
  //#region src/dom/control-flow.ts
939
938
  function _await_promise(nodeAccessor, params) {
940
939
  nodeAccessor = decodeAccessor(nodeAccessor);
@@ -1239,7 +1238,7 @@ function _enable_catch() {
1239
1238
  //#region src/dom/abort-signal.ts
1240
1239
  function $signalReset(scope, id) {
1241
1240
  let ctrl = scope.A?.[id];
1242
- ctrl && (queueEffect(ctrl, abort), scope.A[id] = void 0);
1241
+ ctrl && (scope.A[id] = void 0, rendering ? queueEffect(ctrl, abort) : abort(ctrl));
1243
1242
  }
1244
1243
  function $signal(scope, id) {
1245
1244
  return scope.F && (scope.F.B ||= /* @__PURE__ */ new Set()).add(scope), ((scope.A ||= {})[id] ||= new AbortController()).signal;
@@ -1285,10 +1284,10 @@ function mount(input = {}, reference, position) {
1285
1284
  set value(newValue) {
1286
1285
  _var_change(branch, newValue);
1287
1286
  },
1288
- update(newInput) {
1289
- args && runEffects(prepareEffects(() => {
1287
+ update(newInput = {}) {
1288
+ args && (newInput.$global && ({$global, ...newInput} = newInput), runEffects(prepareEffects(() => {
1290
1289
  args(branch, newInput);
1291
- }));
1290
+ })));
1292
1291
  },
1293
1292
  destroy() {
1294
1293
  removeAndDestroyBranch(branch);
package/dist/html.js CHANGED
@@ -957,11 +957,15 @@ function writeGenerator(state, iter, ref) {
957
957
  needsId ||= isDedupedMember(value), yields.push(value);
958
958
  }
959
959
  if (returnValue === void 0 && !yields.length) return state.buf.push("(function*(){})()"), !0;
960
- if (state.buf.push(returnValue === void 0 ? "(function*(a){yield*a})(" : "(function*(a,r){yield*a;return r})("), needsId) {
960
+ let heldReturn = returnValue !== void 0 && isAncestorMember(state, ref, returnValue);
961
+ if (state.buf.push(returnValue === void 0 ? "(function*(a){yield*a})(" : heldReturn ? "(function*(a,r){yield*a;return r.v})(" : "(function*(a,r){yield*a;return r})("), needsId) {
961
962
  let arrayRef = new Reference(ref, null, state.flush, null, nextRefAccess(state));
962
963
  state.buf.push(arrayRef.id + "="), writeArray(state, yields, arrayRef);
963
964
  } else writeArray(state, yields, new Reference(ref, null, state.flush, state.buf.length));
964
- if (returnValue !== void 0) {
965
+ if (heldReturn) {
966
+ let holder = new Reference(ref, null, state.flush, null, nextRefAccess(state));
967
+ state.buf.push("," + holder.id + "={}"), writeProp(state, returnValue, holder, "v");
968
+ } else if (returnValue !== void 0) {
965
969
  let sepIndex = state.buf.push(",") - 1;
966
970
  if (writeProp(state, returnValue, ref, "") && isDedupedMember(returnValue)) {
967
971
  let retRef = typeof returnValue == "string" ? state.strs.get(returnValue) : state.refs.get(returnValue);
@@ -1820,7 +1824,8 @@ function _attr_textarea_value(scopeId, nodeAccessor, value, valueChange, seriali
1820
1824
  return valueChange && writeControlledScope(2, scopeId, nodeAccessor, void 0, valueChange, serializeType), _textarea_value(value);
1821
1825
  }
1822
1826
  function _textarea_value(value) {
1823
- return _escape(normalizeStrAttrValue(value));
1827
+ let escaped = _escape(normalizeStrAttrValue(value));
1828
+ return escaped[0] === "\n" || escaped[0] === "\r" ? "\n" + escaped : escaped;
1824
1829
  }
1825
1830
  function _attr_input_value(scopeId, nodeAccessor, value, valueChange, serializeType) {
1826
1831
  return valueChange && writeControlledScope(2, scopeId, nodeAccessor, void 0, valueChange, serializeType), _attr("value", value);
package/dist/html.mjs CHANGED
@@ -956,11 +956,15 @@ function writeGenerator(state, iter, ref) {
956
956
  needsId ||= isDedupedMember(value), yields.push(value);
957
957
  }
958
958
  if (returnValue === void 0 && !yields.length) return state.buf.push("(function*(){})()"), !0;
959
- if (state.buf.push(returnValue === void 0 ? "(function*(a){yield*a})(" : "(function*(a,r){yield*a;return r})("), needsId) {
959
+ let heldReturn = returnValue !== void 0 && isAncestorMember(state, ref, returnValue);
960
+ if (state.buf.push(returnValue === void 0 ? "(function*(a){yield*a})(" : heldReturn ? "(function*(a,r){yield*a;return r.v})(" : "(function*(a,r){yield*a;return r})("), needsId) {
960
961
  let arrayRef = new Reference(ref, null, state.flush, null, nextRefAccess(state));
961
962
  state.buf.push(arrayRef.id + "="), writeArray(state, yields, arrayRef);
962
963
  } else writeArray(state, yields, new Reference(ref, null, state.flush, state.buf.length));
963
- if (returnValue !== void 0) {
964
+ if (heldReturn) {
965
+ let holder = new Reference(ref, null, state.flush, null, nextRefAccess(state));
966
+ state.buf.push("," + holder.id + "={}"), writeProp(state, returnValue, holder, "v");
967
+ } else if (returnValue !== void 0) {
964
968
  let sepIndex = state.buf.push(",") - 1;
965
969
  if (writeProp(state, returnValue, ref, "") && isDedupedMember(returnValue)) {
966
970
  let retRef = typeof returnValue == "string" ? state.strs.get(returnValue) : state.refs.get(returnValue);
@@ -1819,7 +1823,8 @@ function _attr_textarea_value(scopeId, nodeAccessor, value, valueChange, seriali
1819
1823
  return valueChange && writeControlledScope(2, scopeId, nodeAccessor, void 0, valueChange, serializeType), _textarea_value(value);
1820
1824
  }
1821
1825
  function _textarea_value(value) {
1822
- return _escape(normalizeStrAttrValue(value));
1826
+ let escaped = _escape(normalizeStrAttrValue(value));
1827
+ return escaped[0] === "\n" || escaped[0] === "\r" ? "\n" + escaped : escaped;
1823
1828
  }
1824
1829
  function _attr_input_value(scopeId, nodeAccessor, value, valueChange, serializeType) {
1825
1830
  return valueChange && writeControlledScope(2, scopeId, nodeAccessor, void 0, valueChange, serializeType), _attr("value", value);