marko 6.3.47 → 6.3.49

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 (59) hide show
  1. package/cheatsheet.md +19 -16
  2. package/dist/common/accessor.d.ts +0 -3
  3. package/dist/common/accessor.debug.d.ts +0 -3
  4. package/dist/common/constants/resume-symbol.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-var.feat.js +1 -1
  18. package/dist/debug/dom/dynamic-tag-var.feat.mjs +1 -1
  19. package/dist/debug/dom/placeholder.feat.js +1 -1
  20. package/dist/debug/dom/placeholder.feat.mjs +1 -1
  21. package/dist/debug/{dom-BheMBjYT.js → dom-BAGeiafn.js} +31 -17
  22. package/dist/debug/{dom-DyBeisho.mjs → dom-C55iHvof.mjs} +26 -18
  23. package/dist/debug/dom.js +20 -24
  24. package/dist/debug/dom.mjs +20 -24
  25. package/dist/debug/html.js +76 -37
  26. package/dist/debug/html.mjs +76 -37
  27. package/dist/dom/catch.feat.js +1 -1
  28. package/dist/dom/catch.feat.mjs +1 -1
  29. package/dist/dom/controllable-input.feat.js +1 -1
  30. package/dist/dom/controllable-input.feat.mjs +1 -1
  31. package/dist/dom/controllable-open.feat.js +1 -1
  32. package/dist/dom/controllable-open.feat.mjs +1 -1
  33. package/dist/dom/controllable-select.feat.js +1 -1
  34. package/dist/dom/controllable-select.feat.mjs +1 -1
  35. package/dist/dom/controllable-textarea.feat.js +1 -1
  36. package/dist/dom/controllable-textarea.feat.mjs +1 -1
  37. package/dist/dom/controllable.feat.js +1 -1
  38. package/dist/dom/controllable.feat.mjs +1 -1
  39. package/dist/dom/dynamic-tag-var.feat.js +1 -1
  40. package/dist/dom/dynamic-tag-var.feat.mjs +1 -1
  41. package/dist/dom/placeholder.feat.js +1 -1
  42. package/dist/dom/placeholder.feat.mjs +1 -1
  43. package/dist/{dom-DprILxYO.js → dom-BNmfm4st.js} +31 -26
  44. package/dist/{dom-BbknkVDz.mjs → dom-BsAS26Ze.mjs} +16 -16
  45. package/dist/dom.js +20 -20
  46. package/dist/dom.mjs +14 -14
  47. package/dist/html/inlined-runtimes.d.ts +2 -2
  48. package/dist/html/inlined-runtimes.debug.d.ts +2 -2
  49. package/dist/html/writer.d.ts +3 -1
  50. package/dist/html.js +46 -36
  51. package/dist/html.mjs +46 -36
  52. package/dist/translator/index.js +108 -82
  53. package/dist/translator/util/get-compile-stage.d.ts +2 -0
  54. package/dist/translator/util/references.d.ts +4 -2
  55. package/dist/translator/util/sections.d.ts +4 -1
  56. package/dist/translator/util/serialize-reasons.d.ts +3 -2
  57. package/package.json +4 -4
  58. package/dist/common/constants/load-signal-value.d.ts +0 -5
  59. package/dist/common/constants/load-signal-value.debug.d.ts +0 -5
@@ -1,4 +1,4 @@
1
- import { $ as _attrs_script, $t as $signal, A as _attr_input_value_script, At as _for_closure, B as _attr, Bt as _return, C as _attr_input_checkedValue_script, D as _attr_input_value_attribute_default, Dn as Global, Dt as _closure_get, E as _attr_input_value, Et as _closure, F as _controllable_open, Ft as _id, G as _attr_nonce, Gt as _assert_init, H as _attr_class_item, Ht as _script, I as _controllable_select, It as _if_closure, J as _attr_style_items, Jt as removeAndDestroyBranch, K as _attr_style, Kt as destroyBranch, L as _controllable_textarea, Lt as _let, M as _attr_select_value_default, Mt as _global_read, N as _attr_select_value_script, Nn as StartNode, Nt as _hoist, O as _attr_input_value_default, On as Load, Ot as _const, P as _controllable_input, Pn as TagVariable, Pt as _hoist_resume, Q as _attrs_partial_content, Rt as _let_change, S as _attr_input_checkedValue_default, St as readyFailed, T as _attr_input_checked_script, Tn as EndNode, Tt as _child_setup, U as _attr_class_items, Ut as _var, V as _attr_class, Vt as _return_change, W as _attr_content, Wt as _var_change, X as _attrs_content, Xt as _on, Y as _attrs, Yt as syncGen, Z as _attrs_partial, _ as _attr_details_or_dialog_open, _n as Clone, _t as _var_resume, a as _for_in, an as queueAsyncRender, at as _text_content, b as _attr_input_checked, bn as Setup, bt as initEmbedded, c as _for_until, cn as runEffects, ct as toInsertNode, d as _show, dn as forOf, dt as _content_resume, en as $signalReset, et as _html, f as _try, fn as forTo, ft as createAndSetupBranch, g as renderCatch, gn as _call, gt as _resume, h as patchDynamicTag, hn as _hoist_read_error, ht as _el, i as _dynamic_tag_content, in as prepareEffects, it as _text, j as _attr_select_value, jt as _for_selector, k as _attr_input_value_dynamic_default, kt as _el_read, l as _if, ln as runId, lt as _content, mn as _assert_hoist, mt as setupBranch, n as _await_promise, nt as _style_rule_item, o as _for_of, on as queueEffect, ot as _to_text, p as addAwaitCounter, pn as forUntil, pt as createBranch, q as _attr_style_item, qt as insertBranchBefore, r as _dynamic_tag, rt as _style_shell, s as _for_to, sn as run, st as insertChildNodes, t as _await_content, tt as _lifecycle, u as _resume_dynamic_tag, un as forIn, ut as _content_closures, v as _attr_details_or_dialog_open_default, vn as Owner, vt as getRegisteredWithScope, w as _attr_input_checked_default, wt as withLazy, x as _attr_input_checkedValue, xt as ready, y as _attr_details_or_dialog_open_script, yn as Params, yt as init, zt as _or } from "./dom-DyBeisho.mjs";
1
+ import { $ as _attrs_script, $t as $signal, A as _attr_input_value_script, At as _for_closure, B as _attr, Bt as _return, C as _attr_input_checkedValue_script, D as _attr_input_value_attribute_default, Dt as _closure_get, E as _attr_input_value, En as EndNode, Et as _closure, F as _controllable_open, Fn as TagVariable, Ft as _id, G as _attr_nonce, Gt as _assert_init, H as _attr_class_item, Ht as _script, I as _controllable_select, It as _if_closure, J as _attr_style_items, Jt as removeAndDestroyBranch, K as _attr_style, Kt as destroyBranch, L as _controllable_textarea, Lt as _let, M as _attr_select_value_default, Mt as _global_read, N as _attr_select_value_script, Nt as _hoist, O as _attr_input_value_default, On as Global, Ot as _const, P as _controllable_input, Pn as StartNode, Pt as _hoist_resume, Q as _attrs_partial_content, Rt as _let_change, S as _attr_input_checkedValue_default, St as readyFailed, T as _attr_input_checked_script, Tt as _child_setup, U as _attr_class_items, Ut as _var, V as _attr_class, Vt as _return_change, W as _attr_content, Wt as _var_change, X as _attrs_content, Xt as _on, Y as _attrs, Yt as syncGen, Z as _attrs_partial, _ as _attr_details_or_dialog_open, _n as _call, _t as _var_resume, a as _for_in, an as queueAsyncRender, at as _text_content, b as _attr_input_checked, bn as Params, bt as initEmbedded, c as _for_until, cn as run, ct as toInsertNode, d as _show, dn as forIn, dt as _content_resume, en as $signalReset, et as _html, f as _try, fn as forOf, ft as createAndSetupBranch, g as renderCatch, gn as _hoist_read_error, gt as _resume, h as patchDynamicTag, hn as _assert_hoist, ht as _el, i as _dynamic_tag_content, in as prepareEffects, it as _text, j as _attr_select_value, jt as _for_selector, k as _attr_input_value_dynamic_default, kn as Load, kt as _el_read, l as _if, ln as runEffects, lt as _content, mn as forUntil, mt as setupBranch, n as _await_promise, nt as _style_rule_item, o as _for_of, on as queueEffect, ot as _to_text, p as addAwaitCounter, pn as forTo, pt as createBranch, q as _attr_style_item, qt as insertBranchBefore, r as _dynamic_tag, rt as _style_shell, s as _for_to, sn as queueRender, st as insertChildNodes, t as _await_content, tt as _lifecycle, u as _resume_dynamic_tag, un as runId, ut as _content_closures, v as _attr_details_or_dialog_open_default, vn as Clone, vt as getRegisteredWithScope, w as _attr_input_checked_default, wt as withLazy, x as _attr_input_checkedValue, xn as Setup, xt as ready, y as _attr_details_or_dialog_open_script, yn as Owner, yt as init, zt as _or } from "./dom-C55iHvof.mjs";
2
2
  //#region src/common/attr-tag.ts
3
3
  const empty = [];
4
4
  const rest = Symbol("Attribute Tag");
@@ -20,10 +20,6 @@ function* attrTagIterator() {
20
20
  yield* this[rest];
21
21
  }
22
22
  //#endregion
23
- //#region src/common/constants/load-signal-value.debug.ts
24
- const Value = "value";
25
- const Signal = "signal";
26
- //#endregion
27
23
  //#region src/common/compat-meta.ts
28
24
  const SET_SCOPE_REGISTER_ID = "$compat_setScope";
29
25
  const RENDER_BODY_ID = "$compat_renderBody";
@@ -211,9 +207,10 @@ const _load_template = /*@__PURE__*/ withLazy((id, load) => {
211
207
  const _load_setup = /*@__PURE__*/ withLazy((nodeAccessor, childScopeAccessor, load) => {
212
208
  let pending;
213
209
  let renderer;
210
+ const insertCached = (child, marker) => insertLoaded(renderer, child, marker);
214
211
  return (owner) => {
215
212
  const child = owner[childScopeAccessor];
216
- if (renderer) insertLoaded(renderer, child, owner[nodeAccessor]);
213
+ if (renderer) queueRender(child, insertCached, -1, owner[nodeAccessor]);
217
214
  else {
218
215
  const awaitCounter = addAwaitCounter(owner);
219
216
  child[Load] ||= /* @__PURE__ */ new Map();
@@ -225,27 +222,26 @@ const _load_setup = /*@__PURE__*/ withLazy((nodeAccessor, childScopeAccessor, lo
225
222
  };
226
223
  });
227
224
  function insertLoaded(renderer, branch, marker, awaitCounter) {
228
- const parent = marker.parentNode, values = branch[Load], insert = () => {
225
+ const parent = marker.parentNode, values = branch[Load], clone = () => {
226
+ syncGen(branch);
227
+ renderer[Clone](branch, parent.namespaceURI);
228
+ branch[Load] = 0;
229
+ }, insert = () => {
229
230
  insertBranchBefore(branch, parent, marker);
230
231
  marker.remove();
231
232
  awaitCounter?.c();
232
233
  };
233
234
  let remaining;
234
- syncGen(branch);
235
- renderer[Clone](branch, parent.namespaceURI);
236
- branch[Load] = 0;
237
235
  if (remaining = values?.size) {
238
236
  const fail = loadFailed(branch, awaitCounter);
239
- for (const [promise, entry] of values) promise.then((signal) => {
240
- entry[Signal] = signal;
241
- if (!--remaining) queueAsyncRender(branch, (branch) => {
242
- syncGen(branch);
243
- renderer[Setup]?.(branch);
244
- values.forEach((e) => e[Signal]._(branch, e[Value]));
245
- insert();
246
- });
247
- }, (error) => remaining > 0 && (remaining = 0, fail(error)));
237
+ values.forEach(([, apply], promise) => promise.then((mod) => (apply._ = mod._) && !--remaining && queueAsyncRender(branch, (branch) => {
238
+ clone();
239
+ renderer["setup"]?.(branch);
240
+ values.forEach(([value, apply]) => apply(branch, value));
241
+ insert();
242
+ }), (error) => remaining > 0 && (remaining = 0, fail(error))));
248
243
  } else {
244
+ clone();
249
245
  setupBranch(renderer, branch);
250
246
  insert();
251
247
  }
@@ -259,13 +255,13 @@ function loadFailed(scope, awaitCounter) {
259
255
  }
260
256
  const _load_signal = /*@__PURE__*/ withLazy((load) => {
261
257
  let pending;
262
- let signal;
263
- return (scope, value) => {
258
+ const apply = (scope, value) => {
264
259
  pending ||= load();
265
- if (scope["#Load"] || !("#Load" in scope) && scope["#Gen"] === runId) (scope[Load] ||= /* @__PURE__ */ new Map()).set(pending, { [Value]: value });
266
- else if (signal) signal(scope, value);
267
- else pending.then((mod) => queueAsyncRender(scope, signal = mod._, value), () => 0);
260
+ if (scope["#Load"] || !("#Load" in scope) && scope["#Gen"] === runId) (scope[Load] ||= /* @__PURE__ */ new Map()).set(pending, [value, apply]);
261
+ else if (apply._) apply._(scope, value);
262
+ else pending.then((mod) => queueAsyncRender(scope, apply._ = mod._, value), () => 0);
268
263
  };
264
+ return apply;
269
265
  });
270
266
  function _load_visible_trigger(selector, options) {
271
267
  let pending;
@@ -28,7 +28,6 @@ const ControlledHandler = "ControlledHandler:";
28
28
  const ControlledType = "ControlledType:";
29
29
  const ControlledValue = "ControlledValue:";
30
30
  const EventAttributes = "EventAttributes:";
31
- const BranchAccessor = "#BranchAccessor";
32
31
  const CatchContent = "#CatchContent";
33
32
  const ClosestBranchId = "#ClosestBranchId";
34
33
  const LoopKey = "#LoopKey";
@@ -1850,11 +1849,16 @@ const WALKER_RUNTIME_CODE = `((runtimeId) => (self[runtimeId] ||= (
1850
1849
  x() {},
1851
1850
  w(node, op, id) {
1852
1851
  while ((node = walker.nextNode())) {
1852
+ // Only reorder markers ("#", "!") are ever looked up, so only they are
1853
+ // kept: the lookup lives as long as the page, and every node marker
1854
+ // would otherwise stay referenced in it after resume consumed it.
1853
1855
  doc.x(
1854
1856
  (op =
1855
1857
  (op = node.data) &&
1856
1858
  !op.indexOf(prefix) &&
1857
- ((lookup[(id = op.slice(prefixLen + 1))] = node), op[prefixLen])),
1859
+ ((id = op.slice(prefixLen + 1)),
1860
+ (op = op[prefixLen]) > "#" || (lookup[id] = node),
1861
+ op)),
1858
1862
  id,
1859
1863
  node,
1860
1864
  );
@@ -1898,6 +1902,7 @@ const REORDER_RUNTIME_CODE = `((runtime) => {
1898
1902
  (placeholderRoot = placeholders[id] =
1899
1903
  {
1900
1904
  i: runtime.l[id] ? 1 : 2,
1905
+ r: id,
1901
1906
  // Resume may still walk markers inside the dropped placeholder, so
1902
1907
  // park it in any detached parent (a bare <t> clone is the cheapest).
1903
1908
  c(start = runtime.l["^" + id], removed = node.cloneNode()) {
@@ -1913,6 +1918,9 @@ const REORDER_RUNTIME_CODE = `((runtime) => {
1913
1918
  replace(id, node);
1914
1919
  },
1915
1920
  });
1921
+ // Opens the chunk's visits for resume to parent to the root's branch; the
1922
+ // walk that this chunk's own script triggers closes it.
1923
+ runtime.v.push({ data: runtime.i + "*" + placeholder.r });
1916
1924
  // repurpose "op" for callbacks ...carefully
1917
1925
  if ((op = runtime.j[id])) {
1918
1926
  placeholderCb = placeholder.c;
@@ -1983,8 +1991,8 @@ const kIsAsync = Symbol("Is Async");
1983
1991
  function isInResumedBranch() {
1984
1992
  return $chunk?.context?.[kBranchId] !== void 0;
1985
1993
  }
1986
- function withBranchId(branchId, cb) {
1987
- return withContext(kBranchId, branchId, cb);
1994
+ function withBranchId(branchId, cb, cbValue) {
1995
+ return withContext(kBranchId, branchId, cb, cbValue);
1988
1996
  }
1989
1997
  function withIsAsync(cb, value) {
1990
1998
  return withContext(kIsAsync, true, cb, value);
@@ -1995,8 +2003,8 @@ function _html(html) {
1995
2003
  function writeScript(script) {
1996
2004
  $chunk.writeScript(script);
1997
2005
  }
1998
- function _script(scopeId, registryId) {
1999
- if ($chunk.serializeState.readyId || $chunk.context?.[kIsAsync]) _resume_branch(scopeId);
2006
+ function _script(scopeId, registryId, serializeMarker) {
2007
+ if (serializeMarker === 0 && ($chunk.serializeState.readyId || $chunk.context?.[kIsAsync])) _resume_branch(scopeId);
2000
2008
  $chunk.boundary.state.needsMainRuntime = true;
2001
2009
  $chunk.writeEffect(scopeId, registryId);
2002
2010
  }
@@ -2186,6 +2194,7 @@ let writeScope = (scopeId, partialScope) => {
2186
2194
  const scope = scopeWithId(state, scopeId);
2187
2195
  const pending = target.writeScopes[scopeId];
2188
2196
  state.needsMainRuntime = true;
2197
+ countResumeWrite($chunk.boundary);
2189
2198
  Object.assign(scope, partialScope);
2190
2199
  if (pending && pending !== partialScope) Object.assign(pending, partialScope);
2191
2200
  else target.writeScopes[scopeId] = partialScope;
@@ -2257,7 +2266,7 @@ function _await(scopeId, accessor, promise, content, serializeMarker) {
2257
2266
  if (resumeMarker) {
2258
2267
  const branchId = _peek_scope_id();
2259
2268
  $chunk.writeHTML($chunk.boundary.state.mark("[", ""));
2260
- content(promise);
2269
+ withBranchId(branchId, content, promise);
2261
2270
  $chunk.writeHTML($chunk.boundary.state.mark("]", scopeId + " " + accessor + " " + branchId));
2262
2271
  } else content(promise);
2263
2272
  return;
@@ -2279,7 +2288,7 @@ function _await(scopeId, accessor, promise, content, serializeMarker) {
2279
2288
  if (resumeMarker) {
2280
2289
  const branchId = _peek_scope_id();
2281
2290
  $chunk.writeHTML($chunk.boundary.state.mark("[", ""));
2282
- withIsAsync(content, value);
2291
+ withBranchId(branchId, () => withIsAsync(content, value));
2283
2292
  $chunk.writeHTML($chunk.boundary.state.mark("]", scopeId + " " + accessor + " " + branchId));
2284
2293
  } else withIsAsync(content, value);
2285
2294
  });
@@ -2296,16 +2305,19 @@ function _try(scopeId, accessor, content, input) {
2296
2305
  const placeholderContent = normalizeDynamicRenderer(input.placeholder);
2297
2306
  const placeholderBranchId = placeholderContent ? _scope_id() : 0;
2298
2307
  const branchId = _peek_scope_id();
2299
- $chunk.writeHTML($chunk.boundary.state.mark("[", ""));
2300
- if (catchContent !== void 0) tryCatch(placeholderContent ? () => tryPlaceholder(content, placeholderContent, branchId, scopeId, placeholderBranchId) : content, catchContent || (() => {}));
2301
- else if (placeholderContent) tryPlaceholder(content, placeholderContent, branchId, scopeId, placeholderBranchId);
2302
- else content();
2303
- writeScope(branchId, {
2304
- [BranchAccessor]: accessor,
2305
- [CatchContent]: catchContent,
2306
- [PlaceholderContent]: placeholderContent
2307
- });
2308
- $chunk.writeHTML($chunk.boundary.state.mark("]", scopeId + " " + accessor + " " + branchId));
2308
+ const chunk = $chunk;
2309
+ const { boundary } = chunk;
2310
+ const { state } = boundary;
2311
+ const { resumeWrites } = boundary;
2312
+ const beforeBranch = deferBranchStart(chunk);
2313
+ let renderersAtSettle = false;
2314
+ if (catchContent !== void 0 || placeholderContent) renderersAtSettle = tryBoundary(placeholderContent ? () => tryPlaceholder(content, placeholderContent, branchId, scopeId, placeholderBranchId) : content, catchContent, placeholderContent, branchId);
2315
+ else withBranchId(branchId, content);
2316
+ const rendered = chunk !== $chunk || boundary.resumeWrites !== resumeWrites;
2317
+ applyBranchStart(chunk, beforeBranch, rendered);
2318
+ if (!rendered) return;
2319
+ if (!renderersAtSettle) writeTryRenderers(branchId, catchContent, placeholderContent);
2320
+ $chunk.writeHTML(state.mark("]", scopeId + " " + accessor + " " + branchId));
2309
2321
  }
2310
2322
  function tryPlaceholder(content, placeholder, branchId, scopeId, placeholderBranchId) {
2311
2323
  const chunk = $chunk;
@@ -2324,31 +2336,39 @@ function tryPlaceholder(content, placeholder, branchId, scopeId, placeholderBran
2324
2336
  placeholderBranchId
2325
2337
  };
2326
2338
  }
2327
- function tryCatch(content, catchContent) {
2339
+ function tryBoundary(content, catchContent, placeholderContent, branchId) {
2328
2340
  const chunk = $chunk;
2329
2341
  const { boundary } = chunk;
2330
2342
  const { state } = boundary;
2331
2343
  const catchBoundary = new Boundary(state, boundary.signal, boundary);
2332
2344
  const body = chunk.fork(catchBoundary, null);
2333
- const bodyEnd = body.render(content);
2345
+ const bodyEnd = withBranchId(branchId, () => body.render(content));
2334
2346
  if (catchBoundary.signal.aborted) {
2335
- catchContent(catchBoundary.signal.reason);
2336
- return;
2347
+ if (catchContent === void 0) boundary.abort(catchBoundary.signal.reason);
2348
+ else if (catchContent) catchContent(catchBoundary.signal.reason);
2349
+ return false;
2337
2350
  }
2338
2351
  if (body === bodyEnd) {
2339
2352
  chunk.append(body);
2340
- return;
2353
+ return false;
2341
2354
  }
2342
- const reorderId = state.nextReorderId();
2343
- const endMarker = state.mark("!", reorderId);
2344
- const bodyNext = bodyEnd.next = $chunk = body.fork(boundary, chunk.next);
2355
+ const renderersAtSettle = !catchBoundary.resumeWrites;
2356
+ const bodyNext = bodyEnd.next = $chunk = chunk.fork(boundary, chunk.next);
2345
2357
  chunk.next = body;
2346
- chunk.writeHTML(state.mark("!^", reorderId));
2347
- bodyEnd.writeHTML(endMarker);
2348
2358
  boundary.startAsync();
2359
+ const reorderId = catchContent === void 0 ? "" : state.nextReorderId();
2360
+ const endMarker = reorderId && state.mark("!", reorderId);
2361
+ if (reorderId) {
2362
+ chunk.writeHTML(state.mark("!^", reorderId));
2363
+ bodyEnd.writeHTML(endMarker);
2364
+ }
2349
2365
  catchBoundary.onNext = () => {
2350
2366
  if (boundary.signal.aborted) return;
2351
2367
  if (catchBoundary.signal.aborted) {
2368
+ if (!reorderId) {
2369
+ boundary.abort(catchBoundary.signal.reason);
2370
+ return;
2371
+ }
2352
2372
  if (!bodyEnd.consumed) {
2353
2373
  let cur = body;
2354
2374
  let writeMarker = true;
@@ -2368,15 +2388,28 @@ function tryCatch(content, catchContent) {
2368
2388
  } while (cur !== bodyNext);
2369
2389
  }
2370
2390
  const catchChunk = chunk.fork(boundary, null);
2391
+ const { resumeWrites } = boundary;
2371
2392
  catchChunk.reorderId = reorderId;
2372
- catchChunk.render(catchContent, catchBoundary.signal.reason);
2393
+ if ((catchChunk.render(catchContent || NOOP$2, catchBoundary.signal.reason) !== catchChunk || boundary.resumeWrites !== resumeWrites) && renderersAtSettle) catchChunk.render(() => writeTryRenderers(branchId, catchContent, placeholderContent));
2373
2394
  state.reorder(catchChunk);
2374
2395
  boundary.endAsync();
2375
- } else if (!catchBoundary.count) boundary.endAsync();
2376
- else boundary.onNext();
2396
+ } else if (!catchBoundary.count) {
2397
+ if (renderersAtSettle && catchBoundary.resumeWrites) bodyEnd.render(() => writeTryRenderers(branchId, catchContent, placeholderContent));
2398
+ boundary.endAsync();
2399
+ } else boundary.onNext();
2377
2400
  };
2401
+ return renderersAtSettle;
2402
+ }
2403
+ function writeTryRenderers(branchId, catchContent, placeholderContent) {
2404
+ writeScope(branchId, {
2405
+ [CatchContent]: catchContent,
2406
+ [PlaceholderContent]: placeholderContent
2407
+ });
2378
2408
  }
2379
2409
  const NOOP$2 = () => {};
2410
+ function countResumeWrite(boundary) {
2411
+ for (; boundary; boundary = boundary.parent) boundary.resumeWrites++;
2412
+ }
2380
2413
  var State = class {
2381
2414
  tagId = 1;
2382
2415
  scopeId = 1;
@@ -2444,6 +2477,7 @@ var State = class {
2444
2477
  var Boundary = class extends AbortController {
2445
2478
  onNext = NOOP$2;
2446
2479
  count = 0;
2480
+ resumeWrites = 0;
2447
2481
  state;
2448
2482
  parent;
2449
2483
  constructor(state, signal, parent) {
@@ -2502,6 +2536,7 @@ var Chunk = class Chunk {
2502
2536
  this.html += html;
2503
2537
  }
2504
2538
  writeEffect(scopeId, registryId) {
2539
+ countResumeWrite(this.boundary);
2505
2540
  if (this.lastEffect === registryId) this.effects += " " + scopeId;
2506
2541
  else {
2507
2542
  this.lastEffect = registryId;
@@ -2660,6 +2695,8 @@ var Chunk = class Chunk {
2660
2695
  needsWalk = true;
2661
2696
  state.resumes = state.resumes ? state.resumes + ",\"" + effects + "\"" : "\"" + effects + "\"";
2662
2697
  }
2698
+ let reordered = "";
2699
+ let needsResumeArray = false;
2663
2700
  if (state.writeReorders) {
2664
2701
  let carried = null;
2665
2702
  for (const reorderedChunk of state.writeReorders) {
@@ -2703,14 +2740,11 @@ var Chunk = class Chunk {
2703
2740
  else break;
2704
2741
  }
2705
2742
  if (reorderEffects) {
2706
- if (!state.hasWrittenResume) {
2707
- state.hasWrittenResume = true;
2708
- scripts = concatScripts(scripts, runtimePrefix + ".r=[]");
2709
- }
2743
+ needsResumeArray = true;
2710
2744
  reorderScripts = concatScripts(reorderScripts, "_.push(\"" + reorderEffects + "\")");
2711
2745
  }
2712
- for (const reservation of readyReservations) scripts = concatScripts(scripts, reservation);
2713
- scripts = concatScripts(scripts, reorderScripts && runtimePrefix + ".j" + toAccess(reorderId) + "=_=>{" + reorderScripts + "}");
2746
+ for (const reservation of readyReservations) reordered = concatScripts(reordered, reservation);
2747
+ reordered = concatScripts(reordered, reorderScripts && runtimePrefix + ".j" + toAccess(reorderId) + "=_=>{" + reorderScripts + "}");
2714
2748
  html += "<t hidden " + state.commentPrefix + "=" + reorderId + ">" + reorderHTML + "</t>";
2715
2749
  }
2716
2750
  state.writeReorders = carried;
@@ -2721,6 +2755,11 @@ var Chunk = class Chunk {
2721
2755
  state.hasWrittenResume = true;
2722
2756
  scripts = concatScripts(scripts, runtimePrefix + ".r=[" + state.resumes + "]");
2723
2757
  }
2758
+ else if (needsResumeArray && !state.hasWrittenResume) {
2759
+ state.hasWrittenResume = true;
2760
+ scripts = concatScripts(scripts, runtimePrefix + ".r=[]");
2761
+ }
2762
+ scripts = concatScripts(scripts, reordered);
2724
2763
  if (needsWalk) scripts = concatScripts(scripts, runtimePrefix + ".w()");
2725
2764
  this.html = html;
2726
2765
  this.scripts = scripts;
@@ -26,7 +26,6 @@ const ControlledHandler = "ControlledHandler:";
26
26
  const ControlledType = "ControlledType:";
27
27
  const ControlledValue = "ControlledValue:";
28
28
  const EventAttributes = "EventAttributes:";
29
- const BranchAccessor = "#BranchAccessor";
30
29
  const CatchContent = "#CatchContent";
31
30
  const ClosestBranchId = "#ClosestBranchId";
32
31
  const LoopKey = "#LoopKey";
@@ -1848,11 +1847,16 @@ const WALKER_RUNTIME_CODE = `((runtimeId) => (self[runtimeId] ||= (
1848
1847
  x() {},
1849
1848
  w(node, op, id) {
1850
1849
  while ((node = walker.nextNode())) {
1850
+ // Only reorder markers ("#", "!") are ever looked up, so only they are
1851
+ // kept: the lookup lives as long as the page, and every node marker
1852
+ // would otherwise stay referenced in it after resume consumed it.
1851
1853
  doc.x(
1852
1854
  (op =
1853
1855
  (op = node.data) &&
1854
1856
  !op.indexOf(prefix) &&
1855
- ((lookup[(id = op.slice(prefixLen + 1))] = node), op[prefixLen])),
1857
+ ((id = op.slice(prefixLen + 1)),
1858
+ (op = op[prefixLen]) > "#" || (lookup[id] = node),
1859
+ op)),
1856
1860
  id,
1857
1861
  node,
1858
1862
  );
@@ -1896,6 +1900,7 @@ const REORDER_RUNTIME_CODE = `((runtime) => {
1896
1900
  (placeholderRoot = placeholders[id] =
1897
1901
  {
1898
1902
  i: runtime.l[id] ? 1 : 2,
1903
+ r: id,
1899
1904
  // Resume may still walk markers inside the dropped placeholder, so
1900
1905
  // park it in any detached parent (a bare <t> clone is the cheapest).
1901
1906
  c(start = runtime.l["^" + id], removed = node.cloneNode()) {
@@ -1911,6 +1916,9 @@ const REORDER_RUNTIME_CODE = `((runtime) => {
1911
1916
  replace(id, node);
1912
1917
  },
1913
1918
  });
1919
+ // Opens the chunk's visits for resume to parent to the root's branch; the
1920
+ // walk that this chunk's own script triggers closes it.
1921
+ runtime.v.push({ data: runtime.i + "*" + placeholder.r });
1914
1922
  // repurpose "op" for callbacks ...carefully
1915
1923
  if ((op = runtime.j[id])) {
1916
1924
  placeholderCb = placeholder.c;
@@ -1981,8 +1989,8 @@ const kIsAsync = Symbol("Is Async");
1981
1989
  function isInResumedBranch() {
1982
1990
  return $chunk?.context?.[kBranchId] !== void 0;
1983
1991
  }
1984
- function withBranchId(branchId, cb) {
1985
- return withContext(kBranchId, branchId, cb);
1992
+ function withBranchId(branchId, cb, cbValue) {
1993
+ return withContext(kBranchId, branchId, cb, cbValue);
1986
1994
  }
1987
1995
  function withIsAsync(cb, value) {
1988
1996
  return withContext(kIsAsync, true, cb, value);
@@ -1993,8 +2001,8 @@ function _html(html) {
1993
2001
  function writeScript(script) {
1994
2002
  $chunk.writeScript(script);
1995
2003
  }
1996
- function _script(scopeId, registryId) {
1997
- if ($chunk.serializeState.readyId || $chunk.context?.[kIsAsync]) _resume_branch(scopeId);
2004
+ function _script(scopeId, registryId, serializeMarker) {
2005
+ if (serializeMarker === 0 && ($chunk.serializeState.readyId || $chunk.context?.[kIsAsync])) _resume_branch(scopeId);
1998
2006
  $chunk.boundary.state.needsMainRuntime = true;
1999
2007
  $chunk.writeEffect(scopeId, registryId);
2000
2008
  }
@@ -2184,6 +2192,7 @@ let writeScope = (scopeId, partialScope) => {
2184
2192
  const scope = scopeWithId(state, scopeId);
2185
2193
  const pending = target.writeScopes[scopeId];
2186
2194
  state.needsMainRuntime = true;
2195
+ countResumeWrite($chunk.boundary);
2187
2196
  Object.assign(scope, partialScope);
2188
2197
  if (pending && pending !== partialScope) Object.assign(pending, partialScope);
2189
2198
  else target.writeScopes[scopeId] = partialScope;
@@ -2255,7 +2264,7 @@ function _await(scopeId, accessor, promise, content, serializeMarker) {
2255
2264
  if (resumeMarker) {
2256
2265
  const branchId = _peek_scope_id();
2257
2266
  $chunk.writeHTML($chunk.boundary.state.mark("[", ""));
2258
- content(promise);
2267
+ withBranchId(branchId, content, promise);
2259
2268
  $chunk.writeHTML($chunk.boundary.state.mark("]", scopeId + " " + accessor + " " + branchId));
2260
2269
  } else content(promise);
2261
2270
  return;
@@ -2277,7 +2286,7 @@ function _await(scopeId, accessor, promise, content, serializeMarker) {
2277
2286
  if (resumeMarker) {
2278
2287
  const branchId = _peek_scope_id();
2279
2288
  $chunk.writeHTML($chunk.boundary.state.mark("[", ""));
2280
- withIsAsync(content, value);
2289
+ withBranchId(branchId, () => withIsAsync(content, value));
2281
2290
  $chunk.writeHTML($chunk.boundary.state.mark("]", scopeId + " " + accessor + " " + branchId));
2282
2291
  } else withIsAsync(content, value);
2283
2292
  });
@@ -2294,16 +2303,19 @@ function _try(scopeId, accessor, content, input) {
2294
2303
  const placeholderContent = normalizeDynamicRenderer(input.placeholder);
2295
2304
  const placeholderBranchId = placeholderContent ? _scope_id() : 0;
2296
2305
  const branchId = _peek_scope_id();
2297
- $chunk.writeHTML($chunk.boundary.state.mark("[", ""));
2298
- if (catchContent !== void 0) tryCatch(placeholderContent ? () => tryPlaceholder(content, placeholderContent, branchId, scopeId, placeholderBranchId) : content, catchContent || (() => {}));
2299
- else if (placeholderContent) tryPlaceholder(content, placeholderContent, branchId, scopeId, placeholderBranchId);
2300
- else content();
2301
- writeScope(branchId, {
2302
- [BranchAccessor]: accessor,
2303
- [CatchContent]: catchContent,
2304
- [PlaceholderContent]: placeholderContent
2305
- });
2306
- $chunk.writeHTML($chunk.boundary.state.mark("]", scopeId + " " + accessor + " " + branchId));
2306
+ const chunk = $chunk;
2307
+ const { boundary } = chunk;
2308
+ const { state } = boundary;
2309
+ const { resumeWrites } = boundary;
2310
+ const beforeBranch = deferBranchStart(chunk);
2311
+ let renderersAtSettle = false;
2312
+ if (catchContent !== void 0 || placeholderContent) renderersAtSettle = tryBoundary(placeholderContent ? () => tryPlaceholder(content, placeholderContent, branchId, scopeId, placeholderBranchId) : content, catchContent, placeholderContent, branchId);
2313
+ else withBranchId(branchId, content);
2314
+ const rendered = chunk !== $chunk || boundary.resumeWrites !== resumeWrites;
2315
+ applyBranchStart(chunk, beforeBranch, rendered);
2316
+ if (!rendered) return;
2317
+ if (!renderersAtSettle) writeTryRenderers(branchId, catchContent, placeholderContent);
2318
+ $chunk.writeHTML(state.mark("]", scopeId + " " + accessor + " " + branchId));
2307
2319
  }
2308
2320
  function tryPlaceholder(content, placeholder, branchId, scopeId, placeholderBranchId) {
2309
2321
  const chunk = $chunk;
@@ -2322,31 +2334,39 @@ function tryPlaceholder(content, placeholder, branchId, scopeId, placeholderBran
2322
2334
  placeholderBranchId
2323
2335
  };
2324
2336
  }
2325
- function tryCatch(content, catchContent) {
2337
+ function tryBoundary(content, catchContent, placeholderContent, branchId) {
2326
2338
  const chunk = $chunk;
2327
2339
  const { boundary } = chunk;
2328
2340
  const { state } = boundary;
2329
2341
  const catchBoundary = new Boundary(state, boundary.signal, boundary);
2330
2342
  const body = chunk.fork(catchBoundary, null);
2331
- const bodyEnd = body.render(content);
2343
+ const bodyEnd = withBranchId(branchId, () => body.render(content));
2332
2344
  if (catchBoundary.signal.aborted) {
2333
- catchContent(catchBoundary.signal.reason);
2334
- return;
2345
+ if (catchContent === void 0) boundary.abort(catchBoundary.signal.reason);
2346
+ else if (catchContent) catchContent(catchBoundary.signal.reason);
2347
+ return false;
2335
2348
  }
2336
2349
  if (body === bodyEnd) {
2337
2350
  chunk.append(body);
2338
- return;
2351
+ return false;
2339
2352
  }
2340
- const reorderId = state.nextReorderId();
2341
- const endMarker = state.mark("!", reorderId);
2342
- const bodyNext = bodyEnd.next = $chunk = body.fork(boundary, chunk.next);
2353
+ const renderersAtSettle = !catchBoundary.resumeWrites;
2354
+ const bodyNext = bodyEnd.next = $chunk = chunk.fork(boundary, chunk.next);
2343
2355
  chunk.next = body;
2344
- chunk.writeHTML(state.mark("!^", reorderId));
2345
- bodyEnd.writeHTML(endMarker);
2346
2356
  boundary.startAsync();
2357
+ const reorderId = catchContent === void 0 ? "" : state.nextReorderId();
2358
+ const endMarker = reorderId && state.mark("!", reorderId);
2359
+ if (reorderId) {
2360
+ chunk.writeHTML(state.mark("!^", reorderId));
2361
+ bodyEnd.writeHTML(endMarker);
2362
+ }
2347
2363
  catchBoundary.onNext = () => {
2348
2364
  if (boundary.signal.aborted) return;
2349
2365
  if (catchBoundary.signal.aborted) {
2366
+ if (!reorderId) {
2367
+ boundary.abort(catchBoundary.signal.reason);
2368
+ return;
2369
+ }
2350
2370
  if (!bodyEnd.consumed) {
2351
2371
  let cur = body;
2352
2372
  let writeMarker = true;
@@ -2366,15 +2386,28 @@ function tryCatch(content, catchContent) {
2366
2386
  } while (cur !== bodyNext);
2367
2387
  }
2368
2388
  const catchChunk = chunk.fork(boundary, null);
2389
+ const { resumeWrites } = boundary;
2369
2390
  catchChunk.reorderId = reorderId;
2370
- catchChunk.render(catchContent, catchBoundary.signal.reason);
2391
+ if ((catchChunk.render(catchContent || NOOP$2, catchBoundary.signal.reason) !== catchChunk || boundary.resumeWrites !== resumeWrites) && renderersAtSettle) catchChunk.render(() => writeTryRenderers(branchId, catchContent, placeholderContent));
2371
2392
  state.reorder(catchChunk);
2372
2393
  boundary.endAsync();
2373
- } else if (!catchBoundary.count) boundary.endAsync();
2374
- else boundary.onNext();
2394
+ } else if (!catchBoundary.count) {
2395
+ if (renderersAtSettle && catchBoundary.resumeWrites) bodyEnd.render(() => writeTryRenderers(branchId, catchContent, placeholderContent));
2396
+ boundary.endAsync();
2397
+ } else boundary.onNext();
2375
2398
  };
2399
+ return renderersAtSettle;
2400
+ }
2401
+ function writeTryRenderers(branchId, catchContent, placeholderContent) {
2402
+ writeScope(branchId, {
2403
+ [CatchContent]: catchContent,
2404
+ [PlaceholderContent]: placeholderContent
2405
+ });
2376
2406
  }
2377
2407
  const NOOP$2 = () => {};
2408
+ function countResumeWrite(boundary) {
2409
+ for (; boundary; boundary = boundary.parent) boundary.resumeWrites++;
2410
+ }
2378
2411
  var State = class {
2379
2412
  tagId = 1;
2380
2413
  scopeId = 1;
@@ -2442,6 +2475,7 @@ var State = class {
2442
2475
  var Boundary = class extends AbortController {
2443
2476
  onNext = NOOP$2;
2444
2477
  count = 0;
2478
+ resumeWrites = 0;
2445
2479
  state;
2446
2480
  parent;
2447
2481
  constructor(state, signal, parent) {
@@ -2500,6 +2534,7 @@ var Chunk = class Chunk {
2500
2534
  this.html += html;
2501
2535
  }
2502
2536
  writeEffect(scopeId, registryId) {
2537
+ countResumeWrite(this.boundary);
2503
2538
  if (this.lastEffect === registryId) this.effects += " " + scopeId;
2504
2539
  else {
2505
2540
  this.lastEffect = registryId;
@@ -2658,6 +2693,8 @@ var Chunk = class Chunk {
2658
2693
  needsWalk = true;
2659
2694
  state.resumes = state.resumes ? state.resumes + ",\"" + effects + "\"" : "\"" + effects + "\"";
2660
2695
  }
2696
+ let reordered = "";
2697
+ let needsResumeArray = false;
2661
2698
  if (state.writeReorders) {
2662
2699
  let carried = null;
2663
2700
  for (const reorderedChunk of state.writeReorders) {
@@ -2701,14 +2738,11 @@ var Chunk = class Chunk {
2701
2738
  else break;
2702
2739
  }
2703
2740
  if (reorderEffects) {
2704
- if (!state.hasWrittenResume) {
2705
- state.hasWrittenResume = true;
2706
- scripts = concatScripts(scripts, runtimePrefix + ".r=[]");
2707
- }
2741
+ needsResumeArray = true;
2708
2742
  reorderScripts = concatScripts(reorderScripts, "_.push(\"" + reorderEffects + "\")");
2709
2743
  }
2710
- for (const reservation of readyReservations) scripts = concatScripts(scripts, reservation);
2711
- scripts = concatScripts(scripts, reorderScripts && runtimePrefix + ".j" + toAccess(reorderId) + "=_=>{" + reorderScripts + "}");
2744
+ for (const reservation of readyReservations) reordered = concatScripts(reordered, reservation);
2745
+ reordered = concatScripts(reordered, reorderScripts && runtimePrefix + ".j" + toAccess(reorderId) + "=_=>{" + reorderScripts + "}");
2712
2746
  html += "<t hidden " + state.commentPrefix + "=" + reorderId + ">" + reorderHTML + "</t>";
2713
2747
  }
2714
2748
  state.writeReorders = carried;
@@ -2719,6 +2753,11 @@ var Chunk = class Chunk {
2719
2753
  state.hasWrittenResume = true;
2720
2754
  scripts = concatScripts(scripts, runtimePrefix + ".r=[" + state.resumes + "]");
2721
2755
  }
2756
+ else if (needsResumeArray && !state.hasWrittenResume) {
2757
+ state.hasWrittenResume = true;
2758
+ scripts = concatScripts(scripts, runtimePrefix + ".r=[]");
2759
+ }
2760
+ scripts = concatScripts(scripts, reordered);
2722
2761
  if (needsWalk) scripts = concatScripts(scripts, runtimePrefix + ".w()");
2723
2762
  this.html = html;
2724
2763
  this.scripts = scripts;
@@ -1,4 +1,4 @@
1
- let require_control_flow = require("../dom-DprILxYO.js"), handlePendingTry = (fn, scope, branch) => {
1
+ let require_control_flow = require("../dom-BNmfm4st.js"), handlePendingTry = (fn, scope, branch) => {
2
2
  for (; branch;) {
3
3
  if (branch.O?.i) return (branch.J ||= []).push(fn, scope);
4
4
  branch = branch.N;
@@ -4,7 +4,7 @@ let handlePendingTry = (fn, scope, branch) => {
4
4
  branch = branch.N;
5
5
  }
6
6
  };
7
- import { $t as caughtError, en as installCatch, g as renderCatch, tn as placeholderShown } from "../dom-BbknkVDz.mjs";
7
+ import { $t as caughtError, en as installCatch, g as renderCatch, tn as placeholderShown } from "../dom-BsAS26Ze.mjs";
8
8
  //#region src/dom/catch.feat.ts
9
9
  installCatch((runEffects) => (effects, checkPending = placeholderShown.has(effects)) => {
10
10
  if (checkPending || caughtError.has(effects)) {
@@ -1,3 +1,3 @@
1
- let require_control_flow = require("../dom-DprILxYO.js");
1
+ let require_control_flow = require("../dom-BNmfm4st.js");
2
2
  require_control_flow.z[0] = require_control_flow.T, require_control_flow.z[1] = require_control_flow.C, require_control_flow.z[2] = require_control_flow.A;
3
3
  //#endregion
@@ -1,3 +1,3 @@
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-BbknkVDz.mjs";
1
+ import { A as _attr_input_value_script, C as _attr_input_checkedValue_script, T as _attr_input_checked_script, z as controllableScripts } from "../dom-BsAS26Ze.mjs";
2
2
  controllableScripts[0] = _attr_input_checked_script, controllableScripts[1] = _attr_input_checkedValue_script, controllableScripts[2] = _attr_input_value_script;
3
3
  //#endregion
@@ -1,4 +1,4 @@
1
- let require_control_flow = require("../dom-DprILxYO.js");
1
+ let require_control_flow = require("../dom-BNmfm4st.js");
2
2
  //#region src/dom/controllable-open.feat.ts
3
3
  require_control_flow.z[4] = require_control_flow.y;
4
4
  //#endregion
@@ -1,4 +1,4 @@
1
- import { y as _attr_details_or_dialog_open_script, z as controllableScripts } from "../dom-BbknkVDz.mjs";
1
+ import { y as _attr_details_or_dialog_open_script, z as controllableScripts } from "../dom-BsAS26Ze.mjs";
2
2
  //#region src/dom/controllable-open.feat.ts
3
3
  controllableScripts[4] = _attr_details_or_dialog_open_script;
4
4
  //#endregion
@@ -1,4 +1,4 @@
1
- let require_control_flow = require("../dom-DprILxYO.js");
1
+ let require_control_flow = require("../dom-BNmfm4st.js");
2
2
  //#region src/dom/controllable-select.feat.ts
3
3
  require_control_flow.z[3] = require_control_flow.N;
4
4
  //#endregion