marko 6.3.53 → 6.3.55

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 (79) hide show
  1. package/cheatsheet.md +1 -0
  2. package/dist/common/constants/renderer-prop.d.ts +0 -1
  3. package/dist/common/constants/renderer-prop.debug.d.ts +0 -1
  4. package/dist/common/helpers.d.ts +1 -0
  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/placeholder.feat.js +1 -1
  22. package/dist/debug/dom/placeholder.feat.mjs +1 -1
  23. package/dist/debug/{dom-CBLlE8L-.js → dom-CI0Vojyk.js} +119 -78
  24. package/dist/debug/{dom-DQCODUa1.mjs → dom-tl43c2wO.mjs} +102 -79
  25. package/dist/debug/dom.js +9 -7
  26. package/dist/debug/dom.mjs +7 -8
  27. package/dist/debug/html.js +51 -25
  28. package/dist/debug/html.mjs +51 -25
  29. package/dist/dom/catch.feat.js +4 -4
  30. package/dist/dom/catch.feat.mjs +1 -1
  31. package/dist/dom/control-flow.d.ts +4 -1
  32. package/dist/dom/controllable-input.feat.js +2 -2
  33. package/dist/dom/controllable-input.feat.mjs +1 -1
  34. package/dist/dom/controllable-open.feat.js +2 -2
  35. package/dist/dom/controllable-open.feat.mjs +1 -1
  36. package/dist/dom/controllable-select.feat.js +2 -2
  37. package/dist/dom/controllable-select.feat.mjs +1 -1
  38. package/dist/dom/controllable-textarea.feat.js +2 -2
  39. package/dist/dom/controllable-textarea.feat.mjs +1 -1
  40. package/dist/dom/controllable.feat.js +2 -2
  41. package/dist/dom/controllable.feat.mjs +1 -1
  42. package/dist/dom/dynamic-tag-script.feat.js +2 -2
  43. package/dist/dom/dynamic-tag-script.feat.mjs +1 -1
  44. package/dist/dom/dynamic-tag-var.feat.js +1 -1
  45. package/dist/dom/dynamic-tag-var.feat.mjs +1 -1
  46. package/dist/dom/load.d.ts +2 -2
  47. package/dist/dom/placeholder.feat.js +3 -3
  48. package/dist/dom/placeholder.feat.mjs +1 -1
  49. package/dist/dom/renderer.d.ts +2 -3
  50. package/dist/dom/signals.d.ts +1 -1
  51. package/dist/{dom-z4IMlmeO.mjs → dom-4udEPZaj.mjs} +71 -58
  52. package/dist/{dom-vuB05Hnj.js → dom-C1mr-TA7.js} +199 -176
  53. package/dist/dom.d.ts +1 -1
  54. package/dist/dom.js +40 -42
  55. package/dist/dom.mjs +6 -8
  56. package/dist/html/dynamic-tag.d.ts +2 -1
  57. package/dist/html/serializer.d.ts +3 -2
  58. package/dist/html/writer.d.ts +6 -5
  59. package/dist/html.js +34 -19
  60. package/dist/html.mjs +34 -19
  61. package/dist/translator/index.js +2890 -2688
  62. package/dist/translator/util/binding-has-prop.d.ts +1 -0
  63. package/dist/translator/util/branch-tag.d.ts +6 -1
  64. package/dist/translator/util/optional.d.ts +2 -0
  65. package/dist/translator/util/references.d.ts +20 -9
  66. package/dist/translator/util/runtime.d.ts +1 -0
  67. package/dist/translator/util/sections.d.ts +11 -6
  68. package/dist/translator/util/serialize-guard.d.ts +1 -1
  69. package/dist/translator/util/serialize-reasons.d.ts +3 -0
  70. package/dist/translator/util/set-tag-sections-downstream.d.ts +1 -1
  71. package/dist/translator/util/signals.d.ts +4 -1
  72. package/dist/translator/util/structure.d.ts +1 -1
  73. package/dist/translator/util/tag-name-type.d.ts +1 -1
  74. package/dist/translator/visitors/function.d.ts +1 -0
  75. package/dist/translator/visitors/import-declaration.d.ts +1 -0
  76. package/dist/translator/visitors/tag/custom-tag.d.ts +5 -0
  77. package/package.json +4 -4
  78. package/tags/try.d.marko +2 -0
  79. package/tags-html.d.ts +6 -0
@@ -58,7 +58,6 @@ const Params = "params";
58
58
  const Owner = "owner";
59
59
  const Accessor = "accessor";
60
60
  const LocalClosures = "localClosures";
61
- const LocalClosureValues = "localClosureValues";
62
61
  //#endregion
63
62
  //#region src/common/helpers.ts
64
63
  const htmlAttrNameReg = /^[^a-z_]|[^a-z0-9._:-]/i;
@@ -730,20 +729,24 @@ function _closure(...closureSignals) {
730
729
  }
731
730
  };
732
731
  }
733
- function _closure_get(valueAccessor, fn, getOwnerScope, resumeId) {
734
- const closureSignal = ((scope) => {
732
+ function _closure_get(valueAccessor, fn, getOwnerScope, resumeId, ownerValueAccessor) {
733
+ const closureSignal = ((scope, resumed) => {
734
+ const ownerScope = getOwnerScope ? getOwnerScope(scope) : scope["_"];
735
735
  scope[closureSignal[SignalIndexAccessor]] = closureSignal[Index];
736
- fn(scope);
737
- subscribeToScopeSet(getOwnerScope ? getOwnerScope(scope) : scope["_"], closureSignal[ScopeInstancesAccessor], scope);
736
+ if (!resumed || ownerValueAccessor in ownerScope) fn(scope);
737
+ subscribeToScopeSet(ownerScope, closureSignal[ScopeInstancesAccessor], scope);
738
738
  });
739
739
  closureSignal[ScopeInstancesAccessor] = ClosureScopes + valueAccessor;
740
740
  closureSignal[SignalIndexAccessor] = ClosureSignalIndex + valueAccessor;
741
- if (resumeId) _resumed[resumeId] = closureSignal;
741
+ if (resumeId) {
742
+ ownerValueAccessor = valueAccessor;
743
+ _resumed[resumeId] = (scope) => closureSignal(scope, 1);
744
+ }
742
745
  return closureSignal;
743
746
  }
744
747
  function _child_setup(setup) {
745
748
  setup._ = (scope, owner) => {
746
- scope["_"] = owner;
749
+ scope["_"] ||= owner;
747
750
  queueRender(scope, setup, -1);
748
751
  };
749
752
  return setup;
@@ -787,8 +790,9 @@ function _el_read(value) {
787
790
  }
788
791
  function* traverse(scope, path, args, i = path.length - 1) {
789
792
  if (rendering) _hoist_read_error();
790
- if (scope) if (Symbol.iterator in scope) for (const childScope of scope.values()) yield* traverse(childScope, path, args, i);
791
- else {
793
+ if (scope) if (Symbol.iterator in scope) {
794
+ for (const childScope of scope.values()) if (childScope["#Gen"] !== 0) yield* traverse(childScope, path, args, i);
795
+ } else {
792
796
  const item = scope[path[i]];
793
797
  if (i) yield* traverse(item, path, args, i - 1);
794
798
  else yield typeof item === "function" ? item(...args) : item;
@@ -1128,7 +1132,7 @@ function _content(id, template, walks, setup, params, dynamicScopesAccessor) {
1128
1132
  } : (branch) => {
1129
1133
  walk(branch[StartNode] = branch[EndNode] = new Text(), walks, branch);
1130
1134
  };
1131
- return (owner) => {
1135
+ return _resumed[id] = (owner) => {
1132
1136
  return {
1133
1137
  ["id"]: id,
1134
1138
  [Clone]: clone,
@@ -1139,16 +1143,29 @@ function _content(id, template, walks, setup, params, dynamicScopesAccessor) {
1139
1143
  };
1140
1144
  };
1141
1145
  }
1142
- function _content_resume(id, template, walks, setup, params, dynamicScopesAccessor) {
1143
- return _resumed[id] = _content(id, template, walks, setup, params, dynamicScopesAccessor);
1146
+ function _content_resume(renderer, hasLocalValues = 0) {
1147
+ return _resumed[renderer()["id"]] = (owner, ...values) => {
1148
+ for (let i = values.length, scope = owner; i > hasLocalValues;) {
1149
+ const closures = values[--i];
1150
+ for (const key in closures) if (!(key in scope)) scope[key] = closures[key];
1151
+ scope = scope["_"];
1152
+ }
1153
+ return renderer(owner, values[hasLocalValues - 1]);
1154
+ };
1144
1155
  }
1145
1156
  function _content_closures(renderer, closureFns) {
1146
1157
  const closureSignals = {};
1147
1158
  for (const key in closureFns) closureSignals[key] = _const(key, closureFns[key]);
1148
1159
  return (owner, closureValues) => {
1149
1160
  const instance = renderer(owner);
1150
- instance[LocalClosures] = closureSignals;
1151
- instance[LocalClosureValues] = closureValues;
1161
+ const clone = instance[Clone];
1162
+ const setClosures = instance[LocalClosures] = (branch) => {
1163
+ for (const key in closureSignals) closureSignals[key](branch, closureValues[key]);
1164
+ };
1165
+ instance[Clone] = (branch, ns) => {
1166
+ clone(branch, ns);
1167
+ setClosures(branch);
1168
+ };
1152
1169
  return instance;
1153
1170
  };
1154
1171
  }
@@ -1293,7 +1310,7 @@ function _attr_content(scope, nodeAccessor, value) {
1293
1310
  setConditionalRenderer(scope, nodeAccessor, content, createAndSetupBranch);
1294
1311
  if (content?.["accessor"]) subscribeToScopeSet(content[Owner], content[Accessor], scope[BranchScopes$1 + nodeAccessor]);
1295
1312
  }
1296
- for (const accessor in content?.[LocalClosures]) content[LocalClosures][accessor](scope[BranchScopes$1 + nodeAccessor], content[LocalClosureValues][accessor]);
1313
+ content?.[LocalClosures]?.(scope[BranchScopes$1 + nodeAccessor]);
1297
1314
  }
1298
1315
  function _attrs_script(scope, nodeAccessor) {
1299
1316
  const el = scope[nodeAccessor];
@@ -1689,18 +1706,20 @@ function _await_promise(nodeAccessor, params) {
1689
1706
  return awaitBranch;
1690
1707
  };
1691
1708
  const awaitPromise = (scope, promise) => {
1692
- if (!isPromise(promise) && scope[promiseAccessor]) promise = Promise.resolve(promise);
1709
+ if (!isPromise(scope[promiseAccessor])) scope[promiseAccessor] = 0;
1693
1710
  let awaitBranch = scope[branchAccessor];
1694
- const tryPlaceholder = findBranchWithKey(scope, PlaceholderContent);
1711
+ const tryPlaceholder = (isPromise(promise) || scope[promiseAccessor]) && findBranchWithKey(scope, "#PlaceholderContent");
1695
1712
  const tryBranch = tryPlaceholder || awaitBranch;
1696
- if (!(isPromise(promise) ? tryBranch : awaitBranch)) {
1697
- scope[promiseAccessor] = () => awaitPromise(scope, promise);
1698
- return;
1699
- }
1700
- if (!isPromise(promise)) {
1701
- resolveAwait(scope, scope[nodeAccessor], promise);
1713
+ if (!tryBranch) {
1714
+ const replay = scope[promiseAccessor] = () => replay === scope[promiseAccessor] && awaitPromise(scope, promise);
1715
+ const awaitCounter = findBranchWithKey(scope, PlaceholderContent)?.[AwaitCounter];
1716
+ if (awaitCounter?.i) {
1717
+ const complete = awaitCounter.c;
1718
+ awaitCounter.c = () => complete() || queueAsyncRender(scope, replay);
1719
+ }
1702
1720
  return;
1703
1721
  }
1722
+ if (!isPromise(promise)) return scope[promiseAccessor] ? awaitPromise(scope, Promise.resolve(promise)) : resolveAwait(scope, scope[nodeAccessor], promise);
1704
1723
  let awaitCounter = tryBranch[AwaitCounter];
1705
1724
  placeholderShown.add(pendingEffects);
1706
1725
  if (!tryPlaceholder && !awaitCounter?.i) awaitCounter = createAwaitCounter(tryBranch, () => {
@@ -1711,7 +1730,7 @@ function _await_promise(nodeAccessor, params) {
1711
1730
  if (detachedParent === anchor.parentNode) anchor.remove();
1712
1731
  else anchor.replaceWith(detachedParent);
1713
1732
  }
1714
- } else dismissPlaceholder(tryBranch);
1733
+ }
1715
1734
  });
1716
1735
  if (!scope[promiseAccessor]) {
1717
1736
  if (awaitBranch) awaitBranch[PendingRenders] ||= [];
@@ -1727,7 +1746,8 @@ function _await_promise(nodeAccessor, params) {
1727
1746
  if (thisPromise === scope[promiseAccessor]) {
1728
1747
  const referenceNode = scope[nodeAccessor];
1729
1748
  scope[promiseAccessor] = 0;
1730
- if (scope["#ClosestBranch"]?.["#Gen"] === 0) {
1749
+ if (!scope[branchAccessor] || scope["#ClosestBranch"]?.["#Gen"] === 0) {
1750
+ if (!scope[branchAccessor]) awaitPromise(scope, data);
1731
1751
  awaitCounter.c();
1732
1752
  run();
1733
1753
  return;
@@ -1774,11 +1794,7 @@ function _await_content(nodeAccessor, template, walks, setup) {
1774
1794
  return (scope) => {
1775
1795
  const pendingScopes = collectScopes(() => (scope[branchAccessor] = createBranch(scope[Global], renderer, scope, scope[nodeAccessor].parentNode))[DetachedAwait] = renderer);
1776
1796
  scope[branchAccessor][PendingScopes] = pendingScopes;
1777
- const resolveSync = scope[promiseAccessor];
1778
- if (typeof resolveSync === "function") {
1779
- scope[promiseAccessor] = 0;
1780
- resolveSync();
1781
- }
1797
+ if (typeof scope[promiseAccessor] === "function") scope[promiseAccessor]();
1782
1798
  };
1783
1799
  }
1784
1800
  function addAwaitCounter(scope, tryBranch = findBranchWithKey(scope, PlaceholderContent)) {
@@ -1904,18 +1920,19 @@ let _dynamic_tag = /*@__PURE__*/ withBranches((nodeAccessor, getContent, getTagV
1904
1920
  return (scope, newRenderer, getInput) => {
1905
1921
  const normalizedRenderer = normalizeDynamicRenderer(newRenderer);
1906
1922
  if (scope[rendererAccessor] !== (scope[rendererAccessor] = rendererKey(normalizedRenderer)) || getContent && !(normalizedRenderer || scope[childScopeAccessor])) {
1907
- setConditionalRenderer(scope, nodeAccessor, normalizedRenderer || (getContent ? getContent(scope) : void 0), createBranchWithTagNameOrRenderer);
1923
+ const renderer = normalizedRenderer || (getContent ? getContent(scope) : void 0);
1924
+ setConditionalRenderer(scope, nodeAccessor, renderer, createBranchWithTagNameOrRenderer);
1908
1925
  if (getTagVar) if (scope[childScopeAccessor]) {
1909
1926
  scope[childScopeAccessor][TagVariable] = (value) => getTagVar()(scope, value);
1910
1927
  if (typeof normalizedRenderer === "string") bindNativeTagVar?.(scope[childScopeAccessor]);
1911
1928
  } else getTagVar()(scope, void 0);
1912
- if (typeof normalizedRenderer === "string") {
1929
+ if (typeof renderer === "string") {
1913
1930
  if (getContent) {
1914
1931
  const content = getContent(scope);
1915
- setConditionalRenderer(scope[childScopeAccessor], `#${normalizedRenderer.toLowerCase()}/0`, content, createAndSetupBranch);
1916
- if (content["accessor"]) subscribeToScopeSet(content[Owner], content[Accessor], scope[childScopeAccessor][`BranchScopes:#${normalizedRenderer.toLowerCase()}/0`]);
1932
+ setConditionalRenderer(scope[childScopeAccessor], `#${renderer.toLowerCase()}/0`, content, createAndSetupBranch);
1933
+ if (content["accessor"]) subscribeToScopeSet(content[Owner], content[Accessor], scope[childScopeAccessor][`BranchScopes:#${renderer.toLowerCase()}/0`]);
1917
1934
  }
1918
- } else if (normalizedRenderer?.["accessor"]) subscribeToScopeSet(normalizedRenderer[Owner], normalizedRenderer[Accessor], scope[childScopeAccessor]);
1935
+ } else if (renderer?.["accessor"]) subscribeToScopeSet(renderer[Owner], renderer[Accessor], scope[childScopeAccessor]);
1919
1936
  }
1920
1937
  if (normalizedRenderer) {
1921
1938
  const childScope = scope[childScopeAccessor];
@@ -1925,7 +1942,7 @@ let _dynamic_tag = /*@__PURE__*/ withBranches((nodeAccessor, getContent, getTagV
1925
1942
  (getContent ? _attrs : _attrs_content)(childScope, nodeAccessor, (inputIsArgs ? args[0] : args) || {}, controllableRenders[childScope[nodeAccessor].tagName]);
1926
1943
  if (childScope["EventAttributes:" + nodeAccessor] || childScope["ControlledHandler:" + nodeAccessor]) queueEffect(childScope, dynamicTagScript);
1927
1944
  } else {
1928
- for (const accessor in normalizedRenderer[LocalClosures]) normalizedRenderer[LocalClosures][accessor](childScope, normalizedRenderer[LocalClosureValues][accessor]);
1945
+ normalizedRenderer[LocalClosures]?.(childScope);
1929
1946
  if (normalizedRenderer["params"]) if (inputIsArgs) normalizedRenderer[Params](childScope, normalizedRenderer._ ? args[0] : args);
1930
1947
  else {
1931
1948
  const inputWithContent = getContent ? {
@@ -1946,7 +1963,7 @@ const _dynamic_tag_content = /*@__PURE__*/ withBranches((nodeAccessor) => {
1946
1963
  setConditionalRenderer(scope, nodeAccessor, renderer, createAndSetupBranch);
1947
1964
  if (renderer?.["accessor"]) subscribeToScopeSet(renderer[Owner], renderer[Accessor], scope[childScopeAccessor]);
1948
1965
  }
1949
- if (renderer) for (const accessor in renderer[LocalClosures]) renderer[LocalClosures][accessor](scope[childScopeAccessor], renderer[LocalClosureValues][accessor]);
1966
+ renderer?.[LocalClosures]?.(scope[childScopeAccessor]);
1950
1967
  };
1951
1968
  });
1952
1969
  let bindNativeTagVar;
@@ -1976,7 +1993,7 @@ function setConditionalRenderer(scope, nodeAccessor, newRenderer, createBranch)
1976
1993
  referenceNode.remove();
1977
1994
  }
1978
1995
  }
1979
- const loop = /*@__PURE__*/ withBranches((forEach) => (nodeAccessor, template, walks, setup, params) => {
1996
+ const loop = /*@__PURE__*/ withBranches((forEach, reorder) => (nodeAccessor, template, walks, setup, params) => {
1980
1997
  const scopesAccessor = BranchScopes$1 + nodeAccessor;
1981
1998
  const keyedScopesAccessor = KeyedScopes + nodeAccessor;
1982
1999
  const renderer = _content("", template, walks, setup)();
@@ -2037,61 +2054,67 @@ const loop = /*@__PURE__*/ withBranches((forEach) => (nodeAccessor, template, wa
2037
2054
  for (let i = start; i <= newEnd; i++) insertBranchBefore(newScopes[i], parentNode, afterReference);
2038
2055
  return;
2039
2056
  }
2040
- const diffLen = newEnd - start + 1;
2041
- const sources = new Array(diffLen);
2042
- const pred = new Array(diffLen);
2043
- const tails = [];
2044
- let tail = -1;
2045
- let lo;
2046
- let hi;
2047
- let mid;
2048
- for (let i = diffLen; i--;) sources[i] = newScopes[start + i]["#LoopIndex"] ?? -1;
2049
- for (let i = 0; i < diffLen; i++) if (~sources[i]) if (tail < 0 || sources[tails[tail]] < sources[i]) {
2050
- if (~tail) pred[i] = tails[tail];
2051
- tails[++tail] = i;
2052
- } else {
2053
- lo = 0;
2054
- hi = tail;
2055
- while (lo < hi) {
2056
- mid = (lo + hi) / 2 | 0;
2057
- if (sources[tails[mid]] < sources[i]) lo = mid + 1;
2058
- else hi = mid;
2059
- }
2060
- if (sources[i] < sources[tails[lo]]) {
2061
- if (lo > 0) pred[i] = tails[lo - 1];
2062
- tails[lo] = i;
2063
- }
2064
- }
2065
- hi = tails[tail];
2066
- lo = tail + 1;
2067
- while (lo-- > 0) {
2068
- tails[lo] = hi;
2069
- hi = pred[hi];
2070
- }
2071
- for (let i = diffLen; i--;) {
2072
- if (~tail && i === tails[tail]) tail--;
2073
- else insertBranchBefore(newScopes[start + i], parentNode, afterReference);
2074
- afterReference = newScopes[start + i][StartNode];
2075
- }
2057
+ reorder(newScopes, start, newEnd, parentNode, afterReference);
2076
2058
  };
2077
2059
  });
2078
2060
  const _for_of = /*@__PURE__*/ loop(([all, by], cb) => {
2079
2061
  by ||= bySecondArg;
2080
2062
  if (typeof by === "string") forOf(all, (item, i) => cb(item[by], [item, i]));
2081
2063
  else forOf(all, (item, i) => cb(by(item, i), [item, i]));
2082
- });
2064
+ }, reorderKeyed);
2083
2065
  const _for_in = /*@__PURE__*/ loop(([obj, by], cb) => {
2084
2066
  by ||= byFirstArg;
2085
2067
  forIn(obj, (key, value) => cb(by(key, value), [key, value]));
2086
- });
2068
+ }, reorderKeyed);
2087
2069
  const _for_to = /*@__PURE__*/ loop(([to, from, step, by], cb) => {
2088
2070
  by ||= byFirstArg;
2089
2071
  forTo(to, from, step, (v) => cb(by(v), [v]));
2090
- });
2072
+ }, reorderKeyed);
2091
2073
  const _for_until = /*@__PURE__*/ loop(([until, from, step, by], cb) => {
2092
2074
  by ||= byFirstArg;
2093
2075
  forUntil(until, from, step, (v) => cb(by(v), [v]));
2094
- });
2076
+ }, reorderKeyed);
2077
+ const _for_of_unkeyed = /*@__PURE__*/ loop(([all], cb) => forOf(all, (item, i) => cb(i, [item, i])));
2078
+ const _for_to_unkeyed = /*@__PURE__*/ loop(([to, from, step], cb) => forTo(to, from, step, (v) => cb(v, [v])));
2079
+ const _for_until_unkeyed = /*@__PURE__*/ loop(([until, from, step], cb) => forUntil(until, from, step, (v) => cb(v, [v])));
2080
+ function reorderKeyed(newScopes, start, newEnd, parentNode, afterReference) {
2081
+ const diffLen = newEnd - start + 1;
2082
+ const sources = new Array(diffLen);
2083
+ const pred = new Array(diffLen);
2084
+ const tails = [];
2085
+ let tail = -1;
2086
+ let lo;
2087
+ let hi;
2088
+ let mid;
2089
+ for (let i = diffLen; i--;) sources[i] = newScopes[start + i]["#LoopIndex"] ?? -1;
2090
+ for (let i = 0; i < diffLen; i++) if (~sources[i]) if (tail < 0 || sources[tails[tail]] < sources[i]) {
2091
+ if (~tail) pred[i] = tails[tail];
2092
+ tails[++tail] = i;
2093
+ } else {
2094
+ lo = 0;
2095
+ hi = tail;
2096
+ while (lo < hi) {
2097
+ mid = (lo + hi) / 2 | 0;
2098
+ if (sources[tails[mid]] < sources[i]) lo = mid + 1;
2099
+ else hi = mid;
2100
+ }
2101
+ if (sources[i] < sources[tails[lo]]) {
2102
+ if (lo > 0) pred[i] = tails[lo - 1];
2103
+ tails[lo] = i;
2104
+ }
2105
+ }
2106
+ hi = tails[tail];
2107
+ lo = tail + 1;
2108
+ while (lo-- > 0) {
2109
+ tails[lo] = hi;
2110
+ hi = pred[hi];
2111
+ }
2112
+ for (let i = diffLen; i--;) {
2113
+ if (~tail && i === tails[tail]) tail--;
2114
+ else insertBranchBefore(newScopes[start + i], parentNode, afterReference);
2115
+ afterReference = newScopes[start + i][StartNode];
2116
+ }
2117
+ }
2095
2118
  function createBranchWithTagNameOrRenderer($global, tagNameOrRenderer, parentScope, parentNode) {
2096
2119
  if (typeof tagNameOrRenderer === "string") assertValidTagName(tagNameOrRenderer);
2097
2120
  const branch = createBranch($global, tagNameOrRenderer, parentScope, parentNode);
@@ -2106,4 +2129,4 @@ function byFirstArg(name) {
2106
2129
  return name;
2107
2130
  }
2108
2131
  //#endregion
2109
- export { _attrs_script as $, $signal as $t, _attr_input_value_script as A, Load as An, _for_closure as At, _attr as B, _return as Bt, _attr_input_checkedValue_script as C, Pending as Cn, readyFailed as Ct, _attr_input_value_attribute_default as D, EndNode as Dn, _closure_get as Dt, _attr_input_value as E, ClosestBranch as En, _closure as Et, _controllable_open as F, StartNode as Fn, _id as Ft, _attr_nonce as G, _assert_init as Gt, _attr_class_item as H, _script as Ht, _controllable_select as I, TagVariable as In, _if_closure as It, _attr_style_items as J, removeAndDestroyBranch as Jt, _attr_style as K, destroyBranch as Kt, _controllable_textarea as L, _let as Lt, _attr_select_value_default as M, PendingEffects as Mn, _global_read as Mt, _attr_select_value_script as N, PendingRenders as Nn, _hoist as Nt, _attr_input_value_default as O, Gen$1 as On, _const as Ot, _controllable_input as P, PlaceholderBranch as Pn, _hoist_resume as Pt, _attrs_partial_content as Q, _on as Qt, controllableRenders as R, _let_change as Rt, _attr_input_checkedValue_default as S, Setup as Sn, ready as St, _attr_input_checked_script as T, AwaitCounter as Tn, _child_setup as Tt, _attr_class_items as U, _var as Ut, _attr_class as V, _return_change as Vt, _attr_content as W, _var_change as Wt, _attrs_content as X, DYNAMIC_TAG_SCRIPT_REGISTER_ID as Xt, _attrs as Y, syncGen as Yt, _attrs_partial as Z, PLACEHOLDER_DISMISS_REGISTER_ID as Zt, _attr_details_or_dialog_open as _, _call as _n, _resumed as _t, _for_in as a, queueAsyncRender as an, _text_content as at, _attr_input_checked as b, Owner as bn, init as bt, _for_until as c, run as cn, toInsertNode as ct, _try as d, forIn as dn, _content_resume as dt, $signalReset as en, _html as et, addAwaitCounter as f, forOf as fn, createAndSetupBranch as ft, renderCatch as g, _hoist_read_error as gn, _resume_dynamic_tag_var as gt, patchDynamicTag as h, _assert_hoist as hn, _el as ht, _dynamic_tag_content as i, prepareEffects as in, _text as it, _attr_select_value as j, ParentBranch as jn, _for_selector as jt, _attr_input_value_dynamic_default as k, Global as kn, _el_read as kt, _if as l, runEffects as ln, _content as lt, installDynamicTagVar as m, forUntil as mn, setupBranch as mt, _await_promise as n, installCatch as nn, _style_rule_item as nt, _for_of as o, queueEffect as on, _to_text as ot, dynamicTagScript as p, forTo as pn, createBranch as pt, _attr_style_item as q, insertBranchBefore as qt, _dynamic_tag as r, placeholderShown as rn, _style_shell as rt, _for_to as s, queueRender as sn, insertChildNodes as st, _await_content as t, caughtError as tn, _lifecycle as tt, _show as u, runId as un, _content_closures as ut, _attr_details_or_dialog_open_default as v, withBranches as vn, _var_resume as vt, _attr_input_checked_default as w, Scope as wn, withLazy as wt, _attr_input_checkedValue as x, Params as xn, initEmbedded as xt, _attr_details_or_dialog_open_script as y, Clone as yn, getRegisteredWithScope as yt, controllableScripts as z, _or as zt };
2132
+ export { _attrs_content as $, DYNAMIC_TAG_SCRIPT_REGISTER_ID as $t, _attr_input_value_attribute_default as A, EndNode as An, _closure_get as At, _controllable_textarea as B, _let as Bt, _attr_input_checked as C, Owner as Cn, init as Ct, _attr_input_checked_default as D, Scope as Dn, withLazy as Dt, _attr_input_checkedValue_script as E, Pending as En, readyFailed as Et, _attr_select_value_default as F, PendingEffects as Fn, _global_read as Ft, _attr_class_item as G, _script as Gt, controllableScripts as H, _or as Ht, _attr_select_value_script as I, PendingRenders as In, _hoist as It, _attr_nonce as J, _assert_init as Jt, _attr_class_items as K, _var as Kt, _controllable_input as L, PlaceholderBranch as Ln, _hoist_resume as Lt, _attr_input_value_dynamic_default as M, Global as Mn, _el_read as Mt, _attr_input_value_script as N, Load as Nn, _for_closure as Nt, _attr_input_checked_script as O, AwaitCounter as On, _child_setup as Ot, _attr_select_value as P, ParentBranch as Pn, _for_selector as Pt, _attrs as Q, syncGen as Qt, _controllable_open as R, StartNode as Rn, _id as Rt, _attr_details_or_dialog_open_script as S, Clone as Sn, getRegisteredWithScope as St, _attr_input_checkedValue_default as T, Setup as Tn, ready as Tt, _attr as U, _return as Ut, controllableRenders as V, _let_change as Vt, _attr_class as W, _return_change as Wt, _attr_style_item as X, insertBranchBefore as Xt, _attr_style as Y, destroyBranch as Yt, _attr_style_items as Z, removeAndDestroyBranch as Zt, installDynamicTagVar as _, forUntil as _n, setupBranch as _t, _for_in as a, installCatch as an, _style_rule_item as at, _attr_details_or_dialog_open as b, _call as bn, _resumed as bt, _for_to as c, queueAsyncRender as cn, _text_content as ct, _for_until_unkeyed as d, run as dn, toInsertNode as dt, PLACEHOLDER_DISMISS_REGISTER_ID as en, _attrs_partial as et, _if as f, runEffects as fn, _content as ft, dynamicTagScript as g, forTo as gn, createBranch as gt, addAwaitCounter as h, forOf as hn, createAndSetupBranch as ht, _dynamic_tag_content as i, caughtError as in, _lifecycle as it, _attr_input_value_default as j, Gen$1 as jn, _const as jt, _attr_input_value as k, ClosestBranch as kn, _closure as kt, _for_to_unkeyed as l, queueEffect as ln, _to_text as lt, _try as m, forIn as mn, _content_resume as mt, _await_promise as n, $signal as nn, _attrs_script as nt, _for_of as o, placeholderShown as on, _style_shell as ot, _show as p, runId as pn, _content_closures as pt, _attr_content as q, _var_change as qt, _dynamic_tag as r, $signalReset as rn, _html as rt, _for_of_unkeyed as s, prepareEffects as sn, _text as st, _await_content as t, _on as tn, _attrs_partial_content as tt, _for_until as u, queueRender as un, insertChildNodes as ut, patchDynamicTag as v, _assert_hoist as vn, _el as vt, _attr_input_checkedValue as w, Params as wn, initEmbedded as wt, _attr_details_or_dialog_open_default as x, withBranches as xn, _var_resume as xt, renderCatch as y, _hoist_read_error as yn, _resume_dynamic_tag_var as yt, _controllable_select as z, TagVariable as zn, _if_closure as zt };
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-CBLlE8L-.js");
3
+ const require_control_flow = require("./dom-CI0Vojyk.js");
4
4
  //#region src/common/attr-tag.ts
5
5
  const empty = [];
6
6
  const rest = Symbol("Attribute Tag");
@@ -207,19 +207,18 @@ const _load_template = /*@__PURE__*/ require_control_flow.withLazy((id, load) =>
207
207
  }, _load_signal(() => (pending ||= load()).then((r) => ({ _: r["params"] || noop }))));
208
208
  return lazyTemplate;
209
209
  });
210
- const _load_setup = /*@__PURE__*/ require_control_flow.withLazy((nodeAccessor, childScopeAccessor, load) => {
210
+ const _load_setup = /*@__PURE__*/ require_control_flow.withLazy((load) => {
211
211
  let pending;
212
212
  let renderer;
213
213
  const insertCached = (child, marker) => insertLoaded(renderer, child, marker);
214
- return (owner) => {
215
- const child = owner[childScopeAccessor];
216
- if (renderer) require_control_flow.queueRender(child, insertCached, -1, owner[nodeAccessor]);
214
+ return (owner, child, marker) => {
215
+ if (renderer) require_control_flow.queueRender(child, insertCached, -1, marker);
217
216
  else {
218
217
  const awaitCounter = require_control_flow.addAwaitCounter(owner);
219
218
  child[require_control_flow.Load] ||= /* @__PURE__ */ new Map();
220
219
  (pending ||= load()).then((mod) => {
221
- renderer = require_control_flow._content("", ...mod._)();
222
- require_control_flow.queueAsyncRender(child, (child) => insertLoaded(renderer, child, owner[nodeAccessor], awaitCounter));
220
+ renderer ||= require_control_flow._content("", ...mod._)();
221
+ require_control_flow.queueAsyncRender(child, (child) => insertLoaded(renderer, child, marker, awaitCounter));
223
222
  }, loadFailed(child, awaitCounter));
224
223
  }
225
224
  };
@@ -359,9 +358,12 @@ exports._el_read = require_control_flow._el_read;
359
358
  exports._for_closure = require_control_flow._for_closure;
360
359
  exports._for_in = require_control_flow._for_in;
361
360
  exports._for_of = require_control_flow._for_of;
361
+ exports._for_of_unkeyed = require_control_flow._for_of_unkeyed;
362
362
  exports._for_selector = require_control_flow._for_selector;
363
363
  exports._for_to = require_control_flow._for_to;
364
+ exports._for_to_unkeyed = require_control_flow._for_to_unkeyed;
364
365
  exports._for_until = require_control_flow._for_until;
366
+ exports._for_until_unkeyed = require_control_flow._for_until_unkeyed;
365
367
  exports._global_read = require_control_flow._global_read;
366
368
  exports._hoist = require_control_flow._hoist;
367
369
  exports._hoist_read_error = require_control_flow._hoist_read_error;
@@ -1,4 +1,4 @@
1
- import { $ as _attrs_script, $t as $signal, A as _attr_input_value_script, An as Load, At as _for_closure, B as _attr, Bt as _return, C as _attr_input_checkedValue_script, Ct as readyFailed, D as _attr_input_value_attribute_default, Dn as EndNode, Dt as _closure_get, E as _attr_input_value, Et as _closure, F as _controllable_open, Fn as StartNode, Ft as _id, G as _attr_nonce, Gt as _assert_init, H as _attr_class_item, Ht as _script, I as _controllable_select, In as TagVariable, 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, Ot as _const, P as _controllable_input, Pt as _hoist_resume, Q as _attrs_partial_content, Qt as _on, Rt as _let_change, S as _attr_input_checkedValue_default, Sn as Setup, St as ready, 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, Y as _attrs, Yt as syncGen, Z as _attrs_partial, _ as _attr_details_or_dialog_open, _n as _call, _t as _resumed, a as _for_in, an as queueAsyncRender, at as _text_content, b as _attr_input_checked, bn as Owner, bt as init, c as _for_until, cn as run, ct as toInsertNode, d as _try, dn as forIn, dt as _content_resume, en as $signalReset, et as _html, f as addAwaitCounter, fn as forOf, ft as createAndSetupBranch, g as renderCatch, gn as _hoist_read_error, gt as _resume_dynamic_tag_var, 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 Global, 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, 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 _show, un as runId, ut as _content_closures, v as _attr_details_or_dialog_open_default, vt as _var_resume, w as _attr_input_checked_default, wt as withLazy, x as _attr_input_checkedValue, xn as Params, xt as initEmbedded, y as _attr_details_or_dialog_open_script, yn as Clone, yt as getRegisteredWithScope, zt as _or } from "./dom-DQCODUa1.mjs";
1
+ import { $ as _attrs_content, A as _attr_input_value_attribute_default, An as EndNode, At as _closure_get, B as _controllable_textarea, Bt as _let, C as _attr_input_checked, Cn as Owner, Ct as init, D as _attr_input_checked_default, Dt as withLazy, E as _attr_input_checkedValue_script, Et as readyFailed, F as _attr_select_value_default, Ft as _global_read, G as _attr_class_item, Gt as _script, Ht as _or, I as _attr_select_value_script, It as _hoist, J as _attr_nonce, Jt as _assert_init, K as _attr_class_items, Kt as _var, L as _controllable_input, Lt as _hoist_resume, M as _attr_input_value_dynamic_default, Mn as Global, Mt as _el_read, N as _attr_input_value_script, Nn as Load, Nt as _for_closure, O as _attr_input_checked_script, Ot as _child_setup, P as _attr_select_value, Pt as _for_selector, Q as _attrs, Qt as syncGen, R as _controllable_open, Rn as StartNode, Rt as _id, S as _attr_details_or_dialog_open_script, Sn as Clone, St as getRegisteredWithScope, T as _attr_input_checkedValue_default, Tn as Setup, Tt as ready, U as _attr, Ut as _return, Vt as _let_change, W as _attr_class, Wt as _return_change, X as _attr_style_item, Xt as insertBranchBefore, Y as _attr_style, Yt as destroyBranch, Z as _attr_style_items, Zt as removeAndDestroyBranch, _n as forUntil, _t as setupBranch, a as _for_in, at as _style_rule_item, b as _attr_details_or_dialog_open, bn as _call, bt as _resumed, c as _for_to, cn as queueAsyncRender, ct as _text_content, d as _for_until_unkeyed, dn as run, dt as toInsertNode, et as _attrs_partial, f as _if, fn as runEffects, ft as _content, gn as forTo, gt as createBranch, h as addAwaitCounter, hn as forOf, ht as createAndSetupBranch, i as _dynamic_tag_content, it as _lifecycle, j as _attr_input_value_default, jt as _const, k as _attr_input_value, kt as _closure, l as _for_to_unkeyed, ln as queueEffect, lt as _to_text, m as _try, mn as forIn, mt as _content_resume, n as _await_promise, nn as $signal, nt as _attrs_script, o as _for_of, ot as _style_shell, p as _show, pn as runId, pt as _content_closures, q as _attr_content, qt as _var_change, r as _dynamic_tag, rn as $signalReset, rt as _html, s as _for_of_unkeyed, sn as prepareEffects, st as _text, t as _await_content, tn as _on, tt as _attrs_partial_content, u as _for_until, un as queueRender, ut as insertChildNodes, v as patchDynamicTag, vn as _assert_hoist, vt as _el, w as _attr_input_checkedValue, wn as Params, wt as initEmbedded, x as _attr_details_or_dialog_open_default, xt as _var_resume, y as renderCatch, yn as _hoist_read_error, yt as _resume_dynamic_tag_var, z as _controllable_select, zn as TagVariable, zt as _if_closure } from "./dom-tl43c2wO.mjs";
2
2
  //#region src/common/attr-tag.ts
3
3
  const empty = [];
4
4
  const rest = Symbol("Attribute Tag");
@@ -205,19 +205,18 @@ const _load_template = /*@__PURE__*/ withLazy((id, load) => {
205
205
  }, _load_signal(() => (pending ||= load()).then((r) => ({ _: r["params"] || noop }))));
206
206
  return lazyTemplate;
207
207
  });
208
- const _load_setup = /*@__PURE__*/ withLazy((nodeAccessor, childScopeAccessor, load) => {
208
+ const _load_setup = /*@__PURE__*/ withLazy((load) => {
209
209
  let pending;
210
210
  let renderer;
211
211
  const insertCached = (child, marker) => insertLoaded(renderer, child, marker);
212
- return (owner) => {
213
- const child = owner[childScopeAccessor];
214
- if (renderer) queueRender(child, insertCached, -1, owner[nodeAccessor]);
212
+ return (owner, child, marker) => {
213
+ if (renderer) queueRender(child, insertCached, -1, marker);
215
214
  else {
216
215
  const awaitCounter = addAwaitCounter(owner);
217
216
  child[Load] ||= /* @__PURE__ */ new Map();
218
217
  (pending ||= load()).then((mod) => {
219
- renderer = _content("", ...mod._)();
220
- queueAsyncRender(child, (child) => insertLoaded(renderer, child, owner[nodeAccessor], awaitCounter));
218
+ renderer ||= _content("", ...mod._)();
219
+ queueAsyncRender(child, (child) => insertLoaded(renderer, child, marker, awaitCounter));
221
220
  }, loadFailed(child, awaitCounter));
222
221
  }
223
222
  };
@@ -290,4 +289,4 @@ function getSelectorOrResolve(selector, resolve) {
290
289
  return document.querySelector(selector) || (console.warn(`A lazy load trigger could not find an element matching "${selector}". The module was loaded immediately.`), resolve());
291
290
  }
292
291
  //#endregion
293
- export { $signal, $signalReset, _assert_hoist, _assert_init, _attr, _attr_class, _attr_class_item, _attr_class_items, _attr_content, _attr_details_or_dialog_open as _attr_details_open, _attr_details_or_dialog_open as _attr_dialog_open, _attr_details_or_dialog_open_default as _attr_details_open_default, _attr_details_or_dialog_open_default as _attr_dialog_open_default, _attr_details_or_dialog_open_script as _attr_details_open_script, _attr_details_or_dialog_open_script as _attr_dialog_open_script, _attr_input_checked, _attr_input_checkedValue, _attr_input_checkedValue_default, _attr_input_checkedValue_script, _attr_input_checked_default, _attr_input_checked_script, _attr_input_value, _attr_input_value as _attr_textarea_value, _attr_input_value_attribute_default, _attr_input_value_default, _attr_input_value_default as _attr_textarea_value_default, _attr_input_value_dynamic_default, _attr_input_value_script, _attr_input_value_script as _attr_textarea_value_script, _attr_nonce, _attr_select_value, _attr_select_value_default, _attr_select_value_script, _attr_style, _attr_style_item, _attr_style_items, _attrs, _attrs_content, _attrs_partial, _attrs_partial_content, _attrs_script, _await_content, _await_promise, _call, _child_setup, _closure, _closure_get, _const, _content, _content_closures, _content_resume, _controllable_input, _controllable_open, _controllable_select, _controllable_textarea, _dynamic_tag, _dynamic_tag_content, _el, _el_read, _for_closure, _for_in, _for_of, _for_selector, _for_to, _for_until, _global_read, _hoist, _hoist_read_error, _hoist_resume, _html, _id, _if, _if_closure, _let, _let_change, _lifecycle, _load_event_trigger, _load_idle_trigger, _load_media_trigger, _load_race_trigger, _load_setup, _load_signal, _load_template, _load_visible_trigger, _on, _or, _resume_dynamic_tag_var, _resumed, _return, _return_change, _script, _show, _style_rule_item, _style_shell, _template, _text, _text_content, _to_text, _try, _var, _var_change, _var_resume, attrTag, attrTags, compat, forIn, forOf, forTo, forUntil, init, initEmbedded, ready, readyFailed, run };
292
+ export { $signal, $signalReset, _assert_hoist, _assert_init, _attr, _attr_class, _attr_class_item, _attr_class_items, _attr_content, _attr_details_or_dialog_open as _attr_details_open, _attr_details_or_dialog_open as _attr_dialog_open, _attr_details_or_dialog_open_default as _attr_details_open_default, _attr_details_or_dialog_open_default as _attr_dialog_open_default, _attr_details_or_dialog_open_script as _attr_details_open_script, _attr_details_or_dialog_open_script as _attr_dialog_open_script, _attr_input_checked, _attr_input_checkedValue, _attr_input_checkedValue_default, _attr_input_checkedValue_script, _attr_input_checked_default, _attr_input_checked_script, _attr_input_value, _attr_input_value as _attr_textarea_value, _attr_input_value_attribute_default, _attr_input_value_default, _attr_input_value_default as _attr_textarea_value_default, _attr_input_value_dynamic_default, _attr_input_value_script, _attr_input_value_script as _attr_textarea_value_script, _attr_nonce, _attr_select_value, _attr_select_value_default, _attr_select_value_script, _attr_style, _attr_style_item, _attr_style_items, _attrs, _attrs_content, _attrs_partial, _attrs_partial_content, _attrs_script, _await_content, _await_promise, _call, _child_setup, _closure, _closure_get, _const, _content, _content_closures, _content_resume, _controllable_input, _controllable_open, _controllable_select, _controllable_textarea, _dynamic_tag, _dynamic_tag_content, _el, _el_read, _for_closure, _for_in, _for_of, _for_of_unkeyed, _for_selector, _for_to, _for_to_unkeyed, _for_until, _for_until_unkeyed, _global_read, _hoist, _hoist_read_error, _hoist_resume, _html, _id, _if, _if_closure, _let, _let_change, _lifecycle, _load_event_trigger, _load_idle_trigger, _load_media_trigger, _load_race_trigger, _load_setup, _load_signal, _load_template, _load_visible_trigger, _on, _or, _resume_dynamic_tag_var, _resumed, _return, _return_change, _script, _show, _style_rule_item, _style_shell, _template, _text, _text_content, _to_text, _try, _var, _var_change, _var_resume, attrTag, attrTags, compat, forIn, forOf, forTo, forUntil, init, initEmbedded, ready, readyFailed, run };
@@ -129,6 +129,10 @@ function isEventHandler(name) {
129
129
  function getEventHandlerName(name) {
130
130
  return name[2] === "-" ? name.slice(3) : name.slice(2).toLowerCase();
131
131
  }
132
+ function hasKeys(obj) {
133
+ for (const _ in obj) return true;
134
+ return false;
135
+ }
132
136
  function isVoid(value) {
133
137
  return value == null || value === false;
134
138
  }
@@ -631,10 +635,11 @@ var Serializer = class {
631
635
  });
632
636
  }
633
637
  };
634
- function register(id, val, scope) {
638
+ function register(id, val, scope, locals) {
635
639
  REGISTRY.set(val, {
636
640
  id,
637
641
  scope,
642
+ locals,
638
643
  access: "_._" + toAccess(toObjectKey(id))
639
644
  });
640
645
  return val;
@@ -817,6 +822,9 @@ function newScopeReference(state, val, scopeId) {
817
822
  ref.debug = DEBUG.get(val);
818
823
  return ref;
819
824
  }
825
+ function quoteRegisterId(id) {
826
+ return quote(id, 0);
827
+ }
820
828
  function writeRegistered(state, val, parent, accessor, registered) {
821
829
  const { scope } = registered;
822
830
  if (scope) {
@@ -826,7 +834,16 @@ function writeRegistered(state, val, parent, accessor, registered) {
826
834
  ref.debug = DEBUG.get(val);
827
835
  const scopeId = scope[K_SCOPE_ID];
828
836
  trackScope(state, scope, scopeId);
829
- state.buf.push("_(" + scopeId + "," + quote(registered.id, 0) + ")");
837
+ const locals = registered.locals?.(state.boundary.state.scope);
838
+ if (locals) {
839
+ state.buf.push(registered.access + "(_(" + scopeId + ")");
840
+ for (const local of locals) {
841
+ state.buf.push(",");
842
+ if (local) writePlainObject(state, local, new Reference(ref, null, state.flushId, state.buf.length));
843
+ else state.buf.push("0");
844
+ }
845
+ } else state.buf.push("_(" + scopeId + "," + quoteRegisterId(registered.id));
846
+ state.buf.push(")");
830
847
  } else state.buf.push(registered.access);
831
848
  return true;
832
849
  }
@@ -2018,8 +2035,8 @@ function _script(scopeId, registryId, serializeMarker) {
2018
2035
  function _trailers(html) {
2019
2036
  $chunk.boundary.state.trailerHTML += html;
2020
2037
  }
2021
- function _resume(val, id, scopeId) {
2022
- return register(id, val, scopeId === void 0 ? void 0 : _scope_with_id(scopeId));
2038
+ function _resume(val, id, scopeId, locals) {
2039
+ return register(id, val, scopeId === void 0 ? void 0 : _scope_with_id(scopeId), locals);
2023
2040
  }
2024
2041
  function _resume_locals(val, id, locals, ownerScopeId) {
2025
2042
  if (ownerScopeId !== void 0) locals["_"] = _scope_with_id(ownerScopeId);
@@ -2131,13 +2148,17 @@ function _for_until(to, from, step, cb, by, scopeId, accessor, serializeBranch,
2131
2148
  }, scopeId, accessor, serializeBranch, serializeMarker, serializeStateful, parentEndTag, singleNode);
2132
2149
  }
2133
2150
  function forBranches(by, iterate, scopeId, accessor, serializeBranch, serializeMarker, serializeStateful, parentEndTag, singleNode) {
2134
- var seenKeys = /* @__PURE__ */ new Set();
2135
- if (serializeBranch === 0) {
2136
- if (by) iterate((itemKey, _sameAsIndex, render) => {
2151
+ if (by) {
2152
+ const run = iterate;
2153
+ const seenKeys = /* @__PURE__ */ new Set();
2154
+ iterate = (each) => run((itemKey, sameAsIndex, render) => {
2137
2155
  assertValidLoopKey(itemKey, seenKeys);
2138
- render();
2156
+ if (each) each(itemKey, sameAsIndex, render);
2157
+ else render();
2139
2158
  });
2140
- else iterate(0);
2159
+ }
2160
+ if (serializeBranch === 0) {
2161
+ iterate(0);
2141
2162
  writeBranchEnd(scopeId, accessor, serializeStateful, serializeMarker, parentEndTag, singleNode, "");
2142
2163
  return;
2143
2164
  }
@@ -2148,7 +2169,6 @@ function forBranches(by, iterate, scopeId, accessor, serializeBranch, serializeM
2148
2169
  let loopScopes;
2149
2170
  iterate((itemKey, sameAsIndex, render) => {
2150
2171
  const branchId = _peek_scope_id();
2151
- if (by) assertValidLoopKey(itemKey, seenKeys);
2152
2172
  if (resumeMarker) if (singleNode) flushBranchIds = " " + branchId + flushBranchIds;
2153
2173
  else {
2154
2174
  $chunk.writeHTML(state.mark("[", flushBranchIds));
@@ -2225,17 +2245,18 @@ function scopeWithId(state, scopeId) {
2225
2245
  if (!scope) scopes.set(scopeId, scope = { [K_SCOPE_ID]: scopeId });
2226
2246
  return scope;
2227
2247
  }
2228
- function _subscribe(subscribers, scope) {
2248
+ function _subscribe(subscribers, scope, resumeId, serializeMarker) {
2229
2249
  if (subscribers) {
2230
2250
  const { serializer } = $chunk.boundary.state;
2231
2251
  if (!$chunk.serializeState.readyId && !serializer.written(subscribers)) subscribers.add(scope);
2252
+ else if (resumeId) _script(scope[K_SCOPE_ID], resumeId, serializeMarker);
2232
2253
  else serializer.writeCall(scope, subscribers, "add", $chunk.serializeState);
2233
2254
  }
2234
2255
  return scope;
2235
2256
  }
2236
- const CLIENT_ALL = 715827882;
2257
+ const CLIENT_ALL = 715827883;
2237
2258
  function maskGroup(mask, group) {
2238
- return mask === 715827882 ? 1 : typeof mask === "number" ? mask >>> 1 + 2 * group & 3 : mask[group] ?? 0;
2259
+ return mask === 715827883 ? 1 : typeof mask === "number" ? group < 15 ? mask >>> 1 + 2 * group & 3 : 0 : mask[group] ?? 0;
2239
2260
  }
2240
2261
  function _set_serialize_reason(reason) {
2241
2262
  $chunk.boundary.state.serializeReason = reason;
@@ -2439,6 +2460,7 @@ var State = class {
2439
2460
  serializer = new Serializer();
2440
2461
  writeReorders = null;
2441
2462
  scopes = /* @__PURE__ */ new Map();
2463
+ scope = (scopeId) => scopeWithId(this, scopeId);
2442
2464
  flushScopes = false;
2443
2465
  writeScopes = {};
2444
2466
  readyIds = null;
@@ -2670,23 +2692,23 @@ var Chunk = class Chunk {
2670
2692
  $chunk = prev;
2671
2693
  }
2672
2694
  }
2673
- flushReadyScripts(reservations) {
2695
+ flushReadyScripts(reservations, holdEffects) {
2674
2696
  const { boundary, serializeState } = this;
2675
2697
  const { readyId } = serializeState;
2676
2698
  let scripts = "";
2677
2699
  forEach(this.takeDeferredReady(), (chunk) => {
2678
- scripts = concatScripts(scripts, chunk.flushReadyScripts(reservations));
2700
+ scripts = concatScripts(scripts, chunk.flushReadyScripts(reservations, holdEffects));
2701
+ if (chunk.effects || chunk.deferredReady) this.deferredReady = push(this.deferredReady, chunk);
2679
2702
  });
2680
2703
  if (readyId && !this.async) {
2681
2704
  const { state } = boundary;
2682
2705
  flushSerializer(boundary, serializeState);
2683
2706
  const deps = state.serializer.takeChannelDeps();
2684
- const { effects } = this;
2707
+ const effects = holdEffects ? "" : this.effects;
2685
2708
  const { resumes } = serializeState;
2686
2709
  const chunkScripts = this.scripts;
2687
- serializeState.resumes = "";
2688
- this.effects = this.scripts = "";
2689
- this.lastEffect = "";
2710
+ serializeState.resumes = this.scripts = "";
2711
+ if (effects) this.effects = this.lastEffect = "";
2690
2712
  if (resumes || effects) {
2691
2713
  state.needsMainRuntime = true;
2692
2714
  const batch = concatSequence(depsMarker(deps), concatSequence(resumes, effects && `"${effects}"`));
@@ -2706,7 +2728,7 @@ var Chunk = class Chunk {
2706
2728
  const { $global, runtimePrefix } = state;
2707
2729
  let needsWalk = state.walkOnNextFlush;
2708
2730
  if (needsWalk) state.walkOnNextFlush = false;
2709
- let readyResumeScripts = this.flushReadyScripts();
2731
+ let readyResumeScripts = this.flushReadyScripts(void 0, this.async);
2710
2732
  for (let channel; channel = state.serializer.pendingReadyChannel();) {
2711
2733
  const resumes = state.serializer.stringifyScopes([], boundary, channel);
2712
2734
  const deps = state.serializer.takeChannelDeps();
@@ -2755,7 +2777,8 @@ var Chunk = class Chunk {
2755
2777
  cur.flushPlaceholder();
2756
2778
  cur.deferOwnReady();
2757
2779
  const { next } = cur;
2758
- const readyResumeScripts = cur.flushReadyScripts(readyReservations);
2780
+ const readyResumeScripts = cur.flushReadyScripts(readyReservations, this.async);
2781
+ this.deferredReady = concat(this.deferredReady, cur.takeDeferredReady());
2759
2782
  cur.consumed = true;
2760
2783
  reorderHTML += cur.html;
2761
2784
  reorderEffects = concatEffects(reorderEffects, cur.effects);
@@ -2769,7 +2792,10 @@ var Chunk = class Chunk {
2769
2792
  if (next) cur = next;
2770
2793
  else break;
2771
2794
  }
2772
- if (reorderEffects) {
2795
+ if (reorderEffects) if (this.async) {
2796
+ this.effects = concatEffects(this.effects, reorderEffects);
2797
+ this.lastEffect = "";
2798
+ } else {
2773
2799
  needsResumeArray = true;
2774
2800
  reorderScripts = concatScripts(reorderScripts, "_.push(\"" + reorderEffects + "\")");
2775
2801
  }
@@ -2829,7 +2855,7 @@ function flushSerializer(boundary, serializeState) {
2829
2855
  for (const key in writeScopes) {
2830
2856
  const scopeId = +key;
2831
2857
  const props = writeScopes[scopeId];
2832
- if (Object.getOwnPropertyNames(props).length) flushes.push([
2858
+ if (hasKeys(props)) flushes.push([
2833
2859
  scopeId,
2834
2860
  state.scopes.get(scopeId),
2835
2861
  props
@@ -3212,8 +3238,8 @@ function _content(id, fn, scopeId) {
3212
3238
  fn[Owner] = scopeId;
3213
3239
  return fn;
3214
3240
  }
3215
- function _content_resume(id, fn, scopeId) {
3216
- return _resume(_content(id, fn, scopeId), id, scopeId);
3241
+ function _content_resume(id, fn, scopeId, locals) {
3242
+ return _resume(_content(id, fn, scopeId), id, scopeId, locals);
3217
3243
  }
3218
3244
  const patchDynamicTag = /* @__PURE__ */ ((originalDynamicTag) => (patch) => {
3219
3245
  _dynamic_tag = (scopeId, accessor, tag, input, content, inputIsArgs, resume) => {