octane 0.13.1 → 0.13.3

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 (47) hide show
  1. package/dist/cjs/runtime.cjs +208 -428
  2. package/dist/cjs/signals/engine.cjs +6 -76
  3. package/dist/cjs/signals/facade.cjs +1 -0
  4. package/dist/cjs/signals/graph.cjs +1 -1
  5. package/dist/cjs/signals/native-read-seeds.cjs +3 -1
  6. package/dist/cjs/signals/native-read-server.cjs +2 -0
  7. package/dist/cjs/signals/read-protocol.cjs +32 -2
  8. package/dist/cjs/signals/seed-serialization.cjs +103 -0
  9. package/dist/cjs/stream-protocol.cjs +2 -0
  10. package/dist/cjs/version.cjs +1 -1
  11. package/dist/compiler/bundler.js +28 -3
  12. package/dist/compiler/compile-universal.js +40 -38
  13. package/dist/compiler/compile.js +911 -358
  14. package/dist/compiler/hook-deps.js +2 -11
  15. package/dist/compiler/index.d.ts +10 -0
  16. package/dist/compiler/strong-diagnostics.js +2 -32
  17. package/dist/compiler/strong-fixes.js +0 -63
  18. package/dist/compiler/strong-mode.js +1 -6
  19. package/dist/compiler/vite.js +91 -5
  20. package/dist/node/runtime.js +210 -434
  21. package/dist/node/signals/engine.js +8 -78
  22. package/dist/node/signals/facade.js +3 -1
  23. package/dist/node/signals/graph.js +2 -1
  24. package/dist/node/signals/native-read-seeds.js +3 -1
  25. package/dist/node/signals/native-read-server.js +3 -1
  26. package/dist/node/signals/read-protocol.js +25 -1
  27. package/dist/node/signals/seed-serialization.js +78 -0
  28. package/dist/node/stream-protocol.js +1 -0
  29. package/dist/node/version.js +1 -1
  30. package/dist/runtime.d.ts +38 -33
  31. package/dist/runtime.js +210 -434
  32. package/dist/signals/engine.d.ts +0 -2
  33. package/dist/signals/engine.js +8 -78
  34. package/dist/signals/facade.js +3 -1
  35. package/dist/signals/graph.d.ts +1 -2
  36. package/dist/signals/graph.js +2 -1
  37. package/dist/signals/native-read-seeds.d.ts +1 -1
  38. package/dist/signals/native-read-seeds.js +3 -1
  39. package/dist/signals/native-read-server.js +3 -1
  40. package/dist/signals/read-protocol.d.ts +14 -1
  41. package/dist/signals/read-protocol.js +25 -1
  42. package/dist/signals/seed-serialization.d.ts +8 -0
  43. package/dist/signals/seed-serialization.js +77 -0
  44. package/dist/stream-protocol.d.ts +6 -0
  45. package/dist/stream-protocol.js +1 -0
  46. package/dist/version.js +1 -1
  47. package/package.json +1 -2
@@ -93,6 +93,7 @@ __export(runtime_exports, {
93
93
  compilerCacheMappedArray: () => compilerCacheMappedArray,
94
94
  compilerMemoRegion: () => compilerMemoRegion,
95
95
  compilerMemoWitness: () => compilerMemoWitness,
96
+ compilerOpaqueTag: () => compilerOpaqueTag,
96
97
  compilerOwnsContextProvider: () => compilerOwnsContextProvider,
97
98
  componentSlot: () => componentSlot,
98
99
  componentSlotLite: () => componentSlotLite,
@@ -368,6 +369,7 @@ var import_dom_binding_protocol = require("./dom-binding-protocol.cjs");
368
369
  var import_hydration_markers = require("./hydration-markers.cjs");
369
370
  var import_runtime_tags = require("./runtime-tags.cjs");
370
371
  var import_dom_focused_move = require("./dom-focused-move.cjs");
372
+ var import_data_encoding = require("./data-encoding.cjs");
371
373
  var import_stream_protocol = require("./stream-protocol.cjs");
372
374
  var import_renderer_bridge = require("./renderer-bridge.cjs");
373
375
  var import_context_identity = require("./context-identity.cjs");
@@ -500,6 +502,7 @@ let SCHEDULED_VISIBILITY_DRIVER = null;
500
502
  let DEFERRED_LAYOUT_DRIVER = null;
501
503
  let STAGED_COMMIT_CAPTURE = null;
502
504
  let FORM_SUBMIT_DRIVER = null;
505
+ let SKIPPED_ROW_REFRESH = null;
503
506
  let activityRefState = null;
504
507
  let EFFECT_RECONNECT_CONTEXT = null;
505
508
  let drainEffectEventUpdates = noop;
@@ -1355,10 +1358,30 @@ function retainNativeRetryReads(block, reads) {
1355
1358
  retry.track(reads);
1356
1359
  }
1357
1360
  function ownNativeAdoption(scope, manifest, consume) {
1358
- const adoption = (0, import_native_read_seeds.createNativeAdoptionState)(
1359
- manifest,
1360
- scope.block.idState.renderOwner?.initialDocumentSignals
1361
- );
1361
+ const renderOwner = scope.block.idState.renderOwner;
1362
+ const initial = renderOwner?.initialDocumentSignals;
1363
+ const signalOwner = renderOwner?.signalOwner;
1364
+ const initialScopeKey = (signalOwner?.documentOwner ?? signalOwner)?.scopeKey ?? "octane:document";
1365
+ let state = import_read_protocol.nativeSignalHydration ? (0, import_native_read_seeds.createNativeAdoptionState)(
1366
+ typeof manifest === "string" ? (0, import_native_read_seeds.parseNativeSignalManifest)(manifest) : manifest,
1367
+ initial,
1368
+ initialScopeKey
1369
+ ) : void 0;
1370
+ const adoption = state ?? {
1371
+ resolve(owner) {
1372
+ if (state === null || !import_read_protocol.nativeSignalHydration) return void 0;
1373
+ state ??= (0, import_native_read_seeds.createNativeAdoptionState)(
1374
+ typeof manifest === "string" ? (0, import_native_read_seeds.parseNativeSignalManifest)(manifest) : manifest,
1375
+ initial,
1376
+ initialScopeKey
1377
+ );
1378
+ return state.resolve(owner);
1379
+ },
1380
+ release() {
1381
+ state?.release();
1382
+ state = null;
1383
+ }
1384
+ };
1362
1385
  (0, import_read_protocol.registerNativeReadRebase)(import_native_read_client.rebaseNativeRead);
1363
1386
  registerHookCleanup(scope, () => {
1364
1387
  adoption.release();
@@ -7573,6 +7596,7 @@ function blockRare(block) {
7573
7596
  activitySlot: void 0,
7574
7597
  thenables: void 0,
7575
7598
  thenableIdx: 0,
7599
+ batchThenables: void 0,
7576
7600
  warmCache: void 0,
7577
7601
  warmCacheEpisode: void 0,
7578
7602
  updateChain: -1,
@@ -7630,6 +7654,7 @@ function createBlock(kind, parentBlock, parentNode, startMarker, endMarker, body
7630
7654
  }
7631
7655
  let renderPhaseOwner = null;
7632
7656
  let renderPhaseUpdates = null;
7657
+ let compilerMemoPass = 0;
7633
7658
  function captureRenderPhaseUpdate(cell, key) {
7634
7659
  const updates = renderPhaseUpdates ??= /* @__PURE__ */ new Map();
7635
7660
  if (!updates.has(cell)) updates.set(cell, { value: cell.value, queue: cell[key]?.slice(), key });
@@ -7657,6 +7682,7 @@ function renderBlock(block) {
7657
7682
  }
7658
7683
  const previousOwner = renderPhaseOwner;
7659
7684
  let previousUpdates = renderPhaseUpdates;
7685
+ if (previousOwner === null) compilerMemoPass++;
7660
7686
  renderPhaseOwner = block;
7661
7687
  renderPhaseUpdates = null;
7662
7688
  try {
@@ -7815,6 +7841,8 @@ function renderBlockInner(block) {
7815
7841
  block.__warmEpisode = CURRENT_WARM_EPISODE;
7816
7842
  EFFECT_EVENT_RENDER_TARGET = effectEventTarget;
7817
7843
  EFFECT_EVENT_ACTION_TARGET = effectEventActionTarget;
7844
+ const replayUpdate = RESUME_REPLAY && block.pending && urgentTransitionRender === null;
7845
+ if (replayUpdate) RESUME_REPLAY = false;
7818
7846
  block.pending = false;
7819
7847
  block.crossRenderUpdate = false;
7820
7848
  const rare = block.rare;
@@ -7822,8 +7850,9 @@ function renderBlockInner(block) {
7822
7850
  if (rare.eventRender !== 0) rare.eventRender++;
7823
7851
  rare.thenableIdx = 0;
7824
7852
  const tState = rare.thenables;
7825
- if (tState !== void 0 && tState.length !== 0 && (!RESUME_REPLAY || block.__thenableDone === true)) {
7826
- tState.length = 0;
7853
+ if (tState !== void 0 && (!RESUME_REPLAY || block.__thenableDone === true)) {
7854
+ if (tState.length !== 0) tState.length = 0;
7855
+ rare.batchThenables = void 0;
7827
7856
  }
7828
7857
  }
7829
7858
  block.__thenableDone = false;
@@ -7911,6 +7940,7 @@ function renderBlockInner(block) {
7911
7940
  CURRENT_EFFECT_REACHED = prevEffectReached;
7912
7941
  CURRENT_SCOPE = prevScope;
7913
7942
  CURRENT_BLOCK = prevBlock;
7943
+ if (replayUpdate) RESUME_REPLAY = true;
7914
7944
  try {
7915
7945
  if (NATIVE_READ_DRIVER)
7916
7946
  NATIVE_READ_DRIVER.endRender(block, renderCompleted, isSuspenseException(profileThrown));
@@ -8000,6 +8030,7 @@ function renderReturnedValue(block, out, reset) {
8000
8030
  }
8001
8031
  if (useSingleRoot) {
8002
8032
  const d = out;
8033
+ if (!block.memoInChain) promoteMemoAncestry(block);
8003
8034
  if (typeof __OCTANE_PROFILE_ENABLED__ !== "undefined" && __OCTANE_PROFILE_ENABLED__ && !(0, import_profiling.__profileHasComponentMetadata)(d.type)) {
8004
8035
  withProfileComponentOverride(
8005
8036
  d.type,
@@ -8228,7 +8259,11 @@ function componentSlotLite(parentScope, slotKey, host, comp, props, invocationSi
8228
8259
  });
8229
8260
  }
8230
8261
  parentScope.slots[slotKey] = scope;
8231
- (parentScope.children ??= []).push({ key: slotKey, scope });
8262
+ (parentScope.children ??= []).push({
8263
+ key: slotKey,
8264
+ scope,
8265
+ at: parentScope._slots === null ? 0 : parentScope._slots.length
8266
+ });
8232
8267
  if (unframed !== void 0) {
8233
8268
  mountUnframedLite(
8234
8269
  hydration,
@@ -8260,6 +8295,9 @@ function componentSlotLite(parentScope, slotKey, host, comp, props, invocationSi
8260
8295
  }
8261
8296
  const prevScope = CURRENT_SCOPE;
8262
8297
  const warmPlanCheckpoint = ACTIVE_WARM_PLANS.length;
8298
+ const effectReached = CURRENT_EFFECT_REACHED;
8299
+ CURRENT_EFFECT_REACHED = 0;
8300
+ if (scope.effectSlots !== null) ensureEffectRenderVersion();
8263
8301
  CURRENT_SCOPE = scope;
8264
8302
  if (typeof __OCTANE_PROFILE_ENABLED__ !== "undefined" && __OCTANE_PROFILE_ENABLED__)
8265
8303
  (0, import_profiling.__profileTrackComponent)(scope, comp);
@@ -8281,6 +8319,7 @@ function componentSlotLite(parentScope, slotKey, host, comp, props, invocationSi
8281
8319
  } else comp(props, scope, void 0);
8282
8320
  if (hydration !== null) hydration.settleUnclaimed(scope);
8283
8321
  if (retryVisit !== null) pruneSignalRetryVisit(retryVisit, false);
8322
+ if (scope.effectSlots !== null) finishEffectRender(scope);
8284
8323
  if (!scope.mounted) scope.mounted = true;
8285
8324
  } catch (error) {
8286
8325
  if (retryVisit !== null && isSuspenseException(error)) pruneSignalRetryVisit(retryVisit, true);
@@ -8294,6 +8333,7 @@ function componentSlotLite(parentScope, slotKey, host, comp, props, invocationSi
8294
8333
  (0, import_profiling.__profileEndRender)(profileFrame, profileDidThrow, profileThrown);
8295
8334
  if (ACTIVE_WARM_PLANS.length !== warmPlanCheckpoint)
8296
8335
  ACTIVE_WARM_PLANS.length = warmPlanCheckpoint;
8336
+ CURRENT_EFFECT_REACHED = effectReached;
8297
8337
  CURRENT_SCOPE = prevScope;
8298
8338
  }
8299
8339
  if (hydration !== null && adoptedClose !== null) {
@@ -8458,6 +8498,7 @@ function unmountScope(scope, detachDom = true) {
8458
8498
  if (effects !== null) {
8459
8499
  for (let i = 0; i < effects.length; i++) {
8460
8500
  const slot = effects[i];
8501
+ slot.revision++;
8461
8502
  const cleanup = slot.cleanup;
8462
8503
  if (cleanup === void 0) continue;
8463
8504
  slot.cleanup = void 0;
@@ -8531,15 +8572,18 @@ function unmountScopeChildrenAndSlots(scope, detachDom, retireUnowned = true) {
8531
8572
  }
8532
8573
  function unmountScopeChildrenAndSlotsOnly(scope, detachDom) {
8533
8574
  const children = scope.children;
8534
- if (children !== null)
8535
- for (let i = 0, n = children.length; i < n; i++) unmountScope(children[i].scope, detachDom);
8536
8575
  const slots = scope._slots;
8576
+ let c = 0;
8537
8577
  if (slots !== null) {
8538
8578
  for (let i = 0, n = slots.length; i < n; i++) {
8539
- const val = slots[i];
8540
- unmountSlot(val, detachDom);
8579
+ if (children !== null)
8580
+ for (; c < children.length && children[c].at <= i; c++)
8581
+ unmountScope(children[c].scope, detachDom);
8582
+ unmountSlot(slots[i], detachDom);
8541
8583
  }
8542
8584
  }
8585
+ if (children !== null)
8586
+ for (; c < children.length; c++) unmountScope(children[c].scope, detachDom);
8543
8587
  }
8544
8588
  function unmountSlot(val, detachDom) {
8545
8589
  if ((val.__flags & SLOT_FLAG_TEARDOWN) !== 0) val.__teardown(val, detachDom);
@@ -9444,16 +9488,23 @@ function useCallback(fn, deps, slot) {
9444
9488
  }
9445
9489
  const hookMemoEqual = Object.is;
9446
9490
  let COMPILER_MEMO_PROOFS = null;
9491
+ let unprovenCompilerMemo = 0;
9447
9492
  function markCompilerMemo(component, read) {
9448
- (COMPILER_MEMO_PROOFS ??= /* @__PURE__ */ new WeakMap()).set(component, { read, values: [] });
9493
+ (COMPILER_MEMO_PROOFS ??= /* @__PURE__ */ new WeakMap()).set(component, { read, values: [], pass: -1 });
9449
9494
  return component;
9450
9495
  }
9451
9496
  function compilerMemoWitness(component) {
9497
+ if (typeof component !== "function") return --unprovenCompilerMemo;
9452
9498
  if (component.__memo === true && component.__compare === void 0) return component;
9453
9499
  const proof = COMPILER_MEMO_PROOFS?.get(component);
9454
- if (proof === void 0 || "defaultProps" in component) return void 0;
9455
- if (proof.read === null) return proof.values;
9456
- const values = proof.read();
9500
+ if (proof === void 0 || "defaultProps" in component) return --unprovenCompilerMemo;
9501
+ const read = proof.read;
9502
+ if (read === null) return proof.values;
9503
+ if (proof.pass === compilerMemoPass) return proof.values;
9504
+ if (proof.pass === ~compilerMemoPass) return --unprovenCompilerMemo;
9505
+ proof.pass = ~compilerMemoPass;
9506
+ const values = read();
9507
+ proof.pass = compilerMemoPass;
9457
9508
  const previous = proof.values;
9458
9509
  if (values.length !== previous.length) return proof.values = values;
9459
9510
  for (let index = 0; index < values.length; index++) {
@@ -9741,7 +9792,7 @@ function useEffectEvent(fn, slot) {
9741
9792
  slot = resolveSlot(slot);
9742
9793
  if (slot === void 0) missingSlot("useEffectEvent");
9743
9794
  const scope = CURRENT_SCOPE;
9744
- const block = scope.block;
9795
+ const block = CURRENT_BLOCK;
9745
9796
  const rare = blockRare(block);
9746
9797
  if (rare.eventRender === 0) rare.eventRender = 1;
9747
9798
  let s = scope.hooks?.get(slot);
@@ -10894,6 +10945,28 @@ function resumeFreshHydrateSource(source) {
10894
10945
  }
10895
10946
  }
10896
10947
  }
10948
+ function renderSuspended(hydration, source) {
10949
+ const claim = hydration.suspendedClaims?.get(source);
10950
+ if (claim !== void 0) {
10951
+ hydration.suspendedClaims.delete(source);
10952
+ hydration.renderClaimed(source, claim[0], claim[1]);
10953
+ } else renderBlock(source);
10954
+ }
10955
+ function finishRoot(hydration) {
10956
+ let remainder = hydration.rootRemainder === void 0 ? hydration.node : hydration.rootRemainder;
10957
+ while (remainder !== null && (remainder === hydration.rootCleanupBoundary || hydration.freshNodes.has(remainder) || isRendererHydrationStyle(remainder)))
10958
+ remainder = getNextSibling(remainder);
10959
+ if (remainder === null) return;
10960
+ hydration.mismatch(
10961
+ __octaneDev ? componentSourceLoc(hydration.rootBlock.body) : void 0,
10962
+ () => "the end of the root",
10963
+ remainder
10964
+ );
10965
+ }
10966
+ function keepChanges(hydration) {
10967
+ hydration.undoable = false;
10968
+ hydration.saved = hydration.undo = null;
10969
+ }
10897
10970
  function activateHydrateBoundary(state) {
10898
10971
  if (state.start === null || state.end === null) return;
10899
10972
  const block = state.block;
@@ -10934,13 +11007,9 @@ function activateHydrateBoundary(state) {
10934
11007
  let restart;
10935
11008
  try {
10936
11009
  if (preserved === void 0 && state.nativeSeedRaw !== void 0) {
10937
- hydration.nativeAdoption = ownNativeAdoption(
10938
- block,
10939
- (0, import_native_read_seeds.parseNativeSignalManifest)(state.nativeSeedRaw),
10940
- () => {
10941
- state.nativeSeedRaw = void 0;
10942
- }
10943
- );
11010
+ hydration.nativeAdoption = ownNativeAdoption(block, state.nativeSeedRaw, () => {
11011
+ state.nativeSeedRaw = void 0;
11012
+ });
10944
11013
  (0, import_read_protocol.setNativeAdoptionResolver)(hydration.nativeAdoption.resolve);
10945
11014
  }
10946
11015
  if (preserved?.source !== null && preserved?.source !== void 0) {
@@ -10948,7 +11017,7 @@ function activateHydrateBoundary(state) {
10948
11017
  hydration.node = preserved.cursor;
10949
11018
  try {
10950
11019
  if (preserved.fresh) hydration.suspend(() => resumeFreshHydrateSource(source));
10951
- else hydration.renderSuspended(source);
11020
+ else renderSuspended(hydration, source);
10952
11021
  } catch (error) {
10953
11022
  if (!isSuspenseException(error)) throw error;
10954
11023
  preserveSuspendedHydrateActivation(state, hydration, error);
@@ -10964,7 +11033,7 @@ function activateHydrateBoundary(state) {
10964
11033
  hydration.claimRootRemainder(getNextSibling(adoptedSlot.end));
10965
11034
  }
10966
11035
  hydration.settleValues();
10967
- hydration.finishRoot();
11036
+ finishRoot(hydration);
10968
11037
  completed = true;
10969
11038
  }
10970
11039
  } catch (thrown) {
@@ -11052,12 +11121,11 @@ function activateHydrateBoundary(state) {
11052
11121
  }
11053
11122
  if (completed) {
11054
11123
  state.initialCaptures = null;
11055
- hydration.keepChanges();
11124
+ keepChanges(hydration);
11056
11125
  hydration.passSeeds(previousHydration);
11057
11126
  releasePreservedHydrateActivation(state);
11058
11127
  spliceOffscreenCapture(capture);
11059
11128
  }
11060
- if (completed && hydration.hasAdjacentRangePair && !hydration.presentation) hydration.coalesce();
11061
11129
  }
11062
11130
  function discardHydrateTail(state) {
11063
11131
  const end = state.end;
@@ -11149,7 +11217,7 @@ function initializeHydrateComponent(boundaryBody) {
11149
11217
  }
11150
11218
  const surroundingUpdate = state.props !== props || state.contextChanged;
11151
11219
  state.props = props;
11152
- if (!state.independent && !state.hydrated) {
11220
+ if (!state.independent && !state.hydrated && state.serverPreserved) {
11153
11221
  const strategy = resolveHydrateStrategy(state);
11154
11222
  if (strategy._t === "never") {
11155
11223
  cleanupHydrateStrategy(state);
@@ -11367,6 +11435,7 @@ function promoteMemoAncestry(scope) {
11367
11435
  }
11368
11436
  function recordContextDependency(block, context) {
11369
11437
  if (block === null || !block.memoInChain) return;
11438
+ SKIPPED_ROW_REFRESH = refreshSkippedRows;
11370
11439
  (block.$$ctxDirect ??= /* @__PURE__ */ new Map()).set(context, context.$$version);
11371
11440
  for (let current = block; current !== null; current = current.parentBlock) {
11372
11441
  if (current.body?.__memo === true || current.$$implicitBail === true) {
@@ -11691,17 +11760,15 @@ function useThenable(thenable, replaceOnResume = false) {
11691
11760
  return hydration.useSeed(thenable, state, idx, replaceOnResume);
11692
11761
  }
11693
11762
  const stored = state[idx];
11763
+ if (stored !== void 0 && stored !== thenable && !replaceOnResume)
11764
+ thenable = replayThenable(block, stored, thenable);
11694
11765
  if (stored === thenable) {
11695
11766
  if (thenable.status === "fulfilled") return thenable.value;
11696
11767
  if (thenable.status === "rejected") throw thenable.reason;
11697
11768
  throw new SuspenseException(thenable);
11698
11769
  }
11699
- if (stored !== void 0 && RESUME_REPLAY && !replaceOnResume) {
11700
- if (__octaneDev) warnUncachedUsePromise(block);
11701
- if (stored.status === "fulfilled") return stored.value;
11702
- if (stored.status === "rejected") throw stored.reason;
11703
- throw new SuspenseException(stored);
11704
- }
11770
+ if (rare.batchThenables !== void 0)
11771
+ thenable = heldBatchThenable(rare.batchThenables, thenable);
11705
11772
  state[idx] = thenable;
11706
11773
  trackThenable(thenable);
11707
11774
  if (thenable.status === "fulfilled") return thenable.value;
@@ -11710,6 +11777,11 @@ function useThenable(thenable, replaceOnResume = false) {
11710
11777
  warnUseWaterfall(block, idx);
11711
11778
  throw new SuspenseException(thenable);
11712
11779
  }
11780
+ function replayThenable(block, kept, thenable) {
11781
+ if (!RESUME_REPLAY) return thenable;
11782
+ if (__octaneDev) warnUncachedUsePromise(block);
11783
+ return kept;
11784
+ }
11713
11785
  let SETTLED_WAKEABLES = null;
11714
11786
  function resumeOnSettle(wakeable, retry) {
11715
11787
  const onSettle = SETTLED_WAKEABLES?.has(wakeable) === true ? () => void setTimeout(retry, 0) : () => {
@@ -11770,7 +11842,10 @@ function useBatch(items, warm) {
11770
11842
  if (it == null || typeof it.then !== "function") continue;
11771
11843
  trackThenable(it);
11772
11844
  if (it.status === "rejected") break;
11773
- if (it.status === "pending") (pending ??= []).push(it);
11845
+ if (it.status === "pending") {
11846
+ pending = holdBatchThenables(items);
11847
+ break;
11848
+ }
11774
11849
  }
11775
11850
  if (pending === null) return;
11776
11851
  runActiveWarmPlans(warm);
@@ -11786,6 +11861,32 @@ function useBatch(items, warm) {
11786
11861
  });
11787
11862
  throw new SuspenseException(combined);
11788
11863
  }
11864
+ function holdBatchThenables(items) {
11865
+ const block = CURRENT_BLOCK;
11866
+ const rare = blockRare(block);
11867
+ rare.thenables ??= [];
11868
+ const held = rare.batchThenables ??= [];
11869
+ let pending = null;
11870
+ for (let i = 0, at = rare.thenableIdx * 2; i < items.length; i++) {
11871
+ let it = items[i];
11872
+ if (it == null || typeof it.then !== "function") continue;
11873
+ trackThenable(it);
11874
+ const kept = held[at];
11875
+ if (kept === void 0) held[at] = it;
11876
+ else if (kept !== it) {
11877
+ held[at + 1] = it;
11878
+ it = replayThenable(block, kept, it);
11879
+ }
11880
+ at += 2;
11881
+ if (it.status === "rejected") break;
11882
+ if (it.status === "pending") (pending ??= []).push(it);
11883
+ }
11884
+ return pending;
11885
+ }
11886
+ function heldBatchThenable(held, thenable) {
11887
+ for (let i = 1; i < held.length; i += 2) if (held[i] === thenable) return held[i - 1];
11888
+ return thenable;
11889
+ }
11789
11890
  function registerWarmPlan(fn, props) {
11790
11891
  ACTIVE_WARM_PLANS.push(CURRENT_BLOCK, fn, props);
11791
11892
  }
@@ -12764,7 +12865,6 @@ class HydrationCapability {
12764
12865
  */
12765
12866
  replayDepth = -1;
12766
12867
  seedCursor = 0;
12767
- hasAdjacentRangePair = false;
12768
12868
  freshNodes = /* @__PURE__ */ new WeakSet();
12769
12869
  unframedRootRanges = /* @__PURE__ */ new WeakMap();
12770
12870
  /** Adopted ranges whose first render suspended, by block, with its slot (renderClaimed). */
@@ -12979,11 +13079,6 @@ class HydrationCapability {
12979
13079
  this.saved = this.undo = null;
12980
13080
  if (undo !== null) for (let i = undo.length - 1; i >= 0; i--) undo[i]();
12981
13081
  }
12982
- /** An island's attempt completed: it keeps the server nodes it changed. */
12983
- keepChanges() {
12984
- this.undoable = false;
12985
- this.saved = this.undo = null;
12986
- }
12987
13082
  isActive() {
12988
13083
  return this.depth === 0;
12989
13084
  }
@@ -13163,18 +13258,6 @@ class HydrationCapability {
13163
13258
  this.unclaimed = this.unclaimedScope = null;
13164
13259
  this.slotMismatch(scope, this.unclaimedKey, "a component range", node);
13165
13260
  }
13166
- /**
13167
- * Resume `source`, the block that a preserved activation suspended in. A
13168
- * source whose first render into its adopted range suspended claims that
13169
- * range again, as the render that suspended did.
13170
- */
13171
- renderSuspended(source) {
13172
- const claim = this.suspendedClaims?.get(source);
13173
- if (claim !== void 0) {
13174
- this.suspendedClaims.delete(source);
13175
- this.renderClaimed(source, claim[0], claim[1]);
13176
- } else renderBlock(source);
13177
- }
13178
13261
  /**
13179
13262
  * Open a claim on the server range a slot adopted, whose content starts at
13180
13263
  * `first`, for the first render of that content. Returns what endClaim
@@ -13611,11 +13694,7 @@ class HydrationCapability {
13611
13694
  }
13612
13695
  close(open) {
13613
13696
  const known = this.matchingCloses?.get(open);
13614
- const found = known ?? findMatchingClose(open, this.matchingCloses ??= /* @__PURE__ */ new WeakMap());
13615
- if (!this.hasAdjacentRangePair && isBlockOpen((STAGED_DOM ? STAGED_DOM.view(open) : open).previousSibling) && isBlockClose(getNextSibling(found))) {
13616
- this.hasAdjacentRangePair = true;
13617
- }
13618
- return found;
13697
+ return known ?? findMatchingClose(open, this.matchingCloses ??= /* @__PURE__ */ new WeakMap());
13619
13698
  }
13620
13699
  /**
13621
13700
  * Adopt the text of a binding-view text hole whose server range `posNode`
@@ -14481,26 +14560,6 @@ class HydrationCapability {
14481
14560
  if ((STAGED_DOM ? STAGED_DOM.view(root) : root).parentNode === parent) return;
14482
14561
  (STAGED_DOM ? STAGED_DOM.view(parent) : parent).insertBefore(root, block.endMarker);
14483
14562
  }
14484
- /**
14485
- * After a Hydrate island's content adopted its server range, a server
14486
- * sibling left after the island's complete client shape is content the
14487
- * client renders nothing for: a mismatch, which the island falls back from.
14488
- * Cursor-based adoption may stop on an owned range marker, and the client
14489
- * may have built nodes there, so look past both, and past renderer style
14490
- * sidecars. A root keeps the unmatched siblings in its container, as React
14491
- * does, so only an island settles its remainder.
14492
- */
14493
- finishRoot() {
14494
- let remainder = this.rootRemainder === void 0 ? this.node : this.rootRemainder;
14495
- while (remainder !== null && (remainder === this.rootCleanupBoundary || this.freshNodes.has(remainder) || isRendererHydrationStyle(remainder)))
14496
- remainder = getNextSibling(remainder);
14497
- if (remainder === null) return;
14498
- this.mismatch(
14499
- __octaneDev ? componentSourceLoc(this.rootBlock.body) : void 0,
14500
- () => "the end of the root",
14501
- remainder
14502
- );
14503
- }
14504
14563
  /**
14505
14564
  * Whether `el`, whose only child is a text value, keeps the server content
14506
14565
  * it holds: React compares such a host's text content as a whole, and under
@@ -14865,13 +14924,6 @@ class HydrationCapability {
14865
14924
  for (const [line, node] of unpatched) if (root.contains(node)) lines.push(line);
14866
14925
  if (lines.length !== 0) warnHydrationUnpatched(lines);
14867
14926
  }
14868
- coalesce() {
14869
- const leases = this.rootBlock.idState.renderOwner?.bindingLeases;
14870
- if (leases !== void 0) {
14871
- for (const lease of leases) if (lease.revision !== void 0 && lease.active()) return;
14872
- }
14873
- coalesceHydratedRanges(this.rootBlock, this.liteRanges);
14874
- }
14875
14927
  }
14876
14928
  function decodeSeedWire(value) {
14877
14929
  const undefinedWire = import_constants.SUSPENSE_SEED_WIRE_PREFIX + "u";
@@ -15835,33 +15887,15 @@ function setBindingClassIfChanged(value, previous, element, receipt) {
15835
15887
  if (value !== previous) setBindingClass(element, receipt, value);
15836
15888
  return value;
15837
15889
  }
15838
- function hydrationMarkerMultiplicity(data, open) {
15839
- const marker = open ? import_constants.HYDRATION_START : import_constants.HYDRATION_END;
15840
- if (data === marker) return 1;
15841
- if (open && (data === import_constants.HYDRATION_FOR_EMPTY || data === import_constants.HYDRATION_FOR_ITEMS)) return 1;
15842
- if (open && (data.startsWith(import_dom_binding_protocol.BINDING_OPEN_PREFIX) || data.startsWith(import_hydration_markers.HYDRATION_FOR_PREFIX)) && (0, import_dom_binding_protocol.isBindingOpenComment)(data))
15843
- return 1;
15844
- if (data.length < 2 || data.charCodeAt(0) !== marker.charCodeAt(0)) return 0;
15845
- const first = data.charCodeAt(1);
15846
- if (first < 49 || first > 57) return 0;
15847
- let value = first - 48;
15848
- for (let i = 2; i < data.length; i++) {
15849
- const digit = data.charCodeAt(i) - 48;
15850
- if (digit < 0 || digit > 9) return 0;
15851
- value = value * 10 + digit;
15852
- if (!Number.isSafeInteger(value)) return 0;
15853
- }
15854
- return value >= 2 ? value : 0;
15855
- }
15856
15890
  function isBlockOpen(node) {
15857
15891
  if (node === null || node.nodeType !== 8) return false;
15858
15892
  const data = (STAGED_DOM ? STAGED_DOM.view(node) : node).data;
15859
- return hydrationMarkerMultiplicity(data, true) > 0;
15893
+ return (0, import_stream_protocol.hydrationMarkerMultiplicity)(data, true) > 0;
15860
15894
  }
15861
15895
  function isBlockClose(node) {
15862
15896
  if (node === null || node.nodeType !== 8) return false;
15863
15897
  const data = (STAGED_DOM ? STAGED_DOM.view(node) : node).data;
15864
- return data === import_constants.HYDRATION_END || hydrationMarkerMultiplicity(data, false) > 1;
15898
+ return data === import_constants.HYDRATION_END || (0, import_stream_protocol.hydrationMarkerMultiplicity)(data, false) > 1;
15865
15899
  }
15866
15900
  function isTextSeparator(node) {
15867
15901
  return node !== null && node.nodeType === 8 && (STAGED_DOM ? STAGED_DOM.view(node) : node).data === import_constants.HYDRATION_TEXT_SEP;
@@ -15880,9 +15914,9 @@ function findMatchingClose(open, matches) {
15880
15914
  if (!close && !nestedOpen && data.length > 1) {
15881
15915
  const first = data.charCodeAt(0);
15882
15916
  if (first === import_constants.HYDRATION_END.charCodeAt(0)) {
15883
- close = hydrationMarkerMultiplicity(data, false) > 0;
15917
+ close = (0, import_stream_protocol.hydrationMarkerMultiplicity)(data, false) > 0;
15884
15918
  } else if (first === import_constants.HYDRATION_START.charCodeAt(0)) {
15885
- nestedOpen = hydrationMarkerMultiplicity(data, true) > 0;
15919
+ nestedOpen = (0, import_stream_protocol.hydrationMarkerMultiplicity)(data, true) > 0;
15886
15920
  }
15887
15921
  }
15888
15922
  if (close) {
@@ -22509,7 +22543,11 @@ function hostComponent(scope, slot, tag, props, childrenBody, anchor) {
22509
22543
  scope.slots[slot] = state;
22510
22544
  const childScope = new ScopeImpl(scope, block);
22511
22545
  state.childScope = childScope;
22512
- (scope.children ??= []).push({ key: slot, scope: childScope });
22546
+ (scope.children ??= []).push({
22547
+ key: slot,
22548
+ scope: childScope,
22549
+ at: scope._slots === null ? 0 : scope._slots.length
22550
+ });
22513
22551
  domNode(block.parentNode).insertBefore(el2, anchor ?? block.endMarker);
22514
22552
  (scope.cleanups ??= []).push(() => queueRefDetach(state.ref, state.el));
22515
22553
  }
@@ -23836,6 +23874,7 @@ function renderPreparedChildList(state, parentBlock, domParent, preparedList, hy
23836
23874
  tail: null,
23837
23875
  size: 0,
23838
23876
  cachedDeps: null,
23877
+ ctxEpoch: 0,
23839
23878
  emptyBlock: null,
23840
23879
  env: void 0,
23841
23880
  adopt: null,
@@ -23971,6 +24010,7 @@ function renderPreparedChildList(state, parentBlock, domParent, preparedList, hy
23971
24010
  ssrMarkerless,
23972
24011
  normalizeKey
23973
24012
  );
24013
+ if (pure && SKIPPED_ROW_REFRESH) SKIPPED_ROW_REFRESH(state.forSlot, parentBlock);
23974
24014
  }
23975
24015
  if (state.forSlot.adopt !== null) {
23976
24016
  const leftovers = state.forSlot.adopt;
@@ -25139,6 +25179,10 @@ function compilerCacheContext(scope, slotKey, previous, restampMemoAncestors = f
25139
25179
  if (restamp) restampCachedSlotContext(slot);
25140
25180
  return current;
25141
25181
  }
25182
+ function compilerOpaqueTag(scope, tag) {
25183
+ if (!scope.block.memoInChain) promoteMemoAncestry(scope);
25184
+ return tag;
25185
+ }
25142
25186
  const OBJ_PROTO = Object.prototype;
25143
25187
  function shallowEqualProps(a, b) {
25144
25188
  if (a === b) return true;
@@ -26324,10 +26368,9 @@ function takeInitialSuspenseHydration(state, hydration) {
26324
26368
  nativeRaw
26325
26369
  };
26326
26370
  }
26327
- function finishInitialSuspenseHydration(initial, hydration) {
26371
+ function finishInitialSuspenseHydration(initial) {
26328
26372
  for (const node of initial.metadata) (STAGED_DOM ? STAGED_DOM.view(node) : node).remove();
26329
26373
  initial.consume?.();
26330
- if (hydration.hasAdjacentRangePair) hydration.coalesce();
26331
26374
  }
26332
26375
  function catchesInHydrationFallback(render) {
26333
26376
  const transaction = ROOT_RENDER_TRANSACTION;
@@ -26409,10 +26452,7 @@ function renderInitialSuspenseHydration(state, initial, updated = false) {
26409
26452
  let failure;
26410
26453
  try {
26411
26454
  if (initial.nativeRaw !== null) {
26412
- hydration.nativeAdoption = ownNativeAdoption(
26413
- block,
26414
- (0, import_native_read_seeds.parseNativeSignalManifest)(initial.nativeRaw)
26415
- );
26455
+ hydration.nativeAdoption = ownNativeAdoption(block, initial.nativeRaw);
26416
26456
  (0, import_read_protocol.setNativeAdoptionResolver)(hydration.nativeAdoption.resolve);
26417
26457
  }
26418
26458
  renderBlock(block);
@@ -26459,7 +26499,7 @@ function renderInitialSuspenseHydration(state, initial, updated = false) {
26459
26499
  initialSuspenseHydrations?.delete(state);
26460
26500
  (capture.renderCleanups ??= []).push((discarded) => {
26461
26501
  if (discarded) return;
26462
- finishInitialSuspenseHydration(initial, hydration);
26502
+ finishInitialSuspenseHydration(initial);
26463
26503
  });
26464
26504
  spliceOffscreenCapture(capture);
26465
26505
  return;
@@ -26493,10 +26533,10 @@ function renderInitialSuspenseHydration(state, initial, updated = false) {
26493
26533
  adoptServerCatch ? initial.start : void 0,
26494
26534
  adoptServerCatch ? initial.end : void 0
26495
26535
  );
26496
- if (WIP_CAPTURE === null) finishInitialSuspenseHydration(initial, hydration);
26536
+ if (WIP_CAPTURE === null) finishInitialSuspenseHydration(initial);
26497
26537
  else
26498
26538
  (WIP_CAPTURE.renderCleanups ??= []).push((discarded) => {
26499
- if (!discarded) finishInitialSuspenseHydration(initial, hydration);
26539
+ if (!discarded) finishInitialSuspenseHydration(initial);
26500
26540
  });
26501
26541
  } finally {
26502
26542
  swapHydration(outerHydration);
@@ -26590,7 +26630,7 @@ function mountTry(state, claimsRetryOwners = false) {
26590
26630
  let nativeAdoption;
26591
26631
  if (import_hydration_flag.hydrating && scopedNativeRaw !== void 0 && !freshBoundary) {
26592
26632
  const boundaryId = streamedBoundaryId;
26593
- nativeAdoption = ownNativeAdoption(b, (0, import_native_read_seeds.parseNativeSignalManifest)(scopedNativeRaw), () => {
26633
+ nativeAdoption = ownNativeAdoption(b, scopedNativeRaw, () => {
26594
26634
  const stash = typeof window !== "undefined" ? window.$OCTS : void 0;
26595
26635
  if (stash !== void 0) {
26596
26636
  delete stash[boundaryId + "$signals"];
@@ -27820,7 +27860,8 @@ function useActionState(action, initialState, permalinkOrSlot, slot) {
27820
27860
  return [s.state, s.dispatch, s.isPending];
27821
27861
  }
27822
27862
  function findAncestorForm(block) {
27823
- let n = block.startMarker ?? block.parentNode ?? null;
27863
+ const start = block.startMarker;
27864
+ let n = start ? (STAGED_DOM ? STAGED_DOM.view(start) : start).parentNode : block.parentNode ?? null;
27824
27865
  while (n) {
27825
27866
  if (n.nodeName === "FORM") return n;
27826
27867
  n = (STAGED_DOM ? STAGED_DOM.view(n) : n).parentNode;
@@ -27842,7 +27883,7 @@ function useFormStatus(slot) {
27842
27883
  FORM_STATUS_LISTENERS.get(slotRef.form)?.delete(slotRef.listener);
27843
27884
  });
27844
27885
  }
27845
- const form = findAncestorForm(block);
27886
+ const form = findAncestorForm(scope.block);
27846
27887
  if (form !== s.form) {
27847
27888
  if (s.form && s.listener) FORM_STATUS_LISTENERS.get(s.form)?.delete(s.listener);
27848
27889
  s.form = form;
@@ -28376,16 +28417,17 @@ function unmountLiteArm(state, detachDom) {
28376
28417
  }
28377
28418
  function replaceSharedBlockBoundary(parent, oldStart, oldEnd, newStart, newEnd) {
28378
28419
  if (oldStart === null || oldEnd === null) return;
28379
- let block = parent;
28380
- while (block !== null && block.startMarker === oldStart && block.endMarker === oldEnd) {
28420
+ for (let block = parent; block !== null; block = block.parentBlock) {
28421
+ if (block.startMarker === void 0) continue;
28422
+ if (block.startMarker !== oldStart || block.endMarker !== oldEnd) return;
28381
28423
  journalRootProperty(block, "startMarker", block.startMarker);
28382
28424
  journalRootProperty(block, "endMarker", block.endMarker);
28383
28425
  block.startMarker = newStart;
28384
28426
  block.endMarker = newEnd;
28385
- block = block.parentBlock;
28386
28427
  }
28387
28428
  }
28388
28429
  function sharesBlockBoundary(parent, start, end) {
28430
+ while (parent !== null && parent.startMarker === void 0) parent = parent.parentBlock;
28389
28431
  return parent !== null && start !== null && end !== null && parent.startMarker === start && parent.endMarker === end;
28390
28432
  }
28391
28433
  function renderBranchSlot(parentScope, slotKey, state, domParent, next, body, marker, env, lite) {
@@ -29258,10 +29300,12 @@ function activityBlock(parentScope, slotKey, domParent, mode, body, anchor, env)
29258
29300
  }
29259
29301
  function forEachSubtreeChild(scope, visit, includeHiddenTry = true) {
29260
29302
  const children = scope.children;
29261
- if (children !== null) for (let i = 0, n = children.length; i < n; i++) visit(children[i].scope);
29262
29303
  const slots = scope._slots;
29304
+ let c = 0;
29263
29305
  if (slots !== null) {
29264
29306
  for (let i = 0, n = slots.length; i < n; i++) {
29307
+ if (children !== null)
29308
+ for (; c < children.length && children[c].at <= i; c++) visit(children[c].scope);
29265
29309
  const val = slots[i];
29266
29310
  if (val.__kind === "forBlockSlot") {
29267
29311
  for (let b = val.head; b !== null; b = b.nextSibling) visit(b);
@@ -29281,6 +29325,7 @@ function forEachSubtreeChild(scope, visit, includeHiddenTry = true) {
29281
29325
  } else if (val.lite != null) visit(val.lite);
29282
29326
  }
29283
29327
  }
29328
+ if (children !== null) for (; c < children.length; c++) visit(children[c].scope);
29284
29329
  }
29285
29330
  function detachRegisteredSubtreeRefs(scope, out, shouldDetach = true, includeHiddenTry = true, uncommitted = null, activityRefs = null) {
29286
29331
  const deoptRoot = scope.deoptNode;
@@ -29533,6 +29578,7 @@ function forBlock(parentScope, slotKey, domParent, inputItems, getKey, itemBody,
29533
29578
  tail: null,
29534
29579
  size: 0,
29535
29580
  cachedDeps: null,
29581
+ ctxEpoch: 0,
29536
29582
  emptyBlock: null,
29537
29583
  env: void 0,
29538
29584
  adopt: null,
@@ -29649,9 +29695,21 @@ function forBlock(parentScope, slotKey, domParent, inputItems, getKey, itemBody,
29649
29695
  (f & 8) !== 0,
29650
29696
  (f & 16) !== 0
29651
29697
  );
29698
+ if (pure && SKIPPED_ROW_REFRESH) SKIPPED_ROW_REFRESH(state, parentBlock);
29652
29699
  }
29653
29700
  hydration?.parkPast(state.end, parentScope);
29654
29701
  }
29702
+ function refreshSkippedRows(list, owner) {
29703
+ const epoch = (0, import_context_epoch.contextEpochNow)();
29704
+ const refresh = list.ctxEpoch !== epoch;
29705
+ if (!refresh && !owner.memoInChain) return;
29706
+ for (let item = list.head; item !== null; item = item.nextSibling) {
29707
+ if (item._slots === null && item.children === null) continue;
29708
+ if (refresh && item.$$ctxDepsEpoch !== epoch) refreshBlockForContext(item);
29709
+ if (owner.memoInChain) restampCachedContextScope(item);
29710
+ }
29711
+ list.ctxEpoch = epoch;
29712
+ }
29655
29713
  function keyedForBlock(parentScope, slotKey, domParent, items, getKey, itemBody, flags, deps, emptyBody, anchor, ownEnd, selectionBody, signalSite) {
29656
29714
  if (CURRENT_BLOCK?.pending && !CURRENT_BLOCK.crossRenderUpdate) return;
29657
29715
  const state = parentScope.slots[slotKey];
@@ -29670,6 +29728,7 @@ function keyedForBlock(parentScope, slotKey, domParent, items, getKey, itemBody,
29670
29728
  flags >>> 6,
29671
29729
  selectionBody
29672
29730
  )) {
29731
+ if (SKIPPED_ROW_REFRESH) SKIPPED_ROW_REFRESH(state, parentScope.block);
29673
29732
  return;
29674
29733
  }
29675
29734
  forBlock(
@@ -30256,7 +30315,13 @@ function reconcileKeyed(parentBlock, state, items, keySource, itemBody, pure, si
30256
30315
  record = journalForSlot(state, true);
30257
30316
  journalShape = false;
30258
30317
  }
30259
- updateSurvivor(block, newItem, newEnd, itemBody, pure, lite, indexIndependent, state.env);
30318
+ if (pure && indexIndependent && block.props === newItem && block.body === itemBody) {
30319
+ if (typeof __OCTANE_PROFILE_ENABLED__ !== "undefined" && __OCTANE_PROFILE_ENABLED__)
30320
+ (0, import_profiling.__profileCount)(import_profiling.ProfileCounter.LIST_UPDATE);
30321
+ block.itemIndex = newEnd;
30322
+ } else {
30323
+ updateSurvivor(block, newItem, newEnd, itemBody, pure, lite, indexIndependent, state.env);
30324
+ }
30260
30325
  }
30261
30326
  oldLast = block.prevSibling;
30262
30327
  newEnd--;
@@ -31006,297 +31071,6 @@ function lis(arr, n) {
31006
31071
  }
31007
31072
  return result;
31008
31073
  }
31009
- function scopeHasFragmentRef(scope) {
31010
- const fields = scope.refFields;
31011
- if (fields === null) return false;
31012
- for (let i = 0; i < fields.length; i += 3) {
31013
- if (fields[i] === "f") return true;
31014
- }
31015
- return false;
31016
- }
31017
- function coalesceHydratedRanges(rootBlock, liteRanges) {
31018
- const blockGroups = /* @__PURE__ */ new WeakMap();
31019
- const scopeGroups = /* @__PURE__ */ new WeakMap();
31020
- const ownerGroups = /* @__PURE__ */ new WeakMap();
31021
- const groups = [];
31022
- const seenBlocks = /* @__PURE__ */ new WeakSet();
31023
- const seenScopes = /* @__PURE__ */ new WeakSet();
31024
- let redundantMarkers = null;
31025
- let removalRange = null;
31026
- function canonicalGroup(group) {
31027
- let canonical = group;
31028
- while (canonical.parent !== null) canonical = canonical.parent;
31029
- while (group.parent !== null && group.parent !== canonical) {
31030
- const parent = group.parent;
31031
- group.parent = canonical;
31032
- group = parent;
31033
- }
31034
- return canonical;
31035
- }
31036
- function makeGroup(startNode, endNode, block, liteScope, owner) {
31037
- if (!isBlockOpen(startNode) || !isBlockClose(endNode) || startNode === endNode) return null;
31038
- if ((0, import_dom_binding_protocol.isBindingOpenComment)((STAGED_DOM ? STAGED_DOM.view(startNode) : startNode).data))
31039
- return null;
31040
- if ((STAGED_DOM ? STAGED_DOM.view(startNode) : startNode).parentNode === null || (STAGED_DOM ? STAGED_DOM.view(startNode) : startNode).parentNode !== (STAGED_DOM ? STAGED_DOM.view(endNode) : endNode).parentNode)
31041
- return null;
31042
- const openDepth = hydrationMarkerMultiplicity(
31043
- (STAGED_DOM ? STAGED_DOM.view(startNode) : startNode).data,
31044
- true
31045
- );
31046
- const closeDepth = hydrationMarkerMultiplicity(
31047
- (STAGED_DOM ? STAGED_DOM.view(endNode) : endNode).data,
31048
- false
31049
- );
31050
- if (openDepth === 0 || openDepth !== closeDepth) return null;
31051
- const group = {
31052
- start: startNode,
31053
- end: endNode,
31054
- depth: openDepth,
31055
- parent: null,
31056
- blocks: block === void 0 ? [] : [block],
31057
- liteScopes: liteScope === void 0 ? [] : [liteScope],
31058
- owners: owner === void 0 ? [] : [owner]
31059
- };
31060
- groups.push(group);
31061
- if (block !== void 0) blockGroups.set(block, group);
31062
- if (liteScope !== void 0) scopeGroups.set(liteScope, group);
31063
- if (owner !== void 0) ownerGroups.set(owner, group);
31064
- return group;
31065
- }
31066
- function writeMultiplicity(group) {
31067
- domNode(group.start).data = group.depth === 1 ? import_constants.HYDRATION_START : import_constants.HYDRATION_START + String(group.depth);
31068
- domNode(group.end).data = group.depth === 1 ? import_constants.HYDRATION_END : import_constants.HYDRATION_END + String(group.depth);
31069
- }
31070
- function removeRedundantMarkerRun(anchor, after) {
31071
- if (redundantMarkers === null) return;
31072
- const adjacent = after ? getNextSibling(anchor) : (STAGED_DOM ? STAGED_DOM.view(anchor) : anchor).previousSibling;
31073
- if (adjacent === null || adjacent.nodeType !== 8 || !redundantMarkers.has(adjacent)) {
31074
- return;
31075
- }
31076
- let edge = adjacent;
31077
- for (; ; ) {
31078
- const next = after ? getNextSibling(edge) : (STAGED_DOM ? STAGED_DOM.view(edge) : edge).previousSibling;
31079
- if (next === null || next.nodeType !== 8 || !redundantMarkers.has(next)) break;
31080
- edge = next;
31081
- }
31082
- if (STAGED_DOM) {
31083
- const first = after ? adjacent : edge;
31084
- const last = after ? edge : adjacent;
31085
- removeRange(first, getNextSibling(last));
31086
- return;
31087
- }
31088
- const range = removalRange ??= anchor.ownerDocument.createRange();
31089
- range.setStartBefore(after ? adjacent : edge);
31090
- range.setEndAfter(after ? edge : adjacent);
31091
- range.deleteContents();
31092
- }
31093
- function unifySharedPair(outer, inner) {
31094
- outer = canonicalGroup(outer);
31095
- inner = canonicalGroup(inner);
31096
- if (outer === inner) return outer;
31097
- outer.depth = Math.max(outer.depth, inner.depth);
31098
- inner.parent = outer;
31099
- writeMultiplicity(outer);
31100
- return outer;
31101
- }
31102
- function rangesAreExactlyNested(outer, inner) {
31103
- return domNode(outer.start).parentNode !== null && domNode(outer.start).parentNode === domNode(inner.start).parentNode && domNode(outer.end).parentNode === domNode(outer.start).parentNode && domNode(inner.end).parentNode === domNode(outer.start).parentNode && getNextSibling(outer.start) === inner.start && getNextSibling(inner.end) === outer.end;
31104
- }
31105
- function borrowGroupMembers(outer, inner) {
31106
- for (let i = 0; i < inner.blocks.length; i++) {
31107
- const block = inner.blocks[i];
31108
- block.startMarker = outer.start;
31109
- block.endMarker = outer.end;
31110
- block.exclusiveMarkers = true;
31111
- }
31112
- for (let i = 0; i < inner.liteScopes.length; i++) {
31113
- inner.liteScopes[i].block.endMarker = outer.end;
31114
- }
31115
- for (let i = 0; i < inner.owners.length; i++) {
31116
- const owner = inner.owners[i];
31117
- owner.start = outer.start;
31118
- owner.end = outer.end;
31119
- if (owner.__kind === "componentSlotSlot") {
31120
- owner.inherited = true;
31121
- } else if (owner.__kind === "childSlot") {
31122
- owner.borrowed = true;
31123
- if (owner.forSlot !== null) {
31124
- owner.forSlot.start = outer.start;
31125
- owner.forSlot.end = outer.end;
31126
- }
31127
- } else {
31128
- owner.borrowed = true;
31129
- }
31130
- }
31131
- }
31132
- function mergeExactRanges(outer, inner) {
31133
- outer = canonicalGroup(outer);
31134
- inner = canonicalGroup(inner);
31135
- if (outer === inner) return outer;
31136
- if (outer.start === inner.start && outer.end === inner.end) {
31137
- return unifySharedPair(outer, inner);
31138
- }
31139
- if (!rangesAreExactlyNested(outer, inner)) return outer;
31140
- const mergedDepth = outer.depth + inner.depth;
31141
- if (!Number.isSafeInteger(mergedDepth)) return outer;
31142
- (redundantMarkers ??= /* @__PURE__ */ new Set()).add(inner.start).add(inner.end);
31143
- outer.depth = mergedDepth;
31144
- inner.parent = outer;
31145
- writeMultiplicity(outer);
31146
- return outer;
31147
- }
31148
- function attachOwner(group, owner) {
31149
- if (group === null) return;
31150
- group = canonicalGroup(group);
31151
- if (group.owners.indexOf(owner) === -1) group.owners.push(owner);
31152
- ownerGroups.set(owner, group);
31153
- }
31154
- function isBoundaryOwner(owner) {
31155
- return (0, import_component_flags.hasComponentFlags)(owner.currentComp, import_component_flags.COMPONENT_FLAG_BOUNDARY);
31156
- }
31157
- function mayBorrowCandidate(value) {
31158
- if (value === null || typeof value !== "object") return false;
31159
- const kind = value.__kind;
31160
- if (kind === "componentSlotSlot") {
31161
- const owner = value;
31162
- return owner.block !== null && !owner.keyed && !isBoundaryOwner(owner) && !scopeHasFragmentRef(owner.block);
31163
- }
31164
- if (kind === "childSlot") {
31165
- const owner = value;
31166
- return owner.block !== null && owner.forSlot === null && owner.portal === null && !(0, import_component_flags.hasComponentFlags)(owner.currentComp, import_component_flags.COMPONENT_FLAG_BOUNDARY) && !scopeHasFragmentRef(owner.block);
31167
- }
31168
- if (kind === "ifBlockSlot" || kind === "switchBlockSlot") {
31169
- const owner = value;
31170
- return owner.block === null || !scopeHasFragmentRef(owner.block);
31171
- }
31172
- return liteRanges.has(value) && !scopeHasFragmentRef(value);
31173
- }
31174
- function mappedGroup(value) {
31175
- if (value === null || typeof value !== "object") return void 0;
31176
- const group = ownerGroups.get(value) ?? scopeGroups.get(value);
31177
- return group === void 0 ? void 0 : canonicalGroup(group);
31178
- }
31179
- function soleRangeCandidate(scope) {
31180
- let only = void 0;
31181
- let count = 0;
31182
- const slots = scope.slots;
31183
- for (let i = 0; i < slots.length; i++) {
31184
- if (slots[i] === void 0) continue;
31185
- only = slots[i];
31186
- count++;
31187
- if (count > 1) break;
31188
- }
31189
- if (count === 1 && mayBorrowCandidate(only)) {
31190
- const group = mappedGroup(only);
31191
- if (group !== void 0) return group;
31192
- }
31193
- const registered = scope._slots;
31194
- if (registered !== null && registered.length === 1 && scope.children === null && registered[0].__kind === "childSlot" && registered[0].compactable && mayBorrowCandidate(registered[0])) {
31195
- const group = ownerGroups.get(registered[0]);
31196
- return group === void 0 ? null : canonicalGroup(group);
31197
- }
31198
- return null;
31199
- }
31200
- function compactScopeRange(scope, own) {
31201
- visitScopeContents(scope);
31202
- if (own === null || scopeHasFragmentRef(scope)) return;
31203
- const candidate = soleRangeCandidate(scope);
31204
- if (candidate !== null) mergeExactRanges(own, candidate);
31205
- }
31206
- function visitBlock(block, owner) {
31207
- if (seenBlocks.has(block)) {
31208
- const existing = blockGroups.get(block) ?? null;
31209
- if (owner !== void 0) attachOwner(existing, owner);
31210
- return existing;
31211
- }
31212
- seenBlocks.add(block);
31213
- const own = makeGroup(block.startMarker, block.endMarker, block, void 0, owner);
31214
- compactScopeRange(block, own);
31215
- return blockGroups.get(block) ?? own;
31216
- }
31217
- function visitNestedScope(scope) {
31218
- if (seenScopes.has(scope)) return scopeGroups.get(scope) ?? null;
31219
- seenScopes.add(scope);
31220
- const range = liteRanges.get(scope);
31221
- const own = range === void 0 ? null : makeGroup(range.start, range.end, void 0, scope, void 0);
31222
- compactScopeRange(scope, own);
31223
- return scopeGroups.get(scope) ?? own;
31224
- }
31225
- function visitForSlot(state) {
31226
- for (let block = state.head; block !== null; block = block.nextSibling) visitBlock(block);
31227
- if (state.emptyBlock !== null) visitBlock(state.emptyBlock);
31228
- }
31229
- function visitBranchSlot(state) {
31230
- const inner = state.block === null ? null : visitBlock(state.block);
31231
- const outer = makeGroup(state.start, state.end, void 0, void 0, state);
31232
- if (outer !== null && inner !== null && !scopeHasFragmentRef(state.block)) {
31233
- mergeExactRanges(outer, inner);
31234
- }
31235
- }
31236
- function visitSlot(state, scope) {
31237
- const kind = state.__kind;
31238
- if (kind === "componentSlotSlot") {
31239
- if (state.block !== null) visitBlock(state.block, state);
31240
- return;
31241
- }
31242
- if (kind === "childSlot") {
31243
- const child2 = state;
31244
- if (child2.block !== null) visitBlock(child2.block, child2);
31245
- else if (child2.borrowed) {
31246
- const own = blockGroups.get(scope.block);
31247
- if (own !== void 0 && child2.start === own.start && child2.end === own.end)
31248
- attachOwner(own, child2);
31249
- }
31250
- if (child2.forSlot !== null) visitForSlot(child2.forSlot);
31251
- if (child2.portal?.block != null) visitBlock(child2.portal.block);
31252
- return;
31253
- }
31254
- if (kind === "ifBlockSlot" || kind === "switchBlockSlot") {
31255
- visitBranchSlot(state);
31256
- return;
31257
- }
31258
- if (kind === "forBlockSlot") {
31259
- visitForSlot(state);
31260
- return;
31261
- }
31262
- if (kind === "trySlotSlot") {
31263
- const visible = state.block;
31264
- const persistent = state.tryBlock;
31265
- if (visible !== null) visitBlock(visible);
31266
- if (persistent !== null && persistent !== visible) visitBlock(persistent);
31267
- return;
31268
- }
31269
- if (kind === "activityBlockSlot" || kind === "portalSlotSlot") {
31270
- if (state.block !== null) visitBlock(state.block);
31271
- return;
31272
- }
31273
- if (state.block != null) visitBlock(state.block);
31274
- }
31275
- function visitScopeContents(scope) {
31276
- const children = scope.children;
31277
- if (children !== null)
31278
- for (let i = 0; i < children.length; i++) visitNestedScope(children[i].scope);
31279
- const registered = scope._slots;
31280
- if (registered === null) return;
31281
- for (let i = 0; i < registered.length; i++) visitSlot(registered[i], scope);
31282
- }
31283
- visitBlock(rootBlock);
31284
- for (let i = 0; i < groups.length; i++) {
31285
- const group = groups[i];
31286
- const canonical = canonicalGroup(group);
31287
- if (group.start !== canonical.start || group.end !== canonical.end) {
31288
- borrowGroupMembers(canonical, group);
31289
- }
31290
- }
31291
- if (redundantMarkers !== null) {
31292
- for (let i = 0; i < groups.length; i++) {
31293
- const group = groups[i];
31294
- if (group.parent !== null) continue;
31295
- removeRedundantMarkerRun(group.start, true);
31296
- removeRedundantMarkerRun(group.end, false);
31297
- }
31298
- }
31299
- }
31300
31074
  function registerEnabledRootErrorHandlers(root, options) {
31301
31075
  if (options === void 0) return;
31302
31076
  const { onCaughtError, onUncaughtError, onRecoverableError } = options;
@@ -32006,7 +31780,7 @@ function hydrateRootWithOutputHandler(container, bodyOrElement, propsOrOptions,
32006
31780
  registerRootErrorHandlers = registerEnabledRootErrorHandlers;
32007
31781
  assertValidRootContainer(container);
32008
31782
  installHydrationDriver();
32009
- (0, import_early_values.installEarlyControlBridge)();
31783
+ (0, import_read_protocol.startEarlySignalHydration)(import_early_values.installEarlyControlBridge);
32010
31784
  let body;
32011
31785
  let props;
32012
31786
  let rootKey = null;
@@ -32053,17 +31827,16 @@ function hydrateRootWithOutputHandler(container, bodyOrElement, propsOrOptions,
32053
31827
  if (controlLeases !== void 0 && new Set(controlLeases.map((lease) => lease.control)).size !== controlLeases.length)
32054
31828
  throw new Error((0, import_error_codes_client_generated.formatClientError)(78));
32055
31829
  const signalOwner = rootOptions?.signalOwner ?? (import_document_owner.signalDocumentEnabled ? (0, import_document_owner.documentSignalOwner)(container) : void 0);
32056
- const initialDocumentSignals = rootOptions?.initialDocumentSignals === void 0 ? void 0 : (0, import_native_read_seeds.captureInitialDocumentSignals)(
31830
+ const initialDocumentSignals = rootOptions?.initialDocumentSignals === void 0 ? void 0 : import_read_protocol.nativeSignalHydration ? (0, import_native_read_seeds.captureInitialDocumentSignals)(
32057
31831
  rootOptions.initialDocumentSignals,
32058
31832
  (signalOwner?.documentOwner ?? signalOwner)?.scopeKey ?? "octane:document"
32059
- );
31833
+ ) : (0, import_data_encoding.snapshotSignalValue)(rootOptions.initialDocumentSignals);
32060
31834
  const nativeSidecar = findHydrateSeedSidecar(container, import_native_read_seeds.NATIVE_SIGNAL_SEED_ATTR);
32061
- const nativeManifest = nativeSidecar === null ? void 0 : (0, import_native_read_seeds.materializeNativeSignalManifest)(
32062
- (0, import_native_read_seeds.parseNativeSignalManifest)(
32063
- (STAGED_DOM ? STAGED_DOM.view(nativeSidecar) : nativeSidecar).textContent || ""
32064
- ),
31835
+ const nativeRaw = nativeSidecar === null ? void 0 : (STAGED_DOM ? STAGED_DOM.view(nativeSidecar) : nativeSidecar).textContent || "";
31836
+ const nativeManifest = nativeRaw !== void 0 && import_read_protocol.nativeSignalHydration ? (0, import_native_read_seeds.materializeNativeSignalManifest)(
31837
+ (0, import_native_read_seeds.parseNativeSignalManifest)(nativeRaw),
32065
31838
  initialDocumentSignals
32066
- );
31839
+ ) : nativeRaw;
32067
31840
  (STAGED_DOM ? STAGED_DOM.view(nativeSidecar) : nativeSidecar)?.remove();
32068
31841
  const ownerToken = claimRootContainer(container);
32069
31842
  registerDelegationTarget(container, true);
@@ -32179,15 +31952,22 @@ function hydrateRootWithOutputHandler(container, bodyOrElement, propsOrOptions,
32179
31952
  });
32180
31953
  };
32181
31954
  }
32182
- if (nativeManifest !== void 0)
32183
- hydration.nativeAdoption = ownNativeAdoption(rootBlock, nativeManifest);
32184
31955
  hydration.passthroughRoot = hydration.passthroughRanges = body[import_constants.HYDRATION_RANGE_BOUNDARY] === "passthrough";
32185
31956
  const previousHydration = currentHydration;
32186
31957
  swapHydration(hydration);
32187
- const previousNative = (0, import_read_protocol.setNativeAdoptionResolver)(hydration.nativeAdoption?.resolve ?? null);
31958
+ const previousNative = (0, import_read_protocol.setNativeAdoptionResolver)(null);
32188
31959
  let completed = false;
32189
31960
  let nativeRecovery;
32190
31961
  try {
31962
+ if (owner.initialDocumentSignals !== void 0 && import_read_protocol.nativeSignalHydration)
31963
+ owner.initialDocumentSignals = (0, import_native_read_seeds.captureInitialDocumentSignals)(
31964
+ owner.initialDocumentSignals,
31965
+ (signalOwner?.documentOwner ?? signalOwner)?.scopeKey ?? "octane:document"
31966
+ );
31967
+ if (nativeManifest !== void 0) {
31968
+ hydration.nativeAdoption = ownNativeAdoption(rootBlock, nativeManifest);
31969
+ (0, import_read_protocol.setNativeAdoptionResolver)(hydration.nativeAdoption.resolve);
31970
+ }
32191
31971
  if (firstNode?.nodeType === 8 && (STAGED_DOM ? STAGED_DOM.view(firstNode) : firstNode).data === body[BINDING_VIEW_ROOT]) {
32192
31972
  rootBlock.startMarker = firstNode;
32193
31973
  rootBlock.endMarker = hydration.close(firstNode);
@@ -32258,7 +32038,6 @@ function hydrateRootWithOutputHandler(container, bodyOrElement, propsOrOptions,
32258
32038
  return;
32259
32039
  }
32260
32040
  if (!completed) return;
32261
- if (hydration.hasAdjacentRangePair && !hydration.presentation) hydration.coalesce();
32262
32041
  owner.retry = () => {
32263
32042
  if (!rootBlock.disposed) scheduleRender(rootBlock);
32264
32043
  };
@@ -32798,6 +32577,7 @@ function scriptResource(attrs) {
32798
32577
  compilerCacheMappedArray,
32799
32578
  compilerMemoRegion,
32800
32579
  compilerMemoWitness,
32580
+ compilerOpaqueTag,
32801
32581
  compilerOwnsContextProvider,
32802
32582
  componentSlot,
32803
32583
  componentSlotLite,