octane 0.6.3 → 0.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (50) hide show
  1. package/dist/cjs/constants.cjs +3 -0
  2. package/dist/cjs/error-codes.client.generated.cjs +5 -0
  3. package/dist/cjs/error-codes.server.generated.cjs +25 -0
  4. package/dist/cjs/index.cjs +2 -0
  5. package/dist/cjs/runtime.cjs +699 -217
  6. package/dist/cjs/runtime.server.cjs +210 -28
  7. package/dist/cjs/server/index.cjs +2 -0
  8. package/dist/cjs/server/rpc-stream.cjs +19 -12
  9. package/dist/cjs/server/streamed-signals.cjs +18 -1
  10. package/dist/cjs/shared-value-helpers.cjs +24 -2
  11. package/dist/cjs/version.cjs +1 -1
  12. package/dist/compiler/arm-exits.js +151 -0
  13. package/dist/compiler/compile-universal.js +262 -65
  14. package/dist/compiler/compile.js +1567 -312
  15. package/dist/compiler/deferred-snapshots.js +791 -0
  16. package/dist/compiler/strong-mode.js +59 -10
  17. package/dist/constants.d.ts +5 -1
  18. package/dist/constants.js +2 -0
  19. package/dist/error-codes.client.generated.d.ts +1 -0
  20. package/dist/error-codes.client.generated.js +5 -0
  21. package/dist/error-codes.server.generated.d.ts +5 -0
  22. package/dist/error-codes.server.generated.js +25 -0
  23. package/dist/index.d.ts +1 -1
  24. package/dist/index.js +2 -0
  25. package/dist/node/constants.js +2 -0
  26. package/dist/node/error-codes.client.generated.js +5 -0
  27. package/dist/node/error-codes.server.generated.js +25 -0
  28. package/dist/node/index.js +2 -0
  29. package/dist/node/runtime.js +701 -218
  30. package/dist/node/runtime.server.js +213 -29
  31. package/dist/node/server/index.js +2 -0
  32. package/dist/node/server/rpc-stream.js +19 -12
  33. package/dist/node/server/streamed-signals.js +18 -1
  34. package/dist/node/shared-value-helpers.js +21 -1
  35. package/dist/node/universal-core.js +178 -50
  36. package/dist/node/version.js +1 -1
  37. package/dist/runtime.d.ts +201 -8
  38. package/dist/runtime.js +701 -218
  39. package/dist/runtime.server.d.ts +26 -2
  40. package/dist/runtime.server.js +213 -29
  41. package/dist/server/index.d.ts +1 -1
  42. package/dist/server/index.js +2 -0
  43. package/dist/server/rpc-stream.js +19 -12
  44. package/dist/server/streamed-signals.js +18 -1
  45. package/dist/shared-value-helpers.d.ts +11 -0
  46. package/dist/shared-value-helpers.js +21 -1
  47. package/dist/universal-core.d.ts +3 -1
  48. package/dist/universal-core.js +178 -50
  49. package/dist/version.js +1 -1
  50. package/package.json +1 -1
@@ -289,6 +289,7 @@ __export(runtime_exports, {
289
289
  textHole: () => textHole,
290
290
  textHoleUpdate: () => textHoleUpdate,
291
291
  textSlot: () => textSlot,
292
+ textareaText: () => textareaText,
292
293
  tryBlock: () => tryBlock,
293
294
  updateFreshClassAttr: () => updateFreshClassAttr,
294
295
  updateFreshClassName: () => updateFreshClassName,
@@ -386,10 +387,10 @@ function profileTrackComponent(subject, fallback) {
386
387
  override !== null && override.target === fallback ? override.component : fallback
387
388
  );
388
389
  }
389
- function profilePortalComponent(rawBody) {
390
+ function profilePortalComponent(rawBody, body) {
390
391
  if (typeof rawBody === "function" && (0, import_profiling.__profileHasComponentMetadata)(rawBody)) return rawBody;
391
392
  const descriptor = rawBody;
392
- return descriptor != null && descriptor.$$kind === import_runtime_tags.ELEMENT_TAG && typeof descriptor.type === "function" ? descriptor.type : null;
393
+ return descriptor != null && descriptor.$$kind === import_runtime_tags.ELEMENT_TAG && descriptor.type === body ? body : null;
393
394
  }
394
395
  function ensureHooks(scope) {
395
396
  return scope.hooks ?? (scope.hooks = /* @__PURE__ */ new Map());
@@ -1156,6 +1157,7 @@ function siteLoc(scope, slotKey) {
1156
1157
  if (lc === void 0) return "";
1157
1158
  return `${scope.locFile ?? "<unknown>"}:${lc[0]}:${lc[1]}`;
1158
1159
  }
1160
+ const COMPONENT_SOURCE_LOCS = !__octaneDev ? null : /* @__PURE__ */ new WeakMap();
1159
1161
  function componentSourceLoc(body) {
1160
1162
  if (typeof body !== "function") return void 0;
1161
1163
  try {
@@ -1163,13 +1165,17 @@ function componentSourceLoc(body) {
1163
1165
  if (typeof stamped === "string") return stamped;
1164
1166
  } catch {
1165
1167
  }
1168
+ const cache = COMPONENT_SOURCE_LOCS;
1169
+ if (cache !== null && cache.has(body)) return cache.get(body);
1170
+ let loc;
1166
1171
  try {
1167
1172
  const source = Function.prototype.toString.call(body);
1168
1173
  const match = /["']__octane_loc:([^"'\\\s]+)["']/.exec(source);
1169
- if (match !== null) return decodeURIComponent(match[1]);
1174
+ if (match !== null) loc = decodeURIComponent(match[1]);
1170
1175
  } catch {
1171
1176
  }
1172
- return void 0;
1177
+ cache?.set(body, loc);
1178
+ return loc;
1173
1179
  }
1174
1180
  function isHydrationSuppressed(el) {
1175
1181
  return el !== null && el.__oct_suppress === true;
@@ -1245,6 +1251,10 @@ function hydrationNodeMatches(server, template2, partialStyles, path = "") {
1245
1251
  }
1246
1252
  return true;
1247
1253
  }
1254
+ function fragmentRootMatches(server, fragment, partialStyles) {
1255
+ const first = getFirstChild(fragment);
1256
+ return first.nodeType === 8 || hydrationNodeMatches(server, first, partialStyles, "0");
1257
+ }
1248
1258
  function removeHydrationRange(start, end) {
1249
1259
  let n = start;
1250
1260
  while (n !== null) {
@@ -2506,7 +2516,7 @@ function suspendRootRender(block, wakeable, attempt) {
2506
2516
  owner.retry();
2507
2517
  });
2508
2518
  };
2509
- wakeable.then(ping, ping);
2519
+ resumeOnSettle(wakeable, ping);
2510
2520
  return true;
2511
2521
  }
2512
2522
  const BINDING_BAG_ARITY = /* @__PURE__ */ Symbol();
@@ -3117,8 +3127,8 @@ function vtScopeForBlock(block) {
3117
3127
  const host = vtScopeHost(ancestor);
3118
3128
  if (host === null) return null;
3119
3129
  if (ancestor !== block) {
3120
- const parent2 = block.parentNode;
3121
- if (parent2 !== host && !(STAGED_DOM?.view(host) ?? host).contains(parent2)) {
3130
+ const parent = block.parentNode;
3131
+ if (parent !== host && !(STAGED_DOM?.view(host) ?? host).contains(parent)) {
3122
3132
  const elements = vtRangeElements(block);
3123
3133
  if (elements.length === 0 || elements.some(
3124
3134
  (element) => element !== host && !(STAGED_DOM?.view(host) ?? host).contains(element)
@@ -3128,10 +3138,14 @@ function vtScopeForBlock(block) {
3128
3138
  }
3129
3139
  return host;
3130
3140
  }
3131
- const parent = block.parentNode;
3132
- const physical = vtClosestScope(parent);
3133
- if (physical !== null) return physical;
3134
- return parent.nodeType === 9 ? parent : parent.ownerDocument;
3141
+ for (let current = block; current !== null; current = current.parentBlock) {
3142
+ const parent = current.parentNode;
3143
+ const physical = vtClosestScope(parent);
3144
+ if (physical !== null) return physical;
3145
+ const owner = parent.nodeType === 9 ? parent : parent.ownerDocument;
3146
+ if (owner.defaultView !== null) return owner;
3147
+ }
3148
+ return null;
3135
3149
  }
3136
3150
  function vtCaptureElements(block, owner) {
3137
3151
  return vtRangeElements(block).filter((element) => {
@@ -4840,6 +4854,8 @@ function vtFinalizeGroup(group, types) {
4840
4854
  while (ancestor !== null && !active.has(ancestor))
4841
4855
  ancestor = vtNearestBoundaryAncestor(ancestor);
4842
4856
  if (ancestor === null) vtCancelOldCapture(rec, cancelledAnimations);
4857
+ else if (visibleAfter.has(rec.block))
4858
+ vtApplyStyles(rec, vtResolveClass(rec.props, "update", types));
4843
4859
  }
4844
4860
  vtCheckNames(group);
4845
4861
  const root = owner.documentElement;
@@ -7053,12 +7069,12 @@ function renderReturnedValue(block, out, reset) {
7053
7069
  block.parentNode,
7054
7070
  d.type,
7055
7071
  d.props,
7072
+ d.__octaneInvocationSite,
7056
7073
  block.endMarker,
7057
- d.key ?? void 0,
7058
7074
  true,
7059
7075
  void 0,
7060
- activeHydration() !== null && elementKeyWasProvided(d),
7061
- d.__octaneInvocationSite
7076
+ d.key ?? void 0,
7077
+ activeHydration() !== null && elementKeyWasProvided(d)
7062
7078
  )
7063
7079
  );
7064
7080
  } else {
@@ -7068,32 +7084,21 @@ function renderReturnedValue(block, out, reset) {
7068
7084
  block.parentNode,
7069
7085
  d.type,
7070
7086
  d.props,
7087
+ d.__octaneInvocationSite,
7071
7088
  block.endMarker,
7072
- d.key ?? void 0,
7073
7089
  true,
7074
7090
  void 0,
7075
- activeHydration() !== null && elementKeyWasProvided(d),
7076
- d.__octaneInvocationSite
7091
+ d.key ?? void 0,
7092
+ activeHydration() !== null && elementKeyWasProvided(d)
7077
7093
  );
7078
7094
  }
7079
7095
  } else {
7080
7096
  const returnHydration = activeHydration();
7081
- if (returnHydration !== null && block.slots[0] === void 0 && block.startMarker !== null && block.endMarker !== null && block.startMarker !== block.endMarker && block.startMarker.nodeType === 8 && block.endMarker.nodeType === 8 && (getNextSibling(block.startMarker) === block.endMarker || returnHydration.isUnframedRootRange(block.startMarker, block.endMarker))) {
7082
- const borrowed = {
7083
- __kind: "childSlot",
7084
- start: block.startMarker,
7085
- end: block.endMarker,
7086
- ownerHost: null,
7087
- borrowed: true,
7088
- compactable: false,
7089
- block: null,
7090
- text: null,
7091
- currentComp: null,
7092
- currentIsBodyFn: false,
7093
- forSlot: null,
7094
- hostNode: null,
7095
- portal: null
7096
- };
7097
+ if (returnHydration !== null && block.slots[0] === void 0 && block.startMarker !== null && block.endMarker !== null && block.startMarker !== block.endMarker && block.startMarker.nodeType === 8 && block.endMarker.nodeType === 8 && (getNextSibling(block.startMarker) === block.endMarker || returnHydration.isUnframedRootRange(block.startMarker, block.endMarker) || isComponentDescriptor && returnHydration.holdsServerText(block))) {
7098
+ const borrowed = returnHydration.lendRange(
7099
+ block.startMarker,
7100
+ block.endMarker
7101
+ );
7097
7102
  block.slots[0] = borrowed;
7098
7103
  registerSlot(block, borrowed);
7099
7104
  }
@@ -7201,7 +7206,7 @@ class LiteBlockImpl {
7201
7206
  this.signalInstanceResolved = void 0;
7202
7207
  }
7203
7208
  }
7204
- function componentSlotLite(parentScope, slotKey, host, comp, props, anchor, invocationSite) {
7209
+ function componentSlotLite(parentScope, slotKey, host, comp, props, invocationSite, anchor) {
7205
7210
  if (CURRENT_BLOCK?.pending && !CURRENT_BLOCK.crossRenderUpdate) return;
7206
7211
  if (parentScope === SHARED_BODY_SCOPE) {
7207
7212
  componentSlotImpl(
@@ -7231,8 +7236,8 @@ function componentSlotLite(parentScope, slotKey, host, comp, props, anchor, invo
7231
7236
  host,
7232
7237
  comp,
7233
7238
  props,
7234
- anchor,
7235
- invocationSite
7239
+ invocationSite,
7240
+ anchor
7236
7241
  );
7237
7242
  return;
7238
7243
  }
@@ -7301,9 +7306,9 @@ function componentSlotLite(parentScope, slotKey, host, comp, props, anchor, invo
7301
7306
  }
7302
7307
  if (hydration !== null && adoptedClose !== null) hydration.node = getNextSibling(adoptedClose);
7303
7308
  }
7304
- function suspendFreshLiteComponent(hydration, parentScope, slotKey, host, comp, props, anchor, invocationSite) {
7309
+ function suspendFreshLiteComponent(hydration, parentScope, slotKey, host, comp, props, invocationSite, anchor) {
7305
7310
  hydration.suspend(
7306
- () => componentSlotLite(parentScope, slotKey, host, comp, props, anchor, invocationSite)
7311
+ () => componentSlotLite(parentScope, slotKey, host, comp, props, invocationSite, anchor)
7307
7312
  );
7308
7313
  }
7309
7314
  let TEARDOWN_DEPTH = 0;
@@ -8989,7 +8994,7 @@ function preserveSuspendedHydrateActivation(state, hydration, thenable) {
8989
8994
  state.serverActivationStarted = false;
8990
8995
  scheduleRender(state.parentBlock);
8991
8996
  };
8992
- thenable.then(resume, resume);
8997
+ resumeOnSettle(thenable, resume);
8993
8998
  }
8994
8999
  function hydrateStrategyType(when) {
8995
9000
  return typeof when === "function" ? "dynamic" : when?._t ?? "dynamic";
@@ -10480,6 +10485,14 @@ function useThenable(thenable, replaceOnResume = false) {
10480
10485
  warnUseWaterfall(block, idx);
10481
10486
  throw new SuspenseException(thenable);
10482
10487
  }
10488
+ let SETTLED_WAKEABLES = null;
10489
+ function resumeOnSettle(wakeable, retry) {
10490
+ const onSettle = SETTLED_WAKEABLES?.has(wakeable) === true ? () => void setTimeout(retry, 0) : () => {
10491
+ (SETTLED_WAKEABLES ??= /* @__PURE__ */ new WeakSet()).add(wakeable);
10492
+ retry();
10493
+ };
10494
+ wakeable.then(onSettle, onSettle);
10495
+ }
10483
10496
  function trackThenable(thenable) {
10484
10497
  if (thenable.status !== void 0) return;
10485
10498
  thenable.status = "pending";
@@ -11332,16 +11345,16 @@ function template(html, ns = 0, frag = 0) {
11332
11345
  }
11333
11346
  };
11334
11347
  }
11335
- function templateRootDescriptor(html) {
11336
- if (html.charCodeAt(0) !== 60) return 3;
11337
- const c = html.charCodeAt(1);
11348
+ function templateRootDescriptor(html, at = 0) {
11349
+ if (html.charCodeAt(at) !== 60) return 3;
11350
+ const c = html.charCodeAt(at + 1);
11338
11351
  if (!(c >= 97 && c <= 122 || c >= 65 && c <= 90)) return 8;
11339
- let i = 2;
11352
+ let i = at + 2;
11340
11353
  for (; i < html.length; i++) {
11341
11354
  const cc = html.charCodeAt(i);
11342
11355
  if (cc === 62 || cc === 47 || cc <= 32) break;
11343
11356
  }
11344
- return html.slice(1, i);
11357
+ return html.slice(at + 1, i);
11345
11358
  }
11346
11359
  function lazyRootDescriptor(lazy2) {
11347
11360
  const root = lazy2.root;
@@ -11357,6 +11370,16 @@ function lazyRootMatches(server, lazy2) {
11357
11370
  if (server.nodeType !== 1) return false;
11358
11371
  return server.localName === root;
11359
11372
  }
11373
+ function lazyFragmentRootMatches(server, lazy2) {
11374
+ const root = lazy2.frag !== 0 ? lazyRootDescriptor(lazy2) : templateRootDescriptor(
11375
+ lazy2.html,
11376
+ 13
11377
+ /* '<octane-frag>'.length */
11378
+ );
11379
+ if (root === 8) return true;
11380
+ if (root === 3) return server.nodeType === 3;
11381
+ return server.nodeType === 1 && server.localName === root;
11382
+ }
11360
11383
  function resolveLazyTemplate(lazy2) {
11361
11384
  let ns;
11362
11385
  if (lazy2.ns === 3) {
@@ -11373,6 +11396,8 @@ function resolveLazyTemplate(lazy2) {
11373
11396
  return parsed;
11374
11397
  }
11375
11398
  let currentHydration = null;
11399
+ let HYDRATION_REBUILT = null;
11400
+ let HYDRATION_REBUILT_HOSTS = null;
11376
11401
  function activeHydration() {
11377
11402
  const hydration = currentHydration;
11378
11403
  return hydration !== null && hydration.isActive() ? hydration : null;
@@ -11380,6 +11405,31 @@ function activeHydration() {
11380
11405
  function isRendererHydrationStyle(node) {
11381
11406
  return node.nodeType === 1 && node.localName === "style" && (STAGED_DOM?.view(node) ?? node).hasAttribute("data-octane");
11382
11407
  }
11408
+ function isFloatHeadResource(node) {
11409
+ if (node.nodeType !== 1) return false;
11410
+ const el = STAGED_DOM?.view(node) ?? node;
11411
+ const tag = el.localName;
11412
+ return (tag === "link" || tag === "style" || tag === "script") && (el.hasAttribute("data-precedence") || el.hasAttribute("data-oct-hint") || el.hasAttribute("data-oct-res"));
11413
+ }
11414
+ function skipFoldedHeadPrefix(container, node) {
11415
+ const head = container.nodeType === 9 ? null : container.ownerDocument.head;
11416
+ while (node !== null) {
11417
+ if (node.nodeType === 10 || isRendererHydrationStyle(node) || isFloatHeadResource(node)) {
11418
+ node = getNextSibling(node);
11419
+ continue;
11420
+ }
11421
+ const el = head !== null && node.nodeType === 8 ? getNextSibling(node) : null;
11422
+ const end = el === null ? null : getNextSibling(el);
11423
+ if (end === null || end.nodeType !== 8) return node;
11424
+ const key = (STAGED_DOM?.view(node) ?? node).data;
11425
+ if (!key.startsWith("rnh-") || (STAGED_DOM?.view(end) ?? end).data !== "/" + key)
11426
+ return node;
11427
+ const next = getNextSibling(end);
11428
+ (STAGED_DOM?.view(head) ?? head).append(node, el, end);
11429
+ node = next;
11430
+ }
11431
+ return null;
11432
+ }
11383
11433
  class HydrationCapability {
11384
11434
  constructor(rootBlock, node, seeds) {
11385
11435
  this.rootBlock = rootBlock;
@@ -11409,6 +11459,8 @@ class HydrationCapability {
11409
11459
  textWarnings = /* @__PURE__ */ new Map();
11410
11460
  /** Skip component-frame adoption until the declared container owner. */
11411
11461
  passthroughRanges = false;
11462
+ /** A slot lent a server range whose first render has yet to claim it. */
11463
+ lentSlot = null;
11412
11464
  nativeAdoption;
11413
11465
  retryPresentation;
11414
11466
  presentation;
@@ -11462,6 +11514,147 @@ class HydrationCapability {
11462
11514
  warnStructural(loc, expected, actual) {
11463
11515
  warnHydrationStructuralMismatch(loc, expected, actual);
11464
11516
  }
11517
+ /**
11518
+ * A slot for the range `start`…`end` that a list item or a returning
11519
+ * component adopted, lent to the child slot that renders its value, so that
11520
+ * the value hydrates inside that range rather than claiming a range of its
11521
+ * own. The slot's first render claims the server range as an adopted one.
11522
+ */
11523
+ lendRange(start, end) {
11524
+ const slot = {
11525
+ __kind: "childSlot",
11526
+ start,
11527
+ end,
11528
+ ownerHost: null,
11529
+ borrowed: true,
11530
+ compactable: false,
11531
+ block: null,
11532
+ text: null,
11533
+ currentComp: null,
11534
+ currentIsBodyFn: false,
11535
+ forSlot: null,
11536
+ hostNode: null,
11537
+ portal: null
11538
+ };
11539
+ if (this.isOpen(start)) this.lentSlot = slot;
11540
+ return slot;
11541
+ }
11542
+ /**
11543
+ * Before a child slot's first hydrating render of the server range
11544
+ * `start`…`end`, which it adopted or was lent, check that `value` can adopt
11545
+ * what the range holds. A host descriptor serializes as exactly one element
11546
+ * of its tag. A list (`list`, from prepareDeoptList) frames or self-delimits
11547
+ * each of its items, so it neither leaves the range empty nor opens it with
11548
+ * text, unless it has no items, and then the range is empty. A portal does
11549
+ * not open it with text either. Anything else is server content the client
11550
+ * cannot adopt: what the server rendered for another value, or invalid
11551
+ * nesting that the HTML parser repaired (`<p><div></div></p>` arrives as
11552
+ * `<p></p><div></div><p></p>`, all inside the range). Discard it, as
11553
+ * renderBranchSlot's rebuild does. Returns whether it did, in which case the
11554
+ * caller builds the value as a client mount would.
11555
+ */
11556
+ claimRange(scope, slotKey, start, end, value, list) {
11557
+ const rebuilt = HYDRATION_REBUILT?.has(end) === true;
11558
+ const type = list === null && isHostDescriptor(value) ? value.type : null;
11559
+ if (!rebuilt && type === null && list === null && value?.$$kind !== import_runtime_tags.PORTAL_TAG)
11560
+ return false;
11561
+ const first = getNextSibling(start);
11562
+ const matches = type !== null && first !== end && first.nodeType === 1 && isHostElementOfType(first, type);
11563
+ if (!rebuilt && (type !== null ? matches && getNextSibling(first) === end : list !== null && first === end ? list.items.length === 0 : first.nodeType !== 3 && list?.items.length !== 0))
11564
+ return false;
11565
+ return this.discard(
11566
+ scope,
11567
+ slotKey,
11568
+ first,
11569
+ end,
11570
+ // Items that render nothing differ from an empty range only in the
11571
+ // frames the server would have given them: rebuild those quietly.
11572
+ rebuilt || list !== null && first === end && !list.items.some((item) => item != null && typeof item !== "boolean" && item !== ""),
11573
+ __octaneDev ? type !== null ? matches ? `the end of <${type}>` : `<${type}>` : list?.items.length === 0 ? "nothing" : list !== null ? "a renderable list range" : "a portal" : "",
11574
+ matches ? getNextSibling(first) : first === end ? null : first
11575
+ );
11576
+ }
11577
+ /**
11578
+ * A child slot's first hydrating render without a server range of its own,
11579
+ * such as a return slot's when its component's range holds server text. A
11580
+ * list, a fragment, a keyed or lone element, and a portal never serialize as
11581
+ * bare text, so a lone text node before `end` in `parent` is what the server
11582
+ * rendered for a primitive, which the value cannot adopt. Discard it; returns
11583
+ * whether it did. An earlier attempt that did so left its own content there.
11584
+ */
11585
+ discardServerText(scope, slotKey, parent, end, value, list) {
11586
+ const text = this.node;
11587
+ if (end !== null && HYDRATION_REBUILT?.has(end) === true) {
11588
+ let node = text;
11589
+ while (node !== null && node !== end) node = getNextSibling(node);
11590
+ return this.discard(scope, slotKey, node === end ? text : null, end, true, "", null);
11591
+ }
11592
+ if (text === null || text.nodeType !== 3 || !(list || value?.$$kind === import_runtime_tags.PORTAL_TAG || isHostDescriptor(value)) || domNode(text).parentNode !== parent || getNextSibling(text) !== end)
11593
+ return false;
11594
+ return this.discard(
11595
+ scope,
11596
+ slotKey,
11597
+ text,
11598
+ end,
11599
+ false,
11600
+ __octaneDev ? list ? "a renderable list range" : value.$$kind === import_runtime_tags.PORTAL_TAG ? "a portal" : `<${value.type}>` : "",
11601
+ text
11602
+ );
11603
+ }
11604
+ /**
11605
+ * A list item's first hydrating render where the server content at the
11606
+ * cursor cannot be that item: the server rendered fewer items, a bare item
11607
+ * where this one needs a range of its own, or an item of another tag.
11608
+ * Discard the list's server content from the cursor to its `end`, so that
11609
+ * this item and every later one build as a client mount would. The list
11610
+ * reports once, and an earlier attempt that rebuilt it left its own content.
11611
+ */
11612
+ discardItems(end, expected) {
11613
+ const from = this.node;
11614
+ let node = from;
11615
+ while (node !== null && node !== end) node = getNextSibling(node);
11616
+ const stale = node === end && from !== end ? from : null;
11617
+ this.discard(null, 0, stale, end, HYDRATION_REBUILT?.has(end) === true, expected, stale);
11618
+ }
11619
+ /**
11620
+ * STRUCTURAL recovery for a list where the SERVER rendered MORE items than the
11621
+ * client now renders: after its first fill adopts the client's items, the
11622
+ * cursor sits on the first unconsumed server item (or at `end`). Discard
11623
+ * everything between the cursor and `end` so the extra server items don't
11624
+ * linger. Only when the cursor precedes `end`; stops AT `end`.
11625
+ */
11626
+ discardLeftoverItems(end) {
11627
+ const from = this.node;
11628
+ if (from === end) return;
11629
+ let node = from;
11630
+ while (node !== null && node !== end) node = getNextSibling(node);
11631
+ if (node === null) return;
11632
+ if (!this.staleServerValues)
11633
+ noteRecoverableHydrationError(() => new Error((0, import_error_codes_client_generated.formatClientError)(56)));
11634
+ removeRange(from, end);
11635
+ }
11636
+ /**
11637
+ * Remove the server content from `from` up to `end` that a child slot's
11638
+ * value cannot adopt, and point the cursor at `end`. Reports the structural
11639
+ * mismatch (`expected`, and the `actual` server node, describe it in
11640
+ * development) unless it is `quiet`, as it is when an earlier attempt already
11641
+ * rebuilt this content, or the captures legitimately changed before a dormant
11642
+ * boundary activated. Remembers `end` for later attempts.
11643
+ */
11644
+ discard(scope, slotKey, from, end, quiet, expected, actual) {
11645
+ if (PRESENTATION_HYDRATION?.revision !== void 0) presentationMiss();
11646
+ if (!quiet && !this.staleServerValues) {
11647
+ noteRecoverableHydrationError(() => new Error((0, import_error_codes_client_generated.formatClientError)(51)));
11648
+ if (__octaneDev) {
11649
+ const loc = scope !== null && (siteLoc(scope, slotKey) || componentSourceLoc(scope.block.body)) || domNode(from ?? end).parentNode?.__oct_loc;
11650
+ if (loc) warnHydrationStructuralMismatch(loc, expected, describeHydrationNode(actual));
11651
+ }
11652
+ }
11653
+ removeRange(from, end);
11654
+ if (end !== null) (HYDRATION_REBUILT ??= /* @__PURE__ */ new WeakSet()).add(end);
11655
+ this.node = end;
11656
+ return true;
11657
+ }
11465
11658
  recordTextMismatch(node, loc, server) {
11466
11659
  if (this.staleServerValues) return;
11467
11660
  if (!__octaneDev && ROOT_ERROR_HANDLERS === null) return;
@@ -11482,6 +11675,35 @@ class HydrationCapability {
11482
11675
  removeRange(start, end) {
11483
11676
  removeHydrationRange(start, end);
11484
11677
  }
11678
+ /**
11679
+ * Runs before the first hydrating render of a text or empty value `str` in a
11680
+ * child slot that adopted the server's `<!--[-->…<!--]-->` range. The value
11681
+ * serializes as at most one text node there, which the slot adopts when it
11682
+ * leads the range. Anything else in the range is server content the client
11683
+ * cannot adopt, such as an element or component the server rendered for a
11684
+ * value the client renders as text or nothing. Discard it and report the
11685
+ * recovery, as claimRange does for a host descriptor.
11686
+ */
11687
+ discardUnadoptedText(scope, slotKey, state, str) {
11688
+ const end = state.end;
11689
+ const first = getNextSibling(state.start);
11690
+ const kept = str !== "" && first.nodeType === 3;
11691
+ const stale = kept ? getNextSibling(first) : first;
11692
+ if (stale === end) return;
11693
+ if (PRESENTATION_HYDRATION?.revision !== void 0) presentationMiss();
11694
+ if (!this.staleServerValues) {
11695
+ noteRecoverableHydrationError(() => new Error((0, import_error_codes_client_generated.formatClientError)(51)));
11696
+ if (__octaneDev) {
11697
+ const loc = siteLoc(scope, slotKey);
11698
+ if (loc) {
11699
+ const client = str === "" ? "nothing" : `text ${JSON.stringify(str)}`;
11700
+ this.warnStructural(loc, kept ? `the end of ${client}` : client, this.describe(stale));
11701
+ }
11702
+ }
11703
+ }
11704
+ removeRange(stale, end);
11705
+ if (!kept) this.node = end;
11706
+ }
11485
11707
  parseSeeds(raw) {
11486
11708
  return parseSeedJson(raw);
11487
11709
  }
@@ -11577,6 +11799,14 @@ class HydrationCapability {
11577
11799
  isUnframedRootRange(start, end) {
11578
11800
  return this.unframedRootRanges.get(start) === end;
11579
11801
  }
11802
+ /**
11803
+ * Whether `block`'s server range holds only unclaimed text at the cursor:
11804
+ * what the server rendered for a primitive.
11805
+ */
11806
+ holdsServerText(block) {
11807
+ const text = this.node;
11808
+ return text !== null && text.nodeType === 3 && getNextSibling(block.startMarker) === text && getNextSibling(text) === block.endMarker;
11809
+ }
11580
11810
  /** Record the first node outside a root-owned range exactly once. */
11581
11811
  claimRootRemainder(node) {
11582
11812
  if (this.rootRemainder === void 0) this.rootRemainder = node;
@@ -11719,14 +11949,7 @@ class HydrationCapability {
11719
11949
  const target = CURRENT_BLOCK?.parentNode;
11720
11950
  if (!claimsRoot && target != null && (STAGED_DOM?.view(cursor) ?? cursor).parentNode !== target)
11721
11951
  return this.freshClone(template2);
11722
- if (isBlockOpen(cursor)) {
11723
- const close = this.close(cursor);
11724
- this.node = getNextSibling(close);
11725
- removeHydrationRange(cursor, close);
11726
- } else {
11727
- this.node = getNextSibling(cursor);
11728
- (STAGED_DOM?.view(cursor) ?? cursor).remove();
11729
- }
11952
+ this.discardCursor(cursor);
11730
11953
  if (claimsRoot)
11731
11954
  this.claimRootRemainder(
11732
11955
  framedRemainder === void 0 ? unframedRemainder ?? null : framedRemainder
@@ -11734,7 +11957,9 @@ class HydrationCapability {
11734
11957
  return this.freshClone(template2);
11735
11958
  }
11736
11959
  if (isFragment) {
11737
- return { __oct_vfrag: true, firstChild: cursor };
11960
+ if (claimsRoot || (template2 !== null ? fragmentRootMatches(cursor, template2, partialStyles) : lazyFragmentRootMatches(cursor, lazy2)))
11961
+ return { __oct_vfrag: true, firstChild: cursor };
11962
+ return this.rebuildFragment(template2 ?? resolveLazyTemplate(lazy2), cursor, loc);
11738
11963
  }
11739
11964
  if (claimsRoot)
11740
11965
  this.claimRootRemainder(
@@ -11742,6 +11967,52 @@ class HydrationCapability {
11742
11967
  );
11743
11968
  return cursor;
11744
11969
  }
11970
+ /**
11971
+ * The server rendered something other than this nested fragment at the
11972
+ * cursor (a text value, another component's roots). Report it once and build
11973
+ * the fragment on the client. The fragment's block owns the server nodes from
11974
+ * the cursor up to its end marker, where drainFrag inserts the fresh roots, so
11975
+ * discard them. When the end marker does not follow the cursor inside the
11976
+ * block's range, discard only the cursor node or its range, as a single-root
11977
+ * mismatch does.
11978
+ */
11979
+ rebuildFragment(template2, cursor, loc) {
11980
+ if (PRESENTATION_HYDRATION?.revision !== void 0) presentationMiss();
11981
+ if (!this.staleServerValues) {
11982
+ noteRecoverableHydrationError(() => new Error((0, import_error_codes_client_generated.formatClientError)(51)));
11983
+ if (__octaneDev)
11984
+ warnHydrationStructuralMismatch(
11985
+ loc ?? componentSourceLoc(CURRENT_BLOCK?.body) ?? CURRENT_SCOPE?.locFile,
11986
+ `a fragment starting with ${describeHydrationNode(getFirstChild(template2))}`,
11987
+ describeHydrationNode(cursor)
11988
+ );
11989
+ }
11990
+ const block = CURRENT_SCOPE?.block;
11991
+ const parent = block?.parentNode;
11992
+ const end = block?.endMarker ?? null;
11993
+ if (parent == null || cursor === end || (STAGED_DOM?.view(cursor) ?? cursor).parentNode !== parent)
11994
+ return this.freshClone(template2);
11995
+ let node = cursor;
11996
+ if (end !== null)
11997
+ while (node !== null && node !== end && node !== block.startMarker)
11998
+ node = getNextSibling(node);
11999
+ if (node === end) {
12000
+ this.node = end;
12001
+ removeHydrationRange(cursor, (STAGED_DOM?.view(end) ?? end).previousSibling);
12002
+ } else this.discardCursor(cursor);
12003
+ return this.freshClone(template2);
12004
+ }
12005
+ /** Discard a mismatched server node (or the marker range it opens) and step past it. */
12006
+ discardCursor(cursor) {
12007
+ if (isBlockOpen(cursor)) {
12008
+ const close = this.close(cursor);
12009
+ this.node = getNextSibling(close);
12010
+ removeHydrationRange(cursor, close);
12011
+ } else {
12012
+ this.node = getNextSibling(cursor);
12013
+ (STAGED_DOM?.view(cursor) ?? cursor).remove();
12014
+ }
12015
+ }
11745
12016
  /** Remove server siblings left after the root's complete client shape was adopted. */
11746
12017
  finishRoot() {
11747
12018
  if (this.abandoned) return;
@@ -11765,6 +12036,18 @@ class HydrationCapability {
11765
12036
  this.node = null;
11766
12037
  this.rootRemainder = null;
11767
12038
  }
12039
+ /**
12040
+ * Whether the server framed `el`'s only child in a `<!--[-->…<!--]-->` range
12041
+ * holding something other than one text node or nothing. htext unwraps a
12042
+ * text-only frame; any other framed content belongs to a child slot.
12043
+ */
12044
+ framesSlotContent(el) {
12045
+ const first = getFirstChild(el);
12046
+ if (!this.isOpen(first)) return false;
12047
+ let next = getNextSibling(first);
12048
+ if (next !== null && next.nodeType === 3) next = getNextSibling(next);
12049
+ return !this.isClose(next);
12050
+ }
11768
12051
  htext(el, text, loc) {
11769
12052
  const first = getFirstChild(el);
11770
12053
  if (first !== null && first.nodeType === 3) {
@@ -11800,6 +12083,78 @@ class HydrationCapability {
11800
12083
  (STAGED_DOM?.view(el) ?? el).appendChild(created);
11801
12084
  return created;
11802
12085
  }
12086
+ /**
12087
+ * childTextHole's first hydrating render of an element, a component, or a
12088
+ * list. The server frames such a value in a `<!--[-->…<!--]-->` range, which
12089
+ * the hole's child slot adopts from the cursor. Anything else in the host is
12090
+ * the text, or nothing, that the server rendered for a primitive value, which
12091
+ * none of these values can adopt: discard it, report the recovery, and build
12092
+ * the value as a client mount would. A textarea's text is its default value,
12093
+ * which its value props own, so it stays. `render` is the hole's childSlot
12094
+ * call, passed in so that hydration alone never retains the child-slot graph.
12095
+ */
12096
+ hydrateOnlyChild(scope, slotKey, el, render) {
12097
+ let stale = getFirstChild(el);
12098
+ const rebuilt = HYDRATION_REBUILT_HOSTS?.has(el) === true;
12099
+ if (!rebuilt && this.isOpen(stale)) {
12100
+ this.node = stale;
12101
+ render();
12102
+ return;
12103
+ }
12104
+ if (PRESENTATION_HYDRATION?.revision !== void 0) presentationMiss();
12105
+ if (stale !== null) {
12106
+ if (el.localName === "textarea") stale = getNextSibling(stale);
12107
+ else if (!rebuilt && !this.staleServerValues) {
12108
+ noteRecoverableHydrationError(() => new Error((0, import_error_codes_client_generated.formatClientError)(51)), this.rootBlock);
12109
+ if (__octaneDev)
12110
+ warnHydrationStructuralMismatch(
12111
+ siteLoc(scope, slotKey) || el.__oct_loc,
12112
+ "a renderable range",
12113
+ describeHydrationNode(stale)
12114
+ );
12115
+ }
12116
+ }
12117
+ while (stale !== null) {
12118
+ const next = getNextSibling(stale);
12119
+ (STAGED_DOM?.view(el) ?? el).removeChild(stale);
12120
+ stale = next;
12121
+ }
12122
+ (HYDRATION_REBUILT_HOSTS ??= /* @__PURE__ */ new WeakSet()).add(el);
12123
+ this.suspend(render);
12124
+ }
12125
+ /**
12126
+ * htext's counterpart for an only-child hole whose first hydrating value
12127
+ * renders nothing (`null`, `undefined`, a boolean, or `''`). The server
12128
+ * serializes that as no children, or as an empty `<!--[--><!--]-->` frame,
12129
+ * which unwraps like htext's text-only frame. Anything else is server content
12130
+ * the client renders no node for, so a later value would land beside it.
12131
+ * Discard it and report the recovery as htext reports extra children.
12132
+ * A textarea's text is its default value, which its value props own.
12133
+ */
12134
+ hempty(el, loc) {
12135
+ const first = getFirstChild(el);
12136
+ if (first === null || el.localName === "textarea") return;
12137
+ const next = getNextSibling(first);
12138
+ const framed = this.isOpen(first);
12139
+ if (framed && this.isClose(next) && getNextSibling(next) === null) {
12140
+ (STAGED_DOM?.view(first) ?? first).remove();
12141
+ (STAGED_DOM?.view(next) ?? next).remove();
12142
+ return;
12143
+ }
12144
+ if (PRESENTATION_HYDRATION?.revision !== void 0) presentationMiss();
12145
+ if (!this.staleServerValues) {
12146
+ noteRecoverableHydrationError(() => new Error((0, import_error_codes_client_generated.formatClientError)(62)), this.rootBlock);
12147
+ if (__octaneDev) {
12148
+ warnHydrationStructuralMismatch(
12149
+ loc || el.__oct_loc,
12150
+ "nothing",
12151
+ describeHydrationNode(framed && next !== null ? next : first)
12152
+ );
12153
+ }
12154
+ }
12155
+ for (let n = getFirstChild(el); n !== null; n = getFirstChild(el))
12156
+ (STAGED_DOM?.view(el) ?? el).removeChild(n);
12157
+ }
11803
12158
  htextSwap(posNode, text) {
11804
12159
  if (isEmptyTextSlot(posNode)) {
11805
12160
  const empty = (STAGED_DOM?.view(document) ?? document).createTextNode("");
@@ -12168,6 +12523,43 @@ function htextSwap(posNode, value) {
12168
12523
  (STAGED_DOM?.view(parent) ?? parent).replaceChild(t, posNode);
12169
12524
  return t;
12170
12525
  }
12526
+ function rejectTextareaChild(child2) {
12527
+ throw new Error((0, import_error_codes_client_generated.formatClientError)(336, (0, import_shared_value_helpers.describeTextareaChild)(child2, isElementDescriptor)));
12528
+ }
12529
+ function textareaPartText(part, textHole2) {
12530
+ return textHole2 ? coerceText(part) : (0, import_shared_value_helpers.textareaChildText)(part, rejectTextareaChild);
12531
+ }
12532
+ function joinTextareaParts(parts, textHoles, read) {
12533
+ let text = "";
12534
+ for (let i = 0; i < parts.length; i++) {
12535
+ const part = parts[i];
12536
+ text += textareaPartText(
12537
+ isSignalHandle(part) ? read(part) : part,
12538
+ textHoles !== void 0 && textHoles.charCodeAt(i) === 116
12539
+ // 't'
12540
+ );
12541
+ }
12542
+ return text;
12543
+ }
12544
+ function textareaText(parts, textHoles) {
12545
+ let handles;
12546
+ for (const part of parts) if (isSignalHandle(part)) (handles ??= []).push(part);
12547
+ if (handles === void 0) return joinTextareaParts(parts, textHoles, readSignalBinding);
12548
+ const signals = handles;
12549
+ return {
12550
+ [import_types.SIGNAL_HANDLE]: true,
12551
+ kind: "derived",
12552
+ key: signals.map((handle) => handle.key).join("+"),
12553
+ [import_types.SIGNAL_BINDING_READ]: () => joinTextareaParts(parts, textHoles, readSignalBinding),
12554
+ get: () => joinTextareaParts(parts, textHoles, (handle) => handle.get()),
12555
+ [import_types.SIGNAL_BINDING_SUBSCRIBE](notify, onRetire) {
12556
+ const stops = signals.map((handle) => handle[import_types.SIGNAL_BINDING_SUBSCRIBE](notify, onRetire));
12557
+ return () => {
12558
+ for (const stop of stops) stop();
12559
+ };
12560
+ }
12561
+ };
12562
+ }
12171
12563
  function bindingText(posNode, value, marker) {
12172
12564
  const text = coerceText(value);
12173
12565
  const hydration = activeHydration();
@@ -12472,9 +12864,9 @@ function preparePresentationSignalBinding(args, frame, text = false) {
12472
12864
  if (witness >= 0)
12473
12865
  frame.witnesses.set(handle, finishNativeReadWitness(witness, readCompleted));
12474
12866
  }
12475
- if (text && (current !== null && (typeof current === "object" || typeof current === "function") || typeof args[7] !== "string"))
12867
+ if (text && (current !== null && (typeof current === "object" || typeof current === "function") || typeof args[8] !== "string"))
12476
12868
  presentationMiss(false);
12477
- const prepared = text ? bindingText(element, current, args[7]) : preparedPresentationAttribute(element, name, current, attributeKind);
12869
+ const prepared = text ? bindingText(element, current, args[8]) : preparedPresentationAttribute(element, name, current, attributeKind);
12478
12870
  if (handle === null) {
12479
12871
  if (text) {
12480
12872
  frame.writes.get(element)?.delete("signalText");
@@ -12764,8 +13156,7 @@ function presentationStructure(writer, kind, marker, ...args) {
12764
13156
  if (frame?.revision === void 0) return writer(...args);
12765
13157
  const hydration = activeHydration();
12766
13158
  if (hydration === null) presentationMiss(false);
12767
- const anchorIndex = kind === "if" ? 6 : 5;
12768
- const start = hydration.resolveOpen(args[anchorIndex] ?? null, args[2]);
13159
+ const start = hydration.resolveOpen(args[6] ?? null, args[2]);
12769
13160
  if (kind === "if") {
12770
13161
  const arm = args[3] ? args[4] === null ? -1 : 0 : args[5] === null ? -1 : 1;
12771
13162
  const range2 = presentationRange(frame, start, marker + arm, kind);
@@ -13258,8 +13649,8 @@ function bindDirectSignal(scope, previous, target, value, site, policy, name, at
13258
13649
  }
13259
13650
  return binding;
13260
13651
  }
13261
- function bindSignalText(scope, previous, position, value, site, onlyChild = false, seededText = void 0, bindingMarker, previousValue) {
13262
- if (previous instanceof Text && arguments.length > 8 && previousValue === value && !isSignalHandle(value))
13652
+ function bindSignalText(scope, previous, position, value, site, onlyChild = false, previousValue, seededText = void 0, bindingMarker) {
13653
+ if (previous instanceof Text && arguments.length > 6 && previousValue === value && !isSignalHandle(value))
13263
13654
  return previous;
13264
13655
  if (previous === void 0 && bindingMarker !== void 0) {
13265
13656
  const existing = activeHydration() !== null ? getNextSibling(position) : null;
@@ -13778,15 +14169,16 @@ class FragmentInstance {
13778
14169
  }
13779
14170
  /**
13780
14171
  * Blur the focused element only when a logical fragment child owns it,
13781
- * including children rendered into foreign portal containers.
14172
+ * including children rendered into foreign portal containers. Each child is
14173
+ * checked against its own focus root, so shadow-root and iframe portal
14174
+ * children resolve to the owned element rather than their host or frame.
13782
14175
  */
13783
14176
  blur() {
13784
14177
  if (this._destroyed) return;
13785
- const doc = this._startMarker.ownerDocument || document;
13786
- const active = doc.activeElement;
13787
- if (!active || active === doc.body) return;
13788
14178
  for (const child2 of fragmentDirectChildren(this)) {
13789
- if (child2 === active || (STAGED_DOM?.view(child2) ?? child2).contains(active)) {
14179
+ const root = (STAGED_DOM?.view(child2) ?? child2).getRootNode();
14180
+ const active = root.activeElement;
14181
+ if (active && (child2 === active || (STAGED_DOM?.view(child2) ?? child2).contains(active))) {
13790
14182
  (STAGED_DOM?.view(active) ?? active).blur();
13791
14183
  return;
13792
14184
  }
@@ -14153,6 +14545,10 @@ const HTML_NS = "http://www.w3.org/1999/xhtml";
14153
14545
  function isHtmlCustomElement(el) {
14154
14546
  return el.namespaceURI === HTML_NS && el.localName.indexOf("-") !== -1;
14155
14547
  }
14548
+ function isHostElementOfType(el, type) {
14549
+ const name = el.localName;
14550
+ return name === type || name === type.toLowerCase() && el.namespaceURI === HTML_NS;
14551
+ }
14156
14552
  function inferTagNs(tag, inherited) {
14157
14553
  if (tag === "svg") return SVG_NS;
14158
14554
  if (tag === "math") return MATHML_NS;
@@ -14841,7 +15237,8 @@ function setHostPropSources(el, sources, prev, scope, hasNestedChildren = false,
14841
15237
  props.get("defaultValue")?.value,
14842
15238
  props.get("checked")?.value,
14843
15239
  props.get("defaultChecked")?.value,
14844
- props.get("multiple")?.value
15240
+ props.get("multiple")?.value,
15241
+ hasNestedChildren || props.has("children")
14845
15242
  );
14846
15243
  return resolved;
14847
15244
  }
@@ -16748,7 +17145,8 @@ function armControlledBase(el) {
16748
17145
  compositionEndTask: void 0,
16749
17146
  queued: false,
16750
17147
  formSeen: false,
16751
- formMultiple: false
17148
+ formMultiple: false,
17149
+ formChildren: false
16752
17150
  };
16753
17151
  (STAGED_DOM?.view(el) ?? el).$$ctrl = ctrl;
16754
17152
  delegateEvents(RESTORE_EVENT_LIST);
@@ -17211,7 +17609,7 @@ function setFormControlSources(el, sources) {
17211
17609
  }
17212
17610
  applyFormControlValues(el, tag, value, defaultValue, checked, defaultChecked, multiple);
17213
17611
  }
17214
- function applyFormControlValues(el, tag, value, defaultValue, checked, defaultChecked, multiple) {
17612
+ function applyFormControlValues(el, tag, value, defaultValue, checked, defaultChecked, multiple, hasChildren = false) {
17215
17613
  const ctrl = armControlled(el);
17216
17614
  const first = !ctrl.formSeen;
17217
17615
  const previousMultiple = ctrl.formMultiple;
@@ -17241,10 +17639,12 @@ function applyFormControlValues(el, tag, value, defaultValue, checked, defaultCh
17241
17639
  }
17242
17640
  if (tag === "textarea") {
17243
17641
  const textarea = el;
17642
+ const childrenOwned = ctrl.formChildren;
17643
+ ctrl.formChildren = hasChildren;
17244
17644
  setValue(textarea, value);
17245
17645
  if (value == null) {
17246
17646
  if (defaultValue != null) setDefaultValue(textarea, defaultValue, first);
17247
- else if (!first && (STAGED_DOM?.view(textarea) ?? textarea).defaultValue !== "")
17647
+ else if (!first && !childrenOwned && (STAGED_DOM?.view(textarea) ?? textarea).defaultValue !== "")
17248
17648
  (STAGED_DOM?.view(textarea) ?? textarea).defaultValue = "";
17249
17649
  }
17250
17650
  return;
@@ -17595,7 +17995,8 @@ function portal(parentScope, slotKey, target, body, props, host, env, fragmentOw
17595
17995
  if (prev !== state) {
17596
17996
  journalRootProperty(parentScope.slots, slotKey, parentScope.slots[slotKey]);
17597
17997
  parentScope.slots[slotKey] = state;
17598
- registerSlot(parentScope, state);
17998
+ if (prev === void 0) registerSlot(parentScope, state);
17999
+ else replacePortalSlot(parentScope, prev, state);
17599
18000
  }
17600
18001
  if (fragmentOwners !== void 0 && fragmentAnchor !== void 0) {
17601
18002
  registerFragmentPortalOwners(state, fragmentOwners, fragmentAnchor);
@@ -17615,6 +18016,16 @@ function portal(parentScope, slotKey, target, body, props, host, env, fragmentOw
17615
18016
  }
17616
18017
  }
17617
18018
  }
18019
+ function replacePortalSlot(scope, prev, state) {
18020
+ const slots = scope._slots;
18021
+ const index = slots === null ? -1 : slots.indexOf(prev);
18022
+ if (index === -1) {
18023
+ registerSlot(scope, state);
18024
+ return;
18025
+ }
18026
+ journalRootProperty(slots, index, prev);
18027
+ slots[index] = state;
18028
+ }
17618
18029
  function prepareFragmentPortalInterleaving(portal2) {
17619
18030
  const start = portal2.start;
17620
18031
  const end = portal2.end;
@@ -17762,8 +18173,9 @@ function renderPortalState(prev, parentBlock, target, rawBody, rawProps, host, e
17762
18173
  );
17763
18174
  }
17764
18175
  const norm = normalizePortalBody(rawBody, rawProps);
18176
+ const childType = portalChildType(rawBody, norm.body);
17765
18177
  let state = prev;
17766
- if (state === null || state.target !== target || state.key !== key) {
18178
+ if (state === null || state.target !== target || state.key !== key || state.childType !== childType) {
17767
18179
  if (state !== null) teardownPortalState(state);
17768
18180
  const start = (STAGED_DOM?.view(document) ?? document).createComment("portal");
17769
18181
  const end = (STAGED_DOM?.view(document) ?? document).createComment("/portal");
@@ -17782,9 +18194,9 @@ function renderPortalState(prev, parentBlock, target, rawBody, rawProps, host, e
17782
18194
  renderReturnedValue
17783
18195
  );
17784
18196
  if (typeof __OCTANE_PROFILE_ENABLED__ !== "undefined" && __OCTANE_PROFILE_ENABLED__) {
17785
- (0, import_profiling.__profileTrackComponent)(block, profilePortalComponent(rawBody));
18197
+ (0, import_profiling.__profileTrackComponent)(block, profilePortalComponent(rawBody, norm.body));
17786
18198
  }
17787
- state = { __kind: "portalSlotSlot", block, target, key, host, start, end };
18199
+ state = { __kind: "portalSlotSlot", block, target, key, childType, host, start, end };
17788
18200
  registerPortalEventRange(target, state);
17789
18201
  activityPortalCreated?.(block);
17790
18202
  registerDelegationTarget(target);
@@ -17808,7 +18220,7 @@ function renderPortalState(prev, parentBlock, target, rawBody, rawProps, host, e
17808
18220
  state.block.props = norm.props;
17809
18221
  state.block.extra = env;
17810
18222
  if (typeof __OCTANE_PROFILE_ENABLED__ !== "undefined" && __OCTANE_PROFILE_ENABLED__) {
17811
- (0, import_profiling.__profileTrackComponent)(state.block, profilePortalComponent(rawBody));
18223
+ (0, import_profiling.__profileTrackComponent)(state.block, profilePortalComponent(rawBody, norm.body));
17812
18224
  }
17813
18225
  renderBlock(state.block);
17814
18226
  }
@@ -17853,7 +18265,7 @@ function normalizePortalBody(rawBody, rawProps) {
17853
18265
  if (typeof rawBody === "function") {
17854
18266
  return { body: rawBody, props: rawProps };
17855
18267
  }
17856
- if (rawBody != null && rawBody.$$kind === import_runtime_tags.ELEMENT_TAG && typeof rawBody.type === "function") {
18268
+ if (rawBody != null && rawBody.$$kind === import_runtime_tags.ELEMENT_TAG && typeof rawBody.type === "function" && rawBody.key === null) {
17857
18269
  return {
17858
18270
  body: rawBody.type,
17859
18271
  props: rawBody.props
@@ -17864,6 +18276,9 @@ function normalizePortalBody(rawBody, rawProps) {
17864
18276
  props: rawBody
17865
18277
  };
17866
18278
  }
18279
+ function portalChildType(rawBody, body) {
18280
+ return typeof rawBody === "function" ? null : body;
18281
+ }
17867
18282
  function genericPortalBody(value, scope) {
17868
18283
  childSlot(scope, 0, scope.parentNode, value, scope.endMarker);
17869
18284
  }
@@ -18416,7 +18831,7 @@ const Children = {
18416
18831
  }
18417
18832
  };
18418
18833
  const NO_KEY = /* @__PURE__ */ Symbol("NO_KEY");
18419
- function componentSlot(parentScope, slotKey, domParent, comp, props, anchor, key, singleRoot, inherit, hasKey, invocationSite) {
18834
+ function componentSlot(parentScope, slotKey, domParent, comp, props, invocationSite, anchor, singleRoot, inherit, key, hasKey) {
18420
18835
  const dispatch = activityDescriptorDispatch;
18421
18836
  const activity = dispatch !== null && comp === dispatch.type;
18422
18837
  if (!activity && typeof comp !== "function" && typeof comp !== "string") {
@@ -18456,7 +18871,7 @@ function componentSlot(parentScope, slotKey, domParent, comp, props, anchor, key
18456
18871
  invocationSite
18457
18872
  );
18458
18873
  }
18459
- function componentSlotVoid(parentScope, slotKey, domParent, comp, props, anchor, key, singleRoot, inherit, hasKey, invocationSite) {
18874
+ function componentSlotVoid(parentScope, slotKey, domParent, comp, props, invocationSite, anchor, singleRoot, inherit, key, hasKey) {
18460
18875
  if (typeof comp !== "function") throw invalidElementTypeError(comp);
18461
18876
  componentSlotImpl(
18462
18877
  null,
@@ -19190,7 +19605,7 @@ function hasDangerHTML(props) {
19190
19605
  return true;
19191
19606
  }
19192
19607
  function hasHostPropContent(descriptor) {
19193
- return hasDangerHTML(descriptor.props) || descriptor.type === "textarea" && (descriptor.props?.value != null || descriptor.props?.defaultValue != null);
19608
+ return hasDangerHTML(descriptor.props) || isTextareaTag(descriptor.type) && (descriptor.props?.value != null || descriptor.props?.defaultValue != null);
19194
19609
  }
19195
19610
  function markInputCheckedness(input) {
19196
19611
  (STAGED_DOM?.view(input) ?? input).checked = (STAGED_DOM?.view(input) ?? input).checked;
@@ -19623,7 +20038,7 @@ function reconcileDeoptNode(prev, value, ownerBlock, ns) {
19623
20038
  if (isHostDescriptor(value)) {
19624
20039
  const elNs = inferTagNs(value.type, ns);
19625
20040
  let el;
19626
- if (prev !== null && prev.nodeType === 1 && prev.localName === value.type && prev.namespaceURI === (elNs ?? HTML_NS)) {
20041
+ if (prev !== null && prev.nodeType === 1 && isHostElementOfType(prev, value.type) && prev.namespaceURI === (elNs ?? HTML_NS)) {
19627
20042
  el = prev;
19628
20043
  patchDeoptProps(el, getDeoptDesc(el)?.props ?? null, value.props, ownerBlock);
19629
20044
  } else {
@@ -19633,7 +20048,11 @@ function reconcileDeoptNode(prev, value, ownerBlock, ns) {
19633
20048
  }
19634
20049
  setDeoptDesc(el, value);
19635
20050
  if (!hasHostPropContent(value)) {
19636
- reconcileDeoptChildren(el, value.children, ownerBlock);
20051
+ reconcileDeoptChildren(
20052
+ el,
20053
+ isHtmlTextareaType(value.type, elNs) ? (0, import_shared_value_helpers.textareaChildText)(value.children, rejectTextareaChild) : value.children,
20054
+ ownerBlock
20055
+ );
19637
20056
  }
19638
20057
  return el;
19639
20058
  }
@@ -19694,7 +20113,7 @@ function reconcileDeoptChildren(el, children, ownerBlock) {
19694
20113
  }
19695
20114
  const stampedKey = scan.$$deoptKey;
19696
20115
  const descriptor = stampedKey === void 0 ? getDeoptDesc(scan) : void 0;
19697
- if (stampedKey === void 0 && descriptor === void 0 && !(hydrationOwnsUnstamped ??= activeHydration() !== null)) {
20116
+ if (stampedKey === void 0 && descriptor === void 0 && (!(hydrationOwnsUnstamped ??= activeHydration() !== null) || isTextSeparator(scan))) {
19698
20117
  hasForeign = true;
19699
20118
  scan = getNextSibling(scan);
19700
20119
  continue;
@@ -19773,7 +20192,7 @@ function nextDeoptOwnedChild(scan, adoptHydrationChildren) {
19773
20192
  scan = nodeAfterPortalRange(scan, rangeEnd);
19774
20193
  continue;
19775
20194
  }
19776
- if (!adoptHydrationChildren && scan.$$deoptKey === void 0 && getDeoptDesc(scan) === void 0) {
20195
+ if (adoptHydrationChildren ? isTextSeparator(scan) : scan.$$deoptKey === void 0 && getDeoptDesc(scan) === void 0) {
19777
20196
  scan = getNextSibling(scan);
19778
20197
  continue;
19779
20198
  }
@@ -19806,7 +20225,7 @@ function deoptItemBody(item, scope) {
19806
20225
  let transfer = null;
19807
20226
  if (stale != null) {
19808
20227
  journalRootProperty(block, "deoptNode", block.deoptNode);
19809
- if (scope.slots[0] === void 0 && stale.nodeType === 1 && isHostDescriptor(item) && stale.localName === item.type && (STAGED_DOM?.view(stale) ?? stale).parentNode === block.parentNode) {
20228
+ if (scope.slots[0] === void 0 && stale.nodeType === 1 && isHostDescriptor(item) && isHostElementOfType(stale, item.type) && (STAGED_DOM?.view(stale) ?? stale).parentNode === block.parentNode) {
19810
20229
  transfer = stale;
19811
20230
  } else if ((STAGED_DOM?.view(stale) ?? stale).parentNode === block.parentNode) {
19812
20231
  if (ROOT_RENDER_TRANSACTION !== null) {
@@ -19825,21 +20244,7 @@ function deoptItemBody(item, scope) {
19825
20244
  block.deoptNode = null;
19826
20245
  }
19827
20246
  if (hydration !== null && scope.slots[0] === void 0 && hydration.isOpen(block.startMarker)) {
19828
- const seeded = {
19829
- __kind: "childSlot",
19830
- start: block.startMarker,
19831
- end: block.endMarker,
19832
- ownerHost: null,
19833
- borrowed: true,
19834
- compactable: false,
19835
- block: null,
19836
- text: null,
19837
- currentComp: null,
19838
- currentIsBodyFn: false,
19839
- forSlot: null,
19840
- hostNode: null,
19841
- portal: null
19842
- };
20247
+ const seeded = hydration.lendRange(block.startMarker, block.endMarker);
19843
20248
  scope.slots[0] = seeded;
19844
20249
  registerSlot(scope, seeded);
19845
20250
  }
@@ -19956,12 +20361,10 @@ function mappedDeoptItemBody(item, scope) {
19956
20361
  block.parentNode,
19957
20362
  item.type,
19958
20363
  item.props,
20364
+ item.__octaneInvocationSite,
19959
20365
  block.endMarker,
19960
- void 0,
19961
- true,
19962
20366
  true,
19963
- void 0,
19964
- item.__octaneInvocationSite
20367
+ true
19965
20368
  );
19966
20369
  return;
19967
20370
  }
@@ -19999,11 +20402,31 @@ function descNeedsBlocks(value) {
19999
20402
  if (value.$$kind === import_runtime_tags.PORTAL_TAG) return true;
20000
20403
  return false;
20001
20404
  }
20405
+ function isTextareaTag(type) {
20406
+ return type === "textarea" || type.length === 8 && type.toLowerCase() === "textarea";
20407
+ }
20408
+ function isHtmlTextareaType(type, elNs) {
20409
+ return elNs === void 0 && isTextareaTag(type);
20410
+ }
20411
+ function deoptHostChildren(block, el, d, elNs, adopt = false) {
20412
+ if (!isHtmlTextareaType(d.type, elNs)) {
20413
+ childSlot(block, 0, el, d.children, null, false, el);
20414
+ return;
20415
+ }
20416
+ const text = adopt ? null : getFirstChild(el);
20417
+ childTextHole(
20418
+ block,
20419
+ 0,
20420
+ el,
20421
+ (0, import_shared_value_helpers.textareaChildText)(d.children, rejectTextareaChild),
20422
+ text?.nodeType === 3 ? text : null
20423
+ );
20424
+ }
20002
20425
  function hostElementBody(d, block) {
20003
20426
  let el = block.deoptNode;
20004
20427
  const hydration = activeHydration();
20005
20428
  const elNs = inferTagNs(d.type, deoptChildNamespace(block.parentNode));
20006
- if (el === null && hydration !== null && hydration.node !== null && hydration.node.nodeType === 1 && hydration.node.localName === d.type && (elNs === void 0 || hydration.node.namespaceURI === elNs)) {
20429
+ if (el === null && hydration !== null && hydration.node !== null && hydration.node.nodeType === 1 && isHostElementOfType(hydration.node, d.type) && (elNs === void 0 || hydration.node.namespaceURI === elNs)) {
20007
20430
  el = hydration.node;
20008
20431
  block.deoptNode = el;
20009
20432
  applyDeoptProps(el, d.props, block);
@@ -20011,7 +20434,7 @@ function hostElementBody(d, block) {
20011
20434
  const savedCursor = getNextSibling(hydration.node);
20012
20435
  if (!hasHostPropContent(d)) {
20013
20436
  hydration.node = getFirstChild(el);
20014
- childSlot(block, 0, el, d.children, null, false, el);
20437
+ deoptHostChildren(block, el, d, elNs, true);
20015
20438
  }
20016
20439
  hydration.node = savedCursor;
20017
20440
  return;
@@ -20039,11 +20462,11 @@ function hostElementBody(d, block) {
20039
20462
  applyDeoptProps(el, d.props, block);
20040
20463
  setDeoptDesc(el, d);
20041
20464
  if (!hasHostPropContent(d)) {
20042
- hydration.suspend(() => childSlot(block, 0, el, d.children, null, false, el));
20465
+ hydration.suspend(() => deoptHostChildren(block, el, d, elNs));
20043
20466
  }
20044
20467
  return;
20045
20468
  }
20046
- if (el === null || el.localName !== d.type || elNs !== void 0 && el.namespaceURI !== elNs) {
20469
+ if (el === null || !isHostElementOfType(el, d.type) || elNs !== void 0 && el.namespaceURI !== elNs) {
20047
20470
  if (el !== null) {
20048
20471
  const retired = el;
20049
20472
  if (ROOT_RENDER_TRANSACTION !== null) {
@@ -20079,7 +20502,7 @@ function hostElementBody(d, block) {
20079
20502
  patchDeoptProps(el, getDeoptDesc(el)?.props ?? null, d.props, block);
20080
20503
  }
20081
20504
  setDeoptDesc(el, d);
20082
- if (!hasHostPropContent(d)) childSlot(block, 0, el, d.children, null, false, el);
20505
+ if (!hasHostPropContent(d)) deoptHostChildren(block, el, d, elNs);
20083
20506
  }
20084
20507
  function hostStringTagBody(d, block) {
20085
20508
  const tag = d.type;
@@ -20087,7 +20510,7 @@ function hostStringTagBody(d, block) {
20087
20510
  const hydration = activeHydration();
20088
20511
  const elNs = inferTagNs(tag, deoptChildNamespace(block.parentNode));
20089
20512
  if (el === null) {
20090
- if (hydration !== null && hydration.node !== null && hydration.node.nodeType === 1 && hydration.node.localName === tag && (elNs === void 0 || hydration.node.namespaceURI === elNs)) {
20513
+ if (hydration !== null && hydration.node !== null && hydration.node.nodeType === 1 && isHostElementOfType(hydration.node, tag) && (elNs === void 0 || hydration.node.namespaceURI === elNs)) {
20091
20514
  el = hydration.node;
20092
20515
  block.deoptNode = el;
20093
20516
  applyDeoptProps(el, d.props, block);
@@ -20207,7 +20630,7 @@ function buildDeoptAdoptQueue(oldChildren, start, end) {
20207
20630
  if (cursor === null || cursor === end) break;
20208
20631
  const t = typeof v;
20209
20632
  const isText = t === "string" || t === "number" || t === "bigint";
20210
- const compatible = isText ? cursor.nodeType === 3 : isHostDescriptor(v) ? cursor.nodeType === 1 && cursor.localName === v.type : false;
20633
+ const compatible = isText ? cursor.nodeType === 3 : isHostDescriptor(v) ? cursor.nodeType === 1 && isHostElementOfType(cursor, v.type) : false;
20211
20634
  if (!compatible) break;
20212
20635
  queue.push({ key: keys[i], node: cursor });
20213
20636
  cursor = getNextSibling(cursor);
@@ -20632,6 +21055,7 @@ function renderPreparedChildList(state, parentBlock, domParent, preparedList, hy
20632
21055
  if (passthroughStart !== null || passthroughEnd !== null) state.forSlot = null;
20633
21056
  throw error;
20634
21057
  }
21058
+ if (hydration !== null && !passthroughList) hydration.discardLeftoverItems(state.forSlot.end);
20635
21059
  } else {
20636
21060
  reconcileKeyed(
20637
21061
  parentBlock,
@@ -20882,7 +21306,7 @@ function childSlot(parentScope, slotKey, domParent, value, anchor, ownEnd, ownsH
20882
21306
  const component = pureHost || preparedList !== null ? null : isHostDescriptor(value) ? hostElementBody : valueComponent;
20883
21307
  const unchangedList = preparedList !== null && state.forSlot !== null;
20884
21308
  const unchangedComponent = state.block !== null && component !== null && (component === state.currentComp || typeof value === "function" && state.currentIsBodyFn);
20885
- const unchangedHost = pureHost && state.hostNode !== null && state.block === null && state.hostNode.nodeType === 1 && state.hostNode.localName === value.type;
21309
+ const unchangedHost = pureHost && state.hostNode !== null && state.block === null && state.hostNode.nodeType === 1 && isHostElementOfType(state.hostNode, value.type);
20886
21310
  const primitive = value == null || typeof value !== "object" && typeof value !== "function";
20887
21311
  const text = primitive ? coerceChildText(value) : null;
20888
21312
  const unchangedText = primitive && state.block === null && state.forSlot === null && state.hostNode === null && state.portal === null && state.text === null === (text === "");
@@ -20924,6 +21348,8 @@ function childSlot(parentScope, slotKey, domParent, value, anchor, ownEnd, ownsH
20924
21348
  return;
20925
21349
  }
20926
21350
  }
21351
+ let adoptedRange = false;
21352
+ let rebuild = false;
20927
21353
  if (state === void 0) {
20928
21354
  const transaction = ROOT_RENDER_TRANSACTION;
20929
21355
  if (transaction !== null && !transaction.aborted && !ROOT_RENDER_ROLLBACK && parentScope.mounted && !isCreatedInRootRender(transaction, parentBlock)) {
@@ -20944,6 +21370,7 @@ function childSlot(parentScope, slotKey, domParent, value, anchor, ownEnd, ownsH
20944
21370
  end = hydration.close(anchor);
20945
21371
  if (parentBlock === hydration.rootBlock) hydration.claimRootRemainder(getNextSibling(end));
20946
21372
  hydration.node = getNextSibling(start);
21373
+ adoptedRange = true;
20947
21374
  } else if (hydration !== null && hydration.isOpen(hydration.node)) {
20948
21375
  start = hydration.node;
20949
21376
  end = hydration.close(hydration.node);
@@ -20952,6 +21379,7 @@ function childSlot(parentScope, slotKey, domParent, value, anchor, ownEnd, ownsH
20952
21379
  hydration.claimRootRemainder(getNextSibling(end));
20953
21380
  }
20954
21381
  hydration.node = getNextSibling(start);
21382
+ adoptedRange = true;
20955
21383
  } else if (bindingMarker !== void 0) {
20956
21384
  start = (STAGED_DOM?.view(document) ?? document).createComment(bindingMarker);
20957
21385
  end = ownEnd && anchor != null ? anchor : (STAGED_DOM?.view(document) ?? document).createComment(import_constants.HYDRATION_END);
@@ -20970,6 +21398,15 @@ function childSlot(parentScope, slotKey, domParent, value, anchor, ownEnd, ownsH
20970
21398
  end = null;
20971
21399
  } else {
20972
21400
  start = null;
21401
+ if (hydration !== null && ownsHost === void 0)
21402
+ rebuild = hydration.discardServerText(
21403
+ parentScope,
21404
+ slotKey,
21405
+ domParent,
21406
+ anchor ?? null,
21407
+ value,
21408
+ preparedList !== null && compiledMapBody === void 0 && mappedFallback !== true
21409
+ );
20973
21410
  end = (STAGED_DOM?.view(document) ?? document).createComment("");
20974
21411
  (STAGED_DOM?.view(domParent) ?? domParent).insertBefore(end, anchor ?? null);
20975
21412
  if (hydration !== null && parentBlock === hydration.rootBlock)
@@ -20993,7 +21430,19 @@ function childSlot(parentScope, slotKey, domParent, value, anchor, ownEnd, ownsH
20993
21430
  };
20994
21431
  parentScope.slots[slotKey] = state;
20995
21432
  registerSlot(parentScope, state);
21433
+ } else if (hydration !== null && hydration.lentSlot === state) {
21434
+ hydration.lentSlot = null;
21435
+ adoptedRange = true;
20996
21436
  }
21437
+ if (adoptedRange)
21438
+ rebuild = hydration.claimRange(
21439
+ parentScope,
21440
+ slotKey,
21441
+ state.start,
21442
+ state.end,
21443
+ value,
21444
+ compiledMapBody === void 0 && mappedFallback !== true ? preparedList : null
21445
+ );
20997
21446
  if (compactable === true) state.compactable = true;
20998
21447
  let upgradeChildren = void 0;
20999
21448
  let upgradeArmed = false;
@@ -21049,6 +21498,21 @@ function childSlot(parentScope, slotKey, domParent, value, anchor, ownEnd, ownsH
21049
21498
  return;
21050
21499
  }
21051
21500
  if (preparedList !== null) {
21501
+ if (rebuild) {
21502
+ const slot = state;
21503
+ hydration.suspend(
21504
+ () => renderPreparedChildList(
21505
+ slot,
21506
+ parentBlock,
21507
+ domParent,
21508
+ preparedList,
21509
+ null,
21510
+ upgradeArmed,
21511
+ upgradeChildren
21512
+ )
21513
+ );
21514
+ return;
21515
+ }
21052
21516
  renderPreparedChildList(
21053
21517
  state,
21054
21518
  parentBlock,
@@ -21260,7 +21724,7 @@ function childSlot(parentScope, slotKey, domParent, value, anchor, ownEnd, ownsH
21260
21724
  return;
21261
21725
  }
21262
21726
  }
21263
- if (hydration === null && comp === hostElementBody && state.block === null && state.hostNode !== null && state.hostNode.nodeType === 1 && state.hostNode.localName === props.type && state.hostNode.namespaceURI === (inferTagNs(props.type, deoptChildNamespace(domParent)) ?? HTML_NS) && !hasDangerHTML(props.props) && !hasDangerHTML(getDeoptDesc(state.hostNode)?.props ?? null)) {
21727
+ if (hydration === null && comp === hostElementBody && state.block === null && state.hostNode !== null && state.hostNode.nodeType === 1 && isHostElementOfType(state.hostNode, props.type) && state.hostNode.namespaceURI === (inferTagNs(props.type, deoptChildNamespace(domParent)) ?? HTML_NS) && !hasDangerHTML(props.props) && !hasDangerHTML(getDeoptDesc(state.hostNode)?.props ?? null)) {
21264
21728
  const el = state.hostNode;
21265
21729
  state.hostNode = null;
21266
21730
  state.currentComp = comp;
@@ -21381,7 +21845,11 @@ function childSlot(parentScope, slotKey, domParent, value, anchor, ownEnd, ownsH
21381
21845
  b.memoInChain = true;
21382
21846
  }
21383
21847
  state.block = b;
21384
- renderBlock(b);
21848
+ if (rebuild) {
21849
+ hydration.suspend(() => renderBlock(b));
21850
+ } else {
21851
+ renderBlock(b);
21852
+ }
21385
21853
  if (hydration !== null && !state.borrowed && state.end !== null) {
21386
21854
  hydration.node = getNextSibling(state.end);
21387
21855
  }
@@ -21390,6 +21858,7 @@ function childSlot(parentScope, slotKey, domParent, value, anchor, ownEnd, ownsH
21390
21858
  if (value !== null && typeof value === "object") throw invalidChildError(value);
21391
21859
  if (state.block !== null || state.hostNode !== null) clearChildContent(state);
21392
21860
  const str = coerceChildText(value);
21861
+ if (adoptedRange) hydration.discardUnadoptedText(parentScope, slotKey, state, str);
21393
21862
  if (str === "") {
21394
21863
  if (state.text !== null) {
21395
21864
  if (ROOT_RENDER_TRANSACTION !== null) clearChildContent(state);
@@ -21475,17 +21944,22 @@ function childTextHole(parentScope, slotKey, domParent, value, cachedNode) {
21475
21944
  throw new Error((0, import_error_codes_client_generated.formatClientError)(26, domParent.localName));
21476
21945
  }
21477
21946
  if (dangerouslySetInnerHTMLOwnsChild(domParent, value)) return null;
21478
- const vt = typeof value;
21947
+ let vt = typeof value;
21479
21948
  const state = parentScope.slots[slotKey];
21949
+ if (state === void 0 && (vt === "object" || vt === "function") && domParent.nodeType === 1 && domParent.localName === "textarea" && domParent.namespaceURI === HTML_NS && !isSignalHandle(value)) {
21950
+ value = (0, import_shared_value_helpers.textareaChildText)(value, rejectTextareaChild);
21951
+ vt = "string";
21952
+ }
21480
21953
  if (ROOT_RENDER_TRANSACTION !== null && state === void 0 && parentScope.mounted) {
21481
21954
  journalBag();
21482
21955
  journalRootRange(domParent, null, null);
21483
21956
  journalRootProperty(parentScope.slots, slotKey, parentScope.slots[slotKey]);
21484
21957
  }
21485
- if (state === void 0 && vt !== "object" && vt !== "function") {
21958
+ if (state === void 0 && (value === null || vt !== "object" && vt !== "function")) {
21486
21959
  const str = value == null || value === false || value === true ? "" : vt === "string" ? value : String(value);
21487
21960
  if (str === "") {
21488
21961
  if (cachedNode !== null) (STAGED_DOM?.view(cachedNode) ?? cachedNode).remove();
21962
+ else activeHydration()?.hempty(domParent, siteLoc(parentScope, slotKey));
21489
21963
  return null;
21490
21964
  }
21491
21965
  if (cachedNode !== null) {
@@ -21493,16 +21967,25 @@ function childTextHole(parentScope, slotKey, domParent, value, cachedNode) {
21493
21967
  return cachedNode;
21494
21968
  }
21495
21969
  const hydration2 = activeHydration();
21496
- if (hydration2 !== null) return hydration2.htext(domParent, str, siteLoc(parentScope, slotKey));
21497
- const tn = (STAGED_DOM?.view(document) ?? document).createTextNode(str);
21498
- (STAGED_DOM?.view(domParent) ?? domParent).appendChild(tn);
21499
- return tn;
21970
+ if (hydration2 === null) {
21971
+ const tn = (STAGED_DOM?.view(document) ?? document).createTextNode(str);
21972
+ (STAGED_DOM?.view(domParent) ?? domParent).appendChild(tn);
21973
+ return tn;
21974
+ }
21975
+ if (!hydration2.framesSlotContent(domParent))
21976
+ return hydration2.htext(domParent, str, siteLoc(parentScope, slotKey));
21500
21977
  }
21501
21978
  if (state === void 0 && cachedNode !== null)
21502
21979
  (STAGED_DOM?.view(cachedNode) ?? cachedNode).remove();
21503
21980
  const hydration = activeHydration();
21504
- if (hydration !== null && state === void 0) hydration.node = getFirstChild(domParent);
21505
- childSlot(parentScope, slotKey, domParent, value, null, false, domParent);
21981
+ if (hydration !== null && state === void 0)
21982
+ hydration.hydrateOnlyChild(
21983
+ parentScope,
21984
+ slotKey,
21985
+ domParent,
21986
+ () => childSlot(parentScope, slotKey, domParent, value, null, false, domParent)
21987
+ );
21988
+ else childSlot(parentScope, slotKey, domParent, value, null, false, domParent);
21506
21989
  const s = parentScope.slots[slotKey];
21507
21990
  return s.block === null && s.forSlot === null && s.hostNode === null ? s.text : null;
21508
21991
  }
@@ -22235,7 +22718,7 @@ function mountPassthroughPending(state, thenable) {
22235
22718
  setTryBranch(state, -1);
22236
22719
  scheduleRender(state.parentBlock);
22237
22720
  };
22238
- thenable.then(retry, retry);
22721
+ resumeOnSettle(thenable, retry);
22239
22722
  }
22240
22723
  function renderPassthroughTry(state) {
22241
22724
  if (state.branch === 0 && state.block !== null) {
@@ -22892,7 +23375,7 @@ function renderInitialSuspenseHydration(state, initial) {
22892
23375
  return;
22893
23376
  scheduleRender(state.parentBlock);
22894
23377
  };
22895
- suspended.then(resume, resume);
23378
+ resumeOnSettle(suspended, resume);
22896
23379
  return;
22897
23380
  }
22898
23381
  initialSuspenseHydrations?.delete(state);
@@ -23961,7 +24444,7 @@ function attachResume(state, thenable) {
23961
24444
  commitResume(state);
23962
24445
  }
23963
24446
  };
23964
- thenable.then(retry, retry);
24447
+ resumeOnSettle(thenable, retry);
23965
24448
  }
23966
24449
  function startTransition(fn) {
23967
24450
  runTransition(fn);
@@ -24126,6 +24609,7 @@ function useActionState(action, initialState, permalinkOrSlot, slot) {
24126
24609
  };
24127
24610
  const dispatch = ((payload) => {
24128
24611
  const outsideTransition = __octaneDev && transitionActionBatchForUpdate() === null && ACTIVE_SUBMIT_DISPATCH?.intercepted !== true;
24612
+ const run = slotRef.action;
24129
24613
  slotRef.pendingCount++;
24130
24614
  setPending(true);
24131
24615
  slotRef.chain = slotRef.chain.then(
@@ -24137,7 +24621,7 @@ function useActionState(action, initialState, permalinkOrSlot, slot) {
24137
24621
  startTransition(() => {
24138
24622
  let p;
24139
24623
  try {
24140
- const result = slotRef.action(prevState, payload);
24624
+ const result = run(prevState, payload);
24141
24625
  if (__octaneDev && outsideTransition && result != null && typeof result.then === "function") {
24142
24626
  console.error(
24143
24627
  "An async useActionState action was dispatched outside a transition or action. Use an action/formAction prop or wrap the dispatch in startTransition."
@@ -24233,6 +24717,9 @@ function useFormStatus(slot) {
24233
24717
  }
24234
24718
  return s.form ? FORM_STATUS.get(s.form) ?? IDLE_FORM_STATUS : IDLE_FORM_STATUS;
24235
24719
  }
24720
+ function basicOptimisticReducer(state, value) {
24721
+ return typeof value === "function" ? value(state) : value;
24722
+ }
24236
24723
  function useOptimistic(passthrough, updateFnOrSlot, slot) {
24237
24724
  let updateFn;
24238
24725
  if (typeof updateFnOrSlot === "symbol") slot = updateFnOrSlot;
@@ -24256,7 +24743,6 @@ function useOptimistic(passthrough, updateFnOrSlot, slot) {
24256
24743
  };
24257
24744
  const slotRef = {
24258
24745
  queue: [],
24259
- updateFn,
24260
24746
  armed: false,
24261
24747
  add: (value) => {
24262
24748
  if (__octaneDev && TRANSITION_DEPTH === 0 && ASYNC_TRANSITION_COUNT === 0) {
@@ -24285,11 +24771,9 @@ function useOptimistic(passthrough, updateFnOrSlot, slot) {
24285
24771
  TRANSITION_LISTENERS.add(listener);
24286
24772
  registerHookCleanup(scope, () => TRANSITION_LISTENERS.delete(listener));
24287
24773
  }
24288
- s.updateFn = updateFn;
24289
24774
  let optimistic = passthrough;
24290
- for (let i = 0; i < s.queue.length; i++) {
24291
- optimistic = s.updateFn ? s.updateFn(optimistic, s.queue[i]) : s.queue[i];
24292
- }
24775
+ const reduce = updateFn ?? basicOptimisticReducer;
24776
+ for (let i = 0; i < s.queue.length; i++) optimistic = reduce(optimistic, s.queue[i]);
24293
24777
  return [optimistic, s.add];
24294
24778
  }
24295
24779
  function spawnDeferredSwap(s) {
@@ -24947,7 +25431,13 @@ function renderBranchSlot(parentScope, slotKey, state, domParent, next, body, ma
24947
25431
  );
24948
25432
  state.block = b;
24949
25433
  state.markerlessBefore = before;
24950
- renderBlock(b);
25434
+ try {
25435
+ renderBlock(b);
25436
+ } catch (error) {
25437
+ if ((before ? getNextSibling(before) : getFirstChild(domParent)) !== after)
25438
+ finalizeMarkerlessBranch(state, domParent, b, marker, before, after);
25439
+ throw error;
25440
+ }
24951
25441
  finalizeMarkerlessBranch(state, domParent, b, marker, before, after);
24952
25442
  replaceSharedBlockBoundary(
24953
25443
  parentBlock,
@@ -25275,7 +25765,7 @@ function suspendHiddenActivity(state, thenable) {
25275
25765
  if (state.pendingThenable !== thenable || !state.hidden || blockSubtreeDisposed(block)) return;
25276
25766
  scheduleRender(block);
25277
25767
  };
25278
- thenable.then(retry, retry);
25768
+ resumeOnSettle(thenable, retry);
25279
25769
  }
25280
25770
  function renderHiddenActivity(state, replay = false, block = state.block) {
25281
25771
  const previousReplay = RESUME_REPLAY;
@@ -25808,7 +26298,7 @@ function forBlock(parentScope, slotKey, domParent, inputItems, getKey, itemBody,
25808
26298
  (f & 2) !== 0,
25809
26299
  (f & 16) !== 0
25810
26300
  );
25811
- if (hydration !== null) discardLeftoverHydrationItems(state.end, hydration);
26301
+ if (hydration !== null) hydration.discardLeftoverItems(state.end);
25812
26302
  } else {
25813
26303
  reconcileKeyed(
25814
26304
  parentBlock,
@@ -26054,13 +26544,6 @@ function fastMapSlot(scopeOrItems, slotOrMethod, domParent, items, method, nativ
26054
26544
  true
26055
26545
  );
26056
26546
  }
26057
- function discardLeftoverHydrationItems(end, hydration) {
26058
- const n = hydration.node;
26059
- if (n === null || n === end || (STAGED_DOM?.view(n) ?? n).parentNode !== (STAGED_DOM?.view(end) ?? end).parentNode)
26060
- return;
26061
- noteRecoverableHydrationError(() => new Error((0, import_error_codes_client_generated.formatClientError)(56)));
26062
- removeRange(n, end);
26063
- }
26064
26547
  function removeRange(from, end) {
26065
26548
  let n = from;
26066
26549
  while (n !== null && n !== end) {
@@ -26810,87 +27293,65 @@ function batchClearItems(state, oldItems, ownedRootClear = false) {
26810
27293
  function mountItem(parentBlock, parentNode, anchor, item, index, key, body, forSlot, singleRoot, ssrMarkerless, adoptNode = null) {
26811
27294
  const hydration = activeHydration();
26812
27295
  if (hydration !== null) {
26813
- if (ssrMarkerless && !hydration.isOpen(hydration.node) && (singleRoot !== 2 || forSlot.plainDeopt !== true || isHostDescriptor(item) && !descNeedsBlocks(item))) {
26814
- if (hydration.node !== null && hydration.node !== forSlot.end && (singleRoot !== 2 || forSlot.plainDeopt !== true || hydration.node.nodeType === 1 && domNode(hydration.node).parentNode === parentNode)) {
26815
- const root = hydration.node;
26816
- const block3 = createBlock(
27296
+ const node = hydration.node;
27297
+ if (ssrMarkerless && !hydration.isOpen(node) && (singleRoot !== 2 || forSlot.plainDeopt !== true || isHostDescriptor(item) && !descNeedsBlocks(item))) {
27298
+ if (node !== null && node !== forSlot.end && (singleRoot !== 2 || forSlot.plainDeopt !== true || node.nodeType === 1 && domNode(node).parentNode === parentNode && isHostElementOfType(node, item.type))) {
27299
+ const block2 = createBlock(
26817
27300
  "control-flow",
26818
27301
  parentBlock,
26819
27302
  parentNode,
26820
- root,
26821
- root,
27303
+ node,
27304
+ node,
26822
27305
  body,
26823
27306
  item,
26824
27307
  forSlot.env
26825
27308
  );
26826
- block3.forSlot = forSlot;
26827
- block3.key = key;
26828
- block3.itemIndex = index;
26829
- if (singleRoot === 2 && forSlot.plainDeopt === true) block3.deoptNode = root;
26830
- renderBlock(block3);
26831
- hydration.node = domNode(block3.endMarker)?.nextSibling ?? getNextSibling(root);
26832
- return block3;
26833
- }
26834
- if (__octaneDev) {
26835
- const mmLoc = parentNode.__oct_loc;
26836
- if (mmLoc)
26837
- hydration.warnStructural(mmLoc, "another list item", hydration.describe(hydration.node));
26838
- }
26839
- return hydration.suspend(
26840
- () => mountItem(
26841
- parentBlock,
26842
- parentNode,
26843
- anchor,
26844
- item,
26845
- index,
26846
- key,
26847
- body,
26848
- forSlot,
26849
- singleRoot,
26850
- ssrMarkerless
26851
- )
26852
- );
26853
- }
26854
- if (!hydration.isOpen(hydration.node)) {
26855
- if (__octaneDev) {
26856
- const mmLoc = parentNode.__oct_loc;
26857
- if (mmLoc)
26858
- hydration.warnStructural(mmLoc, "another list item", hydration.describe(hydration.node));
26859
- }
26860
- return hydration.suspend(
26861
- () => mountItem(
26862
- parentBlock,
26863
- parentNode,
26864
- anchor,
26865
- item,
26866
- index,
26867
- key,
26868
- body,
26869
- forSlot,
26870
- singleRoot,
26871
- ssrMarkerless
26872
- )
27309
+ block2.forSlot = forSlot;
27310
+ block2.key = key;
27311
+ block2.itemIndex = index;
27312
+ if (singleRoot === 2 && forSlot.plainDeopt === true) block2.deoptNode = node;
27313
+ renderBlock(block2);
27314
+ hydration.node = domNode(block2.endMarker)?.nextSibling ?? getNextSibling(node);
27315
+ return block2;
27316
+ }
27317
+ } else if (hydration.isOpen(node)) {
27318
+ const itemEnd = hydration.close(node);
27319
+ hydration.node = getNextSibling(node);
27320
+ const block2 = createBlock(
27321
+ "control-flow",
27322
+ parentBlock,
27323
+ parentNode,
27324
+ node,
27325
+ itemEnd,
27326
+ body,
27327
+ item,
27328
+ forSlot.env
26873
27329
  );
26874
- }
26875
- const itemStart = hydration.node;
26876
- const itemEnd = hydration.close(itemStart);
26877
- hydration.node = getNextSibling(itemStart);
26878
- const block2 = createBlock(
26879
- "control-flow",
26880
- parentBlock,
26881
- parentNode,
26882
- itemStart,
26883
- itemEnd,
26884
- body,
26885
- item,
26886
- forSlot.env
27330
+ block2.forSlot = forSlot;
27331
+ block2.key = key;
27332
+ block2.itemIndex = index;
27333
+ renderBlock(block2);
27334
+ hydration.node = getNextSibling(itemEnd);
27335
+ return block2;
27336
+ }
27337
+ hydration.discardItems(
27338
+ forSlot.end,
27339
+ __octaneDev ? forSlot.plainDeopt === true && isHostDescriptor(item) && !descNeedsBlocks(item) ? `<${item.type}>` : "another list item" : ""
27340
+ );
27341
+ return hydration.suspend(
27342
+ () => mountItem(
27343
+ parentBlock,
27344
+ parentNode,
27345
+ anchor,
27346
+ item,
27347
+ index,
27348
+ key,
27349
+ body,
27350
+ forSlot,
27351
+ singleRoot,
27352
+ ssrMarkerless
27353
+ )
26887
27354
  );
26888
- block2.forSlot = forSlot;
26889
- block2.key = key;
26890
- block2.itemIndex = index;
26891
- renderBlock(block2);
26892
- hydration.node = getNextSibling(itemEnd);
26893
- return block2;
26894
27355
  }
26895
27356
  if (singleRoot === true || singleRoot === 2 && isHostDescriptor(item) && !descNeedsBlocks(item)) {
26896
27357
  if (adoptNode !== null) {
@@ -26925,7 +27386,12 @@ function mountItem(parentBlock, parentNode, anchor, item, index, key, body, forS
26925
27386
  block2.forSlot = forSlot;
26926
27387
  block2.key = key;
26927
27388
  block2.itemIndex = index;
26928
- renderBlock(block2);
27389
+ try {
27390
+ renderBlock(block2);
27391
+ } catch (error) {
27392
+ discardThrownItem(block2, error, anchor);
27393
+ throw error;
27394
+ }
26929
27395
  const root = (STAGED_DOM?.view(anchor) ?? anchor).previousSibling;
26930
27396
  block2.startMarker = root;
26931
27397
  block2.endMarker = root;
@@ -26960,12 +27426,21 @@ function mountItem(parentBlock, parentNode, anchor, item, index, key, body, forS
26960
27426
  try {
26961
27427
  renderBlock(block);
26962
27428
  } catch (error) {
26963
- if (isSuspenseException(error)) retainDiscardedWarmMemos(block);
26964
- unmountBlock(block, !ROOT_RENDER_TRANSACTION?.retainedCreated?.has(block));
27429
+ discardThrownItem(block, error, null);
26965
27430
  throw error;
26966
27431
  }
26967
27432
  return block;
26968
27433
  }
27434
+ function discardThrownItem(block, error, selfMarkedAnchor) {
27435
+ const bag = block.slots[0];
27436
+ if (selfMarkedAnchor !== null && bag != null && bag.__kind === void 0) {
27437
+ const root = (STAGED_DOM?.view(selfMarkedAnchor) ?? selfMarkedAnchor).previousSibling;
27438
+ block.startMarker = root;
27439
+ block.endMarker = root;
27440
+ }
27441
+ if (isSuspenseException(error)) retainDiscardedWarmMemos(block);
27442
+ unmountBlock(block, !ROOT_RENDER_TRANSACTION?.retainedCreated?.has(block));
27443
+ }
26969
27444
  function moveBlockBefore(block, anchor) {
26970
27445
  const parent = domNode(block.startMarker).parentNode;
26971
27446
  const end = block.endMarker;
@@ -28183,9 +28658,7 @@ function hydrateRootWithOutputHandler(container, bodyOrElement, propsOrOptions,
28183
28658
  createdInRootRender(rootBlock);
28184
28659
  journalRootProperty(idState, "next", idState.next);
28185
28660
  idState.next = rootOptions?.identifierSeed ?? 0;
28186
- let firstNode = getFirstChild(container);
28187
- while (firstNode !== null && (firstNode.nodeType === 10 || isRendererHydrationStyle(firstNode)))
28188
- firstNode = getNextSibling(firstNode);
28661
+ const firstNode = skipFoldedHeadPrefix(container, getFirstChild(container));
28189
28662
  const hydration = new HydrationCapability(rootBlock, firstNode, seeds);
28190
28663
  if (bindingLeases?.length) {
28191
28664
  const attempted = rootBlock;
@@ -28334,7 +28807,15 @@ function createIndependentHydrateActivator(body) {
28334
28807
  tryBlock(scope, 0, scope.block.parentNode, content, null, null, scope.block.endMarker);
28335
28808
  };
28336
28809
  const adapter = (_props, scope) => {
28337
- componentSlotVoid(scope, 0, scope.block.parentNode, framed, void 0, scope.block.endMarker);
28810
+ componentSlotVoid(
28811
+ scope,
28812
+ 0,
28813
+ scope.block.parentNode,
28814
+ framed,
28815
+ void 0,
28816
+ void 0,
28817
+ scope.block.endMarker
28818
+ );
28338
28819
  };
28339
28820
  const root = hydrateRoot(element, adapter, captures, {
28340
28821
  identifierPrefix: manifest.boundaryId + "-",
@@ -28988,6 +29469,7 @@ function scriptResource(attrs) {
28988
29469
  textHole,
28989
29470
  textHoleUpdate,
28990
29471
  textSlot,
29472
+ textareaText,
28991
29473
  tryBlock,
28992
29474
  updateFreshClassAttr,
28993
29475
  updateFreshClassName,