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
@@ -33,4 +33,5 @@ export declare let isResuming: undefined | 0 | 1;
33
33
  export declare function getRegisteredWithScope(id: string, scope?: Scope): unknown;
34
34
  export declare function _var_resume<T extends Signal<unknown>>(id: string, signal: T): T;
35
35
  export declare function _el(id: string, accessor: EncodedAccessor): (scope: Scope) => () => any;
36
+ export declare function _resume_dynamic_tag_var(accessor: EncodedAccessor): void;
36
37
  export {};
@@ -10,7 +10,7 @@ export declare function _for_selector(ownerLoopNodeAccessor: EncodedAccessor, ow
10
10
  export declare function _if_closure(ownerConditionalNodeAccessor: EncodedAccessor, branch: number, fn: SignalFn): SignalFn;
11
11
  export declare function subscribeToScopeSet(ownerScope: Scope, accessor: Accessor, scope: Scope): void;
12
12
  export declare function _closure(...closureSignals: ReturnType<typeof _closure_get>[]): (scope: Scope) => void;
13
- export declare function _closure_get(valueAccessor: EncodedAccessor, fn: SignalFn, getOwnerScope?: (scope: Scope) => Scope, resumeId?: string): SignalFn & {
13
+ export declare function _closure_get(valueAccessor: EncodedAccessor, fn: SignalFn, getOwnerScope?: (scope: Scope) => Scope, resumeId?: string, ownerValueAccessor?: EncodedAccessor): ((scope: Scope, resumed?: 1) => void) & {
14
14
  scopeInstancesAccessor: string;
15
15
  signalIndexAccessor: string;
16
16
  index: number;
@@ -55,25 +55,25 @@ let unsafeStyleAttrReg = /[\\;]/g, replaceUnsafeStyleAttr = (c) => c === ";" ? "
55
55
  let childScopeAccessor = "A" + nodeAccessor, rendererAccessor = "D" + nodeAccessor;
56
56
  return (scope, newRenderer, getInput) => {
57
57
  let normalizedRenderer = normalizeDynamicRenderer(newRenderer);
58
- if (scope[rendererAccessor] !== (scope[rendererAccessor] = rendererKey(normalizedRenderer)) || getContent && !(normalizedRenderer || scope[childScopeAccessor])) if (setConditionalRenderer(scope, nodeAccessor, normalizedRenderer || (getContent ? getContent(scope) : void 0), createBranchWithTagNameOrRenderer), getTagVar && (scope[childScopeAccessor] ? (scope[childScopeAccessor].T = (value) => getTagVar()(scope, value), typeof normalizedRenderer == "string" && bindNativeTagVar?.(scope[childScopeAccessor])) : getTagVar()(scope, void 0)), typeof normalizedRenderer == "string") {
59
- if (getContent) {
60
- let content = getContent(scope);
61
- setConditionalRenderer(scope[childScopeAccessor], "a", content, createAndSetupBranch), content.f && subscribeToScopeSet(content.e, content.f, scope[childScopeAccessor].Aa);
62
- }
63
- } else normalizedRenderer?.f && subscribeToScopeSet(normalizedRenderer.e, normalizedRenderer.f, scope[childScopeAccessor]);
58
+ if (scope[rendererAccessor] !== (scope[rendererAccessor] = rendererKey(normalizedRenderer)) || getContent && !(normalizedRenderer || scope[childScopeAccessor])) {
59
+ let renderer = normalizedRenderer || (getContent ? getContent(scope) : void 0);
60
+ if (setConditionalRenderer(scope, nodeAccessor, renderer, createBranchWithTagNameOrRenderer), getTagVar && (scope[childScopeAccessor] ? (scope[childScopeAccessor].T = (value) => getTagVar()(scope, value), typeof normalizedRenderer == "string" && bindNativeTagVar?.(scope[childScopeAccessor])) : getTagVar()(scope, void 0)), typeof renderer == "string") {
61
+ if (getContent) {
62
+ let content = getContent(scope);
63
+ setConditionalRenderer(scope[childScopeAccessor], "a", content, createAndSetupBranch), content.f && subscribeToScopeSet(content.e, content.f, scope[childScopeAccessor].Aa);
64
+ }
65
+ } else renderer?.f && subscribeToScopeSet(renderer.e, renderer.f, scope[childScopeAccessor]);
66
+ }
64
67
  if (normalizedRenderer) {
65
68
  let childScope = scope[childScopeAccessor], args = getInput?.();
66
69
  if (typeof normalizedRenderer == "string") (getContent ? _attrs : _attrs_content)(childScope, "a", (inputIsArgs ? args[0] : args) || {}, controllableRenders[childScope.a.tagName]), (childScope.Ia || childScope.Ea) && queueEffect(childScope, dynamicTagScript);
70
+ else if (normalizedRenderer.g?.(childScope), normalizedRenderer.d) if (inputIsArgs) normalizedRenderer.d(childScope, normalizedRenderer._ ? args[0] : args);
67
71
  else {
68
- for (let accessor in normalizedRenderer.g) normalizedRenderer.g[accessor](childScope, normalizedRenderer.h[accessor]);
69
- if (normalizedRenderer.d) if (inputIsArgs) normalizedRenderer.d(childScope, normalizedRenderer._ ? args[0] : args);
70
- else {
71
- let inputWithContent = getContent ? {
72
- ...args,
73
- content: getContent(scope)
74
- } : args || {};
75
- normalizedRenderer.d(childScope, normalizedRenderer._ ? inputWithContent : [inputWithContent]);
76
- }
72
+ let inputWithContent = getContent ? {
73
+ ...args,
74
+ content: getContent(scope)
75
+ } : args || {};
76
+ normalizedRenderer.d(childScope, normalizedRenderer._ ? inputWithContent : [inputWithContent]);
77
77
  }
78
78
  }
79
79
  };
@@ -81,9 +81,9 @@ let unsafeStyleAttrReg = /[\\;]/g, replaceUnsafeStyleAttr = (c) => c === ";" ? "
81
81
  nodeAccessor = decodeAccessor(nodeAccessor);
82
82
  let childScopeAccessor = "A" + nodeAccessor, rendererAccessor = "D" + nodeAccessor;
83
83
  return (scope, renderer) => {
84
- if (scope[rendererAccessor] !== (scope[rendererAccessor] = rendererKey(renderer)) && (setConditionalRenderer(scope, nodeAccessor, renderer, createAndSetupBranch), renderer?.f && subscribeToScopeSet(renderer.e, renderer.f, scope[childScopeAccessor])), renderer) for (let accessor in renderer.g) renderer.g[accessor](scope[childScopeAccessor], renderer.h[accessor]);
84
+ scope[rendererAccessor] !== (scope[rendererAccessor] = rendererKey(renderer)) && (setConditionalRenderer(scope, nodeAccessor, renderer, createAndSetupBranch), renderer?.f && subscribeToScopeSet(renderer.e, renderer.f, scope[childScopeAccessor])), renderer?.g?.(scope[childScopeAccessor]);
85
85
  };
86
- }), bindNativeTagVar, _resume_dynamic_tag = /*@__PURE__*/ withBranches(() => _resumed._d = dynamicTagScript), loop = /*@__PURE__*/ withBranches((forEach) => (nodeAccessor, template, walks, setup, params) => {
86
+ }), bindNativeTagVar, loop = /*@__PURE__*/ withBranches((forEach, reorder) => (nodeAccessor, template, walks, setup, params) => {
87
87
  nodeAccessor = decodeAccessor(nodeAccessor);
88
88
  let scopesAccessor = "A" + nodeAccessor, keyedScopesAccessor = "O" + nodeAccessor, renderer = _content("", template, walks, setup)();
89
89
  return (scope, value) => {
@@ -107,25 +107,17 @@ let unsafeStyleAttrReg = /[\\;]/g, replaceUnsafeStyleAttr = (c) => c === ";" ? "
107
107
  for (let i = start; i <= newEnd; i++) insertBranchBefore(newScopes[i], parentNode, afterReference);
108
108
  return;
109
109
  }
110
- let diffLen = newEnd - start + 1, sources = Array(diffLen), pred = Array(diffLen), tails = [], tail = -1, lo, hi, mid;
111
- for (let i = diffLen; i--;) sources[i] = newScopes[start + i].I ?? -1;
112
- for (let i = 0; i < diffLen; i++) if (~sources[i]) if (tail < 0 || sources[tails[tail]] < sources[i]) ~tail && (pred[i] = tails[tail]), tails[++tail] = i;
113
- else {
114
- for (lo = 0, hi = tail; lo < hi;) mid = (lo + hi) / 2 | 0, sources[tails[mid]] < sources[i] ? lo = mid + 1 : hi = mid;
115
- sources[i] < sources[tails[lo]] && (lo > 0 && (pred[i] = tails[lo - 1]), tails[lo] = i);
116
- }
117
- for (hi = tails[tail], lo = tail + 1; lo-- > 0;) tails[lo] = hi, hi = pred[hi];
118
- for (let i = diffLen; i--;) ~tail && i === tails[tail] ? tail-- : insertBranchBefore(newScopes[start + i], parentNode, afterReference), afterReference = newScopes[start + i].S;
110
+ reorder(newScopes, start, newEnd, parentNode, afterReference);
119
111
  };
120
112
  }), _for_of = /*@__PURE__*/ loop(([all, by], cb) => {
121
113
  by ||= bySecondArg, typeof by == "string" ? forOf(all, (item, i) => cb(item[by], [item, i])) : forOf(all, (item, i) => cb(by(item, i), [item, i]));
122
- }), _for_in = /*@__PURE__*/ loop(([obj, by], cb) => {
114
+ }, reorderKeyed), _for_in = /*@__PURE__*/ loop(([obj, by], cb) => {
123
115
  by ||= byFirstArg, forIn(obj, (key, value) => cb(by(key, value), [key, value]));
124
- }), _for_to = /*@__PURE__*/ loop(([to, from, step, by], cb) => {
116
+ }, reorderKeyed), _for_to = /*@__PURE__*/ loop(([to, from, step, by], cb) => {
125
117
  by ||= byFirstArg, forTo(to, from, step, (v) => cb(by(v), [v]));
126
- }), _for_until = /*@__PURE__*/ loop(([until, from, step, by], cb) => {
118
+ }, reorderKeyed), _for_until = /*@__PURE__*/ loop(([until, from, step, by], cb) => {
127
119
  by ||= byFirstArg, forUntil(until, from, step, (v) => cb(by(v), [v]));
128
- });
120
+ }, reorderKeyed), _for_of_unkeyed = /*@__PURE__*/ loop(([all], cb) => forOf(all, (item, i) => cb(i, [item, i]))), _for_to_unkeyed = /*@__PURE__*/ loop(([to, from, step], cb) => forTo(to, from, step, (v) => cb(v, [v]))), _for_until_unkeyed = /*@__PURE__*/ loop(([until, from, step], cb) => forUntil(until, from, step, (v) => cb(v, [v])));
129
121
  //#region src/common/helpers.ts
130
122
  function _call(fn, v) {
131
123
  return fn(v), v;
@@ -450,16 +442,17 @@ function _closure(...closureSignals) {
450
442
  if (scope[scopeInstances]) for (let childScope of scope[scopeInstances]) childScope.H > 0 && childScope.H < runId && queueRender(childScope, closureSignals[childScope[signalIndex] || 0], -1);
451
443
  };
452
444
  }
453
- function _closure_get(valueAccessor, fn, getOwnerScope, resumeId) {
445
+ function _closure_get(valueAccessor, fn, getOwnerScope, resumeId, ownerValueAccessor) {
454
446
  valueAccessor = decodeAccessor(valueAccessor);
455
- let closureSignal = ((scope) => {
456
- scope[closureSignal.b] = closureSignal.c, fn(scope), subscribeToScopeSet(getOwnerScope ? getOwnerScope(scope) : scope._, closureSignal.a, scope);
447
+ let closureSignal = ((scope, resumed) => {
448
+ let ownerScope = getOwnerScope ? getOwnerScope(scope) : scope._;
449
+ scope[closureSignal.b] = closureSignal.c, (!resumed || ownerValueAccessor in ownerScope) && fn(scope), subscribeToScopeSet(ownerScope, closureSignal.a, scope);
457
450
  });
458
- return closureSignal.a = valueAccessor, closureSignal.b = "C" + valueAccessor, resumeId && (_resumed[resumeId] = closureSignal), closureSignal;
451
+ return closureSignal.a = valueAccessor, closureSignal.b = "C" + valueAccessor, resumeId && (ownerValueAccessor = decodeAccessor(ownerValueAccessor), _resumed[resumeId] = (scope) => closureSignal(scope, 1)), closureSignal;
459
452
  }
460
453
  function _child_setup(setup) {
461
454
  return setup._ = (scope, owner) => {
462
- scope._ = owner, queueRender(scope, setup, -1);
455
+ scope._ ||= owner, queueRender(scope, setup, -1);
463
456
  }, setup;
464
457
  }
465
458
  function _var(scope, childAccessor, signal) {
@@ -488,7 +481,7 @@ function _el_read(value) {
488
481
  return value;
489
482
  }
490
483
  function* traverse(scope, path, args, i = path.length - 1) {
491
- if (scope) if (Symbol.iterator in scope) for (let childScope of scope.values()) yield* traverse(childScope, path, args, i);
484
+ if (scope) if (Symbol.iterator in scope) for (let childScope of scope.values()) childScope.H !== 0 && (yield* traverse(childScope, path, args, i));
492
485
  else {
493
486
  let item = scope[path[i]];
494
487
  i ? yield* traverse(item, path, args, i - 1) : yield typeof item == "function" ? item(...args) : item;
@@ -617,6 +610,12 @@ function _var_resume(id, signal) {
617
610
  function _el(id, accessor) {
618
611
  return accessor = decodeAccessor(accessor), _resumed[id] = (scope) => () => scope[accessor];
619
612
  }
613
+ function _resume_dynamic_tag_var(accessor) {
614
+ accessor = decodeAccessor(accessor), _resumed["-" + accessor] = (scope) => () => {
615
+ let node = scope[accessor];
616
+ return node.nodeType === 8 ? node.previousSibling : node;
617
+ };
618
+ }
620
619
  //#endregion
621
620
  //#region src/dom/renderer.ts
622
621
  function createBranch($global, renderer, parentScope, parentNode) {
@@ -639,7 +638,7 @@ function _content(id, template, walks, setup, params, dynamicScopesAccessor) {
639
638
  } : (branch) => {
640
639
  walk(branch.S = branch.K = new Text(), walks, branch);
641
640
  };
642
- return (owner) => ({
641
+ return _resumed[id] = (owner) => ({
643
642
  a: id,
644
643
  b: clone,
645
644
  e: owner,
@@ -648,15 +647,26 @@ function _content(id, template, walks, setup, params, dynamicScopesAccessor) {
648
647
  f: dynamicScopesAccessor
649
648
  });
650
649
  }
651
- function _content_resume(id, template, walks, setup, params, dynamicScopesAccessor) {
652
- return _resumed[id] = _content(id, template, walks, setup, params, dynamicScopesAccessor);
650
+ function _content_resume(renderer, hasLocalValues = 0) {
651
+ return _resumed[renderer().a] = (owner, ...values) => {
652
+ for (let i = values.length, scope = owner; i > hasLocalValues;) {
653
+ let closures = values[--i];
654
+ for (let key in closures) key in scope || (scope[key] = closures[key]);
655
+ scope = scope._;
656
+ }
657
+ return renderer(owner, values[hasLocalValues - 1]);
658
+ };
653
659
  }
654
660
  function _content_closures(renderer, closureFns) {
655
661
  let closureSignals = {};
656
662
  for (let key in closureFns) closureSignals[key] = _const(+key, closureFns[key]);
657
663
  return (owner, closureValues) => {
658
- let instance = renderer(owner);
659
- return instance.g = closureSignals, instance.h = closureValues, instance;
664
+ let instance = renderer(owner), clone = instance.b, setClosures = instance.g = (branch) => {
665
+ for (let key in closureSignals) closureSignals[key](branch, closureValues[key]);
666
+ };
667
+ return instance.b = (branch, ns) => {
668
+ clone(branch, ns), setClosures(branch);
669
+ }, instance;
660
670
  };
661
671
  }
662
672
  function createCloneableHTML(html, ns) {
@@ -766,8 +776,7 @@ function attrsInternal(scope, nodeAccessor, nextAttrs, controllable) {
766
776
  }
767
777
  function _attr_content(scope, nodeAccessor, value) {
768
778
  let content = normalizeClientRender(value);
769
- scope["D" + nodeAccessor] !== (scope["D" + nodeAccessor] = rendererKey(content)) && (setConditionalRenderer(scope, nodeAccessor, content, createAndSetupBranch), content?.f && subscribeToScopeSet(content.e, content.f, scope["A" + nodeAccessor]));
770
- for (let accessor in content?.g) content.g[accessor](scope["A" + nodeAccessor], content.h[accessor]);
779
+ scope["D" + nodeAccessor] !== (scope["D" + nodeAccessor] = rendererKey(content)) && (setConditionalRenderer(scope, nodeAccessor, content, createAndSetupBranch), content?.f && subscribeToScopeSet(content.e, content.f, scope["A" + nodeAccessor])), content?.g?.(scope["A" + nodeAccessor]);
771
780
  }
772
781
  function _attrs_script(scope, nodeAccessor) {
773
782
  let el = scope[nodeAccessor], events = scope["I" + nodeAccessor];
@@ -1017,16 +1026,17 @@ function _await_promise(nodeAccessor, params) {
1017
1026
  let awaitBranch = scope[branchAccessor];
1018
1027
  return awaitBranch.V && (awaitBranch.Y = awaitBranch.Y?.forEach(syncGen), setupBranch(awaitBranch.V, awaitBranch), awaitBranch.V = 0, insertBranchBefore(awaitBranch, scope[nodeAccessor].parentNode, scope[nodeAccessor]), referenceNode.remove()), params?.(awaitBranch, [value]), awaitBranch;
1019
1028
  }, awaitPromise = (scope, promise) => {
1020
- !isPromise(promise) && scope[promiseAccessor] && (promise = Promise.resolve(promise));
1021
- let awaitBranch = scope[branchAccessor], tryPlaceholder = findBranchWithKey(scope, "Q"), tryBranch = tryPlaceholder || awaitBranch;
1022
- if (!(isPromise(promise) ? tryBranch : awaitBranch)) {
1023
- scope[promiseAccessor] = () => awaitPromise(scope, promise);
1024
- return;
1025
- }
1026
- if (!isPromise(promise)) {
1027
- resolveAwait(scope, scope[nodeAccessor], promise);
1029
+ isPromise(scope[promiseAccessor]) || (scope[promiseAccessor] = 0);
1030
+ let awaitBranch = scope[branchAccessor], tryPlaceholder = (isPromise(promise) || scope[promiseAccessor]) && findBranchWithKey(scope, "Q"), tryBranch = tryPlaceholder || awaitBranch;
1031
+ if (!tryBranch) {
1032
+ let replay = scope[promiseAccessor] = () => replay === scope[promiseAccessor] && awaitPromise(scope, promise), awaitCounter = findBranchWithKey(scope, "Q")?.O;
1033
+ if (awaitCounter?.i) {
1034
+ let complete = awaitCounter.c;
1035
+ awaitCounter.c = () => complete() || queueAsyncRender(scope, replay);
1036
+ }
1028
1037
  return;
1029
1038
  }
1039
+ if (!isPromise(promise)) return scope[promiseAccessor] ? awaitPromise(scope, Promise.resolve(promise)) : resolveAwait(scope, scope[nodeAccessor], promise);
1030
1040
  let awaitCounter = tryBranch.O;
1031
1041
  placeholderShown.add(pendingEffects), !tryPlaceholder && !awaitCounter?.i && (awaitCounter = createAwaitCounter(tryBranch, () => {
1032
1042
  if (tryBranch === scope[branchAccessor]) {
@@ -1035,15 +1045,15 @@ function _await_promise(nodeAccessor, params) {
1035
1045
  let detachedParent = scope[branchAccessor].S.parentNode;
1036
1046
  detachedParent === anchor.parentNode ? anchor.remove() : anchor.replaceWith(detachedParent);
1037
1047
  }
1038
- } else dismissPlaceholder(tryBranch);
1048
+ }
1039
1049
  })), scope[promiseAccessor] || (awaitBranch && (awaitBranch.W ||= []), tryPlaceholder ? awaitCounter = addAwaitCounter(scope, tryPlaceholder) : scheduleAwaitFrame(awaitCounter, scope, () => {
1040
1050
  awaitBranch.V || (awaitBranch.S.parentNode.insertBefore(scope[nodeAccessor], awaitBranch.S), tempDetachBranch(tryBranch));
1041
1051
  }));
1042
1052
  let thisPromise = scope[promiseAccessor] = promise.then((data) => {
1043
1053
  if (thisPromise === scope[promiseAccessor]) {
1044
1054
  let referenceNode = scope[nodeAccessor];
1045
- if (scope[promiseAccessor] = 0, scope.F?.H === 0) {
1046
- awaitCounter.c(), run();
1055
+ if (scope[promiseAccessor] = 0, !scope[branchAccessor] || scope.F?.H === 0) {
1056
+ scope[branchAccessor] || awaitPromise(scope, data), awaitCounter.c(), run();
1047
1057
  return;
1048
1058
  }
1049
1059
  queueAsyncRender(scope, () => {
@@ -1073,9 +1083,7 @@ function _await_content(nodeAccessor, template, walks, setup) {
1073
1083
  let branchAccessor = "A" + nodeAccessor, promiseAccessor = "L" + nodeAccessor, renderer = _content("", template, walks, setup)();
1074
1084
  return (scope) => {
1075
1085
  let pendingScopes = collectScopes(() => (scope[branchAccessor] = createBranch(scope.$, renderer, scope, scope[nodeAccessor].parentNode)).V = renderer);
1076
- scope[branchAccessor].Y = pendingScopes;
1077
- let resolveSync = scope[promiseAccessor];
1078
- typeof resolveSync == "function" && (scope[promiseAccessor] = 0, resolveSync());
1086
+ scope[branchAccessor].Y = pendingScopes, typeof scope[promiseAccessor] == "function" && scope[promiseAccessor]();
1079
1087
  };
1080
1088
  }
1081
1089
  function addAwaitCounter(scope, tryBranch = findBranchWithKey(scope, "Q")) {
@@ -1138,6 +1146,17 @@ function setConditionalRenderer(scope, nodeAccessor, newRenderer, createBranch)
1138
1146
  let referenceNode = scope[nodeAccessor], prevBranch = scope["A" + nodeAccessor], parentNode = referenceNode.nodeType > 1 ? (prevBranch?.S || referenceNode).parentNode : referenceNode, newBranch = scope["A" + nodeAccessor] = newRenderer && createBranch(scope.$, newRenderer, scope, parentNode);
1139
1147
  referenceNode === parentNode ? (prevBranch && (destroyBranch(prevBranch), referenceNode.textContent = ""), newBranch && insertBranchBefore(newBranch, parentNode, null)) : prevBranch ? (newBranch ? insertBranchBefore(newBranch, parentNode, prevBranch.S) : parentNode.insertBefore(referenceNode, prevBranch.S), removeAndDestroyBranch(prevBranch)) : newBranch && (insertBranchBefore(newBranch, parentNode, referenceNode), referenceNode.remove());
1140
1148
  }
1149
+ function reorderKeyed(newScopes, start, newEnd, parentNode, afterReference) {
1150
+ let diffLen = newEnd - start + 1, sources = Array(diffLen), pred = Array(diffLen), tails = [], tail = -1, lo, hi, mid;
1151
+ for (let i = diffLen; i--;) sources[i] = newScopes[start + i].I ?? -1;
1152
+ for (let i = 0; i < diffLen; i++) if (~sources[i]) if (tail < 0 || sources[tails[tail]] < sources[i]) ~tail && (pred[i] = tails[tail]), tails[++tail] = i;
1153
+ else {
1154
+ for (lo = 0, hi = tail; lo < hi;) mid = (lo + hi) / 2 | 0, sources[tails[mid]] < sources[i] ? lo = mid + 1 : hi = mid;
1155
+ sources[i] < sources[tails[lo]] && (lo > 0 && (pred[i] = tails[lo - 1]), tails[lo] = i);
1156
+ }
1157
+ for (hi = tails[tail], lo = tail + 1; lo-- > 0;) tails[lo] = hi, hi = pred[hi];
1158
+ for (let i = diffLen; i--;) ~tail && i === tails[tail] ? tail-- : insertBranchBefore(newScopes[start + i], parentNode, afterReference), afterReference = newScopes[start + i].S;
1159
+ }
1141
1160
  function createBranchWithTagNameOrRenderer($global, tagNameOrRenderer, parentScope, parentNode) {
1142
1161
  let branch = createBranch($global, tagNameOrRenderer, parentScope, parentNode);
1143
1162
  return typeof tagNameOrRenderer == "string" ? branch.a = branch.S = branch.K = document.createElementNS(tagNameOrRenderer === "svg" ? "http://www.w3.org/2000/svg" : tagNameOrRenderer === "math" ? "http://www.w3.org/1998/Math/MathML" : parentNode.namespaceURI, tagNameOrRenderer) : setupBranch(tagNameOrRenderer, branch), branch;
@@ -1149,4 +1168,4 @@ function byFirstArg(name) {
1149
1168
  return name;
1150
1169
  }
1151
1170
  //#endregion
1152
- export { _attrs_script as $, installCatch as $t, _attr_input_value_script as A, _for_selector as At, _attr as B, _return_change as Bt, _attr_input_checkedValue_script as C, withLazy as Ct, _attr_input_value_attribute_default as D, _const as Dt, _attr_input_value as E, _closure_get as Et, _controllable_open as F, _if_closure as Ft, _attr_nonce as G, destroyBranch as Gt, _attr_class_item as H, _var as Ht, _controllable_select as I, _let as It, _attr_style_items as J, syncGen as Jt, _attr_style as K, insertBranchBefore as Kt, _controllable_textarea as L, _let_change as Lt, _attr_select_value_default as M, _hoist as Mt, _attr_select_value_script as N, _hoist_resume as Nt, _attr_input_value_default as O, _el_read as Ot, _controllable_input as P, _id as Pt, _attrs_partial_content as Q, caughtError as Qt, controllableRenders as R, _or as Rt, _attr_input_checkedValue_default as S, readyFailed as St, _attr_input_checked_script as T, _closure as Tt, _attr_class_items as U, _var_change as Ut, _attr_class as V, _script as Vt, _attr_content as W, _assert_init as Wt, _attrs_content as X, $signal as Xt, _attrs as Y, _on as Yt, _attrs_partial as Z, $signalReset as Zt, _attr_details_or_dialog_open as _, _var_resume as _t, _for_in as a, run as an, _text_content as at, _attr_input_checked as b, initEmbedded as bt, _for_until as c, forIn as cn, toInsertNode as ct, _show as d, forUntil as dn, _content_resume as dt, placeholderShown as en, _html as et, _try as f, _assert_hoist as fn, createAndSetupBranch as ft, renderCatch as g, _resumed as gt, patchDynamicTag as h, decodeAccessor as hn, _el as ht, _dynamic_tag_content as i, queueRender as in, _text as it, _attr_select_value as j, _global_read as jt, _attr_input_value_dynamic_default as k, _for_closure as kt, _if as l, forOf as ln, _content as lt, installDynamicTagVar as m, _call as mn, setupBranch as mt, _await_promise as n, queueAsyncRender as nn, _style_rule_item as nt, _for_of as o, runEffects as on, _to_text as ot, addAwaitCounter as p, _hoist_read_error as pn, createBranch as pt, _attr_style_item as q, removeAndDestroyBranch as qt, _dynamic_tag as r, queueEffect as rn, _style_shell as rt, _for_to as s, runId as sn, insertChildNodes as st, _await_content as t, prepareEffects as tn, _lifecycle as tt, _resume_dynamic_tag as u, forTo as un, _content_closures as ut, _attr_details_or_dialog_open_default as v, getRegisteredWithScope as vt, _attr_input_checked_default as w, _child_setup as wt, _attr_input_checkedValue as x, ready as xt, _attr_details_or_dialog_open_script as y, init as yt, controllableScripts as z, _return as zt };
1171
+ export { _attrs_content as $, _on as $t, _attr_input_value_attribute_default as A, _closure_get as At, _controllable_textarea as B, _let as Bt, _attr_input_checked as C, init as Ct, _attr_input_checked_default as D, withLazy as Dt, _attr_input_checkedValue_script as E, readyFailed as Et, _attr_select_value_default as F, _global_read as Ft, _attr_class_item as G, _script as Gt, controllableScripts as H, _or as Ht, _attr_select_value_script as I, _hoist as It, _attr_nonce as J, _assert_init as Jt, _attr_class_items as K, _var as Kt, _controllable_input as L, _hoist_resume as Lt, _attr_input_value_dynamic_default as M, _el_read as Mt, _attr_input_value_script as N, _for_closure as Nt, _attr_input_checked_script as O, _child_setup as Ot, _attr_select_value as P, _for_selector as Pt, _attrs as Q, syncGen as Qt, _controllable_open as R, _id as Rt, _attr_details_or_dialog_open_script as S, getRegisteredWithScope as St, _attr_input_checkedValue_default as T, 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 _, _hoist_read_error as _n, setupBranch as _t, _for_in as a, prepareEffects as an, _style_rule_item as at, _attr_details_or_dialog_open as b, _resumed as bt, _for_to as c, queueRender as cn, _text_content as ct, _for_until_unkeyed as d, runId as dn, toInsertNode as dt, $signal as en, _attrs_partial as et, _if as f, forIn as fn, _content as ft, dynamicTagScript as g, _assert_hoist as gn, createBranch as gt, addAwaitCounter as h, forUntil as hn, createAndSetupBranch as ht, _dynamic_tag_content as i, placeholderShown as in, _lifecycle as it, _attr_input_value_default as j, _const as jt, _attr_input_value as k, _closure as kt, _for_to_unkeyed as l, run as ln, _to_text as lt, _try as m, forTo as mn, _content_resume as mt, _await_promise as n, caughtError as nn, _attrs_script as nt, _for_of as o, queueAsyncRender as on, _style_shell as ot, _show as p, forOf as pn, _content_closures as pt, _attr_content as q, _var_change as qt, _dynamic_tag as r, installCatch as rn, _html as rt, _for_of_unkeyed as s, queueEffect as sn, _text as st, _await_content as t, $signalReset as tn, _attrs_partial_content as tt, _for_until as u, runEffects as un, insertChildNodes as ut, patchDynamicTag as v, _call as vn, _el as vt, _attr_input_checkedValue as w, initEmbedded as wt, _attr_details_or_dialog_open_default as x, _var_resume as xt, renderCatch as y, withBranches as yn, _resume_dynamic_tag_var as yt, _controllable_select as z, _if_closure as zt };