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
@@ -51,8 +51,6 @@ const Changed = "Changed";
51
51
  const ScopesAccessor = "scopesAccessor";
52
52
  const SignalIndexAccessor = "signalIndexAccessor";
53
53
  const Index = "index";
54
- // src/common/constants/keyed-scopes-prop.debug.ts
55
- const PreviousKey = "PreviousKey:";
56
54
  const Scope = "scope";
57
55
  const Signal = "signal";
58
56
  const Value = "value";
@@ -133,7 +131,7 @@ function escapeStyleValue(str) {
133
131
  else if (c === closers[0]) closers = closers.slice(1);
134
132
  return result + closers;
135
133
  }
136
- const toDelimitedString = function toDelimitedString(val, delimiter, stringify) {
134
+ function toDelimitedString(val, delimiter, stringify) {
137
135
  let str = "";
138
136
  let sep = "";
139
137
  let part;
@@ -155,7 +153,7 @@ const toDelimitedString = function toDelimitedString(val, delimiter, stringify)
155
153
  }
156
154
  }
157
155
  return str;
158
- };
156
+ }
159
157
  function isEventHandler(name) {
160
158
  return /^on[A-Z-]/.test(name);
161
159
  }
@@ -434,9 +432,9 @@ function prepareEffects(fn) {
434
432
  }
435
433
  return preparedEffects;
436
434
  }
437
- let runEffects = ((effects) => {
435
+ let runEffects = (effects) => {
438
436
  for (let i = 0; i < effects.length;) effects[i++](effects[i++]);
439
- });
437
+ };
440
438
  let runRender = (render) => {
441
439
  if (!branchesEnabled || render["scope"]["#ClosestBranch"]?.["#Gen"] !== 0) render[Signal](render[Scope], render[Value]);
442
440
  };
@@ -486,7 +484,7 @@ function $signal(scope, id) {
486
484
  return ((scope[AbortControllers] ||= {})[id] ||= new AbortController()).signal;
487
485
  }
488
486
  /** Runs `abort` as a destroyed scope's `$signal` would fire, without creating one. */
489
- function trackAbort(scope, id, abort) {
487
+ function onAbort(scope, id, abort) {
490
488
  abortsEnabled = 1;
491
489
  trackCleanup(scope);
492
490
  (scope[AbortControllers] ||= {})[id] = { abort };
@@ -585,7 +583,7 @@ function skipScope() {
585
583
  return nextScopeId++;
586
584
  }
587
585
  function destroyBranch(branch) {
588
- branch[ParentBranch]?.[BranchScopes]?.delete(branch);
586
+ branch[ParentBranch]?.[BranchScopes].delete(branch);
589
587
  destroyNestedScopes(branch);
590
588
  }
591
589
  function destroyScope(scope) {
@@ -594,11 +592,11 @@ function destroyScope(scope) {
594
592
  cleanupScope(scope);
595
593
  }
596
594
  }
597
- const destroyNestedScopes = function destroyNestedScopes(scope) {
595
+ function destroyNestedScopes(scope) {
598
596
  scope[Gen$1] = 0;
599
597
  scope[BranchScopes]?.forEach(destroyNestedScopes);
600
598
  scope[AbortScopes]?.forEach(cleanupScope);
601
- };
599
+ }
602
600
  function cleanupScope(scope) {
603
601
  if (subscriptionsEnabled) scope[Subscriptions]?.forEach(unsubscribe, scope);
604
602
  if (abortsEnabled) for (const id in scope[AbortControllers]) $signalReset(scope, id);
@@ -690,7 +688,8 @@ function _const(valueAccessor, fn) {
690
688
  }
691
689
  });
692
690
  }
693
- function _or(id, fn, defaultPending = 1, scopeIdAccessor = "#Id") {
691
+ function _or(id, fn, defaultPending = 1, scopeIdAccessor) {
692
+ scopeIdAccessor = scopeIdAccessor ? scopeIdAccessor : "#Id";
694
693
  return (scope) => {
695
694
  if (scope["#Gen"] === runId) {
696
695
  if (~id in scope) {
@@ -699,36 +698,33 @@ function _or(id, fn, defaultPending = 1, scopeIdAccessor = "#Id") {
699
698
  } else queueRender(scope, fn, id, 0, scope[scopeIdAccessor]);
700
699
  };
701
700
  }
702
- function _for_closure(ownerLoopNodeAccessor, fn) {
701
+ function _for_closure(ownerLoopNodeAccessor, fn, id, scopeIdAccessor) {
702
+ scopeIdAccessor = scopeIdAccessor ? scopeIdAccessor : "#Id";
703
703
  const scopeAccessor = BranchScopes$1 + ownerLoopNodeAccessor;
704
- const ownerSignal = (ownerScope) => {
705
- const scopes = toArray(ownerScope[scopeAccessor]);
706
- queueRender(ownerScope, (_) => {
707
- for (const scope of scopes) if (scope["#Gen"] > 0 && scope["#Gen"] < runId) fn(scope);
708
- }, -1);
704
+ const render = (ownerScope) => {
705
+ for (const scope of toArray(ownerScope[scopeAccessor])) if (scope["#Gen"] < runId) fn(scope);
709
706
  };
707
+ const ownerSignal = (ownerScope) => queueRender(ownerScope, render, id, 0, ownerScope[scopeIdAccessor]);
710
708
  ownerSignal._ = (scope) => queueRender(scope, fn, -1);
711
709
  return ownerSignal;
712
710
  }
713
- function _for_selector(ownerLoopNodeAccessor, ownerValueAccessor, fn) {
711
+ function _for_selector(ownerLoopNodeAccessor, ownerValueAccessor, fn, getValueScope) {
714
712
  const scopeAccessor = BranchScopes$1 + ownerLoopNodeAccessor;
715
713
  const mapAccessor = KeyedScopes + ownerLoopNodeAccessor;
716
- const prevKeyProp = `${PreviousKey}${ownerValueAccessor}`;
714
+ const prevKey = Symbol(ownerValueAccessor);
717
715
  const ownerSignal = (ownerScope) => {
718
716
  if (ownerScope["#Gen"] < runId) {
719
- const nextKey = ownerScope[ownerValueAccessor];
720
- queueRender(ownerScope, (_) => {
721
- const map = keyedScopes(ownerScope, scopeAccessor, mapAccessor);
722
- if (map && prevKeyProp in map) {
723
- const prevScope = map.get(map[prevKeyProp]);
724
- const nextScope = map.get(nextKey);
725
- if (prevScope !== nextScope) {
726
- runLiveBranch(prevScope, fn);
727
- runLiveBranch(nextScope, fn);
728
- }
729
- } else for (const scope of toArray(ownerScope[scopeAccessor])) runLiveBranch(scope, fn);
730
- if (map) map[prevKeyProp] = nextKey;
731
- }, -1);
717
+ const nextKey = (getValueScope ? getValueScope(ownerScope) : ownerScope)[ownerValueAccessor];
718
+ const map = keyedScopes(ownerScope, scopeAccessor, mapAccessor);
719
+ if (map && prevKey in ownerScope) {
720
+ const prevScope = map.get(ownerScope[prevKey]);
721
+ const nextScope = map.get(nextKey);
722
+ if (prevScope !== nextScope) {
723
+ queueLiveBranch(prevScope, fn);
724
+ queueLiveBranch(nextScope, fn);
725
+ }
726
+ } else for (const scope of toArray(ownerScope[scopeAccessor])) queueLiveBranch(scope, fn);
727
+ ownerScope[prevKey] = nextKey;
732
728
  }
733
729
  };
734
730
  ownerSignal._ = (scope) => queueRender(scope, fn, -1);
@@ -743,8 +739,8 @@ function keyedScopes(ownerScope, scopeAccessor, mapAccessor) {
743
739
  }
744
740
  return map;
745
741
  }
746
- function runLiveBranch(scope, fn) {
747
- if (scope && scope["#Gen"] > 0 && scope["#Gen"] < runId) fn(scope);
742
+ function queueLiveBranch(scope, fn) {
743
+ if (scope?.["#Gen"] < runId) queueRender(scope, fn, -1);
748
744
  }
749
745
  function _if_closure(ownerConditionalNodeAccessor, branch, fn) {
750
746
  const scopeAccessor = BranchScopes$1 + ownerConditionalNodeAccessor;
@@ -813,9 +809,7 @@ function _id(scope, accessor) {
813
809
  }
814
810
  function _script(id, fn) {
815
811
  _resumed[id] = fn;
816
- return (scope) => {
817
- queueEffect(scope, fn);
818
- };
812
+ return (scope) => queueEffect(scope, fn);
819
813
  }
820
814
  function _global_read($global, key) {
821
815
  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.`);
@@ -855,7 +849,7 @@ function walk(startNode, walkCodes, branch) {
855
849
  currentNode = startNode;
856
850
  walkInternal(0, walkCodes, branch);
857
851
  }
858
- const walkInternal = function walkInternal(currentWalkIndex, walkCodes, scope) {
852
+ function walkInternal(currentWalkIndex, walkCodes, scope) {
859
853
  let value;
860
854
  let currentMultiplier;
861
855
  let storedMultiplier = 0;
@@ -891,7 +885,7 @@ const walkInternal = function walkInternal(currentWalkIndex, walkCodes, scope) {
891
885
  storedMultiplier = currentMultiplier * 10 + value - 117;
892
886
  }
893
887
  }
894
- };
888
+ }
895
889
  function getDebugKey(index, node) {
896
890
  if (typeof node === "string") return `${node}/${index}`;
897
891
  else if (node.nodeType === 3) return `#text/${index}`;
@@ -943,168 +937,166 @@ function init(runtimeId = "M") {
943
937
  }
944
938
  const renders = self[runtimeId];
945
939
  const defineRuntime = (desc) => Object.defineProperty(self, runtimeId, desc);
946
- const initRuntime = (renders) => {
947
- defineRuntime({ value: curRenders = ((renderId) => {
948
- const render = curRenders[renderId] = renders[renderId] || renders(renderId);
949
- const walk = render.w;
950
- const scopeLookup = {};
951
- const pending = [];
952
- const getScope = (id) => scopeLookup[id] || (+id ? initScope(scopeLookup[id] = { ["#Id"]: +id }) : initGlobal());
953
- const initGlobal = (_) => scopeLookup[0] ||= {
954
- runtimeId,
955
- renderId
956
- };
957
- const initScope = (scope) => {
958
- scope[Gen$1] ??= 1;
959
- scope[Global] = initGlobal();
960
- if (branchesEnabled && scope["#ClosestBranchId"]) scope[ClosestBranch] = getScope(scope[ClosestBranchId]);
961
- return scope;
962
- };
963
- const applyScopes = (partials) => {
964
- let scopeId = partials[0];
965
- for (let i = 1; i < partials.length; i++) {
966
- const partial = partials[i];
967
- if (typeof partial === "number") scopeId += partial;
968
- else {
969
- if (scopeId) initScope(Object.assign(scopeLookup[scopeId] ||= (partial["#Id"] = scopeId, partial), partial));
970
- else Object.assign(initGlobal(), partial);
971
- scopeId++;
972
- }
940
+ const initRuntime = (renders) => defineRuntime({ value: curRenders = ((renderId) => {
941
+ const render = curRenders[renderId] = renders[renderId] || renders(renderId);
942
+ const walk = render.w;
943
+ const scopeLookup = {};
944
+ const pending = [];
945
+ const getScope = (id) => scopeLookup[id] || (+id ? initScope(scopeLookup[id] = { ["#Id"]: +id }) : initGlobal());
946
+ const initGlobal = (_) => scopeLookup[0] ||= {
947
+ runtimeId,
948
+ renderId
949
+ };
950
+ const initScope = (scope) => {
951
+ scope[Gen$1] ??= 1;
952
+ scope[Global] = initGlobal();
953
+ if (branchesEnabled && scope["#ClosestBranchId"]) scope[ClosestBranch] = getScope(scope[ClosestBranchId]);
954
+ return scope;
955
+ };
956
+ const applyScopes = (partials) => {
957
+ let scopeId = partials[0];
958
+ for (let i = 1; i < partials.length; i++) {
959
+ const partial = partials[i];
960
+ if (typeof partial === "number") scopeId += partial;
961
+ else {
962
+ if (scopeId) initScope(Object.assign(scopeLookup[scopeId] ||= (partial["#Id"] = scopeId, partial), partial));
963
+ else Object.assign(initGlobal(), partial);
964
+ scopeId++;
973
965
  }
974
- };
975
- const serializeContext = ((data, registryId) => typeof data === "number" ? registryId ? _resumed[registryId](getScope(data)) : getScope(data) : applyScopes(data));
976
- const createVisitBranches = (branchScopesStack = [], branchStarts = [], curBranchScopes, reorderBranch, reorderDepth = 0, adopt = (scope, branch) => scope["#ClosestBranch"] === scope ? scope !== branch && setParentBranch(scope, branch) : scope[ClosestBranch] = branch) => {
977
- return (branchId, branch, endedBranches, accessor, nodeAccessor, singleNode, parent = visit.parentNode, startVisit = visit) => {
978
- if (visitType === "*") {
979
- while (reorderBranch && pending.length >= reorderDepth) adopt(pending.pop(), reorderBranch);
980
- if (reorderBranch = +lastToken && visitScope) reorderDepth = pending.push(reorderBranch);
981
- return;
982
- }
983
- if (visitType !== "[") {
984
- visitScope[nextToken()] = visitType === ")" || visitType === "}" ? parent : visit;
985
- accessor = BranchScopes$1 + (nodeAccessor = lastToken);
986
- singleNode = visitType !== "]" && visitType !== ")";
987
- nextToken();
988
- }
989
- while (branchId = +lastToken) {
990
- (endedBranches ||= []).push(branch = getScope(branchId));
991
- setParentBranch(branch, branch[ClosestBranch]);
992
- if (branch["#AwaitCounter"] = render.p?.[branchId]) branch[AwaitCounter].m = render.m;
993
- if (singleNode) {
994
- while (startVisit.previousSibling && (startVisit = startVisit.previousSibling).nodeType > 1);
995
- branch["_"] ??= visitScope;
996
- branch[EndNode] = branch[StartNode] = startVisit;
997
- if (visitType === "(") branch[getDebugKey(0, startVisit)] = startVisit;
998
- } else {
999
- branch[BranchAccessor] = nodeAccessor;
1000
- curBranchScopes = push(curBranchScopes, branch);
1001
- if (accessor) {
1002
- visitScope[accessor] = curBranchScopes;
1003
- forEach(curBranchScopes, (scope) => scope["_"] ??= visitScope);
1004
- curBranchScopes = branchScopesStack.pop();
1005
- }
1006
- startVisit = branchStarts.pop();
1007
- if (parent !== startVisit.parentNode) parent.prepend(startVisit);
1008
- branch[StartNode] = startVisit;
1009
- branch[EndNode] = visit.previousSibling === startVisit ? startVisit : parent.insertBefore(new Text(), visit);
966
+ }
967
+ };
968
+ const serializeContext = ((data, registryId) => typeof data === "number" ? registryId ? _resumed[registryId](getScope(data)) : getScope(data) : applyScopes(data));
969
+ const createVisitBranches = (branchScopesStack = [], branchStarts = [], curBranchScopes, reorderBranch, reorderDepth = 0, adopt = (scope, branch) => scope["#ClosestBranch"] === scope ? scope !== branch && setParentBranch(scope, branch) : scope[ClosestBranch] = branch) => {
970
+ return (branchId, branch, endedBranches, accessor, nodeAccessor, singleNode, parent = visit.parentNode, startVisit = visit) => {
971
+ if (visitType === "*") {
972
+ while (reorderBranch && pending.length >= reorderDepth) adopt(pending.pop(), reorderBranch);
973
+ if (reorderBranch = +lastToken && visitScope) reorderDepth = pending.push(reorderBranch);
974
+ return;
975
+ }
976
+ if (visitType !== "[") {
977
+ visitScope[nextToken()] = visitType === ")" || visitType === "}" ? parent : visit;
978
+ accessor = BranchScopes$1 + (nodeAccessor = lastToken);
979
+ singleNode = visitType !== "]" && visitType !== ")";
980
+ nextToken();
981
+ }
982
+ while (branchId = +lastToken) {
983
+ (endedBranches ||= []).push(branch = getScope(branchId));
984
+ setParentBranch(branch, branch[ClosestBranch]);
985
+ if (branch["#AwaitCounter"] = render.p?.[branchId]) branch[AwaitCounter].m = render.m;
986
+ if (singleNode) {
987
+ while (startVisit.previousSibling && (startVisit = startVisit.previousSibling).nodeType > 1);
988
+ branch["_"] ??= visitScope;
989
+ branch[EndNode] = branch[StartNode] = startVisit;
990
+ if (visitType === "(") branch[getDebugKey(0, startVisit)] = startVisit;
991
+ } else {
992
+ branch[BranchAccessor] = nodeAccessor;
993
+ curBranchScopes = push(curBranchScopes, branch);
994
+ if (accessor) {
995
+ visitScope[accessor] = curBranchScopes;
996
+ forEach(curBranchScopes, (scope) => scope["_"] ??= visitScope);
997
+ curBranchScopes = branchScopesStack.pop();
1010
998
  }
1011
- while (pending.at(-1)?.["#Id"] >= branchId) adopt(pending.pop(), branch);
1012
- nextToken();
999
+ startVisit = branchStarts.pop();
1000
+ if (parent !== startVisit.parentNode) parent.prepend(startVisit);
1001
+ branch[StartNode] = startVisit;
1002
+ branch[EndNode] = visit.previousSibling === startVisit ? startVisit : parent.insertBefore(new Text(), visit);
1013
1003
  }
1014
- if (endedBranches) {
1015
- for (const ended of endedBranches) pending.push(ended);
1016
- if (singleNode) visitScope[accessor] = endedBranches.length > 1 ? endedBranches.reverse() : endedBranches[0];
1004
+ while (pending.at(-1)?.["#Id"] >= branchId) adopt(pending.pop(), branch);
1005
+ nextToken();
1006
+ }
1007
+ if (endedBranches) {
1008
+ for (const ended of endedBranches) pending.push(ended);
1009
+ if (singleNode) visitScope[accessor] = endedBranches.length > 1 ? endedBranches.reverse() : endedBranches[0];
1010
+ }
1011
+ if (visitType === "[") {
1012
+ if (!endedBranches) {
1013
+ branchScopesStack.push(curBranchScopes);
1014
+ curBranchScopes = void 0;
1017
1015
  }
1018
- if (visitType === "[") {
1019
- if (!endedBranches) {
1020
- branchScopesStack.push(curBranchScopes);
1021
- curBranchScopes = void 0;
1022
- }
1023
- branchStarts.push(visit);
1024
- } else pending.push(visitScope);
1025
- };
1016
+ branchStarts.push(visit);
1017
+ } else pending.push(visitScope);
1026
1018
  };
1027
- const nextToken = (_) => lastToken = visitText.slice(lastTokenIndex, (lastTokenIndex = visitText.indexOf(" ", lastTokenIndex) + 1 || visitText.length + 1) - 1);
1028
- const processResumes = (resumes = [], effects) => {
1029
- let i = 0;
1030
- for (; i < resumes.length; i++) {
1031
- const serialized = resumes[i];
1032
- if (typeof serialized === "string") {
1033
- lastTokenIndex = 0;
1034
- visitText = serialized;
1035
- while (nextToken()) if (/\D/.test(lastToken)) lastEffect = _resumed[lastToken];
1036
- else effects.push(lastEffect, getScope(lastToken));
1037
- } else if (Array.isArray(serialized)) {
1038
- if (!(readyIds && serialized.every((dep) => readyIds.has(dep) && !render.b[dep].length))) break;
1039
- } else if (readyIds && typeof serialized === "number") break;
1040
- else {
1041
- const scopes = serialized(serializeContext);
1042
- if (Array.isArray(scopes)) applyScopes(scopes);
1043
- }
1019
+ };
1020
+ const nextToken = (_) => lastToken = visitText.slice(lastTokenIndex, (lastTokenIndex = visitText.indexOf(" ", lastTokenIndex) + 1 || visitText.length + 1) - 1);
1021
+ const processResumes = (resumes = [], effects) => {
1022
+ let i = 0;
1023
+ for (; i < resumes.length; i++) {
1024
+ const serialized = resumes[i];
1025
+ if (typeof serialized === "string") {
1026
+ lastTokenIndex = 0;
1027
+ visitText = serialized;
1028
+ while (nextToken()) if (/\D/.test(lastToken)) lastEffect = _resumed[lastToken];
1029
+ else effects.push(lastEffect, getScope(lastToken));
1030
+ } else if (Array.isArray(serialized)) {
1031
+ if (!(readyIds && serialized.every((dep) => readyIds.has(dep) && !render.b[dep].length))) break;
1032
+ } else if (readyIds && typeof serialized === "number") break;
1033
+ else {
1034
+ const scopes = serialized(serializeContext);
1035
+ if (Array.isArray(scopes)) applyScopes(scopes);
1044
1036
  }
1045
- resumes.splice(0, i);
1046
- return i;
1047
- };
1048
- let lastEffect;
1049
- let visits;
1050
- let visit;
1051
- let visitText;
1052
- let visitType;
1053
- let visitScope;
1054
- let lastToken;
1055
- let lastTokenIndex;
1056
- let visitBranches;
1057
- let htmlStart;
1058
- let embedAnchor;
1059
- serializeContext._ = _resumed;
1060
- 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.`);
1061
- 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.`);
1062
- render.m = (effects) => {
1063
- processResumes(render.r, effects);
1064
- if (readyIds && render.b) for (let progress = 1; progress;) {
1065
- progress = 0;
1066
- for (const readyId of readyIds) {
1067
- const resumes = render.b[readyId];
1068
- if (resumes && processResumes(resumes, effects)) progress = 1;
1069
- }
1037
+ }
1038
+ resumes.splice(0, i);
1039
+ return i;
1040
+ };
1041
+ let lastEffect;
1042
+ let visits;
1043
+ let visit;
1044
+ let visitText;
1045
+ let visitType;
1046
+ let visitScope;
1047
+ let lastToken;
1048
+ let lastTokenIndex;
1049
+ let visitBranches;
1050
+ let htmlStart;
1051
+ let embedAnchor;
1052
+ serializeContext._ = _resumed;
1053
+ 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.`);
1054
+ 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.`);
1055
+ render.m = (effects) => {
1056
+ processResumes(render.r, effects);
1057
+ if (readyIds && render.b) for (let progress = 1; progress;) {
1058
+ progress = 0;
1059
+ for (const readyId of readyIds) {
1060
+ const resumes = render.b[readyId];
1061
+ if (resumes && processResumes(resumes, effects)) progress = 1;
1070
1062
  }
1071
- let retained = 0;
1072
- for (visit of visits = render.v) {
1073
- lastTokenIndex = render.i.length;
1074
- visitText = visit.data;
1075
- visitType = visitText[lastTokenIndex++];
1076
- visitScope = getScope(nextToken());
1077
- if (dynamicHtmlEnabled && visitType > "%" && visitType <= "'") {
1078
- if (visitType === "&") htmlStart = visit;
1079
- else {
1080
- 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.");
1081
- visitScope[nextToken()] = htmlStart;
1082
- visitScope[DynamicHTMLLastChild + lastToken] = visit;
1083
- if ((branchesEnabled || lazyEnabled) && pending[pending.length - 1] !== visitScope) pending.push(visitScope);
1084
- }
1085
- } else if (branchesEnabled && visitType > "'") (visitBranches ||= createVisitBranches())();
1086
- else if (lazyEnabled && render.b && visitType > "%") visits[retained++] = visit;
1063
+ }
1064
+ let retained = 0;
1065
+ for (visit of visits = render.v) {
1066
+ lastTokenIndex = render.i.length;
1067
+ visitText = visit.data;
1068
+ visitType = visitText[lastTokenIndex++];
1069
+ visitScope = getScope(nextToken());
1070
+ if (dynamicHtmlEnabled && visitType > "%" && visitType <= "'") {
1071
+ if (visitType === "&") htmlStart = visit;
1087
1072
  else {
1088
- visitScope[nextToken()] = visitType === "%" ? visit.parentNode.insertBefore(new Text(), visit) : visit.previousSibling;
1073
+ 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.");
1074
+ visitScope[nextToken()] = htmlStart;
1075
+ visitScope[DynamicHTMLLastChild + lastToken] = visit;
1089
1076
  if ((branchesEnabled || lazyEnabled) && pending[pending.length - 1] !== visitScope) pending.push(visitScope);
1090
1077
  }
1091
- if (embedRenders && !embedAnchor && visit.parentNode) embedRenders.set(embedAnchor = visit.parentNode.insertBefore(new Text(), visit), [renderId, scopeLookup]);
1092
- }
1093
- if (branchesEnabled && visitBranches) {
1094
- visitType = "*";
1095
- lastToken = "";
1096
- visitBranches();
1078
+ } else if (branchesEnabled && visitType > "'") (visitBranches ||= createVisitBranches())();
1079
+ else if (lazyEnabled && render.b && visitType > "%") visits[retained++] = visit;
1080
+ else {
1081
+ visitScope[nextToken()] = visitType === "%" ? visit.parentNode.insertBefore(new Text(), visit) : visit.previousSibling;
1082
+ if ((branchesEnabled || lazyEnabled) && pending[pending.length - 1] !== visitScope) pending.push(visitScope);
1097
1083
  }
1098
- visits.length = retained;
1099
- return effects;
1100
- };
1101
- render.w = (_) => {
1102
- walk();
1103
- runResumeEffects(render);
1104
- };
1105
- return render;
1106
- }) });
1107
- };
1084
+ if (embedRenders && !embedAnchor && visit.parentNode) embedRenders.set(embedAnchor = visit.parentNode.insertBefore(new Text(), visit), [renderId, scopeLookup]);
1085
+ }
1086
+ if (branchesEnabled && visitBranches) {
1087
+ visitType = "*";
1088
+ lastToken = "";
1089
+ visitBranches();
1090
+ }
1091
+ visits.length = retained;
1092
+ return effects;
1093
+ };
1094
+ render.w = (_) => {
1095
+ walk();
1096
+ runResumeEffects(render);
1097
+ };
1098
+ return render;
1099
+ }) });
1108
1100
  if (renders) {
1109
1101
  initRuntime(renders);
1110
1102
  for (const renderId in renders) runResumeEffects(curRenders(renderId));
@@ -1135,7 +1127,7 @@ function _el(id, accessor) {
1135
1127
  function _dynamic_tag_var_resume(accessor) {
1136
1128
  _resumed[DYNAMIC_TAG_VAR_REGISTER_ID + accessor] = (scope) => (_) => {
1137
1129
  const node = scope[accessor];
1138
- return _el_read(node.nodeType === 8 ? node.previousSibling : node);
1130
+ return _el_read(node.nodeType > 1 ? node.previousSibling : node);
1139
1131
  };
1140
1132
  }
1141
1133
  // src/dom/renderer.ts
@@ -1169,11 +1161,8 @@ function _content(id, template, walks, setup, params, dynamicScopesAccessor) {
1169
1161
  walks = walks ? walks.replace(/[^\0-1]+$/, "") : "";
1170
1162
  setup = setup ? setup._ || setup : void 0;
1171
1163
  params ||= void 0;
1172
- const clone = template ? (branch, ns) => {
1173
- ((cloneCache[ns] ||= {})[1 + template] ||= createCloneableHTML(template, ns))(branch, walks);
1174
- } : (branch) => {
1175
- walk(branch[StartNode] = branch[EndNode] = new Text(), walks, branch);
1176
- };
1164
+ const cloneables = {};
1165
+ const clone = template ? (branch, ns) => (cloneables[ns] ||= createCloneableHTML(template, walks, ns))(branch) : (branch) => walk(branch[StartNode] = branch[EndNode] = new Text(), walks, branch);
1177
1166
  return _resumed[id] = (owner) => {
1178
1167
  return {
1179
1168
  ["id"]: id,
@@ -1213,14 +1202,11 @@ function _content_closures(renderer, closureFns) {
1213
1202
  return instance;
1214
1203
  };
1215
1204
  }
1216
- const cloneCache = {};
1217
- function createCloneableHTML(html, ns) {
1205
+ function createCloneableHTML(html, walks, ns) {
1218
1206
  const { firstChild, lastChild } = parseHTML(html, ns);
1219
1207
  const parent = new DocumentFragment();
1220
1208
  insertChildNodes(parent, null, firstChild, lastChild);
1221
- return firstChild === lastChild && firstChild.nodeType < 8 ? (branch, walks) => {
1222
- walk(branch[StartNode] = branch[EndNode] = firstChild.cloneNode(true), walks, branch);
1223
- } : (branch, walks) => {
1209
+ return firstChild === lastChild && firstChild.nodeType < 8 ? (branch) => walk(branch[StartNode] = branch[EndNode] = firstChild.cloneNode(true), walks, branch) : (branch) => {
1224
1210
  const clone = parent.cloneNode(true);
1225
1211
  clone.namespaceURI = ns;
1226
1212
  walk(clone.firstChild, walks, branch);
@@ -1358,7 +1344,12 @@ function attrsInternal(scope, nodeAccessor, nextAttrs, controllable) {
1358
1344
  }
1359
1345
  }
1360
1346
  function _attr_content(scope, nodeAccessor, value) {
1361
- const content = normalizeClientRender(value);
1347
+ const renderer = normalizeDynamicRenderer(value);
1348
+ let content;
1349
+ if (renderer) {
1350
+ if (renderer["id"]) content = renderer;
1351
+ else throw new Error(`Invalid \`content\` attribute. Received ${typeof value}`);
1352
+ }
1362
1353
  if (scope["ConditionalRenderer:" + nodeAccessor] !== (scope["ConditionalRenderer:" + nodeAccessor] = rendererKey(content))) {
1363
1354
  setBranch(scope, nodeAccessor, content, createAndSetupBranch);
1364
1355
  if (content?.["accessor"]) subscribeToScopeSet(content[Owner], content[Accessor], scope[BranchScopes$1 + nodeAccessor]);
@@ -1393,13 +1384,6 @@ const _html = /*@__PURE__*/ withDynamicHtml(function _html(scope, value, accesso
1393
1384
  removeChildNodes(firstChild, lastChild);
1394
1385
  }
1395
1386
  });
1396
- function normalizeClientRender(value) {
1397
- const renderer = normalizeDynamicRenderer(value);
1398
- if (renderer) {
1399
- if (renderer["id"]) return renderer;
1400
- else throw new Error(`Invalid \`content\` attribute. Received ${typeof value}`);
1401
- }
1402
- }
1403
1387
  function normalizeAttrValue(value) {
1404
1388
  if (isNotNullishOrFalse(value)) return value === true ? "" : value + "";
1405
1389
  }
@@ -1416,7 +1400,7 @@ function _lifecycle(scope, thisObj, index = 0) {
1416
1400
  Object.assign(thisObj, thisObj.onMount?.());
1417
1401
  for (const prop in snapshot) if (!Object.is(snapshot[prop], thisObj[prop])) throw new Error(`Tried to overwrite existing property "${prop}" in <lifecycle> onMount.`);
1418
1402
  }
1419
- trackAbort(scope, accessor, (_) => thisObj.onDestroy?.());
1403
+ onAbort(scope, accessor, (_) => thisObj.onDestroy?.());
1420
1404
  }
1421
1405
  }
1422
1406
  function removeChildNodes(startNode, endNode) {
@@ -1778,7 +1762,7 @@ function _await_promise(nodeAccessor, params) {
1778
1762
  let awaitCounter = tryBranch[AwaitCounter];
1779
1763
  if (!scope[tryAccessor]) {
1780
1764
  scope[tryAccessor] = tryBranch;
1781
- trackAbort(scope, promiseAccessor, (_) => {
1765
+ onAbort(scope, promiseAccessor, (_) => {
1782
1766
  scope[promiseAccessor] = 0;
1783
1767
  if (scope[tryAccessor]) queueAsyncRender(scope[tryAccessor], completeAwaitCounter, awaitCounter);
1784
1768
  });
@@ -1956,7 +1940,7 @@ const _show = /*@__PURE__*/ withBranches((nodeAccessor, startNodeAccessor) => {
1956
1940
  const rangeAccessor = BranchScopes$1 + nodeAccessor;
1957
1941
  return (scope, display) => {
1958
1942
  const referenceNode = scope[nodeAccessor];
1959
- const onlyChild = referenceNode.nodeType === 1;
1943
+ const onlyChild = referenceNode.nodeType < 3;
1960
1944
  const parentNode = onlyChild ? referenceNode : referenceNode.parentNode;
1961
1945
  let range = scope[rangeAccessor];
1962
1946
  if (!range) {
@@ -2094,7 +2078,7 @@ const loop = /*@__PURE__*/ withBranches((forEach, reorder) => (nodeAccessor, tem
2094
2078
  const oldScope = oldScopes[i];
2095
2079
  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));
2096
2080
  if (branch) {
2097
- hasPotentialMoves = true;
2081
+ hasPotentialMoves = 1;
2098
2082
  oldScopesByKey?.delete(key);
2099
2083
  branch[LoopKey] = key;
2100
2084
  } else {
@@ -2210,4 +2194,4 @@ function bySecondArg(_item, index) {
2210
2194
  function byFirstArg(name) {
2211
2195
  return name;
2212
2196
  }
2213
- export { _attr_style_items as $, DYNAMIC_TAG_SCRIPT_REGISTER_ID as $t, _attr_input_value as A, Setup as An, _closure_get as At, _controllable_select as B, ParentBranch as Bn, _let as Bt, _attr_details_or_dialog_open_script as C, withBranches as Cn, getRegisteredWithScope as Ct, _attr_input_checkedValue_script as D, Owner as Dn, readyFailed as Dt, _attr_input_checkedValue_default as E, LocalClosures as En, ready as Et, _attr_select_value as F, ClosestBranch as Fn, _global_read as Ft, _attr_class as G, StartNode as Gn, _script as Gt, controllableScripts as H, PendingEffects as Hn, _or as Ht, _attr_select_value_default as I, EndNode as In, _hoist as It, _attr_class_names as J, _assert_init as Jt, _attr_class_item as K, TagVariable as Kn, _var as Kt, _attr_select_value_script as L, Gen$1 as Ln, _hoist_resume as Lt, _attr_input_value_default as M, Scope as Mn, _el_read as Mt, _attr_input_value_dynamic_default as N, AwaitCounter as Nn, _for_closure as Nt, _attr_input_checked_default as O, Params as On, withLazy as Ot, _attr_input_value_script as P, BranchRenders as Pn, _for_selector as Pt, _attr_style_item as Q, syncGen as Qt, _controllable_input as R, Global as Rn, _id as Rt, _attr_details_or_dialog_open_default as S, _call as Sn, _var_resume as St, _attr_input_checkedValue as T, Lazy as Tn, initEmbedded as Tt, controllableSpreadHelpers as U, PendingRenders as Un, _return as Ut, _controllable_textarea as V, PendingEffectScopes as Vn, _let_change as Vt, _attr as W, PlaceholderBranch as Wn, _return_change as Wt, _attr_nonce as X, insertBranchBefore as Xt, _attr_content as Y, destroyBranch as Yt, _attr_style as Z, removeAndDestroyBranch as Zt, patchDynamicTag as _, forTo as _n, createBranch as _t, _for_in as a, installBranchRenders as an, _html as at, startAwait as b, _assert_hoist as bn, _el as bt, _for_to as c, queueAsyncRender as cn, _style_shell as ct, _for_until_unkeyed as d, rendering as dn, _to_text as dt, PLACEHOLDER_DISMISS_REGISTER_ID as en, _attrs as et, _if as f, run as fn, _content as ft, installDynamicTagVar as g, forOf as gn, createAndSetupBranch as gt, dynamicTagScript as h, forIn as hn, _return_setup as ht, _dynamic_tag_content as i, createBranchRenders as in, _attrs_script as it, _attr_input_value_attribute_default as j, Pending as jn, _const as jt, _attr_input_checked_script as k, Returns as kn, _closure as kt, _for_to_unkeyed as l, queueEffect as ln, _text as lt, _try as m, runId as mn, _content_resume as mt, _await_promise as n, $signal as nn, _attrs_partial as nt, _for_of as o, installCatch as on, _lifecycle as ot, _show as p, runEffects as pn, _content_closures as pt, _attr_class_items as q, _var_change as qt, _dynamic_tag as r, $signalReset as rn, _attrs_partial_content as rt, _for_of_unkeyed as s, prepareEffects as sn, _style_rule_item as st, _await_content as t, _on as tn, _attrs_content as tt, _for_until as u, queueRender as un, _text_content as ut, renderCatch as v, forUntil as vn, setupBranch as vt, _attr_input_checked as w, Clone as wn, init as wt, _attr_details_or_dialog_open as x, _hoist_read_error as xn, _resumed as xt, runPendingEffects as y, _assert_class_toggles as yn, _dynamic_tag_var_resume as yt, _controllable_open as z, Load as zn, _if_closure as zt };
2197
+ export { _attr_style_items as $, DYNAMIC_TAG_SCRIPT_REGISTER_ID as $t, _attr_input_value as A, Returns as An, _closure_get as At, _controllable_select as B, Load as Bn, _let as Bt, _attr_details_or_dialog_open_script as C, _call as Cn, getRegisteredWithScope as Ct, _attr_input_checkedValue_script as D, LocalClosures as Dn, readyFailed as Dt, _attr_input_checkedValue_default as E, Lazy as En, ready as Et, _attr_select_value as F, BranchRenders as Fn, _global_read as Ft, _attr_class as G, PlaceholderBranch as Gn, _script as Gt, controllableScripts as H, PendingEffectScopes as Hn, _or as Ht, _attr_select_value_default as I, ClosestBranch as In, _hoist as It, _attr_class_names as J, _assert_init as Jt, _attr_class_item as K, StartNode as Kn, _var as Kt, _attr_select_value_script as L, EndNode as Ln, _hoist_resume as Lt, _attr_input_value_default as M, Pending as Mn, _el_read as Mt, _attr_input_value_dynamic_default as N, Scope as Nn, _for_closure as Nt, _attr_input_checked_default as O, Owner as On, withLazy as Ot, _attr_input_value_script as P, AwaitCounter as Pn, _for_selector as Pt, _attr_style_item as Q, syncGen as Qt, _controllable_input as R, Gen$1 as Rn, _id as Rt, _attr_details_or_dialog_open_default as S, _hoist_read_error as Sn, _var_resume as St, _attr_input_checkedValue as T, Clone as Tn, initEmbedded as Tt, controllableSpreadHelpers as U, PendingEffects as Un, _return as Ut, _controllable_textarea as V, ParentBranch as Vn, _let_change as Vt, _attr as W, PendingRenders as Wn, _return_change as Wt, _attr_nonce as X, insertBranchBefore as Xt, _attr_content as Y, destroyBranch as Yt, _attr_style as Z, removeAndDestroyBranch as Zt, patchDynamicTag as _, forOf as _n, createBranch as _t, _for_in as a, createBranchRenders as an, _html as at, startAwait as b, _assert_class_toggles as bn, _el as bt, _for_to as c, prepareEffects as cn, _style_shell as ct, _for_until_unkeyed as d, queueRender as dn, _to_text as dt, PLACEHOLDER_DISMISS_REGISTER_ID as en, _attrs as et, _if as f, rendering as fn, _content as ft, installDynamicTagVar as g, forIn as gn, createAndSetupBranch as gt, dynamicTagScript as h, runId as hn, _return_setup as ht, _dynamic_tag_content as i, onAbort as in, _attrs_script as it, _attr_input_value_attribute_default as j, Setup as jn, _const as jt, _attr_input_checked_script as k, Params as kn, _closure as kt, _for_to_unkeyed as l, queueAsyncRender as ln, _text as lt, _try as m, runEffects as mn, _content_resume as mt, _await_promise as n, $signal as nn, _attrs_partial as nt, _for_of as o, installBranchRenders as on, _lifecycle as ot, _show as p, run as pn, _content_closures as pt, _attr_class_items as q, TagVariable as qn, _var_change as qt, _dynamic_tag as r, $signalReset as rn, _attrs_partial_content as rt, _for_of_unkeyed as s, installCatch as sn, _style_rule_item as st, _await_content as t, _on as tn, _attrs_content as tt, _for_until as u, queueEffect as un, _text_content as ut, renderCatch as v, forTo as vn, setupBranch as vt, _attr_input_checked as w, withBranches as wn, init as wt, _attr_details_or_dialog_open as x, _assert_hoist as xn, _resumed as xt, runPendingEffects as y, forUntil as yn, _dynamic_tag_var_resume as yt, _controllable_open as z, Global as zn, _if_closure as zt };