marko 6.3.55 → 6.4.0

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 (90) hide show
  1. package/cheatsheet.md +3 -2
  2. package/dist/common/accessor.d.ts +3 -0
  3. package/dist/common/accessor.debug.d.ts +3 -0
  4. package/dist/common/constants/accessor-prefix.d.ts +1 -0
  5. package/dist/common/constants/accessor-prefix.debug.d.ts +1 -0
  6. package/dist/common/constants/accessor-prop.d.ts +3 -0
  7. package/dist/common/constants/accessor-prop.debug.d.ts +3 -0
  8. package/dist/common/constants/closure-scopes-prop.d.ts +4 -0
  9. package/dist/common/constants/closure-scopes-prop.debug.d.ts +4 -0
  10. package/dist/common/types.d.ts +9 -3
  11. package/dist/debug/dom/catch.feat.js +12 -14
  12. package/dist/debug/dom/catch.feat.mjs +12 -14
  13. package/dist/debug/dom/controllable-input.feat.js +1 -1
  14. package/dist/debug/dom/controllable-input.feat.mjs +1 -1
  15. package/dist/debug/dom/controllable-open.feat.js +1 -1
  16. package/dist/debug/dom/controllable-open.feat.mjs +1 -1
  17. package/dist/debug/dom/controllable-select.feat.js +1 -1
  18. package/dist/debug/dom/controllable-select.feat.mjs +1 -1
  19. package/dist/debug/dom/controllable-textarea.feat.js +1 -1
  20. package/dist/debug/dom/controllable-textarea.feat.mjs +1 -1
  21. package/dist/debug/dom/controllable.feat.js +1 -1
  22. package/dist/debug/dom/controllable.feat.mjs +1 -1
  23. package/dist/debug/dom/dynamic-tag-script.feat.js +1 -1
  24. package/dist/debug/dom/dynamic-tag-script.feat.mjs +1 -1
  25. package/dist/debug/dom/dynamic-tag-var.feat.js +1 -1
  26. package/dist/debug/dom/dynamic-tag-var.feat.mjs +1 -1
  27. package/dist/debug/dom/lazy.feat.js +4 -0
  28. package/dist/debug/dom/lazy.feat.mjs +4 -0
  29. package/dist/debug/dom/placeholder.feat.js +1 -1
  30. package/dist/debug/dom/placeholder.feat.mjs +1 -1
  31. package/dist/debug/{dom-CI0Vojyk.js → dom-BRO5aArp.js} +248 -193
  32. package/dist/debug/{dom-tl43c2wO.mjs → dom-Btj2QJhk.mjs} +225 -176
  33. package/dist/debug/dom.js +15 -13
  34. package/dist/debug/dom.mjs +15 -13
  35. package/dist/debug/html.js +605 -523
  36. package/dist/debug/html.mjs +604 -524
  37. package/dist/dom/abort-signal.d.ts +2 -0
  38. package/dist/dom/catch.feat.js +6 -7
  39. package/dist/dom/catch.feat.mjs +5 -7
  40. package/dist/dom/control-flow.d.ts +3 -5
  41. package/dist/dom/controllable-input.feat.js +3 -2
  42. package/dist/dom/controllable-input.feat.mjs +1 -1
  43. package/dist/dom/controllable-open.feat.js +3 -2
  44. package/dist/dom/controllable-open.feat.mjs +1 -1
  45. package/dist/dom/controllable-select.feat.js +3 -2
  46. package/dist/dom/controllable-select.feat.mjs +1 -1
  47. package/dist/dom/controllable-textarea.feat.js +3 -2
  48. package/dist/dom/controllable-textarea.feat.mjs +1 -1
  49. package/dist/dom/controllable.feat.js +3 -2
  50. package/dist/dom/controllable.feat.mjs +1 -1
  51. package/dist/dom/dynamic-tag-script.feat.js +3 -2
  52. package/dist/dom/dynamic-tag-script.feat.mjs +1 -1
  53. package/dist/dom/dynamic-tag-var.feat.js +2 -1
  54. package/dist/dom/dynamic-tag-var.feat.mjs +1 -1
  55. package/dist/dom/lazy.feat.d.ts +1 -0
  56. package/dist/dom/lazy.feat.js +4 -0
  57. package/dist/dom/lazy.feat.mjs +4 -0
  58. package/dist/dom/load.d.ts +3 -3
  59. package/dist/dom/placeholder.feat.js +4 -3
  60. package/dist/dom/placeholder.feat.mjs +1 -1
  61. package/dist/dom/queue.d.ts +2 -4
  62. package/dist/dom/resume.d.ts +2 -2
  63. package/dist/dom/scope.d.ts +0 -1
  64. package/dist/dom/signals.d.ts +1 -1
  65. package/dist/{dom-4udEPZaj.mjs → dom-B-v8Gw6T.mjs} +122 -92
  66. package/dist/{dom-C1mr-TA7.js → dom-BSsI9OPC.js} +218 -187
  67. package/dist/dom.d.ts +1 -1
  68. package/dist/dom.js +59 -56
  69. package/dist/dom.mjs +35 -33
  70. package/dist/html/attrs.d.ts +2 -0
  71. package/dist/html/writer.d.ts +5 -11
  72. package/dist/html.d.ts +1 -1
  73. package/dist/html.js +367 -327
  74. package/dist/html.mjs +366 -327
  75. package/dist/translator/index.js +866 -748
  76. package/dist/translator/util/binding-has-prop.d.ts +2 -0
  77. package/dist/translator/util/entry-builder.d.ts +2 -0
  78. package/dist/translator/util/generate-uid.d.ts +5 -0
  79. package/dist/translator/util/optional.d.ts +1 -3
  80. package/dist/translator/util/references.d.ts +6 -2
  81. package/dist/translator/util/runtime.d.ts +3 -3
  82. package/dist/translator/util/sections.d.ts +8 -2
  83. package/dist/translator/util/serialize-reasons.d.ts +3 -1
  84. package/dist/translator/util/setup-work.d.ts +5 -0
  85. package/dist/translator/util/signals.d.ts +5 -7
  86. package/dist/translator/util/translate-attrs.d.ts +2 -1
  87. package/dist/translator/visitors/tag/native-tag.d.ts +1 -0
  88. package/package.json +3 -3
  89. package/tags-html.d.ts +4 -3
  90. package/dist/translator/util/setup-statements.d.ts +0 -5
@@ -1,16 +1,18 @@
1
1
  let unsafeStyleAttrReg = /[\\;]/g, replaceUnsafeStyleAttr = (c) => c === ";" ? "\\3B " : "\\\\", toDelimitedString = function toDelimitedString(val, delimiter, stringify) {
2
2
  let str = "", sep = "", part;
3
- if (val) if (typeof val != "object") str += val;
4
- else if (Array.isArray(val)) for (let v of val) part = toDelimitedString(v, delimiter, stringify), part && (str += sep + part, sep = delimiter);
5
- else for (let name in val) part = stringify(name, val[name]), part && (str += sep + part, sep = delimiter);
3
+ if (val) {
4
+ if (typeof val != "object") str += val;
5
+ else if (Array.isArray(val)) for (let v of val) part = toDelimitedString(v, delimiter, stringify), part && (str += sep + part, sep = delimiter);
6
+ else for (let name in val) part = stringify(name, val[name]), part && (str += sep + part, sep = delimiter);
7
+ }
6
8
  return str;
7
- }, decodeAccessor = (num) => (num + (num < 26 ? 10 : num < 962 ? 334 : 11998)).toString(36), branchesEnabled, dynamicHtmlEnabled, rendering, runId = 2, caughtError = /* @__PURE__ */ new WeakSet(), placeholderShown = /* @__PURE__ */ new WeakSet(), pendingEffects = [], pendingRenders = [], runEffects = ((effects) => {
9
+ }, decodeAccessor = (num) => (num + (num < 26 ? 10 : num < 962 ? 334 : 11998)).toString(36), branchesEnabled, dynamicHtmlEnabled, rendering, runId = 2, pendingEffects = [], pendingRenders = [], runEffects = ((effects) => {
8
10
  for (let i = 0; i < effects.length;) effects[i++](effects[i++]);
9
11
  }), runRender = (render) => {
10
12
  (!branchesEnabled || render.b.F?.H !== 0) && render.c(render.b, render.d);
11
13
  }, catchEnabled, abortsEnabled, subscriptionsEnabled, delegate = (type, handler) => handler[1 + type] ||= (document.addEventListener(type, handler, !0), 1), parsers = {}, nextScopeId = 1e6, collectingScopes, destroyNestedScopes = function destroyNestedScopes(scope) {
12
14
  scope.H = 0, scope.D?.forEach(destroyNestedScopes), scope.B?.forEach(cleanupScope);
13
- }, isScheduled, channel, _return = (scope, value) => scope.T?.(value), _var_change = (scope, value) => scope.U?.(value), tagIdsByGlobal = /* @__PURE__ */ new WeakMap(), currentNode, walkInternal = function walkInternal(currentWalkIndex, walkCodes, scope) {
15
+ }, isScheduled, channel, _return = (scope, value) => scope.T ? scope.T(value) : scope.RV = value, _var_change = (scope, value) => scope.U?.(value), tagIdsByGlobal = /* @__PURE__ */ new WeakMap(), currentNode, walkInternal = function walkInternal(currentWalkIndex, walkCodes, scope) {
14
16
  let value, currentMultiplier, storedMultiplier = 0, currentScopeIndex = 0;
15
17
  for (; currentWalkIndex < walkCodes.length;) if (value = walkCodes.charCodeAt(currentWalkIndex++), currentMultiplier = storedMultiplier, storedMultiplier = 0, value === 32) scope[decodeAccessor(currentScopeIndex++)] = currentNode;
16
18
  else if (value === 37 || value === 49) currentNode.replaceWith(currentNode = scope[decodeAccessor(currentScopeIndex++)] = new Text()), value === 49 && (scope[decodeAccessor(currentScopeIndex++)] = skipScope());
@@ -67,13 +69,15 @@ let unsafeStyleAttrReg = /[\\;]/g, replaceUnsafeStyleAttr = (c) => c === ";" ? "
67
69
  if (normalizedRenderer) {
68
70
  let childScope = scope[childScopeAccessor], args = getInput?.();
69
71
  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);
71
- else {
72
- let inputWithContent = getContent ? {
73
- ...args,
74
- content: getContent(scope)
75
- } : args || {};
76
- normalizedRenderer.d(childScope, normalizedRenderer._ ? inputWithContent : [inputWithContent]);
72
+ else if (normalizedRenderer.g?.(childScope), normalizedRenderer.d) {
73
+ if (inputIsArgs) normalizedRenderer.d(childScope, normalizedRenderer._ ? args[0] : args);
74
+ else {
75
+ let inputWithContent = getContent ? {
76
+ ...args,
77
+ content: getContent(scope)
78
+ } : args || {};
79
+ normalizedRenderer.d(childScope, normalizedRenderer._ ? inputWithContent : [inputWithContent]);
80
+ }
77
81
  }
78
82
  }
79
83
  };
@@ -232,8 +236,8 @@ function prepareEffects(fn) {
232
236
  }
233
237
  return preparedEffects;
234
238
  }
235
- function installCatch(wrapEffects, wrapRender) {
236
- catchEnabled = 1, withBranches(), runEffects = wrapEffects(runEffects), runRender = wrapRender(runRender);
239
+ function installCatch(catchEffects, wrapRender) {
240
+ catchEnabled = 1, withBranches(), runEffects = catchEffects, runRender = wrapRender(runRender);
237
241
  }
238
242
  function runRenders() {
239
243
  for (; pendingRenders.length;) {
@@ -259,6 +263,10 @@ function $signalReset(scope, id) {
259
263
  function $signal(scope, id) {
260
264
  return abortsEnabled = 1, trackCleanup(scope), ((scope.A ||= {})[id] ||= new AbortController()).signal;
261
265
  }
266
+ /** Runs `abort` as a destroyed scope's `$signal` would fire, without creating one. */
267
+ function trackAbort(scope, id, abort) {
268
+ abortsEnabled = 1, trackCleanup(scope), (scope.A ||= {})[id] = { abort };
269
+ }
262
270
  /** Enrols `scope` with its branch so destroying the branch cleans it up. */
263
271
  function trackCleanup(scope, subscribers) {
264
272
  let branch = scope.F;
@@ -273,8 +281,10 @@ function toArray(opt) {
273
281
  return opt ? Array.isArray(opt) ? opt : [opt] : [];
274
282
  }
275
283
  function forEach(opt, cb) {
276
- if (opt) if (Array.isArray(opt)) for (let item of opt) cb(item);
277
- else cb(opt);
284
+ if (opt) {
285
+ if (Array.isArray(opt)) for (let item of opt) cb(item);
286
+ else cb(opt);
287
+ }
278
288
  }
279
289
  function push(opt, item) {
280
290
  return opt ? Array.isArray(opt) ? (opt.push(item), opt) : [opt, item] : item;
@@ -323,11 +333,6 @@ function collectScopes(fn) {
323
333
  function skipScope() {
324
334
  return nextScopeId++;
325
335
  }
326
- function findBranchWithKey(scope, key) {
327
- let branch = scope.F;
328
- for (; branch && branch[key] == null;) branch = branch.N;
329
- return branch;
330
- }
331
336
  function destroyBranch(branch) {
332
337
  branch.N?.D?.delete(branch), destroyNestedScopes(branch);
333
338
  }
@@ -439,16 +444,19 @@ function _closure(...closureSignals) {
439
444
  let [firstSignal] = closureSignals, scopeInstances = firstSignal.a, signalIndex = firstSignal.b;
440
445
  for (let i = closureSignals.length; i--;) closureSignals[i].c = i;
441
446
  return (scope) => {
442
- if (scope[scopeInstances]) for (let childScope of scope[scopeInstances]) childScope.H > 0 && childScope.H < runId && queueRender(childScope, closureSignals[childScope[signalIndex] || 0], -1);
447
+ if (scope[scopeInstances]) {
448
+ scope[scopeInstances]._ = 1;
449
+ for (let childScope of scope[scopeInstances]) childScope.H > 0 && childScope.H < runId && queueRender(childScope, closureSignals[childScope[signalIndex] || 0], -1);
450
+ }
443
451
  };
444
452
  }
445
- function _closure_get(valueAccessor, fn, getOwnerScope, resumeId, ownerValueAccessor) {
453
+ function _closure_get(valueAccessor, fn, getOwnerScope, resumeId) {
446
454
  valueAccessor = decodeAccessor(valueAccessor);
447
455
  let closureSignal = ((scope, resumed) => {
448
456
  let ownerScope = getOwnerScope ? getOwnerScope(scope) : scope._;
449
- scope[closureSignal.b] = closureSignal.c, (!resumed || ownerValueAccessor in ownerScope) && fn(scope), subscribeToScopeSet(ownerScope, closureSignal.a, scope);
457
+ scope[closureSignal.b] = closureSignal.c, resumed ? ownerScope[closureSignal.a]._ && queueAsyncRender(scope, closureSignal) : fn(scope), subscribeToScopeSet(ownerScope, closureSignal.a, scope);
450
458
  });
451
- return closureSignal.a = valueAccessor, closureSignal.b = "C" + valueAccessor, resumeId && (ownerValueAccessor = decodeAccessor(ownerValueAccessor), _resumed[resumeId] = (scope) => closureSignal(scope, 1)), closureSignal;
459
+ return closureSignal.a = valueAccessor, closureSignal.b = "C" + valueAccessor, resumeId && (_resumed[resumeId] = (scope) => closureSignal(scope, 1)), closureSignal;
452
460
  }
453
461
  function _child_setup(setup) {
454
462
  return setup._ = (scope, owner) => {
@@ -456,7 +464,8 @@ function _child_setup(setup) {
456
464
  }, setup;
457
465
  }
458
466
  function _var(scope, childAccessor, signal) {
459
- scope[decodeAccessor(childAccessor)].T = (value) => signal(scope, value);
467
+ let childScope = scope[decodeAccessor(childAccessor)];
468
+ childScope.T = (value) => signal(scope, value), "RV" in childScope && signal(scope, childScope.RV);
460
469
  }
461
470
  function _return_change(scope, changeHandler) {
462
471
  scope.U = changeHandler || void 0;
@@ -475,16 +484,18 @@ function _script(id, fn) {
475
484
  };
476
485
  }
477
486
  function _global_read($global, key) {
478
- return key in $global || console.error(`\`$global.${key}\` is not serialized to the client, so this read is \`undefined\`. Add \`${key}\` to \`serializedGlobals\` at the render call.`), $global[key];
487
+ return $global[key];
479
488
  }
480
489
  function _el_read(value) {
481
490
  return value;
482
491
  }
483
492
  function* traverse(scope, path, args, i = path.length - 1) {
484
- if (scope) if (Symbol.iterator in scope) for (let childScope of scope.values()) childScope.H !== 0 && (yield* traverse(childScope, path, args, i));
485
- else {
486
- let item = scope[path[i]];
487
- i ? yield* traverse(item, path, args, i - 1) : yield typeof item == "function" ? item(...args) : item;
493
+ if (scope) {
494
+ if (Symbol.iterator in scope) for (let childScope of scope.values()) childScope.H !== 0 && (yield* traverse(childScope, path, args, i));
495
+ else {
496
+ let item = scope[path[i]];
497
+ i ? yield* traverse(item, path, args, i - 1) : yield typeof item == "function" ? item(...args) : item;
498
+ }
488
499
  }
489
500
  }
490
501
  function _hoist(...path) {
@@ -509,8 +520,8 @@ function ready(readyId) {
509
520
  for (let renderId in curRenders) runResumeEffects(curRenders[renderId]);
510
521
  }
511
522
  function readyFailed(readyId) {}
512
- function withLazy(runtime) {
513
- return lazyEnabled = 1, runtime;
523
+ function withLazy() {
524
+ lazyEnabled = 1;
514
525
  }
515
526
  function initEmbedded(readyId, runtimeId) {
516
527
  embedRenders || (embedRenders = /* @__PURE__ */ new Map(), new MutationObserver(() => {
@@ -544,7 +555,7 @@ function init(runtimeId = "M") {
544
555
  }
545
556
  for (visitType !== "[" && (visitScope[nextToken()] = visitType === ")" || visitType === "}" ? parent : visit, accessor = "A" + (nodeAccessor = lastToken), singleNode = visitType !== "]" && visitType !== ")", nextToken()); branchId = +lastToken;) {
546
557
  if ((endedBranches ||= []).push(branch = getScope(branchId)), setParentBranch(branch, branch.F), (branch.O = render.p?.[branchId]) && (branch.O.m = render.m), singleNode) {
547
- for (; startVisit.previousSibling && ~visits.indexOf(startVisit = startVisit.previousSibling););
558
+ for (; startVisit.previousSibling && (startVisit = startVisit.previousSibling).nodeType > 1;);
548
559
  branch._ ??= visitScope, branch.K = branch.S = startVisit, visitType === "(" && (branch.a = startVisit);
549
560
  } else branch.C = nodeAccessor, curBranchScopes = push(curBranchScopes, branch), accessor && (visitScope[accessor] = curBranchScopes, forEach(curBranchScopes, (scope) => scope._ ??= visitScope), curBranchScopes = branchScopesStack.pop()), startVisit = branchStarts.pop(), parent !== startVisit.parentNode && parent.prepend(startVisit), branch.S = startVisit, branch.K = visit.previousSibling === startVisit ? startVisit : parent.insertBefore(new Text(), visit);
550
561
  for (; pending.at(-1)?.L >= branchId;) adopt(pending.pop(), branch);
@@ -596,7 +607,7 @@ function init(runtimeId = "M") {
596
607
  }
597
608
  function runResumeEffects(render) {
598
609
  try {
599
- isResuming = 1, runEffects(render.m([]), 1);
610
+ isResuming = 1, runEffects(render.m([]));
600
611
  } finally {
601
612
  isResuming = 0;
602
613
  }
@@ -610,7 +621,7 @@ function _var_resume(id, signal) {
610
621
  function _el(id, accessor) {
611
622
  return accessor = decodeAccessor(accessor), _resumed[id] = (scope) => () => scope[accessor];
612
623
  }
613
- function _resume_dynamic_tag_var(accessor) {
624
+ function _dynamic_tag_var_resume(accessor) {
614
625
  accessor = decodeAccessor(accessor), _resumed["-" + accessor] = (scope) => () => {
615
626
  let node = scope[accessor];
616
627
  return node.nodeType === 8 ? node.previousSibling : node;
@@ -768,9 +779,7 @@ function attrsInternal(scope, nodeAccessor, nextAttrs, controllable) {
768
779
  case "style":
769
780
  _attr_style(el, value);
770
781
  break;
771
- default:
772
- isEventHandler(name) ? (events ||= scope["I" + nodeAccessor] = {})[getEventHandlerName(name)] = value : skip?.test(name) || name === "content" && el.tagName !== "META" || _attr(el, name, value);
773
- break;
782
+ default: isEventHandler(name) ? (events ||= scope["I" + nodeAccessor] = {})[getEventHandlerName(name)] = value : skip?.test(name) || name === "content" && el.tagName !== "META" || _attr(el, name, value);
774
783
  }
775
784
  }
776
785
  }
@@ -792,7 +801,7 @@ function normalizeAttrValue(value) {
792
801
  }
793
802
  function _lifecycle(scope, thisObj, index = 0) {
794
803
  let accessor = "K" + index, instance = scope[accessor];
795
- instance ? (Object.assign(instance, thisObj), instance.onUpdate?.()) : (scope[accessor] = thisObj, Object.assign(thisObj, thisObj.onMount?.()), $signal(scope, accessor).onabort = () => thisObj.onDestroy?.());
804
+ instance ? (Object.assign(instance, thisObj), instance.onUpdate?.()) : (scope[accessor] = thisObj, Object.assign(thisObj, thisObj.onMount?.()), trackAbort(scope, accessor, () => thisObj.onDestroy?.()));
796
805
  }
797
806
  function removeChildNodes(startNode, endNode) {
798
807
  let stop = endNode.nextSibling;
@@ -929,14 +938,16 @@ function _attr_select_value_script(scope, nodeAccessor) {
929
938
  setSelectValue(el, oldValue, multiple), valueChange(newValue), run();
930
939
  }
931
940
  };
932
- if (isResuming) if (el.multiple) {
933
- scope["G" + nodeAccessor] = [];
934
- for (let opt of el.options) opt.defaultSelected && scope["G" + nodeAccessor].push(opt.value);
935
- } else {
936
- scope["G" + nodeAccessor] = "";
937
- for (let opt of el.options) if (opt.defaultSelected) {
938
- scope["G" + nodeAccessor] = opt.value;
939
- break;
941
+ if (isResuming) {
942
+ if (el.multiple) {
943
+ scope["G" + nodeAccessor] = [];
944
+ for (let opt of el.options) opt.defaultSelected && scope["G" + nodeAccessor].push(opt.value);
945
+ } else {
946
+ scope["G" + nodeAccessor] = "";
947
+ for (let opt of el.options) if (opt.defaultSelected) {
948
+ scope["G" + nodeAccessor] = opt.value;
949
+ break;
950
+ }
940
951
  }
941
952
  }
942
953
  syncControllableFormInput(el, hasSelectChanged, onChange), observeOnce(scope, nodeAccessor, {
@@ -1022,23 +1033,25 @@ function _controllable_open(scope, nodeAccessor, nextAttrs) {
1022
1033
  //#region src/dom/control-flow.ts
1023
1034
  function _await_promise(nodeAccessor, params) {
1024
1035
  nodeAccessor = decodeAccessor(nodeAccessor);
1025
- let promiseAccessor = "L" + nodeAccessor, branchAccessor = "A" + nodeAccessor, resolveAwait = (scope, referenceNode, value) => {
1036
+ let promiseAccessor = "L" + nodeAccessor, branchAccessor = "A" + nodeAccessor, tryAccessor = "Q" + nodeAccessor, resolveAwait = (scope, referenceNode, value) => {
1026
1037
  let awaitBranch = scope[branchAccessor];
1027
1038
  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;
1028
1039
  }, awaitPromise = (scope, promise) => {
1029
1040
  isPromise(scope[promiseAccessor]) || (scope[promiseAccessor] = 0);
1030
- let awaitBranch = scope[branchAccessor], tryPlaceholder = (isPromise(promise) || scope[promiseAccessor]) && findBranchWithKey(scope, "Q"), tryBranch = tryPlaceholder || awaitBranch;
1041
+ let awaitBranch = scope[branchAccessor], tryBranch = scope[tryAccessor] || isPromise(promise) && findTryWithPlaceholder(scope) || awaitBranch;
1031
1042
  if (!tryBranch) {
1032
- let replay = scope[promiseAccessor] = () => replay === scope[promiseAccessor] && awaitPromise(scope, promise), awaitCounter = findBranchWithKey(scope, "Q")?.O;
1043
+ let deferred = scope[promiseAccessor] = () => deferred === scope[promiseAccessor] && awaitPromise(scope, promise), awaitCounter = findTryWithPlaceholder(scope)?.O;
1033
1044
  if (awaitCounter?.i) {
1034
1045
  let complete = awaitCounter.c;
1035
- awaitCounter.c = () => complete() || queueAsyncRender(scope, replay);
1046
+ awaitCounter.c = () => complete() || queueAsyncRender(scope, deferred);
1036
1047
  }
1037
1048
  return;
1038
1049
  }
1039
- if (!isPromise(promise)) return scope[promiseAccessor] ? awaitPromise(scope, Promise.resolve(promise)) : resolveAwait(scope, scope[nodeAccessor], promise);
1050
+ if (!isPromise(promise)) return scope[tryAccessor] ? awaitPromise(scope, Promise.resolve(promise)) : resolveAwait(scope, scope[nodeAccessor], promise);
1040
1051
  let awaitCounter = tryBranch.O;
1041
- placeholderShown.add(pendingEffects), !tryPlaceholder && !awaitCounter?.i && (awaitCounter = createAwaitCounter(tryBranch, () => {
1052
+ scope[tryAccessor] || (scope[tryAccessor] = tryBranch, trackAbort(scope, promiseAccessor, () => {
1053
+ scope[promiseAccessor] = 0, scope[tryAccessor] && queueAsyncRender(scope[tryAccessor], completeAwaitCounter, awaitCounter);
1054
+ }), awaitBranch && (awaitBranch.W ||= []), tryBranch === awaitBranch ? (awaitCounter?.i || (awaitCounter = createAwaitCounter(tryBranch, () => {
1042
1055
  if (tryBranch === scope[branchAccessor]) {
1043
1056
  let anchor = scope[nodeAccessor];
1044
1057
  if (anchor.parentNode) {
@@ -1046,34 +1059,22 @@ function _await_promise(nodeAccessor, params) {
1046
1059
  detachedParent === anchor.parentNode ? anchor.remove() : anchor.replaceWith(detachedParent);
1047
1060
  }
1048
1061
  }
1049
- })), scope[promiseAccessor] || (awaitBranch && (awaitBranch.W ||= []), tryPlaceholder ? awaitCounter = addAwaitCounter(scope, tryPlaceholder) : scheduleAwaitFrame(awaitCounter, scope, () => {
1062
+ })), scheduleAwaitFrame(awaitCounter, scope, () => {
1050
1063
  awaitBranch.V || (awaitBranch.S.parentNode.insertBefore(scope[nodeAccessor], awaitBranch.S), tempDetachBranch(tryBranch));
1051
- }));
1064
+ })) : awaitCounter = addAwaitCounter(scope, tryBranch));
1052
1065
  let thisPromise = scope[promiseAccessor] = promise.then((data) => {
1053
1066
  if (thisPromise === scope[promiseAccessor]) {
1054
1067
  let referenceNode = scope[nodeAccessor];
1055
- if (scope[promiseAccessor] = 0, !scope[branchAccessor] || scope.F?.H === 0) {
1056
- scope[branchAccessor] || awaitPromise(scope, data), awaitCounter.c(), run();
1057
- return;
1058
- }
1059
- queueAsyncRender(scope, () => {
1060
- awaitBranch = resolveAwait(scope, referenceNode, data);
1061
- let pendingRenders = awaitBranch.W;
1062
- if (awaitBranch.W = 0, pendingRenders?.forEach(queuePendingRender), placeholderShown.add(pendingEffects), awaitCounter.c(), awaitCounter.m) {
1063
- let fnScopes = /* @__PURE__ */ new Map(), effects = awaitCounter.m([]);
1064
- for (let i = 0; i < pendingEffects.length;) {
1065
- let fn = pendingEffects[i++], scopes = fnScopes.get(fn);
1066
- scopes || fnScopes.set(fn, scopes = /* @__PURE__ */ new Set()), scopes.add(pendingEffects[i++]);
1067
- }
1068
- for (let i = 0; i < effects.length;) {
1069
- let fn = effects[i++], scope = effects[i++];
1070
- fnScopes.get(fn)?.has(scope) || queueEffect(scope, fn);
1071
- }
1068
+ scope[promiseAccessor] = 0, scope[branchAccessor] ? queueAsyncRender(scope, () => {
1069
+ if (!scope[promiseAccessor]) {
1070
+ awaitBranch = resolveAwait(scope, referenceNode, data);
1071
+ let pendingRenders = awaitBranch.W;
1072
+ awaitBranch.W = 0, pendingRenders?.forEach(queuePendingRender), scope[tryAccessor] = 0, queueCompleteAwaitCounter(tryBranch, awaitCounter);
1072
1073
  }
1073
- });
1074
+ }) : (scope[tryAccessor] = 0, awaitPromise(scope, data), awaitCounter.c(), run());
1074
1075
  }
1075
1076
  }, (error) => {
1076
- thisPromise === scope[promiseAccessor] && (scope[promiseAccessor] = 0, tryPlaceholder && !awaitCounter.m ? awaitCounter.c() : awaitCounter.i = 0, queueAsyncRender(scope, renderCatch, error));
1077
+ thisPromise === scope[promiseAccessor] && (scope[promiseAccessor] = scope[tryAccessor] = 0, queueAsyncRender(scope, renderCatch, error), tryBranch !== awaitBranch && !awaitCounter.m ? findTryWithCatch(scope) ? queueCompleteAwaitCounter(tryBranch, awaitCounter) : awaitCounter.c() : awaitCounter.i = 0);
1077
1078
  });
1078
1079
  };
1079
1080
  return awaitPromise;
@@ -1086,16 +1087,32 @@ function _await_content(nodeAccessor, template, walks, setup) {
1086
1087
  scope[branchAccessor].Y = pendingScopes, typeof scope[promiseAccessor] == "function" && scope[promiseAccessor]();
1087
1088
  };
1088
1089
  }
1089
- function addAwaitCounter(scope, tryBranch = findBranchWithKey(scope, "Q")) {
1090
+ function addAwaitCounter(scope, tryBranch = findTryWithPlaceholder(scope)) {
1090
1091
  if (!tryBranch) return;
1091
1092
  let awaitCounter = tryBranch.O;
1092
- return awaitCounter?.i || (awaitCounter = createAwaitCounter(tryBranch, () => dismissPlaceholder(tryBranch))), placeholderShown.add(pendingEffects), scheduleAwaitFrame(awaitCounter, tryBranch, () => {
1093
- insertBranchBefore(tryBranch.P = createAndSetupBranch(tryBranch.$, tryBranch.Q, tryBranch._, tryBranch.S.parentNode), tryBranch.S.parentNode, tryBranch.S), tempDetachBranch(tryBranch);
1093
+ return awaitCounter?.i || (awaitCounter = createAwaitCounter(tryBranch, () => dismissPlaceholder(tryBranch))), scheduleAwaitFrame(awaitCounter, tryBranch, () => {
1094
+ (tryBranch.P = createAndSetupBranch(tryBranch.$, tryBranch.Q(), tryBranch._, tryBranch.S.parentNode)).PT = tryBranch, insertBranchBefore(tryBranch.P, tryBranch.S.parentNode, tryBranch.S), tempDetachBranch(tryBranch);
1094
1095
  }), awaitCounter;
1095
1096
  }
1096
1097
  function scheduleAwaitFrame(awaitCounter, scope, render) {
1097
1098
  awaitCounter.i++ || requestAnimationFrame(() => awaitCounter.i && runEffects(prepareEffects(() => queueRender(scope, render, -1))));
1098
1099
  }
1100
+ function queueCompleteAwaitCounter(tryBranch, awaitCounter) {
1101
+ queueRender(tryBranch, completeAwaitCounter, -1, awaitCounter, tryBranch.L + 1e9);
1102
+ }
1103
+ function completeAwaitCounter(_scope, awaitCounter) {
1104
+ if (awaitCounter.c(), awaitCounter.m) {
1105
+ let fnScopes = /* @__PURE__ */ new Map(), effects = awaitCounter.m([]);
1106
+ for (let i = 0; i < pendingEffects.length;) {
1107
+ let fn = pendingEffects[i++], scopes = fnScopes.get(fn);
1108
+ scopes || fnScopes.set(fn, scopes = /* @__PURE__ */ new Set()), scopes.add(pendingEffects[i++]);
1109
+ }
1110
+ for (let i = 0; i < effects.length;) {
1111
+ let fn = effects[i++], scope = effects[i++];
1112
+ fnScopes.get(fn)?.has(scope) || queueEffect(scope, fn);
1113
+ }
1114
+ }
1115
+ }
1099
1116
  function createAwaitCounter(tryBranch, done) {
1100
1117
  let awaitCounter = tryBranch.O = {
1101
1118
  i: 0,
@@ -1106,30 +1123,41 @@ function createAwaitCounter(tryBranch, done) {
1106
1123
  };
1107
1124
  return awaitCounter;
1108
1125
  }
1109
- function runPendingEffects(scope) {
1110
- let effects = scope.J;
1111
- effects && (scope.J = [], runEffects(effects, 1));
1126
+ function runPendingEffects(tryBranch) {
1127
+ tryBranch.JS?.forEach((scope) => scope.J.forEach((fn) => runEffects([fn, scope]), scope.J = null), tryBranch.JS = null);
1112
1128
  }
1113
1129
  function dismissPlaceholder(tryBranch) {
1114
1130
  let placeholderBranch = tryBranch.P;
1115
1131
  placeholderBranch && (tryBranch.P = 0, placeholderBranch.S.parentNode.insertBefore(tryBranch.S.parentNode, placeholderBranch.S), removeAndDestroyBranch(placeholderBranch));
1116
1132
  }
1117
- function _try(nodeAccessor, template, walks, setup) {
1133
+ function _try(nodeAccessor, template, walks, setup, placeholderContent, catchContent) {
1118
1134
  nodeAccessor = decodeAccessor(nodeAccessor);
1119
1135
  let branchAccessor = "A" + nodeAccessor, renderer = _content("", template, walks, setup)();
1120
- return (scope, input) => {
1121
- scope[branchAccessor] || setConditionalRenderer(scope, nodeAccessor, renderer, createAndSetupBranch);
1136
+ return (scope) => {
1137
+ setConditionalRenderer(scope, nodeAccessor, renderer, createAndSetupBranch);
1122
1138
  let branch = scope[branchAccessor];
1123
- branch && (branch.C = nodeAccessor, branch.E = input.catch && (normalizeDynamicRenderer(input.catch) || 0), branch.Q = normalizeDynamicRenderer(input.placeholder));
1139
+ branch.C = nodeAccessor, branch.E = catchContent, branch.Q = placeholderContent || void 0;
1124
1140
  };
1125
1141
  }
1126
1142
  function renderCatch(scope, error) {
1127
- let tryWithCatch = findBranchWithKey(scope, "E");
1143
+ let tryWithCatch = findTryWithCatch(scope);
1128
1144
  if (tryWithCatch) {
1129
1145
  let owner = tryWithCatch._, placeholderBranch = tryWithCatch.P;
1130
- placeholderBranch && (tryWithCatch.O && (tryWithCatch.O.i = 0), owner["A" + tryWithCatch.C] = placeholderBranch, destroyBranch(tryWithCatch)), caughtError.add(pendingEffects), setConditionalRenderer(owner, tryWithCatch.C, tryWithCatch.E, createAndSetupBranch), tryWithCatch.E?.d?.(owner["A" + tryWithCatch.C], [error]);
1146
+ placeholderBranch && (tryWithCatch.O && (tryWithCatch.O.i = 0), owner["A" + tryWithCatch.C] = placeholderBranch, destroyBranch(tryWithCatch));
1147
+ let catchContent = tryWithCatch.E();
1148
+ setConditionalRenderer(owner, tryWithCatch.C, catchContent, createAndSetupBranch), catchContent.d?.(owner["A" + tryWithCatch.C], [error]);
1131
1149
  } else throw error;
1132
1150
  }
1151
+ function findTryWithPlaceholder(scope) {
1152
+ let branch = scope.F;
1153
+ for (; branch && !branch.Q;) branch = branch.N;
1154
+ return branch;
1155
+ }
1156
+ function findTryWithCatch(scope) {
1157
+ let branch = scope.F;
1158
+ for (; branch && !branch.E;) branch = branch.PT || branch.N;
1159
+ return branch;
1160
+ }
1133
1161
  function rendererKey(renderer) {
1134
1162
  return renderer?.e ? renderer.a + " " + renderer.e.L : renderer?.a || renderer;
1135
1163
  }
@@ -1149,10 +1177,12 @@ function setConditionalRenderer(scope, nodeAccessor, newRenderer, createBranch)
1149
1177
  function reorderKeyed(newScopes, start, newEnd, parentNode, afterReference) {
1150
1178
  let diffLen = newEnd - start + 1, sources = Array(diffLen), pred = Array(diffLen), tails = [], tail = -1, lo, hi, mid;
1151
1179
  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);
1180
+ for (let i = 0; i < diffLen; i++) if (~sources[i]) {
1181
+ if (tail < 0 || sources[tails[tail]] < sources[i]) ~tail && (pred[i] = tails[tail]), tails[++tail] = i;
1182
+ else {
1183
+ for (lo = 0, hi = tail; lo < hi;) mid = (lo + hi) / 2 | 0, sources[tails[mid]] < sources[i] ? lo = mid + 1 : hi = mid;
1184
+ sources[i] < sources[tails[lo]] && (lo > 0 && (pred[i] = tails[lo - 1]), tails[lo] = i);
1185
+ }
1156
1186
  }
1157
1187
  for (hi = tails[tail], lo = tail + 1; lo-- > 0;) tails[lo] = hi, hi = pred[hi];
1158
1188
  for (let i = diffLen; i--;) ~tail && i === tails[tail] ? tail-- : insertBranchBefore(newScopes[start + i], parentNode, afterReference), afterReference = newScopes[start + i].S;
@@ -1168,4 +1198,4 @@ function byFirstArg(name) {
1168
1198
  return name;
1169
1199
  }
1170
1200
  //#endregion
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 };
1201
+ export { _attrs as $, syncGen as $t, _attr_input_value as A, _closure as At, _controllable_select as B, _if_closure as Bt, _attr_details_or_dialog_open_script as C, getRegisteredWithScope as Ct, _attr_input_checkedValue_script as D, readyFailed as Dt, _attr_input_checkedValue_default as E, ready as Et, _attr_select_value as F, _for_selector as Ft, _attr_class as G, _return_change as Gt, controllableRenders as H, _let_change as Ht, _attr_select_value_default as I, _global_read as It, _attr_content as J, _var_change as Jt, _attr_class_item as K, _script as Kt, _attr_select_value_script as L, _hoist as Lt, _attr_input_value_default as M, _const as Mt, _attr_input_value_dynamic_default as N, _el_read as Nt, _attr_input_checked_default as O, withLazy as Ot, _attr_input_value_script as P, _for_closure as Pt, _attr_style_items as Q, removeAndDestroyBranch as Qt, _controllable_input as R, _hoist_resume as Rt, _attr_details_or_dialog_open_default as S, _var_resume as St, _attr_input_checkedValue as T, initEmbedded as Tt, controllableScripts as U, _or as Ut, _controllable_textarea as V, _let as Vt, _attr as W, _return as Wt, _attr_style as X, destroyBranch as Xt, _attr_nonce as Y, _assert_init as Yt, _attr_style_item as Z, insertBranchBefore as Zt, installDynamicTagVar as _, _hoist_read_error as _n, createBranch as _t, _for_in as a, queueAsyncRender as an, _lifecycle as at, runPendingEffects as b, _el as bt, _for_to as c, rendering as cn, _text as ct, _for_until_unkeyed as d, runId as dn, insertChildNodes as dt, _on as en, _attrs_content as et, _if as f, forIn as fn, toInsertNode as ft, dynamicTagScript as g, _assert_hoist as gn, createAndSetupBranch as gt, addAwaitCounter as h, forUntil as hn, _content_resume as ht, _dynamic_tag_content as i, prepareEffects as in, _html as it, _attr_input_value_attribute_default as j, _closure_get as jt, _attr_input_checked_script as k, _child_setup as kt, _for_to_unkeyed as l, run as ln, _text_content as lt, _try as m, forTo as mn, _content_closures as mt, _await_promise as n, $signalReset as nn, _attrs_partial_content as nt, _for_of as o, queueEffect as on, _style_rule_item as ot, _show as p, forOf as pn, _content as pt, _attr_class_items as q, _var as qt, _dynamic_tag as r, installCatch as rn, _attrs_script as rt, _for_of_unkeyed as s, queueRender as sn, _style_shell as st, _await_content as t, $signal as tn, _attrs_partial as tt, _for_until as u, runEffects as un, _to_text as ut, patchDynamicTag as v, _call as vn, setupBranch as vt, _attr_input_checked as w, init as wt, _attr_details_or_dialog_open as x, _resumed as xt, renderCatch as y, withBranches as yn, _dynamic_tag_var_resume as yt, _controllable_open as z, _id as zt };