marko 6.0.40 → 6.0.42

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
@@ -21,6 +21,7 @@ __export(dom_exports, {
21
21
  attrTag: () => attrTag,
22
22
  attrTags: () => attrTags,
23
23
  attrs: () => attrs,
24
+ attrsAndContent: () => attrsAndContent,
24
25
  attrsEvents: () => attrsEvents,
25
26
  awaitTag: () => awaitTag,
26
27
  classAttr: () => classAttr,
@@ -58,6 +59,7 @@ __export(dom_exports, {
58
59
  hoist: () => hoist,
59
60
  html: () => html,
60
61
  init: () => init,
62
+ insertContent: () => insertContent,
61
63
  intersection: () => intersection,
62
64
  lifecycle: () => lifecycle,
63
65
  localClosures: () => localClosures,
@@ -69,6 +71,7 @@ __export(dom_exports, {
69
71
  nodeRef: () => nodeRef,
70
72
  on: () => on,
71
73
  partialAttrs: () => partialAttrs,
74
+ partialAttrsAndContent: () => partialAttrsAndContent,
72
75
  props: () => props,
73
76
  register: () => register,
74
77
  registerBoundSignal: () => registerBoundSignal,
@@ -241,11 +244,11 @@ function init(runtimeId = DEFAULT_RUNTIME_ID) {
241
244
  }
242
245
  }
243
246
  },
244
- o(scope) {
247
+ p(scope) {
245
248
  let parentBranchId = scope.g || parentBranchIds.get(scopeId);
246
249
  if (parentBranchId && (scope.k = scopeLookup[parentBranchId]), branchIds.has(scopeId)) {
247
250
  let branch = scope, parentBranch = branch.k;
248
- scope.k = branch, parentBranch && (branch.u = parentBranch, (parentBranch.A ||= /* @__PURE__ */ new Set()).add(branch));
251
+ scope.k = branch, parentBranch && (branch.y = parentBranch, (parentBranch.A ||= /* @__PURE__ */ new Set()).add(branch));
249
252
  }
250
253
  }
251
254
  };
@@ -275,7 +278,7 @@ function init(runtimeId = DEFAULT_RUNTIME_ID) {
275
278
  $global ? typeof scope == "number" ? lastScopeId += scope : (scopeId = ++lastScopeId, scope.$global = $global, scope.l = scopeId, scopeLookup[scopeId] !== scope && (scopeLookup[scopeId] = Object.assign(
276
279
  scope,
277
280
  scopeLookup[scopeId]
278
- )), branches && branches.o(scope)) : ($global = scope || {}, $global.runtimeId = runtimeId, $global.renderId = renderId, $global.p = 1e6);
281
+ )), branches && branches.p(scope)) : ($global = scope || {}, $global.runtimeId = runtimeId, $global.renderId = renderId, $global.q = 1e6);
279
282
  } finally {
280
283
  isResuming = visits.length = resumes.length = 0;
281
284
  }
@@ -500,6 +503,294 @@ function parseHTML(html2, ns) {
500
503
  return parser.innerHTML = html2, parser.content || parser;
501
504
  }
502
505
 
506
+ // src/dom/scope.ts
507
+ function createScope($global, closestBranch) {
508
+ let scope = {
509
+ l: $global.q++,
510
+ t: 1,
511
+ k: closestBranch,
512
+ $global
513
+ };
514
+ return pendingScopes.push(scope), scope;
515
+ }
516
+ function skipScope(scope) {
517
+ return scope.$global.q++;
518
+ }
519
+ function findBranchWithKey(scope, key) {
520
+ let branch = scope.k;
521
+ for (; branch && !branch[key]; )
522
+ branch = branch.y;
523
+ return branch;
524
+ }
525
+ function destroyBranch(branch) {
526
+ branch.y?.A?.delete(branch), destroyNestedBranches(branch);
527
+ }
528
+ function destroyNestedBranches(branch) {
529
+ branch.B = 1, branch.A?.forEach(destroyNestedBranches), branch.K?.forEach((scope) => {
530
+ for (let id in scope.z)
531
+ scope.z[id]?.abort();
532
+ });
533
+ }
534
+ function removeAndDestroyBranch(branch) {
535
+ destroyBranch(branch), removeChildNodes(branch.h, branch.j);
536
+ }
537
+ function insertBranchBefore(branch, parentNode, nextSibling) {
538
+ insertChildNodes(
539
+ parentNode,
540
+ nextSibling,
541
+ branch.h,
542
+ branch.j
543
+ );
544
+ }
545
+ function tempDetachBranch(branch) {
546
+ let fragment = new DocumentFragment();
547
+ fragment.namespaceURI = branch.h.parentNode.namespaceURI, insertChildNodes(fragment, null, branch.h, branch.j);
548
+ }
549
+
550
+ // src/dom/schedule.ts
551
+ var isScheduled, channel;
552
+ function schedule() {
553
+ isScheduled || (isScheduled = 1, queueMicrotask(flushAndWaitFrame));
554
+ }
555
+ function flushAndWaitFrame() {
556
+ run(), requestAnimationFrame(triggerMacroTask);
557
+ }
558
+ function triggerMacroTask() {
559
+ channel || (channel = new MessageChannel(), channel.port1.onmessage = () => {
560
+ isScheduled = 0, run();
561
+ }), channel.port2.postMessage(0);
562
+ }
563
+
564
+ // src/dom/signals.ts
565
+ function state(valueAccessor, fn) {
566
+ if (0)
567
+ var id;
568
+ let valueChangeAccessor = "o" /* TagVariableChange */ + valueAccessor, update = (scope, value2) => {
569
+ scope[valueAccessor] !== value2 && (scope[valueAccessor] = value2, fn(scope, value2));
570
+ };
571
+ return (scope, value2, valueChange) => (rendering ? ((scope[valueChangeAccessor] = valueChange) && scope[valueAccessor] !== value2 || !(valueAccessor in scope)) && (scope[valueAccessor] = value2, fn(scope, value2)) : scope[valueChangeAccessor] ? scope[valueChangeAccessor](value2) : (schedule(), queueRender(
572
+ scope,
573
+ update,
574
+ valueAccessor,
575
+ value2
576
+ )), value2);
577
+ }
578
+ function value(valueAccessor, fn = () => {
579
+ }) {
580
+ return (scope, value2) => {
581
+ (!(valueAccessor in scope) || scope[valueAccessor] !== value2) && (scope[valueAccessor] = value2, fn(scope, value2));
582
+ };
583
+ }
584
+ function intersection(id, fn, defaultPending = 1, scopeIdAccessor = /* @__KEY__ */ "l") {
585
+ return (scope) => {
586
+ scope.t ? scope[id] === void 0 ? scope[id] = defaultPending : --scope[id] || fn(scope) : queueRender(scope, fn, id, 0, scope[scopeIdAccessor]);
587
+ };
588
+ }
589
+ function loopClosure(valueAccessor, ownerLoopNodeAccessor, fn) {
590
+ let childSignal = closure(valueAccessor, fn), loopScopeAccessor = "l" /* LoopScopeArray */ + ownerLoopNodeAccessor, loopScopeMapAccessor = "m" /* LoopScopeMap */ + ownerLoopNodeAccessor, ownerSignal = (ownerScope) => {
591
+ let scopes = ownerScope[loopScopeAccessor] ||= ownerScope[loopScopeMapAccessor] ? [...ownerScope[loopScopeMapAccessor].values()] : [], [firstScope] = scopes;
592
+ firstScope && queueRender(
593
+ ownerScope,
594
+ () => {
595
+ for (let scope of scopes)
596
+ !scope.t && !scope.B && childSignal(scope);
597
+ },
598
+ -1,
599
+ 0,
600
+ firstScope.l
601
+ );
602
+ };
603
+ return ownerSignal._ = childSignal, ownerSignal;
604
+ }
605
+ function conditionalClosure(valueAccessor, ownerConditionalNodeAccessor, branch, fn) {
606
+ let childSignal = closure(valueAccessor, fn), scopeAccessor = "d" /* ConditionalScope */ + ownerConditionalNodeAccessor, branchAccessor = "c" /* ConditionalRenderer */ + ownerConditionalNodeAccessor, ownerSignal = (scope) => {
607
+ let ifScope = scope[scopeAccessor];
608
+ ifScope && !ifScope.t && scope[branchAccessor] === branch && queueRender(ifScope, childSignal, -1);
609
+ };
610
+ return ownerSignal._ = childSignal, ownerSignal;
611
+ }
612
+ function subscribeToScopeSet(ownerScope, accessor, scope) {
613
+ let subscribers = ownerScope[accessor] ||= /* @__PURE__ */ new Set();
614
+ subscribers.has(scope) || (subscribers.add(scope), getAbortSignal(scope, -1).addEventListener(
615
+ "abort",
616
+ () => ownerScope[accessor].delete(scope)
617
+ ));
618
+ }
619
+ function dynamicClosure(...closureSignals) {
620
+ let [{ E: ___scopeInstancesAccessor, F: ___signalIndexAccessor }] = closureSignals;
621
+ for (let i = closureSignals.length; i--; )
622
+ closureSignals[i].L = i;
623
+ return (scope) => {
624
+ if (scope[___scopeInstancesAccessor])
625
+ for (let childScope of scope[___scopeInstancesAccessor])
626
+ childScope.t || queueRender(
627
+ childScope,
628
+ closureSignals[childScope[___signalIndexAccessor]],
629
+ -1
630
+ );
631
+ };
632
+ }
633
+ function dynamicClosureRead(valueAccessor, fn, getOwnerScope) {
634
+ let childSignal = closure(valueAccessor, fn, getOwnerScope), closureSignal = (scope) => {
635
+ scope[closureSignal.F] = closureSignal.L, childSignal(scope), subscribeToScopeSet(
636
+ getOwnerScope ? getOwnerScope(scope) : scope._,
637
+ closureSignal.E,
638
+ scope
639
+ );
640
+ };
641
+ return closureSignal.E = "a" /* ClosureScopes */ + valueAccessor, closureSignal.F = "b" /* ClosureSignalIndex */ + valueAccessor, closureSignal;
642
+ }
643
+ function closure(valueAccessor, fn, getOwnerScope) {
644
+ return (scope) => {
645
+ fn(
646
+ scope,
647
+ (getOwnerScope ? getOwnerScope(scope) : scope._)[valueAccessor]
648
+ );
649
+ };
650
+ }
651
+ function setTagVar(scope, childAccessor, tagVarSignal2) {
652
+ scope[childAccessor].e = (value2) => tagVarSignal2(scope, value2);
653
+ }
654
+ var tagVarSignal = (scope, value2) => scope.e?.(value2);
655
+ function setTagVarChange(scope, changeHandler) {
656
+ scope.f = changeHandler;
657
+ }
658
+ var tagVarSignalChange = (scope, value2) => scope.f?.(value2), tagIdsByGlobal = /* @__PURE__ */ new WeakMap();
659
+ function nextTagId({ $global }) {
660
+ let id = tagIdsByGlobal.get($global) || 0;
661
+ return tagIdsByGlobal.set($global, id + 1), "c" + $global.runtimeId + $global.renderId + id.toString(36);
662
+ }
663
+ function effect(id, fn) {
664
+ return register(id, fn), (scope) => {
665
+ queueEffect(scope, fn);
666
+ };
667
+ }
668
+ function* traverseAllHoisted(scope, path, curIndex = path.length - 1) {
669
+ if (scope)
670
+ if (Symbol.iterator in scope)
671
+ for (let s of scope instanceof Map ? scope.values() : scope)
672
+ yield* traverseAllHoisted(s, path, curIndex);
673
+ else curIndex ? yield* traverseAllHoisted(scope[path[curIndex]], path, curIndex - 1) : yield scope[path[0]];
674
+ }
675
+ function hoist(...path) {
676
+ return (scope) => {
677
+ let getOne = (...args) => iterator().next().value(...args), iterator = getOne[Symbol.iterator] = () => traverseAllHoisted(scope, path);
678
+ return getOne;
679
+ };
680
+ }
681
+
682
+ // src/dom/walker.ts
683
+ var walker = /* @__PURE__ */ document.createTreeWalker(document);
684
+ function walk(startNode, walkCodes, branch) {
685
+ walker.currentNode = startNode, walkInternal(0, walkCodes, branch);
686
+ }
687
+ function walkInternal(currentWalkIndex, walkCodes, scope) {
688
+ let value2, storedMultiplier = 0, currentMultiplier = 0, currentScopeIndex = 0;
689
+ for (; currentWalkIndex < walkCodes.length; )
690
+ if (value2 = walkCodes.charCodeAt(currentWalkIndex++), currentMultiplier = storedMultiplier, storedMultiplier = 0, value2 === 32 /* Get */) {
691
+ let node = walker.currentNode;
692
+ scope[currentScopeIndex] = node, scope["j" /* Getter */ + currentScopeIndex++] = () => node;
693
+ } else if (value2 === 37 /* Replace */ || value2 === 49 /* DynamicTagWithVar */)
694
+ walker.currentNode.replaceWith(
695
+ walker.currentNode = scope[currentScopeIndex++] = new Text()
696
+ ), value2 === 49 /* DynamicTagWithVar */ && (scope[currentScopeIndex++] = skipScope(scope));
697
+ else {
698
+ if (value2 === 38 /* EndChild */)
699
+ return currentWalkIndex;
700
+ if (value2 === 47 /* BeginChild */ || value2 === 48 /* BeginChildWithVar */)
701
+ currentWalkIndex = walkInternal(
702
+ currentWalkIndex,
703
+ walkCodes,
704
+ scope[currentScopeIndex++] = createScope(scope.$global, scope.k)
705
+ ), value2 === 48 /* BeginChildWithVar */ && (scope[currentScopeIndex++] = skipScope(scope));
706
+ else if (value2 < 92)
707
+ for (value2 = 20 /* Next */ * currentMultiplier + value2 - 67 /* Next */; value2--; )
708
+ walker.nextNode();
709
+ else if (value2 < 107)
710
+ for (value2 = 10 /* Over */ * currentMultiplier + value2 - 97 /* Over */; value2--; )
711
+ walker.nextSibling();
712
+ else if (value2 < 117) {
713
+ for (value2 = 10 /* Out */ * currentMultiplier + value2 - 107 /* Out */; value2--; )
714
+ walker.parentNode();
715
+ walker.nextSibling();
716
+ } else
717
+ storedMultiplier = currentMultiplier * 10 /* Multiplier */ + value2 - 117 /* Multiplier */;
718
+ }
719
+ }
720
+
721
+ // src/dom/renderer.ts
722
+ function createBranch($global, renderer, parentScope, parentNode) {
723
+ let branch = createScope($global), parentBranch = parentScope?.k;
724
+ return branch._ = renderer.u || parentScope, branch.k = branch, parentBranch && (branch.y = parentBranch, (parentBranch.A ||= /* @__PURE__ */ new Set()).add(branch)), renderer.C?.(
725
+ branch,
726
+ parentNode.namespaceURI
727
+ ), branch;
728
+ }
729
+ function createAndSetupBranch($global, renderer, parentScope, parentNode) {
730
+ return setupBranch(
731
+ renderer,
732
+ createBranch($global, renderer, parentScope, parentNode)
733
+ );
734
+ }
735
+ function setupBranch(renderer, branch) {
736
+ return renderer.D && queueRender(branch, renderer.D, -1), branch;
737
+ }
738
+ function createContent(id, template, walks, setup, params, dynamicScopesAccessor) {
739
+ walks = walks ? walks.replace(/[^\0-1]+$/, "") : "", setup = setup ? setup._ || setup : void 0, params ||= void 0;
740
+ let clone = template ? (branch, ns) => {
741
+ ((cloneCache[ns] ||= {})[template] ||= createCloneableHTML(
742
+ template,
743
+ ns
744
+ ))(branch, walks);
745
+ } : (branch) => {
746
+ walk(
747
+ branch.h = branch.j = new Text(),
748
+ walks,
749
+ branch
750
+ );
751
+ };
752
+ return (owner) => ({
753
+ l: id,
754
+ C: clone,
755
+ u: owner,
756
+ D: setup,
757
+ m: params,
758
+ n: dynamicScopesAccessor
759
+ });
760
+ }
761
+ function registerContent(id, template, walks, setup, params, dynamicScopesAccessor) {
762
+ return register(
763
+ id,
764
+ createContent(id, template, walks, setup, params, dynamicScopesAccessor)
765
+ );
766
+ }
767
+ function localClosures(renderer, closureFns) {
768
+ let closureSignals = {};
769
+ for (let key in closureFns)
770
+ closureSignals[key] = value(key, closureFns[key]);
771
+ return (owner, closureValues) => {
772
+ let instance = renderer(owner);
773
+ return instance.G = closureSignals, instance.M = closureValues, instance;
774
+ };
775
+ }
776
+ function createRenderer(template, walks, setup, params) {
777
+ return createContent("", template, walks, setup, params)();
778
+ }
779
+ var cloneCache = {};
780
+ function createCloneableHTML(html2, ns) {
781
+ let { firstChild, lastChild } = parseHTML(html2, ns), parent = document.createElementNS(ns, "t");
782
+ return insertChildNodes(parent, null, firstChild, lastChild), firstChild === lastChild && firstChild.nodeType < 8 /* Comment */ ? (branch, walks) => {
783
+ walk(
784
+ branch.h = branch.j = firstChild.cloneNode(!0),
785
+ walks,
786
+ branch
787
+ );
788
+ } : (branch, walks) => {
789
+ let clone = parent.cloneNode(!0);
790
+ walk(clone.firstChild, walks, branch), branch.h = clone.firstChild, branch.j = clone.lastChild;
791
+ };
792
+ }
793
+
503
794
  // src/dom/dom.ts
504
795
  function attr(element, name, value2) {
505
796
  setAttribute(element, name, normalizeAttrValue(value2));
@@ -543,6 +834,9 @@ function attrs(scope, nodeAccessor, nextAttrs) {
543
834
  }
544
835
  attrsInternal(scope, nodeAccessor, nextAttrs);
545
836
  }
837
+ function attrsAndContent(scope, nodeAccessor, nextAttrs) {
838
+ attrs(scope, nodeAccessor, nextAttrs), insertContent(scope, nodeAccessor, nextAttrs?.content);
839
+ }
546
840
  function hasAttrAlias(element, attr2, nextAttrs) {
547
841
  return attr2 === "checked" && element.tagName === "INPUT" && "checkedValue" in nextAttrs;
548
842
  }
@@ -556,6 +850,9 @@ function partialAttrs(scope, nodeAccessor, nextAttrs, skip) {
556
850
  skip[key] || (partial[key] = nextAttrs[key]);
557
851
  attrsInternal(scope, nodeAccessor, partial);
558
852
  }
853
+ function partialAttrsAndContent(scope, nodeAccessor, nextAttrs, skip) {
854
+ partialAttrs(scope, nodeAccessor, nextAttrs, skip), insertContent(scope, nodeAccessor, nextAttrs?.content);
855
+ }
559
856
  function attrsInternal(scope, nodeAccessor, nextAttrs) {
560
857
  let el = scope[nodeAccessor], events, skip;
561
858
  switch (el.tagName) {
@@ -628,6 +925,14 @@ function attrsInternal(scope, nodeAccessor, nextAttrs) {
628
925
  }
629
926
  }
630
927
  }
928
+ function insertContent(scope, nodeAccessor, value2) {
929
+ let content = normalizeClientRender(value2), rendererAccessor = "c" /* ConditionalRenderer */ + nodeAccessor;
930
+ scope[rendererAccessor] !== (scope[rendererAccessor] = content?.l) && (setConditionalRenderer(scope, nodeAccessor, content, createAndSetupBranch), content?.n && subscribeToScopeSet(
931
+ content.u,
932
+ content.n,
933
+ scope["d" /* ConditionalScope */ + nodeAccessor]
934
+ ));
935
+ }
631
936
  function attrsEvents(scope, nodeAccessor) {
632
937
  let el = scope[nodeAccessor], events = scope["i" /* EventAttributes */ + nodeAccessor];
633
938
  switch (scope["f" /* ControlledType */ + nodeAccessor]) {
@@ -662,6 +967,11 @@ function html(scope, value2, accessor) {
662
967
  scope["h" /* DynamicPlaceholderLastChild */ + accessor] = newContent.lastChild
663
968
  ), removeChildNodes(firstChild, lastChild);
664
969
  }
970
+ function normalizeClientRender(value2) {
971
+ let renderer = normalizeDynamicRenderer(value2);
972
+ if (renderer && renderer.l)
973
+ return renderer;
974
+ }
665
975
  function props(scope, nodeIndex, index) {
666
976
  let nextProps = scope[index], prevProps = scope[index + "-"], node = scope[nodeIndex];
667
977
  if (prevProps)
@@ -686,67 +996,23 @@ function lifecycle(scope, index, thisObj) {
686
996
  ).onabort = () => thisObj.onDestroy?.());
687
997
  }
688
998
  function removeChildNodes(startNode, endNode) {
689
- let stop = endNode.nextSibling, current = startNode;
690
- for (; current !== stop; ) {
691
- let next = current.nextSibling;
692
- current.remove(), current = next;
693
- }
694
- }
695
- function insertChildNodes(parentNode, referenceNode, startNode, endNode) {
696
- parentNode.insertBefore(toInsertNode(startNode, endNode), referenceNode);
697
- }
698
- function toInsertNode(startNode, endNode) {
699
- if (startNode === endNode) return startNode;
700
- let parent = new DocumentFragment(), stop = endNode.nextSibling, current = startNode;
701
- for (; current !== stop; ) {
702
- let next = current.nextSibling;
703
- parent.appendChild(current), current = next;
704
- }
705
- return parent;
706
- }
707
-
708
- // src/dom/scope.ts
709
- function createScope($global, closestBranch) {
710
- let scope = {
711
- l: $global.p++,
712
- q: 1,
713
- k: closestBranch,
714
- $global
715
- };
716
- return pendingScopes.push(scope), scope;
717
- }
718
- function skipScope(scope) {
719
- return scope.$global.p++;
720
- }
721
- function findBranchWithKey(scope, key) {
722
- let branch = scope.k;
723
- for (; branch && !branch[key]; )
724
- branch = branch.u;
725
- return branch;
726
- }
727
- function destroyBranch(branch) {
728
- branch.u?.A?.delete(branch), destroyNestedBranches(branch);
729
- }
730
- function destroyNestedBranches(branch) {
731
- branch.B = 1, branch.A?.forEach(destroyNestedBranches), branch.K?.forEach((scope) => {
732
- for (let id in scope.x)
733
- scope.x[id]?.abort();
734
- });
735
- }
736
- function removeAndDestroyBranch(branch) {
737
- destroyBranch(branch), removeChildNodes(branch.h, branch.j);
738
- }
739
- function insertBranchBefore(branch, parentNode, nextSibling) {
740
- insertChildNodes(
741
- parentNode,
742
- nextSibling,
743
- branch.h,
744
- branch.j
745
- );
999
+ let stop = endNode.nextSibling, current = startNode;
1000
+ for (; current !== stop; ) {
1001
+ let next = current.nextSibling;
1002
+ current.remove(), current = next;
1003
+ }
746
1004
  }
747
- function tempDetachBranch(branch) {
748
- let fragment = new DocumentFragment();
749
- fragment.namespaceURI = branch.h.parentNode.namespaceURI, insertChildNodes(fragment, null, branch.h, branch.j);
1005
+ function insertChildNodes(parentNode, referenceNode, startNode, endNode) {
1006
+ parentNode.insertBefore(toInsertNode(startNode, endNode), referenceNode);
1007
+ }
1008
+ function toInsertNode(startNode, endNode) {
1009
+ if (startNode === endNode) return startNode;
1010
+ let parent = new DocumentFragment(), stop = endNode.nextSibling, current = startNode;
1011
+ for (; current !== stop; ) {
1012
+ let next = current.nextSibling;
1013
+ parent.appendChild(current), current = next;
1014
+ }
1015
+ return parent;
750
1016
  }
751
1017
 
752
1018
  // src/dom/reconcile.ts
@@ -824,250 +1090,6 @@ function longestIncreasingSubsequence(a) {
824
1090
  return result;
825
1091
  }
826
1092
 
827
- // src/dom/schedule.ts
828
- var isScheduled, channel;
829
- function schedule() {
830
- isScheduled || (isScheduled = 1, queueMicrotask(flushAndWaitFrame));
831
- }
832
- function flushAndWaitFrame() {
833
- run(), requestAnimationFrame(triggerMacroTask);
834
- }
835
- function triggerMacroTask() {
836
- channel || (channel = new MessageChannel(), channel.port1.onmessage = () => {
837
- isScheduled = 0, run();
838
- }), channel.port2.postMessage(0);
839
- }
840
-
841
- // src/dom/signals.ts
842
- function state(valueAccessor, fn) {
843
- if (0)
844
- var id;
845
- let valueChangeAccessor = "o" /* TagVariableChange */ + valueAccessor, update = (scope, value2) => {
846
- scope[valueAccessor] !== value2 && (scope[valueAccessor] = value2, fn(scope, value2));
847
- };
848
- return (scope, value2, valueChange) => (rendering ? ((scope[valueChangeAccessor] = valueChange) && scope[valueAccessor] !== value2 || !(valueAccessor in scope)) && (scope[valueAccessor] = value2, fn(scope, value2)) : scope[valueChangeAccessor] ? scope[valueChangeAccessor](value2) : (schedule(), queueRender(
849
- scope,
850
- update,
851
- valueAccessor,
852
- value2
853
- )), value2);
854
- }
855
- function value(valueAccessor, fn = () => {
856
- }) {
857
- return (scope, value2) => {
858
- (!(valueAccessor in scope) || scope[valueAccessor] !== value2) && (scope[valueAccessor] = value2, fn(scope, value2));
859
- };
860
- }
861
- function intersection(id, fn, defaultPending = 1, scopeIdAccessor = /* @__KEY__ */ "l") {
862
- return (scope) => {
863
- scope.q ? scope[id] === void 0 ? scope[id] = defaultPending : --scope[id] || fn(scope) : queueRender(scope, fn, id, 0, scope[scopeIdAccessor]);
864
- };
865
- }
866
- function loopClosure(valueAccessor, ownerLoopNodeAccessor, fn) {
867
- let childSignal = closure(valueAccessor, fn), loopScopeAccessor = "l" /* LoopScopeArray */ + ownerLoopNodeAccessor, loopScopeMapAccessor = "m" /* LoopScopeMap */ + ownerLoopNodeAccessor, ownerSignal = (ownerScope) => {
868
- let scopes = ownerScope[loopScopeAccessor] ||= ownerScope[loopScopeMapAccessor] ? [...ownerScope[loopScopeMapAccessor].values()] : [], [firstScope] = scopes;
869
- firstScope && queueRender(
870
- ownerScope,
871
- () => {
872
- for (let scope of scopes)
873
- !scope.q && !scope.B && childSignal(scope);
874
- },
875
- -1,
876
- 0,
877
- firstScope.l
878
- );
879
- };
880
- return ownerSignal._ = childSignal, ownerSignal;
881
- }
882
- function conditionalClosure(valueAccessor, ownerConditionalNodeAccessor, branch, fn) {
883
- let childSignal = closure(valueAccessor, fn), scopeAccessor = "d" /* ConditionalScope */ + ownerConditionalNodeAccessor, branchAccessor = "c" /* ConditionalRenderer */ + ownerConditionalNodeAccessor, ownerSignal = (scope) => {
884
- let ifScope = scope[scopeAccessor];
885
- ifScope && !ifScope.q && scope[branchAccessor] === branch && queueRender(ifScope, childSignal, -1);
886
- };
887
- return ownerSignal._ = childSignal, ownerSignal;
888
- }
889
- function subscribeToScopeSet(ownerScope, accessor, scope) {
890
- let subscribers = ownerScope[accessor] ||= /* @__PURE__ */ new Set();
891
- subscribers.has(scope) || (subscribers.add(scope), getAbortSignal(scope, -1).addEventListener(
892
- "abort",
893
- () => ownerScope[accessor].delete(scope)
894
- ));
895
- }
896
- function dynamicClosure(...closureSignals) {
897
- let [{ E: ___scopeInstancesAccessor, F: ___signalIndexAccessor }] = closureSignals;
898
- for (let i = closureSignals.length; i--; )
899
- closureSignals[i].L = i;
900
- return (scope) => {
901
- if (scope[___scopeInstancesAccessor])
902
- for (let childScope of scope[___scopeInstancesAccessor])
903
- childScope.q || queueRender(
904
- childScope,
905
- closureSignals[childScope[___signalIndexAccessor]],
906
- -1
907
- );
908
- };
909
- }
910
- function dynamicClosureRead(valueAccessor, fn, getOwnerScope) {
911
- let childSignal = closure(valueAccessor, fn, getOwnerScope), closureSignal = (scope) => {
912
- scope[closureSignal.F] = closureSignal.L, childSignal(scope), subscribeToScopeSet(
913
- getOwnerScope ? getOwnerScope(scope) : scope._,
914
- closureSignal.E,
915
- scope
916
- );
917
- };
918
- return closureSignal.E = "a" /* ClosureScopes */ + valueAccessor, closureSignal.F = "b" /* ClosureSignalIndex */ + valueAccessor, closureSignal;
919
- }
920
- function closure(valueAccessor, fn, getOwnerScope) {
921
- return (scope) => {
922
- fn(
923
- scope,
924
- (getOwnerScope ? getOwnerScope(scope) : scope._)[valueAccessor]
925
- );
926
- };
927
- }
928
- function setTagVar(scope, childAccessor, tagVarSignal2) {
929
- scope[childAccessor].e = (value2) => tagVarSignal2(scope, value2);
930
- }
931
- var tagVarSignal = (scope, value2) => scope.e?.(value2);
932
- function setTagVarChange(scope, changeHandler) {
933
- scope.f = changeHandler;
934
- }
935
- var tagVarSignalChange = (scope, value2) => scope.f?.(value2), tagIdsByGlobal = /* @__PURE__ */ new WeakMap();
936
- function nextTagId({ $global }) {
937
- let id = tagIdsByGlobal.get($global) || 0;
938
- return tagIdsByGlobal.set($global, id + 1), "c" + $global.runtimeId + $global.renderId + id.toString(36);
939
- }
940
- function effect(id, fn) {
941
- return register(id, fn), (scope) => {
942
- queueEffect(scope, fn);
943
- };
944
- }
945
- function* traverseAllHoisted(scope, path, curIndex = path.length - 1) {
946
- if (scope)
947
- if (Symbol.iterator in scope)
948
- for (let s of scope instanceof Map ? scope.values() : scope)
949
- yield* traverseAllHoisted(s, path, curIndex);
950
- else curIndex ? yield* traverseAllHoisted(scope[path[curIndex]], path, curIndex - 1) : yield scope[path[0]];
951
- }
952
- function hoist(...path) {
953
- return (scope) => {
954
- let getOne = (...args) => iterator().next().value(...args), iterator = getOne[Symbol.iterator] = () => traverseAllHoisted(scope, path);
955
- return getOne;
956
- };
957
- }
958
-
959
- // src/dom/walker.ts
960
- var walker = /* @__PURE__ */ document.createTreeWalker(document);
961
- function walk(startNode, walkCodes, branch) {
962
- walker.currentNode = startNode, walkInternal(0, walkCodes, branch);
963
- }
964
- function walkInternal(currentWalkIndex, walkCodes, scope) {
965
- let value2, storedMultiplier = 0, currentMultiplier = 0, currentScopeIndex = 0;
966
- for (; currentWalkIndex < walkCodes.length; )
967
- if (value2 = walkCodes.charCodeAt(currentWalkIndex++), currentMultiplier = storedMultiplier, storedMultiplier = 0, value2 === 32 /* Get */) {
968
- let node = walker.currentNode;
969
- scope[currentScopeIndex] = node, scope["j" /* Getter */ + currentScopeIndex++] = () => node;
970
- } else if (value2 === 37 /* Replace */ || value2 === 49 /* DynamicTagWithVar */)
971
- walker.currentNode.replaceWith(
972
- walker.currentNode = scope[currentScopeIndex++] = new Text()
973
- ), value2 === 49 /* DynamicTagWithVar */ && (scope[currentScopeIndex++] = skipScope(scope));
974
- else {
975
- if (value2 === 38 /* EndChild */)
976
- return currentWalkIndex;
977
- if (value2 === 47 /* BeginChild */ || value2 === 48 /* BeginChildWithVar */)
978
- currentWalkIndex = walkInternal(
979
- currentWalkIndex,
980
- walkCodes,
981
- scope[currentScopeIndex++] = createScope(scope.$global, scope.k)
982
- ), value2 === 48 /* BeginChildWithVar */ && (scope[currentScopeIndex++] = skipScope(scope));
983
- else if (value2 < 92)
984
- for (value2 = 20 /* Next */ * currentMultiplier + value2 - 67 /* Next */; value2--; )
985
- walker.nextNode();
986
- else if (value2 < 107)
987
- for (value2 = 10 /* Over */ * currentMultiplier + value2 - 97 /* Over */; value2--; )
988
- walker.nextSibling();
989
- else if (value2 < 117) {
990
- for (value2 = 10 /* Out */ * currentMultiplier + value2 - 107 /* Out */; value2--; )
991
- walker.parentNode();
992
- walker.nextSibling();
993
- } else
994
- storedMultiplier = currentMultiplier * 10 /* Multiplier */ + value2 - 117 /* Multiplier */;
995
- }
996
- }
997
-
998
- // src/dom/renderer.ts
999
- function createBranch($global, renderer, parentScope, parentNode) {
1000
- let branch = createScope($global), parentBranch = parentScope?.k;
1001
- return branch._ = renderer.y || parentScope, branch.k = branch, parentBranch && (branch.u = parentBranch, (parentBranch.A ||= /* @__PURE__ */ new Set()).add(branch)), renderer.C?.(
1002
- branch,
1003
- parentNode.namespaceURI
1004
- ), branch;
1005
- }
1006
- function createAndSetupBranch($global, renderer, parentScope, parentNode) {
1007
- return setupBranch(
1008
- renderer,
1009
- createBranch($global, renderer, parentScope, parentNode)
1010
- );
1011
- }
1012
- function setupBranch(renderer, branch) {
1013
- return renderer.D && queueRender(branch, renderer.D, -1), branch;
1014
- }
1015
- function createContent(id, template, walks, setup, params, dynamicScopesAccessor) {
1016
- walks = walks ? walks.replace(/[^\0-1]+$/, "") : "", setup = setup ? setup._ || setup : void 0, params ||= void 0;
1017
- let clone = template ? (branch, ns) => {
1018
- ((cloneCache[ns] ||= {})[template] ||= createCloneableHTML(
1019
- template,
1020
- ns
1021
- ))(branch, walks);
1022
- } : (branch) => {
1023
- walk(
1024
- branch.h = branch.j = new Text(),
1025
- walks,
1026
- branch
1027
- );
1028
- };
1029
- return (owner) => ({
1030
- l: id,
1031
- C: clone,
1032
- y: owner,
1033
- D: setup,
1034
- m: params,
1035
- z: dynamicScopesAccessor
1036
- });
1037
- }
1038
- function registerContent(id, template, walks, setup, params, dynamicScopesAccessor) {
1039
- return register(
1040
- id,
1041
- createContent(id, template, walks, setup, params, dynamicScopesAccessor)
1042
- );
1043
- }
1044
- function localClosures(renderer, closureFns) {
1045
- let closureSignals = {};
1046
- for (let key in closureFns)
1047
- closureSignals[key] = value(key, closureFns[key]);
1048
- return (owner, closureValues) => {
1049
- let instance = renderer(owner);
1050
- return instance.G = closureSignals, instance.M = closureValues, instance;
1051
- };
1052
- }
1053
- function createRenderer(template, walks, setup, params) {
1054
- return createContent("", template, walks, setup, params)();
1055
- }
1056
- var cloneCache = {};
1057
- function createCloneableHTML(html2, ns) {
1058
- let { firstChild, lastChild } = parseHTML(html2, ns), parent = document.createElementNS(ns, "t");
1059
- return insertChildNodes(parent, null, firstChild, lastChild), firstChild === lastChild && firstChild.nodeType < 8 /* Comment */ ? (branch, walks) => {
1060
- walk(
1061
- branch.h = branch.j = firstChild.cloneNode(!0),
1062
- walks,
1063
- branch
1064
- );
1065
- } : (branch, walks) => {
1066
- let clone = parent.cloneNode(!0);
1067
- walk(clone.firstChild, walks, branch), branch.h = clone.firstChild, branch.j = clone.lastChild;
1068
- };
1069
- }
1070
-
1071
1093
  // src/dom/control-flow.ts
1072
1094
  function awaitTag(nodeAccessor, renderer) {
1073
1095
  let promiseAccessor = "n" /* Promise */ + nodeAccessor, branchAccessor = "d" /* ConditionalScope */ + nodeAccessor;
@@ -1076,8 +1098,8 @@ function awaitTag(nodeAccessor, renderer) {
1076
1098
  scope,
1077
1099
  "d" /* PlaceholderContent */
1078
1100
  ), awaitBranch = scope[branchAccessor];
1079
- tryWithPlaceholder ? (placeholderShown.add(pendingEffects), !scope[promiseAccessor] && (tryWithPlaceholder.n = (tryWithPlaceholder.n || 0) + 1) === 1 && requestAnimationFrame(
1080
- () => tryWithPlaceholder.n && runEffects(
1101
+ tryWithPlaceholder ? (placeholderShown.add(pendingEffects), !scope[promiseAccessor] && (tryWithPlaceholder.o = (tryWithPlaceholder.o || 0) + 1) === 1 && requestAnimationFrame(
1102
+ () => tryWithPlaceholder.o && runEffects(
1081
1103
  prepareEffects(
1082
1104
  () => queueRender(
1083
1105
  tryWithPlaceholder,
@@ -1117,7 +1139,7 @@ function awaitTag(nodeAccessor, renderer) {
1117
1139
  ),
1118
1140
  referenceNode.parentNode,
1119
1141
  referenceNode
1120
- ), referenceNode.remove()), renderer.m?.(awaitBranch, [data2]), tryWithPlaceholder && (placeholderShown.add(pendingEffects), !--tryWithPlaceholder.n)) {
1142
+ ), referenceNode.remove()), renderer.m?.(awaitBranch, [data2]), tryWithPlaceholder && (placeholderShown.add(pendingEffects), !--tryWithPlaceholder.o)) {
1121
1143
  let placeholderBranch = tryWithPlaceholder.c;
1122
1144
  tryWithPlaceholder.c = 0, placeholderBranch && (placeholderBranch.h.parentNode.insertBefore(
1123
1145
  tryWithPlaceholder.h.parentNode,
@@ -1129,7 +1151,7 @@ function awaitTag(nodeAccessor, renderer) {
1129
1151
  ));
1130
1152
  },
1131
1153
  (error) => {
1132
- thisPromise === scope[promiseAccessor] && (tryWithPlaceholder && (tryWithPlaceholder.n = 0), scope[promiseAccessor] = 0, schedule(), queueRender(scope, renderCatch, -1, error));
1154
+ thisPromise === scope[promiseAccessor] && (tryWithPlaceholder && (tryWithPlaceholder.o = 0), scope[promiseAccessor] = 0, schedule(), queueRender(scope, renderCatch, -1, error));
1133
1155
  }
1134
1156
  );
1135
1157
  };
@@ -1153,7 +1175,7 @@ function renderCatch(scope, error) {
1153
1175
  let tryWithCatch = findBranchWithKey(scope, "b" /* CatchContent */);
1154
1176
  if (tryWithCatch) {
1155
1177
  let owner = tryWithCatch._, placeholderBranch = tryWithCatch.c;
1156
- placeholderBranch && (tryWithCatch.n = 0, owner["d" /* ConditionalScope */ + tryWithCatch.a] = placeholderBranch, destroyBranch(tryWithCatch)), caughtError.add(pendingEffects), setConditionalRenderer(
1178
+ placeholderBranch && (tryWithCatch.o = 0, owner["d" /* ConditionalScope */ + tryWithCatch.a] = placeholderBranch, destroyBranch(tryWithCatch)), caughtError.add(pendingEffects), setConditionalRenderer(
1157
1179
  owner,
1158
1180
  tryWithCatch.a,
1159
1181
  tryWithCatch.b,
@@ -1197,15 +1219,15 @@ var dynamicTag = function(nodeAccessor, getContent, getTagVar, inputIsArgs) {
1197
1219
  0,
1198
1220
  content,
1199
1221
  createAndSetupBranch
1200
- ), content.z && subscribeToScopeSet(
1201
- content.y,
1202
- content.z,
1222
+ ), content.n && subscribeToScopeSet(
1223
+ content.u,
1224
+ content.n,
1203
1225
  scope[childScopeAccessor]["d" /* ConditionalScope */ + 0]
1204
1226
  );
1205
1227
  }
1206
- } else normalizedRenderer?.z && subscribeToScopeSet(
1207
- normalizedRenderer.y,
1208
- normalizedRenderer.z,
1228
+ } else normalizedRenderer?.n && subscribeToScopeSet(
1229
+ normalizedRenderer.u,
1230
+ normalizedRenderer.n,
1209
1231
  scope[childScopeAccessor]
1210
1232
  );
1211
1233
  if (normalizedRenderer) {
@@ -1310,14 +1332,14 @@ function queueRender(scope, signal, signalKey, value2, scopeKey = scope.l) {
1310
1332
  existingRender.I = value2;
1311
1333
  else {
1312
1334
  let render = {
1313
- t: key,
1314
- o: scope,
1335
+ x: key,
1336
+ p: scope,
1315
1337
  N: signal,
1316
1338
  I: value2
1317
1339
  }, i = pendingRenders.push(render) - 1;
1318
1340
  for (; i; ) {
1319
1341
  let parentIndex = i - 1 >> 1, parent = pendingRenders[parentIndex];
1320
- if (key - parent.t >= 0) break;
1342
+ if (key - parent.x >= 0) break;
1321
1343
  pendingRenders[i] = parent, i = parentIndex;
1322
1344
  }
1323
1345
  signalKey >= 0 && pendingRendersLookup.set(key, render), pendingRenders[i] = render;
@@ -1356,29 +1378,29 @@ function runRenders() {
1356
1378
  for (; pendingRenders.length; ) {
1357
1379
  let render = pendingRenders[0], item = pendingRenders.pop();
1358
1380
  if (render !== item) {
1359
- let i = 0, mid = pendingRenders.length >> 1, key = (pendingRenders[0] = item).t;
1381
+ let i = 0, mid = pendingRenders.length >> 1, key = (pendingRenders[0] = item).x;
1360
1382
  for (; i < mid; ) {
1361
1383
  let bestChild = (i << 1) + 1, right = bestChild + 1;
1362
- if (right < pendingRenders.length && pendingRenders[right].t - pendingRenders[bestChild].t < 0 && (bestChild = right), pendingRenders[bestChild].t - key >= 0)
1384
+ if (right < pendingRenders.length && pendingRenders[right].x - pendingRenders[bestChild].x < 0 && (bestChild = right), pendingRenders[bestChild].x - key >= 0)
1363
1385
  break;
1364
1386
  pendingRenders[i] = pendingRenders[bestChild], i = bestChild;
1365
1387
  }
1366
1388
  pendingRenders[i] = item;
1367
1389
  }
1368
- render.o.k?.B || runRender(render);
1390
+ render.p.k?.B || runRender(render);
1369
1391
  }
1370
1392
  for (let scope of pendingScopes)
1371
- scope.q = 0;
1393
+ scope.t = 0;
1372
1394
  pendingScopes = [];
1373
1395
  }
1374
- var runRender = (render) => render.N(render.o, render.I), enableCatch = () => {
1396
+ var runRender = (render) => render.N(render.p, render.I), enableCatch = () => {
1375
1397
  enableCatch = () => {
1376
1398
  }, enableBranches();
1377
1399
  let handlePendingTry = (fn, scope, branch) => {
1378
1400
  for (; branch; ) {
1379
- if (branch.n)
1401
+ if (branch.o)
1380
1402
  return (branch.H ||= []).push(fn, scope);
1381
- branch = branch.u;
1403
+ branch = branch.y;
1382
1404
  }
1383
1405
  };
1384
1406
  runEffects = /* @__PURE__ */ ((runEffects2) => (effects, checkPending = placeholderShown.has(effects)) => {
@@ -1392,18 +1414,18 @@ var runRender = (render) => render.N(render.o, render.I), enableCatch = () => {
1392
1414
  try {
1393
1415
  runRender2(render);
1394
1416
  } catch (error) {
1395
- renderCatch(render.o, error);
1417
+ renderCatch(render.p, error);
1396
1418
  }
1397
1419
  })(runRender);
1398
1420
  };
1399
1421
 
1400
1422
  // src/dom/abort-signal.ts
1401
1423
  function resetAbortSignal(scope, id) {
1402
- let ctrl = scope.x?.[id];
1403
- ctrl && (queueEffect(ctrl, abort), scope.x[id] = void 0);
1424
+ let ctrl = scope.z?.[id];
1425
+ ctrl && (queueEffect(ctrl, abort), scope.z[id] = void 0);
1404
1426
  }
1405
1427
  function getAbortSignal(scope, id) {
1406
- return scope.k && (scope.k.K ||= /* @__PURE__ */ new Set()).add(scope), ((scope.x ||= {})[id] ||= new AbortController()).signal;
1428
+ return scope.k && (scope.k.K ||= /* @__PURE__ */ new Set()).add(scope), ((scope.z ||= {})[id] ||= new AbortController()).signal;
1407
1429
  }
1408
1430
  function abort(ctrl) {
1409
1431
  ctrl.abort();
@@ -1465,10 +1487,10 @@ var classIdToBranch = /* @__PURE__ */ new Map(), compat = {
1465
1487
  normalizedInput[key === "renderBody" ? "content" : key] = input[key];
1466
1488
  }
1467
1489
  if (component.effects = prepareEffects(() => {
1468
- branch ? existing = 1 : (out.global.p ||= 0, branch = component.scope = createAndSetupBranch(
1490
+ branch ? existing = 1 : (out.global.q ||= 0, branch = component.scope = createAndSetupBranch(
1469
1491
  out.global,
1470
1492
  renderer,
1471
- renderer.y,
1493
+ renderer.u,
1472
1494
  document.body
1473
1495
  )), renderer.m?.(branch, renderer._ ? args[0] : args);
1474
1496
  }), !existing)
@@ -1490,12 +1512,12 @@ var createTemplate = (id, template, walks, setup, inputSignal) => {
1490
1512
  function mount(input = {}, reference, position) {
1491
1513
  let branch, parentNode = reference, nextSibling = null, { $global } = input;
1492
1514
  switch ($global ? ({ $global, ...input } = input, $global = {
1493
- p: 0,
1515
+ q: 0,
1494
1516
  runtimeId: DEFAULT_RUNTIME_ID,
1495
1517
  renderId: DEFAULT_RENDER_ID,
1496
1518
  ...$global
1497
1519
  }) : $global = {
1498
- p: 0,
1520
+ q: 0,
1499
1521
  runtimeId: DEFAULT_RUNTIME_ID,
1500
1522
  renderId: DEFAULT_RENDER_ID
1501
1523
  }, position) {