marko 6.3.48 → 6.3.50

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 (58) hide show
  1. package/dist/common/constants/resume-symbol.d.ts +1 -0
  2. package/dist/debug/dom/catch.feat.js +1 -1
  3. package/dist/debug/dom/catch.feat.mjs +1 -1
  4. package/dist/debug/dom/controllable-input.feat.js +1 -1
  5. package/dist/debug/dom/controllable-input.feat.mjs +1 -1
  6. package/dist/debug/dom/controllable-open.feat.js +1 -1
  7. package/dist/debug/dom/controllable-open.feat.mjs +1 -1
  8. package/dist/debug/dom/controllable-select.feat.js +1 -1
  9. package/dist/debug/dom/controllable-select.feat.mjs +1 -1
  10. package/dist/debug/dom/controllable-textarea.feat.js +1 -1
  11. package/dist/debug/dom/controllable-textarea.feat.mjs +1 -1
  12. package/dist/debug/dom/controllable.feat.js +1 -1
  13. package/dist/debug/dom/controllable.feat.mjs +1 -1
  14. package/dist/debug/dom/dynamic-tag-var.feat.js +1 -1
  15. package/dist/debug/dom/dynamic-tag-var.feat.mjs +1 -1
  16. package/dist/debug/dom/placeholder.feat.js +1 -1
  17. package/dist/debug/dom/placeholder.feat.mjs +1 -1
  18. package/dist/debug/{dom-CA_HiiES.js → dom-BAGeiafn.js} +25 -17
  19. package/dist/debug/{dom-DBMLPLeE.mjs → dom-C55iHvof.mjs} +25 -17
  20. package/dist/debug/dom.js +1 -1
  21. package/dist/debug/dom.mjs +1 -1
  22. package/dist/debug/html.js +76 -37
  23. package/dist/debug/html.mjs +76 -37
  24. package/dist/dom/catch.feat.js +1 -1
  25. package/dist/dom/catch.feat.mjs +1 -1
  26. package/dist/dom/controllable-input.feat.js +1 -1
  27. package/dist/dom/controllable-input.feat.mjs +1 -1
  28. package/dist/dom/controllable-open.feat.js +1 -1
  29. package/dist/dom/controllable-open.feat.mjs +1 -1
  30. package/dist/dom/controllable-select.feat.js +1 -1
  31. package/dist/dom/controllable-select.feat.mjs +1 -1
  32. package/dist/dom/controllable-textarea.feat.js +1 -1
  33. package/dist/dom/controllable-textarea.feat.mjs +1 -1
  34. package/dist/dom/controllable.feat.js +1 -1
  35. package/dist/dom/controllable.feat.mjs +1 -1
  36. package/dist/dom/dynamic-tag-var.feat.js +1 -1
  37. package/dist/dom/dynamic-tag-var.feat.mjs +1 -1
  38. package/dist/dom/placeholder.feat.js +1 -1
  39. package/dist/dom/placeholder.feat.mjs +1 -1
  40. package/dist/{dom-BfydlrCq.js → dom-BNmfm4st.js} +15 -15
  41. package/dist/{dom-UwNQ-AXt.mjs → dom-BsAS26Ze.mjs} +15 -15
  42. package/dist/dom.js +1 -1
  43. package/dist/dom.mjs +1 -1
  44. package/dist/html/inlined-runtimes.d.ts +2 -2
  45. package/dist/html/inlined-runtimes.debug.d.ts +2 -2
  46. package/dist/html/writer.d.ts +3 -1
  47. package/dist/html.js +46 -36
  48. package/dist/html.mjs +46 -36
  49. package/dist/translator/index.js +195 -161
  50. package/dist/translator/util/asset-imports.d.ts +1 -1
  51. package/dist/translator/util/body-to-text-literal.d.ts +1 -1
  52. package/dist/translator/util/get-compile-stage.d.ts +2 -0
  53. package/dist/translator/util/optional.d.ts +1 -0
  54. package/dist/translator/util/references.d.ts +8 -3
  55. package/dist/translator/util/sections.d.ts +24 -6
  56. package/dist/translator/util/serialize-reasons.d.ts +6 -2
  57. package/dist/translator/visitors/program/pre-analyze.d.ts +6 -0
  58. package/package.json +4 -4
@@ -8,6 +8,7 @@ export declare const BranchEndNativeTag = "(";
8
8
  export declare const BranchEndSingleNode = "|";
9
9
  export declare const BranchEndOnlyChildInParent = ")";
10
10
  export declare const BranchEndSingleNodeOnlyChildInParent = "}";
11
+ export declare const ReorderStart = "*";
11
12
  type Self = typeof import("./resume-symbol");
12
13
  export type Value = Self[keyof Self];
13
14
  export {};
@@ -1,5 +1,5 @@
1
1
  "use strict";
2
- const require_control_flow = require("../dom-CA_HiiES.js");
2
+ const require_control_flow = require("../dom-BAGeiafn.js");
3
3
  //#region src/dom/catch.feat.ts
4
4
  const handlePendingTry = (fn, scope, branch) => {
5
5
  while (branch) {
@@ -1,4 +1,4 @@
1
- import { An as ParentBranch, Cn as Scope, Mn as PendingRenders, Sn as Pending, Tn as ClosestBranch, g as renderCatch, jn as PendingEffects, nn as installCatch, rn as placeholderShown, tn as caughtError } from "../dom-DBMLPLeE.mjs";
1
+ import { An as ParentBranch, Cn as Scope, Mn as PendingRenders, Sn as Pending, Tn as ClosestBranch, g as renderCatch, jn as PendingEffects, nn as installCatch, rn as placeholderShown, tn as caughtError } from "../dom-C55iHvof.mjs";
2
2
  //#region src/dom/catch.feat.ts
3
3
  const handlePendingTry = (fn, scope, branch) => {
4
4
  while (branch) {
@@ -1,5 +1,5 @@
1
1
  "use strict";
2
- const require_control_flow = require("../dom-CA_HiiES.js");
2
+ const require_control_flow = require("../dom-BAGeiafn.js");
3
3
  //#region src/dom/controllable-input.feat.ts
4
4
  require_control_flow.controllableScripts[0] = require_control_flow._attr_input_checked_script;
5
5
  require_control_flow.controllableScripts[1] = require_control_flow._attr_input_checkedValue_script;
@@ -1,4 +1,4 @@
1
- import { A as _attr_input_value_script, C as _attr_input_checkedValue_script, T as _attr_input_checked_script, z as controllableScripts } from "../dom-DBMLPLeE.mjs";
1
+ import { A as _attr_input_value_script, C as _attr_input_checkedValue_script, T as _attr_input_checked_script, z as controllableScripts } from "../dom-C55iHvof.mjs";
2
2
  //#region src/dom/controllable-input.feat.ts
3
3
  controllableScripts[0] = _attr_input_checked_script;
4
4
  controllableScripts[1] = _attr_input_checkedValue_script;
@@ -1,5 +1,5 @@
1
1
  "use strict";
2
- const require_control_flow = require("../dom-CA_HiiES.js");
2
+ const require_control_flow = require("../dom-BAGeiafn.js");
3
3
  //#region src/dom/controllable-open.feat.ts
4
4
  require_control_flow.controllableScripts[4] = require_control_flow._attr_details_or_dialog_open_script;
5
5
  //#endregion
@@ -1,4 +1,4 @@
1
- import { y as _attr_details_or_dialog_open_script, z as controllableScripts } from "../dom-DBMLPLeE.mjs";
1
+ import { y as _attr_details_or_dialog_open_script, z as controllableScripts } from "../dom-C55iHvof.mjs";
2
2
  //#region src/dom/controllable-open.feat.ts
3
3
  controllableScripts[4] = _attr_details_or_dialog_open_script;
4
4
  //#endregion
@@ -1,5 +1,5 @@
1
1
  "use strict";
2
- const require_control_flow = require("../dom-CA_HiiES.js");
2
+ const require_control_flow = require("../dom-BAGeiafn.js");
3
3
  //#region src/dom/controllable-select.feat.ts
4
4
  require_control_flow.controllableScripts[3] = require_control_flow._attr_select_value_script;
5
5
  //#endregion
@@ -1,4 +1,4 @@
1
- import { N as _attr_select_value_script, z as controllableScripts } from "../dom-DBMLPLeE.mjs";
1
+ import { N as _attr_select_value_script, z as controllableScripts } from "../dom-C55iHvof.mjs";
2
2
  //#region src/dom/controllable-select.feat.ts
3
3
  controllableScripts[3] = _attr_select_value_script;
4
4
  //#endregion
@@ -1,5 +1,5 @@
1
1
  "use strict";
2
- const require_control_flow = require("../dom-CA_HiiES.js");
2
+ const require_control_flow = require("../dom-BAGeiafn.js");
3
3
  //#region src/dom/controllable-textarea.feat.ts
4
4
  require_control_flow.controllableScripts[2] = require_control_flow._attr_input_value_script;
5
5
  //#endregion
@@ -1,4 +1,4 @@
1
- import { A as _attr_input_value_script, z as controllableScripts } from "../dom-DBMLPLeE.mjs";
1
+ import { A as _attr_input_value_script, z as controllableScripts } from "../dom-C55iHvof.mjs";
2
2
  //#region src/dom/controllable-textarea.feat.ts
3
3
  controllableScripts[2] = _attr_input_value_script;
4
4
  //#endregion
@@ -1,5 +1,5 @@
1
1
  "use strict";
2
- const require_control_flow = require("../dom-CA_HiiES.js");
2
+ const require_control_flow = require("../dom-BAGeiafn.js");
3
3
  require("./controllable-input.feat.js");
4
4
  require("./controllable-open.feat.js");
5
5
  require("./controllable-select.feat.js");
@@ -1,4 +1,4 @@
1
- import { F as _controllable_open, I as _controllable_select, L as _controllable_textarea, P as _controllable_input, R as controllableRenders } from "../dom-DBMLPLeE.mjs";
1
+ import { F as _controllable_open, I as _controllable_select, L as _controllable_textarea, P as _controllable_input, R as controllableRenders } from "../dom-C55iHvof.mjs";
2
2
  import "./controllable-input.feat.mjs";
3
3
  import "./controllable-open.feat.mjs";
4
4
  import "./controllable-select.feat.mjs";
@@ -1,5 +1,5 @@
1
1
  "use strict";
2
- const require_control_flow = require("../dom-CA_HiiES.js");
2
+ const require_control_flow = require("../dom-BAGeiafn.js");
3
3
  //#region src/dom/dynamic-tag-var.feat.ts
4
4
  const elementGetter = (branch) => () => require_control_flow._el_read(branch[require_control_flow.StartNode]);
5
5
  require_control_flow.installDynamicTagVar((branch) => branch[require_control_flow.TagVariable](elementGetter(branch)));
@@ -1,4 +1,4 @@
1
- import { Fn as TagVariable, Pn as StartNode, Zt as DYNAMIC_TAG_VAR_REGISTER_ID, gt as _resume, kt as _el_read, m as installDynamicTagVar } from "../dom-DBMLPLeE.mjs";
1
+ import { Fn as TagVariable, Pn as StartNode, Zt as DYNAMIC_TAG_VAR_REGISTER_ID, gt as _resume, kt as _el_read, m as installDynamicTagVar } from "../dom-C55iHvof.mjs";
2
2
  //#region src/dom/dynamic-tag-var.feat.ts
3
3
  const elementGetter = (branch) => () => _el_read(branch[StartNode]);
4
4
  installDynamicTagVar((branch) => branch[TagVariable](elementGetter(branch)));
@@ -1,5 +1,5 @@
1
1
  "use strict";
2
- const require_control_flow = require("../dom-CA_HiiES.js");
2
+ const require_control_flow = require("../dom-BAGeiafn.js");
3
3
  //#region src/dom/placeholder.feat.ts
4
4
  require_control_flow.registeredValues[require_control_flow.PLACEHOLDER_DISMISS_REGISTER_ID] = (tryBranch) => {
5
5
  if (tryBranch["#PlaceholderBranch"]) {
@@ -1,4 +1,4 @@
1
- import { Ct as registeredValues, Kt as destroyBranch, Nn as PlaceholderBranch, Qt as PLACEHOLDER_DISMISS_REGISTER_ID } from "../dom-DBMLPLeE.mjs";
1
+ import { Ct as registeredValues, Kt as destroyBranch, Nn as PlaceholderBranch, Qt as PLACEHOLDER_DISMISS_REGISTER_ID } from "../dom-C55iHvof.mjs";
2
2
  //#region src/dom/placeholder.feat.ts
3
3
  registeredValues[PLACEHOLDER_DISMISS_REGISTER_ID] = (tryBranch) => {
4
4
  if (tryBranch["#PlaceholderBranch"]) {
@@ -909,13 +909,14 @@ function init(runtimeId = "M") {
909
909
  const render = curRenders[renderId] = renders[renderId] || renders(renderId);
910
910
  const walk = render.w;
911
911
  const scopeLookup = {};
912
+ const pending = [];
912
913
  const getScope = (id) => scopeLookup[id] || (+id ? initScope(scopeLookup[id] = { ["#Id"]: +id }) : initGlobal());
913
914
  const initGlobal = () => scopeLookup[0] ||= {
914
915
  runtimeId,
915
916
  renderId
916
917
  };
917
918
  const initScope = (scope) => {
918
- scope[Gen$1] = 1;
919
+ scope[Gen$1] ??= 1;
919
920
  scope[Global] = initGlobal();
920
921
  if (branchesEnabled && scope["#ClosestBranchId"]) scope[ClosestBranch] = getScope(scope[ClosestBranchId]);
921
922
  return scope;
@@ -933,11 +934,16 @@ function init(runtimeId = "M") {
933
934
  }
934
935
  };
935
936
  const serializeContext = ((data, registryId) => typeof data === "number" ? registryId ? registeredValues[registryId](getScope(data)) : getScope(data) : applyScopes(data));
936
- const createVisitBranches = (branchScopesStack = [], branchStarts = [], orphanBranches = [], deferredOwners = [], curBranchScopes) => {
937
- return (branchId, branch, endedBranches, accessor, singleNode, parent = visit.parentNode, startVisit = visit, i = orphanBranches.length, j = deferredOwners.length) => {
937
+ const createVisitBranches = (branchScopesStack = [], branchStarts = [], curBranchScopes, reorderBranch, reorderDepth = 0, adopt = (scope, branch) => scope["#ClosestBranch"] === scope ? scope !== branch && setParentBranch(scope, branch) : scope[ClosestBranch] = branch) => {
938
+ return (branchId, branch, endedBranches, accessor, nodeAccessor, singleNode, parent = visit.parentNode, startVisit = visit) => {
939
+ if (visitType === "*") {
940
+ while (reorderBranch && pending.length >= reorderDepth) adopt(pending.pop(), reorderBranch);
941
+ if (reorderBranch = +lastToken && visitScope) reorderDepth = pending.push(reorderBranch);
942
+ return;
943
+ }
938
944
  if (visitType !== "[") {
939
945
  visitScope[nextToken()] = visitType === ")" || visitType === "}" ? parent : visit;
940
- accessor = BranchScopes$1 + lastToken;
946
+ accessor = BranchScopes$1 + (nodeAccessor = lastToken);
941
947
  singleNode = visitType !== "]" && visitType !== ")";
942
948
  nextToken();
943
949
  }
@@ -951,6 +957,7 @@ function init(runtimeId = "M") {
951
957
  branch[EndNode] = branch[StartNode] = startVisit;
952
958
  if (visitType === "(") branch[getDebugKey(0, startVisit)] = startVisit;
953
959
  } else {
960
+ branch[BranchAccessor] = nodeAccessor;
954
961
  curBranchScopes = push(curBranchScopes, branch);
955
962
  if (accessor) {
956
963
  visitScope[accessor] = curBranchScopes;
@@ -962,19 +969,11 @@ function init(runtimeId = "M") {
962
969
  branch[StartNode] = startVisit;
963
970
  branch[EndNode] = visit.previousSibling === startVisit ? startVisit : parent.insertBefore(new Text(), visit);
964
971
  }
965
- while (i && orphanBranches[i - 1]["#Id"] > branchId) {
966
- i--;
967
- setParentBranch(orphanBranches.pop(), branch);
968
- }
969
- while (j && deferredOwners[j - 1]["#Id"] > branchId) {
970
- j--;
971
- const owner = deferredOwners.pop();
972
- if (owner["#ClosestBranch"] !== owner) owner[ClosestBranch] = branch;
973
- }
972
+ while (pending.at(-1)?.["#Id"] >= branchId) adopt(pending.pop(), branch);
974
973
  nextToken();
975
974
  }
976
975
  if (endedBranches) {
977
- for (const ended of endedBranches) orphanBranches.push(ended);
976
+ for (const ended of endedBranches) pending.push(ended);
978
977
  if (singleNode) visitScope[accessor] = endedBranches.length > 1 ? endedBranches.reverse() : endedBranches[0];
979
978
  }
980
979
  if (visitType === "[") {
@@ -983,7 +982,7 @@ function init(runtimeId = "M") {
983
982
  curBranchScopes = void 0;
984
983
  }
985
984
  branchStarts.push(visit);
986
- } else deferredOwners.push(visitScope);
985
+ } else pending.push(visitScope);
987
986
  };
988
987
  };
989
988
  const nextToken = () => lastToken = visitText.slice(lastTokenIndex, (lastTokenIndex = visitText.indexOf(" ", lastTokenIndex) + 1 || visitText.length + 1) - 1);
@@ -1039,12 +1038,21 @@ function init(runtimeId = "M") {
1039
1038
  else {
1040
1039
  visitScope[nextToken()] = htmlStart;
1041
1040
  visitScope[DynamicHTMLLastChild + lastToken] = visit;
1041
+ if ((branchesEnabled || lazyEnabled) && pending[pending.length - 1] !== visitScope) pending.push(visitScope);
1042
1042
  }
1043
1043
  else if (branchesEnabled && visitType > "'") (visitBranches ||= createVisitBranches())();
1044
1044
  else if (lazyEnabled && render.b && visitType > "%") visits[retained++] = visit;
1045
- else visitScope[nextToken()] = visitType === "$" ? visit.previousSibling : visit.parentNode.insertBefore(new Text(), visit);
1045
+ else {
1046
+ visitScope[nextToken()] = visitType === "%" ? visit.parentNode.insertBefore(new Text(), visit) : visit.previousSibling;
1047
+ if ((branchesEnabled || lazyEnabled) && pending[pending.length - 1] !== visitScope) pending.push(visitScope);
1048
+ }
1049
+ }
1050
+ if (branchesEnabled && visitBranches) {
1051
+ visitType = "*";
1052
+ lastToken = "";
1053
+ visitBranches();
1046
1054
  }
1047
- if (embedRenders && !embedAnchor && visit) embedRenders.set(embedAnchor = visit.parentNode.insertBefore(new Text(), visit.nextSibling), [renderId, scopeLookup]);
1055
+ if (embedRenders && !embedAnchor && visit?.parentNode) embedRenders.set(embedAnchor = visit.parentNode.insertBefore(new Text(), visit.nextSibling), [renderId, scopeLookup]);
1048
1056
  visits.length = retained;
1049
1057
  return effects;
1050
1058
  };
@@ -908,13 +908,14 @@ function init(runtimeId = "M") {
908
908
  const render = curRenders[renderId] = renders[renderId] || renders(renderId);
909
909
  const walk = render.w;
910
910
  const scopeLookup = {};
911
+ const pending = [];
911
912
  const getScope = (id) => scopeLookup[id] || (+id ? initScope(scopeLookup[id] = { ["#Id"]: +id }) : initGlobal());
912
913
  const initGlobal = () => scopeLookup[0] ||= {
913
914
  runtimeId,
914
915
  renderId
915
916
  };
916
917
  const initScope = (scope) => {
917
- scope[Gen$1] = 1;
918
+ scope[Gen$1] ??= 1;
918
919
  scope[Global] = initGlobal();
919
920
  if (branchesEnabled && scope["#ClosestBranchId"]) scope[ClosestBranch] = getScope(scope[ClosestBranchId]);
920
921
  return scope;
@@ -932,11 +933,16 @@ function init(runtimeId = "M") {
932
933
  }
933
934
  };
934
935
  const serializeContext = ((data, registryId) => typeof data === "number" ? registryId ? registeredValues[registryId](getScope(data)) : getScope(data) : applyScopes(data));
935
- const createVisitBranches = (branchScopesStack = [], branchStarts = [], orphanBranches = [], deferredOwners = [], curBranchScopes) => {
936
- return (branchId, branch, endedBranches, accessor, singleNode, parent = visit.parentNode, startVisit = visit, i = orphanBranches.length, j = deferredOwners.length) => {
936
+ const createVisitBranches = (branchScopesStack = [], branchStarts = [], curBranchScopes, reorderBranch, reorderDepth = 0, adopt = (scope, branch) => scope["#ClosestBranch"] === scope ? scope !== branch && setParentBranch(scope, branch) : scope[ClosestBranch] = branch) => {
937
+ return (branchId, branch, endedBranches, accessor, nodeAccessor, singleNode, parent = visit.parentNode, startVisit = visit) => {
938
+ if (visitType === "*") {
939
+ while (reorderBranch && pending.length >= reorderDepth) adopt(pending.pop(), reorderBranch);
940
+ if (reorderBranch = +lastToken && visitScope) reorderDepth = pending.push(reorderBranch);
941
+ return;
942
+ }
937
943
  if (visitType !== "[") {
938
944
  visitScope[nextToken()] = visitType === ")" || visitType === "}" ? parent : visit;
939
- accessor = BranchScopes$1 + lastToken;
945
+ accessor = BranchScopes$1 + (nodeAccessor = lastToken);
940
946
  singleNode = visitType !== "]" && visitType !== ")";
941
947
  nextToken();
942
948
  }
@@ -950,6 +956,7 @@ function init(runtimeId = "M") {
950
956
  branch[EndNode] = branch[StartNode] = startVisit;
951
957
  if (visitType === "(") branch[getDebugKey(0, startVisit)] = startVisit;
952
958
  } else {
959
+ branch[BranchAccessor] = nodeAccessor;
953
960
  curBranchScopes = push(curBranchScopes, branch);
954
961
  if (accessor) {
955
962
  visitScope[accessor] = curBranchScopes;
@@ -961,19 +968,11 @@ function init(runtimeId = "M") {
961
968
  branch[StartNode] = startVisit;
962
969
  branch[EndNode] = visit.previousSibling === startVisit ? startVisit : parent.insertBefore(new Text(), visit);
963
970
  }
964
- while (i && orphanBranches[i - 1]["#Id"] > branchId) {
965
- i--;
966
- setParentBranch(orphanBranches.pop(), branch);
967
- }
968
- while (j && deferredOwners[j - 1]["#Id"] > branchId) {
969
- j--;
970
- const owner = deferredOwners.pop();
971
- if (owner["#ClosestBranch"] !== owner) owner[ClosestBranch] = branch;
972
- }
971
+ while (pending.at(-1)?.["#Id"] >= branchId) adopt(pending.pop(), branch);
973
972
  nextToken();
974
973
  }
975
974
  if (endedBranches) {
976
- for (const ended of endedBranches) orphanBranches.push(ended);
975
+ for (const ended of endedBranches) pending.push(ended);
977
976
  if (singleNode) visitScope[accessor] = endedBranches.length > 1 ? endedBranches.reverse() : endedBranches[0];
978
977
  }
979
978
  if (visitType === "[") {
@@ -982,7 +981,7 @@ function init(runtimeId = "M") {
982
981
  curBranchScopes = void 0;
983
982
  }
984
983
  branchStarts.push(visit);
985
- } else deferredOwners.push(visitScope);
984
+ } else pending.push(visitScope);
986
985
  };
987
986
  };
988
987
  const nextToken = () => lastToken = visitText.slice(lastTokenIndex, (lastTokenIndex = visitText.indexOf(" ", lastTokenIndex) + 1 || visitText.length + 1) - 1);
@@ -1038,12 +1037,21 @@ function init(runtimeId = "M") {
1038
1037
  else {
1039
1038
  visitScope[nextToken()] = htmlStart;
1040
1039
  visitScope[DynamicHTMLLastChild + lastToken] = visit;
1040
+ if ((branchesEnabled || lazyEnabled) && pending[pending.length - 1] !== visitScope) pending.push(visitScope);
1041
1041
  }
1042
1042
  else if (branchesEnabled && visitType > "'") (visitBranches ||= createVisitBranches())();
1043
1043
  else if (lazyEnabled && render.b && visitType > "%") visits[retained++] = visit;
1044
- else visitScope[nextToken()] = visitType === "$" ? visit.previousSibling : visit.parentNode.insertBefore(new Text(), visit);
1044
+ else {
1045
+ visitScope[nextToken()] = visitType === "%" ? visit.parentNode.insertBefore(new Text(), visit) : visit.previousSibling;
1046
+ if ((branchesEnabled || lazyEnabled) && pending[pending.length - 1] !== visitScope) pending.push(visitScope);
1047
+ }
1048
+ }
1049
+ if (branchesEnabled && visitBranches) {
1050
+ visitType = "*";
1051
+ lastToken = "";
1052
+ visitBranches();
1045
1053
  }
1046
- if (embedRenders && !embedAnchor && visit) embedRenders.set(embedAnchor = visit.parentNode.insertBefore(new Text(), visit.nextSibling), [renderId, scopeLookup]);
1054
+ if (embedRenders && !embedAnchor && visit?.parentNode) embedRenders.set(embedAnchor = visit.parentNode.insertBefore(new Text(), visit.nextSibling), [renderId, scopeLookup]);
1047
1055
  visits.length = retained;
1048
1056
  return effects;
1049
1057
  };
package/dist/debug/dom.js CHANGED
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
- const require_control_flow = require("./dom-CA_HiiES.js");
3
+ const require_control_flow = require("./dom-BAGeiafn.js");
4
4
  //#region src/common/attr-tag.ts
5
5
  const empty = [];
6
6
  const rest = Symbol("Attribute Tag");
@@ -1,4 +1,4 @@
1
- import { $ as _attrs_script, $t as $signal, A as _attr_input_value_script, At as _for_closure, B as _attr, Bt as _return, C as _attr_input_checkedValue_script, D as _attr_input_value_attribute_default, Dt as _closure_get, E as _attr_input_value, En as EndNode, Et as _closure, F as _controllable_open, Fn as TagVariable, Ft as _id, G as _attr_nonce, Gt as _assert_init, H as _attr_class_item, Ht as _script, I as _controllable_select, It as _if_closure, J as _attr_style_items, Jt as removeAndDestroyBranch, K as _attr_style, Kt as destroyBranch, L as _controllable_textarea, Lt as _let, M as _attr_select_value_default, Mt as _global_read, N as _attr_select_value_script, Nt as _hoist, O as _attr_input_value_default, On as Global, Ot as _const, P as _controllable_input, Pn as StartNode, Pt as _hoist_resume, Q as _attrs_partial_content, Rt as _let_change, S as _attr_input_checkedValue_default, St as readyFailed, T as _attr_input_checked_script, Tt as _child_setup, U as _attr_class_items, Ut as _var, V as _attr_class, Vt as _return_change, W as _attr_content, Wt as _var_change, X as _attrs_content, Xt as _on, Y as _attrs, Yt as syncGen, Z as _attrs_partial, _ as _attr_details_or_dialog_open, _n as _call, _t as _var_resume, a as _for_in, an as queueAsyncRender, at as _text_content, b as _attr_input_checked, bn as Params, bt as initEmbedded, c as _for_until, cn as run, ct as toInsertNode, d as _show, dn as forIn, dt as _content_resume, en as $signalReset, et as _html, f as _try, fn as forOf, ft as createAndSetupBranch, g as renderCatch, gn as _hoist_read_error, gt as _resume, h as patchDynamicTag, hn as _assert_hoist, ht as _el, i as _dynamic_tag_content, in as prepareEffects, it as _text, j as _attr_select_value, jt as _for_selector, k as _attr_input_value_dynamic_default, kn as Load, kt as _el_read, l as _if, ln as runEffects, lt as _content, mn as forUntil, mt as setupBranch, n as _await_promise, nt as _style_rule_item, o as _for_of, on as queueEffect, ot as _to_text, p as addAwaitCounter, pn as forTo, pt as createBranch, q as _attr_style_item, qt as insertBranchBefore, r as _dynamic_tag, rt as _style_shell, s as _for_to, sn as queueRender, st as insertChildNodes, t as _await_content, tt as _lifecycle, u as _resume_dynamic_tag, un as runId, ut as _content_closures, v as _attr_details_or_dialog_open_default, vn as Clone, vt as getRegisteredWithScope, w as _attr_input_checked_default, wt as withLazy, x as _attr_input_checkedValue, xn as Setup, xt as ready, y as _attr_details_or_dialog_open_script, yn as Owner, yt as init, zt as _or } from "./dom-DBMLPLeE.mjs";
1
+ import { $ as _attrs_script, $t as $signal, A as _attr_input_value_script, At as _for_closure, B as _attr, Bt as _return, C as _attr_input_checkedValue_script, D as _attr_input_value_attribute_default, Dt as _closure_get, E as _attr_input_value, En as EndNode, Et as _closure, F as _controllable_open, Fn as TagVariable, Ft as _id, G as _attr_nonce, Gt as _assert_init, H as _attr_class_item, Ht as _script, I as _controllable_select, It as _if_closure, J as _attr_style_items, Jt as removeAndDestroyBranch, K as _attr_style, Kt as destroyBranch, L as _controllable_textarea, Lt as _let, M as _attr_select_value_default, Mt as _global_read, N as _attr_select_value_script, Nt as _hoist, O as _attr_input_value_default, On as Global, Ot as _const, P as _controllable_input, Pn as StartNode, Pt as _hoist_resume, Q as _attrs_partial_content, Rt as _let_change, S as _attr_input_checkedValue_default, St as readyFailed, T as _attr_input_checked_script, Tt as _child_setup, U as _attr_class_items, Ut as _var, V as _attr_class, Vt as _return_change, W as _attr_content, Wt as _var_change, X as _attrs_content, Xt as _on, Y as _attrs, Yt as syncGen, Z as _attrs_partial, _ as _attr_details_or_dialog_open, _n as _call, _t as _var_resume, a as _for_in, an as queueAsyncRender, at as _text_content, b as _attr_input_checked, bn as Params, bt as initEmbedded, c as _for_until, cn as run, ct as toInsertNode, d as _show, dn as forIn, dt as _content_resume, en as $signalReset, et as _html, f as _try, fn as forOf, ft as createAndSetupBranch, g as renderCatch, gn as _hoist_read_error, gt as _resume, h as patchDynamicTag, hn as _assert_hoist, ht as _el, i as _dynamic_tag_content, in as prepareEffects, it as _text, j as _attr_select_value, jt as _for_selector, k as _attr_input_value_dynamic_default, kn as Load, kt as _el_read, l as _if, ln as runEffects, lt as _content, mn as forUntil, mt as setupBranch, n as _await_promise, nt as _style_rule_item, o as _for_of, on as queueEffect, ot as _to_text, p as addAwaitCounter, pn as forTo, pt as createBranch, q as _attr_style_item, qt as insertBranchBefore, r as _dynamic_tag, rt as _style_shell, s as _for_to, sn as queueRender, st as insertChildNodes, t as _await_content, tt as _lifecycle, u as _resume_dynamic_tag, un as runId, ut as _content_closures, v as _attr_details_or_dialog_open_default, vn as Clone, vt as getRegisteredWithScope, w as _attr_input_checked_default, wt as withLazy, x as _attr_input_checkedValue, xn as Setup, xt as ready, y as _attr_details_or_dialog_open_script, yn as Owner, yt as init, zt as _or } from "./dom-C55iHvof.mjs";
2
2
  //#region src/common/attr-tag.ts
3
3
  const empty = [];
4
4
  const rest = Symbol("Attribute Tag");
@@ -28,7 +28,6 @@ const ControlledHandler = "ControlledHandler:";
28
28
  const ControlledType = "ControlledType:";
29
29
  const ControlledValue = "ControlledValue:";
30
30
  const EventAttributes = "EventAttributes:";
31
- const BranchAccessor = "#BranchAccessor";
32
31
  const CatchContent = "#CatchContent";
33
32
  const ClosestBranchId = "#ClosestBranchId";
34
33
  const LoopKey = "#LoopKey";
@@ -1850,11 +1849,16 @@ const WALKER_RUNTIME_CODE = `((runtimeId) => (self[runtimeId] ||= (
1850
1849
  x() {},
1851
1850
  w(node, op, id) {
1852
1851
  while ((node = walker.nextNode())) {
1852
+ // Only reorder markers ("#", "!") are ever looked up, so only they are
1853
+ // kept: the lookup lives as long as the page, and every node marker
1854
+ // would otherwise stay referenced in it after resume consumed it.
1853
1855
  doc.x(
1854
1856
  (op =
1855
1857
  (op = node.data) &&
1856
1858
  !op.indexOf(prefix) &&
1857
- ((lookup[(id = op.slice(prefixLen + 1))] = node), op[prefixLen])),
1859
+ ((id = op.slice(prefixLen + 1)),
1860
+ (op = op[prefixLen]) > "#" || (lookup[id] = node),
1861
+ op)),
1858
1862
  id,
1859
1863
  node,
1860
1864
  );
@@ -1898,6 +1902,7 @@ const REORDER_RUNTIME_CODE = `((runtime) => {
1898
1902
  (placeholderRoot = placeholders[id] =
1899
1903
  {
1900
1904
  i: runtime.l[id] ? 1 : 2,
1905
+ r: id,
1901
1906
  // Resume may still walk markers inside the dropped placeholder, so
1902
1907
  // park it in any detached parent (a bare <t> clone is the cheapest).
1903
1908
  c(start = runtime.l["^" + id], removed = node.cloneNode()) {
@@ -1913,6 +1918,9 @@ const REORDER_RUNTIME_CODE = `((runtime) => {
1913
1918
  replace(id, node);
1914
1919
  },
1915
1920
  });
1921
+ // Opens the chunk's visits for resume to parent to the root's branch; the
1922
+ // walk that this chunk's own script triggers closes it.
1923
+ runtime.v.push({ data: runtime.i + "*" + placeholder.r });
1916
1924
  // repurpose "op" for callbacks ...carefully
1917
1925
  if ((op = runtime.j[id])) {
1918
1926
  placeholderCb = placeholder.c;
@@ -1983,8 +1991,8 @@ const kIsAsync = Symbol("Is Async");
1983
1991
  function isInResumedBranch() {
1984
1992
  return $chunk?.context?.[kBranchId] !== void 0;
1985
1993
  }
1986
- function withBranchId(branchId, cb) {
1987
- return withContext(kBranchId, branchId, cb);
1994
+ function withBranchId(branchId, cb, cbValue) {
1995
+ return withContext(kBranchId, branchId, cb, cbValue);
1988
1996
  }
1989
1997
  function withIsAsync(cb, value) {
1990
1998
  return withContext(kIsAsync, true, cb, value);
@@ -1995,8 +2003,8 @@ function _html(html) {
1995
2003
  function writeScript(script) {
1996
2004
  $chunk.writeScript(script);
1997
2005
  }
1998
- function _script(scopeId, registryId) {
1999
- if ($chunk.serializeState.readyId || $chunk.context?.[kIsAsync]) _resume_branch(scopeId);
2006
+ function _script(scopeId, registryId, serializeMarker) {
2007
+ if (serializeMarker === 0 && ($chunk.serializeState.readyId || $chunk.context?.[kIsAsync])) _resume_branch(scopeId);
2000
2008
  $chunk.boundary.state.needsMainRuntime = true;
2001
2009
  $chunk.writeEffect(scopeId, registryId);
2002
2010
  }
@@ -2186,6 +2194,7 @@ let writeScope = (scopeId, partialScope) => {
2186
2194
  const scope = scopeWithId(state, scopeId);
2187
2195
  const pending = target.writeScopes[scopeId];
2188
2196
  state.needsMainRuntime = true;
2197
+ countResumeWrite($chunk.boundary);
2189
2198
  Object.assign(scope, partialScope);
2190
2199
  if (pending && pending !== partialScope) Object.assign(pending, partialScope);
2191
2200
  else target.writeScopes[scopeId] = partialScope;
@@ -2257,7 +2266,7 @@ function _await(scopeId, accessor, promise, content, serializeMarker) {
2257
2266
  if (resumeMarker) {
2258
2267
  const branchId = _peek_scope_id();
2259
2268
  $chunk.writeHTML($chunk.boundary.state.mark("[", ""));
2260
- content(promise);
2269
+ withBranchId(branchId, content, promise);
2261
2270
  $chunk.writeHTML($chunk.boundary.state.mark("]", scopeId + " " + accessor + " " + branchId));
2262
2271
  } else content(promise);
2263
2272
  return;
@@ -2279,7 +2288,7 @@ function _await(scopeId, accessor, promise, content, serializeMarker) {
2279
2288
  if (resumeMarker) {
2280
2289
  const branchId = _peek_scope_id();
2281
2290
  $chunk.writeHTML($chunk.boundary.state.mark("[", ""));
2282
- withIsAsync(content, value);
2291
+ withBranchId(branchId, () => withIsAsync(content, value));
2283
2292
  $chunk.writeHTML($chunk.boundary.state.mark("]", scopeId + " " + accessor + " " + branchId));
2284
2293
  } else withIsAsync(content, value);
2285
2294
  });
@@ -2296,16 +2305,19 @@ function _try(scopeId, accessor, content, input) {
2296
2305
  const placeholderContent = normalizeDynamicRenderer(input.placeholder);
2297
2306
  const placeholderBranchId = placeholderContent ? _scope_id() : 0;
2298
2307
  const branchId = _peek_scope_id();
2299
- $chunk.writeHTML($chunk.boundary.state.mark("[", ""));
2300
- if (catchContent !== void 0) tryCatch(placeholderContent ? () => tryPlaceholder(content, placeholderContent, branchId, scopeId, placeholderBranchId) : content, catchContent || (() => {}));
2301
- else if (placeholderContent) tryPlaceholder(content, placeholderContent, branchId, scopeId, placeholderBranchId);
2302
- else content();
2303
- writeScope(branchId, {
2304
- [BranchAccessor]: accessor,
2305
- [CatchContent]: catchContent,
2306
- [PlaceholderContent]: placeholderContent
2307
- });
2308
- $chunk.writeHTML($chunk.boundary.state.mark("]", scopeId + " " + accessor + " " + branchId));
2308
+ const chunk = $chunk;
2309
+ const { boundary } = chunk;
2310
+ const { state } = boundary;
2311
+ const { resumeWrites } = boundary;
2312
+ const beforeBranch = deferBranchStart(chunk);
2313
+ let renderersAtSettle = false;
2314
+ if (catchContent !== void 0 || placeholderContent) renderersAtSettle = tryBoundary(placeholderContent ? () => tryPlaceholder(content, placeholderContent, branchId, scopeId, placeholderBranchId) : content, catchContent, placeholderContent, branchId);
2315
+ else withBranchId(branchId, content);
2316
+ const rendered = chunk !== $chunk || boundary.resumeWrites !== resumeWrites;
2317
+ applyBranchStart(chunk, beforeBranch, rendered);
2318
+ if (!rendered) return;
2319
+ if (!renderersAtSettle) writeTryRenderers(branchId, catchContent, placeholderContent);
2320
+ $chunk.writeHTML(state.mark("]", scopeId + " " + accessor + " " + branchId));
2309
2321
  }
2310
2322
  function tryPlaceholder(content, placeholder, branchId, scopeId, placeholderBranchId) {
2311
2323
  const chunk = $chunk;
@@ -2324,31 +2336,39 @@ function tryPlaceholder(content, placeholder, branchId, scopeId, placeholderBran
2324
2336
  placeholderBranchId
2325
2337
  };
2326
2338
  }
2327
- function tryCatch(content, catchContent) {
2339
+ function tryBoundary(content, catchContent, placeholderContent, branchId) {
2328
2340
  const chunk = $chunk;
2329
2341
  const { boundary } = chunk;
2330
2342
  const { state } = boundary;
2331
2343
  const catchBoundary = new Boundary(state, boundary.signal, boundary);
2332
2344
  const body = chunk.fork(catchBoundary, null);
2333
- const bodyEnd = body.render(content);
2345
+ const bodyEnd = withBranchId(branchId, () => body.render(content));
2334
2346
  if (catchBoundary.signal.aborted) {
2335
- catchContent(catchBoundary.signal.reason);
2336
- return;
2347
+ if (catchContent === void 0) boundary.abort(catchBoundary.signal.reason);
2348
+ else if (catchContent) catchContent(catchBoundary.signal.reason);
2349
+ return false;
2337
2350
  }
2338
2351
  if (body === bodyEnd) {
2339
2352
  chunk.append(body);
2340
- return;
2353
+ return false;
2341
2354
  }
2342
- const reorderId = state.nextReorderId();
2343
- const endMarker = state.mark("!", reorderId);
2344
- const bodyNext = bodyEnd.next = $chunk = body.fork(boundary, chunk.next);
2355
+ const renderersAtSettle = !catchBoundary.resumeWrites;
2356
+ const bodyNext = bodyEnd.next = $chunk = chunk.fork(boundary, chunk.next);
2345
2357
  chunk.next = body;
2346
- chunk.writeHTML(state.mark("!^", reorderId));
2347
- bodyEnd.writeHTML(endMarker);
2348
2358
  boundary.startAsync();
2359
+ const reorderId = catchContent === void 0 ? "" : state.nextReorderId();
2360
+ const endMarker = reorderId && state.mark("!", reorderId);
2361
+ if (reorderId) {
2362
+ chunk.writeHTML(state.mark("!^", reorderId));
2363
+ bodyEnd.writeHTML(endMarker);
2364
+ }
2349
2365
  catchBoundary.onNext = () => {
2350
2366
  if (boundary.signal.aborted) return;
2351
2367
  if (catchBoundary.signal.aborted) {
2368
+ if (!reorderId) {
2369
+ boundary.abort(catchBoundary.signal.reason);
2370
+ return;
2371
+ }
2352
2372
  if (!bodyEnd.consumed) {
2353
2373
  let cur = body;
2354
2374
  let writeMarker = true;
@@ -2368,15 +2388,28 @@ function tryCatch(content, catchContent) {
2368
2388
  } while (cur !== bodyNext);
2369
2389
  }
2370
2390
  const catchChunk = chunk.fork(boundary, null);
2391
+ const { resumeWrites } = boundary;
2371
2392
  catchChunk.reorderId = reorderId;
2372
- catchChunk.render(catchContent, catchBoundary.signal.reason);
2393
+ if ((catchChunk.render(catchContent || NOOP$2, catchBoundary.signal.reason) !== catchChunk || boundary.resumeWrites !== resumeWrites) && renderersAtSettle) catchChunk.render(() => writeTryRenderers(branchId, catchContent, placeholderContent));
2373
2394
  state.reorder(catchChunk);
2374
2395
  boundary.endAsync();
2375
- } else if (!catchBoundary.count) boundary.endAsync();
2376
- else boundary.onNext();
2396
+ } else if (!catchBoundary.count) {
2397
+ if (renderersAtSettle && catchBoundary.resumeWrites) bodyEnd.render(() => writeTryRenderers(branchId, catchContent, placeholderContent));
2398
+ boundary.endAsync();
2399
+ } else boundary.onNext();
2377
2400
  };
2401
+ return renderersAtSettle;
2402
+ }
2403
+ function writeTryRenderers(branchId, catchContent, placeholderContent) {
2404
+ writeScope(branchId, {
2405
+ [CatchContent]: catchContent,
2406
+ [PlaceholderContent]: placeholderContent
2407
+ });
2378
2408
  }
2379
2409
  const NOOP$2 = () => {};
2410
+ function countResumeWrite(boundary) {
2411
+ for (; boundary; boundary = boundary.parent) boundary.resumeWrites++;
2412
+ }
2380
2413
  var State = class {
2381
2414
  tagId = 1;
2382
2415
  scopeId = 1;
@@ -2444,6 +2477,7 @@ var State = class {
2444
2477
  var Boundary = class extends AbortController {
2445
2478
  onNext = NOOP$2;
2446
2479
  count = 0;
2480
+ resumeWrites = 0;
2447
2481
  state;
2448
2482
  parent;
2449
2483
  constructor(state, signal, parent) {
@@ -2502,6 +2536,7 @@ var Chunk = class Chunk {
2502
2536
  this.html += html;
2503
2537
  }
2504
2538
  writeEffect(scopeId, registryId) {
2539
+ countResumeWrite(this.boundary);
2505
2540
  if (this.lastEffect === registryId) this.effects += " " + scopeId;
2506
2541
  else {
2507
2542
  this.lastEffect = registryId;
@@ -2660,6 +2695,8 @@ var Chunk = class Chunk {
2660
2695
  needsWalk = true;
2661
2696
  state.resumes = state.resumes ? state.resumes + ",\"" + effects + "\"" : "\"" + effects + "\"";
2662
2697
  }
2698
+ let reordered = "";
2699
+ let needsResumeArray = false;
2663
2700
  if (state.writeReorders) {
2664
2701
  let carried = null;
2665
2702
  for (const reorderedChunk of state.writeReorders) {
@@ -2703,14 +2740,11 @@ var Chunk = class Chunk {
2703
2740
  else break;
2704
2741
  }
2705
2742
  if (reorderEffects) {
2706
- if (!state.hasWrittenResume) {
2707
- state.hasWrittenResume = true;
2708
- scripts = concatScripts(scripts, runtimePrefix + ".r=[]");
2709
- }
2743
+ needsResumeArray = true;
2710
2744
  reorderScripts = concatScripts(reorderScripts, "_.push(\"" + reorderEffects + "\")");
2711
2745
  }
2712
- for (const reservation of readyReservations) scripts = concatScripts(scripts, reservation);
2713
- scripts = concatScripts(scripts, reorderScripts && runtimePrefix + ".j" + toAccess(reorderId) + "=_=>{" + reorderScripts + "}");
2746
+ for (const reservation of readyReservations) reordered = concatScripts(reordered, reservation);
2747
+ reordered = concatScripts(reordered, reorderScripts && runtimePrefix + ".j" + toAccess(reorderId) + "=_=>{" + reorderScripts + "}");
2714
2748
  html += "<t hidden " + state.commentPrefix + "=" + reorderId + ">" + reorderHTML + "</t>";
2715
2749
  }
2716
2750
  state.writeReorders = carried;
@@ -2721,6 +2755,11 @@ var Chunk = class Chunk {
2721
2755
  state.hasWrittenResume = true;
2722
2756
  scripts = concatScripts(scripts, runtimePrefix + ".r=[" + state.resumes + "]");
2723
2757
  }
2758
+ else if (needsResumeArray && !state.hasWrittenResume) {
2759
+ state.hasWrittenResume = true;
2760
+ scripts = concatScripts(scripts, runtimePrefix + ".r=[]");
2761
+ }
2762
+ scripts = concatScripts(scripts, reordered);
2724
2763
  if (needsWalk) scripts = concatScripts(scripts, runtimePrefix + ".w()");
2725
2764
  this.html = html;
2726
2765
  this.scripts = scripts;