octane 0.2.2 → 0.2.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 (59) hide show
  1. package/dist/cjs/compatibility.cjs +35 -0
  2. package/dist/cjs/component-flags.cjs +8 -1
  3. package/dist/cjs/css.cjs +9 -0
  4. package/dist/cjs/dom-tables.cjs +8 -1
  5. package/dist/cjs/error-codes.client.generated.cjs +15 -2
  6. package/dist/cjs/error-codes.server.generated.cjs +5 -0
  7. package/dist/cjs/event-names.cjs +39 -0
  8. package/dist/cjs/index.cjs +13 -0
  9. package/dist/cjs/runtime.cjs +1345 -359
  10. package/dist/cjs/runtime.server.cjs +620 -183
  11. package/dist/cjs/server/index.cjs +26 -0
  12. package/dist/cjs/version.cjs +1 -1
  13. package/dist/compatibility.d.ts +7 -0
  14. package/dist/compatibility.js +10 -0
  15. package/dist/compiler/bundler.js +20 -30
  16. package/dist/compiler/compile-renderer-boundaries.js +1 -0
  17. package/dist/compiler/compile-universal.js +3 -0
  18. package/dist/compiler/compile.js +877 -627
  19. package/dist/compiler/hook-deps.js +100 -3
  20. package/dist/compiler/hook-names.js +1 -0
  21. package/dist/compiler/hydrate-boundaries.js +165 -15
  22. package/dist/compiler/manual-hooks.js +171 -0
  23. package/dist/compiler/parser.node.js +34 -8
  24. package/dist/compiler/plain-hook-memo.js +54 -5
  25. package/dist/compiler/slot-hooks.d.ts +43 -0
  26. package/dist/compiler/slot-hooks.js +154 -35
  27. package/dist/compiler/strong-mode.js +836 -3
  28. package/dist/compiler/style-scopes.js +1134 -0
  29. package/dist/compiler/volar.LICENSES.txt +1 -1
  30. package/dist/compiler/volar.js +4543 -2839
  31. package/dist/component-flags.d.ts +1 -1
  32. package/dist/component-flags.js +8 -1
  33. package/dist/css.d.ts +7 -0
  34. package/dist/css.js +8 -0
  35. package/dist/dom-tables.js +8 -1
  36. package/dist/error-codes.client.generated.d.ts +3 -1
  37. package/dist/error-codes.client.generated.js +15 -2
  38. package/dist/error-codes.server.generated.d.ts +1 -0
  39. package/dist/error-codes.server.generated.js +5 -0
  40. package/dist/event-names.d.ts +1 -0
  41. package/dist/event-names.js +15 -0
  42. package/dist/html-tree-validation.d.ts +17 -34
  43. package/dist/index.d.ts +3 -1
  44. package/dist/index.js +12 -1
  45. package/dist/jsx-runtime.d.ts +6 -1
  46. package/dist/public-types.d.ts +188 -0
  47. package/dist/public-types.js +0 -0
  48. package/dist/runtime.d.ts +128 -69
  49. package/dist/runtime.js +1349 -360
  50. package/dist/runtime.server.d.ts +67 -15
  51. package/dist/runtime.server.js +619 -184
  52. package/dist/server/index.d.ts +4 -2
  53. package/dist/server/index.js +23 -0
  54. package/dist/static/index.d.ts +2 -1
  55. package/dist/static/index.js +3 -1
  56. package/dist/universal-core.d.ts +8 -1
  57. package/dist/universal-core.js +95 -9
  58. package/dist/version.js +1 -1
  59. package/package.json +4 -3
@@ -52,11 +52,14 @@ __export(runtime_server_exports, {
52
52
  getSsrSuspenseTimeout: () => getSsrSuspenseTimeout,
53
53
  hookSlots: () => hookSlots,
54
54
  injectStyle: () => injectStyle,
55
+ invokeManualHook: () => invokeManualHook,
55
56
  isChildrenBlock: () => isChildrenBlock,
56
57
  isValidElement: () => isValidElement,
57
58
  lazy: () => lazy,
59
+ manualHook: () => manualHook,
58
60
  mapSlot: () => mapSlot,
59
61
  markChildrenBlock: () => markChildrenBlock,
62
+ markWarm: () => markWarm,
60
63
  memo: () => memo,
61
64
  namespaceHead: () => namespaceHead,
62
65
  namespaceHeadElement: () => namespaceHeadElement,
@@ -92,7 +95,9 @@ __export(runtime_server_exports, {
92
95
  ssrBlock: () => ssrBlock,
93
96
  ssrCheckedAttr: () => ssrCheckedAttr,
94
97
  ssrChild: () => ssrChild,
98
+ ssrChildPre: () => ssrChildPre,
95
99
  ssrChildText: () => ssrChildText,
100
+ ssrChildTextPre: () => ssrChildTextPre,
96
101
  ssrChildrenSources: () => ssrChildrenSources,
97
102
  ssrClass: () => ssrClass,
98
103
  ssrComponent: () => ssrComponent,
@@ -103,6 +108,7 @@ __export(runtime_server_exports, {
103
108
  ssrFormAuthoringDiagnostics: () => ssrFormAuthoringDiagnostics,
104
109
  ssrFragmentMarker: () => ssrFragmentMarker,
105
110
  ssrHeadEl: () => ssrHeadEl,
111
+ ssrHtml: () => ssrHtml,
106
112
  ssrInNamespace: () => ssrInNamespace,
107
113
  ssrInnerHtml: () => ssrInnerHtml,
108
114
  ssrInputAttrs: () => ssrInputAttrs,
@@ -130,6 +136,8 @@ __export(runtime_server_exports, {
130
136
  ssrValueAttr: () => ssrValueAttr,
131
137
  ssrVoidContent: () => ssrVoidContent,
132
138
  startTransition: () => startTransition,
139
+ styleMap: () => styleMap,
140
+ touchStyleMap: () => touchStyleMap,
133
141
  use: () => use,
134
142
  useActionState: () => useActionState,
135
143
  useCallback: () => useCallback,
@@ -603,7 +611,9 @@ function fragmentRefDescriptor(value) {
603
611
  };
604
612
  }
605
613
  function renderFragmentRefDescriptor(descriptor, scope) {
606
- return ssrFragmentMarker(true, descriptor.ref) + ssrChild(descriptor.children, scope) + ssrFragmentMarker(false);
614
+ return ssrHtml(
615
+ ssrFragmentMarker(true, descriptor.ref) + ssrChild(descriptor.children, scope) + ssrFragmentMarker(false)
616
+ );
607
617
  }
608
618
  function ssrDeoptWrapperKind(value) {
609
619
  return POSITIONAL_CHILDREN.has(value) ? "fragment" : "array";
@@ -900,9 +910,29 @@ const Children = {
900
910
  }
901
911
  };
902
912
  function createPortal(body, target, props = void 0) {
903
- return { $$kind: PORTAL_TAG, body, target, props };
913
+ const key = typeof props === "string" || typeof props === "number" ? String(props) : null;
914
+ return { $$kind: PORTAL_TAG, body, target, key, props: key === null ? props : void 0 };
904
915
  }
905
916
  const HTML_ESCAPE_RE = /[&<>]/g;
917
+ const SERVER_HTML = /* @__PURE__ */ Symbol.for("octane.serverHtml");
918
+ class ServerHtml {
919
+ [SERVER_HTML];
920
+ constructor(html) {
921
+ this[SERVER_HTML] = html;
922
+ }
923
+ toString() {
924
+ return this[SERVER_HTML];
925
+ }
926
+ }
927
+ function ssrHtml(html) {
928
+ return typeof html === "string" ? new ServerHtml(html) : html;
929
+ }
930
+ function serverComponentOutput(out, scope) {
931
+ if (out == null) return "";
932
+ if (typeof out === "string") return escapeHtml(out);
933
+ if (typeof out === "object" && SERVER_HTML in out) return out[SERVER_HTML];
934
+ return ssrChild(out, scope);
935
+ }
906
936
  function escapeHtml(v) {
907
937
  const s = typeof v === "string" ? v : String(v);
908
938
  HTML_ESCAPE_RE.lastIndex = 0;
@@ -947,6 +977,9 @@ function ssrChild(v, scope) {
947
977
  return ssrChildValue(v, scope, true);
948
978
  }
949
979
  function ssrChildValue(v, scope, includeKeyedSingle, selfMarkItem = false) {
980
+ if (v !== null && typeof v === "object" && SERVER_HTML in v) {
981
+ return v[SERVER_HTML];
982
+ }
950
983
  if (v == null || v === false || v === true) return ssrBlock("");
951
984
  if ((typeof v === "object" || typeof v === "function") && (v.$$kind === CONTEXT_TAG || typeof v.then === "function")) {
952
985
  return ssrChildValue(
@@ -998,6 +1031,14 @@ function ssrChildText(v, scope) {
998
1031
  if (typeof v === "object" || typeof v === "function") return ssrChild(v, scope);
999
1032
  return escapeHtml(v);
1000
1033
  }
1034
+ function ssrChildTextPre(v, scope) {
1035
+ const content = ssrChildText(v, scope);
1036
+ return content.charCodeAt(0) === 10 ? "\n" + content : content;
1037
+ }
1038
+ function ssrChildPre(v, scope) {
1039
+ const content = ssrChild(v, scope);
1040
+ return content.charCodeAt(0) === 10 ? "\n" + content : content;
1041
+ }
1001
1042
  function ssrHostElement(tag, props, children, scope, rawInner) {
1002
1043
  if (!VALID_TAG_NAME.test(tag)) {
1003
1044
  throw new Error((0, import_error_codes_server_generated.formatServerError)(30, tag));
@@ -1072,9 +1113,9 @@ function ssrHostElement(tag, props, children, scope, rawInner) {
1072
1113
  } else if (rawInner !== void 0) {
1073
1114
  inner = rawInner;
1074
1115
  } else if (hasChildren) {
1075
- const scriptText = semanticTag === "script" ? scriptDescriptorText(children) : null;
1076
- if (scriptText !== null) {
1077
- inner = escapeEntireInlineScriptContent(scriptText);
1116
+ const rawText = semanticTag === "script" || semanticTag === "style" ? scriptDescriptorText(children) : null;
1117
+ if (rawText !== null) {
1118
+ inner = semanticTag === "script" ? escapeEntireInlineScriptContent(rawText) : escapeEntireInlineStyleContent(rawText);
1078
1119
  } else {
1079
1120
  const build = () => ssrInNamespace(
1080
1121
  childrenNamespace,
@@ -1090,6 +1131,9 @@ function ssrHostElement(tag, props, children, scope, rawInner) {
1090
1131
  inner
1091
1132
  );
1092
1133
  }
1134
+ if ((semanticTag === "pre" || semanticTag === "textarea" || semanticTag === "listing") && inner.charCodeAt(0) === 10) {
1135
+ inner = "\n" + inner;
1136
+ }
1093
1137
  return "<" + tag + attrs + ">" + inner + "</" + tag + ">";
1094
1138
  } finally {
1095
1139
  CURRENT_SSR_ELEMENT = parentElement;
@@ -1116,6 +1160,7 @@ function ssrDeoptBlockChildren(children, scope) {
1116
1160
  }
1117
1161
  function serverDescNeedsBlocks(v) {
1118
1162
  if (v == null || typeof v !== "object") return false;
1163
+ if (v.$$kind === CONTEXT_TAG || typeof v.then === "function") return true;
1119
1164
  if (Array.isArray(v)) {
1120
1165
  for (let i = 0; i < v.length; i++) if (serverDescNeedsBlocks(v[i])) return true;
1121
1166
  return false;
@@ -1160,6 +1205,7 @@ function ssrDeoptItemContent(value, scope) {
1160
1205
  }
1161
1206
  function ssrDescriptorContent(v, scope) {
1162
1207
  if (v == null || v === false || v === true || v === "") return "";
1208
+ if (typeof v === "object" && SERVER_HTML in v) return v[SERVER_HTML];
1163
1209
  if (Array.isArray(v)) {
1164
1210
  let out = "";
1165
1211
  for (let i = 0; i < v.length; i++) out += ssrDescriptorContent(v[i], scope);
@@ -1177,7 +1223,7 @@ function ssrDescriptorContent(v, scope) {
1177
1223
  return escapeHtml(v);
1178
1224
  }
1179
1225
  function ssrBlock(content) {
1180
- return MARKERS ? import_constants.BLOCK_OPEN + content + import_constants.BLOCK_CLOSE : content;
1226
+ return MARKERS ? import_constants.BLOCK_OPEN + content + import_constants.BLOCK_CLOSE : String(content);
1181
1227
  }
1182
1228
  function ssrFragmentMarker(open, _ref) {
1183
1229
  return MARKERS ? open ? "<!--frag-->" : "<!--/frag-->" : "";
@@ -1186,10 +1232,10 @@ function ssrActivity(mode, render) {
1186
1232
  return ssrBlock(mode === "hidden" ? "" : render());
1187
1233
  }
1188
1234
  function renderActivityDescriptor(props, scope) {
1189
- return ssrActivity(props.mode ?? "visible", () => ssrChild(props.children, scope));
1235
+ return ssrHtml(ssrActivity(props.mode ?? "visible", () => ssrChild(props.children, scope)));
1190
1236
  }
1191
1237
  function ssrForBlock(content, hasItems) {
1192
- return MARKERS ? (hasItems ? import_constants.FOR_BLOCK_OPEN_ITEMS : import_constants.FOR_BLOCK_OPEN_EMPTY) + content + import_constants.BLOCK_CLOSE : content;
1238
+ return MARKERS ? (hasItems ? import_constants.FOR_BLOCK_OPEN_ITEMS : import_constants.FOR_BLOCK_OPEN_EMPTY) + content + import_constants.BLOCK_CLOSE : String(content);
1193
1239
  }
1194
1240
  const ASCII_ASYNC_IDENTITY_UNITS = [];
1195
1241
  for (let code = 0; code < 128; code++) {
@@ -1370,10 +1416,10 @@ function ssrAttr(name, v, tag, namespace = "html") {
1370
1416
  return ' class="' + escapeAttr((0, import_css.normalizeClass)(v)) + '"';
1371
1417
  }
1372
1418
  if (name.charCodeAt(0) === 97 && name.startsWith("aria-")) {
1373
- if (v == null) return "";
1419
+ if (v == null || typeof v === "function" || typeof v === "symbol") return "";
1374
1420
  return " " + name + '="' + escapeAttr(String(v)) + '"';
1375
1421
  }
1376
- if (name === "suppressContentEditableWarning" || name === "suppressHydrationWarning" || name === "suppressNativeChangeWarning" || name === "__octaneNativeChangeDiagnostic")
1422
+ if (name === "innerText" || name === "textContent" || name === "suppressContentEditableWarning" || name === "suppressHydrationWarning" || name === "suppressNativeChangeWarning" || name === "__octaneNativeChangeDiagnostic")
1377
1423
  return "";
1378
1424
  const t = typeof v;
1379
1425
  if (t === "boolean" && (0, import_constants.isEnumeratedBooleanAttr)(name)) {
@@ -1429,6 +1475,7 @@ function ssrAttr(name, v, tag, namespace = "html") {
1429
1475
  return "";
1430
1476
  }
1431
1477
  if (import_constants.POSITIVE_NUMERIC_ATTR_PROPS.has(lower) && !(Number(v) >= 1)) return "";
1478
+ if ((lower === "rowspan" || lower === "start") && Number.isNaN(Number(v))) return "";
1432
1479
  }
1433
1480
  if (v == null || v === false) return "";
1434
1481
  if (process.env.NODE_ENV !== "production" && !isCustomTag && tag !== void 0 && t === "object" && v.toString === Object.prototype.toString) {
@@ -1520,8 +1567,9 @@ function isAggregatedFormAttribute(tag, name) {
1520
1567
  function ssrAttrs(sources, tag, namespace = "html", skipFormControls = false) {
1521
1568
  namespace = resolveAttributeNamespace(namespace);
1522
1569
  const props = /* @__PURE__ */ new Map();
1570
+ let classMerges = null;
1523
1571
  let sourceOrder = 0;
1524
- const record = (rawName, value) => {
1572
+ function record(rawName, value) {
1525
1573
  if (typeof rawName !== "string") return;
1526
1574
  const order = sourceOrder++;
1527
1575
  const previous = props.get(rawName);
@@ -1531,9 +1579,17 @@ function ssrAttrs(sources, tag, namespace = "html", skipFormControls = false) {
1531
1579
  firstOrder: previous?.firstOrder ?? order,
1532
1580
  lastOrder: order
1533
1581
  });
1534
- };
1535
- for (const [isSpread, sourceOrName, directValue] of sources) {
1582
+ }
1583
+ for (const [isSpread, sourceOrName, directValue, merge] of sources) {
1536
1584
  if (!isSpread) {
1585
+ if (merge === true && typeof sourceOrName === "string" && (sourceOrName === "class" || sourceOrName === "className")) {
1586
+ (classMerges ??= []).push({
1587
+ rawName: sourceOrName,
1588
+ value: directValue,
1589
+ order: sourceOrder++
1590
+ });
1591
+ continue;
1592
+ }
1537
1593
  record(sourceOrName, directValue);
1538
1594
  continue;
1539
1595
  }
@@ -1545,6 +1601,24 @@ function ssrAttrs(sources, tag, namespace = "html", skipFormControls = false) {
1545
1601
  record(name, source[name]);
1546
1602
  }
1547
1603
  }
1604
+ if (process.env.NODE_ENV === "production") {
1605
+ let canonical = true;
1606
+ for (const name of props.keys()) {
1607
+ if (normalizeSsrAttributeName(name, tag, namespace) !== name || namespace === "html" && name.toLowerCase() !== name) {
1608
+ canonical = false;
1609
+ break;
1610
+ }
1611
+ }
1612
+ if (canonical) {
1613
+ let out2 = "";
1614
+ for (const { rawName, value } of props.values()) {
1615
+ if (rawName === "dangerouslySetInnerHTML" || skipFormControls && isAggregatedFormAttribute(tag, rawName))
1616
+ continue;
1617
+ out2 += ssrAttrEntry(rawName, value, tag, namespace);
1618
+ }
1619
+ return out2;
1620
+ }
1621
+ }
1548
1622
  const resolved = /* @__PURE__ */ new Map();
1549
1623
  let needsWinningOrderSort = false;
1550
1624
  for (const writer of props.values()) {
@@ -1571,6 +1645,24 @@ function ssrAttrs(sources, tag, namespace = "html", skipFormControls = false) {
1571
1645
  lastOrder
1572
1646
  ]);
1573
1647
  }
1648
+ if (classMerges !== null) {
1649
+ for (const extra of classMerges) {
1650
+ const name = normalizeSsrAttributeName(extra.rawName, tag, namespace);
1651
+ if (!import_constants.VALID_ATTR_NAME.test(name)) continue;
1652
+ const identity = namespace === "html" ? name.toLowerCase() : name;
1653
+ const previous = resolved.get(identity);
1654
+ if (previous !== void 0) {
1655
+ resolved.set(identity, [
1656
+ previous[0],
1657
+ (0, import_css.mergeClass)(previous[1], extra.value),
1658
+ previous[2],
1659
+ extra.order
1660
+ ]);
1661
+ continue;
1662
+ }
1663
+ resolved.set(identity, [name, extra.value, extra.order, extra.order]);
1664
+ }
1665
+ }
1574
1666
  let out = "";
1575
1667
  const ordered = [...resolved.values()];
1576
1668
  if (needsWinningOrderSort) ordered.sort((a, b) => a[2] - b[2]);
@@ -1755,7 +1847,7 @@ function ssrFormAuthoringDiagnostics(tag, sources) {
1755
1847
  return "";
1756
1848
  }
1757
1849
  function ssrValueAttr(v) {
1758
- if (v == null) return "";
1850
+ if (v == null || typeof v === "function" || typeof v === "symbol") return "";
1759
1851
  return ' value="' + escapeAttr(typeof v === "string" ? v : String(v)) + '"';
1760
1852
  }
1761
1853
  function ssrCheckedAttr(v) {
@@ -2236,7 +2328,7 @@ function renderComponentFramed(comp, props, parent, frame, inherit) {
2236
2328
  ACTIVE_PU_WARM_PLANS.length = warmPlanCheckpoint;
2237
2329
  HOOK_PASS = previousHookPass;
2238
2330
  }
2239
- const inner = typeof out === "string" ? out : out == null ? "" : ssrChild(out, scope);
2331
+ const inner = serverComponentOutput(out, scope);
2240
2332
  nativeCompleted = true;
2241
2333
  return MARKERS && !inherit ? import_constants.BLOCK_OPEN + inner + import_constants.BLOCK_CLOSE : inner;
2242
2334
  } catch (error) {
@@ -2278,7 +2370,7 @@ function ssrComponent(parent, comp, props, inherit, key, identityScoped) {
2278
2370
  const kids = props?.children;
2279
2371
  if (typeof kids === "function") {
2280
2372
  const out = kids(void 0, parent);
2281
- const inner = typeof out === "string" ? out : out == null ? "" : ssrChild(out, parent);
2373
+ const inner = serverComponentOutput(out, parent);
2282
2374
  const html2 = ssrHostElement(tag, props, null, parent, inner);
2283
2375
  return inherit ? html2 : ssrBlock(html2);
2284
2376
  }
@@ -2334,7 +2426,8 @@ function ssrInNamespace(namespace, render) {
2334
2426
  }
2335
2427
  }
2336
2428
  function ssrChildrenHtml(children, scope) {
2337
- if (typeof children === "function") return children(void 0, scope) ?? "";
2429
+ if (typeof children === "function")
2430
+ return serverComponentOutput(children(void 0, scope), scope);
2338
2431
  return ssrChild(children, scope);
2339
2432
  }
2340
2433
  function streamTokenForPendingHtml(html) {
@@ -2368,7 +2461,8 @@ const PermanentStaticHydrate = /* @__PURE__ */ (0, import_component_flags.markCo
2368
2461
  if (nativeCapture < 0) NATIVE_SERVER_READS = null;
2369
2462
  PERMANENT_STATIC_HYDRATE_DEPTH++;
2370
2463
  try {
2371
- if (inheritedPermanentStatic || !MARKERS) return ssrChildrenHtml(props.children, scope);
2464
+ if (inheritedPermanentStatic || !MARKERS)
2465
+ return ssrHtml(ssrChildrenHtml(props.children, scope));
2372
2466
  const childIdStart = ID_COUNTER;
2373
2467
  const serialStart = SERIAL?.length ?? 0;
2374
2468
  const children = ssrBlock(
@@ -2385,7 +2479,9 @@ const PermanentStaticHydrate = /* @__PURE__ */ (0, import_component_flags.markCo
2385
2479
  const streamToken = streamTokenForPendingHtml(children);
2386
2480
  const markerToken = streamToken === null ? "" : streamToken + ":";
2387
2481
  const endToken = streamToken === null ? "" : ":" + streamToken;
2388
- return `<!--${import_constants.HYDRATE_STATIC_ID_COUNT_PREFIX}${markerToken}${idCount}-->` + children + `<!--${import_constants.HYDRATE_STATIC_END}${endToken}-->`;
2482
+ return ssrHtml(
2483
+ `<!--${import_constants.HYDRATE_STATIC_ID_COUNT_PREFIX}${markerToken}${idCount}-->` + children + `<!--${import_constants.HYDRATE_STATIC_END}${endToken}-->`
2484
+ );
2389
2485
  } finally {
2390
2486
  finishNativeSeedCapture(nativeCapture, previousNativeReads, false);
2391
2487
  PERMANENT_STATIC_HYDRATE_DEPTH--;
@@ -2397,51 +2493,53 @@ const PermanentStaticHydrate = /* @__PURE__ */ (0, import_component_flags.markCo
2397
2493
  const hydrate = /* @__PURE__ */ (0, import_component_flags.markComponentFlags)(
2398
2494
  function Hydrate(props, scope) {
2399
2495
  const id = useId();
2400
- return withSsrElementContext(
2401
- "div",
2402
- void 0,
2403
- () => ssrInNamespace("html", () => {
2404
- if (!MARKERS) {
2405
- return "<div>" + ssrChildrenHtml(props.children, scope) + "</div>";
2406
- }
2407
- const childIdStart = ID_COUNTER;
2408
- const serialStart = SERIAL?.length ?? 0;
2409
- const nativeCapture = NATIVE_READ_COLLECTOR?.beginCapture() ?? -1;
2410
- const previousNativeReads = NATIVE_SERVER_READS;
2411
- if (nativeCapture < 0) NATIVE_SERVER_READS = null;
2412
- let children;
2413
- let nativeReads = null;
2414
- try {
2415
- children = ssrBlock(
2416
- ssrTry(
2417
- scope,
2418
- "jsx-hydrate",
2419
- (_arg, childScope) => ssrChildrenHtml(props.children, childScope),
2420
- null,
2421
- null,
2422
- "html"
2423
- )
2496
+ return ssrHtml(
2497
+ withSsrElementContext(
2498
+ "div",
2499
+ void 0,
2500
+ () => ssrInNamespace("html", () => {
2501
+ if (!MARKERS) {
2502
+ return "<div>" + ssrChildrenHtml(props.children, scope) + "</div>";
2503
+ }
2504
+ const childIdStart = ID_COUNTER;
2505
+ const serialStart = SERIAL?.length ?? 0;
2506
+ const nativeCapture = NATIVE_READ_COLLECTOR?.beginCapture() ?? -1;
2507
+ const previousNativeReads = NATIVE_SERVER_READS;
2508
+ if (nativeCapture < 0) NATIVE_SERVER_READS = null;
2509
+ let children;
2510
+ let nativeReads = null;
2511
+ try {
2512
+ children = ssrBlock(
2513
+ ssrTry(
2514
+ scope,
2515
+ "jsx-hydrate",
2516
+ (_arg, childScope) => ssrChildrenHtml(props.children, childScope),
2517
+ null,
2518
+ null,
2519
+ "html"
2520
+ )
2521
+ );
2522
+ } finally {
2523
+ nativeReads = finishNativeSeedCapture(nativeCapture, previousNativeReads, false);
2524
+ }
2525
+ const idCount = ID_COUNTER - childIdStart;
2526
+ const childSeeds = SERIAL === null ? [] : SERIAL.splice(serialStart);
2527
+ const permanentStaticAncestor = PERMANENT_STATIC_HYDRATE_DEPTH !== 0;
2528
+ const attrs = ssrHydrateAttrs(
2529
+ id,
2530
+ props.when,
2531
+ idCount,
2532
+ permanentStaticAncestor,
2533
+ streamTokenForPendingHtml(children)
2424
2534
  );
2425
- } finally {
2426
- nativeReads = finishNativeSeedCapture(nativeCapture, previousNativeReads, false);
2427
- }
2428
- const idCount = ID_COUNTER - childIdStart;
2429
- const childSeeds = SERIAL === null ? [] : SERIAL.splice(serialStart);
2430
- const permanentStaticAncestor = PERMANENT_STATIC_HYDRATE_DEPTH !== 0;
2431
- const attrs = ssrHydrateAttrs(
2432
- id,
2433
- props.when,
2434
- idCount,
2435
- permanentStaticAncestor,
2436
- streamTokenForPendingHtml(children)
2437
- );
2438
- const seedJson = permanentStaticAncestor || childSeeds.length === 0 ? null : serializeSuspenseSeedJson(childSeeds);
2439
- const seedSidecar = seedJson === null || seedJson === "[]" ? "" : '<script type="application/json" ' + import_constants.HYDRATE_SEED_ATTR + NONCE_ATTR + ">" + seedJson + "</script>";
2440
- const nativeSeeds = permanentStaticAncestor ? void 0 : NATIVE_READ_COLLECTOR?.serialize(nativeReads);
2441
- const nativeSidecar = nativeSeeds === void 0 ? "" : serializeNativeSignalSeeds(nativeSeeds, NONCE_ATTR);
2442
- return "<div" + attrs + ">" + children + seedSidecar + nativeSidecar + "</div>";
2443
- }),
2444
- "html"
2535
+ const seedJson = permanentStaticAncestor || childSeeds.length === 0 ? null : serializeSuspenseSeedJson(childSeeds);
2536
+ const seedSidecar = seedJson === null || seedJson === "[]" ? "" : '<script type="application/json" ' + import_constants.HYDRATE_SEED_ATTR + NONCE_ATTR + ">" + seedJson + "</script>";
2537
+ const nativeSeeds = permanentStaticAncestor ? void 0 : NATIVE_READ_COLLECTOR?.serialize(nativeReads);
2538
+ const nativeSidecar = nativeSeeds === void 0 ? "" : serializeNativeSignalSeeds(nativeSeeds, NONCE_ATTR);
2539
+ return "<div" + attrs + ">" + children + seedSidecar + nativeSidecar + "</div>";
2540
+ }),
2541
+ "html"
2542
+ )
2445
2543
  );
2446
2544
  },
2447
2545
  import_component_flags.COMPONENT_FLAG_BOUNDARY,
@@ -2454,17 +2552,22 @@ function initializeHydrateComponent() {
2454
2552
  const Hydrate2 = /* @__PURE__ */ initializeHydrateComponent();
2455
2553
  const Suspense = /* @__PURE__ */ (0, import_component_flags.markComponentFlags)(
2456
2554
  function Suspense2(props, scope) {
2457
- return ssrTry(
2458
- scope,
2459
- "jsx-suspense",
2460
- (_arg, s) => ssrChildrenHtml(props.children, s),
2461
- (_arg, s) => ssrChild(props.fallback, s),
2462
- null,
2463
- FRAME?.namespace ?? "html"
2555
+ return ssrHtml(
2556
+ ssrTry(
2557
+ scope,
2558
+ "jsx-suspense",
2559
+ (_arg, s) => ssrChildrenHtml(props.children, s),
2560
+ (_arg, s) => ssrChild(props.fallback, s),
2561
+ null,
2562
+ FRAME?.namespace ?? "html",
2563
+ false,
2564
+ true
2565
+ )
2464
2566
  );
2465
2567
  },
2466
2568
  import_component_flags.COMPONENT_FLAG_BOUNDARY,
2467
- "Suspense"
2569
+ "Suspense",
2570
+ /* @__PURE__ */ Symbol.for("octane.suspense")
2468
2571
  );
2469
2572
  let VT_SSR_TRY_SEQ = 0;
2470
2573
  let VT_SSR_HAS_CANDIDATES = false;
@@ -2577,7 +2680,7 @@ const ViewTransition = /* @__PURE__ */ (0, import_component_flags.markComponentF
2577
2680
  attrs.push(["vt-enter-x", vtSsrResolve(props, "enter")]);
2578
2681
  attrs.push(["vt-exit-x", vtSsrResolve(props, "exit")]);
2579
2682
  if (named) attrs.push(["vt-share", cand.share]);
2580
- return ssrBlock(vtSsrAnnotate(inner, attrs));
2683
+ return ssrHtml(ssrBlock(vtSsrAnnotate(inner, attrs)));
2581
2684
  },
2582
2685
  import_component_flags.COMPONENT_FLAG_BOUNDARY,
2583
2686
  "ViewTransition"
@@ -2586,21 +2689,27 @@ function addTransitionType(_type) {
2586
2689
  }
2587
2690
  const ErrorBoundary = /* @__PURE__ */ (0, import_component_flags.markComponentFlags)(
2588
2691
  function ErrorBoundary2(props, scope) {
2589
- return ssrBlock(
2590
- (() => {
2591
- try {
2592
- return withAsyncIdentity(
2593
- "error-boundary",
2594
- "content",
2595
- () => ssrBlock(ssrChildrenHtml(props.children, scope))
2596
- );
2597
- } catch (e) {
2598
- e = normalizeThrownServerThenable(e);
2599
- if (ssrIsSuspense(e)) throw e;
2600
- const fb = typeof props.fallback === "function" ? props.fallback(e, NOOP) : props.fallback;
2601
- return withAsyncIdentity("error-boundary", "catch", () => ssrBlock(ssrChild(fb, scope)));
2602
- }
2603
- })()
2692
+ return ssrHtml(
2693
+ ssrBlock(
2694
+ (() => {
2695
+ try {
2696
+ return withAsyncIdentity(
2697
+ "error-boundary",
2698
+ "content",
2699
+ () => ssrBlock(ssrChildrenHtml(props.children, scope))
2700
+ );
2701
+ } catch (e) {
2702
+ e = normalizeThrownServerThenable(e);
2703
+ if (ssrIsSuspense(e)) throw e;
2704
+ const fb = typeof props.fallback === "function" ? props.fallback(e, NOOP) : props.fallback;
2705
+ return withAsyncIdentity(
2706
+ "error-boundary",
2707
+ "catch",
2708
+ () => ssrBlock(ssrChild(fb, scope))
2709
+ );
2710
+ }
2711
+ })()
2712
+ )
2604
2713
  );
2605
2714
  },
2606
2715
  import_component_flags.COMPONENT_FLAG_BOUNDARY,
@@ -2609,7 +2718,7 @@ const ErrorBoundary = /* @__PURE__ */ (0, import_component_flags.markComponentFl
2609
2718
  const CONTEXT_TAG = /* @__PURE__ */ Symbol.for("octane.context");
2610
2719
  function createContext(defaultValue) {
2611
2720
  const ctx = function ProviderBody(props, scope) {
2612
- return renderServerContextProvider(ctx, props, scope);
2721
+ return ssrHtml(renderServerContextProvider(ctx, props, scope));
2613
2722
  };
2614
2723
  ctx.$$kind = CONTEXT_TAG;
2615
2724
  ctx.defaultValue = defaultValue;
@@ -2637,7 +2746,7 @@ function renderServerContextProvider(context, props, renderScope) {
2637
2746
  scope.$$ctxValues.set(context, props.value);
2638
2747
  const children = props.children;
2639
2748
  if (children == null) return "";
2640
- return typeof children === "function" ? children(void 0, scope) ?? "" : ssrChild(children, scope);
2749
+ return ssrHtml(ssrChildrenHtml(children, scope));
2641
2750
  }
2642
2751
  function readContext(ctx) {
2643
2752
  for (let s = CURRENT_SCOPE; s !== null; s = s.parent) {
@@ -2832,6 +2941,11 @@ function hasExternalHydrationOwner(thenable) {
2832
2941
  }
2833
2942
  }
2834
2943
  function use(usable, siteKey, directSite) {
2944
+ if (process.env.NODE_ENV !== "production" && devMemoComputeDepth !== 0) {
2945
+ console.error(
2946
+ "Do not call use() inside a useMemo() factory. Cached factories can skip context or promise reads; call use() before useMemo() and memoize the returned value instead."
2947
+ );
2948
+ }
2835
2949
  if (usable && usable.$$kind === CONTEXT_TAG) {
2836
2950
  recordSkippedHydrationSite(SERIAL, directSite);
2837
2951
  return readContext(usable);
@@ -3214,18 +3328,21 @@ function resolveLazyModule(mod) {
3214
3328
  }
3215
3329
  return comp;
3216
3330
  }
3217
- function callLazyComponent(mod, props, scope, extra) {
3218
- const comp = resolveLazyModule(mod);
3219
- return comp((0, import_shared_value_helpers.resolveLazyDefaultProps)(comp, props), scope, extra);
3220
- }
3221
3331
  function lazy(load) {
3222
3332
  let status = "uninitialized";
3223
3333
  let result = null;
3224
3334
  let promise = null;
3225
3335
  const key = "|lazy#" + LAZY_ID++;
3336
+ let displayName;
3337
+ let resolvedName = "Lazy";
3338
+ const callResolved = (props, scope, extra) => {
3339
+ const comp = resolveLazyModule(result);
3340
+ resolvedName = comp.displayName || comp.name || "Lazy";
3341
+ return comp((0, import_shared_value_helpers.resolveLazyDefaultProps)(comp, props), scope, extra);
3342
+ };
3226
3343
  const lazyWrapper = (props, scope, extra) => {
3227
3344
  if (status === "fulfilled") {
3228
- return callLazyComponent(result, props, scope, extra);
3345
+ return callResolved(props, scope, extra);
3229
3346
  }
3230
3347
  if (status === "rejected") throw result;
3231
3348
  if (status === "uninitialized") {
@@ -3253,7 +3370,7 @@ function lazy(load) {
3253
3370
  if (status === "uninitialized") status = "pending";
3254
3371
  const settledStatus = status;
3255
3372
  if (settledStatus === "fulfilled") {
3256
- return callLazyComponent(result, props, scope, extra);
3373
+ return callResolved(props, scope, extra);
3257
3374
  }
3258
3375
  if (settledStatus === "rejected") throw result;
3259
3376
  }
@@ -3270,11 +3387,22 @@ function lazy(load) {
3270
3387
  }
3271
3388
  throw SSR_SUSPENSE;
3272
3389
  };
3273
- Object.defineProperty(lazyWrapper, LAZY_COMPONENT, { value: true });
3390
+ Object.defineProperty(lazyWrapper, LAZY_COMPONENT, {
3391
+ get() {
3392
+ return this === lazyWrapper;
3393
+ }
3394
+ });
3395
+ Object.defineProperty(lazyWrapper, "displayName", {
3396
+ configurable: true,
3397
+ get: () => displayName ?? resolvedName,
3398
+ set: (value) => {
3399
+ displayName = value;
3400
+ }
3401
+ });
3274
3402
  return lazyWrapper;
3275
3403
  }
3276
3404
  function useState(initial, slot) {
3277
- if (slot === void 0 && typeof initial === "symbol") {
3405
+ if (slot === void 0 && typeof initial === "symbol" && arguments.length === 1 && (HOOK_SLOT_PATH.length === 0 || MANUAL_HOOK_DRIVER?.active === true)) {
3278
3406
  slot = initial;
3279
3407
  initial = void 0;
3280
3408
  }
@@ -3285,7 +3413,7 @@ function useState(initial, slot) {
3285
3413
  );
3286
3414
  }
3287
3415
  function __useStateWithGetter(initial, slot) {
3288
- if (slot === void 0 && typeof initial === "symbol") {
3416
+ if (slot === void 0 && typeof initial === "symbol" && arguments.length === 1 && (HOOK_SLOT_PATH.length === 0 || MANUAL_HOOK_DRIVER?.active === true)) {
3289
3417
  slot = initial;
3290
3418
  initial = void 0;
3291
3419
  }
@@ -3377,30 +3505,43 @@ const useLayoutEffect = useEffect;
3377
3505
  const useInsertionEffect = useEffect;
3378
3506
  function useImperativeHandle() {
3379
3507
  }
3508
+ let devMemoComputeDepth = 0;
3380
3509
  function memoHookValue(input, compute, depsOrSlot, maybeSlot) {
3381
3510
  const deps = Array.isArray(depsOrSlot) ? depsOrSlot : null;
3382
3511
  const slot = maybeSlot ?? (Array.isArray(depsOrSlot) || depsOrSlot === null ? void 0 : depsOrSlot);
3383
3512
  if (deps === null) return compute ? input() : input;
3384
3513
  const position = hookPosition(slot);
3385
- if (position === null) return compute ? input() : input;
3514
+ if (position === null)
3515
+ return compute ? input(...deps) : input;
3386
3516
  let rec = position.list[position.index];
3387
3517
  if (rec === void 0) {
3388
- rec = { value: compute ? input() : input, deps: deps.slice() };
3518
+ rec = {
3519
+ value: compute ? input(...deps) : input,
3520
+ deps: deps.slice()
3521
+ };
3389
3522
  position.list[position.index] = rec;
3390
3523
  } else if (!serverDepsEqual(rec.deps, deps)) {
3391
- rec.value = compute ? input() : input;
3524
+ rec.value = compute ? input(...deps) : input;
3392
3525
  rec.deps = deps.slice();
3393
3526
  }
3394
3527
  return rec.value;
3395
3528
  }
3396
3529
  function useMemo(compute, depsOrSlot, maybeSlot) {
3530
+ if (process.env.NODE_ENV !== "production") {
3531
+ devMemoComputeDepth++;
3532
+ try {
3533
+ return memoHookValue(compute, true, depsOrSlot, maybeSlot);
3534
+ } finally {
3535
+ devMemoComputeDepth--;
3536
+ }
3537
+ }
3397
3538
  return memoHookValue(compute, true, depsOrSlot, maybeSlot);
3398
3539
  }
3399
3540
  function useCallback(fn, depsOrSlot, maybeSlot) {
3400
3541
  return memoHookValue(fn, false, depsOrSlot, maybeSlot);
3401
3542
  }
3402
3543
  function useRef(initial, slot) {
3403
- if (slot === void 0 && typeof initial === "symbol") {
3544
+ if (slot === void 0 && typeof initial === "symbol" && arguments.length === 1 && (HOOK_SLOT_PATH.length === 0 || MANUAL_HOOK_DRIVER?.active === true)) {
3404
3545
  slot = initial;
3405
3546
  initial = void 0;
3406
3547
  }
@@ -3440,20 +3581,102 @@ function useActionState(_action, initialState) {
3440
3581
  return [initialState, NOOP, false];
3441
3582
  }
3442
3583
  function useFormStatus() {
3443
- return { pending: false, data: null, method: "get", action: null };
3584
+ return { pending: false, data: null, method: null, action: null };
3444
3585
  }
3445
3586
  function useOptimistic(state) {
3446
3587
  return [state, NOOP];
3447
3588
  }
3448
3589
  function memo(component) {
3590
+ const memoWrapper = (props, scope, extra) => component(props, scope, extra);
3591
+ Object.defineProperty(memoWrapper, "type", { value: component });
3592
+ Object.defineProperty(memoWrapper, "displayName", {
3593
+ configurable: true,
3594
+ writable: true,
3595
+ value: component.displayName || component.name || "Memo"
3596
+ });
3597
+ Object.defineProperty(memoWrapper, "__memo", {
3598
+ get() {
3599
+ return this === memoWrapper;
3600
+ }
3601
+ });
3602
+ Object.defineProperty(memoWrapper, "defaultProps", {
3603
+ configurable: true,
3604
+ get: () => component.defaultProps,
3605
+ set: (value) => {
3606
+ component.defaultProps = value;
3607
+ }
3608
+ });
3609
+ return memoWrapper;
3610
+ }
3611
+ function markWarm(component, plan) {
3612
+ Object.defineProperty(component, "__warm", {
3613
+ configurable: true,
3614
+ get() {
3615
+ return this === component ? plan : void 0;
3616
+ }
3617
+ });
3449
3618
  return component;
3450
3619
  }
3620
+ let MANUAL_HOOK_DRIVER = null;
3621
+ function invokeManualHook(fn, receiver, args) {
3622
+ const driver = MANUAL_HOOK_DRIVER ??= {
3623
+ pending: HOOK_SLOT_PATH[HOOK_SLOT_PATH.length - 1],
3624
+ active: false
3625
+ };
3626
+ const pending = driver.pending;
3627
+ const active = driver.active;
3628
+ driver.pending = void 0;
3629
+ driver.active = true;
3630
+ try {
3631
+ if (pending === void 0) return Reflect.apply(fn, receiver, args);
3632
+ switch (args.length) {
3633
+ case 0:
3634
+ return fn.call(receiver, pending);
3635
+ case 1:
3636
+ return fn.call(receiver, args[0], pending);
3637
+ case 2:
3638
+ return fn.call(receiver, args[0], args[1], pending);
3639
+ case 3:
3640
+ return fn.call(receiver, args[0], args[1], args[2], pending);
3641
+ case 4:
3642
+ return fn.call(receiver, args[0], args[1], args[2], args[3], pending);
3643
+ default: {
3644
+ const forwarded = new Array(args.length + 1);
3645
+ for (let index = 0; index < args.length; index++) forwarded[index] = args[index];
3646
+ forwarded[args.length] = pending;
3647
+ return fn.apply(receiver, forwarded);
3648
+ }
3649
+ }
3650
+ } finally {
3651
+ driver.pending = pending;
3652
+ driver.active = active;
3653
+ }
3654
+ }
3655
+ function manualHook(fn, name) {
3656
+ function provider() {
3657
+ return invokeManualHook(fn, this, arguments);
3658
+ }
3659
+ Object.defineProperty(provider, "name", { value: name ?? fn.name, configurable: true });
3660
+ Object.defineProperty(provider, "length", { value: fn.length, configurable: true });
3661
+ return provider;
3662
+ }
3451
3663
  function withSlot(sym, fn, ...args) {
3664
+ const driver = MANUAL_HOOK_DRIVER;
3665
+ const pending = driver?.pending;
3666
+ const active = driver?.active ?? false;
3667
+ if (driver !== null) {
3668
+ driver.pending = sym;
3669
+ driver.active = false;
3670
+ }
3452
3671
  HOOK_SLOT_PATH.push(sym);
3453
3672
  try {
3454
3673
  return fn(...args);
3455
3674
  } finally {
3456
3675
  HOOK_SLOT_PATH.pop();
3676
+ if (MANUAL_HOOK_DRIVER !== null) {
3677
+ MANUAL_HOOK_DRIVER.pending = driver === null ? HOOK_SLOT_PATH[HOOK_SLOT_PATH.length - 1] : pending;
3678
+ MANUAL_HOOK_DRIVER.active = active;
3679
+ }
3457
3680
  }
3458
3681
  }
3459
3682
  function startTransition(fn) {
@@ -3478,6 +3701,28 @@ function isChildrenBlock(value) {
3478
3701
  function injectStyle(id, css, nonce) {
3479
3702
  if (CSS !== null) CSS.set(id, nonce === void 0 ? { css } : { css, nonce });
3480
3703
  }
3704
+ function styleMap(id, css, map, applied = []) {
3705
+ let touching = false;
3706
+ const touch = () => {
3707
+ if (CSS === null || touching) return;
3708
+ touching = true;
3709
+ try {
3710
+ for (const dependency of applied) touchStyleMap(dependency);
3711
+ if (id !== null && css !== null) injectStyle(id, css);
3712
+ } finally {
3713
+ touching = false;
3714
+ }
3715
+ };
3716
+ return new Proxy(map, {
3717
+ get(target, key, receiver) {
3718
+ touch();
3719
+ return Reflect.get(target, key, receiver);
3720
+ }
3721
+ });
3722
+ }
3723
+ function touchStyleMap(map) {
3724
+ if (map !== null && typeof map === "object") void map.$class;
3725
+ }
3481
3726
  const HEAD_VOID_ELEMENTS = /* @__PURE__ */ new Set(["meta", "link", "base"]);
3482
3727
  function ssrHeadEl(key, tag, attrs, text) {
3483
3728
  if (HEAD === null || FALLBACK_HOIST_DEPTH !== 0) return "";
@@ -3530,11 +3775,20 @@ function namespaceHeadElement(headKey, tag, attrs, text, authoredKey) {
3530
3775
  return createElement(namespaceHead, config);
3531
3776
  }
3532
3777
  function spliceHead(body, head) {
3533
- if (head === "") return body;
3778
+ if (head === "" && !isDocumentRoot(body)) return body;
3534
3779
  const headClose = body.indexOf("</head>");
3535
3780
  if (headClose !== -1) return body.slice(0, headClose) + head + body.slice(headClose);
3781
+ if (isDocumentRoot(body)) {
3782
+ const openingEnd = documentTagEnd(body, body.indexOf("<html") + 5);
3783
+ if (openingEnd !== -1)
3784
+ return body.slice(0, openingEnd) + "<head>" + head + "</head>" + body.slice(openingEnd);
3785
+ }
3786
+ if (head === "") return body;
3536
3787
  return head + body;
3537
3788
  }
3789
+ function renderEntryValue(props, scope) {
3790
+ return ssrHtml(ssrChild(props.value, scope));
3791
+ }
3538
3792
  const MAX_SUSPENSE_PASSES = 50;
3539
3793
  let SUSPENSE_TIMEOUT_MS = 1e4;
3540
3794
  function setSsrSuspenseTimeout(ms) {
@@ -3801,7 +4055,7 @@ function runFullFramedPass(component, props, resolved, nonceAttr = "", identifie
3801
4055
  const nativeToken = NATIVE_READ_COLLECTOR === null ? -1 : beginActiveNativeReadScope(root);
3802
4056
  try {
3803
4057
  const out = invokeComponentBody(component, props, root, FRAME);
3804
- body = typeof out === "string" ? out : out == null ? "" : ssrChild(out, root);
4058
+ body = serverComponentOutput(out, root);
3805
4059
  nativePassCompleted = true;
3806
4060
  } catch (err) {
3807
4061
  err = normalizeThrownServerThenable(err);
@@ -3817,6 +4071,14 @@ function runFullFramedPass(component, props, resolved, nonceAttr = "", identifie
3817
4071
  restoreAmbient(saved);
3818
4072
  }
3819
4073
  }
4074
+ if (resolved.bufferedErrors !== void 0) {
4075
+ for (const report of resolved.bufferedErrors.values()) {
4076
+ if (!report.reported) {
4077
+ report.reported = true;
4078
+ resolved.resourceOptions?.onError?.(report.error);
4079
+ }
4080
+ }
4081
+ }
3820
4082
  let css = "";
3821
4083
  for (const [hash, sheet] of cssMap) {
3822
4084
  css += '<style data-octane="' + hash + '"' + (sheet.nonce === void 0 ? nonceAttr : ' nonce="' + escapeAttr(sheet.nonce) + '"') + ">" + escapeEntireInlineStyleContent(sheet.css) + "</style>";
@@ -4094,7 +4356,11 @@ function passToResult(pass, nonceAttr, separateHead = false) {
4094
4356
  return result;
4095
4357
  }
4096
4358
  async function prerender(entryComponent, props, options) {
4097
- const component = entryComponent;
4359
+ const component = typeof entryComponent === "function" ? entryComponent : renderEntryValue;
4360
+ if (typeof entryComponent !== "function") {
4361
+ options ??= props;
4362
+ props = { value: entryComponent };
4363
+ }
4098
4364
  const nonceAttr = nonceAttrOf(options);
4099
4365
  const resolved = newResolvedMap(options ?? null);
4100
4366
  try {
@@ -4108,6 +4374,10 @@ async function prerender(entryComponent, props, options) {
4108
4374
  }
4109
4375
  }
4110
4376
  async function prerenderToNodeStream(entryComponent, props, options) {
4377
+ if (typeof entryComponent !== "function" && options === void 0) {
4378
+ options = props;
4379
+ props = void 0;
4380
+ }
4111
4381
  let resolved = options;
4112
4382
  if (options?.headChannel === "separate") {
4113
4383
  if (process.env.NODE_ENV !== "production") {
@@ -4192,7 +4462,11 @@ function renderHostedAttempt(session, component, props, options) {
4192
4462
  return { status: "complete", html: body, head: pass.head, cssEntries: pass.cssEntries };
4193
4463
  }
4194
4464
  function renderToString(entryComponent, props, options) {
4195
- const component = entryComponent;
4465
+ const component = typeof entryComponent === "function" ? entryComponent : renderEntryValue;
4466
+ if (typeof entryComponent !== "function") {
4467
+ options ??= props;
4468
+ props = { value: entryComponent };
4469
+ }
4196
4470
  options?.signal?.throwIfAborted();
4197
4471
  const nonceAttr = nonceAttrOf(options);
4198
4472
  const resolved = newResolvedMap(options ?? null);
@@ -4202,6 +4476,7 @@ function renderToString(entryComponent, props, options) {
4202
4476
  null,
4203
4477
  () => runFullFramedPass(component, props, resolved, nonceAttr, options?.identifierPrefix ?? "")
4204
4478
  );
4479
+ if (pass.rootSuspended) throw new Error((0, import_error_codes_server_generated.formatServerError)(60));
4205
4480
  } catch (err) {
4206
4481
  options?.onError?.(err);
4207
4482
  throw err;
@@ -4211,7 +4486,11 @@ function renderToString(entryComponent, props, options) {
4211
4486
  return passToResult(pass, nonceAttr, options?.headChannel === "separate");
4212
4487
  }
4213
4488
  function renderToStaticMarkup(entryComponent, props, options) {
4214
- const component = entryComponent;
4489
+ const component = typeof entryComponent === "function" ? entryComponent : renderEntryValue;
4490
+ if (typeof entryComponent !== "function") {
4491
+ options ??= props;
4492
+ props = { value: entryComponent };
4493
+ }
4215
4494
  options?.signal?.throwIfAborted();
4216
4495
  const nonceAttr = nonceAttrOf(options);
4217
4496
  const resolved = newResolvedMap(options ?? null);
@@ -4228,6 +4507,7 @@ function renderToStaticMarkup(entryComponent, props, options) {
4228
4507
  false
4229
4508
  )
4230
4509
  );
4510
+ if (pass.rootSuspended) throw new Error((0, import_error_codes_server_generated.formatServerError)(60));
4231
4511
  } catch (err) {
4232
4512
  options?.onError?.(err);
4233
4513
  throw err;
@@ -4321,7 +4601,7 @@ function pruneStreamBoundariesAbsentFromShell(stream, shellBoundaryKeys) {
4321
4601
  if (!shellBoundaryKeys.has(key)) stream.boundaries.delete(key);
4322
4602
  }
4323
4603
  }
4324
- function ssrTry(scope, siteKey, tryFn, pendFn, catchFn, namespace = FRAME?.namespace ?? "html", propagateSuspense = false) {
4604
+ function ssrTry(scope, siteKey, tryFn, pendFn, catchFn, namespace = FRAME?.namespace ?? "html", propagateSuspense = false, recoverErrors = false) {
4325
4605
  VT_SSR_TRY_SEQ++;
4326
4606
  let vtOuter = null;
4327
4607
  if (VT_SSR_STACK.length > 0) {
@@ -4674,6 +4954,13 @@ function ssrTry(scope, siteKey, tryFn, pendFn, catchFn, namespace = FRAME?.names
4674
4954
  pruneUnrepresentedStreamDescendants(stream, key, fallback);
4675
4955
  return fallback;
4676
4956
  }
4957
+ if (recoverErrors && pendFn !== null && PERMANENT_STATIC_HYDRATE_DEPTH === 0) {
4958
+ if (SERIAL !== null) SERIAL.length = serialStart;
4959
+ const reports = RESOLVED?.bufferedErrors ?? (RESOLVED.bufferedErrors = /* @__PURE__ */ new Map());
4960
+ if (!reports.has(key)) reports.set(key, { error: e, reported: false });
4961
+ nativeFresh = true;
4962
+ return pendingForm();
4963
+ }
4677
4964
  throw e;
4678
4965
  }
4679
4966
  } finally {
@@ -4715,19 +5002,22 @@ function documentHeadInsertionPoint(body) {
4715
5002
  const next = body.charCodeAt(start + 5);
4716
5003
  if (next === 62) return start + 6;
4717
5004
  if (next === 32 || next === 9 || next === 10 || next === 13) {
4718
- let quote = 0;
4719
- for (let i = start + 6; i < body.length; i++) {
4720
- const code = body.charCodeAt(i);
4721
- if (quote !== 0) {
4722
- if (code === quote) quote = 0;
4723
- } else if (code === 34 || code === 39) quote = code;
4724
- else if (code === 62) return i + 1;
4725
- }
4726
- return -1;
5005
+ return documentTagEnd(body, start + 6);
4727
5006
  }
4728
5007
  searchFrom = start + 5;
4729
5008
  }
4730
5009
  }
5010
+ function documentTagEnd(body, from) {
5011
+ let quote = 0;
5012
+ for (let i = from; i < body.length; i++) {
5013
+ const code = body.charCodeAt(i);
5014
+ if (quote !== 0) {
5015
+ if (code === quote) quote = 0;
5016
+ } else if (code === 34 || code === 39) quote = code;
5017
+ else if (code === 62) return i + 1;
5018
+ }
5019
+ return -1;
5020
+ }
4731
5021
  function segmentChunk(b, nonceAttr) {
4732
5022
  let seedScript = "";
4733
5023
  if (b.seeds.length > 0) {
@@ -4786,19 +5076,30 @@ async function runStream(component, props, options, sink, resolved) {
4786
5076
  };
4787
5077
  const injection = options?.injection;
4788
5078
  if (injection !== void 0) injection.done.then(NOOP, NOOP);
5079
+ let injectionCompleted = false;
5080
+ const completeInjection = injection === void 0 ? NOOP : () => {
5081
+ if (injectionCompleted) return;
5082
+ injectionCompleted = true;
5083
+ injection.renderComplete?.();
5084
+ };
4789
5085
  let injectionUnsubscribe;
4790
5086
  let injectionFailure;
4791
5087
  let injectionFailed = false;
5088
+ const unacceptedInjection = injection === void 0 ? void 0 : [];
5089
+ const rememberUnaccepted = injection === void 0 ? NOOP : (chunk) => {
5090
+ unacceptedInjection.push(chunk);
5091
+ };
4792
5092
  let signalInjectionFailure;
4793
5093
  const failInjection = (err) => {
5094
+ if (signal?.aborted && err === signal.reason) return;
4794
5095
  if (injectionFailed) return;
4795
5096
  injectionFailed = true;
4796
5097
  injectionFailure = err;
4797
5098
  signalInjectionFailure?.();
4798
5099
  };
4799
5100
  let writeChain = injection === void 0 ? null : Promise.resolve();
4800
- const write = injection === void 0 ? (chunk, terminal) => sink.write(chunk, terminal) : (chunk, terminal) => {
4801
- const operation = writeChain.then(() => sink.write(chunk, terminal));
5101
+ const write = injection === void 0 ? (chunk, terminal) => sink.write(chunk, terminal) : (chunk, terminal, onUnaccepted) => {
5102
+ const operation = writeChain.then(() => sink.write(chunk, terminal, onUnaccepted));
4802
5103
  writeChain = operation.then(NOOP, NOOP);
4803
5104
  return operation;
4804
5105
  };
@@ -4812,11 +5113,34 @@ async function runStream(component, props, options, sink, resolved) {
4812
5113
  return;
4813
5114
  }
4814
5115
  if (!html) return;
4815
- return write(html);
5116
+ return write(html, false, rememberUnaccepted);
5117
+ };
5118
+ const recoveryInjection = injection === void 0 ? void 0 : async () => {
5119
+ if (signal?.aborted) {
5120
+ await writeChain;
5121
+ for (const html of unacceptedInjection) {
5122
+ const replay = write(html, "recovery");
5123
+ if (replay !== void 0) await replay;
5124
+ }
5125
+ unacceptedInjection.length = 0;
5126
+ }
5127
+ if (injectionFailed) return "";
5128
+ let queued;
5129
+ try {
5130
+ queued = injection.take();
5131
+ } catch {
5132
+ return "";
5133
+ }
5134
+ if (queued !== "" && signal?.aborted) {
5135
+ const replay = write(queued, "recovery");
5136
+ if (replay !== void 0) await replay;
5137
+ return "";
5138
+ }
5139
+ return queued;
4816
5140
  };
4817
5141
  const notifyInjection = () => {
4818
5142
  const drained = drainInjection();
4819
- if (drained !== void 0) drained.catch(NOOP);
5143
+ if (drained !== void 0) drained.catch(failInjection);
4820
5144
  };
4821
5145
  const waitForInjectionDone = () => new Promise((resolve, reject) => {
4822
5146
  let settled = false;
@@ -4919,12 +5243,24 @@ async function runStream(component, props, options, sink, resolved) {
4919
5243
  }
4920
5244
  pruneStreamBoundariesAbsentFromShell(stream, shellBoundaryKeys);
4921
5245
  } catch (err) {
5246
+ try {
5247
+ completeInjection();
5248
+ } catch {
5249
+ }
4922
5250
  const reports = signal?.aborted ? Math.max(1, preShellSuspended.length) : 1;
4923
5251
  for (let i = 0; i < reports; i++) options?.onError?.(err);
4924
5252
  sink.shellError(err);
4925
5253
  return;
4926
5254
  }
4927
- reportRecoverableBoundaryErrors();
5255
+ try {
5256
+ reportRecoverableBoundaryErrors();
5257
+ } catch (err) {
5258
+ try {
5259
+ completeInjection();
5260
+ } catch {
5261
+ }
5262
+ throw err;
5263
+ }
4928
5264
  if (pass.sheets !== null) for (const key of pass.sheets.keys()) flushedSheets.add(key);
4929
5265
  let leadingStyles = "";
4930
5266
  for (const [hash, sheet] of pass.cssEntries) {
@@ -4932,7 +5268,17 @@ async function runStream(component, props, options, sink, resolved) {
4932
5268
  leadingStyles += '<style data-octane="' + hash + '"' + (sheet.nonce === void 0 ? nonceAttr : ' nonce="' + escapeAttr(sheet.nonce) + '"') + ">" + escapeEntireInlineStyleContent(sheet.css) + "</style>";
4933
5269
  }
4934
5270
  const separateHead = options?.headChannel === "separate";
4935
- if (separateHead) options?.onHeadReady?.(pass.vtCandidates ? vtSsrStrip(pass.head) : pass.head);
5271
+ if (separateHead) {
5272
+ try {
5273
+ options?.onHeadReady?.(pass.vtCandidates ? vtSsrStrip(pass.head) : pass.head);
5274
+ } catch (err) {
5275
+ try {
5276
+ completeInjection();
5277
+ } catch {
5278
+ }
5279
+ throw err;
5280
+ }
5281
+ }
4936
5282
  const shellHead = separateHead ? "" : pass.head;
4937
5283
  const documentRoot = isDocumentRoot(pass.body);
4938
5284
  let shell = documentRoot ? "<!DOCTYPE html>" : "";
@@ -4941,14 +5287,14 @@ async function runStream(component, props, options, sink, resolved) {
4941
5287
  const tailStart = documentTailStart(pass.body);
4942
5288
  if (tailStart !== -1) {
4943
5289
  heldDocumentTail = pass.body.slice(tailStart);
4944
- const bodyHtml = pass.body.slice(0, tailStart);
5290
+ const bodyHtml = spliceHead(pass.body.slice(0, tailStart), "");
4945
5291
  const headInsert = documentHeadInsertionPoint(bodyHtml);
4946
5292
  shell += headInsert !== -1 ? bodyHtml.slice(0, headInsert) + leadingStyles + shellHead + bodyHtml.slice(headInsert) : leadingStyles + shellHead + bodyHtml;
4947
5293
  } else {
4948
- shell += leadingStyles + shellHead + pass.body;
5294
+ shell += spliceHead(pass.body, leadingStyles + shellHead);
4949
5295
  }
4950
5296
  } else {
4951
- shell += leadingStyles + shellHead + pass.body;
5297
+ shell += documentRoot ? spliceHead(pass.body, leadingStyles + shellHead) : leadingStyles + shellHead + pass.body;
4952
5298
  }
4953
5299
  if (pass.serial.length > 0) shell += serializeSuspenseSeeds(pass.serial, nonceAttr);
4954
5300
  if (pass.signals !== void 0) shell += serializeNativeSignalSeeds(pass.signals, nonceAttr);
@@ -4959,11 +5305,23 @@ async function runStream(component, props, options, sink, resolved) {
4959
5305
  const shellWrite = write(pass.vtCandidates ? vtSsrStrip(shell) : shell);
4960
5306
  if (shellWrite !== void 0) await shellWrite;
4961
5307
  } catch (err) {
5308
+ try {
5309
+ completeInjection();
5310
+ } catch {
5311
+ }
4962
5312
  options?.onError?.(err);
4963
5313
  sink.shellError(err);
4964
5314
  return;
4965
5315
  }
4966
- sink.shellReady();
5316
+ try {
5317
+ sink.shellReady();
5318
+ } catch (err) {
5319
+ try {
5320
+ completeInjection();
5321
+ } catch {
5322
+ }
5323
+ throw err;
5324
+ }
4967
5325
  if (injection !== void 0) {
4968
5326
  try {
4969
5327
  injectionUnsubscribe = injection.subscribe(notifyInjection);
@@ -5053,14 +5411,14 @@ async function runStream(component, props, options, sink, resolved) {
5053
5411
  injectionUnsubscribe?.();
5054
5412
  injectionUnsubscribe = void 0;
5055
5413
  try {
5056
- injection.renderComplete?.();
5414
+ completeInjection();
5057
5415
  } catch {
5058
5416
  }
5059
5417
  }
5060
5418
  let tail = "";
5061
- if (injection !== void 0 && !injectionFailed) {
5419
+ if (recoveryInjection !== void 0) {
5062
5420
  try {
5063
- tail += injection.take();
5421
+ tail = await recoveryInjection();
5064
5422
  } catch {
5065
5423
  }
5066
5424
  }
@@ -5080,7 +5438,7 @@ async function runStream(component, props, options, sink, resolved) {
5080
5438
  }
5081
5439
  if (injection !== void 0) {
5082
5440
  try {
5083
- injection.renderComplete?.();
5441
+ completeInjection();
5084
5442
  } catch (err) {
5085
5443
  failInjection(err);
5086
5444
  }
@@ -5088,11 +5446,14 @@ async function runStream(component, props, options, sink, resolved) {
5088
5446
  await waitForInjectionDone();
5089
5447
  const finalDrain = drainInjection();
5090
5448
  if (finalDrain !== void 0) await finalDrain;
5449
+ await writeChain;
5091
5450
  if (injectionFailed) throw injectionFailure;
5092
5451
  if (heldDocumentTail !== "") {
5093
5452
  const tailChunk = heldDocumentTail;
5094
5453
  heldDocumentTail = "";
5095
- const tailWrite = write(tailChunk);
5454
+ const tailWrite = write(tailChunk, false, (unaccepted) => {
5455
+ heldDocumentTail = unaccepted;
5456
+ });
5096
5457
  if (tailWrite !== void 0) await tailWrite;
5097
5458
  }
5098
5459
  } catch (err) {
@@ -5100,11 +5461,9 @@ async function runStream(component, props, options, sink, resolved) {
5100
5461
  injectionUnsubscribe?.();
5101
5462
  injectionUnsubscribe = void 0;
5102
5463
  let terminal = "";
5103
- if (!injectionFailed) {
5104
- try {
5105
- terminal = injection.take();
5106
- } catch {
5107
- }
5464
+ try {
5465
+ terminal = await recoveryInjection();
5466
+ } catch {
5108
5467
  }
5109
5468
  terminal += heldDocumentTail;
5110
5469
  if (terminal !== "") {
@@ -5122,7 +5481,11 @@ async function runStream(component, props, options, sink, resolved) {
5122
5481
  sink.allReady();
5123
5482
  }
5124
5483
  function renderToPipeableStream(entryComponent, props, options) {
5125
- const component = entryComponent;
5484
+ const component = typeof entryComponent === "function" ? entryComponent : renderEntryValue;
5485
+ if (typeof entryComponent !== "function") {
5486
+ options ??= props;
5487
+ props = { value: entryComponent };
5488
+ }
5126
5489
  const controller = new AbortController();
5127
5490
  let removeOuterAbort;
5128
5491
  if (options?.signal) {
@@ -5141,6 +5504,7 @@ function renderToPipeableStream(entryComponent, props, options) {
5141
5504
  let endCalled = false;
5142
5505
  let pipeCalled = false;
5143
5506
  let writeGate = null;
5507
+ let shellFailure = null;
5144
5508
  const destinationFailure = (reason) => {
5145
5509
  if (closed) return;
5146
5510
  closed = true;
@@ -5154,12 +5518,18 @@ function renderToPipeableStream(entryComponent, props, options) {
5154
5518
  if (!ended || destination === null || writeGate !== null || endCalled || closed) return;
5155
5519
  endCalled = true;
5156
5520
  try {
5521
+ if (shellFailure !== null && destination.destroy !== void 0) {
5522
+ closed = true;
5523
+ destination.destroy(shellFailure.error);
5524
+ return;
5525
+ }
5157
5526
  destination.end();
5158
5527
  } catch (err) {
5159
5528
  destinationFailure(err);
5160
5529
  }
5161
5530
  };
5162
- const waitForDrain = (dest) => {
5531
+ const waitForDrain = (dest, allowAborted = false) => {
5532
+ if (allowAborted && closed) return Promise.reject(new Error((0, import_error_codes_server_generated.formatServerError)(38)));
5163
5533
  if (dest.once === void 0) {
5164
5534
  return Promise.reject(new TypeError((0, import_error_codes_server_generated.formatServerError)(39)));
5165
5535
  }
@@ -5195,14 +5565,17 @@ function renderToPipeableStream(entryComponent, props, options) {
5195
5565
  dest.once("drain", onDrain);
5196
5566
  dest.once("error", onError);
5197
5567
  dest.once("close", onClose);
5198
- if (controller.signal.aborted) onAbort();
5199
- else controller.signal.addEventListener("abort", onAbort, { once: true });
5568
+ if (!allowAborted) {
5569
+ if (controller.signal.aborted) onAbort();
5570
+ else controller.signal.addEventListener("abort", onAbort, { once: true });
5571
+ }
5200
5572
  });
5201
5573
  };
5202
- const writeNow = (chunk, terminal) => {
5574
+ const writeNow = (chunk, terminal, onUnaccepted) => {
5203
5575
  const dest = destination;
5204
5576
  if (closed) return Promise.reject(new Error((0, import_error_codes_server_generated.formatServerError)(40)));
5205
- if (!terminal && controller.signal.aborted) {
5577
+ if (terminal === false && controller.signal.aborted) {
5578
+ onUnaccepted?.(chunk);
5206
5579
  return Promise.reject(controller.signal.reason);
5207
5580
  }
5208
5581
  let accepted;
@@ -5212,7 +5585,7 @@ function renderToPipeableStream(entryComponent, props, options) {
5212
5585
  destinationFailure(err);
5213
5586
  return Promise.reject(err);
5214
5587
  }
5215
- return accepted === false && !terminal ? waitForDrain(dest) : void 0;
5588
+ return accepted === false && terminal !== true ? waitForDrain(dest, terminal === "recovery") : void 0;
5216
5589
  };
5217
5590
  const trackWrite = (operation) => {
5218
5591
  const gate = operation.then(
@@ -5233,16 +5606,18 @@ function renderToPipeableStream(entryComponent, props, options) {
5233
5606
  });
5234
5607
  return operation;
5235
5608
  };
5236
- const queueWrite = (chunk, terminal = false) => {
5609
+ const queueWrite = (chunk, terminal = false, onUnaccepted) => {
5237
5610
  if (destination === null) {
5238
- buffered.push({ chunk, terminal });
5611
+ buffered.push(
5612
+ onUnaccepted === void 0 ? { chunk, terminal } : { chunk, terminal, onUnaccepted }
5613
+ );
5239
5614
  return;
5240
5615
  }
5241
5616
  if (writeGate !== null) {
5242
- const operation2 = writeGate.then(() => writeNow(chunk, terminal));
5617
+ const operation2 = writeGate.then(() => writeNow(chunk, terminal, onUnaccepted));
5243
5618
  return trackWrite(operation2);
5244
5619
  }
5245
- const operation = writeNow(chunk, terminal);
5620
+ const operation = writeNow(chunk, terminal, onUnaccepted);
5246
5621
  return operation === void 0 ? void 0 : trackWrite(operation);
5247
5622
  };
5248
5623
  const flushEnd = () => {
@@ -5262,14 +5637,15 @@ function renderToPipeableStream(entryComponent, props, options) {
5262
5637
  props,
5263
5638
  renderOptions,
5264
5639
  {
5265
- write(chunk, terminal) {
5266
- return queueWrite(chunk, terminal);
5640
+ write(chunk, terminal, onUnaccepted) {
5641
+ return queueWrite(chunk, terminal, onUnaccepted);
5267
5642
  },
5268
5643
  shellReady() {
5269
5644
  options?.onShellReady?.();
5270
5645
  },
5271
5646
  shellError(err) {
5272
5647
  releaseServerRenderResources(resolved);
5648
+ shellFailure = { error: err };
5273
5649
  options?.onShellError?.(err);
5274
5650
  flushEnd();
5275
5651
  },
@@ -5306,7 +5682,11 @@ function renderToPipeableStream(entryComponent, props, options) {
5306
5682
  });
5307
5683
  }
5308
5684
  for (const item of buffered) {
5309
- queueWrite(item.chunk, item.terminal || controller.signal.aborted);
5685
+ queueWrite(
5686
+ item.chunk,
5687
+ item.terminal === "recovery" ? "recovery" : item.terminal || controller.signal.aborted,
5688
+ item.onUnaccepted
5689
+ );
5310
5690
  }
5311
5691
  buffered.length = 0;
5312
5692
  finishEnd();
@@ -5318,7 +5698,11 @@ function renderToPipeableStream(entryComponent, props, options) {
5318
5698
  };
5319
5699
  }
5320
5700
  function renderToReadableStream(entryComponent, props, options) {
5321
- const component = entryComponent;
5701
+ const component = typeof entryComponent === "function" ? entryComponent : renderEntryValue;
5702
+ if (typeof entryComponent !== "function") {
5703
+ options ??= props;
5704
+ props = { value: entryComponent };
5705
+ }
5322
5706
  return new Promise((resolveShell, rejectShell) => {
5323
5707
  const encoder = new TextEncoder();
5324
5708
  const renderController = new AbortController();
@@ -5368,7 +5752,10 @@ function renderToReadableStream(entryComponent, props, options) {
5368
5752
  });
5369
5753
  stream.allReady = allReady;
5370
5754
  let shellDone = false;
5371
- const waitForDemand = () => new Promise((resolve, reject) => {
5755
+ let terminal = false;
5756
+ let released = false;
5757
+ let callbackFailure;
5758
+ const waitForDemand = (allowAborted = false) => new Promise((resolve, reject) => {
5372
5759
  let settled = false;
5373
5760
  const cleanup = () => {
5374
5761
  renderController.signal.removeEventListener("abort", onAbort);
@@ -5383,18 +5770,21 @@ function renderToReadableStream(entryComponent, props, options) {
5383
5770
  const onDemand = () => finish(resolve);
5384
5771
  const onAbort = () => finish(() => reject(renderController.signal.reason));
5385
5772
  wakeDemand = onDemand;
5386
- if (renderController.signal.aborted) onAbort();
5387
- else renderController.signal.addEventListener("abort", onAbort, { once: true });
5773
+ if (!allowAborted) {
5774
+ if (renderController.signal.aborted) onAbort();
5775
+ else renderController.signal.addEventListener("abort", onAbort, { once: true });
5776
+ }
5388
5777
  });
5389
- const writeReadable = (chunk, terminal = false) => {
5778
+ const writeReadable = (chunk, terminal2 = false, onUnaccepted) => {
5390
5779
  if (closed || consumerCancelled) {
5391
5780
  return Promise.reject(cancelReason ?? new Error((0, import_error_codes_server_generated.formatServerError)(44)));
5392
5781
  }
5393
- if (!terminal && renderController.signal.aborted) {
5782
+ if (terminal2 === false && renderController.signal.aborted) {
5783
+ onUnaccepted?.(chunk);
5394
5784
  return Promise.reject(renderController.signal.reason);
5395
5785
  }
5396
5786
  const bytes = encoder.encode(chunk);
5397
- if (terminal) {
5787
+ if (terminal2 === true) {
5398
5788
  readableController.enqueue(bytes);
5399
5789
  return;
5400
5790
  }
@@ -5403,13 +5793,18 @@ function renderToReadableStream(entryComponent, props, options) {
5403
5793
  return;
5404
5794
  }
5405
5795
  return (async () => {
5406
- while ((readableController.desiredSize ?? 0) <= 0) {
5407
- await waitForDemand();
5408
- if (closed || consumerCancelled) {
5409
- throw cancelReason ?? new Error((0, import_error_codes_server_generated.formatServerError)(44));
5796
+ try {
5797
+ while ((readableController.desiredSize ?? 0) <= 0) {
5798
+ await waitForDemand(terminal2 === "recovery");
5799
+ if (closed || consumerCancelled) {
5800
+ throw cancelReason ?? new Error((0, import_error_codes_server_generated.formatServerError)(44));
5801
+ }
5410
5802
  }
5803
+ readableController.enqueue(bytes);
5804
+ } catch (err) {
5805
+ if (!consumerCancelled && renderController.signal.aborted) onUnaccepted?.(chunk);
5806
+ throw err;
5411
5807
  }
5412
- readableController.enqueue(bytes);
5413
5808
  })();
5414
5809
  };
5415
5810
  const closeReadable = () => {
@@ -5423,46 +5818,80 @@ function renderToReadableStream(entryComponent, props, options) {
5423
5818
  }
5424
5819
  };
5425
5820
  const renderOptions = { ...options, signal: renderController.signal };
5821
+ if (options?.onError !== void 0) {
5822
+ renderOptions.onError = (error) => {
5823
+ try {
5824
+ options.onError(error);
5825
+ } catch (err) {
5826
+ callbackFailure ??= { error: err };
5827
+ }
5828
+ };
5829
+ }
5426
5830
  const resolved = newResolvedMap(renderOptions);
5831
+ const release = () => {
5832
+ if (released) return;
5833
+ released = true;
5834
+ releaseServerRenderResources(resolved);
5835
+ };
5836
+ const settleFailure = (error) => {
5837
+ if (terminal) return;
5838
+ terminal = true;
5839
+ try {
5840
+ release();
5841
+ } catch (err) {
5842
+ error = err;
5843
+ }
5844
+ const reason = callbackFailure === void 0 ? error : callbackFailure.error;
5845
+ if (!shellDone) rejectShell(reason);
5846
+ allReadyReject(reason);
5847
+ closeReadable();
5848
+ };
5427
5849
  runStream(
5428
5850
  component,
5429
5851
  props,
5430
5852
  renderOptions,
5431
5853
  {
5432
- write(chunk, terminal) {
5433
- return writeReadable(chunk, terminal);
5854
+ write(chunk, terminal2, onUnaccepted) {
5855
+ return writeReadable(chunk, terminal2, onUnaccepted);
5434
5856
  },
5435
5857
  shellReady() {
5436
- shellDone = true;
5437
5858
  options?.onShellReady?.();
5859
+ shellDone = true;
5438
5860
  resolveShell(stream);
5439
5861
  },
5440
5862
  shellError(err) {
5441
- releaseServerRenderResources(resolved);
5442
- options?.onShellError?.(err);
5443
- if (!shellDone) rejectShell(err);
5444
- allReadyReject(err);
5445
- closeReadable();
5863
+ try {
5864
+ release();
5865
+ options?.onShellError?.(err);
5866
+ } catch (callbackError) {
5867
+ settleFailure(callbackError);
5868
+ return;
5869
+ }
5870
+ settleFailure(err);
5446
5871
  },
5447
5872
  allReady() {
5448
- releaseServerRenderResources(resolved);
5449
- options?.onAllReady?.();
5450
- allReadyResolve();
5873
+ if (terminal) return;
5874
+ try {
5875
+ release();
5876
+ options?.onAllReady?.();
5877
+ } catch (err) {
5878
+ renderOptions.onError?.(err);
5879
+ settleFailure(err);
5880
+ return;
5881
+ }
5882
+ terminal = true;
5883
+ if (callbackFailure === void 0) allReadyResolve();
5884
+ else allReadyReject(callbackFailure.error);
5451
5885
  closeReadable();
5452
5886
  },
5453
5887
  fatal(err) {
5454
- releaseServerRenderResources(resolved);
5455
- allReadyReject(err);
5456
- closeReadable();
5888
+ settleFailure(err);
5457
5889
  }
5458
5890
  },
5459
5891
  resolved
5460
5892
  ).catch((err) => {
5461
- releaseServerRenderResources(resolved);
5462
- options?.onError?.(err);
5463
- if (!shellDone) rejectShell(err);
5464
- allReadyReject(err);
5465
- closeReadable();
5893
+ renderOptions.onError?.(err);
5894
+ settleFailure(err);
5466
5895
  });
5467
5896
  });
5468
5897
  }
@@ -5768,11 +6197,14 @@ function preinitModule(href, options) {
5768
6197
  getSsrSuspenseTimeout,
5769
6198
  hookSlots,
5770
6199
  injectStyle,
6200
+ invokeManualHook,
5771
6201
  isChildrenBlock,
5772
6202
  isValidElement,
5773
6203
  lazy,
6204
+ manualHook,
5774
6205
  mapSlot,
5775
6206
  markChildrenBlock,
6207
+ markWarm,
5776
6208
  memo,
5777
6209
  namespaceHead,
5778
6210
  namespaceHeadElement,
@@ -5808,7 +6240,9 @@ function preinitModule(href, options) {
5808
6240
  ssrBlock,
5809
6241
  ssrCheckedAttr,
5810
6242
  ssrChild,
6243
+ ssrChildPre,
5811
6244
  ssrChildText,
6245
+ ssrChildTextPre,
5812
6246
  ssrChildrenSources,
5813
6247
  ssrClass,
5814
6248
  ssrComponent,
@@ -5819,6 +6253,7 @@ function preinitModule(href, options) {
5819
6253
  ssrFormAuthoringDiagnostics,
5820
6254
  ssrFragmentMarker,
5821
6255
  ssrHeadEl,
6256
+ ssrHtml,
5822
6257
  ssrInNamespace,
5823
6258
  ssrInnerHtml,
5824
6259
  ssrInputAttrs,
@@ -5846,6 +6281,8 @@ function preinitModule(href, options) {
5846
6281
  ssrValueAttr,
5847
6282
  ssrVoidContent,
5848
6283
  startTransition,
6284
+ styleMap,
6285
+ touchStyleMap,
5849
6286
  use,
5850
6287
  useActionState,
5851
6288
  useCallback,