octane 0.2.3 → 0.2.5

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 (41) hide show
  1. package/dist/cjs/constants.cjs +9 -0
  2. package/dist/cjs/css.cjs +9 -0
  3. package/dist/cjs/dom-tables.cjs +6 -1
  4. package/dist/cjs/error-codes.client.generated.cjs +2 -0
  5. package/dist/cjs/host-property-diagnostics.cjs +2 -0
  6. package/dist/cjs/index.cjs +2 -0
  7. package/dist/cjs/runtime.cjs +604 -78
  8. package/dist/cjs/runtime.server.cjs +280 -68
  9. package/dist/cjs/server/index.cjs +4 -0
  10. package/dist/cjs/version.cjs +1 -1
  11. package/dist/compiler/bundler.js +14 -1
  12. package/dist/compiler/compile.js +270 -528
  13. package/dist/compiler/hook-methods.js +164 -0
  14. package/dist/compiler/hydrate-boundaries.js +165 -15
  15. package/dist/compiler/parser-output.js +37 -0
  16. package/dist/compiler/parser.browser.js +145 -1
  17. package/dist/compiler/parser.node.js +28 -36
  18. package/dist/compiler/plain-hook-memo.js +37 -0
  19. package/dist/compiler/slot-hooks.js +129 -5
  20. package/dist/compiler/strong-mode.js +836 -3
  21. package/dist/compiler/style-scopes.js +1134 -0
  22. package/dist/compiler/volar.LICENSES.txt +1 -1
  23. package/dist/compiler/volar.js +5781 -3934
  24. package/dist/constants.d.ts +3 -0
  25. package/dist/constants.js +6 -0
  26. package/dist/css.d.ts +7 -0
  27. package/dist/css.js +8 -0
  28. package/dist/dom-tables.js +6 -1
  29. package/dist/error-codes.client.generated.d.ts +1 -0
  30. package/dist/error-codes.client.generated.js +2 -0
  31. package/dist/host-property-diagnostics.js +2 -0
  32. package/dist/index.d.ts +1 -1
  33. package/dist/index.js +2 -0
  34. package/dist/runtime.d.ts +35 -15
  35. package/dist/runtime.js +612 -79
  36. package/dist/runtime.server.d.ts +30 -1
  37. package/dist/runtime.server.js +287 -69
  38. package/dist/server/index.d.ts +1 -1
  39. package/dist/server/index.js +4 -0
  40. package/dist/version.js +1 -1
  41. package/package.json +5 -5
@@ -61,6 +61,7 @@ __export(runtime_exports, {
61
61
  beginNativeReadScope: () => beginNativeReadScope,
62
62
  beginNativeReadWitness: () => beginNativeReadWitness,
63
63
  bindRendererRegionOwner: () => bindRendererRegionOwner,
64
+ callWithReceiver: () => callWithReceiver,
64
65
  child: () => child,
65
66
  childSlot: () => childSlot,
66
67
  childTextHole: () => childTextHole,
@@ -130,6 +131,7 @@ __export(runtime_exports, {
130
131
  injectStyle: () => injectStyle,
131
132
  invokeManualHook: () => invokeManualHook,
132
133
  isChildrenBlock: () => isChildrenBlock,
134
+ isInActScope: () => isInActScope,
133
135
  isValidElement: () => isValidElement,
134
136
  keyedForBlock: () => keyedForBlock,
135
137
  lazy: () => lazy,
@@ -1423,6 +1425,8 @@ function journalRootRange(parent, before, after) {
1423
1425
  for (let node = before === null ? parent.firstChild : before.nextSibling; node !== null && node !== after; node = node.nextSibling)
1424
1426
  nodes.push(node);
1425
1427
  journalUndo(() => {
1428
+ if (before !== null && before.parentNode !== parent || after !== null && after.parentNode !== parent)
1429
+ return;
1426
1430
  let node = before !== null && before.parentNode === parent ? before.nextSibling : parent.firstChild;
1427
1431
  const anchor = after !== null && after.parentNode === parent ? after : null;
1428
1432
  const retained = new Set(nodes);
@@ -1724,12 +1728,17 @@ function journalDefaultValue(input) {
1724
1728
  journalAttr(input, "value");
1725
1729
  }
1726
1730
  }
1731
+ function radioCousins(input) {
1732
+ if (input.form !== null) return input.form.elements;
1733
+ const root = input.getRootNode();
1734
+ return root.nodeType === 9 ? root.getElementsByName(input.name) : root.querySelectorAll('input[type="radio"]');
1735
+ }
1727
1736
  function journalRadioCousins(input) {
1728
1737
  const name = input.name;
1729
- const group = input.form !== null ? input.form.elements : typeof document !== "undefined" ? document.getElementsByName(name) : [];
1738
+ const group = radioCousins(input);
1730
1739
  for (let i = 0; i < group.length; i++) {
1731
1740
  const other = group[i];
1732
- if (other === input || !other.checked || other.localName !== "input" || other.type !== "radio" || other.name !== name) {
1741
+ if (other === input || !other.checked || other.localName !== "input" || other.type !== "radio" || other.name !== name || other.form !== input.form) {
1733
1742
  continue;
1734
1743
  }
1735
1744
  TRANSITION_JOURNAL.push(JOURNAL_PROP, other, "checked", true);
@@ -1796,23 +1805,45 @@ function journalForSlot(state) {
1796
1805
  TRANSITION_JOURNAL_BAGS.delete(state);
1797
1806
  });
1798
1807
  }
1808
+ function journalForOwnedListClear(state) {
1809
+ const seen = TRANSITION_JOURNAL_BAGS;
1810
+ const oldItems = state.items;
1811
+ seen.set(state, TRANSITION_JOURNAL.length);
1812
+ const snapshot = {
1813
+ head: state.head,
1814
+ tail: state.tail,
1815
+ size: state.size,
1816
+ empty: state.emptyBlock,
1817
+ entries: oldItems
1818
+ };
1819
+ journalUndo(() => {
1820
+ restoreForSlot(state, snapshot, null);
1821
+ seen.delete(state);
1822
+ });
1823
+ state.items = /* @__PURE__ */ new Map();
1824
+ }
1799
1825
  function restoreForSlot(state, snapshot, chain) {
1800
- const kept = /* @__PURE__ */ new Set();
1801
- for (let i = 0; i < chain.length; i++) kept.add(chain[i][0]);
1826
+ const preservedMap = chain === null ? snapshot.entries : null;
1827
+ const kept = chain === null ? null : /* @__PURE__ */ new Set();
1828
+ if (chain !== null) for (let i = 0; i < chain.length; i++) kept.add(chain[i][0]);
1802
1829
  for (let b = state.head; b !== null; b = b.nextSibling) {
1803
- if (!kept.has(b)) unmountBlock(b, false);
1830
+ if (preservedMap !== null || !kept.has(b)) unmountBlock(b, false);
1804
1831
  }
1805
1832
  if (state.end.parentNode === null) return;
1806
1833
  state.head = snapshot.head;
1807
1834
  state.tail = snapshot.tail;
1808
1835
  state.size = snapshot.size;
1809
- state.items.clear();
1810
- for (let i = 0; i < snapshot.entries.length; i++) {
1811
- state.items.set(snapshot.entries[i][0], snapshot.entries[i][1]);
1812
- }
1813
- for (let i = 0; i < chain.length; i++) {
1814
- chain[i][0].nextSibling = chain[i][1];
1815
- chain[i][0].prevSibling = chain[i][2];
1836
+ if (preservedMap !== null) state.items = preservedMap;
1837
+ else {
1838
+ const originalChain = chain;
1839
+ state.items.clear();
1840
+ for (let i = 0; i < snapshot.entries.length; i++) {
1841
+ state.items.set(snapshot.entries[i][0], snapshot.entries[i][1]);
1842
+ }
1843
+ for (let i = 0; i < originalChain.length; i++) {
1844
+ originalChain[i][0].nextSibling = originalChain[i][1];
1845
+ originalChain[i][0].prevSibling = originalChain[i][2];
1846
+ }
1816
1847
  }
1817
1848
  const nodes = [];
1818
1849
  for (let b = state.head; b !== null; b = b.nextSibling) {
@@ -2273,6 +2304,12 @@ function reapplyFragmentBindings() {
2273
2304
  }
2274
2305
  let IS_OCTANE_ACT_ENVIRONMENT = false;
2275
2306
  let actScopeDepth = 0;
2307
+ let actCallbackDepth = 0;
2308
+ let asyncActCallbackDepth = 0;
2309
+ let actErrors = null;
2310
+ function isInActScope() {
2311
+ return actCallbackDepth !== 0 || asyncActCallbackDepth !== 0;
2312
+ }
2276
2313
  function setIsOctaneActEnvironment(value) {
2277
2314
  IS_OCTANE_ACT_ENVIRONMENT = value;
2278
2315
  }
@@ -2599,8 +2636,13 @@ function flush() {
2599
2636
  (0, import_devtools_hook.__devtoolsNotifyFlush)();
2600
2637
  return;
2601
2638
  }
2602
- if (VIEW_TRANSITION_DRIVER?.routeFlush() === true) return;
2603
- flushWork();
2639
+ try {
2640
+ if (VIEW_TRANSITION_DRIVER?.routeFlush() === true) return;
2641
+ flushWork();
2642
+ } catch (error) {
2643
+ if (actScopeDepth === 0) throw error;
2644
+ (actErrors ??= []).push(error);
2645
+ }
2604
2646
  }
2605
2647
  function activeElementForDocument(doc) {
2606
2648
  try {
@@ -2887,6 +2929,17 @@ function captureFocusedMovement(parent, snapshots) {
2887
2929
  }
2888
2930
  (renderingFocusMoves ??= []).push({ snapshot, ancestors });
2889
2931
  }
2932
+ function drainLayoutUpdates(pendingError) {
2933
+ for (let guard = 0; (QUEUE.length > 0 || ROOT_RENDER_TRANSACTIONS.length > 0) && guard < LAYOUT_CASCADE_LIMIT; guard++) {
2934
+ drainPassivesBeforeRender();
2935
+ const focused = QUEUE.length === 0 ? null : captureQueuedFocusSelection();
2936
+ const error = drainQueueWithFocus(focused);
2937
+ if (focused !== null) restoreQueuedFocusSelection(focused);
2938
+ if (error !== null && pendingError === null) pendingError = error;
2939
+ commitEffects();
2940
+ }
2941
+ return pendingError;
2942
+ }
2890
2943
  function flushWork() {
2891
2944
  inFlush = true;
2892
2945
  const clearRetainedTransitionUpdates = FLUSHED_TRANSITION_UPDATES.length > 0;
@@ -2895,9 +2948,11 @@ function flushWork() {
2895
2948
  try {
2896
2949
  if (QUEUE.length > 0) drainPassivesBeforeRender();
2897
2950
  const focused = QUEUE.length === 0 ? null : captureQueuedFocusSelection();
2898
- const pendingError = drainQueueWithFocus(focused);
2951
+ let pendingError = drainQueueWithFocus(focused);
2899
2952
  if (focused !== null) restoreQueuedFocusSelection(focused);
2900
2953
  commitEffects();
2954
+ if (QUEUE.length > 0 || ROOT_RENDER_TRANSACTIONS.length > 0)
2955
+ pendingError = drainLayoutUpdates(pendingError);
2901
2956
  if (pendingError !== null) throw pendingError.err;
2902
2957
  } finally {
2903
2958
  inFlush = false;
@@ -3122,24 +3177,7 @@ function flushSync(fn) {
3122
3177
  if (focused !== null) restoreQueuedFocusSelection(focused);
3123
3178
  commitEffects();
3124
3179
  if (QUEUE.length > 0 || ROOT_RENDER_TRANSACTIONS.length > 0) {
3125
- const seen = new Set(QUEUE);
3126
- let defer = false;
3127
- for (let guard = 0; (QUEUE.length > 0 || ROOT_RENDER_TRANSACTIONS.length > 0) && !defer && guard < LAYOUT_CASCADE_LIMIT; guard++) {
3128
- drainPassivesBeforeRender();
3129
- const focused2 = QUEUE.length === 0 ? null : captureQueuedFocusSelection();
3130
- const err = drainQueueWithFocus(focused2);
3131
- if (focused2 !== null) restoreQueuedFocusSelection(focused2);
3132
- if (err !== null && pendingError === null) pendingError = err;
3133
- commitEffects();
3134
- for (let i = 0; i < QUEUE.length; i++) {
3135
- const b = QUEUE[i];
3136
- if (seen.has(b)) {
3137
- defer = true;
3138
- break;
3139
- }
3140
- seen.add(b);
3141
- }
3142
- }
3180
+ pendingError = drainLayoutUpdates(pendingError);
3143
3181
  }
3144
3182
  } finally {
3145
3183
  inFlush = false;
@@ -3279,6 +3317,35 @@ function drainRefAttaches() {
3279
3317
  }
3280
3318
  }
3281
3319
  }
3320
+ let refStateUpdates = null;
3321
+ let collectingRefStateUpdates = false;
3322
+ function drainCommitRefs() {
3323
+ const previousUpdates = refStateUpdates;
3324
+ const previousCollecting = collectingRefStateUpdates;
3325
+ refStateUpdates = null;
3326
+ collectingRefStateUpdates = true;
3327
+ try {
3328
+ drainRefDetaches();
3329
+ drainRefAttaches();
3330
+ } finally {
3331
+ const updates = refStateUpdates;
3332
+ refStateUpdates = previousUpdates;
3333
+ collectingRefStateUpdates = previousCollecting;
3334
+ if (updates !== null) {
3335
+ REF_CALLBACK_DEPTH++;
3336
+ try {
3337
+ for (const [state, update] of updates) {
3338
+ if (update.block.disposed || Object.is(state.value, update.previous)) continue;
3339
+ if (typeof __OCTANE_PROFILE_ENABLED__ !== "undefined" && __OCTANE_PROFILE_ENABLED__)
3340
+ (0, import_profiling.__profileSchedule)(update.block, "state", update.profileSlot);
3341
+ scheduleRender(update.block);
3342
+ }
3343
+ } finally {
3344
+ REF_CALLBACK_DEPTH--;
3345
+ }
3346
+ }
3347
+ }
3348
+ }
3282
3349
  function blockSubtreeDisposed(block) {
3283
3350
  let b = block;
3284
3351
  while (b !== null) {
@@ -3325,8 +3392,7 @@ function commitEffects() {
3325
3392
  const caughtReports = drainEffectEventCommitActions();
3326
3393
  drainControlledSyncs();
3327
3394
  const mutationBatch = drainMutationEffects();
3328
- drainRefDetaches();
3329
- drainRefAttaches();
3395
+ drainCommitRefs();
3330
3396
  reapplyFragmentBindings();
3331
3397
  if (mutationBatch !== null) runLayoutEffects(mutationBatch);
3332
3398
  if (caughtReports !== null) publishInlineCaughtErrorReports(caughtReports);
@@ -3373,35 +3439,77 @@ function drainEffectEventUpdates() {
3373
3439
  entry.cell.impl = entry.nextImpl;
3374
3440
  }
3375
3441
  }
3442
+ function throwPendingActErrors() {
3443
+ const errors = actErrors;
3444
+ actErrors = null;
3445
+ if (errors !== null)
3446
+ throw errors.length === 1 ? errors[0] : new AggregateError(errors, (0, import_error_codes_client_generated.formatClientError)(64));
3447
+ }
3448
+ function mergePendingActErrors(error) {
3449
+ const errors = actErrors;
3450
+ actErrors = null;
3451
+ return errors === null ? error : new AggregateError([...errors, error], (0, import_error_codes_client_generated.formatClientError)(64));
3452
+ }
3453
+ function actCheckpoint() {
3454
+ return new Promise((resolve) => {
3455
+ const channel = new MessageChannel();
3456
+ channel.port1.onmessage = () => {
3457
+ channel.port1.close();
3458
+ channel.port2.close();
3459
+ resolve();
3460
+ };
3461
+ channel.port2.postMessage(null);
3462
+ });
3463
+ }
3376
3464
  function act(fn) {
3465
+ const nested = isInActScope();
3377
3466
  actScopeDepth++;
3467
+ actCallbackDepth++;
3378
3468
  let result;
3379
3469
  try {
3380
3470
  result = fn();
3381
3471
  } catch (err) {
3382
3472
  actScopeDepth--;
3383
- return Promise.reject(err);
3473
+ return Promise.reject(mergePendingActErrors(err));
3474
+ } finally {
3475
+ actCallbackDepth--;
3384
3476
  }
3385
3477
  if (result !== null && typeof result === "object" && typeof result.then === "function") {
3478
+ asyncActCallbackDepth++;
3386
3479
  return (async () => {
3387
3480
  try {
3388
- const value = await result;
3481
+ let value;
3482
+ try {
3483
+ value = await result;
3484
+ } finally {
3485
+ asyncActCallbackDepth--;
3486
+ }
3487
+ if (nested) return value;
3389
3488
  for (let i = 0; i < ACT_DRAIN_LIMIT; i++) {
3390
- for (let j = 0; j < 5; j++) await Promise.resolve();
3489
+ await actCheckpoint();
3490
+ throwPendingActErrors();
3491
+ const hadWork = hasPendingWork();
3391
3492
  drainPassiveEffects();
3392
- if (!hasPendingWork()) return value;
3493
+ if (!hadWork && !hasPendingWork()) return value;
3393
3494
  }
3394
3495
  throw new Error((0, import_error_codes_client_generated.formatClientError)(14, ACT_DRAIN_LIMIT));
3496
+ } catch (error) {
3497
+ throw mergePendingActErrors(error);
3395
3498
  } finally {
3396
3499
  actScopeDepth--;
3397
3500
  }
3398
3501
  })();
3399
3502
  }
3503
+ if (nested) {
3504
+ actScopeDepth--;
3505
+ return Promise.resolve(result);
3506
+ }
3400
3507
  try {
3401
3508
  for (let i = 0; i < ACT_DRAIN_LIMIT; i++) {
3402
3509
  if (VIEW_TRANSITION_DRIVER?.wouldWrap() === true) flush();
3403
3510
  else flushSync(() => {
3404
3511
  });
3512
+ throwPendingActErrors();
3405
3513
  drainPassiveEffects();
3406
3514
  if (!hasPendingWork()) break;
3407
3515
  if (i === ACT_DRAIN_LIMIT - 1) {
@@ -3410,16 +3518,20 @@ function act(fn) {
3410
3518
  }
3411
3519
  } catch (err) {
3412
3520
  actScopeDepth--;
3413
- return Promise.reject(err);
3521
+ return Promise.reject(mergePendingActErrors(err));
3414
3522
  }
3415
3523
  return (async () => {
3416
3524
  try {
3417
3525
  for (let i = 0; i < ACT_DRAIN_LIMIT; i++) {
3418
- for (let j = 0; j < 5; j++) await Promise.resolve();
3526
+ await actCheckpoint();
3527
+ throwPendingActErrors();
3528
+ const hadWork = hasPendingWork();
3419
3529
  drainPassiveEffects();
3420
- if (!hasPendingWork()) return result;
3530
+ if (!hadWork && !hasPendingWork()) return result;
3421
3531
  }
3422
3532
  throw new Error((0, import_error_codes_client_generated.formatClientError)(14, ACT_DRAIN_LIMIT));
3533
+ } catch (error) {
3534
+ throw mergePendingActErrors(error);
3423
3535
  } finally {
3424
3536
  actScopeDepth--;
3425
3537
  }
@@ -3874,19 +3986,51 @@ function createBlock(kind, parentBlock, parentNode, startMarker, endMarker, body
3874
3986
  }
3875
3987
  return block;
3876
3988
  }
3989
+ let renderPhaseOwner = null;
3990
+ let renderPhaseUpdates = null;
3991
+ function captureRenderPhaseUpdate(cell, key) {
3992
+ const updates = renderPhaseUpdates ??= /* @__PURE__ */ new Map();
3993
+ if (!updates.has(cell)) updates.set(cell, { value: cell.value, queue: cell[key]?.slice(), key });
3994
+ }
3877
3995
  function renderBlock(block) {
3878
3996
  const hydration = activeHydration();
3879
3997
  if (hydration !== null && !hydration.owns(block)) {
3880
3998
  hydration.suspend(() => renderBlock(block));
3881
3999
  return;
3882
4000
  }
3883
- let retries = 0;
3884
- while (renderBlockInner(block)) {
3885
- if (block.nestedUpdateError) {
3886
- block.nestedUpdateError = false;
3887
- throw maximumUpdateDepthError();
4001
+ const previousOwner = renderPhaseOwner;
4002
+ let previousUpdates = renderPhaseUpdates;
4003
+ renderPhaseOwner = block;
4004
+ renderPhaseUpdates = null;
4005
+ try {
4006
+ let retries = 0;
4007
+ while (renderBlockInner(block)) {
4008
+ if (block.nestedUpdateError) {
4009
+ block.nestedUpdateError = false;
4010
+ throw maximumUpdateDepthError();
4011
+ }
4012
+ if (++retries > RENDER_PHASE_UPDATE_LIMIT) throw new Error((0, import_error_codes_client_generated.formatClientError)(9));
4013
+ }
4014
+ const updates = renderPhaseUpdates;
4015
+ if (updates !== null && previousOwner !== null && blockIsAncestorOf(previousOwner, block)) {
4016
+ previousUpdates ??= /* @__PURE__ */ new Map();
4017
+ for (const [cell, snapshot] of updates) {
4018
+ if (!previousUpdates.has(cell)) previousUpdates.set(cell, snapshot);
4019
+ }
4020
+ }
4021
+ } catch (error) {
4022
+ const updates = renderPhaseUpdates;
4023
+ if (updates !== null) {
4024
+ for (const [cell, snapshot] of updates) {
4025
+ cell.value = snapshot.value;
4026
+ cell[snapshot.key] = snapshot.queue;
4027
+ }
4028
+ if (!block.crossRenderUpdate) block.pending = false;
3888
4029
  }
3889
- if (++retries > RENDER_PHASE_UPDATE_LIMIT) throw new Error((0, import_error_codes_client_generated.formatClientError)(9));
4030
+ throw error;
4031
+ } finally {
4032
+ renderPhaseOwner = previousOwner;
4033
+ renderPhaseUpdates = previousUpdates;
3890
4034
  }
3891
4035
  }
3892
4036
  function enqueueEffectEventUpdate(entry) {
@@ -4566,6 +4710,9 @@ function manualHook(fn, name) {
4566
4710
  Object.defineProperty(provider, "length", { value: fn.length, configurable: true });
4567
4711
  return provider;
4568
4712
  }
4713
+ function callWithReceiver(fn, receiver, ...args) {
4714
+ return NATIVE_REFLECT_APPLY(fn, receiver, args);
4715
+ }
4569
4716
  function withSlot(sym, fn, ...args) {
4570
4717
  const driver = MANUAL_HOOK_DRIVER;
4571
4718
  const pending = driver?.pending;
@@ -4631,6 +4778,7 @@ function useState(initial, slot) {
4631
4778
  if (s.pendingActionBatch !== void 0 && transitionActionBatchForUpdate() === null)
4632
4779
  recordUrgentActionUpdate(s, next);
4633
4780
  if ((s.updates !== void 0 || s.renderTransition !== void 0 || typeof next === "function" && TRANSITION_PENDING_COUNT > 0 && TRANSITION_SWAP_DRIVER?.hasHeld(s, block) || block.pending && typeof next === "function") && transitionActionBatchForUpdate() === null) {
4781
+ if (CURRENT_BLOCK === block) captureRenderPhaseUpdate(s, "updates");
4634
4782
  (s.updates ??= []).push(next);
4635
4783
  scheduleRender(block);
4636
4784
  return;
@@ -4642,6 +4790,7 @@ function useState(initial, slot) {
4642
4790
  computed = typeof next === "function" ? next(previous) : next;
4643
4791
  } catch {
4644
4792
  if (transitionActionBatchForUpdate() === null) {
4793
+ if (CURRENT_BLOCK === block) captureRenderPhaseUpdate(s, "updates");
4645
4794
  (s.updates ??= []).push(next);
4646
4795
  scheduleRender(block);
4647
4796
  return;
@@ -4668,6 +4817,19 @@ function useState(initial, slot) {
4668
4817
  }
4669
4818
  return;
4670
4819
  }
4820
+ if (collectingRefStateUpdates && REF_CALLBACK_DEPTH > 0 && !forceRender) {
4821
+ const updates = refStateUpdates ??= /* @__PURE__ */ new Map();
4822
+ const state = s;
4823
+ if (!updates.has(state)) {
4824
+ const update2 = { block, previous: s.value };
4825
+ if (typeof __OCTANE_PROFILE_ENABLED__ !== "undefined" && __OCTANE_PROFILE_ENABLED__)
4826
+ update2.profileSlot = slot;
4827
+ updates.set(state, update2);
4828
+ }
4829
+ s.value = computed;
4830
+ return;
4831
+ }
4832
+ if (CURRENT_BLOCK === block) captureRenderPhaseUpdate(s, "updates");
4671
4833
  s.value = computed;
4672
4834
  if (!block.disposed && typeof __OCTANE_PROFILE_ENABLED__ !== "undefined" && __OCTANE_PROFILE_ENABLED__)
4673
4835
  (0, import_profiling.__profileSchedule)(block, "state", slot);
@@ -5000,6 +5162,7 @@ function useReducer(reducer, initialArg, initOrSlot, slot) {
5000
5162
  dispatch: (action) => {
5001
5163
  if (block.disposed) return;
5002
5164
  if (CURRENT_BLOCK === block || transitionActionBatchForUpdate() === null) {
5165
+ if (CURRENT_BLOCK === block) captureRenderPhaseUpdate(s, "renderPhaseActions");
5003
5166
  if (s.pendingActionBatch !== void 0 && transitionActionBatchForUpdate() === null)
5004
5167
  recordUrgentActionUpdate(s, (value) => s.reducer(value, action));
5005
5168
  const actions = s.renderPhaseActions ??= [];
@@ -7975,6 +8138,7 @@ class HydrationCapability {
7975
8138
  this.rootBlock = rootBlock;
7976
8139
  this.node = node;
7977
8140
  this.seeds = seeds;
8141
+ initialSuspenseHydrationRenderer = renderInitialSuspenseHydration;
7978
8142
  }
7979
8143
  rootBlock;
7980
8144
  node;
@@ -10053,8 +10217,9 @@ function normalizedHostProp(el, rawName) {
10053
10217
  }
10054
10218
  function setHostPropSources(el, sources, prev, scope, hasNestedChildren = false) {
10055
10219
  const props = /* @__PURE__ */ new Map();
10220
+ let classMerges = null;
10056
10221
  let sourceOrder = 0;
10057
- const record = (rawName, value) => {
10222
+ function record(rawName, value) {
10058
10223
  if (typeof rawName !== "string") return;
10059
10224
  const order = sourceOrder++;
10060
10225
  const previous = props.get(rawName);
@@ -10064,10 +10229,15 @@ function setHostPropSources(el, sources, prev, scope, hasNestedChildren = false)
10064
10229
  firstOrder: previous?.firstOrder ?? order,
10065
10230
  lastOrder: order
10066
10231
  });
10067
- };
10232
+ }
10068
10233
  for (const source of sources) {
10069
10234
  if (!source[0]) {
10070
- record(source[1], source[2]);
10235
+ const rawName = source[1];
10236
+ if (source[3] === true && typeof rawName === "string" && (rawName === "class" || rawName === "className")) {
10237
+ (classMerges ??= []).push({ rawName, value: source[2], order: sourceOrder++ });
10238
+ continue;
10239
+ }
10240
+ record(rawName, source[2]);
10071
10241
  continue;
10072
10242
  }
10073
10243
  const spread = source[1];
@@ -10093,6 +10263,22 @@ function setHostPropSources(el, sources, prev, scope, hasNestedChildren = false)
10093
10263
  writer.lastOrder
10094
10264
  ]);
10095
10265
  }
10266
+ if (classMerges !== null) {
10267
+ for (const extra of classMerges) {
10268
+ const [identity, name] = normalizedHostProp(el, extra.rawName);
10269
+ const previous = values.get(identity);
10270
+ if (previous !== void 0) {
10271
+ values.set(identity, [
10272
+ previous[0],
10273
+ (0, import_css.mergeClass)(previous[1], extra.value),
10274
+ previous[2],
10275
+ extra.order
10276
+ ]);
10277
+ continue;
10278
+ }
10279
+ values.set(identity, [name, extra.value, extra.order, extra.order]);
10280
+ }
10281
+ }
10096
10282
  const resolved = /* @__PURE__ */ Object.create(null);
10097
10283
  const ordered = [...values.values()];
10098
10284
  if (needsWinningOrderSort) ordered.sort((a, b) => a[2] - b[2]);
@@ -10268,11 +10454,12 @@ function headBlock(scope, slot, key, tag, attrs, text) {
10268
10454
  const ownerDocument = parent.nodeType === 9 ? parent : parent.ownerDocument;
10269
10455
  const head = ownerDocument.head;
10270
10456
  let el2 = adoptServerHeadEl(head, (0, import_head_ownership.headOwnershipKey)(key, rootIdentifierPrefix(scope.block)), tag);
10457
+ const adopted = el2 !== null;
10271
10458
  if (el2 === null) {
10272
10459
  el2 = ownerDocument.createElement(tag);
10273
10460
  head.appendChild(el2);
10274
10461
  }
10275
- state = { el: el2 };
10462
+ state = { el: el2, attrNames: adopted ? el2.getAttributeNames() : void 0 };
10276
10463
  scope.slots[slot] = state;
10277
10464
  (scope.cleanups ??= []).push(() => {
10278
10465
  removeHeadEventListeners(state, null);
@@ -10281,8 +10468,20 @@ function headBlock(scope, slot, key, tag, attrs, text) {
10281
10468
  });
10282
10469
  }
10283
10470
  const el = state.el;
10471
+ if (TRANSITION_JOURNAL !== null) {
10472
+ journalObjectOnce(state);
10473
+ journalBag();
10474
+ }
10284
10475
  if (state.handlers !== void 0) removeHeadEventListeners(state, attrs);
10476
+ const previousNames = state.attrNames;
10477
+ if (previousNames !== void 0) {
10478
+ for (let i = 0; i < previousNames.length; i++) {
10479
+ const name = previousNames[i];
10480
+ if (attrs === null || !(name in attrs)) setAttribute(el, name, null);
10481
+ }
10482
+ }
10285
10483
  if (attrs !== null) {
10484
+ const names = [];
10286
10485
  for (const k in attrs) {
10287
10486
  const ev = k.length > 2 && k[0] === "o" && k[1] === "n" ? eventSlot(k) : null;
10288
10487
  if (ev !== null) {
@@ -10303,12 +10502,19 @@ function headBlock(scope, slot, key, tag, attrs, text) {
10303
10502
  }
10304
10503
  continue;
10305
10504
  }
10505
+ names.push(k);
10306
10506
  setAttribute(el, k, attrs[k]);
10307
10507
  }
10508
+ state.attrNames = names;
10509
+ } else {
10510
+ state.attrNames = void 0;
10308
10511
  }
10309
- if (text != null) {
10310
- const t = String(text);
10311
- if (el.textContent !== t) el.textContent = t;
10512
+ if (text != null || tag === "title") {
10513
+ const t = text == null ? "" : String(text);
10514
+ if (el.textContent !== t) {
10515
+ if (TRANSITION_JOURNAL !== null) journalRootRange(el, null, null);
10516
+ el.textContent = t;
10517
+ }
10312
10518
  }
10313
10519
  }
10314
10520
  function namespaceHead(props, scope) {
@@ -10341,8 +10547,21 @@ function namespaceHeadElement(headKey, tag, attrs, text, authoredKey) {
10341
10547
  return createElement(namespaceHead, config);
10342
10548
  }
10343
10549
  function injectStyle(id, css, nonce) {
10550
+ if (typeof document === "undefined") {
10551
+ _injectedStyles.add(id);
10552
+ return;
10553
+ }
10554
+ const existing = document.querySelector(`style[data-octane="${id}"]`);
10555
+ if (existing !== null) {
10556
+ if (_injectedStyles.has(id)) {
10557
+ if (existing.textContent !== css) existing.textContent = css;
10558
+ } else {
10559
+ _injectedStyles.add(id);
10560
+ }
10561
+ return;
10562
+ }
10344
10563
  if (_injectedStyles.has(id)) return;
10345
- if (typeof document !== "undefined" && document.querySelector(`style[data-octane="${id}"], style[data-href="octane-${id}"]`)) {
10564
+ if (document.querySelector(`style[data-href~="octane-${id}"]`)) {
10346
10565
  _injectedStyles.add(id);
10347
10566
  return;
10348
10567
  }
@@ -10922,6 +11141,10 @@ function buildDelegatedPath(event, listener, path = event.composedPath()) {
10922
11141
  }
10923
11142
  }
10924
11143
  function fireEventSlot(slot, event) {
11144
+ const previousScope = CURRENT_SCOPE;
11145
+ const previousBlock = CURRENT_BLOCK;
11146
+ CURRENT_SCOPE = null;
11147
+ CURRENT_BLOCK = null;
10925
11148
  try {
10926
11149
  if (typeof slot === "function") {
10927
11150
  slot(event);
@@ -10952,6 +11175,9 @@ function fireEventSlot(slot, event) {
10952
11175
  invokeInvalidEventListener(`${event.type} event`, slot, event);
10953
11176
  } catch (err) {
10954
11177
  reportListenerError(err);
11178
+ } finally {
11179
+ CURRENT_SCOPE = previousScope;
11180
+ CURRENT_BLOCK = previousBlock;
10955
11181
  }
10956
11182
  }
10957
11183
  function invokeInvalidEventListener(label, listener, event) {
@@ -10980,7 +11206,7 @@ function reportListenerError(err) {
10980
11206
  }
10981
11207
  function maybeFlushDiscrete(type) {
10982
11208
  if (_dispatchDepth === 0 && DISCRETE_EVENTS.has(type) && pendingRestores.length > 0) {
10983
- if (hasPendingWork()) {
11209
+ if (!inFlush && hasPendingWork()) {
10984
11210
  if (VIEW_TRANSITION_DRIVER?.queueAllTransition() === true) flush();
10985
11211
  else flushSync(noop);
10986
11212
  }
@@ -11370,13 +11596,12 @@ function armControlledBase(el) {
11370
11596
  sv: null,
11371
11597
  sawV: false,
11372
11598
  sawC: false,
11599
+ sawDC: false,
11373
11600
  dvv: UNCONTROLLED,
11374
11601
  composing: false,
11375
11602
  compositionEndTask: void 0,
11376
11603
  queued: false,
11377
11604
  formSeen: false,
11378
- formDefaultValue: UNCONTROLLED,
11379
- formDefaultChecked: UNCONTROLLED,
11380
11605
  formMultiple: false
11381
11606
  };
11382
11607
  el.$$ctrl = ctrl;
@@ -11551,9 +11776,14 @@ function setCheckedState(input, value, ctrl) {
11551
11776
  if (process.env.NODE_ENV !== "production")
11552
11777
  queueDevFormDiagnostic(input, CURRENT_SCOPE ?? void 0);
11553
11778
  const hydration = activeHydration();
11554
- if (hydration !== null && !hydration.isFresh(input)) return;
11555
- if (input.checked !== b) input.checked = b;
11779
+ if (hydration !== null && !hydration.isFresh(input)) {
11780
+ input.checked = input.checked;
11781
+ ctrl.sawDC = true;
11782
+ return;
11783
+ }
11784
+ input.checked = b;
11556
11785
  input.defaultChecked = b;
11786
+ ctrl.sawDC = true;
11557
11787
  return;
11558
11788
  }
11559
11789
  if (process.env.NODE_ENV !== "production" && ctrl.c === -1) devWarnControlledFlip(input, true);
@@ -11567,7 +11797,7 @@ function inActivationWindow(input) {
11567
11797
  const target = activationCheckable;
11568
11798
  if (target === null) return false;
11569
11799
  if (input === target) return true;
11570
- return input.type === "radio" && target.type === "radio" && input.name !== "" && input.name === target.name && input.form === target.form;
11800
+ return input.type === "radio" && target.type === "radio" && input.name !== "" && input.name === target.name && input.form === target.form && (input.form !== null || input.getRootNode() === target.getRootNode());
11571
11801
  }
11572
11802
  function setChecked(el, value) {
11573
11803
  const ctrl = armControlled(el);
@@ -11705,6 +11935,7 @@ function setDefaultValue(el, value, initial) {
11705
11935
  }
11706
11936
  }
11707
11937
  const DEFAULT_VALUE_BASELINE = /* @__PURE__ */ Symbol("octane.defaultValue");
11938
+ const DEFAULT_CHECKED_INITIALIZED = /* @__PURE__ */ Symbol("octane.defaultCheckedInitialized");
11708
11939
  function setDefaultValueUncontrolled(el, value) {
11709
11940
  const hydration = activeHydration();
11710
11941
  const input = el;
@@ -11733,10 +11964,30 @@ function setDefaultValueUncontrolled(el, value) {
11733
11964
  }
11734
11965
  function setDefaultChecked(el, value) {
11735
11966
  const ctrl = armControlled(el);
11967
+ const input = el;
11736
11968
  const hydration = activeHydration();
11737
- if (hydration !== null && !hydration.isFresh(el) || value == null) return;
11969
+ const hydrating = hydration !== null && !hydration.isFresh(el);
11970
+ const first = !ctrl.sawDC;
11971
+ if (first) {
11972
+ if (TRANSITION_JOURNAL !== null) {
11973
+ journalObjectOnce(ctrl);
11974
+ journalBag();
11975
+ }
11976
+ ctrl.sawDC = true;
11977
+ }
11978
+ if (hydrating) {
11979
+ if (first) input.checked = input.checked;
11980
+ return;
11981
+ }
11738
11982
  if (ctrl.c !== -1) return;
11739
- const input = el;
11983
+ if (first && !(DEFAULT_CHECKED_INITIALIZED in input)) {
11984
+ if (TRANSITION_JOURNAL !== null) {
11985
+ TRANSITION_JOURNAL.push(JOURNAL_PROP, input, "checked", input.checked);
11986
+ if (input.type === "radio" && input.name !== "" && !!value) journalRadioCousins(input);
11987
+ }
11988
+ input.checked = value == null ? input.checked : !!value;
11989
+ }
11990
+ if (value == null) return;
11740
11991
  const b = !!value;
11741
11992
  if (input.defaultChecked !== b) {
11742
11993
  if (TRANSITION_JOURNAL !== null) {
@@ -11795,15 +12046,12 @@ function setFormControlSources(el, sources) {
11795
12046
  }
11796
12047
  const ctrl = armControlled(el);
11797
12048
  const first = !ctrl.formSeen;
11798
- const previousDefaultChecked = ctrl.formDefaultChecked;
11799
12049
  const previousMultiple = ctrl.formMultiple;
11800
12050
  if (TRANSITION_JOURNAL !== null) {
11801
12051
  journalObjectOnce(ctrl);
11802
12052
  journalBag();
11803
12053
  }
11804
12054
  ctrl.formSeen = true;
11805
- ctrl.formDefaultValue = defaultValue;
11806
- ctrl.formDefaultChecked = defaultChecked;
11807
12055
  if (process.env.NODE_ENV !== "production" && hasDevFormDiagnosticContext(el, CURRENT_SCOPE ?? void 0)) {
11808
12056
  const diagnostic = ensureDevFormDiagnosticState(el);
11809
12057
  diagnostic.authoringProps = { value, defaultValue, checked, defaultChecked, multiple };
@@ -11819,10 +12067,8 @@ function setFormControlSources(el, sources) {
11819
12067
  setDefaultValue(input, defaultString, first);
11820
12068
  }
11821
12069
  setChecked(input, checked);
11822
- if (checked == null && defaultChecked != null) setDefaultChecked(input, defaultChecked);
11823
- if (!first && defaultChecked == null && previousDefaultChecked !== UNCONTROLLED && previousDefaultChecked != null) {
11824
- input.defaultChecked = false;
11825
- }
12070
+ if (checked == null && (defaultChecked != null || first))
12071
+ setDefaultChecked(input, defaultChecked);
11826
12072
  return;
11827
12073
  }
11828
12074
  if (tag === "textarea") {
@@ -12015,10 +12261,10 @@ function restoreCheckedState(input, ctrl) {
12015
12261
  }
12016
12262
  function restoreRadioCousins(input) {
12017
12263
  const name = input.name;
12018
- const group = input.form !== null ? input.form.elements : typeof document !== "undefined" ? document.getElementsByName(name) : [];
12264
+ const group = radioCousins(input);
12019
12265
  for (let i = 0; i < group.length; i++) {
12020
12266
  const other = group[i];
12021
- if (other === input || other.localName !== "input" || other.type !== "radio" || other.name !== name) {
12267
+ if (other === input || other.localName !== "input" || other.type !== "radio" || other.name !== name || other.form !== input.form) {
12022
12268
  continue;
12023
12269
  }
12024
12270
  const octrl = other.$$ctrl;
@@ -13494,19 +13740,29 @@ function hasDangerHTML(props) {
13494
13740
  function hasHostPropContent(descriptor) {
13495
13741
  return hasDangerHTML(descriptor.props) || descriptor.type === "textarea" && (descriptor.props?.value != null || descriptor.props?.defaultValue != null);
13496
13742
  }
13743
+ function markInputCheckedness(input) {
13744
+ input.checked = input.checked;
13745
+ input[DEFAULT_CHECKED_INITIALIZED] = true;
13746
+ }
13497
13747
  function applyDeoptProps(el, props, ownerBlock) {
13498
13748
  if (props == null) {
13749
+ if (el.localName === "input") markInputCheckedness(el);
13499
13750
  if (process.env.NODE_ENV !== "production") queueDevFormDiagnostic(el, ownerBlock);
13500
13751
  return;
13501
13752
  }
13753
+ let needsCheckedInitialization = el.localName === "input";
13502
13754
  for (const name in props) {
13503
13755
  if (name === "key" || name === "children") continue;
13504
13756
  if (name === "suppressHydrationWarning") {
13505
13757
  el.__oct_suppress = props[name] === true;
13506
13758
  continue;
13507
13759
  }
13508
- applyDeoptProp(el, name, props[name], ownerBlock);
13760
+ const value = props[name];
13761
+ if (needsCheckedInitialization && (name === "defaultChecked" || name === "checked" && value != null))
13762
+ needsCheckedInitialization = false;
13763
+ applyDeoptProp(el, name, value, ownerBlock);
13509
13764
  }
13765
+ if (needsCheckedInitialization) markInputCheckedness(el);
13510
13766
  if (process.env.NODE_ENV !== "production") queueDevFormDiagnostic(el, ownerBlock);
13511
13767
  }
13512
13768
  function patchDeoptProps(el, prevProps, nextProps, ownerBlock) {
@@ -13567,6 +13823,7 @@ function hostComponent(scope, slot, tag, props, childrenBody, anchor) {
13567
13823
  }
13568
13824
  function applyHostProps(el, props, scope, state) {
13569
13825
  const prev = state.props;
13826
+ let needsCheckedInitialization = prev === void 0 && el.localName === "input";
13570
13827
  if (ROOT_RENDER_TRANSACTION !== null && prev !== props) journalObjectOnce(state);
13571
13828
  if (prev != null) {
13572
13829
  for (const k in prev) {
@@ -13584,12 +13841,15 @@ function applyHostProps(el, props, scope, state) {
13584
13841
  }
13585
13842
  state.props = props;
13586
13843
  if (props == null) {
13844
+ if (needsCheckedInitialization) markInputCheckedness(el);
13587
13845
  if (process.env.NODE_ENV !== "production") queueDevFormDiagnostic(el, scope);
13588
13846
  return;
13589
13847
  }
13590
13848
  for (const name in props) {
13591
13849
  if (name === "key" || name === "children") continue;
13592
13850
  const v = props[name];
13851
+ if (needsCheckedInitialization && (name === "defaultChecked" || name === "checked" && v != null))
13852
+ needsCheckedInitialization = false;
13593
13853
  const actionName = formActionAttributeName(el, name);
13594
13854
  if (actionName !== null) {
13595
13855
  setFormAction(el, actionName, v, prev?.[name]);
@@ -13627,6 +13887,7 @@ function applyHostProps(el, props, scope, state) {
13627
13887
  }
13628
13888
  }
13629
13889
  }
13890
+ if (needsCheckedInitialization) markInputCheckedness(el);
13630
13891
  if (process.env.NODE_ENV !== "production") queueDevFormDiagnostic(el, scope);
13631
13892
  }
13632
13893
  const DEOPT_DESC = /* @__PURE__ */ Symbol("octane.deoptDesc");
@@ -15952,6 +16213,7 @@ function releaseHiddenText(text, restore = true) {
15952
16213
  }
15953
16214
  }
15954
16215
  function teardownTrySlot(state, detachDom) {
16216
+ initialSuspenseHydrations?.delete(state);
15955
16217
  cancelSuspenseRetry(state);
15956
16218
  HIDDEN_REVEAL_ACTIONS?.delete(state);
15957
16219
  if (state.block !== null) unmountBlock(state.block, detachDom);
@@ -16423,6 +16685,15 @@ function tryBlock(parentScope, slotKey, domParent, tryBody, catchBody, pendingBo
16423
16685
  state.env = env;
16424
16686
  }
16425
16687
  const s = state;
16688
+ let initial = initialSuspenseHydrations?.get(s);
16689
+ if (initial === void 0 && hydration !== null && s.branch === -1 && !s.propagateSuspense) {
16690
+ initial = takeInitialSuspenseHydration(s, hydration) ?? void 0;
16691
+ if (initial !== void 0) (initialSuspenseHydrations ??= /* @__PURE__ */ new WeakMap()).set(s, initial);
16692
+ }
16693
+ if (initial !== void 0) {
16694
+ initialSuspenseHydrationRenderer(s, initial);
16695
+ return s.reset;
16696
+ }
16426
16697
  if (s.passthrough) {
16427
16698
  renderPassthroughTry(s);
16428
16699
  return s.reset;
@@ -16540,6 +16811,184 @@ function mountHiddenTryBody(state) {
16540
16811
  hideTryBlock(state);
16541
16812
  return block;
16542
16813
  }
16814
+ let initialSuspenseHydrations = null;
16815
+ let initialStreamedPayloads = null;
16816
+ let initialSuspenseHydrationRenderer = null;
16817
+ function takeInitialSuspenseHydration(state, hydration) {
16818
+ const marker = state.start.nextSibling;
16819
+ if (marker?.nodeType !== 8) return null;
16820
+ const text = marker.data;
16821
+ if (text.startsWith(import_constants.STREAM_SEED_COMMENT)) {
16822
+ const boundaryId = text.slice(import_constants.STREAM_SEED_COMMENT.length);
16823
+ const start = marker.nextSibling;
16824
+ if (!hydration.isOpen(start)) return null;
16825
+ const end2 = hydration.close(start);
16826
+ const stash = typeof window !== "undefined" ? window.$OCTS : void 0;
16827
+ const owner = marker;
16828
+ let payload = initialStreamedPayloads?.get(owner);
16829
+ if (payload === void 0) {
16830
+ payload = {
16831
+ seedRaw: typeof stash?.[boundaryId] === "string" ? stash[boundaryId] : null,
16832
+ nativeRaw: typeof stash?.[boundaryId + "$signals"] === "string" ? stash[boundaryId + "$signals"] : null
16833
+ };
16834
+ (initialStreamedPayloads ??= /* @__PURE__ */ new WeakMap()).set(owner, payload);
16835
+ if (stash !== void 0) {
16836
+ delete stash[boundaryId];
16837
+ delete stash[boundaryId + "$signals"];
16838
+ }
16839
+ }
16840
+ state.idState = {
16841
+ prefix: state.parentBlock.idState.prefix + "b" + boundaryId + "-",
16842
+ next: 0,
16843
+ renderOwner: state.parentBlock.idState.renderOwner
16844
+ };
16845
+ return {
16846
+ metadata: [marker],
16847
+ start,
16848
+ end: end2,
16849
+ idStart: 0,
16850
+ ...payload,
16851
+ consume: () => {
16852
+ initialStreamedPayloads?.delete(owner);
16853
+ }
16854
+ };
16855
+ }
16856
+ if (!text.startsWith(import_constants.SUSPENSE_RESOLVED_COMMENT)) return null;
16857
+ const rawCount = text.slice(import_constants.SUSPENSE_RESOLVED_COMMENT.length);
16858
+ if (!/^(?:0|[1-9]\d*)$/.test(rawCount)) return null;
16859
+ const count = Number(rawCount);
16860
+ if (!Number.isSafeInteger(count)) return null;
16861
+ let cursor = marker.nextSibling;
16862
+ let seedRaw = null;
16863
+ let nativeRaw = null;
16864
+ const sidecars = [];
16865
+ for (const attr of [import_constants.SUSPENSE_RESOLVED_SEED_ATTR, import_constants.SUSPENSE_RESOLVED_NATIVE_ATTR]) {
16866
+ if (cursor?.nodeType !== 1) continue;
16867
+ const script = cursor;
16868
+ if (script.localName !== "script" || script.getAttribute("type") !== "application/json" || !script.hasAttribute(attr))
16869
+ continue;
16870
+ if (attr === import_constants.SUSPENSE_RESOLVED_SEED_ATTR) seedRaw = script.textContent;
16871
+ else nativeRaw = script.textContent;
16872
+ sidecars.push(script);
16873
+ cursor = script.nextSibling;
16874
+ }
16875
+ if (!hydration.isOpen(cursor)) return null;
16876
+ const end = hydration.close(cursor);
16877
+ const rootIds = state.idState;
16878
+ const idStart = rootIds.next;
16879
+ reserveHydrationIds(rootIds, count);
16880
+ state.idState = {
16881
+ prefix: rootIds.prefix,
16882
+ next: idStart,
16883
+ limit: idStart + count,
16884
+ overflow: rootIds,
16885
+ renderOwner: rootIds.renderOwner
16886
+ };
16887
+ return {
16888
+ metadata: [marker, ...sidecars],
16889
+ start: cursor,
16890
+ end,
16891
+ idStart,
16892
+ seedRaw,
16893
+ nativeRaw
16894
+ };
16895
+ }
16896
+ function finishInitialSuspenseHydration(initial, hydration) {
16897
+ for (const node of initial.metadata) node.remove();
16898
+ initial.consume?.();
16899
+ if (hydration.hasAdjacentRangePair) hydration.coalesce();
16900
+ }
16901
+ function renderInitialSuspenseHydration(state, initial) {
16902
+ state.pendingThenable = null;
16903
+ state.idState.next = initial.idStart;
16904
+ const block = createTryBody(state, initial.start, initial.end);
16905
+ state.block = block;
16906
+ setTryBranch(state, 1);
16907
+ const hydration = new HydrationCapability(block, initial.start.nextSibling, null);
16908
+ if (initial.seedRaw !== null) hydration.seeds = hydration.parseSeeds(initial.seedRaw);
16909
+ hydration.claimRootRemainder(initial.end);
16910
+ hydration.protectRootAnchor(initial.end);
16911
+ const previousHydration = currentHydration;
16912
+ const previousCapture = WIP_CAPTURE;
16913
+ const capture = createOffscreenCapture();
16914
+ currentHydration = hydration;
16915
+ WIP_CAPTURE = capture;
16916
+ const previousNative = (0, import_read_protocol.setNativeAdoptionResolver)(null);
16917
+ let suspended = null;
16918
+ let failed = false;
16919
+ let failure;
16920
+ try {
16921
+ if (initial.nativeRaw !== null) {
16922
+ hydration.nativeAdoption = ownNativeAdoption(
16923
+ block,
16924
+ (0, import_native_read_seeds.parseNativeSignalManifest)(initial.nativeRaw)
16925
+ );
16926
+ (0, import_read_protocol.setNativeAdoptionResolver)(hydration.nativeAdoption.resolve);
16927
+ }
16928
+ renderBlock(block);
16929
+ drainHydrationRenderPhaseUpdates(block);
16930
+ hydration.flushClassWrites();
16931
+ hydration.flushTextWarnings();
16932
+ state.hasResolved = true;
16933
+ } catch (error) {
16934
+ failed = true;
16935
+ failure = error;
16936
+ if (isSuspenseException(error)) suspended = error.thenable;
16937
+ const refs = [];
16938
+ collectVisibleSubtreeRefs(block, refs);
16939
+ withRefDetachSuppression(refs, () => unmountBlock(block, false));
16940
+ state.block = null;
16941
+ state.tryBlock = null;
16942
+ discardOffscreenCapture(capture);
16943
+ } finally {
16944
+ (0, import_read_protocol.setNativeAdoptionResolver)(previousNative);
16945
+ WIP_CAPTURE = previousCapture;
16946
+ currentHydration = previousHydration;
16947
+ if (previousHydration !== null) previousHydration.node = state.end;
16948
+ }
16949
+ if (!failed) {
16950
+ initialSuspenseHydrations?.delete(state);
16951
+ (capture.renderCleanups ??= []).push((discarded) => {
16952
+ if (discarded) return;
16953
+ finishInitialSuspenseHydration(initial, hydration);
16954
+ });
16955
+ spliceOffscreenCapture(capture);
16956
+ return;
16957
+ }
16958
+ if (suspended !== null) {
16959
+ state.pendingThenable = suspended;
16960
+ const resume = () => {
16961
+ if (state.parentBlock.disposed || state.pendingThenable !== suspended || initialSuspenseHydrations?.get(state) !== initial)
16962
+ return;
16963
+ scheduleRender(state.parentBlock);
16964
+ };
16965
+ suspended.then(resume, resume);
16966
+ return;
16967
+ }
16968
+ initialSuspenseHydrations?.delete(state);
16969
+ if (failure instanceof import_read_protocol.NativeAdoptionMiss || isHostContextRequest(failure)) throw failure;
16970
+ const adoptServerCatch = hydration.isRejection(failure);
16971
+ if (!adoptServerCatch) removeRange(initial.start.nextSibling, initial.end);
16972
+ const outerHydration = currentHydration;
16973
+ if (adoptServerCatch) currentHydration = hydration;
16974
+ try {
16975
+ switchToCatch(
16976
+ state,
16977
+ failure,
16978
+ true,
16979
+ adoptServerCatch ? initial.start : void 0,
16980
+ adoptServerCatch ? initial.end : void 0
16981
+ );
16982
+ if (WIP_CAPTURE === null) finishInitialSuspenseHydration(initial, hydration);
16983
+ else
16984
+ (WIP_CAPTURE.renderCleanups ??= []).push((discarded) => {
16985
+ if (!discarded) finishInitialSuspenseHydration(initial, hydration);
16986
+ });
16987
+ } finally {
16988
+ currentHydration = outerHydration;
16989
+ if (outerHydration !== null) outerHydration.node = state.end;
16990
+ }
16991
+ }
16543
16992
  function mountTry(state) {
16544
16993
  cancelSuspenseRetry(state);
16545
16994
  HIDDEN_REVEAL_ACTIONS?.delete(state);
@@ -18067,6 +18516,9 @@ function switchToCatchInner(state, err, reportInline, adoptedStart, adoptedEnd)
18067
18516
  );
18068
18517
  b.idState = state.idState;
18069
18518
  state.block = b;
18519
+ if (adopting && hydration !== null && hydration.rootBlock.disposed && hydration.rootBlock.startMarker === bStart && hydration.rootBlock.endMarker === bEnd) {
18520
+ hydration.rootBlock = b;
18521
+ }
18070
18522
  try {
18071
18523
  if (!adopting && hydration !== null) hydration.suspend(() => renderBlock(b));
18072
18524
  else renderBlock(b);
@@ -19137,8 +19589,9 @@ function switchBlock(parentScope, slotKey, domParent, discriminant, cases, defau
19137
19589
  }
19138
19590
  renderBranchSlot(parentScope, slotKey, state, domParent, nextIdx, body, "switch", env);
19139
19591
  }
19140
- function forBlock(parentScope, slotKey, domParent, items, getKey, itemBody, flags, deps, emptyBody, anchor, ownEnd) {
19592
+ function forBlock(parentScope, slotKey, domParent, inputItems, getKey, itemBody, flags, deps, emptyBody, anchor, ownEnd) {
19141
19593
  if (CURRENT_BLOCK?.pending && !CURRENT_BLOCK.crossRenderUpdate) return;
19594
+ const items = Array.isArray(inputItems) ? inputItems : Array.from(inputItems);
19142
19595
  const parentBlock = parentScope.block;
19143
19596
  const hydration = activeHydration();
19144
19597
  let state = parentScope.slots[slotKey];
@@ -19713,8 +20166,11 @@ function reconcileKeyed(parentBlock, state, items, getKey, itemBody, pure, singl
19713
20166
  }
19714
20167
  if (process.env.NODE_ENV !== "production") getKey = checkedListKey(getKey);
19715
20168
  if (newLen === 0) {
19716
- if (journalShape) journalForSlot(state);
19717
- batchClearItems(state, oldItems);
20169
+ const ownedRootClear = journalShape && canDeferRootOwnedListClear(state);
20170
+ if (ownedRootClear && (TRANSITION_JOURNAL_BAGS.get(state) ?? -1) < TRANSITION_JOURNAL_CHECKPOINT)
20171
+ journalForOwnedListClear(state);
20172
+ else if (journalShape) journalForSlot(state);
20173
+ batchClearItems(state, ownedRootClear ? state.items : oldItems, ownedRootClear);
19718
20174
  state.head = null;
19719
20175
  state.tail = null;
19720
20176
  state.size = 0;
@@ -20043,8 +20499,76 @@ function reconcileKeyed(parentBlock, state, items, getKey, itemBody, pure, singl
20043
20499
  }
20044
20500
  }
20045
20501
  const RANGE_CLEAR_MIN_ITEMS = 512;
20046
- function batchClearItems(state, oldItems) {
20502
+ function canDeferRootOwnedListClear(state) {
20503
+ const transaction = ROOT_RENDER_TRANSACTION;
20504
+ const parent = state.start.parentNode;
20505
+ if (transaction === null || transaction.aborted || ROOT_RENDER_ROLLBACK || transaction.hydrating === true || state.adopt !== null || state.size < 16 || parent === null || parent.nodeType !== 1 && parent.nodeType !== 11 || state.end.parentNode !== parent || state.start.previousSibling !== null || state.end.nextSibling !== null)
20506
+ return false;
20507
+ const oldHead = state.head;
20508
+ for (let block = oldHead; block !== null; block = block.nextSibling) {
20509
+ if (!block.mounted || block.idState.renderOwner !== transaction.owner || block.startMarker === null || block.startMarker !== block.endMarker || block.hooks !== null || block.effectSlots !== null || block.cleanups !== null || block.children !== null || block._slots !== null || block.refFields !== null || block.deoptNode !== null || block.vt !== null)
20510
+ return false;
20511
+ }
20512
+ return true;
20513
+ }
20514
+ function deferRootOwnedListClear(state, certified = false) {
20515
+ if (!certified && !canDeferRootOwnedListClear(state)) return false;
20516
+ const transaction = ROOT_RENDER_TRANSACTION;
20517
+ const parent = state.start.parentNode;
20518
+ const oldHead = state.head;
20519
+ const retired = transaction.retired ??= /* @__PURE__ */ new Set();
20520
+ const newlyRetired = [];
20521
+ for (let block = oldHead; block !== null; block = block.nextSibling) {
20522
+ if (!retired.has(block)) {
20523
+ retired.add(block);
20524
+ newlyRetired.push(block);
20525
+ }
20526
+ if (block.pending) {
20527
+ journalRootProperty(block, "pending");
20528
+ block.pending = false;
20529
+ }
20530
+ }
20531
+ let cancelled = false;
20532
+ journalUndo(() => {
20533
+ cancelled = true;
20534
+ for (let i = 0; i < newlyRetired.length; i++) retired.delete(newlyRetired[i]);
20535
+ });
20536
+ const start = state.start;
20537
+ const end = state.end;
20538
+ (transaction.commit ??= []).push(() => {
20539
+ if (cancelled) return;
20540
+ let wholeParent = state.size === 0 && start.parentNode === parent && end.parentNode === parent && start.previousSibling === null && end.nextSibling === null;
20541
+ if (wholeParent) {
20542
+ let node = start.nextSibling;
20543
+ for (let block = oldHead; block !== null; block = block.nextSibling) {
20544
+ if (node !== block.startMarker) {
20545
+ wholeParent = false;
20546
+ break;
20547
+ }
20548
+ node = node.nextSibling;
20549
+ }
20550
+ if (node !== end) wholeParent = false;
20551
+ }
20552
+ for (let block = oldHead; block !== null; block = block.nextSibling) block.disposed = true;
20553
+ if (wholeParent) {
20554
+ parent.textContent = "";
20555
+ parent.appendChild(start);
20556
+ parent.appendChild(end);
20557
+ } else {
20558
+ for (let block = oldHead; block !== null; block = block.nextSibling) {
20559
+ const node = block.startMarker;
20560
+ if (node.parentNode !== null) node.parentNode.removeChild(node);
20561
+ }
20562
+ }
20563
+ });
20564
+ return true;
20565
+ }
20566
+ function batchClearItems(state, oldItems, ownedRootClear = false) {
20047
20567
  if (forSlotParkable(state)) {
20568
+ if (deferRootOwnedListClear(state, ownedRootClear)) {
20569
+ oldItems.clear();
20570
+ return;
20571
+ }
20048
20572
  let next;
20049
20573
  for (let b = state.head; b !== null; b = next) {
20050
20574
  next = b.nextSibling;
@@ -21747,6 +22271,7 @@ function scriptResource(attrs) {
21747
22271
  beginNativeReadScope,
21748
22272
  beginNativeReadWitness,
21749
22273
  bindRendererRegionOwner,
22274
+ callWithReceiver,
21750
22275
  child,
21751
22276
  childSlot,
21752
22277
  childTextHole,
@@ -21816,6 +22341,7 @@ function scriptResource(attrs) {
21816
22341
  injectStyle,
21817
22342
  invokeManualHook,
21818
22343
  isChildrenBlock,
22344
+ isInActScope,
21819
22345
  isValidElement,
21820
22346
  keyedForBlock,
21821
22347
  lazy,