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
@@ -55,7 +55,13 @@ import {
55
55
  escapeMappedElementKey,
56
56
  resolveLazyDefaultProps as lazyResolvedProps
57
57
  } from "./shared-value-helpers.js";
58
- import { devWarnStyleCoercion, devWarnStyleProperty, normalizeClass, styleName } from "./css.js";
58
+ import {
59
+ devWarnStyleCoercion,
60
+ devWarnStyleProperty,
61
+ mergeClass,
62
+ normalizeClass,
63
+ styleName
64
+ } from "./css.js";
59
65
  import {
60
66
  invalidHtmlNestingWithAncestor,
61
67
  invalidHtmlNestingWithParent,
@@ -508,7 +514,9 @@ function fragmentRefDescriptor(value) {
508
514
  };
509
515
  }
510
516
  function renderFragmentRefDescriptor(descriptor, scope) {
511
- return ssrFragmentMarker(true, descriptor.ref) + ssrChild(descriptor.children, scope) + ssrFragmentMarker(false);
517
+ return ssrHtml(
518
+ ssrFragmentMarker(true, descriptor.ref) + ssrChild(descriptor.children, scope) + ssrFragmentMarker(false)
519
+ );
512
520
  }
513
521
  function ssrDeoptWrapperKind(value) {
514
522
  return POSITIONAL_CHILDREN.has(value) ? "fragment" : "array";
@@ -805,9 +813,29 @@ const Children = {
805
813
  }
806
814
  };
807
815
  function createPortal(body, target, props = void 0) {
808
- return { $$kind: PORTAL_TAG, body, target, props };
816
+ const key = typeof props === "string" || typeof props === "number" ? String(props) : null;
817
+ return { $$kind: PORTAL_TAG, body, target, key, props: key === null ? props : void 0 };
809
818
  }
810
819
  const HTML_ESCAPE_RE = /[&<>]/g;
820
+ const SERVER_HTML = /* @__PURE__ */ Symbol.for("octane.serverHtml");
821
+ class ServerHtml {
822
+ [SERVER_HTML];
823
+ constructor(html) {
824
+ this[SERVER_HTML] = html;
825
+ }
826
+ toString() {
827
+ return this[SERVER_HTML];
828
+ }
829
+ }
830
+ function ssrHtml(html) {
831
+ return typeof html === "string" ? new ServerHtml(html) : html;
832
+ }
833
+ function serverComponentOutput(out, scope) {
834
+ if (out == null) return "";
835
+ if (typeof out === "string") return escapeHtml(out);
836
+ if (typeof out === "object" && SERVER_HTML in out) return out[SERVER_HTML];
837
+ return ssrChild(out, scope);
838
+ }
811
839
  function escapeHtml(v) {
812
840
  const s = typeof v === "string" ? v : String(v);
813
841
  HTML_ESCAPE_RE.lastIndex = 0;
@@ -852,6 +880,9 @@ function ssrChild(v, scope) {
852
880
  return ssrChildValue(v, scope, true);
853
881
  }
854
882
  function ssrChildValue(v, scope, includeKeyedSingle, selfMarkItem = false) {
883
+ if (v !== null && typeof v === "object" && SERVER_HTML in v) {
884
+ return v[SERVER_HTML];
885
+ }
855
886
  if (v == null || v === false || v === true) return ssrBlock("");
856
887
  if ((typeof v === "object" || typeof v === "function") && (v.$$kind === CONTEXT_TAG || typeof v.then === "function")) {
857
888
  return ssrChildValue(
@@ -903,6 +934,14 @@ function ssrChildText(v, scope) {
903
934
  if (typeof v === "object" || typeof v === "function") return ssrChild(v, scope);
904
935
  return escapeHtml(v);
905
936
  }
937
+ function ssrChildTextPre(v, scope) {
938
+ const content = ssrChildText(v, scope);
939
+ return content.charCodeAt(0) === 10 ? "\n" + content : content;
940
+ }
941
+ function ssrChildPre(v, scope) {
942
+ const content = ssrChild(v, scope);
943
+ return content.charCodeAt(0) === 10 ? "\n" + content : content;
944
+ }
906
945
  function ssrHostElement(tag, props, children, scope, rawInner) {
907
946
  if (!VALID_TAG_NAME.test(tag)) {
908
947
  throw new Error(formatServerError(30, tag));
@@ -977,9 +1016,9 @@ function ssrHostElement(tag, props, children, scope, rawInner) {
977
1016
  } else if (rawInner !== void 0) {
978
1017
  inner = rawInner;
979
1018
  } else if (hasChildren) {
980
- const scriptText = semanticTag === "script" ? scriptDescriptorText(children) : null;
981
- if (scriptText !== null) {
982
- inner = escapeEntireInlineScriptContent(scriptText);
1019
+ const rawText = semanticTag === "script" || semanticTag === "style" ? scriptDescriptorText(children) : null;
1020
+ if (rawText !== null) {
1021
+ inner = semanticTag === "script" ? escapeEntireInlineScriptContent(rawText) : escapeEntireInlineStyleContent(rawText);
983
1022
  } else {
984
1023
  const build = () => ssrInNamespace(
985
1024
  childrenNamespace,
@@ -995,6 +1034,9 @@ function ssrHostElement(tag, props, children, scope, rawInner) {
995
1034
  inner
996
1035
  );
997
1036
  }
1037
+ if ((semanticTag === "pre" || semanticTag === "textarea" || semanticTag === "listing") && inner.charCodeAt(0) === 10) {
1038
+ inner = "\n" + inner;
1039
+ }
998
1040
  return "<" + tag + attrs + ">" + inner + "</" + tag + ">";
999
1041
  } finally {
1000
1042
  CURRENT_SSR_ELEMENT = parentElement;
@@ -1021,6 +1063,7 @@ function ssrDeoptBlockChildren(children, scope) {
1021
1063
  }
1022
1064
  function serverDescNeedsBlocks(v) {
1023
1065
  if (v == null || typeof v !== "object") return false;
1066
+ if (v.$$kind === CONTEXT_TAG || typeof v.then === "function") return true;
1024
1067
  if (Array.isArray(v)) {
1025
1068
  for (let i = 0; i < v.length; i++) if (serverDescNeedsBlocks(v[i])) return true;
1026
1069
  return false;
@@ -1065,6 +1108,7 @@ function ssrDeoptItemContent(value, scope) {
1065
1108
  }
1066
1109
  function ssrDescriptorContent(v, scope) {
1067
1110
  if (v == null || v === false || v === true || v === "") return "";
1111
+ if (typeof v === "object" && SERVER_HTML in v) return v[SERVER_HTML];
1068
1112
  if (Array.isArray(v)) {
1069
1113
  let out = "";
1070
1114
  for (let i = 0; i < v.length; i++) out += ssrDescriptorContent(v[i], scope);
@@ -1082,7 +1126,7 @@ function ssrDescriptorContent(v, scope) {
1082
1126
  return escapeHtml(v);
1083
1127
  }
1084
1128
  function ssrBlock(content) {
1085
- return MARKERS ? BLOCK_OPEN + content + BLOCK_CLOSE : content;
1129
+ return MARKERS ? BLOCK_OPEN + content + BLOCK_CLOSE : String(content);
1086
1130
  }
1087
1131
  function ssrFragmentMarker(open, _ref) {
1088
1132
  return MARKERS ? open ? "<!--frag-->" : "<!--/frag-->" : "";
@@ -1091,10 +1135,10 @@ function ssrActivity(mode, render) {
1091
1135
  return ssrBlock(mode === "hidden" ? "" : render());
1092
1136
  }
1093
1137
  function renderActivityDescriptor(props, scope) {
1094
- return ssrActivity(props.mode ?? "visible", () => ssrChild(props.children, scope));
1138
+ return ssrHtml(ssrActivity(props.mode ?? "visible", () => ssrChild(props.children, scope)));
1095
1139
  }
1096
1140
  function ssrForBlock(content, hasItems) {
1097
- return MARKERS ? (hasItems ? FOR_BLOCK_OPEN_ITEMS : FOR_BLOCK_OPEN_EMPTY) + content + BLOCK_CLOSE : content;
1141
+ return MARKERS ? (hasItems ? FOR_BLOCK_OPEN_ITEMS : FOR_BLOCK_OPEN_EMPTY) + content + BLOCK_CLOSE : String(content);
1098
1142
  }
1099
1143
  const ASCII_ASYNC_IDENTITY_UNITS = [];
1100
1144
  for (let code = 0; code < 128; code++) {
@@ -1275,10 +1319,10 @@ function ssrAttr(name, v, tag, namespace = "html") {
1275
1319
  return ' class="' + escapeAttr(normalizeClass(v)) + '"';
1276
1320
  }
1277
1321
  if (name.charCodeAt(0) === 97 && name.startsWith("aria-")) {
1278
- if (v == null) return "";
1322
+ if (v == null || typeof v === "function" || typeof v === "symbol") return "";
1279
1323
  return " " + name + '="' + escapeAttr(String(v)) + '"';
1280
1324
  }
1281
- if (name === "suppressContentEditableWarning" || name === "suppressHydrationWarning" || name === "suppressNativeChangeWarning" || name === "__octaneNativeChangeDiagnostic")
1325
+ if (name === "innerText" || name === "textContent" || name === "suppressContentEditableWarning" || name === "suppressHydrationWarning" || name === "suppressNativeChangeWarning" || name === "__octaneNativeChangeDiagnostic")
1282
1326
  return "";
1283
1327
  const t = typeof v;
1284
1328
  if (t === "boolean" && isEnumeratedBooleanAttr(name)) {
@@ -1334,6 +1378,7 @@ function ssrAttr(name, v, tag, namespace = "html") {
1334
1378
  return "";
1335
1379
  }
1336
1380
  if (POSITIVE_NUMERIC_ATTR_PROPS.has(lower) && !(Number(v) >= 1)) return "";
1381
+ if ((lower === "rowspan" || lower === "start") && Number.isNaN(Number(v))) return "";
1337
1382
  }
1338
1383
  if (v == null || v === false) return "";
1339
1384
  if (process.env.NODE_ENV !== "production" && !isCustomTag && tag !== void 0 && t === "object" && v.toString === Object.prototype.toString) {
@@ -1425,8 +1470,9 @@ function isAggregatedFormAttribute(tag, name) {
1425
1470
  function ssrAttrs(sources, tag, namespace = "html", skipFormControls = false) {
1426
1471
  namespace = resolveAttributeNamespace(namespace);
1427
1472
  const props = /* @__PURE__ */ new Map();
1473
+ let classMerges = null;
1428
1474
  let sourceOrder = 0;
1429
- const record = (rawName, value) => {
1475
+ function record(rawName, value) {
1430
1476
  if (typeof rawName !== "string") return;
1431
1477
  const order = sourceOrder++;
1432
1478
  const previous = props.get(rawName);
@@ -1436,9 +1482,17 @@ function ssrAttrs(sources, tag, namespace = "html", skipFormControls = false) {
1436
1482
  firstOrder: previous?.firstOrder ?? order,
1437
1483
  lastOrder: order
1438
1484
  });
1439
- };
1440
- for (const [isSpread, sourceOrName, directValue] of sources) {
1485
+ }
1486
+ for (const [isSpread, sourceOrName, directValue, merge] of sources) {
1441
1487
  if (!isSpread) {
1488
+ if (merge === true && typeof sourceOrName === "string" && (sourceOrName === "class" || sourceOrName === "className")) {
1489
+ (classMerges ??= []).push({
1490
+ rawName: sourceOrName,
1491
+ value: directValue,
1492
+ order: sourceOrder++
1493
+ });
1494
+ continue;
1495
+ }
1442
1496
  record(sourceOrName, directValue);
1443
1497
  continue;
1444
1498
  }
@@ -1450,6 +1504,24 @@ function ssrAttrs(sources, tag, namespace = "html", skipFormControls = false) {
1450
1504
  record(name, source[name]);
1451
1505
  }
1452
1506
  }
1507
+ if (process.env.NODE_ENV === "production") {
1508
+ let canonical = true;
1509
+ for (const name of props.keys()) {
1510
+ if (normalizeSsrAttributeName(name, tag, namespace) !== name || namespace === "html" && name.toLowerCase() !== name) {
1511
+ canonical = false;
1512
+ break;
1513
+ }
1514
+ }
1515
+ if (canonical) {
1516
+ let out2 = "";
1517
+ for (const { rawName, value } of props.values()) {
1518
+ if (rawName === "dangerouslySetInnerHTML" || skipFormControls && isAggregatedFormAttribute(tag, rawName))
1519
+ continue;
1520
+ out2 += ssrAttrEntry(rawName, value, tag, namespace);
1521
+ }
1522
+ return out2;
1523
+ }
1524
+ }
1453
1525
  const resolved = /* @__PURE__ */ new Map();
1454
1526
  let needsWinningOrderSort = false;
1455
1527
  for (const writer of props.values()) {
@@ -1476,6 +1548,24 @@ function ssrAttrs(sources, tag, namespace = "html", skipFormControls = false) {
1476
1548
  lastOrder
1477
1549
  ]);
1478
1550
  }
1551
+ if (classMerges !== null) {
1552
+ for (const extra of classMerges) {
1553
+ const name = normalizeSsrAttributeName(extra.rawName, tag, namespace);
1554
+ if (!VALID_ATTR_NAME.test(name)) continue;
1555
+ const identity = namespace === "html" ? name.toLowerCase() : name;
1556
+ const previous = resolved.get(identity);
1557
+ if (previous !== void 0) {
1558
+ resolved.set(identity, [
1559
+ previous[0],
1560
+ mergeClass(previous[1], extra.value),
1561
+ previous[2],
1562
+ extra.order
1563
+ ]);
1564
+ continue;
1565
+ }
1566
+ resolved.set(identity, [name, extra.value, extra.order, extra.order]);
1567
+ }
1568
+ }
1479
1569
  let out = "";
1480
1570
  const ordered = [...resolved.values()];
1481
1571
  if (needsWinningOrderSort) ordered.sort((a, b) => a[2] - b[2]);
@@ -1660,7 +1750,7 @@ function ssrFormAuthoringDiagnostics(tag, sources) {
1660
1750
  return "";
1661
1751
  }
1662
1752
  function ssrValueAttr(v) {
1663
- if (v == null) return "";
1753
+ if (v == null || typeof v === "function" || typeof v === "symbol") return "";
1664
1754
  return ' value="' + escapeAttr(typeof v === "string" ? v : String(v)) + '"';
1665
1755
  }
1666
1756
  function ssrCheckedAttr(v) {
@@ -2141,7 +2231,7 @@ function renderComponentFramed(comp, props, parent, frame, inherit) {
2141
2231
  ACTIVE_PU_WARM_PLANS.length = warmPlanCheckpoint;
2142
2232
  HOOK_PASS = previousHookPass;
2143
2233
  }
2144
- const inner = typeof out === "string" ? out : out == null ? "" : ssrChild(out, scope);
2234
+ const inner = serverComponentOutput(out, scope);
2145
2235
  nativeCompleted = true;
2146
2236
  return MARKERS && !inherit ? BLOCK_OPEN + inner + BLOCK_CLOSE : inner;
2147
2237
  } catch (error) {
@@ -2183,7 +2273,7 @@ function ssrComponent(parent, comp, props, inherit, key, identityScoped) {
2183
2273
  const kids = props?.children;
2184
2274
  if (typeof kids === "function") {
2185
2275
  const out = kids(void 0, parent);
2186
- const inner = typeof out === "string" ? out : out == null ? "" : ssrChild(out, parent);
2276
+ const inner = serverComponentOutput(out, parent);
2187
2277
  const html2 = ssrHostElement(tag, props, null, parent, inner);
2188
2278
  return inherit ? html2 : ssrBlock(html2);
2189
2279
  }
@@ -2239,7 +2329,8 @@ function ssrInNamespace(namespace, render) {
2239
2329
  }
2240
2330
  }
2241
2331
  function ssrChildrenHtml(children, scope) {
2242
- if (typeof children === "function") return children(void 0, scope) ?? "";
2332
+ if (typeof children === "function")
2333
+ return serverComponentOutput(children(void 0, scope), scope);
2243
2334
  return ssrChild(children, scope);
2244
2335
  }
2245
2336
  function streamTokenForPendingHtml(html) {
@@ -2273,7 +2364,8 @@ const PermanentStaticHydrate = /* @__PURE__ */ markComponentFlags(
2273
2364
  if (nativeCapture < 0) NATIVE_SERVER_READS = null;
2274
2365
  PERMANENT_STATIC_HYDRATE_DEPTH++;
2275
2366
  try {
2276
- if (inheritedPermanentStatic || !MARKERS) return ssrChildrenHtml(props.children, scope);
2367
+ if (inheritedPermanentStatic || !MARKERS)
2368
+ return ssrHtml(ssrChildrenHtml(props.children, scope));
2277
2369
  const childIdStart = ID_COUNTER;
2278
2370
  const serialStart = SERIAL?.length ?? 0;
2279
2371
  const children = ssrBlock(
@@ -2290,7 +2382,9 @@ const PermanentStaticHydrate = /* @__PURE__ */ markComponentFlags(
2290
2382
  const streamToken = streamTokenForPendingHtml(children);
2291
2383
  const markerToken = streamToken === null ? "" : streamToken + ":";
2292
2384
  const endToken = streamToken === null ? "" : ":" + streamToken;
2293
- return `<!--${HYDRATE_STATIC_ID_COUNT_PREFIX}${markerToken}${idCount}-->` + children + `<!--${HYDRATE_STATIC_END}${endToken}-->`;
2385
+ return ssrHtml(
2386
+ `<!--${HYDRATE_STATIC_ID_COUNT_PREFIX}${markerToken}${idCount}-->` + children + `<!--${HYDRATE_STATIC_END}${endToken}-->`
2387
+ );
2294
2388
  } finally {
2295
2389
  finishNativeSeedCapture(nativeCapture, previousNativeReads, false);
2296
2390
  PERMANENT_STATIC_HYDRATE_DEPTH--;
@@ -2302,51 +2396,53 @@ const PermanentStaticHydrate = /* @__PURE__ */ markComponentFlags(
2302
2396
  const hydrate = /* @__PURE__ */ markComponentFlags(
2303
2397
  function Hydrate(props, scope) {
2304
2398
  const id = useId();
2305
- return withSsrElementContext(
2306
- "div",
2307
- void 0,
2308
- () => ssrInNamespace("html", () => {
2309
- if (!MARKERS) {
2310
- return "<div>" + ssrChildrenHtml(props.children, scope) + "</div>";
2311
- }
2312
- const childIdStart = ID_COUNTER;
2313
- const serialStart = SERIAL?.length ?? 0;
2314
- const nativeCapture = NATIVE_READ_COLLECTOR?.beginCapture() ?? -1;
2315
- const previousNativeReads = NATIVE_SERVER_READS;
2316
- if (nativeCapture < 0) NATIVE_SERVER_READS = null;
2317
- let children;
2318
- let nativeReads = null;
2319
- try {
2320
- children = ssrBlock(
2321
- ssrTry(
2322
- scope,
2323
- "jsx-hydrate",
2324
- (_arg, childScope) => ssrChildrenHtml(props.children, childScope),
2325
- null,
2326
- null,
2327
- "html"
2328
- )
2399
+ return ssrHtml(
2400
+ 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
+ )
2424
+ );
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)
2329
2437
  );
2330
- } finally {
2331
- nativeReads = finishNativeSeedCapture(nativeCapture, previousNativeReads, false);
2332
- }
2333
- const idCount = ID_COUNTER - childIdStart;
2334
- const childSeeds = SERIAL === null ? [] : SERIAL.splice(serialStart);
2335
- const permanentStaticAncestor = PERMANENT_STATIC_HYDRATE_DEPTH !== 0;
2336
- const attrs = ssrHydrateAttrs(
2337
- id,
2338
- props.when,
2339
- idCount,
2340
- permanentStaticAncestor,
2341
- streamTokenForPendingHtml(children)
2342
- );
2343
- const seedJson = permanentStaticAncestor || childSeeds.length === 0 ? null : serializeSuspenseSeedJson(childSeeds);
2344
- const seedSidecar = seedJson === null || seedJson === "[]" ? "" : '<script type="application/json" ' + HYDRATE_SEED_ATTR + NONCE_ATTR + ">" + seedJson + "</script>";
2345
- const nativeSeeds = permanentStaticAncestor ? void 0 : NATIVE_READ_COLLECTOR?.serialize(nativeReads);
2346
- const nativeSidecar = nativeSeeds === void 0 ? "" : serializeNativeSignalSeeds(nativeSeeds, NONCE_ATTR);
2347
- return "<div" + attrs + ">" + children + seedSidecar + nativeSidecar + "</div>";
2348
- }),
2349
- "html"
2438
+ const seedJson = permanentStaticAncestor || childSeeds.length === 0 ? null : serializeSuspenseSeedJson(childSeeds);
2439
+ const seedSidecar = seedJson === null || seedJson === "[]" ? "" : '<script type="application/json" ' + 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"
2445
+ )
2350
2446
  );
2351
2447
  },
2352
2448
  COMPONENT_FLAG_BOUNDARY,
@@ -2359,17 +2455,22 @@ function initializeHydrateComponent() {
2359
2455
  const Hydrate2 = /* @__PURE__ */ initializeHydrateComponent();
2360
2456
  const Suspense = /* @__PURE__ */ markComponentFlags(
2361
2457
  function Suspense2(props, scope) {
2362
- return ssrTry(
2363
- scope,
2364
- "jsx-suspense",
2365
- (_arg, s) => ssrChildrenHtml(props.children, s),
2366
- (_arg, s) => ssrChild(props.fallback, s),
2367
- null,
2368
- FRAME?.namespace ?? "html"
2458
+ return ssrHtml(
2459
+ ssrTry(
2460
+ scope,
2461
+ "jsx-suspense",
2462
+ (_arg, s) => ssrChildrenHtml(props.children, s),
2463
+ (_arg, s) => ssrChild(props.fallback, s),
2464
+ null,
2465
+ FRAME?.namespace ?? "html",
2466
+ false,
2467
+ true
2468
+ )
2369
2469
  );
2370
2470
  },
2371
2471
  COMPONENT_FLAG_BOUNDARY,
2372
- "Suspense"
2472
+ "Suspense",
2473
+ /* @__PURE__ */ Symbol.for("octane.suspense")
2373
2474
  );
2374
2475
  let VT_SSR_TRY_SEQ = 0;
2375
2476
  let VT_SSR_HAS_CANDIDATES = false;
@@ -2482,7 +2583,7 @@ const ViewTransition = /* @__PURE__ */ markComponentFlags(
2482
2583
  attrs.push(["vt-enter-x", vtSsrResolve(props, "enter")]);
2483
2584
  attrs.push(["vt-exit-x", vtSsrResolve(props, "exit")]);
2484
2585
  if (named) attrs.push(["vt-share", cand.share]);
2485
- return ssrBlock(vtSsrAnnotate(inner, attrs));
2586
+ return ssrHtml(ssrBlock(vtSsrAnnotate(inner, attrs)));
2486
2587
  },
2487
2588
  COMPONENT_FLAG_BOUNDARY,
2488
2589
  "ViewTransition"
@@ -2491,21 +2592,27 @@ function addTransitionType(_type) {
2491
2592
  }
2492
2593
  const ErrorBoundary = /* @__PURE__ */ markComponentFlags(
2493
2594
  function ErrorBoundary2(props, scope) {
2494
- return ssrBlock(
2495
- (() => {
2496
- try {
2497
- return withAsyncIdentity(
2498
- "error-boundary",
2499
- "content",
2500
- () => ssrBlock(ssrChildrenHtml(props.children, scope))
2501
- );
2502
- } catch (e) {
2503
- e = normalizeThrownServerThenable(e);
2504
- if (ssrIsSuspense(e)) throw e;
2505
- const fb = typeof props.fallback === "function" ? props.fallback(e, NOOP) : props.fallback;
2506
- return withAsyncIdentity("error-boundary", "catch", () => ssrBlock(ssrChild(fb, scope)));
2507
- }
2508
- })()
2595
+ return ssrHtml(
2596
+ ssrBlock(
2597
+ (() => {
2598
+ try {
2599
+ return withAsyncIdentity(
2600
+ "error-boundary",
2601
+ "content",
2602
+ () => ssrBlock(ssrChildrenHtml(props.children, scope))
2603
+ );
2604
+ } catch (e) {
2605
+ e = normalizeThrownServerThenable(e);
2606
+ if (ssrIsSuspense(e)) throw e;
2607
+ const fb = typeof props.fallback === "function" ? props.fallback(e, NOOP) : props.fallback;
2608
+ return withAsyncIdentity(
2609
+ "error-boundary",
2610
+ "catch",
2611
+ () => ssrBlock(ssrChild(fb, scope))
2612
+ );
2613
+ }
2614
+ })()
2615
+ )
2509
2616
  );
2510
2617
  },
2511
2618
  COMPONENT_FLAG_BOUNDARY,
@@ -2514,7 +2621,7 @@ const ErrorBoundary = /* @__PURE__ */ markComponentFlags(
2514
2621
  const CONTEXT_TAG = /* @__PURE__ */ Symbol.for("octane.context");
2515
2622
  function createContext(defaultValue) {
2516
2623
  const ctx = function ProviderBody(props, scope) {
2517
- return renderServerContextProvider(ctx, props, scope);
2624
+ return ssrHtml(renderServerContextProvider(ctx, props, scope));
2518
2625
  };
2519
2626
  ctx.$$kind = CONTEXT_TAG;
2520
2627
  ctx.defaultValue = defaultValue;
@@ -2542,7 +2649,7 @@ function renderServerContextProvider(context, props, renderScope) {
2542
2649
  scope.$$ctxValues.set(context, props.value);
2543
2650
  const children = props.children;
2544
2651
  if (children == null) return "";
2545
- return typeof children === "function" ? children(void 0, scope) ?? "" : ssrChild(children, scope);
2652
+ return ssrHtml(ssrChildrenHtml(children, scope));
2546
2653
  }
2547
2654
  function readContext(ctx) {
2548
2655
  for (let s = CURRENT_SCOPE; s !== null; s = s.parent) {
@@ -2737,6 +2844,11 @@ function hasExternalHydrationOwner(thenable) {
2737
2844
  }
2738
2845
  }
2739
2846
  function use(usable, siteKey, directSite) {
2847
+ if (process.env.NODE_ENV !== "production" && devMemoComputeDepth !== 0) {
2848
+ console.error(
2849
+ "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."
2850
+ );
2851
+ }
2740
2852
  if (usable && usable.$$kind === CONTEXT_TAG) {
2741
2853
  recordSkippedHydrationSite(SERIAL, directSite);
2742
2854
  return readContext(usable);
@@ -3119,18 +3231,21 @@ function resolveLazyModule(mod) {
3119
3231
  }
3120
3232
  return comp;
3121
3233
  }
3122
- function callLazyComponent(mod, props, scope, extra) {
3123
- const comp = resolveLazyModule(mod);
3124
- return comp(lazyResolvedProps(comp, props), scope, extra);
3125
- }
3126
3234
  function lazy(load) {
3127
3235
  let status = "uninitialized";
3128
3236
  let result = null;
3129
3237
  let promise = null;
3130
3238
  const key = "|lazy#" + LAZY_ID++;
3239
+ let displayName;
3240
+ let resolvedName = "Lazy";
3241
+ const callResolved = (props, scope, extra) => {
3242
+ const comp = resolveLazyModule(result);
3243
+ resolvedName = comp.displayName || comp.name || "Lazy";
3244
+ return comp(lazyResolvedProps(comp, props), scope, extra);
3245
+ };
3131
3246
  const lazyWrapper = (props, scope, extra) => {
3132
3247
  if (status === "fulfilled") {
3133
- return callLazyComponent(result, props, scope, extra);
3248
+ return callResolved(props, scope, extra);
3134
3249
  }
3135
3250
  if (status === "rejected") throw result;
3136
3251
  if (status === "uninitialized") {
@@ -3158,7 +3273,7 @@ function lazy(load) {
3158
3273
  if (status === "uninitialized") status = "pending";
3159
3274
  const settledStatus = status;
3160
3275
  if (settledStatus === "fulfilled") {
3161
- return callLazyComponent(result, props, scope, extra);
3276
+ return callResolved(props, scope, extra);
3162
3277
  }
3163
3278
  if (settledStatus === "rejected") throw result;
3164
3279
  }
@@ -3175,11 +3290,22 @@ function lazy(load) {
3175
3290
  }
3176
3291
  throw SSR_SUSPENSE;
3177
3292
  };
3178
- Object.defineProperty(lazyWrapper, LAZY_COMPONENT, { value: true });
3293
+ Object.defineProperty(lazyWrapper, LAZY_COMPONENT, {
3294
+ get() {
3295
+ return this === lazyWrapper;
3296
+ }
3297
+ });
3298
+ Object.defineProperty(lazyWrapper, "displayName", {
3299
+ configurable: true,
3300
+ get: () => displayName ?? resolvedName,
3301
+ set: (value) => {
3302
+ displayName = value;
3303
+ }
3304
+ });
3179
3305
  return lazyWrapper;
3180
3306
  }
3181
3307
  function useState(initial, slot) {
3182
- if (slot === void 0 && typeof initial === "symbol") {
3308
+ if (slot === void 0 && typeof initial === "symbol" && arguments.length === 1 && (HOOK_SLOT_PATH.length === 0 || MANUAL_HOOK_DRIVER?.active === true)) {
3183
3309
  slot = initial;
3184
3310
  initial = void 0;
3185
3311
  }
@@ -3190,7 +3316,7 @@ function useState(initial, slot) {
3190
3316
  );
3191
3317
  }
3192
3318
  function __useStateWithGetter(initial, slot) {
3193
- if (slot === void 0 && typeof initial === "symbol") {
3319
+ if (slot === void 0 && typeof initial === "symbol" && arguments.length === 1 && (HOOK_SLOT_PATH.length === 0 || MANUAL_HOOK_DRIVER?.active === true)) {
3194
3320
  slot = initial;
3195
3321
  initial = void 0;
3196
3322
  }
@@ -3282,30 +3408,43 @@ const useLayoutEffect = useEffect;
3282
3408
  const useInsertionEffect = useEffect;
3283
3409
  function useImperativeHandle() {
3284
3410
  }
3411
+ let devMemoComputeDepth = 0;
3285
3412
  function memoHookValue(input, compute, depsOrSlot, maybeSlot) {
3286
3413
  const deps = Array.isArray(depsOrSlot) ? depsOrSlot : null;
3287
3414
  const slot = maybeSlot ?? (Array.isArray(depsOrSlot) || depsOrSlot === null ? void 0 : depsOrSlot);
3288
3415
  if (deps === null) return compute ? input() : input;
3289
3416
  const position = hookPosition(slot);
3290
- if (position === null) return compute ? input() : input;
3417
+ if (position === null)
3418
+ return compute ? input(...deps) : input;
3291
3419
  let rec = position.list[position.index];
3292
3420
  if (rec === void 0) {
3293
- rec = { value: compute ? input() : input, deps: deps.slice() };
3421
+ rec = {
3422
+ value: compute ? input(...deps) : input,
3423
+ deps: deps.slice()
3424
+ };
3294
3425
  position.list[position.index] = rec;
3295
3426
  } else if (!serverDepsEqual(rec.deps, deps)) {
3296
- rec.value = compute ? input() : input;
3427
+ rec.value = compute ? input(...deps) : input;
3297
3428
  rec.deps = deps.slice();
3298
3429
  }
3299
3430
  return rec.value;
3300
3431
  }
3301
3432
  function useMemo(compute, depsOrSlot, maybeSlot) {
3433
+ if (process.env.NODE_ENV !== "production") {
3434
+ devMemoComputeDepth++;
3435
+ try {
3436
+ return memoHookValue(compute, true, depsOrSlot, maybeSlot);
3437
+ } finally {
3438
+ devMemoComputeDepth--;
3439
+ }
3440
+ }
3302
3441
  return memoHookValue(compute, true, depsOrSlot, maybeSlot);
3303
3442
  }
3304
3443
  function useCallback(fn, depsOrSlot, maybeSlot) {
3305
3444
  return memoHookValue(fn, false, depsOrSlot, maybeSlot);
3306
3445
  }
3307
3446
  function useRef(initial, slot) {
3308
- if (slot === void 0 && typeof initial === "symbol") {
3447
+ if (slot === void 0 && typeof initial === "symbol" && arguments.length === 1 && (HOOK_SLOT_PATH.length === 0 || MANUAL_HOOK_DRIVER?.active === true)) {
3309
3448
  slot = initial;
3310
3449
  initial = void 0;
3311
3450
  }
@@ -3345,20 +3484,102 @@ function useActionState(_action, initialState) {
3345
3484
  return [initialState, NOOP, false];
3346
3485
  }
3347
3486
  function useFormStatus() {
3348
- return { pending: false, data: null, method: "get", action: null };
3487
+ return { pending: false, data: null, method: null, action: null };
3349
3488
  }
3350
3489
  function useOptimistic(state) {
3351
3490
  return [state, NOOP];
3352
3491
  }
3353
3492
  function memo(component) {
3493
+ const memoWrapper = (props, scope, extra) => component(props, scope, extra);
3494
+ Object.defineProperty(memoWrapper, "type", { value: component });
3495
+ Object.defineProperty(memoWrapper, "displayName", {
3496
+ configurable: true,
3497
+ writable: true,
3498
+ value: component.displayName || component.name || "Memo"
3499
+ });
3500
+ Object.defineProperty(memoWrapper, "__memo", {
3501
+ get() {
3502
+ return this === memoWrapper;
3503
+ }
3504
+ });
3505
+ Object.defineProperty(memoWrapper, "defaultProps", {
3506
+ configurable: true,
3507
+ get: () => component.defaultProps,
3508
+ set: (value) => {
3509
+ component.defaultProps = value;
3510
+ }
3511
+ });
3512
+ return memoWrapper;
3513
+ }
3514
+ function markWarm(component, plan) {
3515
+ Object.defineProperty(component, "__warm", {
3516
+ configurable: true,
3517
+ get() {
3518
+ return this === component ? plan : void 0;
3519
+ }
3520
+ });
3354
3521
  return component;
3355
3522
  }
3523
+ let MANUAL_HOOK_DRIVER = null;
3524
+ function invokeManualHook(fn, receiver, args) {
3525
+ const driver = MANUAL_HOOK_DRIVER ??= {
3526
+ pending: HOOK_SLOT_PATH[HOOK_SLOT_PATH.length - 1],
3527
+ active: false
3528
+ };
3529
+ const pending = driver.pending;
3530
+ const active = driver.active;
3531
+ driver.pending = void 0;
3532
+ driver.active = true;
3533
+ try {
3534
+ if (pending === void 0) return Reflect.apply(fn, receiver, args);
3535
+ switch (args.length) {
3536
+ case 0:
3537
+ return fn.call(receiver, pending);
3538
+ case 1:
3539
+ return fn.call(receiver, args[0], pending);
3540
+ case 2:
3541
+ return fn.call(receiver, args[0], args[1], pending);
3542
+ case 3:
3543
+ return fn.call(receiver, args[0], args[1], args[2], pending);
3544
+ case 4:
3545
+ return fn.call(receiver, args[0], args[1], args[2], args[3], pending);
3546
+ default: {
3547
+ const forwarded = new Array(args.length + 1);
3548
+ for (let index = 0; index < args.length; index++) forwarded[index] = args[index];
3549
+ forwarded[args.length] = pending;
3550
+ return fn.apply(receiver, forwarded);
3551
+ }
3552
+ }
3553
+ } finally {
3554
+ driver.pending = pending;
3555
+ driver.active = active;
3556
+ }
3557
+ }
3558
+ function manualHook(fn, name) {
3559
+ function provider() {
3560
+ return invokeManualHook(fn, this, arguments);
3561
+ }
3562
+ Object.defineProperty(provider, "name", { value: name ?? fn.name, configurable: true });
3563
+ Object.defineProperty(provider, "length", { value: fn.length, configurable: true });
3564
+ return provider;
3565
+ }
3356
3566
  function withSlot(sym, fn, ...args) {
3567
+ const driver = MANUAL_HOOK_DRIVER;
3568
+ const pending = driver?.pending;
3569
+ const active = driver?.active ?? false;
3570
+ if (driver !== null) {
3571
+ driver.pending = sym;
3572
+ driver.active = false;
3573
+ }
3357
3574
  HOOK_SLOT_PATH.push(sym);
3358
3575
  try {
3359
3576
  return fn(...args);
3360
3577
  } finally {
3361
3578
  HOOK_SLOT_PATH.pop();
3579
+ if (MANUAL_HOOK_DRIVER !== null) {
3580
+ MANUAL_HOOK_DRIVER.pending = driver === null ? HOOK_SLOT_PATH[HOOK_SLOT_PATH.length - 1] : pending;
3581
+ MANUAL_HOOK_DRIVER.active = active;
3582
+ }
3362
3583
  }
3363
3584
  }
3364
3585
  function startTransition(fn) {
@@ -3383,6 +3604,28 @@ function isChildrenBlock(value) {
3383
3604
  function injectStyle(id, css, nonce) {
3384
3605
  if (CSS !== null) CSS.set(id, nonce === void 0 ? { css } : { css, nonce });
3385
3606
  }
3607
+ function styleMap(id, css, map, applied = []) {
3608
+ let touching = false;
3609
+ const touch = () => {
3610
+ if (CSS === null || touching) return;
3611
+ touching = true;
3612
+ try {
3613
+ for (const dependency of applied) touchStyleMap(dependency);
3614
+ if (id !== null && css !== null) injectStyle(id, css);
3615
+ } finally {
3616
+ touching = false;
3617
+ }
3618
+ };
3619
+ return new Proxy(map, {
3620
+ get(target, key, receiver) {
3621
+ touch();
3622
+ return Reflect.get(target, key, receiver);
3623
+ }
3624
+ });
3625
+ }
3626
+ function touchStyleMap(map) {
3627
+ if (map !== null && typeof map === "object") void map.$class;
3628
+ }
3386
3629
  const HEAD_VOID_ELEMENTS = /* @__PURE__ */ new Set(["meta", "link", "base"]);
3387
3630
  function ssrHeadEl(key, tag, attrs, text) {
3388
3631
  if (HEAD === null || FALLBACK_HOIST_DEPTH !== 0) return "";
@@ -3435,11 +3678,20 @@ function namespaceHeadElement(headKey, tag, attrs, text, authoredKey) {
3435
3678
  return createElement(namespaceHead, config);
3436
3679
  }
3437
3680
  function spliceHead(body, head) {
3438
- if (head === "") return body;
3681
+ if (head === "" && !isDocumentRoot(body)) return body;
3439
3682
  const headClose = body.indexOf("</head>");
3440
3683
  if (headClose !== -1) return body.slice(0, headClose) + head + body.slice(headClose);
3684
+ if (isDocumentRoot(body)) {
3685
+ const openingEnd = documentTagEnd(body, body.indexOf("<html") + 5);
3686
+ if (openingEnd !== -1)
3687
+ return body.slice(0, openingEnd) + "<head>" + head + "</head>" + body.slice(openingEnd);
3688
+ }
3689
+ if (head === "") return body;
3441
3690
  return head + body;
3442
3691
  }
3692
+ function renderEntryValue(props, scope) {
3693
+ return ssrHtml(ssrChild(props.value, scope));
3694
+ }
3443
3695
  const MAX_SUSPENSE_PASSES = 50;
3444
3696
  let SUSPENSE_TIMEOUT_MS = 1e4;
3445
3697
  function setSsrSuspenseTimeout(ms) {
@@ -3706,7 +3958,7 @@ function runFullFramedPass(component, props, resolved, nonceAttr = "", identifie
3706
3958
  const nativeToken = NATIVE_READ_COLLECTOR === null ? -1 : beginActiveNativeReadScope(root);
3707
3959
  try {
3708
3960
  const out = invokeComponentBody(component, props, root, FRAME);
3709
- body = typeof out === "string" ? out : out == null ? "" : ssrChild(out, root);
3961
+ body = serverComponentOutput(out, root);
3710
3962
  nativePassCompleted = true;
3711
3963
  } catch (err) {
3712
3964
  err = normalizeThrownServerThenable(err);
@@ -3722,6 +3974,14 @@ function runFullFramedPass(component, props, resolved, nonceAttr = "", identifie
3722
3974
  restoreAmbient(saved);
3723
3975
  }
3724
3976
  }
3977
+ if (resolved.bufferedErrors !== void 0) {
3978
+ for (const report of resolved.bufferedErrors.values()) {
3979
+ if (!report.reported) {
3980
+ report.reported = true;
3981
+ resolved.resourceOptions?.onError?.(report.error);
3982
+ }
3983
+ }
3984
+ }
3725
3985
  let css = "";
3726
3986
  for (const [hash, sheet] of cssMap) {
3727
3987
  css += '<style data-octane="' + hash + '"' + (sheet.nonce === void 0 ? nonceAttr : ' nonce="' + escapeAttr(sheet.nonce) + '"') + ">" + escapeEntireInlineStyleContent(sheet.css) + "</style>";
@@ -3999,7 +4259,11 @@ function passToResult(pass, nonceAttr, separateHead = false) {
3999
4259
  return result;
4000
4260
  }
4001
4261
  async function prerender(entryComponent, props, options) {
4002
- const component = entryComponent;
4262
+ const component = typeof entryComponent === "function" ? entryComponent : renderEntryValue;
4263
+ if (typeof entryComponent !== "function") {
4264
+ options ??= props;
4265
+ props = { value: entryComponent };
4266
+ }
4003
4267
  const nonceAttr = nonceAttrOf(options);
4004
4268
  const resolved = newResolvedMap(options ?? null);
4005
4269
  try {
@@ -4013,6 +4277,10 @@ async function prerender(entryComponent, props, options) {
4013
4277
  }
4014
4278
  }
4015
4279
  async function prerenderToNodeStream(entryComponent, props, options) {
4280
+ if (typeof entryComponent !== "function" && options === void 0) {
4281
+ options = props;
4282
+ props = void 0;
4283
+ }
4016
4284
  let resolved = options;
4017
4285
  if (options?.headChannel === "separate") {
4018
4286
  if (process.env.NODE_ENV !== "production") {
@@ -4097,7 +4365,11 @@ function renderHostedAttempt(session, component, props, options) {
4097
4365
  return { status: "complete", html: body, head: pass.head, cssEntries: pass.cssEntries };
4098
4366
  }
4099
4367
  function renderToString(entryComponent, props, options) {
4100
- const component = entryComponent;
4368
+ const component = typeof entryComponent === "function" ? entryComponent : renderEntryValue;
4369
+ if (typeof entryComponent !== "function") {
4370
+ options ??= props;
4371
+ props = { value: entryComponent };
4372
+ }
4101
4373
  options?.signal?.throwIfAborted();
4102
4374
  const nonceAttr = nonceAttrOf(options);
4103
4375
  const resolved = newResolvedMap(options ?? null);
@@ -4107,6 +4379,7 @@ function renderToString(entryComponent, props, options) {
4107
4379
  null,
4108
4380
  () => runFullFramedPass(component, props, resolved, nonceAttr, options?.identifierPrefix ?? "")
4109
4381
  );
4382
+ if (pass.rootSuspended) throw new Error(formatServerError(60));
4110
4383
  } catch (err) {
4111
4384
  options?.onError?.(err);
4112
4385
  throw err;
@@ -4116,7 +4389,11 @@ function renderToString(entryComponent, props, options) {
4116
4389
  return passToResult(pass, nonceAttr, options?.headChannel === "separate");
4117
4390
  }
4118
4391
  function renderToStaticMarkup(entryComponent, props, options) {
4119
- const component = entryComponent;
4392
+ const component = typeof entryComponent === "function" ? entryComponent : renderEntryValue;
4393
+ if (typeof entryComponent !== "function") {
4394
+ options ??= props;
4395
+ props = { value: entryComponent };
4396
+ }
4120
4397
  options?.signal?.throwIfAborted();
4121
4398
  const nonceAttr = nonceAttrOf(options);
4122
4399
  const resolved = newResolvedMap(options ?? null);
@@ -4133,6 +4410,7 @@ function renderToStaticMarkup(entryComponent, props, options) {
4133
4410
  false
4134
4411
  )
4135
4412
  );
4413
+ if (pass.rootSuspended) throw new Error(formatServerError(60));
4136
4414
  } catch (err) {
4137
4415
  options?.onError?.(err);
4138
4416
  throw err;
@@ -4226,7 +4504,7 @@ function pruneStreamBoundariesAbsentFromShell(stream, shellBoundaryKeys) {
4226
4504
  if (!shellBoundaryKeys.has(key)) stream.boundaries.delete(key);
4227
4505
  }
4228
4506
  }
4229
- function ssrTry(scope, siteKey, tryFn, pendFn, catchFn, namespace = FRAME?.namespace ?? "html", propagateSuspense = false) {
4507
+ function ssrTry(scope, siteKey, tryFn, pendFn, catchFn, namespace = FRAME?.namespace ?? "html", propagateSuspense = false, recoverErrors = false) {
4230
4508
  VT_SSR_TRY_SEQ++;
4231
4509
  let vtOuter = null;
4232
4510
  if (VT_SSR_STACK.length > 0) {
@@ -4579,6 +4857,13 @@ function ssrTry(scope, siteKey, tryFn, pendFn, catchFn, namespace = FRAME?.names
4579
4857
  pruneUnrepresentedStreamDescendants(stream, key, fallback);
4580
4858
  return fallback;
4581
4859
  }
4860
+ if (recoverErrors && pendFn !== null && PERMANENT_STATIC_HYDRATE_DEPTH === 0) {
4861
+ if (SERIAL !== null) SERIAL.length = serialStart;
4862
+ const reports = RESOLVED?.bufferedErrors ?? (RESOLVED.bufferedErrors = /* @__PURE__ */ new Map());
4863
+ if (!reports.has(key)) reports.set(key, { error: e, reported: false });
4864
+ nativeFresh = true;
4865
+ return pendingForm();
4866
+ }
4582
4867
  throw e;
4583
4868
  }
4584
4869
  } finally {
@@ -4620,19 +4905,22 @@ function documentHeadInsertionPoint(body) {
4620
4905
  const next = body.charCodeAt(start + 5);
4621
4906
  if (next === 62) return start + 6;
4622
4907
  if (next === 32 || next === 9 || next === 10 || next === 13) {
4623
- let quote = 0;
4624
- for (let i = start + 6; i < body.length; i++) {
4625
- const code = body.charCodeAt(i);
4626
- if (quote !== 0) {
4627
- if (code === quote) quote = 0;
4628
- } else if (code === 34 || code === 39) quote = code;
4629
- else if (code === 62) return i + 1;
4630
- }
4631
- return -1;
4908
+ return documentTagEnd(body, start + 6);
4632
4909
  }
4633
4910
  searchFrom = start + 5;
4634
4911
  }
4635
4912
  }
4913
+ function documentTagEnd(body, from) {
4914
+ let quote = 0;
4915
+ for (let i = from; i < body.length; i++) {
4916
+ const code = body.charCodeAt(i);
4917
+ if (quote !== 0) {
4918
+ if (code === quote) quote = 0;
4919
+ } else if (code === 34 || code === 39) quote = code;
4920
+ else if (code === 62) return i + 1;
4921
+ }
4922
+ return -1;
4923
+ }
4636
4924
  function segmentChunk(b, nonceAttr) {
4637
4925
  let seedScript = "";
4638
4926
  if (b.seeds.length > 0) {
@@ -4691,19 +4979,30 @@ async function runStream(component, props, options, sink, resolved) {
4691
4979
  };
4692
4980
  const injection = options?.injection;
4693
4981
  if (injection !== void 0) injection.done.then(NOOP, NOOP);
4982
+ let injectionCompleted = false;
4983
+ const completeInjection = injection === void 0 ? NOOP : () => {
4984
+ if (injectionCompleted) return;
4985
+ injectionCompleted = true;
4986
+ injection.renderComplete?.();
4987
+ };
4694
4988
  let injectionUnsubscribe;
4695
4989
  let injectionFailure;
4696
4990
  let injectionFailed = false;
4991
+ const unacceptedInjection = injection === void 0 ? void 0 : [];
4992
+ const rememberUnaccepted = injection === void 0 ? NOOP : (chunk) => {
4993
+ unacceptedInjection.push(chunk);
4994
+ };
4697
4995
  let signalInjectionFailure;
4698
4996
  const failInjection = (err) => {
4997
+ if (signal?.aborted && err === signal.reason) return;
4699
4998
  if (injectionFailed) return;
4700
4999
  injectionFailed = true;
4701
5000
  injectionFailure = err;
4702
5001
  signalInjectionFailure?.();
4703
5002
  };
4704
5003
  let writeChain = injection === void 0 ? null : Promise.resolve();
4705
- const write = injection === void 0 ? (chunk, terminal) => sink.write(chunk, terminal) : (chunk, terminal) => {
4706
- const operation = writeChain.then(() => sink.write(chunk, terminal));
5004
+ const write = injection === void 0 ? (chunk, terminal) => sink.write(chunk, terminal) : (chunk, terminal, onUnaccepted) => {
5005
+ const operation = writeChain.then(() => sink.write(chunk, terminal, onUnaccepted));
4707
5006
  writeChain = operation.then(NOOP, NOOP);
4708
5007
  return operation;
4709
5008
  };
@@ -4717,11 +5016,34 @@ async function runStream(component, props, options, sink, resolved) {
4717
5016
  return;
4718
5017
  }
4719
5018
  if (!html) return;
4720
- return write(html);
5019
+ return write(html, false, rememberUnaccepted);
5020
+ };
5021
+ const recoveryInjection = injection === void 0 ? void 0 : async () => {
5022
+ if (signal?.aborted) {
5023
+ await writeChain;
5024
+ for (const html of unacceptedInjection) {
5025
+ const replay = write(html, "recovery");
5026
+ if (replay !== void 0) await replay;
5027
+ }
5028
+ unacceptedInjection.length = 0;
5029
+ }
5030
+ if (injectionFailed) return "";
5031
+ let queued;
5032
+ try {
5033
+ queued = injection.take();
5034
+ } catch {
5035
+ return "";
5036
+ }
5037
+ if (queued !== "" && signal?.aborted) {
5038
+ const replay = write(queued, "recovery");
5039
+ if (replay !== void 0) await replay;
5040
+ return "";
5041
+ }
5042
+ return queued;
4721
5043
  };
4722
5044
  const notifyInjection = () => {
4723
5045
  const drained = drainInjection();
4724
- if (drained !== void 0) drained.catch(NOOP);
5046
+ if (drained !== void 0) drained.catch(failInjection);
4725
5047
  };
4726
5048
  const waitForInjectionDone = () => new Promise((resolve, reject) => {
4727
5049
  let settled = false;
@@ -4824,12 +5146,24 @@ async function runStream(component, props, options, sink, resolved) {
4824
5146
  }
4825
5147
  pruneStreamBoundariesAbsentFromShell(stream, shellBoundaryKeys);
4826
5148
  } catch (err) {
5149
+ try {
5150
+ completeInjection();
5151
+ } catch {
5152
+ }
4827
5153
  const reports = signal?.aborted ? Math.max(1, preShellSuspended.length) : 1;
4828
5154
  for (let i = 0; i < reports; i++) options?.onError?.(err);
4829
5155
  sink.shellError(err);
4830
5156
  return;
4831
5157
  }
4832
- reportRecoverableBoundaryErrors();
5158
+ try {
5159
+ reportRecoverableBoundaryErrors();
5160
+ } catch (err) {
5161
+ try {
5162
+ completeInjection();
5163
+ } catch {
5164
+ }
5165
+ throw err;
5166
+ }
4833
5167
  if (pass.sheets !== null) for (const key of pass.sheets.keys()) flushedSheets.add(key);
4834
5168
  let leadingStyles = "";
4835
5169
  for (const [hash, sheet] of pass.cssEntries) {
@@ -4837,7 +5171,17 @@ async function runStream(component, props, options, sink, resolved) {
4837
5171
  leadingStyles += '<style data-octane="' + hash + '"' + (sheet.nonce === void 0 ? nonceAttr : ' nonce="' + escapeAttr(sheet.nonce) + '"') + ">" + escapeEntireInlineStyleContent(sheet.css) + "</style>";
4838
5172
  }
4839
5173
  const separateHead = options?.headChannel === "separate";
4840
- if (separateHead) options?.onHeadReady?.(pass.vtCandidates ? vtSsrStrip(pass.head) : pass.head);
5174
+ if (separateHead) {
5175
+ try {
5176
+ options?.onHeadReady?.(pass.vtCandidates ? vtSsrStrip(pass.head) : pass.head);
5177
+ } catch (err) {
5178
+ try {
5179
+ completeInjection();
5180
+ } catch {
5181
+ }
5182
+ throw err;
5183
+ }
5184
+ }
4841
5185
  const shellHead = separateHead ? "" : pass.head;
4842
5186
  const documentRoot = isDocumentRoot(pass.body);
4843
5187
  let shell = documentRoot ? "<!DOCTYPE html>" : "";
@@ -4846,14 +5190,14 @@ async function runStream(component, props, options, sink, resolved) {
4846
5190
  const tailStart = documentTailStart(pass.body);
4847
5191
  if (tailStart !== -1) {
4848
5192
  heldDocumentTail = pass.body.slice(tailStart);
4849
- const bodyHtml = pass.body.slice(0, tailStart);
5193
+ const bodyHtml = spliceHead(pass.body.slice(0, tailStart), "");
4850
5194
  const headInsert = documentHeadInsertionPoint(bodyHtml);
4851
5195
  shell += headInsert !== -1 ? bodyHtml.slice(0, headInsert) + leadingStyles + shellHead + bodyHtml.slice(headInsert) : leadingStyles + shellHead + bodyHtml;
4852
5196
  } else {
4853
- shell += leadingStyles + shellHead + pass.body;
5197
+ shell += spliceHead(pass.body, leadingStyles + shellHead);
4854
5198
  }
4855
5199
  } else {
4856
- shell += leadingStyles + shellHead + pass.body;
5200
+ shell += documentRoot ? spliceHead(pass.body, leadingStyles + shellHead) : leadingStyles + shellHead + pass.body;
4857
5201
  }
4858
5202
  if (pass.serial.length > 0) shell += serializeSuspenseSeeds(pass.serial, nonceAttr);
4859
5203
  if (pass.signals !== void 0) shell += serializeNativeSignalSeeds(pass.signals, nonceAttr);
@@ -4864,11 +5208,23 @@ async function runStream(component, props, options, sink, resolved) {
4864
5208
  const shellWrite = write(pass.vtCandidates ? vtSsrStrip(shell) : shell);
4865
5209
  if (shellWrite !== void 0) await shellWrite;
4866
5210
  } catch (err) {
5211
+ try {
5212
+ completeInjection();
5213
+ } catch {
5214
+ }
4867
5215
  options?.onError?.(err);
4868
5216
  sink.shellError(err);
4869
5217
  return;
4870
5218
  }
4871
- sink.shellReady();
5219
+ try {
5220
+ sink.shellReady();
5221
+ } catch (err) {
5222
+ try {
5223
+ completeInjection();
5224
+ } catch {
5225
+ }
5226
+ throw err;
5227
+ }
4872
5228
  if (injection !== void 0) {
4873
5229
  try {
4874
5230
  injectionUnsubscribe = injection.subscribe(notifyInjection);
@@ -4958,14 +5314,14 @@ async function runStream(component, props, options, sink, resolved) {
4958
5314
  injectionUnsubscribe?.();
4959
5315
  injectionUnsubscribe = void 0;
4960
5316
  try {
4961
- injection.renderComplete?.();
5317
+ completeInjection();
4962
5318
  } catch {
4963
5319
  }
4964
5320
  }
4965
5321
  let tail = "";
4966
- if (injection !== void 0 && !injectionFailed) {
5322
+ if (recoveryInjection !== void 0) {
4967
5323
  try {
4968
- tail += injection.take();
5324
+ tail = await recoveryInjection();
4969
5325
  } catch {
4970
5326
  }
4971
5327
  }
@@ -4985,7 +5341,7 @@ async function runStream(component, props, options, sink, resolved) {
4985
5341
  }
4986
5342
  if (injection !== void 0) {
4987
5343
  try {
4988
- injection.renderComplete?.();
5344
+ completeInjection();
4989
5345
  } catch (err) {
4990
5346
  failInjection(err);
4991
5347
  }
@@ -4993,11 +5349,14 @@ async function runStream(component, props, options, sink, resolved) {
4993
5349
  await waitForInjectionDone();
4994
5350
  const finalDrain = drainInjection();
4995
5351
  if (finalDrain !== void 0) await finalDrain;
5352
+ await writeChain;
4996
5353
  if (injectionFailed) throw injectionFailure;
4997
5354
  if (heldDocumentTail !== "") {
4998
5355
  const tailChunk = heldDocumentTail;
4999
5356
  heldDocumentTail = "";
5000
- const tailWrite = write(tailChunk);
5357
+ const tailWrite = write(tailChunk, false, (unaccepted) => {
5358
+ heldDocumentTail = unaccepted;
5359
+ });
5001
5360
  if (tailWrite !== void 0) await tailWrite;
5002
5361
  }
5003
5362
  } catch (err) {
@@ -5005,11 +5364,9 @@ async function runStream(component, props, options, sink, resolved) {
5005
5364
  injectionUnsubscribe?.();
5006
5365
  injectionUnsubscribe = void 0;
5007
5366
  let terminal = "";
5008
- if (!injectionFailed) {
5009
- try {
5010
- terminal = injection.take();
5011
- } catch {
5012
- }
5367
+ try {
5368
+ terminal = await recoveryInjection();
5369
+ } catch {
5013
5370
  }
5014
5371
  terminal += heldDocumentTail;
5015
5372
  if (terminal !== "") {
@@ -5027,7 +5384,11 @@ async function runStream(component, props, options, sink, resolved) {
5027
5384
  sink.allReady();
5028
5385
  }
5029
5386
  function renderToPipeableStream(entryComponent, props, options) {
5030
- const component = entryComponent;
5387
+ const component = typeof entryComponent === "function" ? entryComponent : renderEntryValue;
5388
+ if (typeof entryComponent !== "function") {
5389
+ options ??= props;
5390
+ props = { value: entryComponent };
5391
+ }
5031
5392
  const controller = new AbortController();
5032
5393
  let removeOuterAbort;
5033
5394
  if (options?.signal) {
@@ -5046,6 +5407,7 @@ function renderToPipeableStream(entryComponent, props, options) {
5046
5407
  let endCalled = false;
5047
5408
  let pipeCalled = false;
5048
5409
  let writeGate = null;
5410
+ let shellFailure = null;
5049
5411
  const destinationFailure = (reason) => {
5050
5412
  if (closed) return;
5051
5413
  closed = true;
@@ -5059,12 +5421,18 @@ function renderToPipeableStream(entryComponent, props, options) {
5059
5421
  if (!ended || destination === null || writeGate !== null || endCalled || closed) return;
5060
5422
  endCalled = true;
5061
5423
  try {
5424
+ if (shellFailure !== null && destination.destroy !== void 0) {
5425
+ closed = true;
5426
+ destination.destroy(shellFailure.error);
5427
+ return;
5428
+ }
5062
5429
  destination.end();
5063
5430
  } catch (err) {
5064
5431
  destinationFailure(err);
5065
5432
  }
5066
5433
  };
5067
- const waitForDrain = (dest) => {
5434
+ const waitForDrain = (dest, allowAborted = false) => {
5435
+ if (allowAborted && closed) return Promise.reject(new Error(formatServerError(38)));
5068
5436
  if (dest.once === void 0) {
5069
5437
  return Promise.reject(new TypeError(formatServerError(39)));
5070
5438
  }
@@ -5100,14 +5468,17 @@ function renderToPipeableStream(entryComponent, props, options) {
5100
5468
  dest.once("drain", onDrain);
5101
5469
  dest.once("error", onError);
5102
5470
  dest.once("close", onClose);
5103
- if (controller.signal.aborted) onAbort();
5104
- else controller.signal.addEventListener("abort", onAbort, { once: true });
5471
+ if (!allowAborted) {
5472
+ if (controller.signal.aborted) onAbort();
5473
+ else controller.signal.addEventListener("abort", onAbort, { once: true });
5474
+ }
5105
5475
  });
5106
5476
  };
5107
- const writeNow = (chunk, terminal) => {
5477
+ const writeNow = (chunk, terminal, onUnaccepted) => {
5108
5478
  const dest = destination;
5109
5479
  if (closed) return Promise.reject(new Error(formatServerError(40)));
5110
- if (!terminal && controller.signal.aborted) {
5480
+ if (terminal === false && controller.signal.aborted) {
5481
+ onUnaccepted?.(chunk);
5111
5482
  return Promise.reject(controller.signal.reason);
5112
5483
  }
5113
5484
  let accepted;
@@ -5117,7 +5488,7 @@ function renderToPipeableStream(entryComponent, props, options) {
5117
5488
  destinationFailure(err);
5118
5489
  return Promise.reject(err);
5119
5490
  }
5120
- return accepted === false && !terminal ? waitForDrain(dest) : void 0;
5491
+ return accepted === false && terminal !== true ? waitForDrain(dest, terminal === "recovery") : void 0;
5121
5492
  };
5122
5493
  const trackWrite = (operation) => {
5123
5494
  const gate = operation.then(
@@ -5138,16 +5509,18 @@ function renderToPipeableStream(entryComponent, props, options) {
5138
5509
  });
5139
5510
  return operation;
5140
5511
  };
5141
- const queueWrite = (chunk, terminal = false) => {
5512
+ const queueWrite = (chunk, terminal = false, onUnaccepted) => {
5142
5513
  if (destination === null) {
5143
- buffered.push({ chunk, terminal });
5514
+ buffered.push(
5515
+ onUnaccepted === void 0 ? { chunk, terminal } : { chunk, terminal, onUnaccepted }
5516
+ );
5144
5517
  return;
5145
5518
  }
5146
5519
  if (writeGate !== null) {
5147
- const operation2 = writeGate.then(() => writeNow(chunk, terminal));
5520
+ const operation2 = writeGate.then(() => writeNow(chunk, terminal, onUnaccepted));
5148
5521
  return trackWrite(operation2);
5149
5522
  }
5150
- const operation = writeNow(chunk, terminal);
5523
+ const operation = writeNow(chunk, terminal, onUnaccepted);
5151
5524
  return operation === void 0 ? void 0 : trackWrite(operation);
5152
5525
  };
5153
5526
  const flushEnd = () => {
@@ -5167,14 +5540,15 @@ function renderToPipeableStream(entryComponent, props, options) {
5167
5540
  props,
5168
5541
  renderOptions,
5169
5542
  {
5170
- write(chunk, terminal) {
5171
- return queueWrite(chunk, terminal);
5543
+ write(chunk, terminal, onUnaccepted) {
5544
+ return queueWrite(chunk, terminal, onUnaccepted);
5172
5545
  },
5173
5546
  shellReady() {
5174
5547
  options?.onShellReady?.();
5175
5548
  },
5176
5549
  shellError(err) {
5177
5550
  releaseServerRenderResources(resolved);
5551
+ shellFailure = { error: err };
5178
5552
  options?.onShellError?.(err);
5179
5553
  flushEnd();
5180
5554
  },
@@ -5211,7 +5585,11 @@ function renderToPipeableStream(entryComponent, props, options) {
5211
5585
  });
5212
5586
  }
5213
5587
  for (const item of buffered) {
5214
- queueWrite(item.chunk, item.terminal || controller.signal.aborted);
5588
+ queueWrite(
5589
+ item.chunk,
5590
+ item.terminal === "recovery" ? "recovery" : item.terminal || controller.signal.aborted,
5591
+ item.onUnaccepted
5592
+ );
5215
5593
  }
5216
5594
  buffered.length = 0;
5217
5595
  finishEnd();
@@ -5223,7 +5601,11 @@ function renderToPipeableStream(entryComponent, props, options) {
5223
5601
  };
5224
5602
  }
5225
5603
  function renderToReadableStream(entryComponent, props, options) {
5226
- const component = entryComponent;
5604
+ const component = typeof entryComponent === "function" ? entryComponent : renderEntryValue;
5605
+ if (typeof entryComponent !== "function") {
5606
+ options ??= props;
5607
+ props = { value: entryComponent };
5608
+ }
5227
5609
  return new Promise((resolveShell, rejectShell) => {
5228
5610
  const encoder = new TextEncoder();
5229
5611
  const renderController = new AbortController();
@@ -5273,7 +5655,10 @@ function renderToReadableStream(entryComponent, props, options) {
5273
5655
  });
5274
5656
  stream.allReady = allReady;
5275
5657
  let shellDone = false;
5276
- const waitForDemand = () => new Promise((resolve, reject) => {
5658
+ let terminal = false;
5659
+ let released = false;
5660
+ let callbackFailure;
5661
+ const waitForDemand = (allowAborted = false) => new Promise((resolve, reject) => {
5277
5662
  let settled = false;
5278
5663
  const cleanup = () => {
5279
5664
  renderController.signal.removeEventListener("abort", onAbort);
@@ -5288,18 +5673,21 @@ function renderToReadableStream(entryComponent, props, options) {
5288
5673
  const onDemand = () => finish(resolve);
5289
5674
  const onAbort = () => finish(() => reject(renderController.signal.reason));
5290
5675
  wakeDemand = onDemand;
5291
- if (renderController.signal.aborted) onAbort();
5292
- else renderController.signal.addEventListener("abort", onAbort, { once: true });
5676
+ if (!allowAborted) {
5677
+ if (renderController.signal.aborted) onAbort();
5678
+ else renderController.signal.addEventListener("abort", onAbort, { once: true });
5679
+ }
5293
5680
  });
5294
- const writeReadable = (chunk, terminal = false) => {
5681
+ const writeReadable = (chunk, terminal2 = false, onUnaccepted) => {
5295
5682
  if (closed || consumerCancelled) {
5296
5683
  return Promise.reject(cancelReason ?? new Error(formatServerError(44)));
5297
5684
  }
5298
- if (!terminal && renderController.signal.aborted) {
5685
+ if (terminal2 === false && renderController.signal.aborted) {
5686
+ onUnaccepted?.(chunk);
5299
5687
  return Promise.reject(renderController.signal.reason);
5300
5688
  }
5301
5689
  const bytes = encoder.encode(chunk);
5302
- if (terminal) {
5690
+ if (terminal2 === true) {
5303
5691
  readableController.enqueue(bytes);
5304
5692
  return;
5305
5693
  }
@@ -5308,13 +5696,18 @@ function renderToReadableStream(entryComponent, props, options) {
5308
5696
  return;
5309
5697
  }
5310
5698
  return (async () => {
5311
- while ((readableController.desiredSize ?? 0) <= 0) {
5312
- await waitForDemand();
5313
- if (closed || consumerCancelled) {
5314
- throw cancelReason ?? new Error(formatServerError(44));
5699
+ try {
5700
+ while ((readableController.desiredSize ?? 0) <= 0) {
5701
+ await waitForDemand(terminal2 === "recovery");
5702
+ if (closed || consumerCancelled) {
5703
+ throw cancelReason ?? new Error(formatServerError(44));
5704
+ }
5315
5705
  }
5706
+ readableController.enqueue(bytes);
5707
+ } catch (err) {
5708
+ if (!consumerCancelled && renderController.signal.aborted) onUnaccepted?.(chunk);
5709
+ throw err;
5316
5710
  }
5317
- readableController.enqueue(bytes);
5318
5711
  })();
5319
5712
  };
5320
5713
  const closeReadable = () => {
@@ -5328,46 +5721,80 @@ function renderToReadableStream(entryComponent, props, options) {
5328
5721
  }
5329
5722
  };
5330
5723
  const renderOptions = { ...options, signal: renderController.signal };
5724
+ if (options?.onError !== void 0) {
5725
+ renderOptions.onError = (error) => {
5726
+ try {
5727
+ options.onError(error);
5728
+ } catch (err) {
5729
+ callbackFailure ??= { error: err };
5730
+ }
5731
+ };
5732
+ }
5331
5733
  const resolved = newResolvedMap(renderOptions);
5734
+ const release = () => {
5735
+ if (released) return;
5736
+ released = true;
5737
+ releaseServerRenderResources(resolved);
5738
+ };
5739
+ const settleFailure = (error) => {
5740
+ if (terminal) return;
5741
+ terminal = true;
5742
+ try {
5743
+ release();
5744
+ } catch (err) {
5745
+ error = err;
5746
+ }
5747
+ const reason = callbackFailure === void 0 ? error : callbackFailure.error;
5748
+ if (!shellDone) rejectShell(reason);
5749
+ allReadyReject(reason);
5750
+ closeReadable();
5751
+ };
5332
5752
  runStream(
5333
5753
  component,
5334
5754
  props,
5335
5755
  renderOptions,
5336
5756
  {
5337
- write(chunk, terminal) {
5338
- return writeReadable(chunk, terminal);
5757
+ write(chunk, terminal2, onUnaccepted) {
5758
+ return writeReadable(chunk, terminal2, onUnaccepted);
5339
5759
  },
5340
5760
  shellReady() {
5341
- shellDone = true;
5342
5761
  options?.onShellReady?.();
5762
+ shellDone = true;
5343
5763
  resolveShell(stream);
5344
5764
  },
5345
5765
  shellError(err) {
5346
- releaseServerRenderResources(resolved);
5347
- options?.onShellError?.(err);
5348
- if (!shellDone) rejectShell(err);
5349
- allReadyReject(err);
5350
- closeReadable();
5766
+ try {
5767
+ release();
5768
+ options?.onShellError?.(err);
5769
+ } catch (callbackError) {
5770
+ settleFailure(callbackError);
5771
+ return;
5772
+ }
5773
+ settleFailure(err);
5351
5774
  },
5352
5775
  allReady() {
5353
- releaseServerRenderResources(resolved);
5354
- options?.onAllReady?.();
5355
- allReadyResolve();
5776
+ if (terminal) return;
5777
+ try {
5778
+ release();
5779
+ options?.onAllReady?.();
5780
+ } catch (err) {
5781
+ renderOptions.onError?.(err);
5782
+ settleFailure(err);
5783
+ return;
5784
+ }
5785
+ terminal = true;
5786
+ if (callbackFailure === void 0) allReadyResolve();
5787
+ else allReadyReject(callbackFailure.error);
5356
5788
  closeReadable();
5357
5789
  },
5358
5790
  fatal(err) {
5359
- releaseServerRenderResources(resolved);
5360
- allReadyReject(err);
5361
- closeReadable();
5791
+ settleFailure(err);
5362
5792
  }
5363
5793
  },
5364
5794
  resolved
5365
5795
  ).catch((err) => {
5366
- releaseServerRenderResources(resolved);
5367
- options?.onError?.(err);
5368
- if (!shellDone) rejectShell(err);
5369
- allReadyReject(err);
5370
- closeReadable();
5796
+ renderOptions.onError?.(err);
5797
+ settleFailure(err);
5371
5798
  });
5372
5799
  });
5373
5800
  }
@@ -5672,11 +6099,14 @@ export {
5672
6099
  getSsrSuspenseTimeout,
5673
6100
  hookSlots,
5674
6101
  injectStyle,
6102
+ invokeManualHook,
5675
6103
  isChildrenBlock,
5676
6104
  isValidElement,
5677
6105
  lazy,
6106
+ manualHook,
5678
6107
  mapSlot,
5679
6108
  markChildrenBlock,
6109
+ markWarm,
5680
6110
  memo,
5681
6111
  namespaceHead,
5682
6112
  namespaceHeadElement,
@@ -5712,7 +6142,9 @@ export {
5712
6142
  ssrBlock,
5713
6143
  ssrCheckedAttr,
5714
6144
  ssrChild,
6145
+ ssrChildPre,
5715
6146
  ssrChildText,
6147
+ ssrChildTextPre,
5716
6148
  ssrChildrenSources,
5717
6149
  ssrClass,
5718
6150
  ssrComponent,
@@ -5723,6 +6155,7 @@ export {
5723
6155
  ssrFormAuthoringDiagnostics,
5724
6156
  ssrFragmentMarker,
5725
6157
  ssrHeadEl,
6158
+ ssrHtml,
5726
6159
  ssrInNamespace,
5727
6160
  ssrInnerHtml,
5728
6161
  ssrInputAttrs,
@@ -5750,6 +6183,8 @@ export {
5750
6183
  ssrValueAttr,
5751
6184
  ssrVoidContent,
5752
6185
  startTransition,
6186
+ styleMap,
6187
+ touchStyleMap,
5753
6188
  use,
5754
6189
  useActionState,
5755
6190
  useCallback,