octane 0.2.11 → 0.2.13

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 (264) hide show
  1. package/README.md +5 -0
  2. package/dist/behavior-root.d.ts +13 -3
  3. package/dist/behavior-root.js +28 -5
  4. package/dist/cjs/behavior-root.cjs +32 -6
  5. package/dist/cjs/class-names.cjs +49 -0
  6. package/dist/cjs/constants.cjs +9 -0
  7. package/dist/cjs/context-epoch.cjs +38 -0
  8. package/dist/cjs/css.cjs +6 -27
  9. package/dist/cjs/data-encoding.cjs +160 -0
  10. package/dist/cjs/dom-binding-handoff.cjs +93 -0
  11. package/dist/cjs/dom-binding-protocol.cjs +115 -0
  12. package/dist/cjs/dom-binding-styles.cjs +292 -0
  13. package/dist/cjs/dom-bindings.cjs +700 -0
  14. package/dist/cjs/dom-focused-move.cjs +66 -0
  15. package/dist/cjs/dom-stage.cjs +896 -0
  16. package/dist/cjs/dom-tables.cjs +4 -94
  17. package/dist/cjs/error-codes.client.generated.cjs +33 -0
  18. package/dist/cjs/error-codes.server.generated.cjs +24 -0
  19. package/dist/cjs/hydration/control-capture.cjs +244 -0
  20. package/dist/cjs/hydration/event-capture.cjs +125 -43
  21. package/dist/cjs/hydration/interaction-config.cjs +50 -2
  22. package/dist/cjs/hydration-markers.cjs +37 -0
  23. package/dist/cjs/independent-hydration-protocol.cjs +106 -0
  24. package/dist/cjs/index.cjs +9 -0
  25. package/dist/cjs/runtime.cjs +6397 -1683
  26. package/dist/cjs/runtime.server.cjs +1465 -213
  27. package/dist/cjs/server/early-signals.cjs +45 -0
  28. package/dist/cjs/server/index.cjs +47 -0
  29. package/dist/cjs/server/rpc-batch.cjs +149 -0
  30. package/dist/cjs/server/rpc-stream.cjs +146 -0
  31. package/dist/cjs/server/rpc.cjs +34 -15
  32. package/dist/cjs/server/signal-query-observation.cjs +158 -0
  33. package/dist/cjs/server/streamed-region.cjs +52 -0
  34. package/dist/cjs/server/streamed-signals.cjs +512 -0
  35. package/dist/cjs/server-call.cjs +103 -0
  36. package/dist/cjs/server-rpc-batch-client.cjs +141 -0
  37. package/dist/cjs/server-rpc-client.cjs +94 -27
  38. package/dist/cjs/server-rpc-protocol.cjs +141 -0
  39. package/dist/cjs/server-rpc-stream-client.cjs +118 -0
  40. package/dist/cjs/signals/actions.cjs +474 -0
  41. package/dist/cjs/signals/client.cjs +4 -1
  42. package/dist/cjs/signals/computations.cjs +460 -0
  43. package/dist/cjs/signals/control-binding.cjs +368 -0
  44. package/dist/cjs/signals/derived-facade.cjs +50 -0
  45. package/dist/cjs/signals/document-owner.cjs +71 -0
  46. package/dist/cjs/signals/early-values.cjs +155 -0
  47. package/dist/cjs/signals/encoding.cjs +6 -95
  48. package/dist/cjs/signals/engine.cjs +276 -12
  49. package/dist/cjs/signals/errors.cjs +18 -0
  50. package/dist/cjs/signals/facade.cjs +477 -0
  51. package/dist/cjs/signals/graph.cjs +166 -20
  52. package/dist/cjs/signals/handle-protocol.cjs +36 -0
  53. package/dist/cjs/signals/index.cjs +81 -2
  54. package/dist/cjs/signals/native-read-client.cjs +10 -0
  55. package/dist/cjs/signals/owner-context.cjs +112 -0
  56. package/dist/cjs/signals/query-attempt-observer.cjs +68 -0
  57. package/dist/cjs/signals/query-facade.cjs +72 -0
  58. package/dist/cjs/signals/read-protocol.cjs +54 -0
  59. package/dist/cjs/signals/requests.cjs +287 -14
  60. package/dist/cjs/signals/scalar-computations.cjs +76 -0
  61. package/dist/cjs/signals/server.cjs +4 -1
  62. package/dist/cjs/signals/transition-candidate.cjs +567 -0
  63. package/dist/cjs/signals/transition-state.cjs +106 -0
  64. package/dist/cjs/signals/types.cjs +50 -0
  65. package/dist/cjs/stream-protocol.cjs +3 -0
  66. package/dist/cjs/streamed-signals-protocol.cjs +159 -0
  67. package/dist/cjs/style-values.cjs +122 -0
  68. package/dist/cjs/trusted-html.cjs +30 -0
  69. package/dist/cjs/version.cjs +1 -1
  70. package/dist/class-names.d.ts +5 -0
  71. package/dist/class-names.js +25 -0
  72. package/dist/compiler/bundler.js +51 -22
  73. package/dist/compiler/compile.js +2534 -581
  74. package/dist/compiler/dom-binding-program.js +935 -0
  75. package/dist/compiler/dom-binding-request.js +57 -0
  76. package/dist/compiler/dom-bindings.js +2245 -0
  77. package/dist/compiler/hook-deps.js +759 -10
  78. package/dist/compiler/hydrate-boundaries.js +358 -15
  79. package/dist/compiler/index.d.ts +39 -2
  80. package/dist/compiler/index.js +1 -0
  81. package/dist/compiler/native-attribute-reads.js +127 -0
  82. package/dist/compiler/native-change-diagnostics.js +32 -38
  83. package/dist/compiler/native-read-diagnostics.js +69 -8
  84. package/dist/compiler/native-read-types.js +80 -34
  85. package/dist/compiler/parser.node.js +1 -1
  86. package/dist/compiler/renderer-boundaries.js +40 -0
  87. package/dist/compiler/server-context.js +118 -0
  88. package/dist/compiler/signal-attempt-reads.js +479 -0
  89. package/dist/compiler/signal-declarations.js +557 -0
  90. package/dist/compiler/signal-start-reads.js +413 -0
  91. package/dist/compiler/slot-hooks.d.ts +3 -1
  92. package/dist/compiler/slot-hooks.js +168 -34
  93. package/dist/compiler/strong-auto-memo.js +90 -0
  94. package/dist/compiler/strong-html.js +143 -0
  95. package/dist/compiler/strong-mode.js +764 -66
  96. package/dist/compiler/strong-template-policy.js +307 -0
  97. package/dist/compiler/template-ir.js +200 -0
  98. package/dist/compiler/typescript.d.ts +2 -0
  99. package/dist/compiler/typescript.js +2 -0
  100. package/dist/compiler/vite.d.ts +3 -1
  101. package/dist/compiler/vite.js +122 -4
  102. package/dist/compiler/volar.LICENSES.txt +1 -1
  103. package/dist/compiler/volar.d.ts +6 -1
  104. package/dist/compiler/volar.js +750 -1433
  105. package/dist/constants.d.ts +1 -0
  106. package/dist/constants.js +10 -0
  107. package/dist/context-epoch.d.ts +2 -0
  108. package/dist/context-epoch.js +13 -0
  109. package/dist/css.d.ts +2 -5
  110. package/dist/css.js +2 -23
  111. package/dist/data-encoding.d.ts +9 -0
  112. package/dist/data-encoding.js +134 -0
  113. package/dist/dom-binding-classes.d.ts +15 -0
  114. package/dist/dom-binding-classes.js +129 -0
  115. package/dist/dom-binding-controls.d.ts +2 -0
  116. package/dist/dom-binding-controls.js +6 -0
  117. package/dist/dom-binding-handoff.d.ts +55 -0
  118. package/dist/dom-binding-handoff.js +62 -0
  119. package/dist/dom-binding-program.d.ts +300 -0
  120. package/dist/dom-binding-program.js +1625 -0
  121. package/dist/dom-binding-projections.d.ts +15 -0
  122. package/dist/dom-binding-projections.js +187 -0
  123. package/dist/dom-binding-protocol.d.ts +13 -0
  124. package/dist/dom-binding-protocol.js +88 -0
  125. package/dist/dom-binding-signals.d.ts +21 -0
  126. package/dist/dom-binding-signals.js +109 -0
  127. package/dist/dom-binding-styles.d.ts +17 -0
  128. package/dist/dom-binding-styles.js +272 -0
  129. package/dist/dom-bindings.d.ts +89 -0
  130. package/dist/dom-bindings.js +670 -0
  131. package/dist/dom-focused-move.d.ts +6 -0
  132. package/dist/dom-focused-move.js +42 -0
  133. package/dist/dom-stage.d.ts +52 -0
  134. package/dist/dom-stage.js +872 -0
  135. package/dist/dom-tables.d.ts +1 -3
  136. package/dist/dom-tables.js +1 -91
  137. package/dist/error-codes.client.generated.d.ts +9 -0
  138. package/dist/error-codes.client.generated.js +33 -0
  139. package/dist/error-codes.server.generated.d.ts +6 -0
  140. package/dist/error-codes.server.generated.js +24 -0
  141. package/dist/hydration/control-capture.d.ts +62 -0
  142. package/dist/hydration/control-capture.js +223 -0
  143. package/dist/hydration/document-lifecycle.d.ts +23 -0
  144. package/dist/hydration/document-lifecycle.js +80 -0
  145. package/dist/hydration/event-capture.d.ts +20 -1
  146. package/dist/hydration/event-capture.js +128 -42
  147. package/dist/hydration/independent-island.d.ts +45 -0
  148. package/dist/hydration/independent-island.js +233 -0
  149. package/dist/hydration/index.d.ts +8 -1
  150. package/dist/hydration/index.js +55 -1
  151. package/dist/hydration/interaction-config.d.ts +5 -0
  152. package/dist/hydration/interaction-config.js +44 -1
  153. package/dist/hydration/stream-delivery.d.ts +32 -0
  154. package/dist/hydration/stream-delivery.js +333 -0
  155. package/dist/hydration/stream-receiver.d.ts +26 -0
  156. package/dist/hydration/stream-receiver.js +204 -0
  157. package/dist/hydration/stream-result-receiver.d.ts +70 -0
  158. package/dist/hydration/stream-result-receiver.js +246 -0
  159. package/dist/hydration/streamed-signals.d.ts +44 -0
  160. package/dist/hydration/streamed-signals.js +186 -0
  161. package/dist/hydration/types.d.ts +6 -0
  162. package/dist/hydration-markers.d.ts +7 -0
  163. package/dist/hydration-markers.js +10 -0
  164. package/dist/independent-hydration-protocol.d.ts +31 -0
  165. package/dist/independent-hydration-protocol.js +80 -0
  166. package/dist/index.d.ts +3 -0
  167. package/dist/index.js +6 -0
  168. package/dist/internal/signal-read.d.ts +1 -0
  169. package/dist/internal/signal-read.js +4 -0
  170. package/dist/jsx-runtime-strong.d.ts +33 -0
  171. package/dist/jsx-runtime.d.ts +58 -2
  172. package/dist/public-types.d.ts +15 -1
  173. package/dist/runtime.d.ts +297 -23
  174. package/dist/runtime.js +6405 -1679
  175. package/dist/runtime.server.d.ts +110 -27
  176. package/dist/runtime.server.js +1458 -213
  177. package/dist/server/early-signals.d.ts +14 -0
  178. package/dist/server/early-signals.js +34 -0
  179. package/dist/server/index.d.ts +11 -2
  180. package/dist/server/index.js +50 -1
  181. package/dist/server/rpc-batch.d.ts +17 -0
  182. package/dist/server/rpc-batch.js +129 -0
  183. package/dist/server/rpc-stream.d.ts +9 -0
  184. package/dist/server/rpc-stream.js +125 -0
  185. package/dist/server/rpc.d.ts +5 -1
  186. package/dist/server/rpc.js +37 -13
  187. package/dist/server/signal-query-observation.d.ts +3 -0
  188. package/dist/server/signal-query-observation.js +134 -0
  189. package/dist/server/streamed-region.d.ts +15 -0
  190. package/dist/server/streamed-region.js +30 -0
  191. package/dist/server/streamed-signals.d.ts +45 -0
  192. package/dist/server/streamed-signals.js +488 -0
  193. package/dist/server-call.d.ts +41 -0
  194. package/dist/server-call.js +75 -0
  195. package/dist/server-rpc-batch-client.d.ts +7 -0
  196. package/dist/server-rpc-batch-client.js +119 -0
  197. package/dist/server-rpc-client.d.ts +3 -1
  198. package/dist/server-rpc-client.js +99 -27
  199. package/dist/server-rpc-protocol.d.ts +47 -0
  200. package/dist/server-rpc-protocol.js +109 -0
  201. package/dist/server-rpc-stream-client.d.ts +5 -0
  202. package/dist/server-rpc-stream-client.js +98 -0
  203. package/dist/signals/actions.d.ts +12 -0
  204. package/dist/signals/actions.js +466 -0
  205. package/dist/signals/client.d.ts +2 -0
  206. package/dist/signals/client.js +1 -0
  207. package/dist/signals/computations.d.ts +37 -0
  208. package/dist/signals/computations.js +455 -0
  209. package/dist/signals/control-binding.d.ts +31 -0
  210. package/dist/signals/control-binding.js +353 -0
  211. package/dist/signals/derived-facade.d.ts +3 -0
  212. package/dist/signals/derived-facade.js +25 -0
  213. package/dist/signals/document-owner.d.ts +10 -0
  214. package/dist/signals/document-owner.js +43 -0
  215. package/dist/signals/early-values.d.ts +24 -0
  216. package/dist/signals/early-values.js +124 -0
  217. package/dist/signals/encoding.d.ts +1 -3
  218. package/dist/signals/encoding.js +3 -93
  219. package/dist/signals/engine.d.ts +53 -4
  220. package/dist/signals/engine.js +275 -16
  221. package/dist/signals/errors.d.ts +7 -0
  222. package/dist/signals/errors.js +16 -0
  223. package/dist/signals/facade.d.ts +74 -0
  224. package/dist/signals/facade.js +452 -0
  225. package/dist/signals/graph.d.ts +52 -6
  226. package/dist/signals/graph.js +174 -19
  227. package/dist/signals/handle-protocol.d.ts +4 -0
  228. package/dist/signals/handle-protocol.js +11 -0
  229. package/dist/signals/index.d.ts +12 -3
  230. package/dist/signals/index.js +71 -2
  231. package/dist/signals/native-read-client.d.ts +3 -0
  232. package/dist/signals/native-read-client.js +10 -0
  233. package/dist/signals/owner-context.d.ts +22 -0
  234. package/dist/signals/owner-context.js +77 -0
  235. package/dist/signals/query-attempt-observer.d.ts +49 -0
  236. package/dist/signals/query-attempt-observer.js +41 -0
  237. package/dist/signals/query-facade.d.ts +3 -0
  238. package/dist/signals/query-facade.js +49 -0
  239. package/dist/signals/read-protocol.d.ts +37 -2
  240. package/dist/signals/read-protocol.js +44 -0
  241. package/dist/signals/requests.d.ts +38 -5
  242. package/dist/signals/requests.js +298 -15
  243. package/dist/signals/scalar-computations.d.ts +2 -0
  244. package/dist/signals/scalar-computations.js +60 -0
  245. package/dist/signals/server.d.ts +2 -0
  246. package/dist/signals/server.js +1 -0
  247. package/dist/signals/transition-candidate.d.ts +71 -0
  248. package/dist/signals/transition-candidate.js +557 -0
  249. package/dist/signals/transition-state.d.ts +51 -0
  250. package/dist/signals/transition-state.js +70 -0
  251. package/dist/signals/types.d.ts +95 -5
  252. package/dist/signals/types.js +20 -0
  253. package/dist/stream-protocol.d.ts +0 -5
  254. package/dist/stream-protocol.js +3 -0
  255. package/dist/streamed-signals-protocol.d.ts +60 -0
  256. package/dist/streamed-signals-protocol.js +130 -0
  257. package/dist/style-values.d.ts +3 -0
  258. package/dist/style-values.js +96 -0
  259. package/dist/trusted-html.d.ts +17 -0
  260. package/dist/trusted-html.js +6 -0
  261. package/dist/universal-core.d.ts +6 -0
  262. package/dist/universal-core.js +214 -202
  263. package/dist/version.js +1 -1
  264. package/package.json +48 -5
@@ -1,4 +1,7 @@
1
+ import { trustHTML } from "./trusted-html.js";
2
+ import { readNativeDomStyle, readNativeDomProps } from "./signals/read-protocol.js";
1
3
  import { resolveHookPath } from "./hook-slot-cache.js";
4
+ import { encodeBindingKey, isBindingOpenComment } from "./dom-binding-protocol.js";
2
5
  import {
3
6
  BLOCK_OPEN,
4
7
  BLOCK_CLOSE,
@@ -20,6 +23,9 @@ import {
20
23
  HYDRATE_ID_COUNT_ATTR,
21
24
  HYDRATE_STREAM_TOKEN_ATTR,
22
25
  HYDRATE_SEED_ATTR,
26
+ INDEPENDENT_HYDRATE_MANIFEST_ATTR,
27
+ HYDRATE_INDEPENDENT_ATTR,
28
+ SIGNAL_CONTROL_ATTR,
23
29
  STREAM_BOUNDARY_ATTR,
24
30
  STREAM_SEGMENT_ATTR,
25
31
  STREAM_SEED_ATTR,
@@ -36,6 +42,10 @@ import {
36
42
  SVG_ONLY_TAGS,
37
43
  VOID_ELEMENTS
38
44
  } from "./constants.js";
45
+ import {
46
+ createIndependentHydrateManifest,
47
+ serializeIndependentHydrateManifest
48
+ } from "./independent-hydration-protocol.js";
39
49
  import { hasOwnProp } from "./has-own.js";
40
50
  import { headOwnershipSuffix } from "./head-ownership.js";
41
51
  import { resourceHintWarning } from "./resource-hint-diagnostics.js";
@@ -52,6 +62,7 @@ import {
52
62
  invalidHostPropertiesWarning,
53
63
  unsupportedAttributeCoercionWarning
54
64
  } from "./host-property-diagnostics.js";
65
+ import { streamedSignalBootstrapJs } from "./server/early-signals.js";
55
66
  import {
56
67
  applyElementDefaultProps,
57
68
  childElementKey,
@@ -89,6 +100,76 @@ import {
89
100
  NATIVE_SIGNAL_FRESH_COMMENT,
90
101
  mergeNativeSeedReads
91
102
  } from "./signals/native-read-seeds.js";
103
+ import {
104
+ captureSignalOwner,
105
+ currentSignalOwner,
106
+ enterSynchronousSignalOwner,
107
+ retireSignalOwnerIdentity,
108
+ restoreSynchronousSignalOwner,
109
+ runWithSignalOwner
110
+ } from "./signals/owner-context.js";
111
+ import {
112
+ runWithServerSignalQueryAttemptObserver
113
+ } from "./signals/query-attempt-observer.js";
114
+ import {
115
+ SIGNAL_BINDING_IDENTITY,
116
+ SIGNAL_HANDLE
117
+ } from "./signals/types.js";
118
+ function isSignalHandle(value) {
119
+ return (typeof value === "object" || typeof value === "function") && value !== null && value[SIGNAL_HANDLE] === true;
120
+ }
121
+ function readSignalBinding(handle) {
122
+ if (RESOLVED !== null && !SERVER_SIGNAL_OWNER_ACTIVE) {
123
+ return withServerSignalBinding(() => handle.get());
124
+ }
125
+ return handle.get();
126
+ }
127
+ function withServerSignalBinding(read) {
128
+ ensureServerSignalOwner();
129
+ const owner = serverSignalOwner(FRAME);
130
+ const injection = RESOLVED.resourceOptions?.injection;
131
+ return runWithSignalOwner(
132
+ owner,
133
+ () => injection?.observeSignalAttempt === void 0 ? read() : runWithServerSignalQueryAttemptObserver(
134
+ owner,
135
+ (attempt) => injection.observeSignalAttempt(attempt, captureSignalOwner(owner)),
136
+ injection.createSignalAttemptObservations,
137
+ read
138
+ )
139
+ );
140
+ }
141
+ function isWritableSignal(value) {
142
+ return isSignalHandle(value) && value.kind === "signal" && typeof value.set === "function";
143
+ }
144
+ function ssrSignalValue(value) {
145
+ return isSignalHandle(value) ? readSignalBinding(value) : value;
146
+ }
147
+ const SSR_SIGNAL_CONTROL = /* @__PURE__ */ Symbol("octane.ssr-signal-control");
148
+ function isSsrSignalControlValue(value) {
149
+ return typeof value === "object" && value !== null && value[SSR_SIGNAL_CONTROL] === true;
150
+ }
151
+ function unwrapSsrSignalControlValue(value) {
152
+ return isSsrSignalControlValue(value) ? value.value : value;
153
+ }
154
+ function ssrSignalControlValue(value, site) {
155
+ if (!isWritableSignal(value)) return ssrSignalValue(value);
156
+ if (RESOLVED !== null && !SERVER_SIGNAL_OWNER_ACTIVE) {
157
+ return withServerSignalBinding(() => serverSignalControlValue(value, site));
158
+ }
159
+ return serverSignalControlValue(value, site);
160
+ }
161
+ function serverSignalControlValue(value, site) {
162
+ const owner = currentSignalOwner();
163
+ if (owner === null || !("documentOwner" in owner)) return value.get();
164
+ if (RESOLVED !== null) RESOLVED.hasSignalControls = true;
165
+ return {
166
+ [SSR_SIGNAL_CONTROL]: true,
167
+ value: value.get(),
168
+ site,
169
+ owner,
170
+ binding: value[SIGNAL_BINDING_IDENTITY]()
171
+ };
172
+ }
92
173
  const NATIVE_ARRAY_MAP = Array.prototype.map;
93
174
  const NATIVE_REFLECT_APPLY = Reflect.apply;
94
175
  const NATIVE_ARRAY_SPECIES_GETTER = Object.getOwnPropertyDescriptor(Array, Symbol.species)?.get;
@@ -182,6 +263,17 @@ const ACTIVE_PU_WARM_PLANS = [];
182
263
  let CURRENT_PU_WARM_CLAIMS = null;
183
264
  let ID_COUNTER = 0;
184
265
  let ID_PREFIX = "";
266
+ let SIGNAL_INSTANCE_PREFIX = "";
267
+ let SIGNAL_COMPONENT_INSTANCE_KEY = "";
268
+ let SERVER_SIGNAL_OWNER_ACTIVE = false;
269
+ let SIGNAL_CONTROL_SITE = "";
270
+ const EMPTY_SIGNAL_LIST_KEYS = [];
271
+ let SIGNAL_LIST_KEYS = EMPTY_SIGNAL_LIST_KEYS;
272
+ function newStyleCollector() {
273
+ const collector = /* @__PURE__ */ new Map();
274
+ collector.replay = null;
275
+ return collector;
276
+ }
185
277
  let CSS = null;
186
278
  let NONCE_ATTR = "";
187
279
  let MARKERS = true;
@@ -252,13 +344,20 @@ function nextScopedCount(frame, slot, key) {
252
344
  counts.push(key, 1);
253
345
  return 0;
254
346
  }
347
+ function scopeSuffix(frame) {
348
+ const scope = ASYNC_SCOPE;
349
+ if (process.env.NODE_ENV !== "production" && !scope.startsWith(frame.asyncScope)) {
350
+ throw new Error(formatServerError(65));
351
+ }
352
+ return scope.slice(frame.asyncScope.length);
353
+ }
255
354
  function nextFrameOccurrence(frame, base) {
256
- const scopedBase = ASYNC_SCOPE === frame.asyncScope ? base : ASYNC_SCOPE + "\0" + base;
355
+ const scopedBase = ASYNC_SCOPE === frame.asyncScope ? base : scopeSuffix(frame) + "\0" + base;
257
356
  return nextScopedCount(frame, "occ", scopedBase);
258
357
  }
259
358
  function nextChildSegment(frame) {
260
359
  if (ASYNC_SCOPE === frame.asyncScope) return frame.nextChild++;
261
- return nextScopedCount(frame, "scopedChildren", ASYNC_SCOPE);
360
+ return nextScopedCount(frame, "scopedChildren", scopeSuffix(frame));
262
361
  }
263
362
  function ssrScope(parent) {
264
363
  return { parent, $$ctxValues: null };
@@ -392,6 +491,13 @@ const SCOPED_VALUE_PROPERTIES = {
392
491
  get() {
393
492
  return this[SCOPED_VALUE_RESOLVER]().children;
394
493
  }
494
+ },
495
+ __octaneInvocationSite: {
496
+ configurable: true,
497
+ enumerable: false,
498
+ get() {
499
+ return this[SCOPED_VALUE_RESOLVER]().__octaneInvocationSite;
500
+ }
395
501
  }
396
502
  };
397
503
  function restoreWritableScopedChildren(props, name, value) {
@@ -547,10 +653,15 @@ function scopedValueDescriptor(resolve) {
547
653
  Object.defineProperty(descriptor, "key", SCOPED_VALUE_PROPERTIES.key);
548
654
  Object.defineProperty(descriptor, "ref", SCOPED_VALUE_PROPERTIES.ref);
549
655
  Object.defineProperty(descriptor, "children", SCOPED_VALUE_PROPERTIES.children);
656
+ Object.defineProperty(
657
+ descriptor,
658
+ "__octaneInvocationSite",
659
+ SCOPED_VALUE_PROPERTIES.__octaneInvocationSite
660
+ );
550
661
  if (process.env.NODE_ENV !== "production") Object.freeze(descriptor);
551
662
  return descriptor;
552
663
  }
553
- function createScopedElement(type, props, readChildren) {
664
+ function createScopedElement(type, props, readChildren, invocationSite) {
554
665
  const src = props ?? null;
555
666
  const key = hasElementConfigKey(src) ? "" + src.key : null;
556
667
  const copiedProps = copyScopedElementConfig(type, src);
@@ -567,9 +678,9 @@ function createScopedElement(type, props, readChildren) {
567
678
  }
568
679
  return resolvedChildren;
569
680
  };
570
- return scopedElementDescriptor(type, copiedProps, key, children);
681
+ return scopedElementDescriptor(type, copiedProps, key, children, invocationSite);
571
682
  }
572
- function nativeCreateScopedElement(type, props, readChildren) {
683
+ function nativeCreateScopedElement(type, props, readChildren, invocationSite) {
573
684
  const src = props ?? null;
574
685
  const key = hasElementConfigKey(src) ? "" + src.key : null;
575
686
  const copiedProps = copyScopedElementConfig(type, src);
@@ -577,10 +688,11 @@ function nativeCreateScopedElement(type, props, readChildren) {
577
688
  type,
578
689
  copiedProps,
579
690
  key,
580
- createNativeServerScopedResolver(readChildren)
691
+ createNativeServerScopedResolver(readChildren),
692
+ invocationSite
581
693
  );
582
694
  }
583
- function scopedElementDescriptor(type, copiedProps, key, children) {
695
+ function scopedElementDescriptor(type, copiedProps, key, children, invocationSite) {
584
696
  setScopedChildrenResolver(copiedProps, children);
585
697
  SCOPED_ELEMENT_PROPS.add(copiedProps);
586
698
  const descriptor = {
@@ -590,31 +702,43 @@ function scopedElementDescriptor(type, copiedProps, key, children) {
590
702
  key,
591
703
  ref: copiedProps.ref !== void 0 ? copiedProps.ref : null
592
704
  };
705
+ if (invocationSite !== void 0) descriptor.__octaneInvocationSite = invocationSite;
593
706
  Object.defineProperty(descriptor, "children", SCOPED_CHILDREN_PROPERTY);
594
707
  setScopedChildrenResolver(descriptor, children);
595
708
  return finalizeElementDescriptor(descriptor);
596
709
  }
597
710
  function createElement(type, props, ...children) {
711
+ return createElementFromConfig(void 0, type, props, children);
712
+ }
713
+ function createElementAt(invocationSite, type, props, ...children) {
714
+ return createElementFromConfig(invocationSite, type, props, children);
715
+ }
716
+ function createElementFromConfig(invocationSite, type, props, children) {
598
717
  if (typeof type === "function" && isRendererContext(type)) {
599
718
  registerServerRendererContextProvider(renderServerContextProvider);
600
719
  }
601
720
  const src = props ?? null;
602
721
  const key = hasElementConfigKey(src) ? "" + src.key : null;
603
- let kids = children.length > 0 ? children.length === 1 ? children[0] : children : src?.children;
604
- if (children.length > 1) POSITIONAL_CHILDREN.add(children);
605
- if (children.length > 1 && process.env.NODE_ENV !== "production") Object.freeze(children);
722
+ const hasPositional = children !== void 0 && children.length > 0;
723
+ let kids = hasPositional ? children.length === 1 ? children[0] : children : src?.children;
724
+ if (children !== void 0 && children.length > 1) {
725
+ POSITIONAL_CHILDREN.add(children);
726
+ if (process.env.NODE_ENV !== "production") Object.freeze(children);
727
+ }
606
728
  const p = copyElementConfig(src);
607
- if (children.length > 0) p.children = kids;
729
+ if (hasPositional) p.children = kids;
608
730
  applyElementDefaultProps(type, p);
609
731
  kids = p.children;
610
- return finalizeElementDescriptor({
732
+ const descriptor = {
611
733
  $$kind: ELEMENT_TAG,
612
734
  type,
613
735
  props: p,
614
736
  key,
615
737
  ref: p.ref !== void 0 ? p.ref : null,
616
738
  children: kids ?? null
617
- });
739
+ };
740
+ if (invocationSite !== void 0) descriptor.__octaneInvocationSite = invocationSite;
741
+ return finalizeElementDescriptor(descriptor);
618
742
  }
619
743
  const POSITIONAL_CHILDREN = /* @__PURE__ */ new WeakSet();
620
744
  function positionalChildren(children) {
@@ -846,6 +970,8 @@ function cloneElement(element, config, ...children) {
846
970
  children: kids ?? null
847
971
  };
848
972
  }
973
+ if (element.__octaneInvocationSite !== void 0)
974
+ descriptor.__octaneInvocationSite = element.__octaneInvocationSite;
849
975
  return finalizeElementDescriptor(descriptor);
850
976
  }
851
977
  function cloneAndReplaceElementKey(element, key) {
@@ -1049,8 +1175,33 @@ class ServerHtml {
1049
1175
  return this[SERVER_HTML];
1050
1176
  }
1051
1177
  }
1178
+ class RawServerHtml {
1179
+ constructor(html) {
1180
+ this.html = html;
1181
+ }
1182
+ html;
1183
+ get [SERVER_HTML]() {
1184
+ VT_SSR_HAS_RAW_HTML = true;
1185
+ return this.html;
1186
+ }
1187
+ toString() {
1188
+ return this[SERVER_HTML];
1189
+ }
1190
+ }
1052
1191
  function ssrHtml(html) {
1053
- return typeof html === "string" ? new ServerHtml(html) : html;
1192
+ if (typeof html !== "string") return html;
1193
+ if (!VT_SSR_HAS_RAW_HTML) return new ServerHtml(html);
1194
+ if (CURRENT_SCOPE === null) VT_SSR_HAS_RAW_HTML = false;
1195
+ return new RawServerHtml(html);
1196
+ }
1197
+ const BINDING_HTML_ROOT = /* @__PURE__ */ Symbol.for("octane.binding.html");
1198
+ function ssrBindingHtml(html, id) {
1199
+ const output = new ServerHtml(html);
1200
+ output[BINDING_HTML_ROOT] = "[b;" + id + ";root";
1201
+ return output;
1202
+ }
1203
+ function bindPresentationView(view, _id) {
1204
+ return markComponentFlags(view, COMPONENT_FLAG_BOUNDARY, view.name);
1054
1205
  }
1055
1206
  function serverComponentOutput(out, scope) {
1056
1207
  if (out == null) return "";
@@ -1089,21 +1240,53 @@ function ssrTextPre(v) {
1089
1240
  }
1090
1241
  function ssrComponentDescriptor(d, scope) {
1091
1242
  if (SCOPED_ELEMENT_PROPS.has(d.props)) {
1092
- return ssrComponent(scope, d.type, d.props);
1243
+ return ssrComponent(
1244
+ scope,
1245
+ d.type,
1246
+ d.props,
1247
+ void 0,
1248
+ d.key ?? void 0,
1249
+ void 0,
1250
+ d.__octaneInvocationSite
1251
+ );
1093
1252
  }
1094
1253
  const children = d.children;
1095
1254
  if (children == null || children === d.props?.children) {
1096
- return ssrComponent(scope, d.type, d.props);
1255
+ return ssrComponent(
1256
+ scope,
1257
+ d.type,
1258
+ d.props,
1259
+ void 0,
1260
+ d.key ?? void 0,
1261
+ void 0,
1262
+ d.__octaneInvocationSite
1263
+ );
1097
1264
  }
1098
- return ssrComponent(scope, d.type, {
1099
- ...d.props,
1100
- children
1101
- });
1265
+ return ssrComponent(
1266
+ scope,
1267
+ d.type,
1268
+ { ...d.props, children },
1269
+ void 0,
1270
+ d.key ?? void 0,
1271
+ void 0,
1272
+ d.__octaneInvocationSite
1273
+ );
1102
1274
  }
1103
1275
  function ssrChild(v, scope) {
1276
+ if (isSignalHandle(v)) {
1277
+ v = readSignalBinding(v);
1278
+ }
1104
1279
  if (probingDangerHtmlChild(v)) return "";
1105
1280
  return ssrChildValue(v, scope, true);
1106
1281
  }
1282
+ function ssrBindingChild(value, scope, marker) {
1283
+ const html = ssrChild(value, scope);
1284
+ if (!MARKERS) return html;
1285
+ const openingEnd = html.indexOf("-->");
1286
+ const framed = html.startsWith(BLOCK_OPEN) || html.startsWith("<!--") && openingEnd !== -1 && isBindingOpenComment(html.slice(4, openingEnd));
1287
+ const content = framed && html.endsWith(BLOCK_CLOSE) ? html.slice(openingEnd + 3, -BLOCK_CLOSE.length) : html;
1288
+ return ssrBindingBlock(content, marker);
1289
+ }
1107
1290
  function ssrChildValue(v, scope, includeKeyedSingle, selfMarkItem = false) {
1108
1291
  if (v !== null && typeof v === "object" && SERVER_HTML in v) {
1109
1292
  return v[SERVER_HTML];
@@ -1235,6 +1418,7 @@ function ssrHostElement(tag, props, children, scope, rawInner) {
1235
1418
  }
1236
1419
  let inner = "";
1237
1420
  if (hasDangerHTML) {
1421
+ VT_SSR_HAS_RAW_HTML = true;
1238
1422
  const html = innerHTMLValue.__html;
1239
1423
  const raw = html == null ? "" : String(html);
1240
1424
  inner = semanticTag === "script" ? escapeEntireInlineScriptContent(raw) : semanticTag === "style" ? escapeEntireInlineStyleContent(raw) : raw;
@@ -1353,6 +1537,20 @@ function ssrDescriptorContent(v, scope) {
1353
1537
  function ssrBlock(content) {
1354
1538
  return MARKERS ? BLOCK_OPEN + content + BLOCK_CLOSE : String(content);
1355
1539
  }
1540
+ function ssrBindingBlock(content, marker) {
1541
+ return MARKERS ? "<!--" + marker + "-->" + content + BLOCK_CLOSE : String(content);
1542
+ }
1543
+ function ssrBindingKey(key, seen) {
1544
+ const encoded = encodeBindingKey(key);
1545
+ if (seen.has(encoded)) throw new TypeError(formatServerError(73));
1546
+ seen.add(encoded);
1547
+ return encoded;
1548
+ }
1549
+ function ssrBindingClass(receipt, values) {
1550
+ const snapshot = [normalizeClass(values[0]), values[1].map(normalizeClass)];
1551
+ const classes = [snapshot[0], ...snapshot[1]].filter(Boolean).join(" ");
1552
+ return ' class="' + escapeAttr(classes) + '" ' + receipt + '="' + escapeAttr(JSON.stringify(snapshot)) + '"';
1553
+ }
1356
1554
  function ssrFragmentMarker(open, _ref) {
1357
1555
  return MARKERS ? open ? "<!--frag-->" : "<!--/frag-->" : "";
1358
1556
  }
@@ -1435,31 +1633,48 @@ function withAsyncListScope(kind, fn) {
1435
1633
  function ssrControl(siteKey, fn) {
1436
1634
  const frame = FRAME;
1437
1635
  const occurrence = frame === null ? 0 : nextFrameOccurrence(frame, "@control:" + siteKey);
1438
- return withAsyncIdentity("control:" + siteKey, occurrence, fn);
1636
+ const previousSignalControl = SIGNAL_CONTROL_SITE;
1637
+ SIGNAL_CONTROL_SITE = siteKey;
1638
+ try {
1639
+ return withAsyncIdentity("control:" + siteKey, occurrence, fn);
1640
+ } finally {
1641
+ SIGNAL_CONTROL_SITE = previousSignalControl;
1642
+ }
1439
1643
  }
1440
- function enterAsyncArm(armKey) {
1644
+ function enterAsyncArm(armKey, mapped = false) {
1441
1645
  const previous = ASYNC_SCOPE;
1442
1646
  const frame = FRAME;
1443
- const occurrence = frame === null ? 0 : nextFrameOccurrence(frame, "@arm-position:" + previous);
1444
- const fallbackPosition = previous + "|@arm-position:" + occurrence;
1647
+ const occurrence = frame === null ? 0 : nextFrameOccurrence(frame, "@arm-position:");
1648
+ const fallbackPosition = armKey !== null && (typeof armKey === "object" || typeof armKey === "function" || typeof armKey === "symbol") ? previous + "|@arm-position:" + occurrence : void 0;
1649
+ if (SERVER_SIGNAL_BINDINGS_POTENTIAL && SIGNAL_CONTROL_SITE.charCodeAt(0) === 102) {
1650
+ SIGNAL_LIST_KEYS = [
1651
+ ...SIGNAL_LIST_KEYS,
1652
+ signalIdentityKey(mapped ? "k" + String(armKey) : armKey)
1653
+ ];
1654
+ }
1445
1655
  ASYNC_SCOPE = previous + "|@arm:" + asyncIdentityKey(armKey, false, fallbackPosition);
1446
- return previous;
1447
1656
  }
1448
1657
  function ssrArm(armKey, fn) {
1449
- const previous = enterAsyncArm(armKey);
1658
+ const previous = ASYNC_SCOPE;
1659
+ const previousSignalKeys = SIGNAL_LIST_KEYS;
1450
1660
  try {
1661
+ enterAsyncArm(armKey);
1451
1662
  return fn();
1452
1663
  } finally {
1453
1664
  ASYNC_SCOPE = previous;
1665
+ SIGNAL_LIST_KEYS = previousSignalKeys;
1454
1666
  }
1455
1667
  }
1456
- function ssrForItem(armKey, fn, item, index, scope, block) {
1457
- const previous = enterAsyncArm(armKey);
1668
+ function ssrForItem(armKey, fn, item, index, scope, block, mapped = false) {
1669
+ const previous = ASYNC_SCOPE;
1670
+ const previousSignalKeys = SIGNAL_LIST_KEYS;
1458
1671
  try {
1672
+ enterAsyncArm(armKey, mapped);
1459
1673
  const html = index === void 0 ? fn(item, scope) : fn(item, index, scope);
1460
1674
  return block ? ssrBlock(html) : html;
1461
1675
  } finally {
1462
1676
  ASYNC_SCOPE = previous;
1677
+ SIGNAL_LIST_KEYS = previousSignalKeys;
1463
1678
  }
1464
1679
  }
1465
1680
  function ssrPortal() {
@@ -1713,7 +1928,7 @@ function isAggregatedFormAttribute(tag, name) {
1713
1928
  if (tag === "input" && (name === "checked" || name === "defaultChecked")) return true;
1714
1929
  return tag === "select" && name === "multiple";
1715
1930
  }
1716
- function ssrAttrs(sources, tag, namespace = "html", skipFormControls = false) {
1931
+ function ssrAttrs(sources, tag, namespace = "html", skipFormControls = false, readStyle) {
1717
1932
  const dev = process.env.NODE_ENV !== "production";
1718
1933
  namespace = resolveAttributeNamespace(namespace);
1719
1934
  const props = /* @__PURE__ */ new Map();
@@ -1764,7 +1979,12 @@ function ssrAttrs(sources, tag, namespace = "html", skipFormControls = false) {
1764
1979
  for (const { name: rawName, value } of props.values()) {
1765
1980
  if (rawName === "dangerouslySetInnerHTML" || skipFormControls && isAggregatedFormAttribute(tag, rawName))
1766
1981
  continue;
1767
- out2 += ssrAttrEntry(rawName, value, tag, namespace);
1982
+ out2 += ssrAttrEntry(
1983
+ rawName,
1984
+ readStyle !== void 0 && rawName === "style" ? readStyle(value) : value,
1985
+ tag,
1986
+ namespace
1987
+ );
1768
1988
  }
1769
1989
  return out2;
1770
1990
  }
@@ -1807,6 +2027,8 @@ function ssrAttrs(sources, tag, namespace = "html", skipFormControls = false) {
1807
2027
  }
1808
2028
  }
1809
2029
  }
2030
+ const style = resolved.get("style");
2031
+ if (readStyle !== void 0 && style !== void 0) style.value = readStyle(style.value);
1810
2032
  let out = "";
1811
2033
  const ordered = dev || needsWinningOrderSort ? [...resolved.values()] : resolved.values();
1812
2034
  if (needsWinningOrderSort) ordered.sort((a, b) => a.firstOrder - b.firstOrder);
@@ -1861,14 +2083,32 @@ function ssrClass(sources) {
1861
2083
  }
1862
2084
  return found ? ssrAttr("class", value) : "";
1863
2085
  }
1864
- function ssrSnapshotSpread(obj) {
2086
+ function ssrSnapshotSpread(obj, controlSite, deferStyle = false) {
1865
2087
  if (obj == null) return null;
1866
2088
  const source = Object(obj);
1867
2089
  const snapshot = /* @__PURE__ */ Object.create(null);
1868
2090
  for (const key of Reflect.ownKeys(source)) {
1869
2091
  if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue;
1870
- const value = source[key];
1871
- if (typeof key === "string") snapshot[key] = value;
2092
+ let value = source[key];
2093
+ if (typeof key !== "string") continue;
2094
+ if (key === "style" && deferStyle) {
2095
+ snapshot[key] = value;
2096
+ continue;
2097
+ }
2098
+ if (controlSite !== void 0 && (key === "value" || key === "checked") && isWritableSignal(value)) {
2099
+ value = ssrSignalControlValue(value, controlSite);
2100
+ } else if (isSignalHandle(value)) value = readSignalBinding(value);
2101
+ else if (key === "style" && value !== null && typeof value === "object") {
2102
+ let style;
2103
+ for (const name of Object.keys(value)) {
2104
+ const current = value[name];
2105
+ if (!isSignalHandle(current)) continue;
2106
+ style ??= { ...value };
2107
+ style[name] = readSignalBinding(current);
2108
+ }
2109
+ if (style !== void 0) value = style;
2110
+ }
2111
+ snapshot[key] = value;
1872
2112
  }
1873
2113
  return snapshot;
1874
2114
  }
@@ -1920,6 +2160,7 @@ function ssrInnerHtml(sources, renderChildren, definitelyHasChildren = false, ch
1920
2160
  }
1921
2161
  }
1922
2162
  const html = value.__html;
2163
+ VT_SSR_HAS_RAW_HTML = true;
1923
2164
  return html == null ? "" : String(html);
1924
2165
  }
1925
2166
  return void 0;
@@ -1962,6 +2203,7 @@ function ssrSpreadContent(snapshot, scope) {
1962
2203
  }
1963
2204
  if (child != null) throw new Error(formatServerError(5));
1964
2205
  const value = html.__html;
2206
+ VT_SSR_HAS_RAW_HTML = true;
1965
2207
  return value == null ? "" : String(value);
1966
2208
  }
1967
2209
  return child === void 0 ? "" : ssrChildText(child, scope);
@@ -1991,24 +2233,48 @@ function ssrFormAuthoringDiagnostics(tag, sources) {
1991
2233
  return "";
1992
2234
  }
1993
2235
  function ssrValueAttr(v) {
2236
+ v = unwrapSsrSignalControlValue(v);
1994
2237
  if (v == null || typeof v === "function" || typeof v === "symbol") return "";
1995
2238
  return ' value="' + escapeAttr(typeof v === "string" ? v : String(v)) + '"';
1996
2239
  }
1997
2240
  function ssrCheckedAttr(v) {
2241
+ v = unwrapSsrSignalControlValue(v);
1998
2242
  return v == null || !v ? "" : " checked";
1999
2243
  }
2000
2244
  function ssrInputAttrs(sources) {
2001
2245
  const props = resolveFormControlSources(sources);
2002
2246
  if (process.env.NODE_ENV !== "production") {
2003
2247
  devValidateSsrFormProps("input", {
2004
- value: props.value,
2005
- defaultValue: props.defaultValue,
2006
- checked: props.checked,
2007
- defaultChecked: props.defaultChecked
2248
+ value: unwrapSsrSignalControlValue(props.value),
2249
+ defaultValue: unwrapSsrSignalControlValue(props.defaultValue),
2250
+ checked: unwrapSsrSignalControlValue(props.checked),
2251
+ defaultChecked: unwrapSsrSignalControlValue(props.defaultChecked)
2008
2252
  });
2009
2253
  }
2010
2254
  return ssrValueAttr(props.value ?? props.defaultValue) + ssrCheckedAttr(props.checked ?? props.defaultChecked);
2011
2255
  }
2256
+ function ssrSignalControlAttrs(sources) {
2257
+ const props = resolveFormControlSources(sources);
2258
+ const controls = [];
2259
+ let ownerKey;
2260
+ const record = (value, channel) => {
2261
+ if (!isSsrSignalControlValue(value)) return;
2262
+ const documentKey = value.owner.documentOwner.scopeKey;
2263
+ if (ownerKey !== void 0 && ownerKey !== documentKey) {
2264
+ throw new Error(formatServerError(68));
2265
+ }
2266
+ ownerKey = documentKey;
2267
+ controls.push([
2268
+ value.binding.scope === "document" ? "" : value.owner.instanceKey,
2269
+ value.binding.nodeKey,
2270
+ channel
2271
+ ]);
2272
+ };
2273
+ record(props.value, "value");
2274
+ record(props.checked, "checked");
2275
+ if (controls.length === 0) return "";
2276
+ return " " + SIGNAL_CONTROL_ATTR + '="' + escapeAttr(JSON.stringify([1, ownerKey, controls])) + '"';
2277
+ }
2012
2278
  function resolveFormControlSources(sources) {
2013
2279
  const resolved = {
2014
2280
  value: void 0,
@@ -2059,6 +2325,7 @@ function resolveFormControlSources(sources) {
2059
2325
  return resolved;
2060
2326
  }
2061
2327
  function ssrTextareaValue(v) {
2328
+ v = unwrapSsrSignalControlValue(v);
2062
2329
  if (v == null) return "";
2063
2330
  const s = escapeHtml(typeof v === "string" ? v : String(v));
2064
2331
  return s.charCodeAt(0) === 10 ? "\n" + s : s;
@@ -2067,8 +2334,8 @@ function ssrTextareaValueSources(sources) {
2067
2334
  const props = resolveFormControlSources(sources);
2068
2335
  if (process.env.NODE_ENV !== "production") {
2069
2336
  devValidateSsrFormProps("textarea", {
2070
- value: props.value,
2071
- defaultValue: props.defaultValue
2337
+ value: unwrapSsrSignalControlValue(props.value),
2338
+ defaultValue: unwrapSsrSignalControlValue(props.defaultValue)
2072
2339
  });
2073
2340
  }
2074
2341
  const value = props.value ?? props.defaultValue;
@@ -2080,6 +2347,8 @@ function ssrSelectAttrs(sources) {
2080
2347
  }
2081
2348
  const SELECT_STACK = [];
2082
2349
  function ssrSelectScope(value, defaultValue, multiple, children) {
2350
+ value = unwrapSsrSignalControlValue(value);
2351
+ defaultValue = unwrapSsrSignalControlValue(defaultValue);
2083
2352
  if (process.env.NODE_ENV !== "production") {
2084
2353
  devValidateSsrFormProps("select", { value, defaultValue, multiple });
2085
2354
  }
@@ -2268,6 +2537,28 @@ function snapshotSet(set) {
2268
2537
  function snapshotList(list) {
2269
2538
  return list == null || list.length === 0 ? EMPTY_SNAPSHOT_LIST : list.slice();
2270
2539
  }
2540
+ function snapshotStyles(css) {
2541
+ if (css === null || css.size === 0) return snapshotMap(css);
2542
+ return css.replay ??= snapshotMap(css);
2543
+ }
2544
+ const EMPTY_HEAD_REPLAY = {
2545
+ hints: EMPTY_SNAPSHOT_SET,
2546
+ sheets: null,
2547
+ hintHtml: null,
2548
+ preloadXfer: null
2549
+ };
2550
+ function snapshotHeadCollections(head) {
2551
+ if (head === null) return null;
2552
+ if (head.replay !== null) return head.replay;
2553
+ if (head.hints.size === 0 && head.sheets === null && head.hintHtml === null && head.preloadXfer === null)
2554
+ return EMPTY_HEAD_REPLAY;
2555
+ return head.replay = {
2556
+ hints: snapshotSet(head.hints),
2557
+ sheets: snapshotMap(head.sheets),
2558
+ hintHtml: snapshotMap(head.hintHtml),
2559
+ preloadXfer: snapshotMap(head.preloadXfer)
2560
+ };
2561
+ }
2271
2562
  function snapshotVtStack() {
2272
2563
  return VT_SSR_STACK.length === 0 ? EMPTY_SNAPSHOT_LIST : VT_SSR_STACK.map((candidate) => ({ candidate, consumed: candidate.consumed }));
2273
2564
  }
@@ -2285,6 +2576,7 @@ function restoreScopedCounts(snapshot) {
2285
2576
  function captureComponentReplayState(scope, frame) {
2286
2577
  const css = CSS;
2287
2578
  const head = HEAD;
2579
+ const headCollections = snapshotHeadCollections(head);
2288
2580
  const serial = SERIAL;
2289
2581
  const susp = SUSPENDED;
2290
2582
  const jobs = DEFERRED;
@@ -2297,15 +2589,15 @@ function captureComponentReplayState(scope, frame) {
2297
2589
  nativeMixed: NATIVE_SERVER_READS?.mixed ?? false,
2298
2590
  nativeFailures: NATIVE_SERVER_FAILURES,
2299
2591
  css,
2300
- cssEntries: snapshotMap(css),
2592
+ cssEntries: snapshotStyles(css),
2301
2593
  head,
2302
2594
  headLength: head !== null ? head.html.length : 0,
2303
2595
  headCharsetLength: head !== null ? head.charset.length : 0,
2304
2596
  headViewportLength: head !== null ? head.viewport.length : 0,
2305
- headHints: snapshotSet(head?.hints),
2306
- headSheets: snapshotMap(head?.sheets),
2307
- headHintHtml: snapshotMap(head?.hintHtml),
2308
- headXfer: snapshotMap(head?.preloadXfer),
2597
+ headHints: headCollections?.hints ?? null,
2598
+ headSheets: headCollections?.sheets ?? null,
2599
+ headHintHtml: headCollections?.hintHtml ?? null,
2600
+ headXfer: headCollections?.preloadXfer ?? null,
2309
2601
  serial,
2310
2602
  serialLength: serial !== null ? serial.length : 0,
2311
2603
  susp,
@@ -2341,10 +2633,12 @@ function rewindComponentReplayState(snapshot, scope, frame) {
2341
2633
  NATIVE_SERVER_FAILURES = snapshot.nativeFailures;
2342
2634
  ASYNC_SCOPE = snapshot.asyncScope;
2343
2635
  if (snapshot.css !== null && snapshot.cssEntries !== null) {
2636
+ snapshot.css.replay = null;
2344
2637
  snapshot.css.clear();
2345
2638
  for (const [hash, sheet] of snapshot.cssEntries) snapshot.css.set(hash, sheet);
2346
2639
  }
2347
2640
  if (snapshot.head !== null && snapshot.headHints !== null) {
2641
+ snapshot.head.replay = null;
2348
2642
  snapshot.head.html = snapshot.head.html.slice(0, snapshot.headLength);
2349
2643
  snapshot.head.charset = snapshot.head.charset.slice(0, snapshot.headCharsetLength);
2350
2644
  snapshot.head.viewport = snapshot.head.viewport.slice(0, snapshot.headViewportLength);
@@ -2413,10 +2707,96 @@ function replayUpdatedComponentBody(comp, props, scope, frame, hp, snapshot, war
2413
2707
  hp.occ = null;
2414
2708
  rewindComponentReplayState(snapshot, scope, frame);
2415
2709
  ACTIVE_PU_WARM_PLANS.length = warmPlanCheckpoint;
2416
- out = comp(props ?? {}, scope, void 0);
2710
+ out = invokeServerSignalComponent(comp, props, scope, serverSignalOwner(frame));
2417
2711
  } while (hp.update);
2418
2712
  return out;
2419
2713
  }
2714
+ function signalIdentityKey(value) {
2715
+ if (value === null) return "null";
2716
+ const kind = typeof value;
2717
+ return kind === "string" || kind === "number" || kind === "bigint" || kind === "boolean" ? kind.charCodeAt(0).toString(36) + ":" + String(value) : kind === "undefined" ? "u:" : "o:" + String(value);
2718
+ }
2719
+ function serverStructuralSignalInstanceKey(invocationSite, key) {
2720
+ return resolveServerSignalInstanceKey(SIGNAL_COMPONENT_INSTANCE_KEY) + JSON.stringify([
2721
+ invocationSite ?? "legacy",
2722
+ SIGNAL_LIST_KEYS,
2723
+ key != null ? signalIdentityKey(key) : ""
2724
+ ]);
2725
+ }
2726
+ function resolveServerSignalInstanceKey(identity) {
2727
+ if (typeof identity === "string") return identity;
2728
+ if (identity.signalInstanceKey !== void 0) return identity.signalInstanceKey;
2729
+ const pending = [];
2730
+ while (typeof identity !== "string") {
2731
+ if (identity.signalInstanceKey !== void 0) {
2732
+ identity = identity.signalInstanceKey;
2733
+ break;
2734
+ }
2735
+ pending.push(identity);
2736
+ identity = identity.signalParentKey;
2737
+ }
2738
+ for (let index = pending.length - 1; index >= 0; index--) {
2739
+ const frame = pending[index];
2740
+ identity += JSON.stringify([
2741
+ frame.signalInvocationSite ?? "legacy",
2742
+ frame.signalListKeys,
2743
+ frame.signalKey
2744
+ ]);
2745
+ frame.signalInstanceKey = identity;
2746
+ }
2747
+ return identity;
2748
+ }
2749
+ function serverSignalOwner(_frame) {
2750
+ const resolved = RESOLVED;
2751
+ if (resolved !== null && SERVER_SIGNAL_BINDINGS_ENABLED && resolved.signalOwner === void 0) {
2752
+ ensureServerSignalOwner();
2753
+ }
2754
+ if (resolved === null || resolved.signalOwner === void 0 || resolved.signalInstances === void 0)
2755
+ return;
2756
+ const instanceKey = resolveServerSignalInstanceKey(SIGNAL_COMPONENT_INSTANCE_KEY) || JSON.stringify([SIGNAL_INSTANCE_PREFIX, "root"]);
2757
+ let owner = resolved.signalInstances.get(instanceKey);
2758
+ if (owner === void 0) {
2759
+ owner = Object.freeze({
2760
+ scopeKey: resolved.signalOwner.scopeKey,
2761
+ documentOwner: resolved.signalOwner,
2762
+ instanceOwner: Object.freeze({}),
2763
+ instanceKey
2764
+ });
2765
+ resolved.signalInstances.set(instanceKey, owner);
2766
+ }
2767
+ return owner;
2768
+ }
2769
+ function ensureServerSignalOwner() {
2770
+ const resolved = RESOLVED;
2771
+ if (resolved.signalOwner !== void 0 && resolved.signalInstances !== void 0) return;
2772
+ const ambient = currentSignalOwner();
2773
+ resolved.signalOwner = ambient === null ? Object.freeze({ scopeKey: "octane:document" }) : isRendererSignalOwner(ambient) ? ambient.documentOwner : ambient;
2774
+ resolved.ownedSignalOwner = ambient === null;
2775
+ resolved.signalInstances = /* @__PURE__ */ new Map();
2776
+ }
2777
+ function invokeServerSignalComponent(comp, props, scope, owner) {
2778
+ if (owner === void 0) return comp(props ?? {}, scope, void 0);
2779
+ const invoke = () => {
2780
+ const previous = SERVER_SIGNAL_OWNER_ACTIVE;
2781
+ SERVER_SIGNAL_OWNER_ACTIVE = true;
2782
+ try {
2783
+ return comp(props ?? {}, scope, void 0);
2784
+ } finally {
2785
+ SERVER_SIGNAL_OWNER_ACTIVE = previous;
2786
+ }
2787
+ };
2788
+ const injection = RESOLVED?.resourceOptions?.injection;
2789
+ const observe = injection?.observeSignalAttempt;
2790
+ return runWithSignalOwner(
2791
+ owner,
2792
+ () => observe === void 0 ? invoke() : runWithServerSignalQueryAttemptObserver(
2793
+ owner,
2794
+ (attempt) => observe(attempt, captureSignalOwner(owner)),
2795
+ injection.createSignalAttemptObservations,
2796
+ invoke
2797
+ )
2798
+ );
2799
+ }
2420
2800
  function invokeComponentBody(comp, props, scope, frame) {
2421
2801
  const prevHP = HOOK_PASS;
2422
2802
  const hp = { hooks: null, occ: null, update: false };
@@ -2425,7 +2805,7 @@ function invokeComponentBody(comp, props, scope, frame) {
2425
2805
  HOOK_PASS = hp;
2426
2806
  try {
2427
2807
  ACTIVE_PU_WARM_PLANS.length = warmPlanCheckpoint;
2428
- let out = comp(props ?? {}, scope, void 0);
2808
+ let out = invokeServerSignalComponent(comp, props, scope, serverSignalOwner(frame));
2429
2809
  if (hp.update) {
2430
2810
  out = replayUpdatedComponentBody(comp, props, scope, frame, hp, snapshot, warmPlanCheckpoint);
2431
2811
  }
@@ -2437,14 +2817,25 @@ function invokeComponentBody(comp, props, scope, frame) {
2437
2817
  HOOK_PASS = prevHP;
2438
2818
  }
2439
2819
  }
2440
- function renderComponentFramed(comp, props, parent, frame, inherit) {
2441
- const prevScope = CURRENT_SCOPE;
2442
- const prevFrame = FRAME;
2443
- const prevComp = CURRENT_COMP;
2444
- const prevProps = CURRENT_PROPS;
2445
- const prevParent = CURRENT_PARENT_SCOPE;
2446
- const prevAsyncScope = ASYNC_SCOPE;
2447
- const parentScope = parent ?? prevScope;
2820
+ function captureServerComponentContext() {
2821
+ return {
2822
+ scope: CURRENT_SCOPE,
2823
+ frame: FRAME,
2824
+ comp: CURRENT_COMP,
2825
+ props: CURRENT_PROPS,
2826
+ parent: CURRENT_PARENT_SCOPE,
2827
+ asyncScope: ASYNC_SCOPE,
2828
+ signalInstance: SIGNAL_COMPONENT_INSTANCE_KEY,
2829
+ signalOwnerActive: SERVER_SIGNAL_OWNER_ACTIVE,
2830
+ signalControl: SIGNAL_CONTROL_SITE,
2831
+ signalListKeys: SIGNAL_LIST_KEYS,
2832
+ owner: void 0,
2833
+ previousOwner: void 0
2834
+ };
2835
+ }
2836
+ function renderComponentFramed(comp, props, parent, frame, inherit, instanceKey, bindingMarker) {
2837
+ const previous = captureServerComponentContext();
2838
+ const parentScope = parent ?? previous.scope;
2448
2839
  const scope = ssrScope(parentScope);
2449
2840
  CURRENT_SCOPE = scope;
2450
2841
  FRAME = frame;
@@ -2452,6 +2843,9 @@ function renderComponentFramed(comp, props, parent, frame, inherit) {
2452
2843
  CURRENT_PROPS = props;
2453
2844
  CURRENT_PARENT_SCOPE = parentScope;
2454
2845
  ASYNC_SCOPE = frame.asyncScope;
2846
+ if (instanceKey !== void 0) SIGNAL_COMPONENT_INSTANCE_KEY = instanceKey;
2847
+ SIGNAL_CONTROL_SITE = "";
2848
+ SIGNAL_LIST_KEYS = EMPTY_SIGNAL_LIST_KEYS;
2455
2849
  const nativeToken = NATIVE_READ_COLLECTOR === null ? -1 : beginActiveNativeReadScope(scope);
2456
2850
  let nativeCompleted = false;
2457
2851
  try {
@@ -2463,7 +2857,20 @@ function renderComponentFramed(comp, props, parent, frame, inherit) {
2463
2857
  HOOK_PASS = hookPass;
2464
2858
  try {
2465
2859
  ACTIVE_PU_WARM_PLANS.length = warmPlanCheckpoint;
2466
- out = comp(props ?? {}, scope, void 0);
2860
+ previous.owner = serverSignalOwner(frame);
2861
+ if (previous.owner === void 0) {
2862
+ out = comp(props ?? {}, scope, void 0);
2863
+ } else if (RESOLVED?.resourceOptions?.injection?.observeSignalAttempt !== void 0 || (previous.previousOwner = enterSynchronousSignalOwner(previous.owner)) === void 0) {
2864
+ out = invokeServerSignalComponent(comp, props, scope, previous.owner);
2865
+ } else {
2866
+ try {
2867
+ SERVER_SIGNAL_OWNER_ACTIVE = true;
2868
+ out = comp(props ?? {}, scope, void 0);
2869
+ } finally {
2870
+ SERVER_SIGNAL_OWNER_ACTIVE = previous.signalOwnerActive;
2871
+ restoreSynchronousSignalOwner(previous.previousOwner);
2872
+ }
2873
+ }
2467
2874
  if (hookPass.update) {
2468
2875
  out = replayUpdatedComponentBody(
2469
2876
  comp,
@@ -2481,22 +2888,29 @@ function renderComponentFramed(comp, props, parent, frame, inherit) {
2481
2888
  }
2482
2889
  const inner = serverComponentOutput(out, scope);
2483
2890
  nativeCompleted = true;
2484
- return MARKERS && !inherit ? BLOCK_OPEN + inner + BLOCK_CLOSE : inner;
2891
+ if (!MARKERS || inherit) return inner;
2892
+ const marker = bindingMarker ?? (out !== null && typeof out === "object" ? out[BINDING_HTML_ROOT] : void 0);
2893
+ return (marker === void 0 ? BLOCK_OPEN : "<!--" + marker + "-->") + inner + BLOCK_CLOSE;
2485
2894
  } catch (error) {
2486
2895
  throw normalizeThrownServerThenable(error);
2487
2896
  } finally {
2488
2897
  if (nativeToken >= 0) NATIVE_READ_COLLECTOR.endScope(nativeToken, nativeCompleted);
2489
- CURRENT_SCOPE = prevScope;
2490
- FRAME = prevFrame;
2491
- CURRENT_COMP = prevComp;
2492
- CURRENT_PROPS = prevProps;
2493
- CURRENT_PARENT_SCOPE = prevParent;
2494
- ASYNC_SCOPE = prevAsyncScope;
2495
- }
2496
- }
2497
- function ssrComponent(parent, comp, props, inherit, key, identityScoped) {
2898
+ CURRENT_SCOPE = previous.scope;
2899
+ FRAME = previous.frame;
2900
+ CURRENT_COMP = previous.comp;
2901
+ CURRENT_PROPS = previous.props;
2902
+ CURRENT_PARENT_SCOPE = previous.parent;
2903
+ ASYNC_SCOPE = previous.asyncScope;
2904
+ SIGNAL_COMPONENT_INSTANCE_KEY = previous.signalInstance;
2905
+ SERVER_SIGNAL_OWNER_ACTIVE = previous.signalOwnerActive;
2906
+ SIGNAL_CONTROL_SITE = previous.signalControl;
2907
+ SIGNAL_LIST_KEYS = previous.signalListKeys;
2908
+ }
2909
+ }
2910
+ function ssrComponent(parent, comp, props, inherit, key, identityScoped, invocationSite, bindingMarker) {
2498
2911
  const activity = comp === Activity;
2499
2912
  if (activity && key === void 0) key = props?.key;
2913
+ let signalInstanceKey = SERVER_SIGNAL_BINDINGS_ENABLED ? serverStructuralSignalInstanceKey(invocationSite, key) : void 0;
2500
2914
  const previousIdentityScope = ASYNC_SCOPE;
2501
2915
  if (identityScoped !== true) {
2502
2916
  ASYNC_SCOPE = previousIdentityScope + "|@component-type:" + asyncIdentityKey(comp, false);
@@ -2551,17 +2965,41 @@ function ssrComponent(parent, comp, props, inherit, key, identityScoped) {
2551
2965
  asyncScope: ASYNC_SCOPE,
2552
2966
  namespace: explicitNamespace ?? pf.namespace
2553
2967
  };
2554
- return renderComponentFramed(comp, props, parent, frame, inherit);
2968
+ if (signalInstanceKey === void 0 && SERVER_SIGNAL_BINDINGS_POTENTIAL) {
2969
+ frame.signalParentKey = SIGNAL_COMPONENT_INSTANCE_KEY;
2970
+ frame.signalInvocationSite = invocationSite;
2971
+ frame.signalListKeys = SIGNAL_LIST_KEYS;
2972
+ frame.signalKey = key != null ? signalIdentityKey(key) : "";
2973
+ signalInstanceKey = frame;
2974
+ }
2975
+ return renderComponentFramed(
2976
+ comp,
2977
+ props,
2978
+ parent,
2979
+ frame,
2980
+ inherit,
2981
+ signalInstanceKey,
2982
+ bindingMarker
2983
+ );
2555
2984
  } finally {
2556
2985
  if (identityScoped !== true) ASYNC_SCOPE = previousIdentityScope;
2557
2986
  }
2558
2987
  }
2559
2988
  let NEXT_COMPONENT_NAMESPACE = null;
2560
- function ssrComponentNS(parent, comp, props, namespace, inherit, key) {
2989
+ function ssrComponentNS(parent, comp, props, namespace, inherit, key, invocationSite, bindingMarker) {
2561
2990
  const previous = NEXT_COMPONENT_NAMESPACE;
2562
2991
  NEXT_COMPONENT_NAMESPACE = namespace;
2563
2992
  try {
2564
- return ssrComponent(parent, comp, props, inherit, key);
2993
+ return ssrComponent(
2994
+ parent,
2995
+ comp,
2996
+ props,
2997
+ inherit,
2998
+ key,
2999
+ void 0,
3000
+ invocationSite,
3001
+ bindingMarker
3002
+ );
2565
3003
  } finally {
2566
3004
  NEXT_COMPONENT_NAMESPACE = previous;
2567
3005
  }
@@ -2586,6 +3024,50 @@ function streamTokenForPendingHtml(html) {
2586
3024
  const stream = STREAM;
2587
3025
  return stream !== null && html.includes(STREAM_BOUNDARY_ATTR + '="' + stream.token + "-") ? stream.token : null;
2588
3026
  }
3027
+ function ssrIndependentHydrateSidecar(props, instanceId) {
3028
+ const independent = props.__independent;
3029
+ if (independent === void 0) return "";
3030
+ const registry = RESOLVED?.resourceOptions?.independentHydration;
3031
+ if (registry === void 0) {
3032
+ throw new Error(formatServerError(69));
3033
+ }
3034
+ const build = registry.resolve(independent.manifestTemplate.boundaryId);
3035
+ if (build === void 0) {
3036
+ throw new Error(formatServerError(70));
3037
+ }
3038
+ const manifest = createIndependentHydrateManifest(
3039
+ independent.manifestTemplate,
3040
+ independent.captures,
3041
+ instanceId,
3042
+ registry.buildId,
3043
+ build
3044
+ );
3045
+ return '<script type="application/json" ' + INDEPENDENT_HYDRATE_MANIFEST_ATTR + NONCE_ATTR + ">" + serializeIndependentHydrateManifest(manifest) + "</script>";
3046
+ }
3047
+ function withServerIndependentIdentity(prefix, idSeed, render) {
3048
+ const previous = SIGNAL_INSTANCE_PREFIX;
3049
+ const previousInstance = SIGNAL_COMPONENT_INSTANCE_KEY;
3050
+ const previousControl = SIGNAL_CONTROL_SITE;
3051
+ const previousListKeys = SIGNAL_LIST_KEYS;
3052
+ const previousIdPrefix = ID_PREFIX;
3053
+ const previousIdCounter = ID_COUNTER;
3054
+ SIGNAL_INSTANCE_PREFIX = prefix;
3055
+ SIGNAL_COMPONENT_INSTANCE_KEY = JSON.stringify([prefix, "root"]);
3056
+ SIGNAL_CONTROL_SITE = "";
3057
+ SIGNAL_LIST_KEYS = EMPTY_SIGNAL_LIST_KEYS;
3058
+ ID_PREFIX = prefix + "-";
3059
+ ID_COUNTER = idSeed;
3060
+ try {
3061
+ return render();
3062
+ } finally {
3063
+ SIGNAL_INSTANCE_PREFIX = previous;
3064
+ SIGNAL_COMPONENT_INSTANCE_KEY = previousInstance;
3065
+ SIGNAL_CONTROL_SITE = previousControl;
3066
+ SIGNAL_LIST_KEYS = previousListKeys;
3067
+ ID_PREFIX = previousIdPrefix;
3068
+ ID_COUNTER = previousIdCounter + ID_COUNTER - idSeed;
3069
+ }
3070
+ }
2589
3071
  function ssrHydrateAttrs(id, when, idCount, permanentStaticAncestor = false, streamToken = null) {
2590
3072
  const direct = typeof when !== "function" && when !== null ? when : null;
2591
3073
  let attrs = ssrAttr(HYDRATE_ID_ATTR, id, "div") + ssrAttr(
@@ -2643,7 +3125,8 @@ const PermanentStaticHydrate = /* @__PURE__ */ markComponentFlags(
2643
3125
  "PermanentStaticHydrate"
2644
3126
  );
2645
3127
  const hydrate = /* @__PURE__ */ markComponentFlags(
2646
- function Hydrate(props, scope) {
3128
+ function Hydrate(rawProps, scope) {
3129
+ const props = rawProps;
2647
3130
  const id = useId();
2648
3131
  return ssrHtml(
2649
3132
  withSsrElementContext(
@@ -2661,7 +3144,7 @@ const hydrate = /* @__PURE__ */ markComponentFlags(
2661
3144
  let children;
2662
3145
  let nativeReads = null;
2663
3146
  try {
2664
- children = ssrBlock(
3147
+ const renderChildren = () => ssrBlock(
2665
3148
  ssrTry(
2666
3149
  scope,
2667
3150
  "jsx-hydrate",
@@ -2671,6 +3154,11 @@ const hydrate = /* @__PURE__ */ markComponentFlags(
2671
3154
  "html"
2672
3155
  )
2673
3156
  );
3157
+ children = props.__independent === void 0 ? renderChildren() : withServerIndependentIdentity(
3158
+ id,
3159
+ props.__independent.manifestTemplate.idSeed,
3160
+ renderChildren
3161
+ );
2674
3162
  } finally {
2675
3163
  nativeReads = finishNativeSeedCapture(nativeCapture, previousNativeReads, false);
2676
3164
  }
@@ -2688,7 +3176,8 @@ const hydrate = /* @__PURE__ */ markComponentFlags(
2688
3176
  const seedSidecar = seedJson === null || seedJson === "[]" ? "" : '<script type="application/json" ' + HYDRATE_SEED_ATTR + NONCE_ATTR + ">" + seedJson + "</script>";
2689
3177
  const nativeSeeds = permanentStaticAncestor ? void 0 : NATIVE_READ_COLLECTOR?.serialize(nativeReads);
2690
3178
  const nativeSidecar = nativeSeeds === void 0 ? "" : serializeNativeSignalSeeds(nativeSeeds, NONCE_ATTR);
2691
- return "<div" + attrs + ">" + children + seedSidecar + nativeSidecar + "</div>";
3179
+ const independentSidecar = permanentStaticAncestor ? "" : ssrIndependentHydrateSidecar(props, id);
3180
+ return "<div" + attrs + (props.__independent === void 0 ? "" : " " + HYDRATE_INDEPENDENT_ATTR + '=""') + ">" + children + seedSidecar + nativeSidecar + independentSidecar + "</div>";
2692
3181
  }),
2693
3182
  "html"
2694
3183
  )
@@ -2723,43 +3212,14 @@ const Suspense = /* @__PURE__ */ markComponentFlags(
2723
3212
  );
2724
3213
  let VT_SSR_TRY_SEQ = 0;
2725
3214
  let VT_SSR_HAS_CANDIDATES = false;
3215
+ let VT_SSR_HAS_RAW_HTML = false;
2726
3216
  const VT_SSR_STACK = [];
2727
3217
  function vtSsrResolve(props, kind) {
2728
- let v = props[kind];
2729
- if (v == null) v = props.default;
2730
- if (v == null) return "auto";
2731
- if (typeof v === "string") return v;
2732
- return v.default != null ? v.default : "auto";
2733
- }
2734
- function vtSsrFirstVisibleOpenTag(html) {
2735
- const n = html.length;
2736
- let i = 0;
2737
- while (i < n) {
2738
- const lt = html.indexOf("<", i);
2739
- if (lt === -1) return -1;
2740
- if (html.startsWith("<!--", lt)) {
2741
- const close = html.indexOf("-->", lt + 4);
2742
- if (close === -1) return -1;
2743
- i = close + 3;
2744
- continue;
2745
- }
2746
- const c = html.charCodeAt(lt + 1);
2747
- if (!(c >= 65 && c <= 90 || c >= 97 && c <= 122)) {
2748
- i = lt + 1;
2749
- continue;
2750
- }
2751
- let e = lt + 1;
2752
- while (e < n && /[a-zA-Z0-9-]/.test(html[e])) e++;
2753
- if (e - lt === 9 && html.slice(lt + 1, e).toLowerCase() === "template") {
2754
- const j = vtSsrOpenTagEnd(html, e);
2755
- if (j === -1) return -1;
2756
- const close = html.indexOf("</template>", j);
2757
- i = close === -1 ? j + 1 : close + 11;
2758
- continue;
2759
- }
2760
- return lt;
2761
- }
2762
- return -1;
3218
+ const value = props[kind];
3219
+ const resolved = typeof value === "string" ? value : value?.default;
3220
+ if (resolved != null) return resolved;
3221
+ const fallback = props.default;
3222
+ return (typeof fallback === "string" ? fallback : fallback?.default) ?? "auto";
2763
3223
  }
2764
3224
  function vtSsrOpenTagEnd(html, from) {
2765
3225
  let quote = 0;
@@ -2775,45 +3235,297 @@ function vtSsrOpenTagEnd(html, from) {
2775
3235
  }
2776
3236
  return -1;
2777
3237
  }
2778
- function vtSsrAnnotate(html, attrs) {
2779
- const start = vtSsrFirstVisibleOpenTag(html);
2780
- if (start === -1) return html;
2781
- const end = vtSsrOpenTagEnd(html, start + 1);
2782
- if (end === -1) return html;
2783
- const open = html.slice(start, end);
3238
+ function vtSsrMapTags(html, visit, visitText, visitAllElements = false, rootOnly = false) {
3239
+ let depth = 0;
3240
+ let from = 0;
3241
+ let copied = 0;
3242
+ let out = "";
3243
+ while (from < html.length) {
3244
+ const start = html.indexOf("<", from);
3245
+ if (visitText && (!rootOnly || depth === 0))
3246
+ visitText(html.slice(from, start < 0 ? html.length : start), depth);
3247
+ if (start < 0) break;
3248
+ if (html.startsWith("<!--", start)) {
3249
+ const end2 = html.indexOf("-->", start + 4);
3250
+ if (end2 < 0) break;
3251
+ from = end2 + 3;
3252
+ continue;
3253
+ }
3254
+ const closing = html[start + 1] === "/";
3255
+ const nameStart = start + (closing ? 2 : 1);
3256
+ const initial = html.charCodeAt(nameStart);
3257
+ if (!(initial >= 65 && initial <= 90 || initial >= 97 && initial <= 122)) {
3258
+ from = start + 1;
3259
+ continue;
3260
+ }
3261
+ let nameEnd = nameStart + 1;
3262
+ while (nameEnd < html.length) {
3263
+ const code = html.charCodeAt(nameEnd);
3264
+ if (!(code >= 65 && code <= 90 || code >= 97 && code <= 122 || code >= 48 && code <= 57 || code === 58 || code === 45))
3265
+ break;
3266
+ nameEnd++;
3267
+ }
3268
+ const tag = html.slice(nameStart, nameEnd).toLowerCase();
3269
+ const end = vtSsrOpenTagEnd(html, nameStart + tag.length);
3270
+ if (end < 0) break;
3271
+ from = end + 1;
3272
+ if (closing) {
3273
+ depth = Math.max(0, depth - 1);
3274
+ continue;
3275
+ }
3276
+ const inert = tag === "template" || tag === "script" || tag === "style" || tag === "title";
3277
+ const isVoid = VOID_ELEMENTS.has(tag) || html[end - 1] === "/";
3278
+ if ((!rootOnly || depth === 0) && (visitAllElements || !inert && tag !== "link" && tag !== "meta" && tag !== "base" && tag !== "option")) {
3279
+ const open = html.slice(start, end + 1);
3280
+ const next = visit(open, depth, tag);
3281
+ if (next !== open) {
3282
+ out += html.slice(copied, start) + next;
3283
+ copied = end + 1;
3284
+ }
3285
+ }
3286
+ if (inert) {
3287
+ const close = new RegExp("</" + tag + "[\\t\\n\\f\\r ]*>", "gi");
3288
+ close.lastIndex = from;
3289
+ from = close.exec(html) === null ? html.length : close.lastIndex;
3290
+ continue;
3291
+ }
3292
+ if (!isVoid) depth++;
3293
+ }
3294
+ return copied === 0 ? html : out + html.slice(copied);
3295
+ }
3296
+ function vtSsrInject(open, attrs) {
3297
+ let existing;
3298
+ if (/vt-/i.test(open)) {
3299
+ existing = /* @__PURE__ */ new Set();
3300
+ vtSsrAttributes(open, (name) => {
3301
+ existing.add(name);
3302
+ });
3303
+ }
2784
3304
  let inject = "";
2785
- for (let index = 0; index < attrs.length; index++) {
2786
- if (open.indexOf(attrs[index][0] + '="') === -1) {
2787
- inject += " " + attrs[index][0] + '="' + escapeAttr(attrs[index][1]) + '"';
3305
+ for (const [name, value] of attrs) {
3306
+ if (!existing?.has(name)) inject += " " + name + '="' + escapeAttr(value) + '"';
3307
+ }
3308
+ if (inject === "") return open;
3309
+ const insertion = open[open.length - 2] === "/" ? open.length - 2 : open.length - 1;
3310
+ return open.slice(0, insertion) + inject + open.slice(insertion);
3311
+ }
3312
+ function vtSsrAnnotate(html, attrs) {
3313
+ let index = 0;
3314
+ return vtSsrMapTags(
3315
+ html,
3316
+ (open, depth) => {
3317
+ if (depth !== 0) return open;
3318
+ const suffix = index++;
3319
+ return vtSsrInject(
3320
+ open,
3321
+ suffix === 0 ? attrs : attrs.map(([name, value]) => [name, name === "vt-name" ? value + "-" + suffix : value])
3322
+ );
3323
+ },
3324
+ void 0,
3325
+ false,
3326
+ true
3327
+ );
3328
+ }
3329
+ function vtSsrSpace(code) {
3330
+ return code === 32 || code === 9 || code === 10 || code === 12 || code === 13;
3331
+ }
3332
+ function vtSsrAttributes(open, visit) {
3333
+ let i = 1;
3334
+ while (i < open.length && !vtSsrSpace(open.charCodeAt(i)) && open[i] !== "/" && open[i] !== ">")
3335
+ i++;
3336
+ while (i < open.length) {
3337
+ while (vtSsrSpace(open.charCodeAt(i))) i++;
3338
+ if (i >= open.length || open[i] === ">" || open[i] === "/") break;
3339
+ const start = i;
3340
+ while (i < open.length && !vtSsrSpace(open.charCodeAt(i)) && open[i] !== "=" && open[i] !== "/" && open[i] !== ">")
3341
+ i++;
3342
+ const nameEnd = i;
3343
+ const name = open.slice(start, i).toLowerCase();
3344
+ while (vtSsrSpace(open.charCodeAt(i))) i++;
3345
+ if (open[i] !== "=") {
3346
+ if (visit(name, nameEnd, nameEnd, "", start, nameEnd)) return;
3347
+ continue;
3348
+ }
3349
+ i++;
3350
+ while (vtSsrSpace(open.charCodeAt(i))) i++;
3351
+ const quote = open[i] === '"' || open[i] === "'" ? open[i++] : "";
3352
+ const valueStart = i;
3353
+ if (quote) {
3354
+ const closing = open.indexOf(quote, i);
3355
+ i = closing < 0 ? open.length : closing;
3356
+ } else {
3357
+ while (i < open.length && !vtSsrSpace(open.charCodeAt(i)) && open[i] !== ">") i++;
2788
3358
  }
3359
+ const valueEnd = i;
3360
+ if (quote) i++;
3361
+ if (visit(name, valueStart, valueEnd, quote, start, nameEnd)) return;
2789
3362
  }
2790
- if (inject === "") return html;
2791
- const insertion = html[end - 1] === "/" ? end - 1 : end;
2792
- return html.slice(0, insertion) + inject + html.slice(insertion);
3363
+ }
3364
+ function vtSsrAttribute(open, wanted) {
3365
+ let result = null;
3366
+ vtSsrAttributes(open, (name, start, end, quote, nameStart, nameEnd) => {
3367
+ if (name !== wanted) return;
3368
+ result = { start, end, quote, nameStart, nameEnd };
3369
+ return true;
3370
+ });
3371
+ return result;
3372
+ }
3373
+ function vtSsrAnnotateScope(html) {
3374
+ let roots = 0;
3375
+ let sentinel = false;
3376
+ let text = false;
3377
+ vtSsrMapTags(
3378
+ html,
3379
+ (open, depth, tag) => {
3380
+ if (depth === 0) {
3381
+ if (tag === "template" && vtSsrAttribute(open, STREAM_BOUNDARY_ATTR) !== null)
3382
+ sentinel = true;
3383
+ else roots++;
3384
+ }
3385
+ return open;
3386
+ },
3387
+ (value, depth) => {
3388
+ if (depth === 0 && /\S/.test(value)) text = true;
3389
+ },
3390
+ true,
3391
+ true
3392
+ );
3393
+ const valid = roots === 1 && !sentinel && !text;
3394
+ if (valid)
3395
+ injectStyle(
3396
+ "octane-view-transition-scope",
3397
+ '[vt-scope="element"]{view-transition-scope:all!important}'
3398
+ );
3399
+ return vtSsrMapTags(
3400
+ html,
3401
+ (open) => vtSsrInject(open, [["vt-scope", valid ? "element" : "none"]]),
3402
+ void 0,
3403
+ true,
3404
+ true
3405
+ );
2793
3406
  }
2794
3407
  function vtSsrClaimArm(html, kind) {
2795
3408
  if (!VT_SSR_HAS_CANDIDATES) return html;
2796
- const start = vtSsrFirstVisibleOpenTag(html);
2797
- if (start === -1) return html;
2798
- const end = vtSsrOpenTagEnd(html, start + 1);
2799
- if (end === -1) return html;
2800
- const marker = " vt-" + kind + '-x="';
2801
- const offset = html.slice(start, end).indexOf(marker);
2802
- if (offset === -1) return html;
2803
- const insertion = start + offset;
2804
- return html.slice(0, insertion) + " vt-" + kind + '="' + html.slice(insertion + marker.length);
2805
- }
2806
- function vtSsrStrip(html) {
2807
- if (html.indexOf(" vt-e") === -1) return html;
2808
- return html.replace(/ vt-(?:enter|exit)-x="[^"]*"/g, "");
3409
+ const active = [];
3410
+ const eventName = "vt-" + kind;
3411
+ const candidateName = eventName + "-x";
3412
+ const relayName = "vt-parent-" + kind + "-x";
3413
+ return vtSsrMapTags(html, (open, depth) => {
3414
+ let candidate;
3415
+ let candidateEnd = -1;
3416
+ let event;
3417
+ let eventStart = Infinity;
3418
+ let relay;
3419
+ let relayEnd = -1;
3420
+ if (/vt-/i.test(open))
3421
+ vtSsrAttributes(open, (name, start, end, _quote, nameStart, nameEnd) => {
3422
+ if (name === candidateName && candidate === void 0) {
3423
+ candidate = open.slice(start, end);
3424
+ candidateEnd = nameEnd;
3425
+ } else if (name === eventName && event === void 0) {
3426
+ event = open.slice(start, end);
3427
+ eventStart = nameStart;
3428
+ } else if (name === relayName && relay === void 0) {
3429
+ relay = open.slice(start, end);
3430
+ relayEnd = nameEnd;
3431
+ }
3432
+ });
3433
+ let claimEnd = -1;
3434
+ if (depth === 0 && candidate !== void 0 && candidate !== "none") {
3435
+ claimEnd = candidateEnd;
3436
+ if (candidateEnd < eventStart) event = candidate;
3437
+ }
3438
+ const parentActive = depth > 0 && active[depth - 1];
3439
+ if (parentActive && relay !== void 0 && relay !== "none" && relay !== "auto") {
3440
+ claimEnd = relayEnd;
3441
+ }
3442
+ active[depth] = event !== void 0 && event !== "none" || parentActive && (relay === void 0 || relay !== "none");
3443
+ return claimEnd < 0 ? open : open.slice(0, claimEnd - 2) + open.slice(claimEnd);
3444
+ });
3445
+ }
3446
+ const VT_SSR_STRIP = / vt-(?:parent-)?(?:enter|exit)-x="[^"]*"(?=[^<>"]*(?:"[^"]*"[^<>"]*)*>)/gi;
3447
+ const VT_SSR_OPAQUE = /<!--|<(script|style|title|template)(?=[\t\n\f\r />])/gi;
3448
+ const VT_SSR_CANDIDATE = /vt-(?:parent-)?(?:enter|exit)-x/i;
3449
+ function vtSsrStrip(html, rawHtml) {
3450
+ if (!rawHtml) {
3451
+ let lower = html.indexOf('-x="');
3452
+ let upper = html.indexOf('-X="');
3453
+ if (lower < 0 && upper < 0) return html;
3454
+ const advance = (from2) => {
3455
+ if (lower >= 0 && lower < from2) lower = html.indexOf('-x="', from2);
3456
+ if (upper >= 0 && upper < from2) upper = html.indexOf('-X="', from2);
3457
+ return lower < 0 ? upper : upper < 0 ? lower : Math.min(lower, upper);
3458
+ };
3459
+ let candidate = advance(0);
3460
+ let from = 0;
3461
+ let copied = 0;
3462
+ let out = "";
3463
+ VT_SSR_OPAQUE.lastIndex = 0;
3464
+ let opaque;
3465
+ while ((opaque = VT_SSR_OPAQUE.exec(html)) !== null) {
3466
+ const start = opaque.index;
3467
+ const attr = html.slice(from, start).lastIndexOf('="');
3468
+ if (attr >= 0 && html.indexOf('"', from + attr + 2) > start) {
3469
+ rawHtml = true;
3470
+ break;
3471
+ }
3472
+ if (candidate < start) {
3473
+ const part = html.slice(from, start);
3474
+ const next = part.replace(VT_SSR_STRIP, "");
3475
+ if (next !== part) {
3476
+ out += html.slice(copied, from) + next;
3477
+ copied = start;
3478
+ }
3479
+ candidate = advance(start);
3480
+ if (candidate < 0) return copied === 0 ? html : out + html.slice(copied);
3481
+ }
3482
+ const tag = opaque[1];
3483
+ let end;
3484
+ if (tag === void 0) {
3485
+ const close = html.indexOf("-->", start + 4);
3486
+ end = close < 0 ? html.length : close + 3;
3487
+ } else {
3488
+ const openingEnd = vtSsrOpenTagEnd(html, start + tag.length + 1) + 1;
3489
+ const close = html.indexOf("</" + tag + ">", openingEnd);
3490
+ if (close >= 0) end = close + tag.length + 3;
3491
+ else {
3492
+ const closing = new RegExp("</" + tag + "[\\t\\n\\f\\r ]*>", "gi");
3493
+ closing.lastIndex = openingEnd;
3494
+ end = closing.exec(html) === null ? html.length : closing.lastIndex;
3495
+ }
3496
+ }
3497
+ if (candidate < end) {
3498
+ candidate = advance(end);
3499
+ if (candidate < 0) return copied === 0 ? html : out + html.slice(copied);
3500
+ }
3501
+ from = VT_SSR_OPAQUE.lastIndex = end;
3502
+ }
3503
+ if (!rawHtml)
3504
+ return out + html.slice(copied, from) + html.slice(from).replace(VT_SSR_STRIP, "");
3505
+ }
3506
+ if (!VT_SSR_CANDIDATE.test(html)) return html;
3507
+ return vtSsrMapTags(html, (open) => {
3508
+ if (!VT_SSR_CANDIDATE.test(open)) return open;
3509
+ let out = "";
3510
+ let copied = 0;
3511
+ vtSsrAttributes(open, (name, _start, end, quote, nameStart) => {
3512
+ if (name === "vt-enter-x" || name === "vt-exit-x" || name === "vt-parent-enter-x" || name === "vt-parent-exit-x") {
3513
+ const start = vtSsrSpace(open.charCodeAt(nameStart - 1)) ? nameStart - 1 : nameStart;
3514
+ out += open.slice(copied, start);
3515
+ copied = end + (quote ? 1 : 0);
3516
+ }
3517
+ });
3518
+ return copied === 0 ? open : out + open.slice(copied);
3519
+ });
2809
3520
  }
2810
3521
  const ViewTransition = /* @__PURE__ */ markComponentFlags(
2811
3522
  function ViewTransition2(props, scope) {
2812
3523
  VT_SSR_HAS_CANDIDATES = true;
2813
- const explicit = typeof props.name === "string";
3524
+ const explicit = typeof props.name === "string" && props.name !== "auto";
2814
3525
  const frame = FRAME;
2815
3526
  const cand = {
2816
- name: explicit ? props.name : "_O" + (frame !== null ? framePath(frame).replace(/\//g, "-") : "") + "_",
3527
+ elementScope: props.scope === "element",
3528
+ name: explicit ? props.name : "_O" + ID_PREFIX + (STREAM !== null ? STREAM.token + "-" : "") + (frame !== null ? framePath(frame).replace(/\//g, "-") : "") + "_",
2817
3529
  share: vtSsrResolve(props, "share"),
2818
3530
  update: vtSsrResolve(props, "update"),
2819
3531
  consumed: false
@@ -2826,14 +3538,21 @@ const ViewTransition = /* @__PURE__ */ markComponentFlags(
2826
3538
  } finally {
2827
3539
  VT_SSR_STACK.pop();
2828
3540
  }
2829
- const named = explicit || VT_SSR_TRY_SEQ !== seqBefore;
3541
+ const named = explicit || props.scope !== "element" && VT_SSR_TRY_SEQ !== seqBefore;
2830
3542
  const attrs = [];
2831
3543
  if (named) attrs.push(["vt-name", cand.name]);
2832
3544
  attrs.push(["vt-update", cand.update]);
2833
3545
  attrs.push(["vt-enter-x", vtSsrResolve(props, "enter")]);
2834
3546
  attrs.push(["vt-exit-x", vtSsrResolve(props, "exit")]);
2835
- if (named) attrs.push(["vt-share", cand.share]);
2836
- return ssrHtml(ssrBlock(vtSsrAnnotate(inner, attrs)));
3547
+ if (named) attrs.push(["vt-share", VT_SSR_TRY_SEQ !== seqBefore ? cand.update : cand.share]);
3548
+ for (const kind of ["Enter", "Exit"]) {
3549
+ const prop = props["parent" + kind];
3550
+ const value = prop === void 0 ? void 0 : vtSsrResolve(props, "parent" + kind);
3551
+ const handler = props["onParent" + kind];
3552
+ attrs.push(["vt-parent-" + kind.toLowerCase() + "-x", value ?? (handler ? "auto" : "none")]);
3553
+ }
3554
+ const annotated = vtSsrAnnotate(inner, attrs);
3555
+ return ssrHtml(ssrBlock(props.scope === "element" ? vtSsrAnnotateScope(annotated) : annotated));
2837
3556
  },
2838
3557
  COMPONENT_FLAG_BOUNDARY,
2839
3558
  "ViewTransition"
@@ -2932,7 +3651,8 @@ function normalizeThrownServerThenable(error) {
2932
3651
  comp: CURRENT_COMP,
2933
3652
  props: CURRENT_PROPS,
2934
3653
  parentScope: CURRENT_PARENT_SCOPE,
2935
- frame
3654
+ frame,
3655
+ signalInstanceKey: SIGNAL_COMPONENT_INSTANCE_KEY
2936
3656
  });
2937
3657
  }
2938
3658
  return SSR_SUSPENSE;
@@ -3204,7 +3924,8 @@ function use(usable, siteKey, directSite) {
3204
3924
  comp: CURRENT_COMP,
3205
3925
  props: CURRENT_PROPS,
3206
3926
  parentScope: CURRENT_PARENT_SCOPE,
3207
- frame
3927
+ frame,
3928
+ signalInstanceKey: SIGNAL_COMPONENT_INSTANCE_KEY
3208
3929
  });
3209
3930
  }
3210
3931
  throw SSR_SUSPENSE;
@@ -3371,7 +4092,8 @@ function puBatch(thenables, warm) {
3371
4092
  comp: CURRENT_COMP,
3372
4093
  props: CURRENT_PROPS,
3373
4094
  parentScope: CURRENT_PARENT_SCOPE,
3374
- frame
4095
+ frame,
4096
+ signalInstanceKey: SIGNAL_COMPONENT_INSTANCE_KEY
3375
4097
  });
3376
4098
  }
3377
4099
  throw SSR_SUSPENSE;
@@ -3535,7 +4257,8 @@ function lazy(load) {
3535
4257
  comp: CURRENT_COMP,
3536
4258
  props: CURRENT_PROPS,
3537
4259
  parentScope: CURRENT_PARENT_SCOPE,
3538
- frame
4260
+ frame,
4261
+ signalInstanceKey: SIGNAL_COMPONENT_INSTANCE_KEY
3539
4262
  });
3540
4263
  }
3541
4264
  throw SSR_SUSPENSE;
@@ -3862,7 +4585,12 @@ function isChildrenBlock(value) {
3862
4585
  return typeof value === "function" && value[CHILDREN_BLOCK] === true;
3863
4586
  }
3864
4587
  function injectStyle(id, css, nonce) {
3865
- if (CSS !== null) CSS.set(id, nonce === void 0 ? { css } : { css, nonce });
4588
+ if (CSS !== null) {
4589
+ const previous = CSS.get(id);
4590
+ if (previous !== void 0 && previous.css === css && previous.nonce === nonce) return;
4591
+ CSS.replay = null;
4592
+ CSS.set(id, nonce === void 0 ? { css } : { css, nonce });
4593
+ }
3866
4594
  }
3867
4595
  function styleMap(id, css, map, applied = []) {
3868
4596
  let touching = false;
@@ -4016,9 +4744,26 @@ function serializeNativeSignalSeeds(signals, nonceAttr, attr = NATIVE_SIGNAL_SEE
4016
4744
  const json = JSON.stringify(signals).replace(/</g, "\\u003c");
4017
4745
  return '<script type="application/json" ' + attr + nonceAttr + ">" + json + "</script>";
4018
4746
  }
4747
+ let SERVER_SIGNAL_BINDINGS_ENABLED = false;
4748
+ let SERVER_SIGNAL_BINDINGS_POTENTIAL = false;
4749
+ function enableServerSignalBindings(abi = 1, potentialOnly = false) {
4750
+ if (abi !== 1) throw new TypeError(formatServerError(71));
4751
+ SERVER_SIGNAL_BINDINGS_POTENTIAL = true;
4752
+ if (!potentialOnly) SERVER_SIGNAL_BINDINGS_ENABLED = true;
4753
+ }
4754
+ function isRendererSignalOwner(owner) {
4755
+ return "documentOwner" in owner;
4756
+ }
4019
4757
  function newResolvedMap(resourceOptions) {
4020
4758
  const m = /* @__PURE__ */ new Map();
4021
4759
  if (resourceOptions !== void 0) m.resourceOptions = resourceOptions;
4760
+ if (SERVER_SIGNAL_BINDINGS_ENABLED || resourceOptions?.signalOwner !== void 0) {
4761
+ const ambient = currentSignalOwner();
4762
+ const configured = resourceOptions?.signalOwner ?? ambient;
4763
+ m.signalOwner = configured === void 0 || configured === null ? Object.freeze({ scopeKey: "octane:document" }) : isRendererSignalOwner(configured) ? configured.documentOwner : configured;
4764
+ m.ownedSignalOwner = configured === void 0 || configured === null;
4765
+ m.signalInstances = /* @__PURE__ */ new Map();
4766
+ }
4022
4767
  m.asyncIdentities = /* @__PURE__ */ new Map();
4023
4768
  m.asyncPositionIdentities = /* @__PURE__ */ new Map();
4024
4769
  m.nextAsyncIdentity = 0;
@@ -4052,8 +4797,23 @@ function getServerRenderResourceContext() {
4052
4797
  return resources;
4053
4798
  }
4054
4799
  function releaseServerRenderResources(resolved) {
4800
+ const settlements = resolved.streamSettlements;
4801
+ if (settlements !== void 0) {
4802
+ resolved.streamSettlements = void 0;
4803
+ settlements.resolved = null;
4804
+ settlements.wake = null;
4805
+ for (const recorder of settlements.pending.values()) recorder.keys = null;
4806
+ settlements.pending.clear();
4807
+ }
4055
4808
  const resources = resolved.resources;
4056
4809
  resolved.resourceOptions = void 0;
4810
+ if (resolved.signalInstances !== void 0) {
4811
+ for (const owner of resolved.signalInstances.values()) retireSignalOwnerIdentity(owner);
4812
+ resolved.signalInstances.clear();
4813
+ }
4814
+ if (resolved.ownedSignalOwner && resolved.signalOwner !== void 0) {
4815
+ retireSignalOwnerIdentity(resolved.signalOwner);
4816
+ }
4057
4817
  if (resources !== void 0) resolved.resources = void 0;
4058
4818
  if (resources === void 0 || resources.finished) return;
4059
4819
  resources.finished = true;
@@ -4079,6 +4839,11 @@ function saveAmbient() {
4079
4839
  warmClaims: CURRENT_PU_WARM_CLAIMS,
4080
4840
  id: ID_COUNTER,
4081
4841
  idPrefix: ID_PREFIX,
4842
+ signalInstancePrefix: SIGNAL_INSTANCE_PREFIX,
4843
+ signalComponentInstanceKey: SIGNAL_COMPONENT_INSTANCE_KEY,
4844
+ signalOwnerActive: SERVER_SIGNAL_OWNER_ACTIVE,
4845
+ signalControlSite: SIGNAL_CONTROL_SITE,
4846
+ signalListKeys: SIGNAL_LIST_KEYS,
4082
4847
  css: CSS,
4083
4848
  nonceAttr: NONCE_ATTR,
4084
4849
  markers: MARKERS,
@@ -4098,6 +4863,7 @@ function saveAmbient() {
4098
4863
  nestingWarnings: SSR_NESTING_WARNINGS,
4099
4864
  vtTrySeq: VT_SSR_TRY_SEQ,
4100
4865
  vtHasCandidates: VT_SSR_HAS_CANDIDATES,
4866
+ vtHasRawHtml: VT_SSR_HAS_RAW_HTML,
4101
4867
  vtStack: snapshotVtStack()
4102
4868
  };
4103
4869
  }
@@ -4131,6 +4897,11 @@ function restoreAmbient(a) {
4131
4897
  CURRENT_PU_WARM_CLAIMS = a.warmClaims;
4132
4898
  ID_COUNTER = a.id;
4133
4899
  ID_PREFIX = a.idPrefix;
4900
+ SIGNAL_INSTANCE_PREFIX = a.signalInstancePrefix;
4901
+ SIGNAL_COMPONENT_INSTANCE_KEY = a.signalComponentInstanceKey;
4902
+ SERVER_SIGNAL_OWNER_ACTIVE = a.signalOwnerActive;
4903
+ SIGNAL_CONTROL_SITE = a.signalControlSite;
4904
+ SIGNAL_LIST_KEYS = a.signalListKeys;
4134
4905
  CSS = a.css;
4135
4906
  NONCE_ATTR = a.nonceAttr;
4136
4907
  MARKERS = a.markers;
@@ -4150,6 +4921,7 @@ function restoreAmbient(a) {
4150
4921
  SSR_NESTING_WARNINGS = a.nestingWarnings;
4151
4922
  VT_SSR_TRY_SEQ = a.vtTrySeq;
4152
4923
  VT_SSR_HAS_CANDIDATES = a.vtHasCandidates;
4924
+ VT_SSR_HAS_RAW_HTML = a.vtHasRawHtml;
4153
4925
  VT_SSR_STACK.length = 0;
4154
4926
  for (const snapshot of a.vtStack) {
4155
4927
  snapshot.candidate.consumed = snapshot.consumed;
@@ -4170,15 +4942,22 @@ function runFullFramedPass(component, props, resolved, nonceAttr = "", identifie
4170
4942
  CURRENT_PU_WARM_CLAIMS = null;
4171
4943
  ID_COUNTER = 0;
4172
4944
  ID_PREFIX = identifierPrefix;
4945
+ SIGNAL_INSTANCE_PREFIX = identifierPrefix;
4946
+ SIGNAL_COMPONENT_INSTANCE_KEY = JSON.stringify([identifierPrefix, "root"]);
4947
+ SERVER_SIGNAL_OWNER_ACTIVE = false;
4948
+ SIGNAL_CONTROL_SITE = "";
4949
+ SIGNAL_LIST_KEYS = EMPTY_SIGNAL_LIST_KEYS;
4173
4950
  NONCE_ATTR = nonceAttr;
4174
4951
  ASYNC_SCOPE = "";
4175
4952
  MARKERS = markers;
4176
4953
  PERMANENT_STATIC_HYDRATE_DEPTH = 0;
4177
4954
  VT_SSR_TRY_SEQ = 0;
4178
4955
  VT_SSR_HAS_CANDIDATES = false;
4956
+ VT_SSR_HAS_RAW_HTML = false;
4179
4957
  VT_SSR_STACK.length = 0;
4180
- const cssMap = CSS = /* @__PURE__ */ new Map();
4958
+ const cssMap = CSS = newStyleCollector();
4181
4959
  const headBuf = HEAD = {
4960
+ replay: null,
4182
4961
  html: "",
4183
4962
  charset: "",
4184
4963
  viewport: "",
@@ -4213,6 +4992,7 @@ function runFullFramedPass(component, props, resolved, nonceAttr = "", identifie
4213
4992
  CURRENT_PARENT_SCOPE = null;
4214
4993
  let body = "";
4215
4994
  let vtCandidates = false;
4995
+ let rawHtml = false;
4216
4996
  let rootSuspended = false;
4217
4997
  let signals;
4218
4998
  let nativePassCompleted = false;
@@ -4220,6 +5000,10 @@ function runFullFramedPass(component, props, resolved, nonceAttr = "", identifie
4220
5000
  try {
4221
5001
  const out = invokeComponentBody(component, props, root, FRAME);
4222
5002
  body = serverComponentOutput(out, root);
5003
+ if (markers && out !== null && typeof out === "object") {
5004
+ const marker = out[BINDING_HTML_ROOT];
5005
+ if (marker !== void 0) body = ssrBindingBlock(body, marker);
5006
+ }
4223
5007
  nativePassCompleted = true;
4224
5008
  } catch (err) {
4225
5009
  err = normalizeThrownServerThenable(err);
@@ -4227,12 +5011,18 @@ function runFullFramedPass(component, props, resolved, nonceAttr = "", identifie
4227
5011
  rootSuspended = true;
4228
5012
  } finally {
4229
5013
  vtCandidates = VT_SSR_HAS_CANDIDATES;
5014
+ rawHtml = VT_SSR_HAS_RAW_HTML;
4230
5015
  try {
4231
5016
  if (nativeToken >= 0) NATIVE_READ_COLLECTOR.endScope(nativeToken, nativePassCompleted);
4232
5017
  if (markers && nativePassCompleted)
4233
5018
  signals = NATIVE_READ_COLLECTOR?.serialize(NATIVE_SERVER_READS);
4234
5019
  } finally {
4235
- restoreAmbient(saved);
5020
+ try {
5021
+ restoreAmbient(saved);
5022
+ } finally {
5023
+ cssMap.replay = null;
5024
+ headBuf.replay = null;
5025
+ }
4236
5026
  }
4237
5027
  }
4238
5028
  if (resolved.bufferedErrors !== void 0) {
@@ -4256,8 +5046,10 @@ function runFullFramedPass(component, props, resolved, nonceAttr = "", identifie
4256
5046
  deferred,
4257
5047
  rootSuspended,
4258
5048
  vtCandidates,
5049
+ rawHtml,
4259
5050
  cssEntries: cssMap,
4260
- sheets: headBuf.sheets
5051
+ sheets: headBuf.sheets,
5052
+ hasSignalControls: resolved.hasSignalControls === true
4261
5053
  };
4262
5054
  if (signals !== void 0) result.signals = signals;
4263
5055
  return result;
@@ -4272,15 +5064,22 @@ function runDiscoveryRound(jobs, resolved, identifierPrefix) {
4272
5064
  CURRENT_PU_WARM_CLAIMS = null;
4273
5065
  ID_COUNTER = 0;
4274
5066
  ID_PREFIX = identifierPrefix;
5067
+ SIGNAL_INSTANCE_PREFIX = identifierPrefix;
5068
+ SIGNAL_COMPONENT_INSTANCE_KEY = JSON.stringify([identifierPrefix, "root"]);
5069
+ SERVER_SIGNAL_OWNER_ACTIVE = false;
5070
+ SIGNAL_CONTROL_SITE = "";
5071
+ SIGNAL_LIST_KEYS = EMPTY_SIGNAL_LIST_KEYS;
4275
5072
  NONCE_ATTR = "";
4276
5073
  ASYNC_SCOPE = "";
4277
5074
  MARKERS = true;
4278
5075
  PERMANENT_STATIC_HYDRATE_DEPTH = 0;
4279
5076
  VT_SSR_TRY_SEQ = 0;
4280
5077
  VT_SSR_HAS_CANDIDATES = false;
5078
+ VT_SSR_HAS_RAW_HTML = false;
4281
5079
  VT_SSR_STACK.length = 0;
4282
- CSS = /* @__PURE__ */ new Map();
5080
+ CSS = newStyleCollector();
4283
5081
  HEAD = {
5082
+ replay: null,
4284
5083
  html: "",
4285
5084
  charset: "",
4286
5085
  viewport: "",
@@ -4316,7 +5115,14 @@ function runDiscoveryRound(jobs, resolved, identifierPrefix) {
4316
5115
  namespace: void 0
4317
5116
  };
4318
5117
  try {
4319
- renderComponentFramed(job.comp, job.props, job.parentScope, frame);
5118
+ renderComponentFramed(
5119
+ job.comp,
5120
+ job.props,
5121
+ job.parentScope,
5122
+ frame,
5123
+ void 0,
5124
+ job.signalInstanceKey
5125
+ );
4320
5126
  } catch (err) {
4321
5127
  if (!ssrIsSuspense(err)) continue;
4322
5128
  }
@@ -4375,30 +5181,62 @@ async function settleSuspended(suspended, resolved, timeoutMs, signal) {
4375
5181
  await raceSettleGuards(settleAll, timeoutMs, signal);
4376
5182
  }
4377
5183
  const yieldMacrotask = typeof setImmediate === "function" ? () => new Promise((resolve) => setImmediate(resolve)) : () => new Promise((resolve) => setTimeout(resolve, 0));
5184
+ async function recordStreamSettlement(settlements, recorder) {
5185
+ let outcome;
5186
+ try {
5187
+ outcome = { value: await recorder.promise, thenable: recorder.promise };
5188
+ } catch (reason) {
5189
+ outcome = { reason, thenable: recorder.promise };
5190
+ }
5191
+ const resolved = settlements.resolved;
5192
+ if (resolved === null) return;
5193
+ if (!resolved.has(recorder.key)) resolved.set(recorder.key, outcome);
5194
+ if (recorder.keys !== null) {
5195
+ for (const key of recorder.keys) {
5196
+ if (!resolved.has(key)) resolved.set(key, outcome);
5197
+ }
5198
+ recorder.keys = null;
5199
+ }
5200
+ if (recorder.batch && !resolved.pu.resolvedT.has(recorder.promise)) {
5201
+ resolved.pu.resolvedT.set(recorder.promise, outcome);
5202
+ }
5203
+ settlements.pending.delete(recorder.promise);
5204
+ if (recorder.wave === settlements.wave) settlements.wake?.();
5205
+ }
4378
5206
  async function settleFirstOfWave(suspended, resolved, timeoutMs, signal) {
4379
5207
  const pu = resolved.pu;
4380
5208
  pu.recreate ??= { strikes: 0, prevCreated: pu.created.size };
4381
- const recorders = [];
5209
+ const settlements = resolved.streamSettlements ??= {
5210
+ resolved,
5211
+ pending: /* @__PURE__ */ new Map(),
5212
+ wave: 0,
5213
+ wake: null
5214
+ };
5215
+ const wave = ++settlements.wave;
5216
+ let waiting = false;
4382
5217
  for (const { promise, key } of suspended) {
4383
5218
  if (resolved.has(key)) continue;
4384
- const isPu = key.startsWith("|pu#");
4385
- recorders.push(
4386
- (async () => {
4387
- try {
4388
- const value = await promise;
4389
- const outcome = { value, thenable: promise };
4390
- if (!resolved.has(key)) resolved.set(key, outcome);
4391
- if (isPu && !pu.resolvedT.has(promise)) pu.resolvedT.set(promise, outcome);
4392
- } catch (reason) {
4393
- const outcome = { reason, thenable: promise };
4394
- if (!resolved.has(key)) resolved.set(key, outcome);
4395
- if (isPu && !pu.resolvedT.has(promise)) pu.resolvedT.set(promise, outcome);
4396
- }
4397
- })()
4398
- );
5219
+ let recorder = settlements.pending.get(promise);
5220
+ if (recorder === void 0) {
5221
+ recorder = { promise, key, keys: null, batch: key.startsWith("|pu#"), wave };
5222
+ settlements.pending.set(promise, recorder);
5223
+ void recordStreamSettlement(settlements, recorder);
5224
+ } else {
5225
+ if (key !== recorder.key) (recorder.keys ??= /* @__PURE__ */ new Set()).add(key);
5226
+ if (key.startsWith("|pu#")) recorder.batch = true;
5227
+ recorder.wave = wave;
5228
+ }
5229
+ waiting = true;
5230
+ }
5231
+ if (!waiting) return;
5232
+ const first = new Promise((resolve) => {
5233
+ settlements.wake = resolve;
5234
+ });
5235
+ try {
5236
+ await raceSettleGuards(first, timeoutMs, signal);
5237
+ } finally {
5238
+ settlements.wake = null;
4399
5239
  }
4400
- if (recorders.length === 0) return;
4401
- await raceSettleGuards(Promise.race(recorders), timeoutMs, signal);
4402
5240
  await yieldMacrotask();
4403
5241
  let size = resolved.size;
4404
5242
  for (; ; ) {
@@ -4502,38 +5340,129 @@ async function runBuffered(component, props, options, nonceAttr, resolved) {
4502
5340
  if (resolved.pu.touched !== void 0) resolved.pu.touched = /* @__PURE__ */ new Set();
4503
5341
  }
4504
5342
  }
4505
- function passToResult(pass, nonceAttr, separateHead = false) {
5343
+ function passToResult(pass, nonceAttr, separateHead = false, independentHydration = false, externalSignalBootstrap = false) {
4506
5344
  let body = pass.body;
4507
5345
  if (pass.serial.length > 0) body += serializeSuspenseSeeds(pass.serial, nonceAttr);
4508
5346
  if (pass.signals !== void 0) body += serializeNativeSignalSeeds(pass.signals, nonceAttr);
5347
+ if (!externalSignalBootstrap && (pass.hasSignalControls || independentHydration)) {
5348
+ body += "<script " + STREAM_SCRIPT_ATTR + nonceAttr + ">" + streamedSignalBootstrapJs(independentHydration) + "</script>";
5349
+ }
4509
5350
  let result;
4510
5351
  if (separateHead) {
4511
5352
  result = {
4512
- html: pass.vtCandidates ? vtSsrStrip(body) : body,
5353
+ html: pass.vtCandidates ? vtSsrStrip(body, pass.rawHtml) : body,
4513
5354
  css: pass.css,
4514
- head: pass.vtCandidates ? vtSsrStrip(pass.head) : pass.head
5355
+ head: pass.vtCandidates ? vtSsrStrip(pass.head, pass.rawHtml) : pass.head
4515
5356
  };
4516
5357
  } else {
4517
5358
  const html = spliceHead(body, pass.head);
4518
- result = { html: pass.vtCandidates ? vtSsrStrip(html) : html, css: pass.css };
5359
+ result = { html: pass.vtCandidates ? vtSsrStrip(html, pass.rawHtml) : html, css: pass.css };
4519
5360
  }
4520
5361
  if (pass.signals !== void 0) result.signals = pass.signals;
4521
5362
  return result;
4522
5363
  }
5364
+ async function collectBufferedInjection(injection, signal) {
5365
+ let revision = 0;
5366
+ let wake;
5367
+ let settled = false;
5368
+ let failed = false;
5369
+ let failure;
5370
+ const notify = () => {
5371
+ revision++;
5372
+ const resume = wake;
5373
+ wake = void 0;
5374
+ resume?.();
5375
+ };
5376
+ const unsubscribe = injection.subscribe(notify);
5377
+ signal?.addEventListener("abort", notify, { once: true });
5378
+ injection.done.then(
5379
+ () => {
5380
+ settled = true;
5381
+ notify();
5382
+ },
5383
+ (error) => {
5384
+ failed = true;
5385
+ failure = error;
5386
+ settled = true;
5387
+ notify();
5388
+ }
5389
+ );
5390
+ let html = "";
5391
+ try {
5392
+ injection.renderComplete?.();
5393
+ for (; ; ) {
5394
+ signal?.throwIfAborted();
5395
+ const chunk = injection.take();
5396
+ if (chunk !== "") {
5397
+ html += chunk;
5398
+ injection.accepted?.();
5399
+ continue;
5400
+ }
5401
+ if (settled) {
5402
+ if (failed) throw failure;
5403
+ return html;
5404
+ }
5405
+ const observed = revision;
5406
+ await new Promise((resolve) => {
5407
+ wake = resolve;
5408
+ if (settled || revision !== observed) {
5409
+ wake = void 0;
5410
+ resolve();
5411
+ }
5412
+ });
5413
+ }
5414
+ } finally {
5415
+ unsubscribe();
5416
+ signal?.removeEventListener("abort", notify);
5417
+ }
5418
+ }
5419
+ function insertBufferedInjection(pass, injection) {
5420
+ if (injection === "") return;
5421
+ const tailStart = documentTailStart(pass.body);
5422
+ pass.body = tailStart === -1 ? pass.body + injection : pass.body.slice(0, tailStart) + injection + pass.body.slice(tailStart);
5423
+ }
4523
5424
  async function prerender(entryComponent, props, options) {
4524
5425
  const component = typeof entryComponent === "function" ? entryComponent : renderEntryValue;
4525
5426
  if (typeof entryComponent !== "function") {
4526
5427
  options ??= props;
4527
5428
  props = { value: entryComponent };
4528
5429
  }
4529
- const nonceAttr = nonceAttrOf(options);
4530
- const resolved = newResolvedMap(options ?? null);
5430
+ const preparedOptions = needsAutomaticSignalInjection(options) ? await prepareAutomaticSignalInjection(options) : options;
5431
+ const injection = preparedOptions?.injection;
5432
+ const cancelRender = injection === void 0 ? void 0 : new AbortController();
5433
+ injection?.done.then(NOOP, (error) => cancelRender.abort(error));
5434
+ const renderOptions = cancelRender === void 0 ? preparedOptions : {
5435
+ ...preparedOptions,
5436
+ signal: preparedOptions?.signal === void 0 ? cancelRender.signal : AbortSignal.any([preparedOptions.signal, cancelRender.signal])
5437
+ };
5438
+ const nonceAttr = nonceAttrOf(renderOptions);
5439
+ const resolved = newResolvedMap(renderOptions ?? null);
4531
5440
  try {
5441
+ const pass = await runBuffered(component, props, renderOptions, nonceAttr, resolved);
5442
+ if (injection !== void 0) {
5443
+ try {
5444
+ insertBufferedInjection(
5445
+ pass,
5446
+ await collectBufferedInjection(injection, renderOptions?.signal)
5447
+ );
5448
+ } catch (error) {
5449
+ renderOptions?.onError?.(error);
5450
+ throw error;
5451
+ }
5452
+ }
4532
5453
  return passToResult(
4533
- await runBuffered(component, props, options, nonceAttr, resolved),
5454
+ pass,
4534
5455
  nonceAttr,
4535
- options?.headChannel === "separate"
5456
+ renderOptions?.headChannel === "separate",
5457
+ renderOptions?.independentHydration !== void 0,
5458
+ renderOptions?.earlySignalBootstrap === "external"
4536
5459
  );
5460
+ } catch (error) {
5461
+ try {
5462
+ injection?.cancel?.(error);
5463
+ } catch {
5464
+ }
5465
+ throw error;
4537
5466
  } finally {
4538
5467
  releaseServerRenderResources(resolved);
4539
5468
  }
@@ -4623,7 +5552,7 @@ function renderHostedAttempt(session, component, props, options) {
4623
5552
  let body = pass.body;
4624
5553
  if (pass.serial.length > 0) body += serializeSuspenseSeeds(pass.serial, nonceAttr);
4625
5554
  if (pass.signals !== void 0) body += serializeNativeSignalSeeds(pass.signals, nonceAttr);
4626
- if (pass.vtCandidates) body = vtSsrStrip(body);
5555
+ if (pass.vtCandidates) body = vtSsrStrip(body, pass.rawHtml);
4627
5556
  return { status: "complete", html: body, head: pass.head, cssEntries: pass.cssEntries };
4628
5557
  }
4629
5558
  function renderToString(entryComponent, props, options) {
@@ -4648,7 +5577,13 @@ function renderToString(entryComponent, props, options) {
4648
5577
  } finally {
4649
5578
  releaseServerRenderResources(resolved);
4650
5579
  }
4651
- return passToResult(pass, nonceAttr, options?.headChannel === "separate");
5580
+ return passToResult(
5581
+ pass,
5582
+ nonceAttr,
5583
+ options?.headChannel === "separate",
5584
+ options?.independentHydration !== void 0,
5585
+ options?.earlySignalBootstrap === "external"
5586
+ );
4652
5587
  }
4653
5588
  function renderToStaticMarkup(entryComponent, props, options) {
4654
5589
  const component = typeof entryComponent === "function" ? entryComponent : renderEntryValue;
@@ -4681,13 +5616,19 @@ function renderToStaticMarkup(entryComponent, props, options) {
4681
5616
  }
4682
5617
  if (options?.headChannel === "separate") {
4683
5618
  return {
4684
- html: pass.vtCandidates ? vtSsrStrip(pass.body) : pass.body,
5619
+ html: pass.vtCandidates ? vtSsrStrip(pass.body, pass.rawHtml) : pass.body,
4685
5620
  css: pass.css,
4686
- head: pass.vtCandidates ? vtSsrStrip(pass.head) : pass.head
5621
+ head: pass.vtCandidates ? vtSsrStrip(pass.head, pass.rawHtml) : pass.head
4687
5622
  };
4688
5623
  }
4689
5624
  const html = spliceHead(pass.body, pass.head);
4690
- return { html: pass.vtCandidates ? vtSsrStrip(html) : html, css: pass.css };
5625
+ return { html: pass.vtCandidates ? vtSsrStrip(html, pass.rawHtml) : html, css: pass.css };
5626
+ }
5627
+ function hasPendingStreamBoundary(stream) {
5628
+ for (const boundary of stream.boundaries.values()) {
5629
+ if (boundary.state === "pending") return true;
5630
+ }
5631
+ return false;
4691
5632
  }
4692
5633
  function recordStreamBoundaryMutation(stream, key) {
4693
5634
  if (stream.replay === null) return;
@@ -4771,7 +5712,7 @@ function ssrTry(scope, siteKey, tryFn, pendFn, catchFn, namespace = FRAME?.names
4771
5712
  let vtOuter = null;
4772
5713
  if (VT_SSR_STACK.length > 0) {
4773
5714
  const top = VT_SSR_STACK[VT_SSR_STACK.length - 1];
4774
- if (!top.consumed) {
5715
+ if (!top.consumed && !top.elementScope) {
4775
5716
  top.consumed = true;
4776
5717
  vtOuter = top;
4777
5718
  }
@@ -4904,15 +5845,16 @@ function ssrTry(scope, siteKey, tryFn, pendFn, catchFn, namespace = FRAME?.names
4904
5845
  const deferredStart = DEFERRED?.length ?? 0;
4905
5846
  const serialStart2 = SERIAL?.length ?? 0;
4906
5847
  const css = CSS;
4907
- const cssSnapshot = snapshotMap(css);
5848
+ const cssSnapshot = snapshotStyles(css);
4908
5849
  const head = HEAD;
5850
+ const headCollections = snapshotHeadCollections(head);
4909
5851
  const headHtml = head?.html;
4910
5852
  const headCharset = head?.charset;
4911
5853
  const headViewport = head?.viewport;
4912
- const headHints = snapshotSet(head?.hints);
4913
- const headSheets = snapshotMap(head?.sheets);
4914
- const headHintHtml = snapshotMap(head?.hintHtml);
4915
- const headXfer = snapshotMap(head?.preloadXfer);
5854
+ const headHints = headCollections?.hints ?? null;
5855
+ const headSheets = headCollections?.sheets ?? null;
5856
+ const headHintHtml = headCollections?.hintHtml ?? null;
5857
+ const headXfer = headCollections?.preloadXfer ?? null;
4916
5858
  const vtTrySeq = VT_SSR_TRY_SEQ;
4917
5859
  const vtHasCandidates = VT_SSR_HAS_CANDIDATES;
4918
5860
  const vtStack = snapshotVtStack();
@@ -4928,10 +5870,12 @@ function ssrTry(scope, siteKey, tryFn, pendFn, catchFn, namespace = FRAME?.names
4928
5870
  if (DEFERRED !== null) DEFERRED.length = deferredStart;
4929
5871
  if (SERIAL !== null) SERIAL.length = serialStart2;
4930
5872
  if (css !== null && cssSnapshot !== null) {
5873
+ css.replay = null;
4931
5874
  css.clear();
4932
5875
  for (const [hash, sheet] of cssSnapshot) css.set(hash, sheet);
4933
5876
  }
4934
5877
  if (head !== null && headHints !== null) {
5878
+ head.replay = null;
4935
5879
  head.html = headHtml;
4936
5880
  head.charset = headCharset;
4937
5881
  head.viewport = headViewport;
@@ -4991,10 +5935,11 @@ function ssrTry(scope, siteKey, tryFn, pendFn, catchFn, namespace = FRAME?.names
4991
5935
  if (!entry.serverOwnedStatic)
4992
5936
  entry.signals = NATIVE_READ_COLLECTOR?.serialize(nativeReads);
4993
5937
  entry.state = "done";
5938
+ entry.rawHtml = VT_SSR_HAS_RAW_HTML;
4994
5939
  entry.html = vtOuter !== null ? vtSsrAnnotate(inner, [
4995
5940
  ["vt-name", vtOuter.name],
4996
5941
  ["vt-update", vtOuter.update],
4997
- ["vt-share", vtOuter.share]
5942
+ ["vt-share", vtOuter.update]
4998
5943
  ]) : inner;
4999
5944
  if (SERIAL !== null) {
5000
5945
  if (!entry.serverOwnedStatic) entry.seeds = SERIAL.slice(serialStart);
@@ -5034,6 +5979,7 @@ function ssrTry(scope, siteKey, tryFn, pendFn, catchFn, namespace = FRAME?.names
5034
5979
  state: "pending",
5035
5980
  serverOwnedStatic: PERMANENT_STATIC_HYDRATE_DEPTH !== 0,
5036
5981
  html: "",
5982
+ rawHtml: false,
5037
5983
  seeds: [],
5038
5984
  pendingIdOffset,
5039
5985
  namespace,
@@ -5076,6 +6022,7 @@ function ssrTry(scope, siteKey, tryFn, pendFn, catchFn, namespace = FRAME?.names
5076
6022
  }
5077
6023
  entry.state = "done";
5078
6024
  entry.html = inner;
6025
+ entry.rawHtml = VT_SSR_HAS_RAW_HTML;
5079
6026
  entry.seeds = nativeFresh ? [] : caughtSeeds;
5080
6027
  pruneUnrepresentedStreamDescendants(stream, key, entry.html);
5081
6028
  } else if (SERIAL !== null) {
@@ -5101,6 +6048,7 @@ function ssrTry(scope, siteKey, tryFn, pendFn, catchFn, namespace = FRAME?.names
5101
6048
  serverOwnedStatic: false,
5102
6049
  error: e,
5103
6050
  html: "",
6051
+ rawHtml: false,
5104
6052
  seeds: [],
5105
6053
  pendingIdOffset,
5106
6054
  namespace,
@@ -5140,7 +6088,230 @@ function ssrTry(scope, siteKey, tryFn, pendFn, catchFn, namespace = FRAME?.names
5140
6088
  }
5141
6089
  let STREAM_RUNTIME_JS;
5142
6090
  function streamRuntimeJs() {
5143
- return STREAM_RUNTIME_JS ??= "(function(){var d=document;var S=window.$OCTS=window.$OCTS||{};var M=function(v,c){if(v===c)return 1;if(!v||v.charAt(0)!==c)return 0;var s=v.slice(1),n=+s;return n>=2&&Number.isSafeInteger(n)&&String(n)===s;};window.$OCTRC=function(id,nc){var t=d.querySelector('template[" + STREAM_BOUNDARY_ATTR + `="'+id+'"]');var s=d.querySelector('[` + STREAM_SEGMENT_ATTR + `="'+id+'"]');if(!s)return;if(!t){s.remove();return;}var q=s.firstElementChild,z=d.createElement("template"),c=s;if(q&&q.localName==="script"){try{z.innerHTML=JSON.parse(q.textContent);c=z.content;}catch(e){return;}}var sd=c.querySelector("script[` + STREAM_SEED_ATTR + ']");if(sd){S[id]=sd.textContent;sd.parentNode.removeChild(sd);}var ns=c.firstElementChild;while(ns&&!(ns.localName==="script"&&ns.hasAttribute("' + NATIVE_SIGNAL_SEED_ATTR + '")))ns=ns.nextElementSibling;if(ns){S[id+"$signals"]=ns.textContent;ns.parentNode.removeChild(ns);}if(nc)c=c.firstElementChild;var n=t.nextSibling,depth=1;while(n){var x=n.nextSibling,v=n.nodeType===8?n.data:null;if(M(v,"["))depth++;else if(M(v,"]")){depth--;if(depth===0)break;}n.parentNode.removeChild(n);n=x;}var p=t.parentNode;while(c.firstChild)p.insertBefore(c.firstChild,n);p.replaceChild(d.createComment("' + STREAM_SEED_COMMENT + `"+id),t);s.parentNode.removeChild(s);};window.$OCTRX=function(id,so){var t=d.querySelector('template[` + STREAM_BOUNDARY_ATTR + `="'+id+'"]');if(t){if(so)t.remove();else t.setAttribute("data-oct-err","");}};window.$OCTRH=function(id){var c=d.querySelector('[` + STREAM_RESOURCE_ATTR + `="'+id+'"]');if(!c)return;var n;while((n=c.firstElementChild)){c.removeChild(n);if(window.$OCTFR){window.$OCTFR(n);continue;}var p=n.getAttribute("data-precedence"),g=d.head.querySelectorAll("link[data-precedence],style[data-precedence]"),t=g.length?g[g.length-1]:null,x=null;for(var i=0;i<g.length;i++)if(g[i].getAttribute("data-precedence")===p)x=g[i];if(x)x.after(n);else if(t)t.after(n);else d.head.appendChild(n);}c.remove();};})();`;
6091
+ return STREAM_RUNTIME_JS ??= '(function(){if(window.$OCTRC)return;var d=document;var S=window.$OCTS=window.$OCTS||{},E;var M=function(v,c){if(v===c)return 1;if(!v||v.charAt(0)!==c)return 0;var s=v.slice(1),n=+s;return n>=2&&Number.isSafeInteger(n)&&String(n)===s;};var P=function(s){var q=s.firstElementChild;if(q&&q.localName==="script"&&q.hasAttribute("' + STREAM_SCRIPT_ATTR + `")){var z=d.createElement("template");try{z.innerHTML=JSON.parse(q.textContent);return z.content;}catch(e){return null;}}return s;};var C=function(c,nc){if(!nc)return c;var n=c.firstElementChild;while(n&&n.localName==="script")n=n.nextElementSibling;return n;};window.$OCTRC=function(id,nc){var t=d.querySelector('template[` + STREAM_BOUNDARY_ATTR + `="'+id+'"]');var s=d.querySelector('[` + STREAM_SEGMENT_ATTR + `="'+id+'"]');if(!s)return;if(!t){s.remove();return;}var c=P(s);if(!c)return;var sd=c.querySelector("script[` + STREAM_SEED_ATTR + ']");if(sd){S[id]=sd.textContent;sd.parentNode.removeChild(sd);}var ns=c.firstElementChild;while(ns&&!(ns.localName==="script"&&ns.hasAttribute("' + NATIVE_SIGNAL_SEED_ATTR + '")))ns=ns.nextElementSibling;if(ns){S[id+"$signals"]=ns.textContent;ns.parentNode.removeChild(ns);}c=C(c,nc);if(!c)return;var n=t.nextSibling,depth=1;while(n){var x=n.nextSibling,v=n.nodeType===8?n.data:null;if(M(v,"["))depth++;else if(M(v,"]")){depth--;if(depth===0)break;}n.parentNode.removeChild(n);n=x;}var p=t.parentNode;while(c.firstChild)p.insertBefore(c.firstChild,n);p.replaceChild(d.createComment("' + STREAM_SEED_COMMENT + `"+id),t);s.parentNode.removeChild(s);if(E){var errors=E;E=undefined;for(var i=0;i<errors.length;i++)X(errors[i][0],errors[i][1]);}};window.$OCTRC.marker=M;window.$OCTRC.parse=P;window.$OCTRC.content=C;var X=window.$OCTRX=function(id,so){var t=d.querySelector('template[` + STREAM_BOUNDARY_ATTR + `="'+id+'"]');if(t){if(so)t.remove();else t.setAttribute("data-oct-err","");}else(E||(E=[])).push([id,so]);};window.$OCTRH=function(id){var c=d.querySelector('[` + STREAM_RESOURCE_ATTR + `="'+id+'"]');if(!c)return;var n;while((n=c.firstElementChild)){c.removeChild(n);if(window.$OCTFR){window.$OCTFR(n);continue;}var p=n.getAttribute("data-precedence"),g=d.head.querySelectorAll("link[data-precedence],style[data-precedence]"),t=g.length?g[g.length-1]:null,x=null;for(var i=0;i<g.length;i++)if(g[i].getAttribute("data-precedence")===p)x=g[i];if(x)x.after(n);else if(t)t.after(n);else d.head.appendChild(n);}c.remove();};})();`;
6092
+ }
6093
+ let STREAM_VIEW_TRANSITION_RUNTIME_JS;
6094
+ function streamViewTransitionRuntimeJs() {
6095
+ return STREAM_VIEW_TRANSITION_RUNTIME_JS ??= `(function(){
6096
+ var w=window,d=document;
6097
+ if(w.$OCTVT)return;
6098
+ w.$OCTVT=true;
6099
+ var reveal=w.$OCTRC,queue=[],scheduled=false,callbackOnly=new WeakSet(),ready=new WeakSet(),waitReady=new WeakSet(),waitFinish=new WeakSet();
6100
+ w.$OCTRC=function(id,nc){
6101
+ if(typeof d.startViewTransition!=="function"&&typeof Element.prototype.startViewTransition!=="function"){reveal(id,nc);return;}
6102
+ queue.push([id,nc]);later();
6103
+ };
6104
+ function later(){if(queue.length&&!scheduled){scheduled=true;queueMicrotask(function(){scheduled=false;drain();});}}
6105
+ function watch(handle,untilReady){
6106
+ var watched=untilReady?waitReady:waitFinish;
6107
+ if(watched.has(handle))return;
6108
+ watched.add(handle);
6109
+ if(untilReady)handle.ready.then(function(){ready.add(handle);later();},function(){watch(handle,false);});
6110
+ else handle.finished.then(later,later);
6111
+ }
6112
+ function ownerOf(t){
6113
+ var scope=t.closest("[vt-scope]");
6114
+ return scope?(scope.getAttribute("vt-scope")==="element"?scope:null):d;
6115
+ }
6116
+ function blocked(owner){
6117
+ var handle=d.__octaneViewTransition,blocked=false;
6118
+ if(handle&&!(owner&&owner!==d&&ready.has(handle))){watch(handle,!!owner&&owner!==d);blocked=true;}
6119
+ var scopes=d.__octaneViewTransitionScopes;
6120
+ if(scopes)scopes.forEach(function(active,element){
6121
+ if(!owner||owner===d||owner===element||owner.contains(element)){watch(active,false);blocked=true;}
6122
+ else if(element.contains(owner)&&!ready.has(active)){watch(active,true);blocked=true;}
6123
+ });
6124
+ return blocked;
6125
+ }
6126
+ function drain(){
6127
+ if(!queue.length)return;
6128
+ var selected=[],pending=[],groups=[],owners=new Map();
6129
+ for(var i=0;i<queue.length;i++){
6130
+ var item=queue[i],t=d.querySelector('template[${STREAM_BOUNDARY_ATTR}="'+item[0]+'"]'),owner=t?ownerOf(t):null;
6131
+ if(blocked(owner)){pending.push(item);continue;}
6132
+ selected.push(item);
6133
+ var group=owners.get(owner);
6134
+ if(!group){group={owner:owner,items:[],restore:[],changed:new Set(),prepared:[],arrived:false};owners.set(owner,group);groups.push(group);}
6135
+ group.items.push(item);
6136
+ }
6137
+ queue=pending;
6138
+ if(!selected.length)return;
6139
+ var committed=false,animated=false,images=[],resourceWait;
6140
+ function commit(){
6141
+ if(committed)return resourceWait;
6142
+ committed=true;for(var i=0;i<selected.length;i++)reveal(selected[i][0],selected[i][1]);
6143
+ if(!animated)return;
6144
+ var blockers=[],cleanups=[];
6145
+ d.documentElement.clientHeight;
6146
+ if(d.fonts&&d.fonts.status!=="loaded")blockers.push(d.fonts.ready);
6147
+ for(var i=0;i<images.length;i++){
6148
+ var img=images[i],bounds=img.getBoundingClientRect();
6149
+ if(!img.complete&&bounds.bottom>0&&bounds.right>0&&bounds.top<w.innerHeight&&bounds.left<w.innerWidth){
6150
+ blockers.push(new Promise(function(resolve){
6151
+ var image=img;image.addEventListener("load",resolve);image.addEventListener("error",resolve);
6152
+ cleanups.push(function(){image.removeEventListener("load",resolve);image.removeEventListener("error",resolve);});
6153
+ }));
6154
+ }
6155
+ }
6156
+ images.length=0;
6157
+ if(blockers.length)resourceWait=new Promise(function(resolve){
6158
+ var timer=setTimeout(done,500),settled=false;
6159
+ function done(){if(settled)return;settled=true;clearTimeout(timer);for(var i=0;i<cleanups.length;i++)cleanups[i]();cleanups.length=0;resolve();}
6160
+ Promise.all(blockers).then(done,done);
6161
+ });
6162
+ return resourceWait;
6163
+ }
6164
+ function reset(group){
6165
+ var restore=group.restore;
6166
+ for(var i=restore.length-1;i>=0;i--){
6167
+ var entry=restore[i],el=entry[0],style=el.style;
6168
+ if(style.getPropertyValue("view-transition-name")===entry[5]&&style.getPropertyPriority("view-transition-name")===entry[8]){
6169
+ if(entry[1])style.setProperty("view-transition-name",entry[1],entry[2]);
6170
+ else style.removeProperty("view-transition-name");
6171
+ }
6172
+ if(style.getPropertyValue("view-transition-class")===entry[6]&&style.getPropertyPriority("view-transition-class")===entry[9]){
6173
+ if(entry[3])style.setProperty("view-transition-class",entry[3],entry[4]);
6174
+ else style.removeProperty("view-transition-class");
6175
+ }
6176
+ if(!style.length&&!entry[7])el.removeAttribute("style");
6177
+ }
6178
+ restore.length=0;group.changed.clear();
6179
+ }
6180
+ function prepare(group){
6181
+ var owner=group.owner,restore=group.restore,changed=group.changed,appearing=new Map();
6182
+ if(!owner||typeof owner.startViewTransition!=="function")return;
6183
+ function owns(el,content){
6184
+ for(var node=el;node&&node.nodeType===1;node=node.parentElement){
6185
+ if(node===owner)return true;
6186
+ if(node.getAttribute("vt-scope")==="element")return false;
6187
+ if(node===content)return true;
6188
+ }
6189
+ return owner===d;
6190
+ }
6191
+ function apply(el,attr,content){
6192
+ var cls=el.getAttribute(attr);
6193
+ if(!cls||cls==="none"||changed.has(el)||!owns(el,content))return;
6194
+ var style=el.style;
6195
+ if(!style)return;
6196
+ var explicit=el.getAttribute("vt-name"),name=explicit||("_OT_"+restore.length+"_");
6197
+ var entry=[el,style.getPropertyValue("view-transition-name"),style.getPropertyPriority("view-transition-name"),style.getPropertyValue("view-transition-class"),style.getPropertyPriority("view-transition-class"),"","",el.hasAttribute("style")];
6198
+ if(el!==owner||explicit)style.setProperty("view-transition-name",w.CSS.escape(name));
6199
+ if(cls!=="auto")style.setProperty("view-transition-class",cls);
6200
+ entry[5]=style.getPropertyValue("view-transition-name");entry[6]=style.getPropertyValue("view-transition-class");
6201
+ entry[8]=style.getPropertyPriority("view-transition-name");entry[9]=style.getPropertyPriority("view-transition-class");
6202
+ restore.push(entry);changed.add(el);
6203
+ }
6204
+ function descendants(el,attr,content){
6205
+ var nodes=el.querySelectorAll("["+attr+"]");
6206
+ for(var i=0;i<nodes.length;i++)apply(nodes[i],attr,content);
6207
+ }
6208
+ for(var k=0;k<group.items.length;k++){
6209
+ var id=group.items[k][0],nc=group.items[k][1];
6210
+ var t=d.querySelector('template[${STREAM_BOUNDARY_ATTR}="'+id+'"]');
6211
+ var s=d.querySelector('[${STREAM_SEGMENT_ATTR}="'+id+'"]');
6212
+ if(!t||!s)continue;
6213
+ var parent=t.parentNode,rect=parent.getBoundingClientRect();
6214
+ if(!rect.width&&!rect.height&&!rect.left&&!rect.top)continue;
6215
+ var parsed=reveal.parse(s);
6216
+ if(!parsed)continue;
6217
+ if(parsed!==s)s.replaceChildren(parsed);
6218
+ var content=reveal.content(s,nc);
6219
+ if(!content)continue;
6220
+ group.prepared.push([t,content,parent]);
6221
+ var matches=content.querySelectorAll("[vt-share]");
6222
+ for(var i=0;i<matches.length;i++)if(matches[i].getAttribute("vt-share")!=="none"&&owns(matches[i],content))appearing.set(matches[i].getAttribute("vt-name"),matches[i]);
6223
+ var pendingImages=content.querySelectorAll('img[src]:not([loading="lazy"])');
6224
+ for(var i=0;i<pendingImages.length;i++)if(owns(pendingImages[i],content))images.push(pendingImages[i]);
6225
+ }
6226
+ function pair(el){
6227
+ if(!owns(el))return false;
6228
+ var other=appearing.get(el.getAttribute("vt-name"));
6229
+ if(other&&el.getAttribute("vt-share")&&el.getAttribute("vt-share")!=="none"){
6230
+ apply(el,"vt-share");apply(other,"vt-share",other.closest('[${STREAM_SEGMENT_ATTR}]'));appearing.delete(el.getAttribute("vt-name"));return true;
6231
+ }
6232
+ return false;
6233
+ }
6234
+ for(var k=0;k<group.prepared.length;k++){
6235
+ var t=group.prepared[k][0],content=group.prepared[k][1],parent=group.prepared[k][2];
6236
+ var node=t.nextSibling,depth=1;
6237
+ while(node){
6238
+ if(node.nodeType===8){
6239
+ var v=node.data;
6240
+ if(reveal.marker(v,"["))depth++;else if(reveal.marker(v,"]")&&!--depth)break;
6241
+ }else if(node.nodeType===1){
6242
+ if(!pair(node))apply(node,"vt-exit");
6243
+ matches=node.querySelectorAll("[vt-share]");for(var j=0;j<matches.length;j++)pair(matches[j]);
6244
+ descendants(node,"vt-parent-exit");
6245
+ }
6246
+ node=node.nextSibling;
6247
+ }
6248
+ for(var el=content.firstElementChild;el;el=el.nextElementSibling){apply(el,"vt-enter",content);descendants(el,"vt-parent-enter",content);}
6249
+ do{
6250
+ for(var sibling=parent.firstElementChild;sibling;sibling=sibling.nextElementSibling)apply(sibling,"vt-update");
6251
+ if(parent===owner)break;
6252
+ parent=parent.parentNode;
6253
+ }while(parent&&parent.nodeType===1&&parent.getAttribute("vt-update")!=="none");
6254
+ }
6255
+ if(owner!==d&&group.prepared.length)apply(owner,"vt-update");
6256
+ }
6257
+ var captures=[],documentGroup=null,elementsToEnter=0,remaining=0,resolveGate,rejectGate;
6258
+ var gate=new Promise(function(resolve,reject){resolveGate=resolve;rejectGate=reject;});
6259
+ gate.catch(function(){});
6260
+ for(var i=0;i<groups.length;i++){
6261
+ try{prepare(groups[i]);}catch(error){reset(groups[i]);}
6262
+ if(groups[i].restore.length){captures.push(groups[i]);if(groups[i].owner===d)documentGroup=groups[i];else elementsToEnter++;}
6263
+ }
6264
+ remaining=captures.length;animated=remaining>0;
6265
+ if(!remaining){images.length=0;commit();later();return;}
6266
+ function arrive(group){
6267
+ if(group.arrived)return gate;
6268
+ group.arrived=true;remaining--;
6269
+ if(group.owner!==d&&!--elementsToEnter&&documentGroup)start(documentGroup);
6270
+ if(!remaining){try{Promise.resolve(commit()).then(resolveGate,rejectGate);}catch(error){rejectGate(error);}}
6271
+ return gate;
6272
+ }
6273
+ function start(group){
6274
+ if(group.started)return;group.started=true;
6275
+ var owner=group.owner,transition,startNative=owner.startViewTransition,update=function(){return arrive(group);};
6276
+ try{
6277
+ if(callbackOnly.has(startNative))transition=startNative.call(owner,update);
6278
+ else{
6279
+ try{transition=startNative.call(owner,{update:update,types:[]});}
6280
+ catch(error){
6281
+ if(!(error instanceof TypeError))throw error;
6282
+ transition=startNative.call(owner,update);callbackOnly.add(startNative);
6283
+ }
6284
+ }
6285
+ if(owner===d)d.__octaneViewTransition=transition;
6286
+ else (d.__octaneViewTransitionScopes||(d.__octaneViewTransitionScopes=new Map())).set(owner,transition);
6287
+ transition.ready.then(function(){ready.add(transition);reset(group);later();},function(){reset(group);});
6288
+ function complete(){
6289
+ reset(group);
6290
+ if(owner===d){if(d.__octaneViewTransition===transition)d.__octaneViewTransition=null;}
6291
+ else{var scopes=d.__octaneViewTransitionScopes;if(scopes&&scopes.get(owner)===transition)scopes.delete(owner);}
6292
+ drain();
6293
+ }
6294
+ transition.finished.then(complete,complete);
6295
+ }catch(error){reset(group);arrive(group);if(!error||(error.name!=="AbortError"&&error.name!=="InvalidStateError"))console.error(error);}
6296
+ }
6297
+ for(var i=0;i<captures.length;i++)if(captures[i].owner!==d)start(captures[i]);
6298
+ if(!elementsToEnter&&documentGroup&&!documentGroup.arrived)start(documentGroup);
6299
+ }
6300
+ })();`;
6301
+ }
6302
+ function needsAutomaticSignalInjection(options) {
6303
+ return options?.streamedSignals !== void 0 && options?.injection?.observeSignalAttempt === void 0;
6304
+ }
6305
+ async function prepareAutomaticSignalInjection(options) {
6306
+ const config = options.streamedSignals;
6307
+ const { createAutomaticStreamedSignalInjection } = await import("./server/streamed-signals.js");
6308
+ return {
6309
+ ...options,
6310
+ injection: createAutomaticStreamedSignalInjection(
6311
+ { ...config, nonce: options.nonce },
6312
+ options.injection
6313
+ )
6314
+ };
5144
6315
  }
5145
6316
  function withStream(stream, fn) {
5146
6317
  const prev = STREAM;
@@ -5235,7 +6406,7 @@ function segmentChunk(b, nonceAttr) {
5235
6406
  }
5236
6407
  }
5237
6408
  if (b.signals !== void 0) seedScript += serializeNativeSignalSeeds(b.signals, nonceAttr);
5238
- const html = vtSsrStrip(b.html);
6409
+ const html = vtSsrStrip(b.html, b.rawHtml);
5239
6410
  const content = b.namespace === "svg" ? seedScript + "<svg>" + html + "</svg>" : b.namespace === "mathml" ? seedScript + "<math>" + html + "</math>" : seedScript + html;
5240
6411
  const hasNamespaceCarrier = b.namespace === "html" ? "" : ",1";
5241
6412
  const payload = JSON.stringify(content).replace(/<(?=\/?script)/gi, "\\u003c");
@@ -5321,7 +6492,14 @@ async function runStream(component, props, options, sink, resolved) {
5321
6492
  return;
5322
6493
  }
5323
6494
  if (!html) return;
5324
- return write(html, false, rememberUnaccepted);
6495
+ const written = write(html, false, rememberUnaccepted);
6496
+ if (written === void 0) {
6497
+ injection.accepted?.();
6498
+ return;
6499
+ }
6500
+ return written.then(() => {
6501
+ injection.accepted?.();
6502
+ });
5325
6503
  };
5326
6504
  const recoveryInjection = injection === void 0 ? void 0 : async () => {
5327
6505
  if (signal?.aborted) {
@@ -5378,14 +6556,20 @@ async function runStream(component, props, options, sink, resolved) {
5378
6556
  const done = [];
5379
6557
  const reachable = new Set(flushedSegments);
5380
6558
  for (; ; ) {
5381
- const next = [...stream.boundaries.values()].filter((boundary) => {
5382
- if (boundary.state !== "done" || reachable.has(boundary.id)) return false;
6559
+ const next = [];
6560
+ for (const boundary of stream.boundaries.values()) {
6561
+ if (boundary.state !== "done" || reachable.has(boundary.id)) continue;
6562
+ let visible = true;
5383
6563
  for (let i = boundary.ancestors.length - 1; i >= 0; i--) {
5384
6564
  const ancestor = stream.boundaries.get(boundary.ancestors[i]);
5385
- if (ancestor !== void 0) return reachable.has(ancestor.id);
6565
+ if (ancestor !== void 0) {
6566
+ visible = reachable.has(ancestor.id);
6567
+ break;
6568
+ }
5386
6569
  }
5387
- return true;
5388
- }).sort((a, b) => a.order - b.order);
6570
+ if (visible) next.push(boundary);
6571
+ }
6572
+ next.sort((a, b) => a.order - b.order);
5389
6573
  if (next.length === 0) return done;
5390
6574
  for (const boundary of next) {
5391
6575
  done.push(boundary);
@@ -5400,14 +6584,22 @@ async function runStream(component, props, options, sink, resolved) {
5400
6584
  options?.onError?.(boundary.error);
5401
6585
  }
5402
6586
  };
5403
- const reachableErroredBoundaries = () => [...stream.boundaries.values()].filter((boundary) => {
5404
- if (boundary.state !== "errored" || boundary.errorFlushed) return false;
5405
- for (let i = boundary.ancestors.length - 1; i >= 0; i--) {
5406
- const ancestor = stream.boundaries.get(boundary.ancestors[i]);
5407
- if (ancestor !== void 0) return flushedSegments.has(ancestor.id);
6587
+ const reachableErroredBoundaries = () => {
6588
+ const errors = [];
6589
+ for (const boundary of stream.boundaries.values()) {
6590
+ if (boundary.state !== "errored" || boundary.errorFlushed) continue;
6591
+ let visible = true;
6592
+ for (let i = boundary.ancestors.length - 1; i >= 0; i--) {
6593
+ const ancestor = stream.boundaries.get(boundary.ancestors[i]);
6594
+ if (ancestor !== void 0) {
6595
+ visible = flushedSegments.has(ancestor.id);
6596
+ break;
6597
+ }
6598
+ }
6599
+ if (visible) errors.push(boundary);
5408
6600
  }
5409
- return true;
5410
- }).sort((a, b) => a.order - b.order);
6601
+ return errors.sort((a, b) => a.order - b.order);
6602
+ };
5411
6603
  const flushRecoverableBoundaryErrors = () => {
5412
6604
  const errors = reachableErroredBoundaries();
5413
6605
  if (errors.length === 0) return;
@@ -5478,7 +6670,7 @@ async function runStream(component, props, options, sink, resolved) {
5478
6670
  const separateHead = options?.headChannel === "separate";
5479
6671
  if (separateHead) {
5480
6672
  try {
5481
- options?.onHeadReady?.(pass.vtCandidates ? vtSsrStrip(pass.head) : pass.head);
6673
+ options?.onHeadReady?.(pass.vtCandidates ? vtSsrStrip(pass.head, pass.rawHtml) : pass.head);
5482
6674
  } catch (err) {
5483
6675
  try {
5484
6676
  completeInjection();
@@ -5507,11 +6699,19 @@ async function runStream(component, props, options, sink, resolved) {
5507
6699
  }
5508
6700
  if (pass.serial.length > 0) shell += serializeSuspenseSeeds(pass.serial, nonceAttr);
5509
6701
  if (pass.signals !== void 0) shell += serializeNativeSignalSeeds(pass.signals, nonceAttr);
6702
+ if (options?.earlySignalBootstrap !== "external" && (injection?.streamedRenderer === true || pass.hasSignalControls || options?.independentHydration !== void 0)) {
6703
+ shell += "<script " + STREAM_SCRIPT_ATTR + nonceAttr + ">" + streamedSignalBootstrapJs(options?.independentHydration !== void 0) + "</script>";
6704
+ }
6705
+ if (injection?.takeInitialSelections !== void 0) shell += injection.takeInitialSelections();
5510
6706
  const anyPending = stream.boundaries.size > 0;
6707
+ let sentViewTransitions = pass.vtCandidates;
5511
6708
  if (anyPending)
5512
- shell += "<script " + STREAM_SCRIPT_ATTR + nonceAttr + ">" + streamRuntimeJs() + "</script>";
6709
+ shell += "<script " + STREAM_SCRIPT_ATTR + nonceAttr + ">" + streamRuntimeJs() + (sentViewTransitions ? streamViewTransitionRuntimeJs() : "") + "</script>";
5513
6710
  try {
5514
- const shellWrite = write(pass.vtCandidates ? vtSsrStrip(shell) : shell);
6711
+ if (injection?.streamedRenderer === true || pass.hasSignalControls || options?.independentHydration !== void 0) {
6712
+ options?.onEarlyHydrationReady?.();
6713
+ }
6714
+ const shellWrite = write(pass.vtCandidates ? vtSsrStrip(shell, pass.rawHtml) : shell);
5515
6715
  if (shellWrite !== void 0) await shellWrite;
5516
6716
  } catch (err) {
5517
6717
  try {
@@ -5546,7 +6746,7 @@ async function runStream(component, props, options, sink, resolved) {
5546
6746
  if (initiallyDone.length > 0) {
5547
6747
  let chunk = "";
5548
6748
  for (const boundary of initiallyDone) chunk += segmentChunk(boundary, nonceAttr);
5549
- const segmentWrite = write(pass.vtCandidates ? vtSsrStrip(chunk) : chunk);
6749
+ const segmentWrite = write(pass.vtCandidates ? vtSsrStrip(chunk, pass.rawHtml) : chunk);
5550
6750
  if (segmentWrite !== void 0) await segmentWrite;
5551
6751
  for (const boundary of initiallyDone) {
5552
6752
  flushedSegments.add(boundary.id);
@@ -5555,7 +6755,7 @@ async function runStream(component, props, options, sink, resolved) {
5555
6755
  }
5556
6756
  const initialErrorWrite = flushRecoverableBoundaryErrors();
5557
6757
  if (initialErrorWrite !== void 0) await initialErrorWrite;
5558
- while ([...stream.boundaries.values()].some((b) => b.state === "pending")) {
6758
+ while (hasPendingStreamBoundary(stream)) {
5559
6759
  signal?.throwIfAborted();
5560
6760
  if (suspended.length === 0) {
5561
6761
  throw new Error(formatServerError(36));
@@ -5601,9 +6801,13 @@ async function runStream(component, props, options, sink, resolved) {
5601
6801
  if (madeProgress) attempt = 0;
5602
6802
  retryWithoutSettling = observeSuspenseWave(resolved, settledWave, suspended, madeProgress);
5603
6803
  const done = reachableDoneSegments();
6804
+ if (!sentViewTransitions && pass.vtCandidates && done.length > 0) {
6805
+ sentViewTransitions = true;
6806
+ chunk += "<script " + STREAM_SCRIPT_ATTR + nonceAttr + ">" + streamViewTransitionRuntimeJs() + "</script>";
6807
+ }
5604
6808
  for (const b of done) chunk += segmentChunk(b, nonceAttr);
5605
6809
  if (chunk !== "") {
5606
- const segmentWrite = write(pass.vtCandidates ? vtSsrStrip(chunk) : chunk);
6810
+ const segmentWrite = write(pass.vtCandidates ? vtSsrStrip(chunk, pass.rawHtml) : chunk);
5607
6811
  if (segmentWrite !== void 0) await segmentWrite;
5608
6812
  for (const b of done) flushedSegments.add(b.id);
5609
6813
  }
@@ -5611,9 +6815,10 @@ async function runStream(component, props, options, sink, resolved) {
5611
6815
  if (errorWrite !== void 0) await errorWrite;
5612
6816
  }
5613
6817
  } catch (err) {
5614
- const pendingBoundaryCount = [...stream.boundaries.values()].filter(
5615
- (boundary) => boundary.state === "pending" && !flushedSegments.has(boundary.id)
5616
- ).length;
6818
+ let pendingBoundaryCount = 0;
6819
+ for (const boundary of stream.boundaries.values()) {
6820
+ if (boundary.state === "pending" && !flushedSegments.has(boundary.id)) pendingBoundaryCount++;
6821
+ }
5617
6822
  const reports = signal?.aborted ? Math.max(1, pendingBoundaryCount) : 1;
5618
6823
  for (let i = 0; i < reports; i++) options?.onError?.(err);
5619
6824
  if (injection !== void 0) {
@@ -5836,10 +7041,8 @@ function renderToPipeableStream(entryComponent, props, options) {
5836
7041
  finishEnd();
5837
7042
  };
5838
7043
  let started = false;
5839
- const startRender = () => {
5840
- if (started) return;
5841
- started = true;
5842
- const renderOptions = { ...options, signal: controller.signal };
7044
+ const beginRender = (preparedOptions) => {
7045
+ const renderOptions = { ...preparedOptions, signal: controller.signal };
5843
7046
  const resolved = newResolvedMap(renderOptions);
5844
7047
  void runStream(
5845
7048
  component,
@@ -5876,6 +7079,18 @@ function renderToPipeableStream(entryComponent, props, options) {
5876
7079
  flushEnd();
5877
7080
  });
5878
7081
  };
7082
+ const startRender = () => {
7083
+ if (started) return;
7084
+ started = true;
7085
+ if (needsAutomaticSignalInjection(options)) {
7086
+ void prepareAutomaticSignalInjection(options).then(beginRender, (error) => {
7087
+ shellFailure = { error };
7088
+ options?.onShellError?.(error);
7089
+ options?.onError?.(error);
7090
+ flushEnd();
7091
+ });
7092
+ } else beginRender(options);
7093
+ };
5879
7094
  queueMicrotask(startRender);
5880
7095
  return {
5881
7096
  pipe(dest) {
@@ -5912,6 +7127,11 @@ function renderToReadableStream(entryComponent, props, options) {
5912
7127
  options ??= props;
5913
7128
  props = { value: entryComponent };
5914
7129
  }
7130
+ if (needsAutomaticSignalInjection(options)) {
7131
+ return prepareAutomaticSignalInjection(options).then(
7132
+ (prepared) => renderToReadableStream(component, props, prepared)
7133
+ );
7134
+ }
5915
7135
  return new Promise((resolveShell, rejectShell) => {
5916
7136
  const encoder = new TextEncoder();
5917
7137
  const renderController = new AbortController();
@@ -6107,6 +7327,7 @@ function renderToReadableStream(entryComponent, props, options) {
6107
7327
  function emitHeadHint(key, html) {
6108
7328
  if (HEAD === null) return;
6109
7329
  if (HEAD.hints.has(key)) return;
7330
+ HEAD.replay = null;
6110
7331
  HEAD.hints.add(key);
6111
7332
  (HEAD.hintHtml ??= /* @__PURE__ */ new Map()).set(key, html);
6112
7333
  }
@@ -6172,7 +7393,10 @@ function preload(href, options) {
6172
7393
  const v = options[k];
6173
7394
  if (v != null) (subset ??= {})[k] = v;
6174
7395
  }
6175
- if (subset !== null) (HEAD.preloadXfer ??= /* @__PURE__ */ new Map()).set(as + ":" + value, subset);
7396
+ if (subset !== null) {
7397
+ HEAD.replay = null;
7398
+ (HEAD.preloadXfer ??= /* @__PURE__ */ new Map()).set(as + ":" + value, subset);
7399
+ }
6176
7400
  }
6177
7401
  }
6178
7402
  const imageSrcSet = as === "image" ? options.imageSrcSet : void 0;
@@ -6196,6 +7420,7 @@ function preinit(href, options) {
6196
7420
  if (as !== "style" && as !== "script") return;
6197
7421
  let seeded = null;
6198
7422
  if (HEAD !== null) {
7423
+ HEAD.replay = null;
6199
7424
  const xfer = HEAD.preloadXfer?.get(as + ":" + value);
6200
7425
  if (xfer !== void 0) {
6201
7426
  seeded = xfer;
@@ -6282,9 +7507,11 @@ function ssrStylesheetResource(attrs, invalidReason) {
6282
7507
  if (typeof href !== "string" || href === "") return "";
6283
7508
  const key = "sheet:" + href;
6284
7509
  if (HEAD.hints.has(key)) return "";
7510
+ HEAD.replay = null;
6285
7511
  HEAD.hints.add(key);
6286
7512
  const precedence = attrs.precedence == null ? "" : String(attrs.precedence);
6287
7513
  const tag = '<link rel="stylesheet" href="' + escapeAttr(sanitizeURL(href)) + '" data-precedence="' + escapeAttr(precedence) + '"' + resourceAttrs(attrs, "link") + ">";
7514
+ HEAD.replay = null;
6288
7515
  const sheets = HEAD.sheets ??= /* @__PURE__ */ new Map();
6289
7516
  sheets.set(href, { precedence, html: tag });
6290
7517
  return "";
@@ -6316,9 +7543,11 @@ function ssrStyleResource(attrs, css, development) {
6316
7543
  }
6317
7544
  HEAD.hints.add("dev-inline-style:" + href);
6318
7545
  }
7546
+ HEAD.replay = null;
6319
7547
  HEAD.hints.add(key);
6320
7548
  const precedence = attrs.precedence == null ? "" : String(attrs.precedence);
6321
7549
  const tag = '<style data-precedence="' + escapeAttr(precedence) + '" data-href="' + escapeAttr(href) + '"' + resourceAttrs(attrs, "link") + ">" + css + "</style>";
7550
+ HEAD.replay = null;
6322
7551
  const sheets = HEAD.sheets ??= /* @__PURE__ */ new Map();
6323
7552
  sheets.set(href, { precedence, html: tag });
6324
7553
  return "";
@@ -6329,6 +7558,7 @@ function ssrScriptResource(attrs) {
6329
7558
  if (typeof src !== "string" || src === "") return "";
6330
7559
  const key = "script:" + src;
6331
7560
  if (HEAD.hints.has(key) || HEAD.hints.has("module:" + src)) return "";
7561
+ HEAD.replay = null;
6332
7562
  HEAD.hints.add(key);
6333
7563
  HEAD.html += '<script src="' + escapeAttr(sanitizeURL(src)) + '" async data-oct-res=""' + resourceAttrs(attrs, "script") + "></script>";
6334
7564
  return "";
@@ -6386,16 +7616,20 @@ export {
6386
7616
  addTransitionType,
6387
7617
  beginNativeReadScope,
6388
7618
  beginNativeReadWitness,
7619
+ bindPresentationView,
6389
7620
  callWithReceiver,
6390
7621
  cloneElement,
6391
7622
  createContext,
6392
7623
  createElement,
7624
+ createElementAt,
7625
+ createElementFromConfig,
6393
7626
  createHostedServerSession,
6394
7627
  createPortal,
6395
7628
  createScopedElement,
6396
7629
  createScopedValue,
6397
7630
  descriptorChildren,
6398
7631
  enableNativeReadCollection,
7632
+ enableServerSignalBindings,
6399
7633
  encodeAsyncIdentityString,
6400
7634
  endNativeReadScope,
6401
7635
  escapeAttr,
@@ -6434,6 +7668,8 @@ export {
6434
7668
  prerenderToNodeStream,
6435
7669
  puBatch,
6436
7670
  puMemo,
7671
+ readNativeDomProps,
7672
+ readNativeDomStyle,
6437
7673
  renderHostedAttempt,
6438
7674
  renderToPipeableStream,
6439
7675
  renderToReadableStream,
@@ -6446,6 +7682,11 @@ export {
6446
7682
  ssrArm,
6447
7683
  ssrAttr,
6448
7684
  ssrAttrs,
7685
+ ssrBindingBlock,
7686
+ ssrBindingChild,
7687
+ ssrBindingClass,
7688
+ ssrBindingHtml,
7689
+ ssrBindingKey,
6449
7690
  ssrBlock,
6450
7691
  ssrCheckedAttr,
6451
7692
  ssrChild,
@@ -6477,6 +7718,9 @@ export {
6477
7718
  ssrSelectAttrs,
6478
7719
  ssrSelectScope,
6479
7720
  ssrSelectScopeSources,
7721
+ ssrSignalControlAttrs,
7722
+ ssrSignalControlValue,
7723
+ ssrSignalValue,
6480
7724
  ssrSnapshotSpread,
6481
7725
  ssrSpread,
6482
7726
  ssrSpreadContent,
@@ -6493,6 +7737,7 @@ export {
6493
7737
  startTransition,
6494
7738
  styleMap,
6495
7739
  touchStyleMap,
7740
+ trustHTML,
6496
7741
  use,
6497
7742
  useActionState,
6498
7743
  useCallback,