marko 6.4.2 → 6.4.4

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 (74) hide show
  1. package/cheatsheet.md +2 -2
  2. package/dist/common/constants/accessor-prop.d.ts +1 -0
  3. package/dist/common/constants/accessor-prop.debug.d.ts +1 -0
  4. package/dist/common/constants/renderer-prop.d.ts +2 -0
  5. package/dist/common/constants/renderer-prop.debug.d.ts +2 -0
  6. package/dist/common/types.d.ts +1 -0
  7. package/dist/debug/dom/catch.feat.js +1 -1
  8. package/dist/debug/dom/catch.feat.mjs +1 -1
  9. package/dist/debug/dom/controllable-input.feat.js +1 -1
  10. package/dist/debug/dom/controllable-input.feat.mjs +1 -1
  11. package/dist/debug/dom/controllable-open.feat.js +1 -1
  12. package/dist/debug/dom/controllable-open.feat.mjs +1 -1
  13. package/dist/debug/dom/controllable-select.feat.js +1 -1
  14. package/dist/debug/dom/controllable-select.feat.mjs +1 -1
  15. package/dist/debug/dom/controllable-textarea.feat.js +1 -1
  16. package/dist/debug/dom/controllable-textarea.feat.mjs +1 -1
  17. package/dist/debug/dom/controllable.feat.js +1 -1
  18. package/dist/debug/dom/controllable.feat.mjs +1 -1
  19. package/dist/debug/dom/dynamic-tag-script.feat.js +1 -1
  20. package/dist/debug/dom/dynamic-tag-script.feat.mjs +1 -1
  21. package/dist/debug/dom/dynamic-tag-var.feat.js +10 -2
  22. package/dist/debug/dom/dynamic-tag-var.feat.mjs +10 -2
  23. package/dist/debug/dom/lazy.feat.js +1 -1
  24. package/dist/debug/dom/lazy.feat.mjs +1 -1
  25. package/dist/debug/dom/placeholder.feat.js +1 -1
  26. package/dist/debug/dom/placeholder.feat.mjs +1 -1
  27. package/dist/debug/{dom-Cii0IA92.mjs → dom-BeY1nGUb.mjs} +74 -36
  28. package/dist/debug/{dom-BLbR0hEx.js → dom-CUxvM4i9.js} +109 -35
  29. package/dist/debug/dom.js +3 -1
  30. package/dist/debug/dom.mjs +3 -2
  31. package/dist/debug/html.js +37 -23
  32. package/dist/debug/html.mjs +37 -23
  33. package/dist/dom/catch.feat.js +3 -3
  34. package/dist/dom/catch.feat.mjs +1 -1
  35. package/dist/dom/control-flow.d.ts +3 -3
  36. package/dist/dom/controllable-input.feat.js +1 -1
  37. package/dist/dom/controllable-input.feat.mjs +1 -1
  38. package/dist/dom/controllable-open.feat.js +1 -1
  39. package/dist/dom/controllable-open.feat.mjs +1 -1
  40. package/dist/dom/controllable-select.feat.js +1 -1
  41. package/dist/dom/controllable-select.feat.mjs +1 -1
  42. package/dist/dom/controllable-textarea.feat.js +1 -1
  43. package/dist/dom/controllable-textarea.feat.mjs +1 -1
  44. package/dist/dom/controllable.feat.js +1 -1
  45. package/dist/dom/controllable.feat.mjs +1 -1
  46. package/dist/dom/dynamic-tag-script.feat.js +2 -2
  47. package/dist/dom/dynamic-tag-script.feat.mjs +1 -1
  48. package/dist/dom/dynamic-tag-var.feat.js +4 -2
  49. package/dist/dom/dynamic-tag-var.feat.mjs +4 -3
  50. package/dist/dom/lazy.feat.js +1 -1
  51. package/dist/dom/lazy.feat.mjs +1 -1
  52. package/dist/dom/placeholder.feat.js +3 -3
  53. package/dist/dom/placeholder.feat.mjs +1 -1
  54. package/dist/dom/queue.d.ts +4 -1
  55. package/dist/dom/renderer.d.ts +9 -2
  56. package/dist/{dom-BPjLe6YU.mjs → dom-DefWmvQB.mjs} +59 -32
  57. package/dist/{dom-B8UEYzOz.js → dom-Diu8MpmL.js} +132 -90
  58. package/dist/dom.d.ts +1 -1
  59. package/dist/dom.js +30 -30
  60. package/dist/dom.mjs +2 -2
  61. package/dist/html/assets.d.ts +1 -1
  62. package/dist/html/content.d.ts +1 -0
  63. package/dist/html/dynamic-tag.d.ts +1 -1
  64. package/dist/html/template.d.ts +1 -0
  65. package/dist/html/writer.d.ts +1 -1
  66. package/dist/html.js +25 -15
  67. package/dist/html.mjs +25 -15
  68. package/dist/translator/index.js +141 -83
  69. package/dist/translator/util/module-registrations.d.ts +1 -1
  70. package/dist/translator/util/solve-reasons.d.ts +1 -0
  71. package/dist/translator/visitors/function.d.ts +15 -10
  72. package/dist/translator/visitors/import-declaration.d.ts +3 -4
  73. package/package.json +3 -3
  74. package/tags-html.d.ts +9 -7
@@ -23,6 +23,7 @@ const AbortControllers = "#AbortControllers";
23
23
  const AbortScopes = "#AbortScopes";
24
24
  const AwaitCounter = "#AwaitCounter";
25
25
  const BranchAccessor = "#BranchAccessor";
26
+ const BranchRenders = "#BranchRenders";
26
27
  const BranchScopes = "#BranchScopes";
27
28
  const CatchContent = "#CatchContent";
28
29
  const ClosestBranch = "#ClosestBranch";
@@ -67,6 +68,8 @@ const Params = "params";
67
68
  const Owner = "owner";
68
69
  const Accessor = "accessor";
69
70
  const LocalClosures = "localClosures";
71
+ const Returns = "returns";
72
+ const Lazy = "lazy";
70
73
  //#endregion
71
74
  //#region src/common/helpers.ts
72
75
  const htmlAttrNameReg = /^[^a-z_]|[^a-z0-9._:-]/i;
@@ -342,16 +345,19 @@ let rendering;
342
345
  let runId = 2;
343
346
  let pendingEffects = [];
344
347
  let pendingRenders = [];
345
- const scopeKeyOffset = 1e6;
348
+ const ranRenders = /*@__PURE__*/ new WeakMap();
346
349
  function queueRender(scope, signal, signalKey, value, scopeKey = scope["#Id"]) {
347
350
  let render;
348
351
  if (signalKey >= 0 && (render = scope[signalKey])) {
349
352
  render[Value] = value;
350
- if (render["gen"] === runId || catchEnabled && render["pending"]) return;
353
+ if (render["gen"] === runId || catchEnabled && render["pending"]) {
354
+ if (!render["pending"] && ranRenders.get(render) === runId) console.error("A render was queued again after it ran in this update, so its latest value is dropped. This is a bug in Marko.");
355
+ return;
356
+ }
351
357
  render["gen"] = runId;
352
358
  } else {
353
359
  render = {
354
- ["key"]: scopeKey * scopeKeyOffset + signalKey,
360
+ ["key"]: scopeKey * 1e6 + signalKey,
355
361
  [Scope]: scope,
356
362
  [Signal]: signal,
357
363
  [Value]: value,
@@ -361,7 +367,7 @@ function queueRender(scope, signal, signalKey, value, scopeKey = scope["#Id"]) {
361
367
  }
362
368
  queuePendingRender(render);
363
369
  }
364
- function queuePendingRender(render) {
370
+ let queuePendingRender = (render) => {
365
371
  let i = pendingRenders.push(render) - 1;
366
372
  while (i) {
367
373
  const parentIndex = i - 1 >> 1;
@@ -371,6 +377,34 @@ function queuePendingRender(render) {
371
377
  i = parentIndex;
372
378
  }
373
379
  pendingRenders[i] = render;
380
+ };
381
+ function createBranchRenders(scope, scopeKey) {
382
+ return {
383
+ ["key"]: scopeKey * 1e6 - 1,
384
+ [Scope]: scope,
385
+ [Signal]: runBranchRenders,
386
+ [Value]: [],
387
+ ["gen"]: 0
388
+ };
389
+ }
390
+ function installBranchRenders() {
391
+ const queue = queuePendingRender;
392
+ queuePendingRender = (render) => {
393
+ const branchRenders = render[Scope][ClosestBranch]?.[BranchRenders];
394
+ if (branchRenders) {
395
+ if (branchRenders["gen"] !== runId && !branchRenders["pending"]) branchRenders[Value] = [];
396
+ branchRenders["gen"] = runId;
397
+ const renders = branchRenders[Value];
398
+ if (!renders.length) queuePendingRender(branchRenders);
399
+ const prev = pendingRenders;
400
+ pendingRenders = renders;
401
+ queue(render);
402
+ pendingRenders = prev;
403
+ } else queue(render);
404
+ };
405
+ }
406
+ function runBranchRenders(_scope, renders) {
407
+ runRenders(renders);
374
408
  }
375
409
  function queueEffect(scope, fn) {
376
410
  pendingEffects.push(fn, scope);
@@ -422,26 +456,27 @@ function installCatch(catchEffects, wrapRender) {
422
456
  runEffects = catchEffects;
423
457
  runRender = wrapRender(runRender);
424
458
  }
425
- function runRenders() {
426
- while (pendingRenders.length) {
427
- const render = pendingRenders[0];
428
- const item = pendingRenders.pop();
459
+ function runRenders(renders = pendingRenders) {
460
+ while (renders.length) {
461
+ const render = renders[0];
462
+ const item = renders.pop();
429
463
  if (render !== item) {
430
464
  let i = 0;
431
- const mid = pendingRenders.length >> 1;
432
- const key = (pendingRenders[0] = item)["key"];
465
+ const mid = renders.length >> 1;
466
+ const key = (renders[0] = item)["key"];
433
467
  while (i < mid) {
434
468
  let bestChild = (i << 1) + 1;
435
469
  const right = bestChild + 1;
436
- if (right < pendingRenders.length && pendingRenders[right]["key"] - pendingRenders[bestChild]["key"] < 0) bestChild = right;
437
- if (pendingRenders[bestChild]["key"] - key >= 0) break;
470
+ if (right < renders.length && renders[right]["key"] - renders[bestChild]["key"] < 0) bestChild = right;
471
+ if (renders[bestChild]["key"] - key >= 0) break;
438
472
  else {
439
- pendingRenders[i] = pendingRenders[bestChild];
473
+ renders[i] = renders[bestChild];
440
474
  i = bestChild;
441
475
  }
442
476
  }
443
- pendingRenders[i] = item;
477
+ renders[i] = item;
444
478
  }
479
+ ranRenders.set(render, runId);
445
480
  runRender(render);
446
481
  }
447
482
  }
@@ -685,9 +720,9 @@ function _for_closure(ownerLoopNodeAccessor, fn) {
685
720
  const scopeAccessor = BranchScopes$1 + ownerLoopNodeAccessor;
686
721
  const ownerSignal = (ownerScope) => {
687
722
  const scopes = toArray(ownerScope[scopeAccessor]);
688
- if (scopes.length) queueRender(ownerScope, () => {
723
+ queueRender(ownerScope, () => {
689
724
  for (const scope of scopes) if (scope["#Gen"] > 0 && scope["#Gen"] < runId) fn(scope);
690
- }, -1, 0, scopes[0]["#Id"]);
725
+ }, -1);
691
726
  };
692
727
  ownerSignal._ = fn;
693
728
  return ownerSignal;
@@ -697,8 +732,7 @@ function _for_selector(ownerLoopNodeAccessor, ownerValueAccessor, keyValueAccess
697
732
  const mapAccessor = KeyedScopes + ownerLoopNodeAccessor;
698
733
  const prevKeyProp = `${PreviousKey}${ownerValueAccessor}`;
699
734
  const ownerSignal = (ownerScope) => {
700
- const scopes = toArray(ownerScope[scopeAccessor]);
701
- if (ownerScope["#Gen"] < runId && scopes.length) {
735
+ if (ownerScope["#Gen"] < runId) {
702
736
  const nextKey = ownerScope[ownerValueAccessor];
703
737
  queueRender(ownerScope, () => {
704
738
  const map = keyedScopes(ownerScope, scopeAccessor, mapAccessor, keyValueAccessor);
@@ -711,7 +745,7 @@ function _for_selector(ownerLoopNodeAccessor, ownerValueAccessor, keyValueAccess
711
745
  }
712
746
  } else for (const scope of toArray(ownerScope[scopeAccessor])) runLiveBranch(scope, fn);
713
747
  if (map) map[prevKeyProp] = nextKey;
714
- }, -1, 0, scopes[0]["#Id"]);
748
+ }, -1);
715
749
  }
716
750
  };
717
751
  ownerSignal._ = fn;
@@ -1082,13 +1116,13 @@ function init(runtimeId = "M") {
1082
1116
  visitScope[nextToken()] = visitType === "%" ? visit.parentNode.insertBefore(new Text(), visit) : visit.previousSibling;
1083
1117
  if ((branchesEnabled || lazyEnabled) && pending[pending.length - 1] !== visitScope) pending.push(visitScope);
1084
1118
  }
1119
+ if (embedRenders && !embedAnchor && visit.parentNode) embedRenders.set(embedAnchor = visit.parentNode.insertBefore(new Text(), visit), [renderId, scopeLookup]);
1085
1120
  }
1086
1121
  if (branchesEnabled && visitBranches) {
1087
1122
  visitType = "*";
1088
1123
  lastToken = "";
1089
1124
  visitBranches();
1090
1125
  }
1091
- if (embedRenders && !embedAnchor && visit?.parentNode) embedRenders.set(embedAnchor = visit.parentNode.insertBefore(new Text(), visit.nextSibling), [renderId, scopeLookup]);
1092
1126
  visits.length = retained;
1093
1127
  return effects;
1094
1128
  };
@@ -1156,6 +1190,10 @@ function setupBranch(renderer, branch) {
1156
1190
  if (renderer["setup"]) queueRender(branch, renderer[Setup], -1);
1157
1191
  return branch;
1158
1192
  }
1193
+ function _return_setup(setup) {
1194
+ (setup._ || setup)[Returns] = 1;
1195
+ return setup;
1196
+ }
1159
1197
  function _content(id, template, walks, setup, params, dynamicScopesAccessor) {
1160
1198
  walks = walks ? walks.replace(/[^\0-1]+$/, "") : "";
1161
1199
  setup = setup ? setup._ || setup : void 0;
@@ -1649,11 +1687,8 @@ function getSelectValue(el, multiple) {
1649
1687
  return multiple ? Array.from(el.selectedOptions, (opt) => opt.value) : el.value;
1650
1688
  }
1651
1689
  function assertSelectValueMatchesOption(el, normalizedValue, value) {
1652
- const multiple = Array.isArray(normalizedValue);
1653
- if (multiple ? normalizedValue.some(Boolean) : normalizedValue) {
1654
- for (const opt of el.options) if (multiple ? normalizedValue.includes(opt.value) : opt.value === normalizedValue) return;
1655
- console.error("A controlled `<select>`'s `value` has no matching `<option>`:", value);
1656
- }
1690
+ const options = Array.from(el.options, (opt) => opt.value);
1691
+ if ((Array.isArray(normalizedValue) ? normalizedValue : [normalizedValue]).some((v) => v && !options.includes(v))) console.error("A controlled `<select>`'s `value` has no matching `<option>`:", value);
1657
1692
  }
1658
1693
  function _attr_details_or_dialog_open_default(scope, nodeAccessor, open) {
1659
1694
  if (scope["#Gen"] === runId) scope[nodeAccessor].open = isNotVoid(open);
@@ -1688,7 +1723,7 @@ function syncControllableFormInput(el, hasChanged, onChange) {
1688
1723
  el._ = onChange;
1689
1724
  el.c = hasChanged;
1690
1725
  delegate("input", handleChange);
1691
- if (el.form) delegate("reset", handleFormReset);
1726
+ delegate("reset", handleFormReset);
1692
1727
  if (isResuming && hasChanged(el)) queueMicrotask(onChange);
1693
1728
  }
1694
1729
  function handleChange(ev) {
@@ -1696,7 +1731,7 @@ function handleChange(ev) {
1696
1731
  }
1697
1732
  function handleFormReset(ev) {
1698
1733
  const handlers = [];
1699
- for (const el of ev.target.elements) if (el._ && el.c(el)) handlers.push(el._);
1734
+ for (const el of ev.target.elements || []) if (el._ && el.c(el)) handlers.push(el._);
1700
1735
  requestAnimationFrame(() => {
1701
1736
  if (!ev.defaultPrevented) for (const change of handlers) change();
1702
1737
  });
@@ -1993,18 +2028,19 @@ function patchDynamicTag(fn) {
1993
2028
  _dynamic_tag = fn(_dynamic_tag);
1994
2029
  }
1995
2030
  let _dynamic_tag = /*@__PURE__*/ withBranches((nodeAccessor, getContent, getTagVar, inputIsArgs) => {
2031
+ const scopeOffsetAccessor = getTagVar && getDebugKey(+nodeAccessor.slice(nodeAccessor.lastIndexOf("/") + 1) + 1, "#scopeOffset");
1996
2032
  const childScopeAccessor = BranchScopes$1 + nodeAccessor;
1997
2033
  const rendererAccessor = ConditionalRenderer + nodeAccessor;
1998
2034
  return (scope, newRenderer, getInput) => {
1999
2035
  const normalizedRenderer = normalizeDynamicRenderer(newRenderer);
2000
- if (scope[rendererAccessor] !== (scope[rendererAccessor] = rendererKey(normalizedRenderer)) || getContent && !(normalizedRenderer || scope[childScopeAccessor])) {
2036
+ if (scope[rendererAccessor] !== (scope[rendererAccessor] = rendererKey(normalizedRenderer) || (getContent ? void 0 : 0)) || getContent && !(normalizedRenderer || scope[childScopeAccessor])) {
2001
2037
  const renderer = normalizedRenderer || (getContent ? getContent(scope) : void 0);
2002
2038
  setConditionalRenderer(scope, nodeAccessor, renderer, createBranchWithTagNameOrRenderer);
2003
2039
  if (getTagVar) {
2004
- if (scope[childScopeAccessor]) {
2040
+ if (normalizedRenderer) {
2005
2041
  scope[childScopeAccessor][TagVariable] = (value) => getTagVar()(scope, value);
2006
- if (typeof normalizedRenderer === "string") bindNativeTagVar?.(scope[childScopeAccessor]);
2007
- } else getTagVar()(scope, void 0);
2042
+ bindTagVar(scope, scope[childScopeAccessor], scope[scopeOffsetAccessor], normalizedRenderer);
2043
+ } else getTagVar()(scope);
2008
2044
  }
2009
2045
  if (typeof renderer === "string") {
2010
2046
  if (getContent) {
@@ -2012,7 +2048,10 @@ let _dynamic_tag = /*@__PURE__*/ withBranches((nodeAccessor, getContent, getTagV
2012
2048
  setConditionalRenderer(scope[childScopeAccessor], `#${renderer.toLowerCase()}/0`, content, createAndSetupBranch);
2013
2049
  if (content["accessor"]) subscribeToScopeSet(content[Owner], content[Accessor], scope[childScopeAccessor][`BranchScopes:#${renderer.toLowerCase()}/0`]);
2014
2050
  }
2015
- } else if (renderer?.["accessor"]) subscribeToScopeSet(renderer[Owner], renderer[Accessor], scope[childScopeAccessor]);
2051
+ } else if (renderer) {
2052
+ setupBranch(renderer, scope[childScopeAccessor]);
2053
+ if (renderer["accessor"]) subscribeToScopeSet(renderer[Owner], renderer[Accessor], scope[childScopeAccessor]);
2054
+ }
2016
2055
  }
2017
2056
  if (normalizedRenderer) {
2018
2057
  const childScope = scope[childScopeAccessor];
@@ -2048,9 +2087,9 @@ const _dynamic_tag_content = /*@__PURE__*/ withBranches((nodeAccessor) => {
2048
2087
  renderer?.[LocalClosures]?.(scope[childScopeAccessor]);
2049
2088
  };
2050
2089
  });
2051
- let bindNativeTagVar;
2090
+ let bindTagVar;
2052
2091
  function installDynamicTagVar(bind) {
2053
- bindNativeTagVar = bind;
2092
+ bindTagVar = bind;
2054
2093
  }
2055
2094
  function dynamicTagScript(branch) {
2056
2095
  _attrs_script(branch, `#${branch[Renderer].toLowerCase()}/0`);
@@ -2203,7 +2242,6 @@ function createBranchWithTagNameOrRenderer($global, tagNameOrRenderer, parentSco
2203
2242
  if (typeof tagNameOrRenderer === "string") assertValidTagName(tagNameOrRenderer);
2204
2243
  const branch = createBranch($global, tagNameOrRenderer, parentScope, parentNode);
2205
2244
  if (typeof tagNameOrRenderer === "string") branch[`#${tagNameOrRenderer.toLowerCase()}/0`] = branch[StartNode] = branch[EndNode] = document.createElementNS(tagNameOrRenderer === "svg" ? "http://www.w3.org/2000/svg" : tagNameOrRenderer === "math" ? "http://www.w3.org/1998/Math/MathML" : parentNode.namespaceURI, tagNameOrRenderer);
2206
- else setupBranch(tagNameOrRenderer, branch);
2207
2245
  return branch;
2208
2246
  }
2209
2247
  function bySecondArg(_item, index) {
@@ -2231,6 +2269,12 @@ Object.defineProperty(exports, "AwaitCounter", {
2231
2269
  return AwaitCounter;
2232
2270
  }
2233
2271
  });
2272
+ Object.defineProperty(exports, "BranchRenders", {
2273
+ enumerable: true,
2274
+ get: function() {
2275
+ return BranchRenders;
2276
+ }
2277
+ });
2234
2278
  Object.defineProperty(exports, "Clone", {
2235
2279
  enumerable: true,
2236
2280
  get: function() {
@@ -2267,6 +2311,12 @@ Object.defineProperty(exports, "Global", {
2267
2311
  return Global;
2268
2312
  }
2269
2313
  });
2314
+ Object.defineProperty(exports, "Lazy", {
2315
+ enumerable: true,
2316
+ get: function() {
2317
+ return Lazy;
2318
+ }
2319
+ });
2270
2320
  Object.defineProperty(exports, "Load", {
2271
2321
  enumerable: true,
2272
2322
  get: function() {
@@ -2327,6 +2377,12 @@ Object.defineProperty(exports, "PlaceholderBranch", {
2327
2377
  return PlaceholderBranch;
2328
2378
  }
2329
2379
  });
2380
+ Object.defineProperty(exports, "Returns", {
2381
+ enumerable: true,
2382
+ get: function() {
2383
+ return Returns;
2384
+ }
2385
+ });
2330
2386
  Object.defineProperty(exports, "Scope", {
2331
2387
  enumerable: true,
2332
2388
  get: function() {
@@ -2825,6 +2881,12 @@ Object.defineProperty(exports, "_return_change", {
2825
2881
  return _return_change;
2826
2882
  }
2827
2883
  });
2884
+ Object.defineProperty(exports, "_return_setup", {
2885
+ enumerable: true,
2886
+ get: function() {
2887
+ return _return_setup;
2888
+ }
2889
+ });
2828
2890
  Object.defineProperty(exports, "_script", {
2829
2891
  enumerable: true,
2830
2892
  get: function() {
@@ -2921,6 +2983,12 @@ Object.defineProperty(exports, "createBranch", {
2921
2983
  return createBranch;
2922
2984
  }
2923
2985
  });
2986
+ Object.defineProperty(exports, "createBranchRenders", {
2987
+ enumerable: true,
2988
+ get: function() {
2989
+ return createBranchRenders;
2990
+ }
2991
+ });
2924
2992
  Object.defineProperty(exports, "destroyBranch", {
2925
2993
  enumerable: true,
2926
2994
  get: function() {
@@ -2987,6 +3055,12 @@ Object.defineProperty(exports, "insertChildNodes", {
2987
3055
  return insertChildNodes;
2988
3056
  }
2989
3057
  });
3058
+ Object.defineProperty(exports, "installBranchRenders", {
3059
+ enumerable: true,
3060
+ get: function() {
3061
+ return installBranchRenders;
3062
+ }
3063
+ });
2990
3064
  Object.defineProperty(exports, "installCatch", {
2991
3065
  enumerable: true,
2992
3066
  get: function() {
package/dist/debug/dom.js CHANGED
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
- const require_control_flow = require("./dom-BLbR0hEx.js");
3
+ const require_control_flow = require("./dom-CUxvM4i9.js");
4
4
  //#region src/common/attr-tag.ts
5
5
  const empty = [];
6
6
  const rest = Symbol("Attribute Tag");
@@ -205,6 +205,7 @@ function _load_template(id, load) {
205
205
  require_control_flow.queueAsyncRender(branch, (branch) => insertLoaded(renderer, branch, branch[require_control_flow.StartNode], awaitCounter));
206
206
  }, loadFailed(branch, awaitCounter));
207
207
  }, _load_signal(() => (pending ||= load()).then((r) => ({ _: r["params"] || noop }))));
208
+ lazyTemplate[require_control_flow.Lazy] = 1;
208
209
  return lazyTemplate;
209
210
  }
210
211
  function _load_setup(load) {
@@ -394,6 +395,7 @@ exports._or = require_control_flow._or;
394
395
  exports._resumed = require_control_flow._resumed;
395
396
  exports._return = require_control_flow._return;
396
397
  exports._return_change = require_control_flow._return_change;
398
+ exports._return_setup = require_control_flow._return_setup;
397
399
  exports._script = require_control_flow._script;
398
400
  exports._show = require_control_flow._show;
399
401
  exports._style_rule_item = require_control_flow._style_rule_item;
@@ -1,4 +1,4 @@
1
- import { $ as _attr_style_items, $t as removeAndDestroyBranch, A as _attr_input_value, At as _child_setup, B as _controllable_select, Bt as _id, C as _attr_details_or_dialog_open_script, Ct as _var_resume, D as _attr_input_checkedValue_script, Dn as Setup, Dt as ready, E as _attr_input_checkedValue_default, En as Params, Et as initEmbedded, F as _attr_select_value, Fn as Load, Ft as _for_closure, G as _attr_class, Gt as _return, Hn as TagVariable, Ht as _let, I as _attr_select_value_default, It as _for_selector, J as _attr_class_names, Jt as _var, K as _attr_class_item, Kt as _return_change, L as _attr_select_value_script, Lt as _global_read, M as _attr_input_value_default, Mn as EndNode, Mt as _closure_get, N as _attr_input_value_dynamic_default, Nt as _const, O as _attr_input_checked_default, Ot as readyFailed, P as _attr_input_value_script, Pn as Global, Pt as _el_read, Q as _attr_style_item, Qt as insertBranchBefore, R as _controllable_input, Rt as _hoist, S as _attr_details_or_dialog_open_default, Sn as _call, St as _resumed, T as _attr_input_checkedValue, Tn as Owner, Tt as init, Ut as _let_change, V as _controllable_textarea, Vn as StartNode, Vt as _if_closure, W as _attr, Wt as _or, X as _attr_nonce, Xt as _assert_init, Y as _attr_content, Yt as _var_change, Z as _attr_style, Zt as destroyBranch, _n as forTo, _t as createAndSetupBranch, a as _for_in, an as $signalReset, at as _html, bn as _assert_hoist, bt as _dynamic_tag_var_resume, c as _for_to, cn as queueAsyncRender, ct as _style_shell, d as _for_until_unkeyed, dn as rendering, dt as _to_text, en as syncGen, et as _attrs, f as _if, fn as run, ft as insertChildNodes, gn as forOf, gt as _content_resume, h as addAwaitCounter, hn as forIn, ht as _content_closures, i as _dynamic_tag_content, in as $signal, it as _attrs_script, j as _attr_input_value_attribute_default, jt as _closure, k as _attr_input_checked_script, l as _for_to_unkeyed, ln as queueEffect, lt as _text, m as _try, mn as runId, mt as _content, n as _await_promise, nt as _attrs_partial, o as _for_of, ot as _lifecycle, p as _show, pn as runEffects, pt as toInsertNode, q as _attr_class_items, qt as _script, r as _dynamic_tag, rn as _on, rt as _attrs_partial_content, s as _for_of_unkeyed, sn as prepareEffects, st as _style_rule_item, t as _await_content, tt as _attrs_content, u as _for_until, un as queueRender, ut as _text_content, v as patchDynamicTag, vn as forUntil, vt as createBranch, w as _attr_input_checked, wn as Clone, wt as getRegisteredWithScope, x as _attr_details_or_dialog_open, xn as _hoist_read_error, xt as _el, y as renderCatch, yn as _assert_class_toggles, yt as setupBranch, z as _controllable_open, zt as _hoist_resume } from "./dom-Cii0IA92.mjs";
1
+ import { $ as _attr_style_items, $t as insertBranchBefore, A as _attr_input_value, An as Params, B as _controllable_select, Bn as Global, Bt as _hoist_resume, C as _attr_details_or_dialog_open_script, Cn as _assert_hoist, Ct as _resumed, D as _attr_input_checkedValue_script, Dn as Clone, Dt as initEmbedded, E as _attr_input_checkedValue_default, Et as init, F as _attr_select_value, Ft as _el_read, G as _attr_class, Gt as _or, Ht as _if_closure, I as _attr_select_value_default, It as _for_closure, J as _attr_class_names, Jn as TagVariable, Jt as _script, K as _attr_class_item, Kt as _return, L as _attr_select_value_script, Lt as _for_selector, M as _attr_input_value_default, Mn as Setup, Mt as _closure, N as _attr_input_value_dynamic_default, Nt as _closure_get, O as _attr_input_checked_default, On as Lazy, Ot as ready, P as _attr_input_value_script, Pt as _const, Q as _attr_style_item, Qt as destroyBranch, R as _controllable_input, Rn as EndNode, Rt as _global_read, S as _attr_details_or_dialog_open_default, Sn as _assert_class_toggles, St as _el, T as _attr_input_checkedValue, Tn as _call, Tt as getRegisteredWithScope, Ut as _let, V as _controllable_textarea, Vn as Load, Vt as _id, W as _attr, Wt as _let_change, X as _attr_nonce, Xt as _var_change, Y as _attr_content, Yt as _var, Z as _attr_style, Zt as _assert_init, _n as runId, _t as _return_setup, a as _for_in, an as $signal, at as _html, bn as forTo, bt as setupBranch, c as _for_to, ct as _style_shell, d as _for_until_unkeyed, dn as queueAsyncRender, dt as _to_text, en as removeAndDestroyBranch, et as _attrs, f as _if, fn as queueEffect, ft as insertChildNodes, gn as runEffects, gt as _content_resume, h as addAwaitCounter, hn as run, ht as _content_closures, i as _dynamic_tag_content, in as _on, it as _attrs_script, j as _attr_input_value_attribute_default, jt as _child_setup, k as _attr_input_checked_script, kn as Owner, kt as readyFailed, l as _for_to_unkeyed, lt as _text, m as _try, mn as rendering, mt as _content, n as _await_promise, nt as _attrs_partial, o as _for_of, on as $signalReset, ot as _lifecycle, p as _show, pn as queueRender, pt as toInsertNode, q as _attr_class_items, qn as StartNode, qt as _return_change, r as _dynamic_tag, rt as _attrs_partial_content, s as _for_of_unkeyed, st as _style_rule_item, t as _await_content, tn as syncGen, tt as _attrs_content, u as _for_until, un as prepareEffects, ut as _text_content, v as patchDynamicTag, vn as forIn, vt as createAndSetupBranch, w as _attr_input_checked, wn as _hoist_read_error, wt as _var_resume, x as _attr_details_or_dialog_open, xn as forUntil, xt as _dynamic_tag_var_resume, y as renderCatch, yn as forOf, yt as createBranch, z as _controllable_open, zt as _hoist } from "./dom-BeY1nGUb.mjs";
2
2
  //#region src/common/attr-tag.ts
3
3
  const empty = [];
4
4
  const rest = Symbol("Attribute Tag");
@@ -203,6 +203,7 @@ function _load_template(id, load) {
203
203
  queueAsyncRender(branch, (branch) => insertLoaded(renderer, branch, branch[StartNode], awaitCounter));
204
204
  }, loadFailed(branch, awaitCounter));
205
205
  }, _load_signal(() => (pending ||= load()).then((r) => ({ _: r["params"] || noop }))));
206
+ lazyTemplate[Lazy] = 1;
206
207
  return lazyTemplate;
207
208
  }
208
209
  function _load_setup(load) {
@@ -292,4 +293,4 @@ function getSelectorOrResolve(selector, resolve) {
292
293
  return document.querySelector(selector) || (console.warn(`A lazy load trigger could not find an element matching "${selector}". The module was loaded immediately.`), resolve());
293
294
  }
294
295
  //#endregion
295
- export { $signal, $signalReset, _assert_class_toggles, _assert_hoist, _assert_init, _attr, _attr_class, _attr_class_item, _attr_class_items, _attr_class_names, _attr_content, _attr_details_or_dialog_open as _attr_details_open, _attr_details_or_dialog_open as _attr_dialog_open, _attr_details_or_dialog_open_default as _attr_details_open_default, _attr_details_or_dialog_open_default as _attr_dialog_open_default, _attr_details_or_dialog_open_script as _attr_details_open_script, _attr_details_or_dialog_open_script as _attr_dialog_open_script, _attr_input_checked, _attr_input_checkedValue, _attr_input_checkedValue_default, _attr_input_checkedValue_script, _attr_input_checked_default, _attr_input_checked_script, _attr_input_value, _attr_input_value as _attr_textarea_value, _attr_input_value_attribute_default, _attr_input_value_default, _attr_input_value_default as _attr_textarea_value_default, _attr_input_value_dynamic_default, _attr_input_value_script, _attr_input_value_script as _attr_textarea_value_script, _attr_nonce, _attr_select_value, _attr_select_value_default, _attr_select_value_script, _attr_style, _attr_style_item, _attr_style_items, _attrs, _attrs_content, _attrs_partial, _attrs_partial_content, _attrs_script, _await_content, _await_promise, _call, _child_setup, _closure, _closure_get, _const, _content, _content_closures, _content_resume, _controllable_input, _controllable_open, _controllable_select, _controllable_textarea, _dynamic_tag, _dynamic_tag_content, _dynamic_tag_var_resume, _el, _el_read, _for_closure, _for_in, _for_of, _for_of_unkeyed, _for_selector, _for_to, _for_to_unkeyed, _for_until, _for_until_unkeyed, _global_read, _hoist, _hoist_read_error, _hoist_resume, _html, _id, _if, _if_closure, _let, _let_change, _lifecycle, _load_event_trigger, _load_idle_trigger, _load_media_trigger, _load_race_trigger, _load_setup, _load_signal, _load_template, _load_visible_trigger, _on, _or, _resumed, _return, _return_change, _script, _show, _style_rule_item, _style_shell, _template, _text, _text_content, _to_text, _try, _var, _var_change, _var_resume, attrTag, attrTags, compat, forIn, forOf, forTo, forUntil, init, initEmbedded, ready, readyFailed, run };
296
+ export { $signal, $signalReset, _assert_class_toggles, _assert_hoist, _assert_init, _attr, _attr_class, _attr_class_item, _attr_class_items, _attr_class_names, _attr_content, _attr_details_or_dialog_open as _attr_details_open, _attr_details_or_dialog_open as _attr_dialog_open, _attr_details_or_dialog_open_default as _attr_details_open_default, _attr_details_or_dialog_open_default as _attr_dialog_open_default, _attr_details_or_dialog_open_script as _attr_details_open_script, _attr_details_or_dialog_open_script as _attr_dialog_open_script, _attr_input_checked, _attr_input_checkedValue, _attr_input_checkedValue_default, _attr_input_checkedValue_script, _attr_input_checked_default, _attr_input_checked_script, _attr_input_value, _attr_input_value as _attr_textarea_value, _attr_input_value_attribute_default, _attr_input_value_default, _attr_input_value_default as _attr_textarea_value_default, _attr_input_value_dynamic_default, _attr_input_value_script, _attr_input_value_script as _attr_textarea_value_script, _attr_nonce, _attr_select_value, _attr_select_value_default, _attr_select_value_script, _attr_style, _attr_style_item, _attr_style_items, _attrs, _attrs_content, _attrs_partial, _attrs_partial_content, _attrs_script, _await_content, _await_promise, _call, _child_setup, _closure, _closure_get, _const, _content, _content_closures, _content_resume, _controllable_input, _controllable_open, _controllable_select, _controllable_textarea, _dynamic_tag, _dynamic_tag_content, _dynamic_tag_var_resume, _el, _el_read, _for_closure, _for_in, _for_of, _for_of_unkeyed, _for_selector, _for_to, _for_to_unkeyed, _for_until, _for_until_unkeyed, _global_read, _hoist, _hoist_read_error, _hoist_resume, _html, _id, _if, _if_closure, _let, _let_change, _lifecycle, _load_event_trigger, _load_idle_trigger, _load_media_trigger, _load_race_trigger, _load_setup, _load_signal, _load_template, _load_visible_trigger, _on, _or, _resumed, _return, _return_change, _return_setup, _script, _show, _style_rule_item, _style_shell, _template, _text, _text_content, _to_text, _try, _var, _var_change, _var_resume, attrTag, attrTags, compat, forIn, forOf, forTo, forUntil, init, initEmbedded, ready, readyFailed, run };
@@ -37,6 +37,7 @@ const Renderer = "#Renderer";
37
37
  const TagVariable = "#TagVariable";
38
38
  const Owner = "owner";
39
39
  const Embed = "embed";
40
+ const Lazy = "lazy";
40
41
  //#endregion
41
42
  //#region src/common/helpers.ts
42
43
  const htmlAttrNameReg = /^[^a-z_]|[^a-z0-9._:-]/i;
@@ -1853,10 +1854,7 @@ function _attr_option_value(value) {
1853
1854
  const valueAttr = _attr("value", value);
1854
1855
  const selectedValue = getContext(kSelectedValue);
1855
1856
  if (selectedValue !== void 0 && normalizedValueMatches(selectedValue, value)) {
1856
- {
1857
- const matched = getContext(kSelectedValueMatched);
1858
- if (matched) matched.value = true;
1859
- }
1857
+ getContext(kSelectedValueMatched)?.add(normalizeStrAttrValue(value));
1860
1858
  return valueAttr + " selected";
1861
1859
  }
1862
1860
  return valueAttr;
@@ -1868,9 +1866,12 @@ function _attr_select_value(scopeId, nodeAccessor, value, valueChange, content,
1868
1866
  if (content) {
1869
1867
  const selectedValue = value ?? "";
1870
1868
  if (valueChange) {
1871
- const matched = { value: false };
1869
+ const matched = /* @__PURE__ */ new Set();
1872
1870
  withContext(kSelectedValue, selectedValue, () => withContext(kSelectedValueMatched, matched, content));
1873
- if (!matched.value && (Array.isArray(value) ? value.some((v) => normalizeStrAttrValue(v) !== "") : normalizeStrAttrValue(value) !== "")) console.error("A controlled `<select>`'s `value` has no matching `<option>`:", value);
1871
+ if ((Array.isArray(value) ? value : [value]).some((v) => {
1872
+ const str = normalizeStrAttrValue(v);
1873
+ return str !== "" && !matched.has(str);
1874
+ })) console.error("A controlled `<select>`'s `value` has no matching `<option>`:", value);
1874
1875
  } else withContext(kSelectedValue, selectedValue, content);
1875
1876
  }
1876
1877
  }
@@ -2325,9 +2326,12 @@ function _attr_content(nodeAccessor, scopeId, content, markerGuard) {
2325
2326
  const shouldResume = markerGuard !== 0;
2326
2327
  const render = normalizeServerRender(content);
2327
2328
  const branchId = _peek_scope_id();
2328
- if (render) {
2329
+ if (render) try {
2330
+ _set_scope_reason(shouldResume ? CLIENT_ALL : 0);
2329
2331
  if (shouldResume) withBranchId(branchId, render);
2330
2332
  else render();
2333
+ } finally {
2334
+ _set_scope_reason(void 0);
2331
2335
  }
2332
2336
  if (_peek_scope_id() !== branchId) {
2333
2337
  if (shouldResume) writeScope(scopeId, {
@@ -2672,7 +2676,7 @@ function tryBoundary(content, catchContent, branchId, renderers) {
2672
2676
  if (!renderersAtSettle) catchChunk.render(clearTryRenderers, branchId);
2673
2677
  const inOrder = catchChunk === catchChunk.render(catchContent, catchBoundary.reason);
2674
2678
  if (boundary.aborted) return;
2675
- if (bodyEnd.consumed || !inOrder) catchChunk.reorderStart = state.mark("*", branchId + "");
2679
+ if (bodyEnd.consumed || !inOrder) catchChunk.reorderBranch = branchId;
2676
2680
  if (bodyEnd.consumed) {
2677
2681
  catchChunk.reorderId = reorderId;
2678
2682
  state.reorder(catchChunk);
@@ -2880,7 +2884,7 @@ var Chunk = class Chunk {
2880
2884
  async = false;
2881
2885
  consumed = false;
2882
2886
  reorderId = null;
2883
- reorderStart = "";
2887
+ reorderBranch = 0;
2884
2888
  deferredReady = null;
2885
2889
  heldEffects = null;
2886
2890
  deferredReorder = null;
@@ -3138,7 +3142,8 @@ var Chunk = class Chunk {
3138
3142
  state.hasReorderRuntime = true;
3139
3143
  scripts = concatScripts(scripts, REORDER_RUNTIME_CODE + "(" + runtimePrefix + ")");
3140
3144
  }
3141
- const { reorderId, reorderStart } = reorderedChunk;
3145
+ const { reorderId, reorderBranch } = reorderedChunk;
3146
+ const rootBranch = reorderBranch || +reorderId;
3142
3147
  const readyReservations = [];
3143
3148
  let reorderHTML = "";
3144
3149
  let reorderEffects = "";
@@ -3166,7 +3171,8 @@ var Chunk = class Chunk {
3166
3171
  reorderScripts = concatScripts(reorderScripts, concatScripts(readyResumeScripts, cur.scripts));
3167
3172
  if (cur.async) {
3168
3173
  reorderHTML += state.mark("#", cur.reorderId = state.nextReorderId());
3169
- cur.reorderStart = reorderStart;
3174
+ const holeBranch = cur.context?.[kBranchId];
3175
+ cur.reorderBranch = holeBranch > rootBranch ? holeBranch : reorderBranch;
3170
3176
  (cur.boundary.pendingReorders ||= /* @__PURE__ */ new Set()).add(cur);
3171
3177
  cur.html = cur.effects = cur.scripts = cur.lastEffect = "";
3172
3178
  cur.next = null;
@@ -3182,7 +3188,7 @@ var Chunk = class Chunk {
3182
3188
  }
3183
3189
  for (const reservation of readyReservations) reordered = concatScripts(reordered, reservation);
3184
3190
  reordered = concatScripts(reordered, reorderScripts && runtimePrefix + ".j" + toAccess(reorderId) + "=_=>{" + reorderScripts + "}");
3185
- html += "<t hidden " + state.commentPrefix + "=" + reorderId + ">" + reorderStart + reorderHTML + "</t>";
3191
+ html += "<t hidden " + state.commentPrefix + "=" + reorderId + ">" + (reorderBranch ? state.mark("*", reorderBranch + "") : "") + reorderHTML + "</t>";
3186
3192
  }
3187
3193
  state.writeReorders = null;
3188
3194
  }
@@ -3379,11 +3385,14 @@ function _escape(val) {
3379
3385
  return val ? escapeXMLStr(val + "") : val === 0 ? "0" : "";
3380
3386
  }
3381
3387
  const unsafeScriptReg = /<(\/?script|!--)/gi;
3382
- const escapeScriptStr = (str) => unsafeScriptReg.test(str) ? str.replace(unsafeScriptReg, "\\x3C$1") : str;
3388
+ const escapeScriptStr = (str) => unsafeScriptReg.test(str) ? str.replace(unsafeScriptReg, "\\u003C$1") : str;
3383
3389
  function _escape_script(val) {
3384
3390
  assertValidTextValue(val);
3385
3391
  return val ? escapeScriptStr(val + "") : val === 0 ? "0" : "";
3386
3392
  }
3393
+ const unsafeScriptTemplateLiteralReg = /[`\\\r]|\$\{|<(?=\/?script|!--)/gi;
3394
+ const replaceUnsafeScriptTemplateLiteral = (c) => c === "<" ? "\\x3C" : c === "\r" ? "\\r" : "\\" + c;
3395
+ const quoteScriptTemplateLiteral = (str) => "`" + (unsafeScriptTemplateLiteralReg.test(str) ? str.replace(unsafeScriptTemplateLiteralReg, replaceUnsafeScriptTemplateLiteral) : str) + "`";
3387
3396
  const unsafeStyleReg = /<(\/style)/gi;
3388
3397
  const escapeStyleStr = (str) => unsafeStyleReg.test(str) ? str.replace(unsafeStyleReg, "\\3C$1") : str;
3389
3398
  function _escape_style(val) {
@@ -3406,7 +3415,7 @@ function _escape_comment(val) {
3406
3415
  //#endregion
3407
3416
  //#region src/html/dynamic-tag.ts
3408
3417
  const voidElementsReg = /^(?:area|b(?:ase|r)|col|embed|hr|i(?:mg|nput)|link|meta|param|source|track|wbr)$/;
3409
- let _dynamic_tag = (scopeId, accessor, tag, inputOrArgs, content, inputIsArgs, markerGuard) => {
3418
+ let _dynamic_tag = (scopeId, accessor, tag, inputOrArgs, content, inputIsArgs, markerGuard, tagVar) => {
3410
3419
  const shouldResume = markerGuard !== 0;
3411
3420
  const renderer = normalizeDynamicRenderer(tag);
3412
3421
  const state = getState();
@@ -3443,11 +3452,12 @@ let _dynamic_tag = (scopeId, accessor, tag, inputOrArgs, content, inputIsArgs, m
3443
3452
  renderNative();
3444
3453
  result = _el(scopeId, DYNAMIC_TAG_VAR_REGISTER_ID + accessor);
3445
3454
  } else {
3455
+ if (tagVar && renderer?.["lazy"]) throw new Error(`A dynamic tag with a [tag variable](https://markojs.com/docs/reference/language#tag-variables) rendered \`${renderer["id"]}\`, which is lazily loaded, so it does not support one. Import it without \`load\`, or remove the variable.`);
3446
3456
  const chunk = getChunk();
3447
3457
  const beforeBranch = shouldResume ? deferBranchStart(chunk) : void 0;
3448
3458
  const render = () => {
3449
3459
  if (renderer) try {
3450
- _set_scope_reason(shouldResume && inputOrArgs !== void 0 ? CLIENT_ALL : 0);
3460
+ _set_scope_reason(shouldResume ? CLIENT_ALL : 0);
3451
3461
  return inputIsArgs ? renderer(...inputOrArgs) : renderer(content ? {
3452
3462
  ...inputOrArgs,
3453
3463
  content
@@ -3455,13 +3465,14 @@ let _dynamic_tag = (scopeId, accessor, tag, inputOrArgs, content, inputIsArgs, m
3455
3465
  } finally {
3456
3466
  _set_scope_reason(void 0);
3457
3467
  }
3458
- else if (content) return content();
3468
+ else if (content) content();
3459
3469
  };
3460
3470
  result = shouldResume ? withBranchId(branchId, render) : render();
3461
3471
  rendered = _peek_scope_id() !== branchId;
3462
3472
  if (beforeBranch !== void 0) {
3463
3473
  applyBranchStart(chunk, beforeBranch, rendered);
3464
3474
  _html(state.mark("]", scopeId + " " + accessor + (rendered ? " " + branchId : "")));
3475
+ if (renderer) _existing_scope(branchId);
3465
3476
  }
3466
3477
  }
3467
3478
  if (rendered) {
@@ -3478,10 +3489,10 @@ function _content_resume(id, fn, scopeId, locals) {
3478
3489
  return _resume(_content(id, fn, scopeId), id, scopeId, locals);
3479
3490
  }
3480
3491
  const patchDynamicTag = /* @__PURE__ */ ((originalDynamicTag) => (patch) => {
3481
- _dynamic_tag = (scopeId, accessor, tag, input, content, inputIsArgs, resume) => {
3492
+ _dynamic_tag = (scopeId, accessor, tag, input, content, inputIsArgs, resume, tagVar) => {
3482
3493
  const patched = patch(tag, scopeId, accessor);
3483
3494
  if (patched !== tag) patched["id"] = tag;
3484
- return originalDynamicTag(scopeId, accessor, patched, input, content, inputIsArgs, resume);
3495
+ return originalDynamicTag(scopeId, accessor, patched, input, content, inputIsArgs, resume, tagVar);
3485
3496
  };
3486
3497
  })(_dynamic_tag);
3487
3498
  //#endregion
@@ -3754,10 +3765,13 @@ function NOOP$1() {}
3754
3765
  const kAssets = Symbol();
3755
3766
  const kHead = Symbol();
3756
3767
  function withLoadAssets(renderer, flush, assetId, triggers) {
3757
- return Object.assign((input) => {
3768
+ return register(renderer["id"], Object.assign((input) => {
3758
3769
  writeLoadAsset(assetId, flush, triggers);
3759
3770
  return writeWaitReady(assetId, renderer, input);
3760
- }, renderer);
3771
+ }, {
3772
+ ...renderer,
3773
+ [Lazy]: 1
3774
+ }));
3761
3775
  }
3762
3776
  function writeLoadAsset(assetId, flush, triggers) {
3763
3777
  const g = $global();
@@ -3806,7 +3820,7 @@ function writeAsset(g, asset) {
3806
3820
  if (g[kHead] || g.__flush__ !== flushPage) {
3807
3821
  const block = blockHTML(g, asset);
3808
3822
  _html(block + (asset.triggers ? "" : deferHTML(g, asset)));
3809
- if (block && isInResumedBranch()) writeScript(`document.head.insertAdjacentHTML("beforeend",${_escape_script(JSON.stringify(block))})`);
3823
+ if (block && isInResumedBranch()) writeScript(`document.head.insertAdjacentHTML("beforeend",${quoteScriptTemplateLiteral(block)})`);
3810
3824
  asset.htmlAt = catchableBoundary();
3811
3825
  }
3812
3826
  }
@@ -3842,8 +3856,8 @@ function addAsset(g, id, flush, triggers) {
3842
3856
  return asset;
3843
3857
  }
3844
3858
  function triggerScript(id, html, triggers) {
3845
- const htmlStr = _escape_script(JSON.stringify(html));
3846
- const insert = `(d=new Range().createContextualFragment(h),d.querySelectorAll("script").forEach(s=>s.onerror=()=>console.error(${_escape_script(JSON.stringify(`The lazy module for "${id}" failed to load; its server-rendered content cannot become interactive.`))})),document.head.append(d))`;
3859
+ const htmlStr = quoteScriptTemplateLiteral(html);
3860
+ const insert = `(d=new Range().createContextualFragment(h),d.querySelectorAll("script").forEach(s=>s.onerror=()=>console.error(${quoteScriptTemplateLiteral(`The lazy module for "${id}" failed to load; its server-rendered content cannot become interactive.`)})),document.head.append(d))`;
3847
3861
  const exprs = triggers.map((trigger) => {
3848
3862
  const options = trigger.options && toObjectExpression(trigger.options);
3849
3863
  switch (trigger.type) {