marko 6.3.52 → 6.3.54

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 (81) 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 +5 -0
  18. package/dist/debug/dom/dynamic-tag-script.feat.mjs +4 -0
  19. package/dist/debug/dom/dynamic-tag-var.feat.js +2 -3
  20. package/dist/debug/dom/dynamic-tag-var.feat.mjs +2 -3
  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-BJKb8-wr.js → dom-CI0Vojyk.js} +146 -88
  24. package/dist/debug/{dom-Dq_Yu7MS.mjs → dom-tl43c2wO.mjs} +113 -85
  25. package/dist/debug/dom.js +10 -8
  26. package/dist/debug/dom.mjs +7 -8
  27. package/dist/debug/html.js +52 -26
  28. package/dist/debug/html.mjs +52 -26
  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 +5 -4
  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.d.ts +1 -0
  43. package/dist/dom/dynamic-tag-script.feat.js +4 -0
  44. package/dist/dom/dynamic-tag-script.feat.mjs +4 -0
  45. package/dist/dom/dynamic-tag-var.feat.js +1 -2
  46. package/dist/dom/dynamic-tag-var.feat.mjs +2 -3
  47. package/dist/dom/load.d.ts +2 -2
  48. package/dist/dom/placeholder.feat.js +3 -3
  49. package/dist/dom/placeholder.feat.mjs +1 -1
  50. package/dist/dom/renderer.d.ts +2 -3
  51. package/dist/dom/resume.d.ts +1 -0
  52. package/dist/dom/signals.d.ts +1 -1
  53. package/dist/{dom-CzfddxCE.mjs → dom-4udEPZaj.mjs} +77 -58
  54. package/dist/{dom-CzGPOsST.js → dom-C1mr-TA7.js} +213 -174
  55. package/dist/dom.d.ts +2 -2
  56. package/dist/dom.js +40 -42
  57. package/dist/dom.mjs +6 -8
  58. package/dist/html/dynamic-tag.d.ts +2 -1
  59. package/dist/html/serializer.d.ts +3 -2
  60. package/dist/html/writer.d.ts +6 -5
  61. package/dist/html.js +35 -20
  62. package/dist/html.mjs +35 -20
  63. package/dist/translator/index.js +2863 -2666
  64. package/dist/translator/util/binding-has-prop.d.ts +1 -0
  65. package/dist/translator/util/branch-tag.d.ts +6 -1
  66. package/dist/translator/util/optional.d.ts +2 -0
  67. package/dist/translator/util/references.d.ts +26 -12
  68. package/dist/translator/util/runtime.d.ts +2 -1
  69. package/dist/translator/util/sections.d.ts +11 -8
  70. package/dist/translator/util/serialize-guard.d.ts +1 -7
  71. package/dist/translator/util/serialize-reasons.d.ts +3 -0
  72. package/dist/translator/util/set-tag-sections-downstream.d.ts +1 -1
  73. package/dist/translator/util/signals.d.ts +4 -1
  74. package/dist/translator/util/structure.d.ts +1 -1
  75. package/dist/translator/util/tag-name-type.d.ts +1 -1
  76. package/dist/translator/visitors/function.d.ts +1 -0
  77. package/dist/translator/visitors/import-declaration.d.ts +1 -0
  78. package/dist/translator/visitors/tag/custom-tag.d.ts +5 -0
  79. package/package.json +4 -4
  80. package/tags/try.d.marko +2 -0
  81. package/tags-html.d.ts +6 -0
package/cheatsheet.md CHANGED
@@ -18,6 +18,7 @@ Marko 6 = HTML superset, not JSX and not Marko 4/5 syntax. `.marko` files are co
18
18
  8. Transform in the handler when needed; number inputs give strings: `<input type="number" value=n valueChange(v) { n = +v }>`, or `value:parseFloat:=n`. Uncommitted edits (debounce, commit on blur) never sync through a `<script>`; that is rule 4's derive-by-effect trap. Pair a controllable `<let/value:=input.value>` with `<let/pending=null>`, show `<const/draft=pending ?? value>`, collect with `valueChange(v) { pending = v }`, and commit by assigning `value = pending; pending = null`. Prefer that to calling `input.valueChange(...)`, which throws unless every caller controls the tag.
19
19
  9. Radio/checkbox groups: `checkedValue:=picked` on each input (shared var, distinct `value=`); the match is checked; array var for multi-checkbox. Dropdown: `<select value:=picked>`.
20
20
  10. Module-level values, helpers and type aliases need `static`: `static const LIMIT = 10`, `static function fmt(n) {…}`, `static type Row = {…}`. Prefer it to `<const>` for anything that never changes: `<const/LIMIT=10>` runs per instance, `static` hoists it to a module constant. `server`/`client` narrow `static` to one platform (`client import { Chart } from "chart"`); the binding is `undefined` on the other, so read a `client` one only from `<script>`/handlers/`<lifecycle>`. Reading it while rendering throws `is not a function` during SSR.
21
+ 11. `$!{html}` and the contents of `<html-script>`/`<html-style>` are written as-is: the latter are escaped only so they can't close the element, and run as code. Never put user-provided content in them.
21
22
 
22
23
  ## Canonical component
23
24
 
@@ -5,7 +5,6 @@ export declare const Params = "d";
5
5
  export declare const Owner = "e";
6
6
  export declare const Accessor = "f";
7
7
  export declare const LocalClosures = "g";
8
- export declare const LocalClosureValues = "h";
9
8
  export declare const Embed = "i";
10
9
  type Self = typeof import("./renderer-prop");
11
10
  export type Value = Self[keyof Self];
@@ -5,7 +5,6 @@ export declare const Params = "params";
5
5
  export declare const Owner = "owner";
6
6
  export declare const Accessor = "accessor";
7
7
  export declare const LocalClosures = "localClosures";
8
- export declare const LocalClosureValues = "localClosureValues";
9
8
  export declare const Embed = "embed";
10
9
  type Self = typeof import("./renderer-prop.debug");
11
10
  export type Value = Self[keyof Self];
@@ -8,6 +8,7 @@ export declare function escapeStyleValue(str: string): string;
8
8
  export declare const toDelimitedString: (val: unknown, delimiter: string, stringify: (n: string, v: unknown) => string | undefined) => string;
9
9
  export declare function isEventHandler(name: string): name is `on${string}`;
10
10
  export declare function getEventHandlerName(name: `on${string}`): string;
11
+ export declare function hasKeys(obj: object): boolean;
11
12
  export declare function isVoid(value: unknown): value is false | null | undefined;
12
13
  export declare function isNotVoid(value: unknown): boolean;
13
14
  export declare function isPromise(value: unknown): value is Promise<unknown>;
@@ -1,5 +1,5 @@
1
1
  "use strict";
2
- const require_control_flow = require("../dom-BJKb8-wr.js");
2
+ const require_control_flow = require("../dom-CI0Vojyk.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 PendingEffects, Sn as Scope, en as caughtError, g as renderCatch, jn as PendingRenders, kn as ParentBranch, nn as placeholderShown, tn as installCatch, wn as ClosestBranch, xn as Pending } from "../dom-Dq_Yu7MS.mjs";
1
+ import { Dn as Scope, En as Pending, Fn as PendingEffects, In as PendingRenders, Pn as ParentBranch, an as installCatch, in as caughtError, kn as ClosestBranch, on as placeholderShown, y as renderCatch } from "../dom-tl43c2wO.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-BJKb8-wr.js");
2
+ const require_control_flow = require("../dom-CI0Vojyk.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-Dq_Yu7MS.mjs";
1
+ import { E as _attr_input_checkedValue_script, H as controllableScripts, N as _attr_input_value_script, O as _attr_input_checked_script } from "../dom-tl43c2wO.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-BJKb8-wr.js");
2
+ const require_control_flow = require("../dom-CI0Vojyk.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-Dq_Yu7MS.mjs";
1
+ import { H as controllableScripts, S as _attr_details_or_dialog_open_script } from "../dom-tl43c2wO.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-BJKb8-wr.js");
2
+ const require_control_flow = require("../dom-CI0Vojyk.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-Dq_Yu7MS.mjs";
1
+ import { H as controllableScripts, I as _attr_select_value_script } from "../dom-tl43c2wO.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-BJKb8-wr.js");
2
+ const require_control_flow = require("../dom-CI0Vojyk.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-Dq_Yu7MS.mjs";
1
+ import { H as controllableScripts, N as _attr_input_value_script } from "../dom-tl43c2wO.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-BJKb8-wr.js");
2
+ const require_control_flow = require("../dom-CI0Vojyk.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-Dq_Yu7MS.mjs";
1
+ import { B as _controllable_textarea, L as _controllable_input, R as _controllable_open, V as controllableRenders, z as _controllable_select } from "../dom-tl43c2wO.mjs";
2
2
  import "./controllable-input.feat.mjs";
3
3
  import "./controllable-open.feat.mjs";
4
4
  import "./controllable-select.feat.mjs";
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+ const require_control_flow = require("../dom-CI0Vojyk.js");
3
+ //#region src/dom/dynamic-tag-script.feat.ts
4
+ require_control_flow._resumed[require_control_flow.DYNAMIC_TAG_SCRIPT_REGISTER_ID] = require_control_flow.withBranches(require_control_flow.dynamicTagScript);
5
+ //#endregion
@@ -0,0 +1,4 @@
1
+ import { $t as DYNAMIC_TAG_SCRIPT_REGISTER_ID, bt as _resumed, g as dynamicTagScript, xn as withBranches } from "../dom-tl43c2wO.mjs";
2
+ //#region src/dom/dynamic-tag-script.feat.ts
3
+ _resumed[DYNAMIC_TAG_SCRIPT_REGISTER_ID] = withBranches(dynamicTagScript);
4
+ //#endregion
@@ -1,6 +1,5 @@
1
1
  "use strict";
2
- const require_control_flow = require("../dom-BJKb8-wr.js");
2
+ const require_control_flow = require("../dom-CI0Vojyk.js");
3
3
  //#region src/dom/dynamic-tag-var.feat.ts
4
- const elementGetter = require_control_flow._resumed[require_control_flow.DYNAMIC_TAG_VAR_REGISTER_ID] = (branch) => () => require_control_flow._el_read(branch[require_control_flow.StartNode]);
5
- require_control_flow.installDynamicTagVar((branch) => branch[require_control_flow.TagVariable](elementGetter(branch)));
4
+ require_control_flow.installDynamicTagVar((branch) => branch[require_control_flow.TagVariable](() => require_control_flow._el_read(branch[require_control_flow.StartNode])));
6
5
  //#endregion
@@ -1,5 +1,4 @@
1
- import { Nn as StartNode, Ot as _el_read, Pn as TagVariable, Xt as DYNAMIC_TAG_VAR_REGISTER_ID, gt as _resumed, m as installDynamicTagVar } from "../dom-Dq_Yu7MS.mjs";
1
+ import { Mt as _el_read, Rn as StartNode, _ as installDynamicTagVar, zn as TagVariable } from "../dom-tl43c2wO.mjs";
2
2
  //#region src/dom/dynamic-tag-var.feat.ts
3
- const elementGetter = _resumed[DYNAMIC_TAG_VAR_REGISTER_ID] = (branch) => () => _el_read(branch[StartNode]);
4
- installDynamicTagVar((branch) => branch[TagVariable](elementGetter(branch)));
3
+ installDynamicTagVar((branch) => branch[TagVariable](() => _el_read(branch[StartNode])));
5
4
  //#endregion
@@ -1,5 +1,5 @@
1
1
  "use strict";
2
- const require_control_flow = require("../dom-BJKb8-wr.js");
2
+ const require_control_flow = require("../dom-CI0Vojyk.js");
3
3
  //#region src/dom/placeholder.feat.ts
4
4
  require_control_flow._resumed[require_control_flow.PLACEHOLDER_DISMISS_REGISTER_ID] = (tryBranch) => {
5
5
  if (tryBranch["#PlaceholderBranch"]) {
@@ -1,4 +1,4 @@
1
- import { Gt as destroyBranch, Mn as PlaceholderBranch, Zt as PLACEHOLDER_DISMISS_REGISTER_ID, gt as _resumed } from "../dom-Dq_Yu7MS.mjs";
1
+ import { Ln as PlaceholderBranch, Yt as destroyBranch, bt as _resumed, en as PLACEHOLDER_DISMISS_REGISTER_ID } from "../dom-tl43c2wO.mjs";
2
2
  //#region src/dom/placeholder.feat.ts
3
3
  _resumed[PLACEHOLDER_DISMISS_REGISTER_ID] = (tryBranch) => {
4
4
  if (tryBranch["#PlaceholderBranch"]) {
@@ -59,7 +59,6 @@ const Params = "params";
59
59
  const Owner = "owner";
60
60
  const Accessor = "accessor";
61
61
  const LocalClosures = "localClosures";
62
- const LocalClosureValues = "localClosureValues";
63
62
  //#endregion
64
63
  //#region src/common/helpers.ts
65
64
  const htmlAttrNameReg = /^[^a-z_]|[^a-z0-9._:-]/i;
@@ -455,11 +454,6 @@ function abort(ctrl) {
455
454
  ctrl.abort();
456
455
  }
457
456
  //#endregion
458
- //#region src/common/meta.ts
459
- const DYNAMIC_TAG_SCRIPT_REGISTER_ID = "_dynamicTagScript";
460
- const DYNAMIC_TAG_VAR_REGISTER_ID = "_dynamicTagVar";
461
- const PLACEHOLDER_DISMISS_REGISTER_ID = "_placeholderDismiss";
462
- //#endregion
463
457
  //#region src/common/opt.ts
464
458
  function toArray(opt) {
465
459
  return opt ? Array.isArray(opt) ? opt : [opt] : [];
@@ -503,6 +497,11 @@ function parseHTML(html, ns) {
503
497
  return parser.content || parser;
504
498
  }
505
499
  //#endregion
500
+ //#region src/common/meta.ts
501
+ const DYNAMIC_TAG_SCRIPT_REGISTER_ID = "_dynamicTagScript";
502
+ const DYNAMIC_TAG_VAR_REGISTER_ID = "_dynamicTagVar";
503
+ const PLACEHOLDER_DISMISS_REGISTER_ID = "_placeholderDismiss";
504
+ //#endregion
506
505
  //#region src/dom/scope.ts
507
506
  let nextScopeId = 1e6;
508
507
  let collectingScopes;
@@ -731,20 +730,24 @@ function _closure(...closureSignals) {
731
730
  }
732
731
  };
733
732
  }
734
- function _closure_get(valueAccessor, fn, getOwnerScope, resumeId) {
735
- const closureSignal = ((scope) => {
733
+ function _closure_get(valueAccessor, fn, getOwnerScope, resumeId, ownerValueAccessor) {
734
+ const closureSignal = ((scope, resumed) => {
735
+ const ownerScope = getOwnerScope ? getOwnerScope(scope) : scope["_"];
736
736
  scope[closureSignal[SignalIndexAccessor]] = closureSignal[Index];
737
- fn(scope);
738
- subscribeToScopeSet(getOwnerScope ? getOwnerScope(scope) : scope["_"], closureSignal[ScopeInstancesAccessor], scope);
737
+ if (!resumed || ownerValueAccessor in ownerScope) fn(scope);
738
+ subscribeToScopeSet(ownerScope, closureSignal[ScopeInstancesAccessor], scope);
739
739
  });
740
740
  closureSignal[ScopeInstancesAccessor] = ClosureScopes + valueAccessor;
741
741
  closureSignal[SignalIndexAccessor] = ClosureSignalIndex + valueAccessor;
742
- if (resumeId) _resumed[resumeId] = closureSignal;
742
+ if (resumeId) {
743
+ ownerValueAccessor = valueAccessor;
744
+ _resumed[resumeId] = (scope) => closureSignal(scope, 1);
745
+ }
743
746
  return closureSignal;
744
747
  }
745
748
  function _child_setup(setup) {
746
749
  setup._ = (scope, owner) => {
747
- scope["_"] = owner;
750
+ scope["_"] ||= owner;
748
751
  queueRender(scope, setup, -1);
749
752
  };
750
753
  return setup;
@@ -788,8 +791,9 @@ function _el_read(value) {
788
791
  }
789
792
  function* traverse(scope, path, args, i = path.length - 1) {
790
793
  if (rendering) _hoist_read_error();
791
- if (scope) if (Symbol.iterator in scope) for (const childScope of scope.values()) yield* traverse(childScope, path, args, i);
792
- else {
794
+ if (scope) if (Symbol.iterator in scope) {
795
+ for (const childScope of scope.values()) if (childScope["#Gen"] !== 0) yield* traverse(childScope, path, args, i);
796
+ } else {
793
797
  const item = scope[path[i]];
794
798
  if (i) yield* traverse(item, path, args, i - 1);
795
799
  else yield typeof item === "function" ? item(...args) : item;
@@ -1090,6 +1094,12 @@ function _var_resume(id, signal) {
1090
1094
  function _el(id, accessor) {
1091
1095
  return _resumed[id] = (scope) => () => _el_read(scope[accessor]);
1092
1096
  }
1097
+ function _resume_dynamic_tag_var(accessor) {
1098
+ _resumed[DYNAMIC_TAG_VAR_REGISTER_ID + accessor] = (scope) => () => {
1099
+ const node = scope[accessor];
1100
+ return _el_read(node.nodeType === 8 ? node.previousSibling : node);
1101
+ };
1102
+ }
1093
1103
  //#endregion
1094
1104
  //#region src/dom/renderer.ts
1095
1105
  function createBranch($global, renderer, parentScope, parentNode) {
@@ -1123,7 +1133,7 @@ function _content(id, template, walks, setup, params, dynamicScopesAccessor) {
1123
1133
  } : (branch) => {
1124
1134
  walk(branch[StartNode] = branch[EndNode] = new Text(), walks, branch);
1125
1135
  };
1126
- return (owner) => {
1136
+ return _resumed[id] = (owner) => {
1127
1137
  return {
1128
1138
  ["id"]: id,
1129
1139
  [Clone]: clone,
@@ -1134,16 +1144,29 @@ function _content(id, template, walks, setup, params, dynamicScopesAccessor) {
1134
1144
  };
1135
1145
  };
1136
1146
  }
1137
- function _content_resume(id, template, walks, setup, params, dynamicScopesAccessor) {
1138
- return _resumed[id] = _content(id, template, walks, setup, params, dynamicScopesAccessor);
1147
+ function _content_resume(renderer, hasLocalValues = 0) {
1148
+ return _resumed[renderer()["id"]] = (owner, ...values) => {
1149
+ for (let i = values.length, scope = owner; i > hasLocalValues;) {
1150
+ const closures = values[--i];
1151
+ for (const key in closures) if (!(key in scope)) scope[key] = closures[key];
1152
+ scope = scope["_"];
1153
+ }
1154
+ return renderer(owner, values[hasLocalValues - 1]);
1155
+ };
1139
1156
  }
1140
1157
  function _content_closures(renderer, closureFns) {
1141
1158
  const closureSignals = {};
1142
1159
  for (const key in closureFns) closureSignals[key] = _const(key, closureFns[key]);
1143
1160
  return (owner, closureValues) => {
1144
1161
  const instance = renderer(owner);
1145
- instance[LocalClosures] = closureSignals;
1146
- instance[LocalClosureValues] = closureValues;
1162
+ const clone = instance[Clone];
1163
+ const setClosures = instance[LocalClosures] = (branch) => {
1164
+ for (const key in closureSignals) closureSignals[key](branch, closureValues[key]);
1165
+ };
1166
+ instance[Clone] = (branch, ns) => {
1167
+ clone(branch, ns);
1168
+ setClosures(branch);
1169
+ };
1147
1170
  return instance;
1148
1171
  };
1149
1172
  }
@@ -1288,7 +1311,7 @@ function _attr_content(scope, nodeAccessor, value) {
1288
1311
  setConditionalRenderer(scope, nodeAccessor, content, createAndSetupBranch);
1289
1312
  if (content?.["accessor"]) subscribeToScopeSet(content[Owner], content[Accessor], scope[BranchScopes$1 + nodeAccessor]);
1290
1313
  }
1291
- for (const accessor in content?.[LocalClosures]) content[LocalClosures][accessor](scope[BranchScopes$1 + nodeAccessor], content[LocalClosureValues][accessor]);
1314
+ content?.[LocalClosures]?.(scope[BranchScopes$1 + nodeAccessor]);
1292
1315
  }
1293
1316
  function _attrs_script(scope, nodeAccessor) {
1294
1317
  const el = scope[nodeAccessor];
@@ -1684,18 +1707,20 @@ function _await_promise(nodeAccessor, params) {
1684
1707
  return awaitBranch;
1685
1708
  };
1686
1709
  const awaitPromise = (scope, promise) => {
1687
- if (!isPromise(promise) && scope[promiseAccessor]) promise = Promise.resolve(promise);
1710
+ if (!isPromise(scope[promiseAccessor])) scope[promiseAccessor] = 0;
1688
1711
  let awaitBranch = scope[branchAccessor];
1689
- const tryPlaceholder = findBranchWithKey(scope, PlaceholderContent);
1712
+ const tryPlaceholder = (isPromise(promise) || scope[promiseAccessor]) && findBranchWithKey(scope, "#PlaceholderContent");
1690
1713
  const tryBranch = tryPlaceholder || awaitBranch;
1691
- if (!(isPromise(promise) ? tryBranch : awaitBranch)) {
1692
- scope[promiseAccessor] = () => awaitPromise(scope, promise);
1693
- return;
1694
- }
1695
- if (!isPromise(promise)) {
1696
- resolveAwait(scope, scope[nodeAccessor], promise);
1714
+ if (!tryBranch) {
1715
+ const replay = scope[promiseAccessor] = () => replay === scope[promiseAccessor] && awaitPromise(scope, promise);
1716
+ const awaitCounter = findBranchWithKey(scope, PlaceholderContent)?.[AwaitCounter];
1717
+ if (awaitCounter?.i) {
1718
+ const complete = awaitCounter.c;
1719
+ awaitCounter.c = () => complete() || queueAsyncRender(scope, replay);
1720
+ }
1697
1721
  return;
1698
1722
  }
1723
+ if (!isPromise(promise)) return scope[promiseAccessor] ? awaitPromise(scope, Promise.resolve(promise)) : resolveAwait(scope, scope[nodeAccessor], promise);
1699
1724
  let awaitCounter = tryBranch[AwaitCounter];
1700
1725
  placeholderShown.add(pendingEffects);
1701
1726
  if (!tryPlaceholder && !awaitCounter?.i) awaitCounter = createAwaitCounter(tryBranch, () => {
@@ -1706,7 +1731,7 @@ function _await_promise(nodeAccessor, params) {
1706
1731
  if (detachedParent === anchor.parentNode) anchor.remove();
1707
1732
  else anchor.replaceWith(detachedParent);
1708
1733
  }
1709
- } else dismissPlaceholder(tryBranch);
1734
+ }
1710
1735
  });
1711
1736
  if (!scope[promiseAccessor]) {
1712
1737
  if (awaitBranch) awaitBranch[PendingRenders] ||= [];
@@ -1722,7 +1747,8 @@ function _await_promise(nodeAccessor, params) {
1722
1747
  if (thisPromise === scope[promiseAccessor]) {
1723
1748
  const referenceNode = scope[nodeAccessor];
1724
1749
  scope[promiseAccessor] = 0;
1725
- if (scope["#ClosestBranch"]?.["#Gen"] === 0) {
1750
+ if (!scope[branchAccessor] || scope["#ClosestBranch"]?.["#Gen"] === 0) {
1751
+ if (!scope[branchAccessor]) awaitPromise(scope, data);
1726
1752
  awaitCounter.c();
1727
1753
  run();
1728
1754
  return;
@@ -1769,11 +1795,7 @@ function _await_content(nodeAccessor, template, walks, setup) {
1769
1795
  return (scope) => {
1770
1796
  const pendingScopes = collectScopes(() => (scope[branchAccessor] = createBranch(scope[Global], renderer, scope, scope[nodeAccessor].parentNode))[DetachedAwait] = renderer);
1771
1797
  scope[branchAccessor][PendingScopes] = pendingScopes;
1772
- const resolveSync = scope[promiseAccessor];
1773
- if (typeof resolveSync === "function") {
1774
- scope[promiseAccessor] = 0;
1775
- resolveSync();
1776
- }
1798
+ if (typeof scope[promiseAccessor] === "function") scope[promiseAccessor]();
1777
1799
  };
1778
1800
  }
1779
1801
  function addAwaitCounter(scope, tryBranch = findBranchWithKey(scope, PlaceholderContent)) {
@@ -1899,18 +1921,19 @@ let _dynamic_tag = /*@__PURE__*/ withBranches((nodeAccessor, getContent, getTagV
1899
1921
  return (scope, newRenderer, getInput) => {
1900
1922
  const normalizedRenderer = normalizeDynamicRenderer(newRenderer);
1901
1923
  if (scope[rendererAccessor] !== (scope[rendererAccessor] = rendererKey(normalizedRenderer)) || getContent && !(normalizedRenderer || scope[childScopeAccessor])) {
1902
- setConditionalRenderer(scope, nodeAccessor, normalizedRenderer || (getContent ? getContent(scope) : void 0), createBranchWithTagNameOrRenderer);
1924
+ const renderer = normalizedRenderer || (getContent ? getContent(scope) : void 0);
1925
+ setConditionalRenderer(scope, nodeAccessor, renderer, createBranchWithTagNameOrRenderer);
1903
1926
  if (getTagVar) if (scope[childScopeAccessor]) {
1904
1927
  scope[childScopeAccessor][TagVariable] = (value) => getTagVar()(scope, value);
1905
1928
  if (typeof normalizedRenderer === "string") bindNativeTagVar?.(scope[childScopeAccessor]);
1906
1929
  } else getTagVar()(scope, void 0);
1907
- if (typeof normalizedRenderer === "string") {
1930
+ if (typeof renderer === "string") {
1908
1931
  if (getContent) {
1909
1932
  const content = getContent(scope);
1910
- setConditionalRenderer(scope[childScopeAccessor], `#${normalizedRenderer.toLowerCase()}/0`, content, createAndSetupBranch);
1911
- if (content["accessor"]) subscribeToScopeSet(content[Owner], content[Accessor], scope[childScopeAccessor][`BranchScopes:#${normalizedRenderer.toLowerCase()}/0`]);
1933
+ setConditionalRenderer(scope[childScopeAccessor], `#${renderer.toLowerCase()}/0`, content, createAndSetupBranch);
1934
+ if (content["accessor"]) subscribeToScopeSet(content[Owner], content[Accessor], scope[childScopeAccessor][`BranchScopes:#${renderer.toLowerCase()}/0`]);
1912
1935
  }
1913
- } else if (normalizedRenderer?.["accessor"]) subscribeToScopeSet(normalizedRenderer[Owner], normalizedRenderer[Accessor], scope[childScopeAccessor]);
1936
+ } else if (renderer?.["accessor"]) subscribeToScopeSet(renderer[Owner], renderer[Accessor], scope[childScopeAccessor]);
1914
1937
  }
1915
1938
  if (normalizedRenderer) {
1916
1939
  const childScope = scope[childScopeAccessor];
@@ -1920,7 +1943,7 @@ let _dynamic_tag = /*@__PURE__*/ withBranches((nodeAccessor, getContent, getTagV
1920
1943
  (getContent ? _attrs : _attrs_content)(childScope, nodeAccessor, (inputIsArgs ? args[0] : args) || {}, controllableRenders[childScope[nodeAccessor].tagName]);
1921
1944
  if (childScope["EventAttributes:" + nodeAccessor] || childScope["ControlledHandler:" + nodeAccessor]) queueEffect(childScope, dynamicTagScript);
1922
1945
  } else {
1923
- for (const accessor in normalizedRenderer[LocalClosures]) normalizedRenderer[LocalClosures][accessor](childScope, normalizedRenderer[LocalClosureValues][accessor]);
1946
+ normalizedRenderer[LocalClosures]?.(childScope);
1924
1947
  if (normalizedRenderer["params"]) if (inputIsArgs) normalizedRenderer[Params](childScope, normalizedRenderer._ ? args[0] : args);
1925
1948
  else {
1926
1949
  const inputWithContent = getContent ? {
@@ -1941,14 +1964,13 @@ const _dynamic_tag_content = /*@__PURE__*/ withBranches((nodeAccessor) => {
1941
1964
  setConditionalRenderer(scope, nodeAccessor, renderer, createAndSetupBranch);
1942
1965
  if (renderer?.["accessor"]) subscribeToScopeSet(renderer[Owner], renderer[Accessor], scope[childScopeAccessor]);
1943
1966
  }
1944
- if (renderer) for (const accessor in renderer[LocalClosures]) renderer[LocalClosures][accessor](scope[childScopeAccessor], renderer[LocalClosureValues][accessor]);
1967
+ renderer?.[LocalClosures]?.(scope[childScopeAccessor]);
1945
1968
  };
1946
1969
  });
1947
1970
  let bindNativeTagVar;
1948
1971
  function installDynamicTagVar(bind) {
1949
1972
  bindNativeTagVar = bind;
1950
1973
  }
1951
- const _resume_dynamic_tag = /*@__PURE__*/ withBranches(() => _resumed[DYNAMIC_TAG_SCRIPT_REGISTER_ID] = dynamicTagScript);
1952
1974
  function dynamicTagScript(branch) {
1953
1975
  _attrs_script(branch, `#${branch[Renderer].toLowerCase()}/0`);
1954
1976
  }
@@ -1972,7 +1994,7 @@ function setConditionalRenderer(scope, nodeAccessor, newRenderer, createBranch)
1972
1994
  referenceNode.remove();
1973
1995
  }
1974
1996
  }
1975
- const loop = /*@__PURE__*/ withBranches((forEach) => (nodeAccessor, template, walks, setup, params) => {
1997
+ const loop = /*@__PURE__*/ withBranches((forEach, reorder) => (nodeAccessor, template, walks, setup, params) => {
1976
1998
  const scopesAccessor = BranchScopes$1 + nodeAccessor;
1977
1999
  const keyedScopesAccessor = KeyedScopes + nodeAccessor;
1978
2000
  const renderer = _content("", template, walks, setup)();
@@ -2033,61 +2055,67 @@ const loop = /*@__PURE__*/ withBranches((forEach) => (nodeAccessor, template, wa
2033
2055
  for (let i = start; i <= newEnd; i++) insertBranchBefore(newScopes[i], parentNode, afterReference);
2034
2056
  return;
2035
2057
  }
2036
- const diffLen = newEnd - start + 1;
2037
- const sources = new Array(diffLen);
2038
- const pred = new Array(diffLen);
2039
- const tails = [];
2040
- let tail = -1;
2041
- let lo;
2042
- let hi;
2043
- let mid;
2044
- for (let i = diffLen; i--;) sources[i] = newScopes[start + i]["#LoopIndex"] ?? -1;
2045
- for (let i = 0; i < diffLen; i++) if (~sources[i]) if (tail < 0 || sources[tails[tail]] < sources[i]) {
2046
- if (~tail) pred[i] = tails[tail];
2047
- tails[++tail] = i;
2048
- } else {
2049
- lo = 0;
2050
- hi = tail;
2051
- while (lo < hi) {
2052
- mid = (lo + hi) / 2 | 0;
2053
- if (sources[tails[mid]] < sources[i]) lo = mid + 1;
2054
- else hi = mid;
2055
- }
2056
- if (sources[i] < sources[tails[lo]]) {
2057
- if (lo > 0) pred[i] = tails[lo - 1];
2058
- tails[lo] = i;
2059
- }
2060
- }
2061
- hi = tails[tail];
2062
- lo = tail + 1;
2063
- while (lo-- > 0) {
2064
- tails[lo] = hi;
2065
- hi = pred[hi];
2066
- }
2067
- for (let i = diffLen; i--;) {
2068
- if (~tail && i === tails[tail]) tail--;
2069
- else insertBranchBefore(newScopes[start + i], parentNode, afterReference);
2070
- afterReference = newScopes[start + i][StartNode];
2071
- }
2058
+ reorder(newScopes, start, newEnd, parentNode, afterReference);
2072
2059
  };
2073
2060
  });
2074
2061
  const _for_of = /*@__PURE__*/ loop(([all, by], cb) => {
2075
2062
  by ||= bySecondArg;
2076
2063
  if (typeof by === "string") forOf(all, (item, i) => cb(item[by], [item, i]));
2077
2064
  else forOf(all, (item, i) => cb(by(item, i), [item, i]));
2078
- });
2065
+ }, reorderKeyed);
2079
2066
  const _for_in = /*@__PURE__*/ loop(([obj, by], cb) => {
2080
2067
  by ||= byFirstArg;
2081
2068
  forIn(obj, (key, value) => cb(by(key, value), [key, value]));
2082
- });
2069
+ }, reorderKeyed);
2083
2070
  const _for_to = /*@__PURE__*/ loop(([to, from, step, by], cb) => {
2084
2071
  by ||= byFirstArg;
2085
2072
  forTo(to, from, step, (v) => cb(by(v), [v]));
2086
- });
2073
+ }, reorderKeyed);
2087
2074
  const _for_until = /*@__PURE__*/ loop(([until, from, step, by], cb) => {
2088
2075
  by ||= byFirstArg;
2089
2076
  forUntil(until, from, step, (v) => cb(by(v), [v]));
2090
- });
2077
+ }, reorderKeyed);
2078
+ const _for_of_unkeyed = /*@__PURE__*/ loop(([all], cb) => forOf(all, (item, i) => cb(i, [item, i])));
2079
+ const _for_to_unkeyed = /*@__PURE__*/ loop(([to, from, step], cb) => forTo(to, from, step, (v) => cb(v, [v])));
2080
+ const _for_until_unkeyed = /*@__PURE__*/ loop(([until, from, step], cb) => forUntil(until, from, step, (v) => cb(v, [v])));
2081
+ function reorderKeyed(newScopes, start, newEnd, parentNode, afterReference) {
2082
+ const diffLen = newEnd - start + 1;
2083
+ const sources = new Array(diffLen);
2084
+ const pred = new Array(diffLen);
2085
+ const tails = [];
2086
+ let tail = -1;
2087
+ let lo;
2088
+ let hi;
2089
+ let mid;
2090
+ for (let i = diffLen; i--;) sources[i] = newScopes[start + i]["#LoopIndex"] ?? -1;
2091
+ for (let i = 0; i < diffLen; i++) if (~sources[i]) if (tail < 0 || sources[tails[tail]] < sources[i]) {
2092
+ if (~tail) pred[i] = tails[tail];
2093
+ tails[++tail] = i;
2094
+ } else {
2095
+ lo = 0;
2096
+ hi = tail;
2097
+ while (lo < hi) {
2098
+ mid = (lo + hi) / 2 | 0;
2099
+ if (sources[tails[mid]] < sources[i]) lo = mid + 1;
2100
+ else hi = mid;
2101
+ }
2102
+ if (sources[i] < sources[tails[lo]]) {
2103
+ if (lo > 0) pred[i] = tails[lo - 1];
2104
+ tails[lo] = i;
2105
+ }
2106
+ }
2107
+ hi = tails[tail];
2108
+ lo = tail + 1;
2109
+ while (lo-- > 0) {
2110
+ tails[lo] = hi;
2111
+ hi = pred[hi];
2112
+ }
2113
+ for (let i = diffLen; i--;) {
2114
+ if (~tail && i === tails[tail]) tail--;
2115
+ else insertBranchBefore(newScopes[start + i], parentNode, afterReference);
2116
+ afterReference = newScopes[start + i][StartNode];
2117
+ }
2118
+ }
2091
2119
  function createBranchWithTagNameOrRenderer($global, tagNameOrRenderer, parentScope, parentNode) {
2092
2120
  if (typeof tagNameOrRenderer === "string") assertValidTagName(tagNameOrRenderer);
2093
2121
  const branch = createBranch($global, tagNameOrRenderer, parentScope, parentNode);
@@ -2132,10 +2160,10 @@ Object.defineProperty(exports, "ClosestBranch", {
2132
2160
  return ClosestBranch;
2133
2161
  }
2134
2162
  });
2135
- Object.defineProperty(exports, "DYNAMIC_TAG_VAR_REGISTER_ID", {
2163
+ Object.defineProperty(exports, "DYNAMIC_TAG_SCRIPT_REGISTER_ID", {
2136
2164
  enumerable: true,
2137
2165
  get: function() {
2138
- return DYNAMIC_TAG_VAR_REGISTER_ID;
2166
+ return DYNAMIC_TAG_SCRIPT_REGISTER_ID;
2139
2167
  }
2140
2168
  });
2141
2169
  Object.defineProperty(exports, "EndNode", {
@@ -2558,6 +2586,12 @@ Object.defineProperty(exports, "_for_of", {
2558
2586
  return _for_of;
2559
2587
  }
2560
2588
  });
2589
+ Object.defineProperty(exports, "_for_of_unkeyed", {
2590
+ enumerable: true,
2591
+ get: function() {
2592
+ return _for_of_unkeyed;
2593
+ }
2594
+ });
2561
2595
  Object.defineProperty(exports, "_for_selector", {
2562
2596
  enumerable: true,
2563
2597
  get: function() {
@@ -2570,12 +2604,24 @@ Object.defineProperty(exports, "_for_to", {
2570
2604
  return _for_to;
2571
2605
  }
2572
2606
  });
2607
+ Object.defineProperty(exports, "_for_to_unkeyed", {
2608
+ enumerable: true,
2609
+ get: function() {
2610
+ return _for_to_unkeyed;
2611
+ }
2612
+ });
2573
2613
  Object.defineProperty(exports, "_for_until", {
2574
2614
  enumerable: true,
2575
2615
  get: function() {
2576
2616
  return _for_until;
2577
2617
  }
2578
2618
  });
2619
+ Object.defineProperty(exports, "_for_until_unkeyed", {
2620
+ enumerable: true,
2621
+ get: function() {
2622
+ return _for_until_unkeyed;
2623
+ }
2624
+ });
2579
2625
  Object.defineProperty(exports, "_global_read", {
2580
2626
  enumerable: true,
2581
2627
  get: function() {
@@ -2654,10 +2700,10 @@ Object.defineProperty(exports, "_or", {
2654
2700
  return _or;
2655
2701
  }
2656
2702
  });
2657
- Object.defineProperty(exports, "_resume_dynamic_tag", {
2703
+ Object.defineProperty(exports, "_resume_dynamic_tag_var", {
2658
2704
  enumerable: true,
2659
2705
  get: function() {
2660
- return _resume_dynamic_tag;
2706
+ return _resume_dynamic_tag_var;
2661
2707
  }
2662
2708
  });
2663
2709
  Object.defineProperty(exports, "_resumed", {
@@ -2786,6 +2832,12 @@ Object.defineProperty(exports, "destroyBranch", {
2786
2832
  return destroyBranch;
2787
2833
  }
2788
2834
  });
2835
+ Object.defineProperty(exports, "dynamicTagScript", {
2836
+ enumerable: true,
2837
+ get: function() {
2838
+ return dynamicTagScript;
2839
+ }
2840
+ });
2789
2841
  Object.defineProperty(exports, "forIn", {
2790
2842
  enumerable: true,
2791
2843
  get: function() {
@@ -2948,6 +3000,12 @@ Object.defineProperty(exports, "toInsertNode", {
2948
3000
  return toInsertNode;
2949
3001
  }
2950
3002
  });
3003
+ Object.defineProperty(exports, "withBranches", {
3004
+ enumerable: true,
3005
+ get: function() {
3006
+ return withBranches;
3007
+ }
3008
+ });
2951
3009
  Object.defineProperty(exports, "withLazy", {
2952
3010
  enumerable: true,
2953
3011
  get: function() {