marko 6.4.10 → 6.4.11

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.
Files changed (87) hide show
  1. package/dist/common/accessor.d.ts +0 -3
  2. package/dist/common/accessor.debug.d.ts +0 -3
  3. package/dist/common/helpers.d.ts +1 -1
  4. package/dist/common/types.d.ts +4 -3
  5. package/dist/debug/dom/catch.feat.js +1 -1
  6. package/dist/debug/dom/catch.feat.mjs +1 -1
  7. package/dist/debug/dom/controllable-input.feat.js +1 -1
  8. package/dist/debug/dom/controllable-input.feat.mjs +1 -1
  9. package/dist/debug/dom/controllable-open.feat.js +1 -1
  10. package/dist/debug/dom/controllable-open.feat.mjs +1 -1
  11. package/dist/debug/dom/controllable-select.feat.js +1 -1
  12. package/dist/debug/dom/controllable-select.feat.mjs +1 -1
  13. package/dist/debug/dom/controllable-textarea.feat.js +1 -1
  14. package/dist/debug/dom/controllable-textarea.feat.mjs +1 -1
  15. package/dist/debug/dom/controllable.feat.js +1 -1
  16. package/dist/debug/dom/controllable.feat.mjs +1 -1
  17. package/dist/debug/dom/dynamic-tag-script.feat.js +1 -1
  18. package/dist/debug/dom/dynamic-tag-script.feat.mjs +1 -1
  19. package/dist/debug/dom/dynamic-tag-var.feat.js +1 -1
  20. package/dist/debug/dom/dynamic-tag-var.feat.mjs +1 -1
  21. package/dist/debug/dom/lazy.feat.js +1 -1
  22. package/dist/debug/dom/lazy.feat.mjs +1 -1
  23. package/dist/debug/dom/placeholder.feat.js +1 -1
  24. package/dist/debug/dom/placeholder.feat.mjs +1 -1
  25. package/dist/debug/{dom-C1V5vpFs.mjs → dom-DjUZd-9y.mjs} +198 -214
  26. package/dist/debug/{dom-DNB5yq3U.js → dom-mQ5mPBTF.js} +203 -213
  27. package/dist/debug/dom.js +5 -8
  28. package/dist/debug/dom.mjs +5 -9
  29. package/dist/debug/html.js +68 -87
  30. package/dist/debug/html.mjs +68 -87
  31. package/dist/dom/abort-signal.d.ts +1 -1
  32. package/dist/dom/catch.feat.js +3 -3
  33. package/dist/dom/catch.feat.mjs +1 -1
  34. package/dist/dom/control-flow.d.ts +4 -4
  35. package/dist/dom/controllable-input.feat.js +1 -1
  36. package/dist/dom/controllable-input.feat.mjs +1 -1
  37. package/dist/dom/controllable-open.feat.js +1 -1
  38. package/dist/dom/controllable-open.feat.mjs +1 -1
  39. package/dist/dom/controllable-select.feat.js +1 -1
  40. package/dist/dom/controllable-select.feat.mjs +1 -1
  41. package/dist/dom/controllable-textarea.feat.js +1 -1
  42. package/dist/dom/controllable-textarea.feat.mjs +1 -1
  43. package/dist/dom/controllable.feat.js +1 -1
  44. package/dist/dom/controllable.feat.mjs +1 -1
  45. package/dist/dom/dynamic-tag-script.feat.js +2 -2
  46. package/dist/dom/dynamic-tag-script.feat.mjs +1 -1
  47. package/dist/dom/dynamic-tag-var.feat.js +3 -3
  48. package/dist/dom/dynamic-tag-var.feat.mjs +1 -1
  49. package/dist/dom/lazy.feat.js +1 -1
  50. package/dist/dom/lazy.feat.mjs +1 -1
  51. package/dist/dom/load.d.ts +3 -4
  52. package/dist/dom/placeholder.feat.js +1 -1
  53. package/dist/dom/placeholder.feat.mjs +1 -1
  54. package/dist/dom/queue.d.ts +1 -2
  55. package/dist/dom/signals.d.ts +5 -7
  56. package/dist/{dom-C2-Flitp.js → dom-B8j2453O.js} +143 -155
  57. package/dist/{dom-DsHYWMCR.mjs → dom-HEWdZCCb.mjs} +119 -136
  58. package/dist/dom.d.ts +1 -1
  59. package/dist/dom.js +17 -21
  60. package/dist/dom.mjs +5 -9
  61. package/dist/html/assets.d.ts +3 -4
  62. package/dist/html/for.d.ts +0 -1
  63. package/dist/html/writer.d.ts +2 -2
  64. package/dist/html.d.ts +1 -1
  65. package/dist/html.js +60 -72
  66. package/dist/html.mjs +60 -72
  67. package/dist/translator/index.d.ts +0 -1
  68. package/dist/translator/index.js +4629 -4485
  69. package/dist/translator/interop/out-global.d.ts +5 -0
  70. package/dist/translator/util/assert.d.ts +4 -0
  71. package/dist/translator/util/entry-builder.d.ts +1 -1
  72. package/dist/translator/util/finalize-references.d.ts +2 -1
  73. package/dist/translator/util/for-selector.d.ts +1 -1
  74. package/dist/translator/util/known-tag.d.ts +7 -1
  75. package/dist/translator/util/references.d.ts +11 -5
  76. package/dist/translator/util/runtime.d.ts +1 -0
  77. package/dist/translator/util/sections.d.ts +6 -1
  78. package/dist/translator/util/signals.d.ts +2 -1
  79. package/dist/translator/util/style-interpolation.d.ts +1 -1
  80. package/dist/translator/util/tag-name-type.d.ts +1 -0
  81. package/dist/translator/util/visitors.d.ts +1 -1
  82. package/dist/translator/util/write-guard.d.ts +2 -0
  83. package/dist/translator/visitors/program/index.d.ts +0 -4
  84. package/dist/translator/visitors/referenced-identifier.d.ts +3 -1
  85. package/package.json +4 -4
  86. package/dist/common/constants/keyed-scopes-prop.d.ts +0 -4
  87. package/dist/common/constants/keyed-scopes-prop.debug.d.ts +0 -4
@@ -52,8 +52,6 @@ const Changed = "Changed";
52
52
  const ScopesAccessor = "scopesAccessor";
53
53
  const SignalIndexAccessor = "signalIndexAccessor";
54
54
  const Index = "index";
55
- // src/common/constants/keyed-scopes-prop.debug.ts
56
- const PreviousKey = "PreviousKey:";
57
55
  const Scope = "scope";
58
56
  const Signal = "signal";
59
57
  const Value = "value";
@@ -134,7 +132,7 @@ function escapeStyleValue(str) {
134
132
  else if (c === closers[0]) closers = closers.slice(1);
135
133
  return result + closers;
136
134
  }
137
- const toDelimitedString = function toDelimitedString(val, delimiter, stringify) {
135
+ function toDelimitedString(val, delimiter, stringify) {
138
136
  let str = "";
139
137
  let sep = "";
140
138
  let part;
@@ -156,7 +154,7 @@ const toDelimitedString = function toDelimitedString(val, delimiter, stringify)
156
154
  }
157
155
  }
158
156
  return str;
159
- };
157
+ }
160
158
  function isEventHandler(name) {
161
159
  return /^on[A-Z-]/.test(name);
162
160
  }
@@ -435,9 +433,9 @@ function prepareEffects(fn) {
435
433
  }
436
434
  return preparedEffects;
437
435
  }
438
- let runEffects = ((effects) => {
436
+ let runEffects = (effects) => {
439
437
  for (let i = 0; i < effects.length;) effects[i++](effects[i++]);
440
- });
438
+ };
441
439
  let runRender = (render) => {
442
440
  if (!branchesEnabled || render["scope"]["#ClosestBranch"]?.["#Gen"] !== 0) render[Signal](render[Scope], render[Value]);
443
441
  };
@@ -487,7 +485,7 @@ function $signal(scope, id) {
487
485
  return ((scope[AbortControllers] ||= {})[id] ||= new AbortController()).signal;
488
486
  }
489
487
  /** Runs `abort` as a destroyed scope's `$signal` would fire, without creating one. */
490
- function trackAbort(scope, id, abort) {
488
+ function onAbort(scope, id, abort) {
491
489
  abortsEnabled = 1;
492
490
  trackCleanup(scope);
493
491
  (scope[AbortControllers] ||= {})[id] = { abort };
@@ -586,7 +584,7 @@ function skipScope() {
586
584
  return nextScopeId++;
587
585
  }
588
586
  function destroyBranch(branch) {
589
- branch[ParentBranch]?.[BranchScopes]?.delete(branch);
587
+ branch[ParentBranch]?.[BranchScopes].delete(branch);
590
588
  destroyNestedScopes(branch);
591
589
  }
592
590
  function destroyScope(scope) {
@@ -595,11 +593,11 @@ function destroyScope(scope) {
595
593
  cleanupScope(scope);
596
594
  }
597
595
  }
598
- const destroyNestedScopes = function destroyNestedScopes(scope) {
596
+ function destroyNestedScopes(scope) {
599
597
  scope[Gen$1] = 0;
600
598
  scope[BranchScopes]?.forEach(destroyNestedScopes);
601
599
  scope[AbortScopes]?.forEach(cleanupScope);
602
- };
600
+ }
603
601
  function cleanupScope(scope) {
604
602
  if (subscriptionsEnabled) scope[Subscriptions]?.forEach(unsubscribe, scope);
605
603
  if (abortsEnabled) for (const id in scope[AbortControllers]) $signalReset(scope, id);
@@ -691,7 +689,8 @@ function _const(valueAccessor, fn) {
691
689
  }
692
690
  });
693
691
  }
694
- function _or(id, fn, defaultPending = 1, scopeIdAccessor = "#Id") {
692
+ function _or(id, fn, defaultPending = 1, scopeIdAccessor) {
693
+ scopeIdAccessor = scopeIdAccessor ? scopeIdAccessor : "#Id";
695
694
  return (scope) => {
696
695
  if (scope["#Gen"] === runId) {
697
696
  if (~id in scope) {
@@ -700,36 +699,33 @@ function _or(id, fn, defaultPending = 1, scopeIdAccessor = "#Id") {
700
699
  } else queueRender(scope, fn, id, 0, scope[scopeIdAccessor]);
701
700
  };
702
701
  }
703
- function _for_closure(ownerLoopNodeAccessor, fn) {
702
+ function _for_closure(ownerLoopNodeAccessor, fn, id, scopeIdAccessor) {
703
+ scopeIdAccessor = scopeIdAccessor ? scopeIdAccessor : "#Id";
704
704
  const scopeAccessor = BranchScopes$1 + ownerLoopNodeAccessor;
705
- const ownerSignal = (ownerScope) => {
706
- const scopes = toArray(ownerScope[scopeAccessor]);
707
- queueRender(ownerScope, (_) => {
708
- for (const scope of scopes) if (scope["#Gen"] > 0 && scope["#Gen"] < runId) fn(scope);
709
- }, -1);
705
+ const render = (ownerScope) => {
706
+ for (const scope of toArray(ownerScope[scopeAccessor])) if (scope["#Gen"] < runId) fn(scope);
710
707
  };
708
+ const ownerSignal = (ownerScope) => queueRender(ownerScope, render, id, 0, ownerScope[scopeIdAccessor]);
711
709
  ownerSignal._ = (scope) => queueRender(scope, fn, -1);
712
710
  return ownerSignal;
713
711
  }
714
- function _for_selector(ownerLoopNodeAccessor, ownerValueAccessor, fn) {
712
+ function _for_selector(ownerLoopNodeAccessor, ownerValueAccessor, fn, getValueScope) {
715
713
  const scopeAccessor = BranchScopes$1 + ownerLoopNodeAccessor;
716
714
  const mapAccessor = KeyedScopes + ownerLoopNodeAccessor;
717
- const prevKeyProp = `${PreviousKey}${ownerValueAccessor}`;
715
+ const prevKey = Symbol(ownerValueAccessor);
718
716
  const ownerSignal = (ownerScope) => {
719
717
  if (ownerScope["#Gen"] < runId) {
720
- const nextKey = ownerScope[ownerValueAccessor];
721
- queueRender(ownerScope, (_) => {
722
- const map = keyedScopes(ownerScope, scopeAccessor, mapAccessor);
723
- if (map && prevKeyProp in map) {
724
- const prevScope = map.get(map[prevKeyProp]);
725
- const nextScope = map.get(nextKey);
726
- if (prevScope !== nextScope) {
727
- runLiveBranch(prevScope, fn);
728
- runLiveBranch(nextScope, fn);
729
- }
730
- } else for (const scope of toArray(ownerScope[scopeAccessor])) runLiveBranch(scope, fn);
731
- if (map) map[prevKeyProp] = nextKey;
732
- }, -1);
718
+ const nextKey = (getValueScope ? getValueScope(ownerScope) : ownerScope)[ownerValueAccessor];
719
+ const map = keyedScopes(ownerScope, scopeAccessor, mapAccessor);
720
+ if (map && prevKey in ownerScope) {
721
+ const prevScope = map.get(ownerScope[prevKey]);
722
+ const nextScope = map.get(nextKey);
723
+ if (prevScope !== nextScope) {
724
+ queueLiveBranch(prevScope, fn);
725
+ queueLiveBranch(nextScope, fn);
726
+ }
727
+ } else for (const scope of toArray(ownerScope[scopeAccessor])) queueLiveBranch(scope, fn);
728
+ ownerScope[prevKey] = nextKey;
733
729
  }
734
730
  };
735
731
  ownerSignal._ = (scope) => queueRender(scope, fn, -1);
@@ -744,8 +740,8 @@ function keyedScopes(ownerScope, scopeAccessor, mapAccessor) {
744
740
  }
745
741
  return map;
746
742
  }
747
- function runLiveBranch(scope, fn) {
748
- if (scope && scope["#Gen"] > 0 && scope["#Gen"] < runId) fn(scope);
743
+ function queueLiveBranch(scope, fn) {
744
+ if (scope?.["#Gen"] < runId) queueRender(scope, fn, -1);
749
745
  }
750
746
  function _if_closure(ownerConditionalNodeAccessor, branch, fn) {
751
747
  const scopeAccessor = BranchScopes$1 + ownerConditionalNodeAccessor;
@@ -814,9 +810,7 @@ function _id(scope, accessor) {
814
810
  }
815
811
  function _script(id, fn) {
816
812
  _resumed[id] = fn;
817
- return (scope) => {
818
- queueEffect(scope, fn);
819
- };
813
+ return (scope) => queueEffect(scope, fn);
820
814
  }
821
815
  function _global_read($global, key) {
822
816
  if (!(key in $global)) console.error(`\`$global.${key}\` is not serialized to the client, so this read is \`undefined\`. Serialized globals are embedded in the page: add \`${key}\` to \`serializedGlobals\` at the render call only if it holds no secrets; otherwise copy the field the client needs into its own \`$global\` key and serialize that.`);
@@ -856,7 +850,7 @@ function walk(startNode, walkCodes, branch) {
856
850
  currentNode = startNode;
857
851
  walkInternal(0, walkCodes, branch);
858
852
  }
859
- const walkInternal = function walkInternal(currentWalkIndex, walkCodes, scope) {
853
+ function walkInternal(currentWalkIndex, walkCodes, scope) {
860
854
  let value;
861
855
  let currentMultiplier;
862
856
  let storedMultiplier = 0;
@@ -892,7 +886,7 @@ const walkInternal = function walkInternal(currentWalkIndex, walkCodes, scope) {
892
886
  storedMultiplier = currentMultiplier * 10 + value - 117;
893
887
  }
894
888
  }
895
- };
889
+ }
896
890
  function getDebugKey(index, node) {
897
891
  if (typeof node === "string") return `${node}/${index}`;
898
892
  else if (node.nodeType === 3) return `#text/${index}`;
@@ -944,168 +938,166 @@ function init(runtimeId = "M") {
944
938
  }
945
939
  const renders = self[runtimeId];
946
940
  const defineRuntime = (desc) => Object.defineProperty(self, runtimeId, desc);
947
- const initRuntime = (renders) => {
948
- defineRuntime({ value: curRenders = ((renderId) => {
949
- const render = curRenders[renderId] = renders[renderId] || renders(renderId);
950
- const walk = render.w;
951
- const scopeLookup = {};
952
- const pending = [];
953
- const getScope = (id) => scopeLookup[id] || (+id ? initScope(scopeLookup[id] = { ["#Id"]: +id }) : initGlobal());
954
- const initGlobal = (_) => scopeLookup[0] ||= {
955
- runtimeId,
956
- renderId
957
- };
958
- const initScope = (scope) => {
959
- scope[Gen$1] ??= 1;
960
- scope[Global] = initGlobal();
961
- if (branchesEnabled && scope["#ClosestBranchId"]) scope[ClosestBranch] = getScope(scope[ClosestBranchId]);
962
- return scope;
963
- };
964
- const applyScopes = (partials) => {
965
- let scopeId = partials[0];
966
- for (let i = 1; i < partials.length; i++) {
967
- const partial = partials[i];
968
- if (typeof partial === "number") scopeId += partial;
969
- else {
970
- if (scopeId) initScope(Object.assign(scopeLookup[scopeId] ||= (partial["#Id"] = scopeId, partial), partial));
971
- else Object.assign(initGlobal(), partial);
972
- scopeId++;
973
- }
941
+ const initRuntime = (renders) => defineRuntime({ value: curRenders = ((renderId) => {
942
+ const render = curRenders[renderId] = renders[renderId] || renders(renderId);
943
+ const walk = render.w;
944
+ const scopeLookup = {};
945
+ const pending = [];
946
+ const getScope = (id) => scopeLookup[id] || (+id ? initScope(scopeLookup[id] = { ["#Id"]: +id }) : initGlobal());
947
+ const initGlobal = (_) => scopeLookup[0] ||= {
948
+ runtimeId,
949
+ renderId
950
+ };
951
+ const initScope = (scope) => {
952
+ scope[Gen$1] ??= 1;
953
+ scope[Global] = initGlobal();
954
+ if (branchesEnabled && scope["#ClosestBranchId"]) scope[ClosestBranch] = getScope(scope[ClosestBranchId]);
955
+ return scope;
956
+ };
957
+ const applyScopes = (partials) => {
958
+ let scopeId = partials[0];
959
+ for (let i = 1; i < partials.length; i++) {
960
+ const partial = partials[i];
961
+ if (typeof partial === "number") scopeId += partial;
962
+ else {
963
+ if (scopeId) initScope(Object.assign(scopeLookup[scopeId] ||= (partial["#Id"] = scopeId, partial), partial));
964
+ else Object.assign(initGlobal(), partial);
965
+ scopeId++;
974
966
  }
975
- };
976
- const serializeContext = ((data, registryId) => typeof data === "number" ? registryId ? _resumed[registryId](getScope(data)) : getScope(data) : applyScopes(data));
977
- const createVisitBranches = (branchScopesStack = [], branchStarts = [], curBranchScopes, reorderBranch, reorderDepth = 0, adopt = (scope, branch) => scope["#ClosestBranch"] === scope ? scope !== branch && setParentBranch(scope, branch) : scope[ClosestBranch] = branch) => {
978
- return (branchId, branch, endedBranches, accessor, nodeAccessor, singleNode, parent = visit.parentNode, startVisit = visit) => {
979
- if (visitType === "*") {
980
- while (reorderBranch && pending.length >= reorderDepth) adopt(pending.pop(), reorderBranch);
981
- if (reorderBranch = +lastToken && visitScope) reorderDepth = pending.push(reorderBranch);
982
- return;
983
- }
984
- if (visitType !== "[") {
985
- visitScope[nextToken()] = visitType === ")" || visitType === "}" ? parent : visit;
986
- accessor = BranchScopes$1 + (nodeAccessor = lastToken);
987
- singleNode = visitType !== "]" && visitType !== ")";
988
- nextToken();
989
- }
990
- while (branchId = +lastToken) {
991
- (endedBranches ||= []).push(branch = getScope(branchId));
992
- setParentBranch(branch, branch[ClosestBranch]);
993
- if (branch["#AwaitCounter"] = render.p?.[branchId]) branch[AwaitCounter].m = render.m;
994
- if (singleNode) {
995
- while (startVisit.previousSibling && (startVisit = startVisit.previousSibling).nodeType > 1);
996
- branch["_"] ??= visitScope;
997
- branch[EndNode] = branch[StartNode] = startVisit;
998
- if (visitType === "(") branch[getDebugKey(0, startVisit)] = startVisit;
999
- } else {
1000
- branch[BranchAccessor] = nodeAccessor;
1001
- curBranchScopes = push(curBranchScopes, branch);
1002
- if (accessor) {
1003
- visitScope[accessor] = curBranchScopes;
1004
- forEach(curBranchScopes, (scope) => scope["_"] ??= visitScope);
1005
- curBranchScopes = branchScopesStack.pop();
1006
- }
1007
- startVisit = branchStarts.pop();
1008
- if (parent !== startVisit.parentNode) parent.prepend(startVisit);
1009
- branch[StartNode] = startVisit;
1010
- branch[EndNode] = visit.previousSibling === startVisit ? startVisit : parent.insertBefore(new Text(), visit);
967
+ }
968
+ };
969
+ const serializeContext = ((data, registryId) => typeof data === "number" ? registryId ? _resumed[registryId](getScope(data)) : getScope(data) : applyScopes(data));
970
+ const createVisitBranches = (branchScopesStack = [], branchStarts = [], curBranchScopes, reorderBranch, reorderDepth = 0, adopt = (scope, branch) => scope["#ClosestBranch"] === scope ? scope !== branch && setParentBranch(scope, branch) : scope[ClosestBranch] = branch) => {
971
+ return (branchId, branch, endedBranches, accessor, nodeAccessor, singleNode, parent = visit.parentNode, startVisit = visit) => {
972
+ if (visitType === "*") {
973
+ while (reorderBranch && pending.length >= reorderDepth) adopt(pending.pop(), reorderBranch);
974
+ if (reorderBranch = +lastToken && visitScope) reorderDepth = pending.push(reorderBranch);
975
+ return;
976
+ }
977
+ if (visitType !== "[") {
978
+ visitScope[nextToken()] = visitType === ")" || visitType === "}" ? parent : visit;
979
+ accessor = BranchScopes$1 + (nodeAccessor = lastToken);
980
+ singleNode = visitType !== "]" && visitType !== ")";
981
+ nextToken();
982
+ }
983
+ while (branchId = +lastToken) {
984
+ (endedBranches ||= []).push(branch = getScope(branchId));
985
+ setParentBranch(branch, branch[ClosestBranch]);
986
+ if (branch["#AwaitCounter"] = render.p?.[branchId]) branch[AwaitCounter].m = render.m;
987
+ if (singleNode) {
988
+ while (startVisit.previousSibling && (startVisit = startVisit.previousSibling).nodeType > 1);
989
+ branch["_"] ??= visitScope;
990
+ branch[EndNode] = branch[StartNode] = startVisit;
991
+ if (visitType === "(") branch[getDebugKey(0, startVisit)] = startVisit;
992
+ } else {
993
+ branch[BranchAccessor] = nodeAccessor;
994
+ curBranchScopes = push(curBranchScopes, branch);
995
+ if (accessor) {
996
+ visitScope[accessor] = curBranchScopes;
997
+ forEach(curBranchScopes, (scope) => scope["_"] ??= visitScope);
998
+ curBranchScopes = branchScopesStack.pop();
1011
999
  }
1012
- while (pending.at(-1)?.["#Id"] >= branchId) adopt(pending.pop(), branch);
1013
- nextToken();
1000
+ startVisit = branchStarts.pop();
1001
+ if (parent !== startVisit.parentNode) parent.prepend(startVisit);
1002
+ branch[StartNode] = startVisit;
1003
+ branch[EndNode] = visit.previousSibling === startVisit ? startVisit : parent.insertBefore(new Text(), visit);
1014
1004
  }
1015
- if (endedBranches) {
1016
- for (const ended of endedBranches) pending.push(ended);
1017
- if (singleNode) visitScope[accessor] = endedBranches.length > 1 ? endedBranches.reverse() : endedBranches[0];
1005
+ while (pending.at(-1)?.["#Id"] >= branchId) adopt(pending.pop(), branch);
1006
+ nextToken();
1007
+ }
1008
+ if (endedBranches) {
1009
+ for (const ended of endedBranches) pending.push(ended);
1010
+ if (singleNode) visitScope[accessor] = endedBranches.length > 1 ? endedBranches.reverse() : endedBranches[0];
1011
+ }
1012
+ if (visitType === "[") {
1013
+ if (!endedBranches) {
1014
+ branchScopesStack.push(curBranchScopes);
1015
+ curBranchScopes = void 0;
1018
1016
  }
1019
- if (visitType === "[") {
1020
- if (!endedBranches) {
1021
- branchScopesStack.push(curBranchScopes);
1022
- curBranchScopes = void 0;
1023
- }
1024
- branchStarts.push(visit);
1025
- } else pending.push(visitScope);
1026
- };
1017
+ branchStarts.push(visit);
1018
+ } else pending.push(visitScope);
1027
1019
  };
1028
- const nextToken = (_) => lastToken = visitText.slice(lastTokenIndex, (lastTokenIndex = visitText.indexOf(" ", lastTokenIndex) + 1 || visitText.length + 1) - 1);
1029
- const processResumes = (resumes = [], effects) => {
1030
- let i = 0;
1031
- for (; i < resumes.length; i++) {
1032
- const serialized = resumes[i];
1033
- if (typeof serialized === "string") {
1034
- lastTokenIndex = 0;
1035
- visitText = serialized;
1036
- while (nextToken()) if (/\D/.test(lastToken)) lastEffect = _resumed[lastToken];
1037
- else effects.push(lastEffect, getScope(lastToken));
1038
- } else if (Array.isArray(serialized)) {
1039
- if (!(readyIds && serialized.every((dep) => readyIds.has(dep) && !render.b[dep].length))) break;
1040
- } else if (readyIds && typeof serialized === "number") break;
1041
- else {
1042
- const scopes = serialized(serializeContext);
1043
- if (Array.isArray(scopes)) applyScopes(scopes);
1044
- }
1020
+ };
1021
+ const nextToken = (_) => lastToken = visitText.slice(lastTokenIndex, (lastTokenIndex = visitText.indexOf(" ", lastTokenIndex) + 1 || visitText.length + 1) - 1);
1022
+ const processResumes = (resumes = [], effects) => {
1023
+ let i = 0;
1024
+ for (; i < resumes.length; i++) {
1025
+ const serialized = resumes[i];
1026
+ if (typeof serialized === "string") {
1027
+ lastTokenIndex = 0;
1028
+ visitText = serialized;
1029
+ while (nextToken()) if (/\D/.test(lastToken)) lastEffect = _resumed[lastToken];
1030
+ else effects.push(lastEffect, getScope(lastToken));
1031
+ } else if (Array.isArray(serialized)) {
1032
+ if (!(readyIds && serialized.every((dep) => readyIds.has(dep) && !render.b[dep].length))) break;
1033
+ } else if (readyIds && typeof serialized === "number") break;
1034
+ else {
1035
+ const scopes = serialized(serializeContext);
1036
+ if (Array.isArray(scopes)) applyScopes(scopes);
1045
1037
  }
1046
- resumes.splice(0, i);
1047
- return i;
1048
- };
1049
- let lastEffect;
1050
- let visits;
1051
- let visit;
1052
- let visitText;
1053
- let visitType;
1054
- let visitScope;
1055
- let lastToken;
1056
- let lastTokenIndex;
1057
- let visitBranches;
1058
- let htmlStart;
1059
- let embedAnchor;
1060
- serializeContext._ = _resumed;
1061
- if (render.m) throw new Error(`Marko rendered multiple times with $global.runtimeId as ${JSON.stringify(runtimeId)} and $global.renderId as ${JSON.stringify(renderId)}. Ensure each render into a page has a unique $global.renderId.`);
1062
- for (const otherId in curRenders) if (otherId !== renderId && (otherId.startsWith(renderId) || renderId.startsWith(otherId))) console.error(`Marko rendered with $global.runtimeId as ${JSON.stringify(runtimeId)} and $global.renderId as both ${JSON.stringify(otherId)} and ${JSON.stringify(renderId)}, so one render claims the other's resume comments. Ensure no $global.renderId in a page starts another.`);
1063
- render.m = (effects) => {
1064
- processResumes(render.r, effects);
1065
- if (readyIds && render.b) for (let progress = 1; progress;) {
1066
- progress = 0;
1067
- for (const readyId of readyIds) {
1068
- const resumes = render.b[readyId];
1069
- if (resumes && processResumes(resumes, effects)) progress = 1;
1070
- }
1038
+ }
1039
+ resumes.splice(0, i);
1040
+ return i;
1041
+ };
1042
+ let lastEffect;
1043
+ let visits;
1044
+ let visit;
1045
+ let visitText;
1046
+ let visitType;
1047
+ let visitScope;
1048
+ let lastToken;
1049
+ let lastTokenIndex;
1050
+ let visitBranches;
1051
+ let htmlStart;
1052
+ let embedAnchor;
1053
+ serializeContext._ = _resumed;
1054
+ if (render.m) throw new Error(`Marko rendered multiple times with $global.runtimeId as ${JSON.stringify(runtimeId)} and $global.renderId as ${JSON.stringify(renderId)}. Ensure each render into a page has a unique $global.renderId.`);
1055
+ for (const otherId in curRenders) if (otherId !== renderId && (otherId.startsWith(renderId) || renderId.startsWith(otherId))) console.error(`Marko rendered with $global.runtimeId as ${JSON.stringify(runtimeId)} and $global.renderId as both ${JSON.stringify(otherId)} and ${JSON.stringify(renderId)}, so one render claims the other's resume comments. Ensure no $global.renderId in a page starts another.`);
1056
+ render.m = (effects) => {
1057
+ processResumes(render.r, effects);
1058
+ if (readyIds && render.b) for (let progress = 1; progress;) {
1059
+ progress = 0;
1060
+ for (const readyId of readyIds) {
1061
+ const resumes = render.b[readyId];
1062
+ if (resumes && processResumes(resumes, effects)) progress = 1;
1071
1063
  }
1072
- let retained = 0;
1073
- for (visit of visits = render.v) {
1074
- lastTokenIndex = render.i.length;
1075
- visitText = visit.data;
1076
- visitType = visitText[lastTokenIndex++];
1077
- visitScope = getScope(nextToken());
1078
- if (dynamicHtmlEnabled && visitType > "%" && visitType <= "'") {
1079
- if (visitType === "&") htmlStart = visit;
1080
- else {
1081
- if (visit.parentNode !== htmlStart.parentNode) console.error("An unescaped placeholder (`$!{}`) rendered HTML that does not parse as a balanced fragment where it is placed (an unclosed, stray or misnested tag), so updating it removes the wrong nodes.");
1082
- visitScope[nextToken()] = htmlStart;
1083
- visitScope[DynamicHTMLLastChild + lastToken] = visit;
1084
- if ((branchesEnabled || lazyEnabled) && pending[pending.length - 1] !== visitScope) pending.push(visitScope);
1085
- }
1086
- } else if (branchesEnabled && visitType > "'") (visitBranches ||= createVisitBranches())();
1087
- else if (lazyEnabled && render.b && visitType > "%") visits[retained++] = visit;
1064
+ }
1065
+ let retained = 0;
1066
+ for (visit of visits = render.v) {
1067
+ lastTokenIndex = render.i.length;
1068
+ visitText = visit.data;
1069
+ visitType = visitText[lastTokenIndex++];
1070
+ visitScope = getScope(nextToken());
1071
+ if (dynamicHtmlEnabled && visitType > "%" && visitType <= "'") {
1072
+ if (visitType === "&") htmlStart = visit;
1088
1073
  else {
1089
- visitScope[nextToken()] = visitType === "%" ? visit.parentNode.insertBefore(new Text(), visit) : visit.previousSibling;
1074
+ if (visit.parentNode !== htmlStart.parentNode) console.error("An unescaped placeholder (`$!{}`) rendered HTML that does not parse as a balanced fragment where it is placed (an unclosed, stray or misnested tag), so updating it removes the wrong nodes.");
1075
+ visitScope[nextToken()] = htmlStart;
1076
+ visitScope[DynamicHTMLLastChild + lastToken] = visit;
1090
1077
  if ((branchesEnabled || lazyEnabled) && pending[pending.length - 1] !== visitScope) pending.push(visitScope);
1091
1078
  }
1092
- if (embedRenders && !embedAnchor && visit.parentNode) embedRenders.set(embedAnchor = visit.parentNode.insertBefore(new Text(), visit), [renderId, scopeLookup]);
1093
- }
1094
- if (branchesEnabled && visitBranches) {
1095
- visitType = "*";
1096
- lastToken = "";
1097
- visitBranches();
1079
+ } else if (branchesEnabled && visitType > "'") (visitBranches ||= createVisitBranches())();
1080
+ else if (lazyEnabled && render.b && visitType > "%") visits[retained++] = visit;
1081
+ else {
1082
+ visitScope[nextToken()] = visitType === "%" ? visit.parentNode.insertBefore(new Text(), visit) : visit.previousSibling;
1083
+ if ((branchesEnabled || lazyEnabled) && pending[pending.length - 1] !== visitScope) pending.push(visitScope);
1098
1084
  }
1099
- visits.length = retained;
1100
- return effects;
1101
- };
1102
- render.w = (_) => {
1103
- walk();
1104
- runResumeEffects(render);
1105
- };
1106
- return render;
1107
- }) });
1108
- };
1085
+ if (embedRenders && !embedAnchor && visit.parentNode) embedRenders.set(embedAnchor = visit.parentNode.insertBefore(new Text(), visit), [renderId, scopeLookup]);
1086
+ }
1087
+ if (branchesEnabled && visitBranches) {
1088
+ visitType = "*";
1089
+ lastToken = "";
1090
+ visitBranches();
1091
+ }
1092
+ visits.length = retained;
1093
+ return effects;
1094
+ };
1095
+ render.w = (_) => {
1096
+ walk();
1097
+ runResumeEffects(render);
1098
+ };
1099
+ return render;
1100
+ }) });
1109
1101
  if (renders) {
1110
1102
  initRuntime(renders);
1111
1103
  for (const renderId in renders) runResumeEffects(curRenders(renderId));
@@ -1136,7 +1128,7 @@ function _el(id, accessor) {
1136
1128
  function _dynamic_tag_var_resume(accessor) {
1137
1129
  _resumed[DYNAMIC_TAG_VAR_REGISTER_ID + accessor] = (scope) => (_) => {
1138
1130
  const node = scope[accessor];
1139
- return _el_read(node.nodeType === 8 ? node.previousSibling : node);
1131
+ return _el_read(node.nodeType > 1 ? node.previousSibling : node);
1140
1132
  };
1141
1133
  }
1142
1134
  // src/dom/renderer.ts
@@ -1170,11 +1162,8 @@ function _content(id, template, walks, setup, params, dynamicScopesAccessor) {
1170
1162
  walks = walks ? walks.replace(/[^\0-1]+$/, "") : "";
1171
1163
  setup = setup ? setup._ || setup : void 0;
1172
1164
  params ||= void 0;
1173
- const clone = template ? (branch, ns) => {
1174
- ((cloneCache[ns] ||= {})[1 + template] ||= createCloneableHTML(template, ns))(branch, walks);
1175
- } : (branch) => {
1176
- walk(branch[StartNode] = branch[EndNode] = new Text(), walks, branch);
1177
- };
1165
+ const cloneables = {};
1166
+ const clone = template ? (branch, ns) => (cloneables[ns] ||= createCloneableHTML(template, walks, ns))(branch) : (branch) => walk(branch[StartNode] = branch[EndNode] = new Text(), walks, branch);
1178
1167
  return _resumed[id] = (owner) => {
1179
1168
  return {
1180
1169
  ["id"]: id,
@@ -1214,14 +1203,11 @@ function _content_closures(renderer, closureFns) {
1214
1203
  return instance;
1215
1204
  };
1216
1205
  }
1217
- const cloneCache = {};
1218
- function createCloneableHTML(html, ns) {
1206
+ function createCloneableHTML(html, walks, ns) {
1219
1207
  const { firstChild, lastChild } = parseHTML(html, ns);
1220
1208
  const parent = new DocumentFragment();
1221
1209
  insertChildNodes(parent, null, firstChild, lastChild);
1222
- return firstChild === lastChild && firstChild.nodeType < 8 ? (branch, walks) => {
1223
- walk(branch[StartNode] = branch[EndNode] = firstChild.cloneNode(true), walks, branch);
1224
- } : (branch, walks) => {
1210
+ return firstChild === lastChild && firstChild.nodeType < 8 ? (branch) => walk(branch[StartNode] = branch[EndNode] = firstChild.cloneNode(true), walks, branch) : (branch) => {
1225
1211
  const clone = parent.cloneNode(true);
1226
1212
  clone.namespaceURI = ns;
1227
1213
  walk(clone.firstChild, walks, branch);
@@ -1359,7 +1345,12 @@ function attrsInternal(scope, nodeAccessor, nextAttrs, controllable) {
1359
1345
  }
1360
1346
  }
1361
1347
  function _attr_content(scope, nodeAccessor, value) {
1362
- const content = normalizeClientRender(value);
1348
+ const renderer = normalizeDynamicRenderer(value);
1349
+ let content;
1350
+ if (renderer) {
1351
+ if (renderer["id"]) content = renderer;
1352
+ else throw new Error(`Invalid \`content\` attribute. Received ${typeof value}`);
1353
+ }
1363
1354
  if (scope["ConditionalRenderer:" + nodeAccessor] !== (scope["ConditionalRenderer:" + nodeAccessor] = rendererKey(content))) {
1364
1355
  setBranch(scope, nodeAccessor, content, createAndSetupBranch);
1365
1356
  if (content?.["accessor"]) subscribeToScopeSet(content[Owner], content[Accessor], scope[BranchScopes$1 + nodeAccessor]);
@@ -1394,13 +1385,6 @@ const _html = /*@__PURE__*/ withDynamicHtml(function _html(scope, value, accesso
1394
1385
  removeChildNodes(firstChild, lastChild);
1395
1386
  }
1396
1387
  });
1397
- function normalizeClientRender(value) {
1398
- const renderer = normalizeDynamicRenderer(value);
1399
- if (renderer) {
1400
- if (renderer["id"]) return renderer;
1401
- else throw new Error(`Invalid \`content\` attribute. Received ${typeof value}`);
1402
- }
1403
- }
1404
1388
  function normalizeAttrValue(value) {
1405
1389
  if (isNotNullishOrFalse(value)) return value === true ? "" : value + "";
1406
1390
  }
@@ -1417,7 +1401,7 @@ function _lifecycle(scope, thisObj, index = 0) {
1417
1401
  Object.assign(thisObj, thisObj.onMount?.());
1418
1402
  for (const prop in snapshot) if (!Object.is(snapshot[prop], thisObj[prop])) throw new Error(`Tried to overwrite existing property "${prop}" in <lifecycle> onMount.`);
1419
1403
  }
1420
- trackAbort(scope, accessor, (_) => thisObj.onDestroy?.());
1404
+ onAbort(scope, accessor, (_) => thisObj.onDestroy?.());
1421
1405
  }
1422
1406
  }
1423
1407
  function removeChildNodes(startNode, endNode) {
@@ -1779,7 +1763,7 @@ function _await_promise(nodeAccessor, params) {
1779
1763
  let awaitCounter = tryBranch[AwaitCounter];
1780
1764
  if (!scope[tryAccessor]) {
1781
1765
  scope[tryAccessor] = tryBranch;
1782
- trackAbort(scope, promiseAccessor, (_) => {
1766
+ onAbort(scope, promiseAccessor, (_) => {
1783
1767
  scope[promiseAccessor] = 0;
1784
1768
  if (scope[tryAccessor]) queueAsyncRender(scope[tryAccessor], completeAwaitCounter, awaitCounter);
1785
1769
  });
@@ -1957,7 +1941,7 @@ const _show = /*@__PURE__*/ withBranches((nodeAccessor, startNodeAccessor) => {
1957
1941
  const rangeAccessor = BranchScopes$1 + nodeAccessor;
1958
1942
  return (scope, display) => {
1959
1943
  const referenceNode = scope[nodeAccessor];
1960
- const onlyChild = referenceNode.nodeType === 1;
1944
+ const onlyChild = referenceNode.nodeType < 3;
1961
1945
  const parentNode = onlyChild ? referenceNode : referenceNode.parentNode;
1962
1946
  let range = scope[rangeAccessor];
1963
1947
  if (!range) {
@@ -2095,7 +2079,7 @@ const loop = /*@__PURE__*/ withBranches((forEach, reorder) => (nodeAccessor, tem
2095
2079
  const oldScope = oldScopes[i];
2096
2080
  let branch = oldLen && (oldScopesByKey || key !== (oldScope?.["#LoopKey"] ?? i) ? (oldScopesByKey ||= oldScopes.reduce((map, scope, j) => j < i ? map : (scope["#LoopIndex"] = j, map.set(scope["#LoopKey"] ?? j, scope)), /* @__PURE__ */ new Map())).get(key) : oldScope && (start++, oldScope));
2097
2081
  if (branch) {
2098
- hasPotentialMoves = true;
2082
+ hasPotentialMoves = 1;
2099
2083
  oldScopesByKey?.delete(key);
2100
2084
  branch[LoopKey] = key;
2101
2085
  } else {
@@ -3021,6 +3005,12 @@ Object.defineProperty(exports, "installDynamicTagVar", {
3021
3005
  return installDynamicTagVar;
3022
3006
  }
3023
3007
  });
3008
+ Object.defineProperty(exports, "onAbort", {
3009
+ enumerable: true,
3010
+ get: function() {
3011
+ return onAbort;
3012
+ }
3013
+ });
3024
3014
  Object.defineProperty(exports, "patchDynamicTag", {
3025
3015
  enumerable: true,
3026
3016
  get: function() {