octane 0.3.5 → 0.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -85,6 +85,7 @@ __export(index_exports, {
85
85
  createElement: () => import_runtime.createElement,
86
86
  createHostContextRequest: () => import_runtime.createHostContextRequest,
87
87
  createPortal: () => import_runtime.createPortal,
88
+ createResizeObserver: () => import_resize_observer.createResizeObserver,
88
89
  createRoot: () => import_runtime.createRoot,
89
90
  createScopedElement: () => import_runtime.createScopedElement,
90
91
  createScopedValue: () => import_runtime.createScopedValue,
@@ -246,6 +247,7 @@ __export(index_exports, {
246
247
  });
247
248
  module.exports = __toCommonJS(index_exports);
248
249
  var import_trusted_html = require("./trusted-html.cjs");
250
+ var import_resize_observer = require("./resize-observer.cjs");
249
251
  var import_version = require("./version.cjs");
250
252
  var import_compatibility = require("./compatibility.cjs");
251
253
  var import_event_capture = require("./hydration/event-capture.cjs");
@@ -325,6 +327,7 @@ var import_method_dep = require("./method-dep.cjs");
325
327
  createElement,
326
328
  createHostContextRequest,
327
329
  createPortal,
330
+ createResizeObserver,
328
331
  createRoot,
329
332
  createScopedElement,
330
333
  createScopedValue,
@@ -0,0 +1,129 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+ var resize_observer_exports = {};
20
+ __export(resize_observer_exports, {
21
+ createResizeObserver: () => createResizeObserver
22
+ });
23
+ module.exports = __toCommonJS(resize_observer_exports);
24
+ let queuedCallbacks = null;
25
+ let postTask;
26
+ function drainCallbacks() {
27
+ const callbacks = queuedCallbacks;
28
+ queuedCallbacks = null;
29
+ if (callbacks === null) return;
30
+ for (const callback of callbacks) {
31
+ try {
32
+ callback();
33
+ } catch (error) {
34
+ if (typeof reportError === "function") reportError(error);
35
+ else
36
+ setTimeout(() => {
37
+ throw error;
38
+ }, 0);
39
+ }
40
+ }
41
+ }
42
+ function enqueue(callback) {
43
+ if (queuedCallbacks !== null) {
44
+ queuedCallbacks.add(callback);
45
+ return;
46
+ }
47
+ queuedCallbacks = /* @__PURE__ */ new Set([callback]);
48
+ if (postTask === void 0) {
49
+ if (typeof MessageChannel === "undefined") {
50
+ postTask = () => {
51
+ setTimeout(drainCallbacks, 0);
52
+ };
53
+ } else {
54
+ const channel = new MessageChannel();
55
+ channel.port1.onmessage = drainCallbacks;
56
+ postTask = () => channel.port2.postMessage(null);
57
+ }
58
+ }
59
+ postTask();
60
+ }
61
+ function createResizeObserver(callback, ResizeObserverCtor = ResizeObserver) {
62
+ if (typeof callback !== "function")
63
+ throw new TypeError("ResizeObserver callback must be a function");
64
+ const entries = /* @__PURE__ */ new Map();
65
+ const boxes = /* @__PURE__ */ new Map();
66
+ let pending = false;
67
+ const deliver = () => {
68
+ if (!pending) return;
69
+ pending = false;
70
+ const batch = Array.from(entries.values());
71
+ entries.clear();
72
+ Reflect.apply(callback, observer, [batch, observer]);
73
+ };
74
+ const observer = new ResizeObserverCtor((batch) => {
75
+ pending = true;
76
+ for (const entry of batch) entries.set(entry.target, entry);
77
+ enqueue(deliver);
78
+ });
79
+ const observe = observer.observe;
80
+ const unobserve = observer.unobserve;
81
+ const disconnect = observer.disconnect;
82
+ const discard = (target) => {
83
+ if (entries.delete(target) && entries.size === 0) {
84
+ pending = false;
85
+ queuedCallbacks?.delete(deliver);
86
+ }
87
+ };
88
+ observer.observe = function(target, options) {
89
+ let box = "content-box";
90
+ let nativeOptions = options;
91
+ if (options !== null && (typeof options === "object" || typeof options === "function")) {
92
+ nativeOptions = {
93
+ get box() {
94
+ const value = options.box;
95
+ if (value === void 0) return void 0;
96
+ box = `${value}`;
97
+ return box;
98
+ }
99
+ };
100
+ }
101
+ observe.call(this, target, nativeOptions);
102
+ if (this !== observer) return;
103
+ if (boxes.get(target) !== box) discard(target);
104
+ boxes.set(target, box);
105
+ };
106
+ observer.unobserve = function(target) {
107
+ unobserve.call(this, target);
108
+ if (this !== observer) return;
109
+ boxes.delete(target);
110
+ discard(target);
111
+ if (boxes.size === 0 && entries.size === 0) {
112
+ pending = false;
113
+ queuedCallbacks?.delete(deliver);
114
+ }
115
+ };
116
+ observer.disconnect = function() {
117
+ disconnect.call(this);
118
+ if (this !== observer) return;
119
+ boxes.clear();
120
+ entries.clear();
121
+ pending = false;
122
+ queuedCallbacks?.delete(deliver);
123
+ };
124
+ return observer;
125
+ }
126
+ // Annotate the CommonJS export names for ESM import in node:
127
+ 0 && (module.exports = {
128
+ createResizeObserver
129
+ });
@@ -403,7 +403,6 @@ let NATIVE_BLOCK_RETRIES = null;
403
403
  let NATIVE_ADOPTION_RELEASES = null;
404
404
  let SIGNAL_BINDINGS_ENABLED = false;
405
405
  const SCOPE_SIGNAL_OWNERS = /* @__PURE__ */ new WeakMap();
406
- const SCOPE_SIGNAL_INSTANCE_KEYS = /* @__PURE__ */ new WeakMap();
407
406
  let RETAINED_SIGNAL_OWNERS;
408
407
  const SIGNAL_RETRY_LOCATIONS = /* @__PURE__ */ new WeakMap();
409
408
  function signalRetryBoundary(block) {
@@ -604,17 +603,30 @@ function rootSignalInstanceKey(ids) {
604
603
  return JSON.stringify([ids.signalState?.prefix ?? ids.prefix, "root"]);
605
604
  }
606
605
  function resolveSignalInstanceKey(scope) {
607
- const identity = SCOPE_SIGNAL_INSTANCE_KEYS.get(scope);
608
- if (identity === void 0 || typeof identity === "string") return identity;
606
+ const resolved = scope.signalInstanceResolved;
607
+ if (resolved !== void 0) return resolved;
608
+ const parent = scope.signalInstanceParent;
609
+ if (parent === null) return void 0;
609
610
  const key = structuralSignalInstanceKey(
610
- identity.parentScope,
611
- identity.invocationSite,
612
- identity.key,
613
- identity.hasKey
611
+ parent,
612
+ scope.signalInstanceSite,
613
+ scope.signalInstanceValue,
614
+ scope.signalInstanceHasKey
614
615
  );
615
- SCOPE_SIGNAL_INSTANCE_KEYS.set(scope, key);
616
+ scope.signalInstanceResolved = key;
616
617
  return key;
617
618
  }
619
+ function stampSignalInstanceKey(scope, key) {
620
+ if (typeof key === "string") {
621
+ scope.signalInstanceResolved = key;
622
+ return;
623
+ }
624
+ scope.signalInstanceParent = key.parentScope;
625
+ scope.signalInstanceSite = key.invocationSite;
626
+ scope.signalInstanceValue = key.key;
627
+ scope.signalInstanceHasKey = key.hasKey;
628
+ scope.signalInstanceResolved = void 0;
629
+ }
618
630
  function structuralSignalInstanceKey(parentScope, invocationSite, key, hasKey) {
619
631
  let base = resolveSignalInstanceKey(parentScope);
620
632
  const itemKeys = [];
@@ -645,7 +657,11 @@ function structuralSignalInstanceKey(parentScope, invocationSite, key, hasKey) {
645
657
  }
646
658
  function stampSignalInstance(scope, parentScope, invocationSite, key, hasKey) {
647
659
  if (SIGNAL_BINDINGS_ENABLED || import_document_owner.signalDocumentEnabled) {
648
- SCOPE_SIGNAL_INSTANCE_KEYS.set(scope, { parentScope, invocationSite, key, hasKey });
660
+ scope.signalInstanceParent = parentScope;
661
+ scope.signalInstanceSite = invocationSite;
662
+ scope.signalInstanceValue = key;
663
+ scope.signalInstanceHasKey = hasKey;
664
+ scope.signalInstanceResolved = void 0;
649
665
  }
650
666
  }
651
667
  function scopeSignalOwner(scope) {
@@ -6078,14 +6094,20 @@ function drainEffectEventUpdates() {
6078
6094
  for (let i = 0; i < q.length; i++) {
6079
6095
  const entry = q[i];
6080
6096
  const block = entry.block;
6081
- if (!entry.cell.active || NATIVE_READ_DRIVER?.publicationCurrent(entry) === false || blockSubtreeDisposed(block) || // Independently scheduled siblings may complete before another child
6082
- // suspends their shared boundary. That boundary hides the try
6083
- // subtree, so its completed payload is still uncommitted. Do not use the
6084
- // broader inactive check: hidden Activity renders intentionally publish
6085
- // fresh Effect Event bodies while their DOM/effects stay preserved.
6086
- findSuspenseHiddenTry(block) !== null || block.effectEventRenderVersion !== entry.renderVersion || block.effectEventCompletedVersion !== entry.renderVersion) {
6097
+ if (!entry.cell.active || NATIVE_READ_DRIVER?.publicationCurrent(entry) === false || blockSubtreeDisposed(block))
6098
+ continue;
6099
+ const hiddenOwner = findScheduledVisibilityOwner(block, true);
6100
+ if (block.renderStatus !== RENDER_VALID && hiddenOwner === null) continue;
6101
+ if (hiddenOwner !== null && hiddenOwner.__kind === "trySlotSlot") {
6102
+ const hiddenTry = hiddenOwner;
6103
+ deferHiddenRevealAction(hiddenTry, () => {
6104
+ if (entry.cell.active && !blockSubtreeDisposed(block) && block.effectEventRenderVersion === entry.renderVersion && block.effectEventCompletedVersion === entry.renderVersion)
6105
+ entry.cell.impl = entry.nextImpl;
6106
+ });
6087
6107
  continue;
6088
6108
  }
6109
+ if (block.effectEventRenderVersion !== entry.renderVersion || block.effectEventCompletedVersion !== entry.renderVersion)
6110
+ continue;
6089
6111
  entry.cell.impl = entry.nextImpl;
6090
6112
  }
6091
6113
  }
@@ -6532,6 +6554,11 @@ class BlockImpl {
6532
6554
  this.__activitySlot = void 0;
6533
6555
  this.__warmCache = void 0;
6534
6556
  this.__warmCacheEpisode = void 0;
6557
+ this.signalInstanceParent = null;
6558
+ this.signalInstanceSite = void 0;
6559
+ this.signalInstanceValue = void 0;
6560
+ this.signalInstanceHasKey = false;
6561
+ this.signalInstanceResolved = void 0;
6535
6562
  }
6536
6563
  }
6537
6564
  class ScopeImpl {
@@ -6551,6 +6578,11 @@ class ScopeImpl {
6551
6578
  this.mounted = false;
6552
6579
  this.slots = [];
6553
6580
  this.compilerMemo = null;
6581
+ this.signalInstanceParent = null;
6582
+ this.signalInstanceSite = void 0;
6583
+ this.signalInstanceValue = void 0;
6584
+ this.signalInstanceHasKey = false;
6585
+ this.signalInstanceResolved = void 0;
6554
6586
  }
6555
6587
  }
6556
6588
  function createBlock(kind, parentBlock, parentNode, startMarker, endMarker, body, props, extra, outputHandler = null) {
@@ -6695,7 +6727,8 @@ function endUrgentTransitionRender(block, render) {
6695
6727
  }
6696
6728
  function renderBlockInner(block) {
6697
6729
  if (block.renderStatus === RENDER_INVALID) block.renderStatus = RENDER_RETRYING;
6698
- if (WIP_CAPTURE !== null) recordCapturedRender(WIP_CAPTURE, block);
6730
+ if (WIP_CAPTURE !== null && WIP_CAPTURE.rootTransaction !== true)
6731
+ recordCapturedRender(WIP_CAPTURE, block);
6699
6732
  if (TRANSITION_JOURNAL !== null) {
6700
6733
  TRANSITION_JOURNAL.push(JOURNAL_RENDER, block, null, null);
6701
6734
  }
@@ -6773,7 +6806,7 @@ function renderBlockInner(block) {
6773
6806
  if (block.outputHandler !== null && (out !== void 0 || block.slots[0]?.returnedOutput === true)) {
6774
6807
  block.outputHandler(block, out ?? null);
6775
6808
  }
6776
- finishEffectRender(block);
6809
+ if (block.effectSlots !== null) finishEffectRender(block);
6777
6810
  if (!block.mounted) block.mounted = true;
6778
6811
  if (block.renderStatus === RENDER_RETRYING) block.renderStatus = RENDER_VALID;
6779
6812
  if (block.effectEventRenderVersion !== 0) {
@@ -7062,6 +7095,11 @@ class LiteBlockImpl {
7062
7095
  this.parentBlock = parentBlock;
7063
7096
  this.$$ctxValues = null;
7064
7097
  this.idState = parentBlock.idState;
7098
+ this.signalInstanceParent = null;
7099
+ this.signalInstanceSite = void 0;
7100
+ this.signalInstanceValue = void 0;
7101
+ this.signalInstanceHasKey = false;
7102
+ this.signalInstanceResolved = void 0;
7065
7103
  }
7066
7104
  }
7067
7105
  function componentSlotLite(parentScope, slotKey, host, comp, props, anchor, invocationSite) {
@@ -7130,9 +7168,14 @@ function componentSlotLite(parentScope, slotKey, host, comp, props, anchor, invo
7130
7168
  let profileThrown;
7131
7169
  const nativeToken = NATIVE_READ_DRIVER === null ? -1 : beginActiveNativeReadScope(scope);
7132
7170
  try {
7133
- if (import_document_owner.signalDocumentEnabled || scope.block.idState.renderOwner?.signalOwner !== void 0)
7134
- runWithBlockSignalOwner(scope, () => comp(props, scope, void 0));
7135
- else comp(props, scope, void 0);
7171
+ if (import_document_owner.signalDocumentEnabled || scope.block.idState.renderOwner?.signalOwner !== void 0) {
7172
+ const owner = scopeSignalOwner(scope);
7173
+ if (owner !== void 0 && (process.env.NODE_ENV === "production" || hydrateAttributeProbe === null))
7174
+ (0, import_document_owner.streamedSignalOwnerActivator)?.(owner);
7175
+ if (owner === void 0 || (0, import_owner_context.currentSignalOwner)() === owner) {
7176
+ comp(props, scope, void 0);
7177
+ } else (0, import_owner_context.runWithSignalOwner)(owner, () => comp(props, scope, void 0));
7178
+ } else comp(props, scope, void 0);
7136
7179
  if (!scope.mounted) scope.mounted = true;
7137
7180
  } catch (error) {
7138
7181
  profileDidThrow = true;
@@ -18788,7 +18831,7 @@ function componentSlotImpl(outputHandler, parentScope, slotKey, domParent, body,
18788
18831
  void 0,
18789
18832
  outputHandler
18790
18833
  );
18791
- if (signalInstanceKey !== void 0) SCOPE_SIGNAL_INSTANCE_KEYS.set(b, signalInstanceKey);
18834
+ if (signalInstanceKey !== void 0) stampSignalInstanceKey(b, signalInstanceKey);
18792
18835
  if (typeof __OCTANE_PROFILE_ENABLED__ !== "undefined" && __OCTANE_PROFILE_ENABLED__ && typeof identity === "function")
18793
18836
  profileTrackComponent(b, identity);
18794
18837
  state.block = b;
@@ -18818,7 +18861,7 @@ function componentSlotImpl(outputHandler, parentScope, slotKey, domParent, body,
18818
18861
  void 0,
18819
18862
  outputHandler
18820
18863
  );
18821
- if (signalInstanceKey !== void 0) SCOPE_SIGNAL_INSTANCE_KEYS.set(b, signalInstanceKey);
18864
+ if (signalInstanceKey !== void 0) stampSignalInstanceKey(b, signalInstanceKey);
18822
18865
  if (typeof __OCTANE_PROFILE_ENABLED__ !== "undefined" && __OCTANE_PROFILE_ENABLED__ && typeof identity === "function")
18823
18866
  profileTrackComponent(b, identity);
18824
18867
  if (state.inherited) b.exclusiveMarkers = true;
@@ -18859,7 +18902,7 @@ function renderOffscreen(parentBlock, domParent, afterNode, body, props, outputH
18859
18902
  env,
18860
18903
  outputHandler
18861
18904
  );
18862
- if (signalInstanceKey !== void 0) SCOPE_SIGNAL_INSTANCE_KEYS.set(block, signalInstanceKey);
18905
+ if (signalInstanceKey !== void 0) stampSignalInstanceKey(block, signalInstanceKey);
18863
18906
  if (retryLocation !== void 0) SIGNAL_RETRY_LOCATIONS.set(block, retryLocation);
18864
18907
  if (implicitBail) {
18865
18908
  block.$$implicitBail = true;
@@ -21216,7 +21259,7 @@ function childSlot(parentScope, slotKey, domParent, value, anchor, ownEnd, ownsH
21216
21259
  void 0,
21217
21260
  renderReturnedValue
21218
21261
  );
21219
- if (signalInstanceKey !== void 0) SCOPE_SIGNAL_INSTANCE_KEYS.set(b2, signalInstanceKey);
21262
+ if (signalInstanceKey !== void 0) stampSignalInstanceKey(b2, signalInstanceKey);
21220
21263
  preserveRootCreatedDom(b2);
21221
21264
  if (state.borrowed) b2.exclusiveMarkers = true;
21222
21265
  b2.$$implicitBail = true;
@@ -21312,7 +21355,7 @@ function childSlot(parentScope, slotKey, domParent, value, anchor, ownEnd, ownsH
21312
21355
  void 0,
21313
21356
  renderReturnedValue
21314
21357
  );
21315
- if (signalInstanceKey !== void 0) SCOPE_SIGNAL_INSTANCE_KEYS.set(b, signalInstanceKey);
21358
+ if (signalInstanceKey !== void 0) stampSignalInstanceKey(b, signalInstanceKey);
21316
21359
  if (typeof __OCTANE_PROFILE_ENABLED__ !== "undefined" && __OCTANE_PROFILE_ENABLED__ && comp !== hostElementBody)
21317
21360
  (0, import_profiling.__profileTrackComponent)(b, !isBodyFn || (0, import_profiling.__profileHasComponentMetadata)(comp) ? comp : null);
21318
21361
  if (state.borrowed) b.exclusiveMarkers = true;
@@ -22461,6 +22504,7 @@ function tryBlock(parentScope, slotKey, domParent, tryBody, catchBody, pendingBo
22461
22504
  const parentBlock = parentScope.block;
22462
22505
  const hydration = activeHydration();
22463
22506
  let state = parentScope.slots[slotKey];
22507
+ let supersedesInputs = false;
22464
22508
  if (state === void 0) {
22465
22509
  let start;
22466
22510
  let end;
@@ -22512,8 +22556,8 @@ function tryBlock(parentScope, slotKey, domParent, tryBody, catchBody, pendingBo
22512
22556
  registerSlot(parentScope, newState);
22513
22557
  state = newState;
22514
22558
  } else {
22515
- if (state.retrySignalOwners !== void 0 && (state.tryBody !== tryBody || state.env !== env && depsChanged(state.env, env)))
22516
- clearSignalRetryOwners(state);
22559
+ supersedesInputs = (state.branch === 2 || state.retrySignalOwners !== void 0) && (state.tryBody !== tryBody || state.env !== env && depsChanged(state.env, env));
22560
+ if (state.retrySignalOwners !== void 0 && supersedesInputs) clearSignalRetryOwners(state);
22517
22561
  state.tryBody = tryBody;
22518
22562
  state.catchBody = catchBody;
22519
22563
  state.pendingBody = pendingBody;
@@ -22542,7 +22586,7 @@ function tryBlock(parentScope, slotKey, domParent, tryBody, catchBody, pendingBo
22542
22586
  s.block.extra = s.env;
22543
22587
  renderBlock(s.block);
22544
22588
  } else if (s.branch === 2 && s.tryBlock && !s.tryBlock.disposed && s.hiddenDom) {
22545
- attemptHiddenReveal(s, void 0, "parent");
22589
+ attemptHiddenReveal(s, void 0, supersedesInputs ? "parent" : "update");
22546
22590
  if (s.branch === 2) refreshPendingBody(s);
22547
22591
  } else if (s.branch === 2) {
22548
22592
  mountTry(s);
@@ -22678,7 +22722,8 @@ function takeInitialSuspenseHydration(state, hydration) {
22678
22722
  state.idState = {
22679
22723
  prefix: state.parentBlock.idState.prefix + "b" + boundaryId + "-",
22680
22724
  next: 0,
22681
- renderOwner: state.parentBlock.idState.renderOwner
22725
+ renderOwner: state.parentBlock.idState.renderOwner,
22726
+ signalState: state.parentBlock.idState.signalState
22682
22727
  };
22683
22728
  return {
22684
22729
  metadata: [marker],
@@ -22800,7 +22845,7 @@ function renderInitialSuspenseHydration(state, initial) {
22800
22845
  (0, import_read_protocol.setNativeAdoptionResolver)(previousNative);
22801
22846
  WIP_CAPTURE = previousCapture;
22802
22847
  currentHydration = previousHydration;
22803
- if (previousHydration !== null) previousHydration.node = state.end;
22848
+ if (previousHydration !== null) previousHydration.node = getNextSibling(state.end);
22804
22849
  }
22805
22850
  if (!failed) {
22806
22851
  if (state.retrySignalOwners !== void 0) clearSignalRetryOwners(state);
@@ -22844,7 +22889,7 @@ function renderInitialSuspenseHydration(state, initial) {
22844
22889
  });
22845
22890
  } finally {
22846
22891
  currentHydration = outerHydration;
22847
- if (outerHydration !== null) outerHydration.node = state.end;
22892
+ if (outerHydration !== null) outerHydration.node = getNextSibling(state.end);
22848
22893
  }
22849
22894
  }
22850
22895
  function mountTry(state) {
@@ -22916,7 +22961,8 @@ function mountTry(state) {
22916
22961
  state.idState = {
22917
22962
  prefix: state.parentBlock.idState.prefix + "b" + streamedBoundaryId + "-",
22918
22963
  next: 0,
22919
- renderOwner: state.parentBlock.idState.renderOwner
22964
+ renderOwner: state.parentBlock.idState.renderOwner,
22965
+ signalState: state.parentBlock.idState.signalState
22920
22966
  };
22921
22967
  }
22922
22968
  const freshIds = takeNativeFreshArm(hydration, adoptCursor, state.end, state.idState);
@@ -23278,6 +23324,7 @@ function commitResume(state) {
23278
23324
  }
23279
23325
  function commitResumeInner(state) {
23280
23326
  if (state.parentBlock.disposed) return;
23327
+ let deferredNativeAcceptance = false;
23281
23328
  if (NATIVE_READ_DRIVER !== null && state.hiddenDom !== null) {
23282
23329
  const staged = state.stagedCapture;
23283
23330
  if (staged === null || !NATIVE_READ_DRIVER.validateCapture(staged)) {
@@ -23293,7 +23340,8 @@ function commitResumeInner(state) {
23293
23340
  }
23294
23341
  return;
23295
23342
  }
23296
- if (WIP_CAPTURE === null) acceptNativeCapture(staged, state.parentBlock.idState.renderOwner);
23343
+ if (WIP_CAPTURE === null)
23344
+ deferredNativeAcceptance = acceptNativeCapture(staged, state.parentBlock.idState.renderOwner);
23297
23345
  }
23298
23346
  const wasPending = state.branch === 2;
23299
23347
  const hiddenActivity = findHiddenActivity(state.parentBlock);
@@ -23330,7 +23378,7 @@ function commitResumeInner(state) {
23330
23378
  tryBlock2.pendingMode = null;
23331
23379
  tryBlock2.pendingDeferred = false;
23332
23380
  if (state.detachedRefs !== null) stagedCapture.refs.length = 0;
23333
- spliceOffscreenCapture(stagedCapture);
23381
+ spliceOffscreenCapture(stagedCapture, deferredNativeAcceptance);
23334
23382
  state.hasResolved = true;
23335
23383
  } else {
23336
23384
  const journalCheckpoint = armTransitionJournal(state);
@@ -23353,7 +23401,10 @@ function commitResumeInner(state) {
23353
23401
  if (NATIVE_READ_DRIVER !== null) {
23354
23402
  invalidNativeReads = !NATIVE_READ_DRIVER.validateCapture(resumeCapture);
23355
23403
  if (!invalidNativeReads && previousCapture === null)
23356
- acceptNativeCapture(resumeCapture, state.parentBlock.idState.renderOwner);
23404
+ deferredNativeAcceptance = acceptNativeCapture(
23405
+ resumeCapture,
23406
+ state.parentBlock.idState.renderOwner
23407
+ );
23357
23408
  }
23358
23409
  } catch (err) {
23359
23410
  didThrow = true;
@@ -23386,7 +23437,7 @@ function commitResumeInner(state) {
23386
23437
  refDetachQueue.splice(refDetachCheckpoint);
23387
23438
  resumeCapture.refs.length = 0;
23388
23439
  }
23389
- spliceOffscreenCapture(resumeCapture);
23440
+ spliceOffscreenCapture(resumeCapture, deferredNativeAcceptance);
23390
23441
  state.hasResolved = true;
23391
23442
  } else {
23392
23443
  try {
@@ -23657,6 +23708,7 @@ function attemptHiddenRevealInner(state, scheduledMode, reason = "update") {
23657
23708
  const retryMode = scheduledMode ?? tryBlock2.pendingMode ?? CURRENT_BLOCK?.currentRenderMode ?? "urgent";
23658
23709
  const stagesHeldTransition = retryMode === "transition" && HELD_TRANSITIONS.has(state);
23659
23710
  const hiddenCapture = createOffscreenCapture();
23711
+ let deferredNativeAcceptance = false;
23660
23712
  const previousCapture = WIP_CAPTURE;
23661
23713
  const refDetachCheckpoint = refDetachQueue.length;
23662
23714
  WIP_CAPTURE = hiddenCapture;
@@ -23717,7 +23769,10 @@ function attemptHiddenRevealInner(state, scheduledMode, reason = "update") {
23717
23769
  return;
23718
23770
  }
23719
23771
  if (WIP_CAPTURE === null)
23720
- acceptNativeCapture(hiddenCapture, state.parentBlock.idState.renderOwner);
23772
+ deferredNativeAcceptance = acceptNativeCapture(
23773
+ hiddenCapture,
23774
+ state.parentBlock.idState.renderOwner
23775
+ );
23721
23776
  }
23722
23777
  try {
23723
23778
  if (state.block !== null && state.block !== tryBlock2) {
@@ -23733,7 +23788,7 @@ function attemptHiddenRevealInner(state, scheduledMode, reason = "update") {
23733
23788
  setTryBranch(state, 1);
23734
23789
  state.hasResolved = true;
23735
23790
  state.pendingThenable = null;
23736
- spliceOffscreenCapture(hiddenCapture);
23791
+ spliceOffscreenCapture(hiddenCapture, deferredNativeAcceptance);
23737
23792
  recordSuspenseCommit(state);
23738
23793
  publishHiddenRevealActions(state);
23739
23794
  queueCurrentHiddenRefs(state);
@@ -28075,8 +28130,43 @@ function hydrateRootWithOutputHandler(container, bodyOrElement, propsOrOptions,
28075
28130
  }
28076
28131
  function createIndependentHydrateActivator(body) {
28077
28132
  return (context) => {
28133
+ const { captures, element, manifest, signalOwner } = context;
28134
+ let intents = context.intents.length === 0 ? null : context.intents;
28135
+ const notify = intents === null ? null : (scope) => {
28136
+ if (intents === null || scope.block.disposed) return;
28137
+ const retryBatch = suspenseRetryBatchForSubtree(scope.block);
28138
+ if (retryBatch !== null) {
28139
+ const effect = scope.effectSlots.find((entry) => entry.connectedFn === notify);
28140
+ (retryBatch.afterCommit ??= []).push(() => {
28141
+ if (intents === null || scope.block.disposed || !effect.active) return;
28142
+ effectQueues[PASSIVE].push({
28143
+ scope,
28144
+ slot: effect.slot,
28145
+ fn: effect.connectedFn,
28146
+ order: effect.order,
28147
+ revision: effect.revision,
28148
+ args: effect.connectedArgs,
28149
+ phase: PASSIVE,
28150
+ seq: commitSeq++
28151
+ });
28152
+ if (!passiveScheduled) schedulePassiveFlush();
28153
+ });
28154
+ return;
28155
+ }
28156
+ const replays = intents;
28157
+ intents = null;
28158
+ for (const replay of replays) {
28159
+ if (!(0, import_event_capture.isHydrationSelectionIntentCurrent)(replay)) continue;
28160
+ const originalTarget = replay.event.target;
28161
+ if (originalTarget === null || originalTarget.nodeType !== 1 || !element.contains(originalTarget))
28162
+ continue;
28163
+ const target = originalTarget;
28164
+ target.dispatchEvent(cloneHydrationReplayEvent(replay.event, target));
28165
+ }
28166
+ };
28078
28167
  const content = (_props, scope, extra) => {
28079
- body(context.captures, scope, extra);
28168
+ body(captures, scope, extra);
28169
+ if (notify !== null) useEffect(notify, [scope], HYDRATE_NOTIFY_SLOT);
28080
28170
  };
28081
28171
  const framed = (_props, scope) => {
28082
28172
  tryBlock(scope, 0, scope.block.parentNode, content, null, null, scope.block.endMarker);
@@ -28084,19 +28174,18 @@ function createIndependentHydrateActivator(body) {
28084
28174
  const adapter = (_props, scope) => {
28085
28175
  componentSlotVoid(scope, 0, scope.block.parentNode, framed, void 0, scope.block.endMarker);
28086
28176
  };
28087
- const root = hydrateRoot(context.element, adapter, context.captures, {
28088
- identifierPrefix: context.manifest.boundaryId + "-",
28089
- identifierSeed: context.manifest.idSeed,
28090
- signalInstancePrefix: context.manifest.boundaryId,
28091
- ...context.signalOwner === void 0 ? {} : { signalOwner: context.signalOwner }
28177
+ const root = hydrateRoot(element, adapter, captures, {
28178
+ identifierPrefix: manifest.boundaryId + "-",
28179
+ identifierSeed: manifest.idSeed,
28180
+ signalInstancePrefix: manifest.boundaryId,
28181
+ ...signalOwner === void 0 ? {} : { signalOwner }
28092
28182
  });
28093
- for (const replay of context.intents) {
28094
- if (!(0, import_event_capture.isHydrationSelectionIntentCurrent)(replay)) continue;
28095
- const originalTarget = replay.event.target;
28096
- if (originalTarget === null || originalTarget.nodeType !== 1 || !context.element.contains(originalTarget))
28097
- continue;
28098
- const target = originalTarget;
28099
- target.dispatchEvent(cloneHydrationReplayEvent(replay.event, target));
28183
+ if (notify !== null) {
28184
+ const unmount = root.unmount;
28185
+ root.unmount = () => {
28186
+ intents = null;
28187
+ unmount();
28188
+ };
28100
28189
  }
28101
28190
  return root;
28102
28191
  };
@@ -42,6 +42,7 @@ __export(server_exports, {
42
42
  createContext: () => import_runtime_server.createContext,
43
43
  createElement: () => import_runtime_server.createElement,
44
44
  createPortal: () => import_runtime_server.createPortal,
45
+ createResizeObserver: () => import_resize_observer.createResizeObserver,
45
46
  createScopedElement: () => import_runtime_server.createScopedElement,
46
47
  createScopedValue: () => import_runtime_server.createScopedValue,
47
48
  createStreamedRegionPlacementFrame: () => import_streamed_region.createStreamedRegionPlacementFrame,
@@ -180,6 +181,7 @@ __export(server_exports, {
180
181
  });
181
182
  module.exports = __toCommonJS(server_exports);
182
183
  var import_trusted_html = require("../trusted-html.cjs");
184
+ var import_resize_observer = require("../resize-observer.cjs");
183
185
  var import_rpc = require("./rpc.cjs");
184
186
  var import_early_signals = require("./early-signals.cjs");
185
187
  var import_rpc_batch = require("./rpc-batch.cjs");
@@ -218,6 +220,7 @@ var import_runtime_server = require("../runtime.server.cjs");
218
220
  createContext,
219
221
  createElement,
220
222
  createPortal,
223
+ createResizeObserver,
221
224
  createScopedElement,
222
225
  createScopedValue,
223
226
  createStreamedRegionPlacementFrame,
@@ -537,6 +537,7 @@ function evaluate(node) {
537
537
  node.flags = ReactiveFlags.Mutable | ReactiveFlags.Watching;
538
538
  return true;
539
539
  }
540
+ if (historicalReader || (0, import_read_protocol.getNativeAdoptionResolver)()) return evaluateLiveNode(node);
540
541
  const previousNode = activeNode;
541
542
  const previousOwners = activeOwners;
542
543
  const previousObserver = (0, import_read_protocol.setNativeReadObserver)(null);
@@ -579,6 +580,16 @@ function evaluate(node) {
579
580
  commitState(node, next);
580
581
  return true;
581
582
  }
583
+ function evaluateLiveNode(node) {
584
+ const previousReader = setHistoricalReader(void 0);
585
+ const previousAdoption = (0, import_read_protocol.setNativeAdoptionResolver)(null);
586
+ try {
587
+ return evaluate(node);
588
+ } finally {
589
+ (0, import_read_protocol.setNativeAdoptionResolver)(previousAdoption);
590
+ setHistoricalReader(previousReader);
591
+ }
592
+ }
582
593
  function commitState(node, next) {
583
594
  const previous = node.state;
584
595
  node.state = next;
@@ -21,7 +21,7 @@ __export(version_exports, {
21
21
  version: () => version
22
22
  });
23
23
  module.exports = __toCommonJS(version_exports);
24
- const version = "0.3.5";
24
+ const version = "0.4.0";
25
25
  // Annotate the CommonJS export names for ESM import in node:
26
26
  0 && (module.exports = {
27
27
  version