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,7 +1,9 @@
1
1
  "use strict";
2
+ var __create = Object.create;
2
3
  var __defProp = Object.defineProperty;
3
4
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
5
  var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
5
7
  var __hasOwnProp = Object.prototype.hasOwnProperty;
6
8
  var __export = (target, all) => {
7
9
  for (var name in all)
@@ -15,6 +17,14 @@ var __copyProps = (to, from, except, desc) => {
15
17
  }
16
18
  return to;
17
19
  };
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
+ // If the importer is in node compatibility mode or this is not an ESM
22
+ // file that has been converted to a CommonJS file using a Babel-
23
+ // compatible transform (i.e. "__esModule" has not been set), then set
24
+ // "default" to the CommonJS "module.exports" for node compatibility.
25
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
+ mod
27
+ ));
18
28
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
29
  var runtime_server_exports = {};
20
30
  __export(runtime_server_exports, {
@@ -33,16 +43,20 @@ __export(runtime_server_exports, {
33
43
  addTransitionType: () => addTransitionType,
34
44
  beginNativeReadScope: () => beginNativeReadScope,
35
45
  beginNativeReadWitness: () => beginNativeReadWitness,
46
+ bindPresentationView: () => bindPresentationView,
36
47
  callWithReceiver: () => callWithReceiver,
37
48
  cloneElement: () => cloneElement,
38
49
  createContext: () => createContext,
39
50
  createElement: () => createElement,
51
+ createElementAt: () => createElementAt,
52
+ createElementFromConfig: () => createElementFromConfig,
40
53
  createHostedServerSession: () => createHostedServerSession,
41
54
  createPortal: () => createPortal,
42
55
  createScopedElement: () => createScopedElement,
43
56
  createScopedValue: () => createScopedValue,
44
57
  descriptorChildren: () => descriptorChildren,
45
58
  enableNativeReadCollection: () => enableNativeReadCollection,
59
+ enableServerSignalBindings: () => enableServerSignalBindings,
46
60
  encodeAsyncIdentityString: () => encodeAsyncIdentityString,
47
61
  endNativeReadScope: () => endNativeReadScope,
48
62
  escapeAttr: () => escapeAttr,
@@ -81,6 +95,8 @@ __export(runtime_server_exports, {
81
95
  prerenderToNodeStream: () => prerenderToNodeStream,
82
96
  puBatch: () => puBatch,
83
97
  puMemo: () => puMemo,
98
+ readNativeDomProps: () => import_read_protocol.readNativeDomProps,
99
+ readNativeDomStyle: () => import_read_protocol.readNativeDomStyle,
84
100
  renderHostedAttempt: () => renderHostedAttempt,
85
101
  renderToPipeableStream: () => renderToPipeableStream,
86
102
  renderToReadableStream: () => renderToReadableStream,
@@ -93,6 +109,11 @@ __export(runtime_server_exports, {
93
109
  ssrArm: () => ssrArm,
94
110
  ssrAttr: () => ssrAttr,
95
111
  ssrAttrs: () => ssrAttrs,
112
+ ssrBindingBlock: () => ssrBindingBlock,
113
+ ssrBindingChild: () => ssrBindingChild,
114
+ ssrBindingClass: () => ssrBindingClass,
115
+ ssrBindingHtml: () => ssrBindingHtml,
116
+ ssrBindingKey: () => ssrBindingKey,
96
117
  ssrBlock: () => ssrBlock,
97
118
  ssrCheckedAttr: () => ssrCheckedAttr,
98
119
  ssrChild: () => ssrChild,
@@ -124,6 +145,9 @@ __export(runtime_server_exports, {
124
145
  ssrSelectAttrs: () => ssrSelectAttrs,
125
146
  ssrSelectScope: () => ssrSelectScope,
126
147
  ssrSelectScopeSources: () => ssrSelectScopeSources,
148
+ ssrSignalControlAttrs: () => ssrSignalControlAttrs,
149
+ ssrSignalControlValue: () => ssrSignalControlValue,
150
+ ssrSignalValue: () => ssrSignalValue,
127
151
  ssrSnapshotSpread: () => ssrSnapshotSpread,
128
152
  ssrSpread: () => ssrSpread,
129
153
  ssrSpreadContent: () => ssrSpreadContent,
@@ -140,6 +164,7 @@ __export(runtime_server_exports, {
140
164
  startTransition: () => startTransition,
141
165
  styleMap: () => styleMap,
142
166
  touchStyleMap: () => touchStyleMap,
167
+ trustHTML: () => import_trusted_html.trustHTML,
143
168
  use: () => use,
144
169
  useActionState: () => useActionState,
145
170
  useCallback: () => useCallback,
@@ -167,13 +192,18 @@ __export(runtime_server_exports, {
167
192
  withSlot: () => withSlot
168
193
  });
169
194
  module.exports = __toCommonJS(runtime_server_exports);
195
+ var import_trusted_html = require("./trusted-html.cjs");
196
+ var import_read_protocol = require("./signals/read-protocol.cjs");
170
197
  var import_hook_slot_cache = require("./hook-slot-cache.cjs");
198
+ var import_dom_binding_protocol = require("./dom-binding-protocol.cjs");
171
199
  var import_constants = require("./constants.cjs");
200
+ var import_independent_hydration_protocol = require("./independent-hydration-protocol.cjs");
172
201
  var import_has_own = require("./has-own.cjs");
173
202
  var import_head_ownership = require("./head-ownership.cjs");
174
203
  var import_resource_hint_diagnostics = require("./resource-hint-diagnostics.cjs");
175
204
  var import_aria_diagnostics = require("./aria-diagnostics.cjs");
176
205
  var import_host_property_diagnostics = require("./host-property-diagnostics.cjs");
206
+ var import_early_signals = require("./server/early-signals.cjs");
177
207
  var import_shared_value_helpers = require("./shared-value-helpers.cjs");
178
208
  var import_css = require("./css.cjs");
179
209
  var import_html_tree_validation = require("./html-tree-validation.cjs");
@@ -185,6 +215,64 @@ var import_renderer_bridge = require("./renderer-bridge.cjs");
185
215
  var import_native_read_collector = require("./signals/native-read-collector.cjs");
186
216
  var import_native_read_server = require("./signals/native-read-server.cjs");
187
217
  var import_native_read_seeds = require("./signals/native-read-seeds.cjs");
218
+ var import_owner_context = require("./signals/owner-context.cjs");
219
+ var import_query_attempt_observer = require("./signals/query-attempt-observer.cjs");
220
+ var import_types = require("./signals/types.cjs");
221
+ function isSignalHandle(value) {
222
+ return (typeof value === "object" || typeof value === "function") && value !== null && value[import_types.SIGNAL_HANDLE] === true;
223
+ }
224
+ function readSignalBinding(handle) {
225
+ if (RESOLVED !== null && !SERVER_SIGNAL_OWNER_ACTIVE) {
226
+ return withServerSignalBinding(() => handle.get());
227
+ }
228
+ return handle.get();
229
+ }
230
+ function withServerSignalBinding(read) {
231
+ ensureServerSignalOwner();
232
+ const owner = serverSignalOwner(FRAME);
233
+ const injection = RESOLVED.resourceOptions?.injection;
234
+ return (0, import_owner_context.runWithSignalOwner)(
235
+ owner,
236
+ () => injection?.observeSignalAttempt === void 0 ? read() : (0, import_query_attempt_observer.runWithServerSignalQueryAttemptObserver)(
237
+ owner,
238
+ (attempt) => injection.observeSignalAttempt(attempt, (0, import_owner_context.captureSignalOwner)(owner)),
239
+ injection.createSignalAttemptObservations,
240
+ read
241
+ )
242
+ );
243
+ }
244
+ function isWritableSignal(value) {
245
+ return isSignalHandle(value) && value.kind === "signal" && typeof value.set === "function";
246
+ }
247
+ function ssrSignalValue(value) {
248
+ return isSignalHandle(value) ? readSignalBinding(value) : value;
249
+ }
250
+ const SSR_SIGNAL_CONTROL = /* @__PURE__ */ Symbol("octane.ssr-signal-control");
251
+ function isSsrSignalControlValue(value) {
252
+ return typeof value === "object" && value !== null && value[SSR_SIGNAL_CONTROL] === true;
253
+ }
254
+ function unwrapSsrSignalControlValue(value) {
255
+ return isSsrSignalControlValue(value) ? value.value : value;
256
+ }
257
+ function ssrSignalControlValue(value, site) {
258
+ if (!isWritableSignal(value)) return ssrSignalValue(value);
259
+ if (RESOLVED !== null && !SERVER_SIGNAL_OWNER_ACTIVE) {
260
+ return withServerSignalBinding(() => serverSignalControlValue(value, site));
261
+ }
262
+ return serverSignalControlValue(value, site);
263
+ }
264
+ function serverSignalControlValue(value, site) {
265
+ const owner = (0, import_owner_context.currentSignalOwner)();
266
+ if (owner === null || !("documentOwner" in owner)) return value.get();
267
+ if (RESOLVED !== null) RESOLVED.hasSignalControls = true;
268
+ return {
269
+ [SSR_SIGNAL_CONTROL]: true,
270
+ value: value.get(),
271
+ site,
272
+ owner,
273
+ binding: value[import_types.SIGNAL_BINDING_IDENTITY]()
274
+ };
275
+ }
188
276
  const NATIVE_ARRAY_MAP = Array.prototype.map;
189
277
  const NATIVE_REFLECT_APPLY = Reflect.apply;
190
278
  const NATIVE_ARRAY_SPECIES_GETTER = Object.getOwnPropertyDescriptor(Array, Symbol.species)?.get;
@@ -278,6 +366,17 @@ const ACTIVE_PU_WARM_PLANS = [];
278
366
  let CURRENT_PU_WARM_CLAIMS = null;
279
367
  let ID_COUNTER = 0;
280
368
  let ID_PREFIX = "";
369
+ let SIGNAL_INSTANCE_PREFIX = "";
370
+ let SIGNAL_COMPONENT_INSTANCE_KEY = "";
371
+ let SERVER_SIGNAL_OWNER_ACTIVE = false;
372
+ let SIGNAL_CONTROL_SITE = "";
373
+ const EMPTY_SIGNAL_LIST_KEYS = [];
374
+ let SIGNAL_LIST_KEYS = EMPTY_SIGNAL_LIST_KEYS;
375
+ function newStyleCollector() {
376
+ const collector = /* @__PURE__ */ new Map();
377
+ collector.replay = null;
378
+ return collector;
379
+ }
281
380
  let CSS = null;
282
381
  let NONCE_ATTR = "";
283
382
  let MARKERS = true;
@@ -348,13 +447,20 @@ function nextScopedCount(frame, slot, key) {
348
447
  counts.push(key, 1);
349
448
  return 0;
350
449
  }
450
+ function scopeSuffix(frame) {
451
+ const scope = ASYNC_SCOPE;
452
+ if (process.env.NODE_ENV !== "production" && !scope.startsWith(frame.asyncScope)) {
453
+ throw new Error((0, import_error_codes_server_generated.formatServerError)(65));
454
+ }
455
+ return scope.slice(frame.asyncScope.length);
456
+ }
351
457
  function nextFrameOccurrence(frame, base) {
352
- const scopedBase = ASYNC_SCOPE === frame.asyncScope ? base : ASYNC_SCOPE + "\0" + base;
458
+ const scopedBase = ASYNC_SCOPE === frame.asyncScope ? base : scopeSuffix(frame) + "\0" + base;
353
459
  return nextScopedCount(frame, "occ", scopedBase);
354
460
  }
355
461
  function nextChildSegment(frame) {
356
462
  if (ASYNC_SCOPE === frame.asyncScope) return frame.nextChild++;
357
- return nextScopedCount(frame, "scopedChildren", ASYNC_SCOPE);
463
+ return nextScopedCount(frame, "scopedChildren", scopeSuffix(frame));
358
464
  }
359
465
  function ssrScope(parent) {
360
466
  return { parent, $$ctxValues: null };
@@ -488,6 +594,13 @@ const SCOPED_VALUE_PROPERTIES = {
488
594
  get() {
489
595
  return this[SCOPED_VALUE_RESOLVER]().children;
490
596
  }
597
+ },
598
+ __octaneInvocationSite: {
599
+ configurable: true,
600
+ enumerable: false,
601
+ get() {
602
+ return this[SCOPED_VALUE_RESOLVER]().__octaneInvocationSite;
603
+ }
491
604
  }
492
605
  };
493
606
  function restoreWritableScopedChildren(props, name, value) {
@@ -643,10 +756,15 @@ function scopedValueDescriptor(resolve) {
643
756
  Object.defineProperty(descriptor, "key", SCOPED_VALUE_PROPERTIES.key);
644
757
  Object.defineProperty(descriptor, "ref", SCOPED_VALUE_PROPERTIES.ref);
645
758
  Object.defineProperty(descriptor, "children", SCOPED_VALUE_PROPERTIES.children);
759
+ Object.defineProperty(
760
+ descriptor,
761
+ "__octaneInvocationSite",
762
+ SCOPED_VALUE_PROPERTIES.__octaneInvocationSite
763
+ );
646
764
  if (process.env.NODE_ENV !== "production") Object.freeze(descriptor);
647
765
  return descriptor;
648
766
  }
649
- function createScopedElement(type, props, readChildren) {
767
+ function createScopedElement(type, props, readChildren, invocationSite) {
650
768
  const src = props ?? null;
651
769
  const key = hasElementConfigKey(src) ? "" + src.key : null;
652
770
  const copiedProps = copyScopedElementConfig(type, src);
@@ -663,9 +781,9 @@ function createScopedElement(type, props, readChildren) {
663
781
  }
664
782
  return resolvedChildren;
665
783
  };
666
- return scopedElementDescriptor(type, copiedProps, key, children);
784
+ return scopedElementDescriptor(type, copiedProps, key, children, invocationSite);
667
785
  }
668
- function nativeCreateScopedElement(type, props, readChildren) {
786
+ function nativeCreateScopedElement(type, props, readChildren, invocationSite) {
669
787
  const src = props ?? null;
670
788
  const key = hasElementConfigKey(src) ? "" + src.key : null;
671
789
  const copiedProps = copyScopedElementConfig(type, src);
@@ -673,10 +791,11 @@ function nativeCreateScopedElement(type, props, readChildren) {
673
791
  type,
674
792
  copiedProps,
675
793
  key,
676
- createNativeServerScopedResolver(readChildren)
794
+ createNativeServerScopedResolver(readChildren),
795
+ invocationSite
677
796
  );
678
797
  }
679
- function scopedElementDescriptor(type, copiedProps, key, children) {
798
+ function scopedElementDescriptor(type, copiedProps, key, children, invocationSite) {
680
799
  setScopedChildrenResolver(copiedProps, children);
681
800
  SCOPED_ELEMENT_PROPS.add(copiedProps);
682
801
  const descriptor = {
@@ -686,31 +805,43 @@ function scopedElementDescriptor(type, copiedProps, key, children) {
686
805
  key,
687
806
  ref: copiedProps.ref !== void 0 ? copiedProps.ref : null
688
807
  };
808
+ if (invocationSite !== void 0) descriptor.__octaneInvocationSite = invocationSite;
689
809
  Object.defineProperty(descriptor, "children", SCOPED_CHILDREN_PROPERTY);
690
810
  setScopedChildrenResolver(descriptor, children);
691
811
  return finalizeElementDescriptor(descriptor);
692
812
  }
693
813
  function createElement(type, props, ...children) {
814
+ return createElementFromConfig(void 0, type, props, children);
815
+ }
816
+ function createElementAt(invocationSite, type, props, ...children) {
817
+ return createElementFromConfig(invocationSite, type, props, children);
818
+ }
819
+ function createElementFromConfig(invocationSite, type, props, children) {
694
820
  if (typeof type === "function" && (0, import_renderer_bridge.isRendererContext)(type)) {
695
821
  (0, import_renderer_bridge.registerServerRendererContextProvider)(renderServerContextProvider);
696
822
  }
697
823
  const src = props ?? null;
698
824
  const key = hasElementConfigKey(src) ? "" + src.key : null;
699
- let kids = children.length > 0 ? children.length === 1 ? children[0] : children : src?.children;
700
- if (children.length > 1) POSITIONAL_CHILDREN.add(children);
701
- if (children.length > 1 && process.env.NODE_ENV !== "production") Object.freeze(children);
825
+ const hasPositional = children !== void 0 && children.length > 0;
826
+ let kids = hasPositional ? children.length === 1 ? children[0] : children : src?.children;
827
+ if (children !== void 0 && children.length > 1) {
828
+ POSITIONAL_CHILDREN.add(children);
829
+ if (process.env.NODE_ENV !== "production") Object.freeze(children);
830
+ }
702
831
  const p = copyElementConfig(src);
703
- if (children.length > 0) p.children = kids;
832
+ if (hasPositional) p.children = kids;
704
833
  (0, import_shared_value_helpers.applyElementDefaultProps)(type, p);
705
834
  kids = p.children;
706
- return finalizeElementDescriptor({
835
+ const descriptor = {
707
836
  $$kind: ELEMENT_TAG,
708
837
  type,
709
838
  props: p,
710
839
  key,
711
840
  ref: p.ref !== void 0 ? p.ref : null,
712
841
  children: kids ?? null
713
- });
842
+ };
843
+ if (invocationSite !== void 0) descriptor.__octaneInvocationSite = invocationSite;
844
+ return finalizeElementDescriptor(descriptor);
714
845
  }
715
846
  const POSITIONAL_CHILDREN = /* @__PURE__ */ new WeakSet();
716
847
  function positionalChildren(children) {
@@ -942,6 +1073,8 @@ function cloneElement(element, config, ...children) {
942
1073
  children: kids ?? null
943
1074
  };
944
1075
  }
1076
+ if (element.__octaneInvocationSite !== void 0)
1077
+ descriptor.__octaneInvocationSite = element.__octaneInvocationSite;
945
1078
  return finalizeElementDescriptor(descriptor);
946
1079
  }
947
1080
  function cloneAndReplaceElementKey(element, key) {
@@ -1145,8 +1278,33 @@ class ServerHtml {
1145
1278
  return this[SERVER_HTML];
1146
1279
  }
1147
1280
  }
1281
+ class RawServerHtml {
1282
+ constructor(html) {
1283
+ this.html = html;
1284
+ }
1285
+ html;
1286
+ get [SERVER_HTML]() {
1287
+ VT_SSR_HAS_RAW_HTML = true;
1288
+ return this.html;
1289
+ }
1290
+ toString() {
1291
+ return this[SERVER_HTML];
1292
+ }
1293
+ }
1148
1294
  function ssrHtml(html) {
1149
- return typeof html === "string" ? new ServerHtml(html) : html;
1295
+ if (typeof html !== "string") return html;
1296
+ if (!VT_SSR_HAS_RAW_HTML) return new ServerHtml(html);
1297
+ if (CURRENT_SCOPE === null) VT_SSR_HAS_RAW_HTML = false;
1298
+ return new RawServerHtml(html);
1299
+ }
1300
+ const BINDING_HTML_ROOT = /* @__PURE__ */ Symbol.for("octane.binding.html");
1301
+ function ssrBindingHtml(html, id) {
1302
+ const output = new ServerHtml(html);
1303
+ output[BINDING_HTML_ROOT] = "[b;" + id + ";root";
1304
+ return output;
1305
+ }
1306
+ function bindPresentationView(view, _id) {
1307
+ return (0, import_component_flags.markComponentFlags)(view, import_component_flags.COMPONENT_FLAG_BOUNDARY, view.name);
1150
1308
  }
1151
1309
  function serverComponentOutput(out, scope) {
1152
1310
  if (out == null) return "";
@@ -1185,21 +1343,53 @@ function ssrTextPre(v) {
1185
1343
  }
1186
1344
  function ssrComponentDescriptor(d, scope) {
1187
1345
  if (SCOPED_ELEMENT_PROPS.has(d.props)) {
1188
- return ssrComponent(scope, d.type, d.props);
1346
+ return ssrComponent(
1347
+ scope,
1348
+ d.type,
1349
+ d.props,
1350
+ void 0,
1351
+ d.key ?? void 0,
1352
+ void 0,
1353
+ d.__octaneInvocationSite
1354
+ );
1189
1355
  }
1190
1356
  const children = d.children;
1191
1357
  if (children == null || children === d.props?.children) {
1192
- return ssrComponent(scope, d.type, d.props);
1358
+ return ssrComponent(
1359
+ scope,
1360
+ d.type,
1361
+ d.props,
1362
+ void 0,
1363
+ d.key ?? void 0,
1364
+ void 0,
1365
+ d.__octaneInvocationSite
1366
+ );
1193
1367
  }
1194
- return ssrComponent(scope, d.type, {
1195
- ...d.props,
1196
- children
1197
- });
1368
+ return ssrComponent(
1369
+ scope,
1370
+ d.type,
1371
+ { ...d.props, children },
1372
+ void 0,
1373
+ d.key ?? void 0,
1374
+ void 0,
1375
+ d.__octaneInvocationSite
1376
+ );
1198
1377
  }
1199
1378
  function ssrChild(v, scope) {
1379
+ if (isSignalHandle(v)) {
1380
+ v = readSignalBinding(v);
1381
+ }
1200
1382
  if (probingDangerHtmlChild(v)) return "";
1201
1383
  return ssrChildValue(v, scope, true);
1202
1384
  }
1385
+ function ssrBindingChild(value, scope, marker) {
1386
+ const html = ssrChild(value, scope);
1387
+ if (!MARKERS) return html;
1388
+ const openingEnd = html.indexOf("-->");
1389
+ const framed = html.startsWith(import_constants.BLOCK_OPEN) || html.startsWith("<!--") && openingEnd !== -1 && (0, import_dom_binding_protocol.isBindingOpenComment)(html.slice(4, openingEnd));
1390
+ const content = framed && html.endsWith(import_constants.BLOCK_CLOSE) ? html.slice(openingEnd + 3, -import_constants.BLOCK_CLOSE.length) : html;
1391
+ return ssrBindingBlock(content, marker);
1392
+ }
1203
1393
  function ssrChildValue(v, scope, includeKeyedSingle, selfMarkItem = false) {
1204
1394
  if (v !== null && typeof v === "object" && SERVER_HTML in v) {
1205
1395
  return v[SERVER_HTML];
@@ -1331,6 +1521,7 @@ function ssrHostElement(tag, props, children, scope, rawInner) {
1331
1521
  }
1332
1522
  let inner = "";
1333
1523
  if (hasDangerHTML) {
1524
+ VT_SSR_HAS_RAW_HTML = true;
1334
1525
  const html = innerHTMLValue.__html;
1335
1526
  const raw = html == null ? "" : String(html);
1336
1527
  inner = semanticTag === "script" ? escapeEntireInlineScriptContent(raw) : semanticTag === "style" ? escapeEntireInlineStyleContent(raw) : raw;
@@ -1449,6 +1640,20 @@ function ssrDescriptorContent(v, scope) {
1449
1640
  function ssrBlock(content) {
1450
1641
  return MARKERS ? import_constants.BLOCK_OPEN + content + import_constants.BLOCK_CLOSE : String(content);
1451
1642
  }
1643
+ function ssrBindingBlock(content, marker) {
1644
+ return MARKERS ? "<!--" + marker + "-->" + content + import_constants.BLOCK_CLOSE : String(content);
1645
+ }
1646
+ function ssrBindingKey(key, seen) {
1647
+ const encoded = (0, import_dom_binding_protocol.encodeBindingKey)(key);
1648
+ if (seen.has(encoded)) throw new TypeError((0, import_error_codes_server_generated.formatServerError)(73));
1649
+ seen.add(encoded);
1650
+ return encoded;
1651
+ }
1652
+ function ssrBindingClass(receipt, values) {
1653
+ const snapshot = [(0, import_css.normalizeClass)(values[0]), values[1].map(import_css.normalizeClass)];
1654
+ const classes = [snapshot[0], ...snapshot[1]].filter(Boolean).join(" ");
1655
+ return ' class="' + escapeAttr(classes) + '" ' + receipt + '="' + escapeAttr(JSON.stringify(snapshot)) + '"';
1656
+ }
1452
1657
  function ssrFragmentMarker(open, _ref) {
1453
1658
  return MARKERS ? open ? "<!--frag-->" : "<!--/frag-->" : "";
1454
1659
  }
@@ -1531,31 +1736,48 @@ function withAsyncListScope(kind, fn) {
1531
1736
  function ssrControl(siteKey, fn) {
1532
1737
  const frame = FRAME;
1533
1738
  const occurrence = frame === null ? 0 : nextFrameOccurrence(frame, "@control:" + siteKey);
1534
- return withAsyncIdentity("control:" + siteKey, occurrence, fn);
1739
+ const previousSignalControl = SIGNAL_CONTROL_SITE;
1740
+ SIGNAL_CONTROL_SITE = siteKey;
1741
+ try {
1742
+ return withAsyncIdentity("control:" + siteKey, occurrence, fn);
1743
+ } finally {
1744
+ SIGNAL_CONTROL_SITE = previousSignalControl;
1745
+ }
1535
1746
  }
1536
- function enterAsyncArm(armKey) {
1747
+ function enterAsyncArm(armKey, mapped = false) {
1537
1748
  const previous = ASYNC_SCOPE;
1538
1749
  const frame = FRAME;
1539
- const occurrence = frame === null ? 0 : nextFrameOccurrence(frame, "@arm-position:" + previous);
1540
- const fallbackPosition = previous + "|@arm-position:" + occurrence;
1750
+ const occurrence = frame === null ? 0 : nextFrameOccurrence(frame, "@arm-position:");
1751
+ const fallbackPosition = armKey !== null && (typeof armKey === "object" || typeof armKey === "function" || typeof armKey === "symbol") ? previous + "|@arm-position:" + occurrence : void 0;
1752
+ if (SERVER_SIGNAL_BINDINGS_POTENTIAL && SIGNAL_CONTROL_SITE.charCodeAt(0) === 102) {
1753
+ SIGNAL_LIST_KEYS = [
1754
+ ...SIGNAL_LIST_KEYS,
1755
+ signalIdentityKey(mapped ? "k" + String(armKey) : armKey)
1756
+ ];
1757
+ }
1541
1758
  ASYNC_SCOPE = previous + "|@arm:" + asyncIdentityKey(armKey, false, fallbackPosition);
1542
- return previous;
1543
1759
  }
1544
1760
  function ssrArm(armKey, fn) {
1545
- const previous = enterAsyncArm(armKey);
1761
+ const previous = ASYNC_SCOPE;
1762
+ const previousSignalKeys = SIGNAL_LIST_KEYS;
1546
1763
  try {
1764
+ enterAsyncArm(armKey);
1547
1765
  return fn();
1548
1766
  } finally {
1549
1767
  ASYNC_SCOPE = previous;
1768
+ SIGNAL_LIST_KEYS = previousSignalKeys;
1550
1769
  }
1551
1770
  }
1552
- function ssrForItem(armKey, fn, item, index, scope, block) {
1553
- const previous = enterAsyncArm(armKey);
1771
+ function ssrForItem(armKey, fn, item, index, scope, block, mapped = false) {
1772
+ const previous = ASYNC_SCOPE;
1773
+ const previousSignalKeys = SIGNAL_LIST_KEYS;
1554
1774
  try {
1775
+ enterAsyncArm(armKey, mapped);
1555
1776
  const html = index === void 0 ? fn(item, scope) : fn(item, index, scope);
1556
1777
  return block ? ssrBlock(html) : html;
1557
1778
  } finally {
1558
1779
  ASYNC_SCOPE = previous;
1780
+ SIGNAL_LIST_KEYS = previousSignalKeys;
1559
1781
  }
1560
1782
  }
1561
1783
  function ssrPortal() {
@@ -1809,7 +2031,7 @@ function isAggregatedFormAttribute(tag, name) {
1809
2031
  if (tag === "input" && (name === "checked" || name === "defaultChecked")) return true;
1810
2032
  return tag === "select" && name === "multiple";
1811
2033
  }
1812
- function ssrAttrs(sources, tag, namespace = "html", skipFormControls = false) {
2034
+ function ssrAttrs(sources, tag, namespace = "html", skipFormControls = false, readStyle) {
1813
2035
  const dev = process.env.NODE_ENV !== "production";
1814
2036
  namespace = resolveAttributeNamespace(namespace);
1815
2037
  const props = /* @__PURE__ */ new Map();
@@ -1860,7 +2082,12 @@ function ssrAttrs(sources, tag, namespace = "html", skipFormControls = false) {
1860
2082
  for (const { name: rawName, value } of props.values()) {
1861
2083
  if (rawName === "dangerouslySetInnerHTML" || skipFormControls && isAggregatedFormAttribute(tag, rawName))
1862
2084
  continue;
1863
- out2 += ssrAttrEntry(rawName, value, tag, namespace);
2085
+ out2 += ssrAttrEntry(
2086
+ rawName,
2087
+ readStyle !== void 0 && rawName === "style" ? readStyle(value) : value,
2088
+ tag,
2089
+ namespace
2090
+ );
1864
2091
  }
1865
2092
  return out2;
1866
2093
  }
@@ -1903,6 +2130,8 @@ function ssrAttrs(sources, tag, namespace = "html", skipFormControls = false) {
1903
2130
  }
1904
2131
  }
1905
2132
  }
2133
+ const style = resolved.get("style");
2134
+ if (readStyle !== void 0 && style !== void 0) style.value = readStyle(style.value);
1906
2135
  let out = "";
1907
2136
  const ordered = dev || needsWinningOrderSort ? [...resolved.values()] : resolved.values();
1908
2137
  if (needsWinningOrderSort) ordered.sort((a, b) => a.firstOrder - b.firstOrder);
@@ -1957,14 +2186,32 @@ function ssrClass(sources) {
1957
2186
  }
1958
2187
  return found ? ssrAttr("class", value) : "";
1959
2188
  }
1960
- function ssrSnapshotSpread(obj) {
2189
+ function ssrSnapshotSpread(obj, controlSite, deferStyle = false) {
1961
2190
  if (obj == null) return null;
1962
2191
  const source = Object(obj);
1963
2192
  const snapshot = /* @__PURE__ */ Object.create(null);
1964
2193
  for (const key of Reflect.ownKeys(source)) {
1965
2194
  if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue;
1966
- const value = source[key];
1967
- if (typeof key === "string") snapshot[key] = value;
2195
+ let value = source[key];
2196
+ if (typeof key !== "string") continue;
2197
+ if (key === "style" && deferStyle) {
2198
+ snapshot[key] = value;
2199
+ continue;
2200
+ }
2201
+ if (controlSite !== void 0 && (key === "value" || key === "checked") && isWritableSignal(value)) {
2202
+ value = ssrSignalControlValue(value, controlSite);
2203
+ } else if (isSignalHandle(value)) value = readSignalBinding(value);
2204
+ else if (key === "style" && value !== null && typeof value === "object") {
2205
+ let style;
2206
+ for (const name of Object.keys(value)) {
2207
+ const current = value[name];
2208
+ if (!isSignalHandle(current)) continue;
2209
+ style ??= { ...value };
2210
+ style[name] = readSignalBinding(current);
2211
+ }
2212
+ if (style !== void 0) value = style;
2213
+ }
2214
+ snapshot[key] = value;
1968
2215
  }
1969
2216
  return snapshot;
1970
2217
  }
@@ -2016,6 +2263,7 @@ function ssrInnerHtml(sources, renderChildren, definitelyHasChildren = false, ch
2016
2263
  }
2017
2264
  }
2018
2265
  const html = value.__html;
2266
+ VT_SSR_HAS_RAW_HTML = true;
2019
2267
  return html == null ? "" : String(html);
2020
2268
  }
2021
2269
  return void 0;
@@ -2058,6 +2306,7 @@ function ssrSpreadContent(snapshot, scope) {
2058
2306
  }
2059
2307
  if (child != null) throw new Error((0, import_error_codes_server_generated.formatServerError)(5));
2060
2308
  const value = html.__html;
2309
+ VT_SSR_HAS_RAW_HTML = true;
2061
2310
  return value == null ? "" : String(value);
2062
2311
  }
2063
2312
  return child === void 0 ? "" : ssrChildText(child, scope);
@@ -2087,24 +2336,48 @@ function ssrFormAuthoringDiagnostics(tag, sources) {
2087
2336
  return "";
2088
2337
  }
2089
2338
  function ssrValueAttr(v) {
2339
+ v = unwrapSsrSignalControlValue(v);
2090
2340
  if (v == null || typeof v === "function" || typeof v === "symbol") return "";
2091
2341
  return ' value="' + escapeAttr(typeof v === "string" ? v : String(v)) + '"';
2092
2342
  }
2093
2343
  function ssrCheckedAttr(v) {
2344
+ v = unwrapSsrSignalControlValue(v);
2094
2345
  return v == null || !v ? "" : " checked";
2095
2346
  }
2096
2347
  function ssrInputAttrs(sources) {
2097
2348
  const props = resolveFormControlSources(sources);
2098
2349
  if (process.env.NODE_ENV !== "production") {
2099
2350
  devValidateSsrFormProps("input", {
2100
- value: props.value,
2101
- defaultValue: props.defaultValue,
2102
- checked: props.checked,
2103
- defaultChecked: props.defaultChecked
2351
+ value: unwrapSsrSignalControlValue(props.value),
2352
+ defaultValue: unwrapSsrSignalControlValue(props.defaultValue),
2353
+ checked: unwrapSsrSignalControlValue(props.checked),
2354
+ defaultChecked: unwrapSsrSignalControlValue(props.defaultChecked)
2104
2355
  });
2105
2356
  }
2106
2357
  return ssrValueAttr(props.value ?? props.defaultValue) + ssrCheckedAttr(props.checked ?? props.defaultChecked);
2107
2358
  }
2359
+ function ssrSignalControlAttrs(sources) {
2360
+ const props = resolveFormControlSources(sources);
2361
+ const controls = [];
2362
+ let ownerKey;
2363
+ const record = (value, channel) => {
2364
+ if (!isSsrSignalControlValue(value)) return;
2365
+ const documentKey = value.owner.documentOwner.scopeKey;
2366
+ if (ownerKey !== void 0 && ownerKey !== documentKey) {
2367
+ throw new Error((0, import_error_codes_server_generated.formatServerError)(68));
2368
+ }
2369
+ ownerKey = documentKey;
2370
+ controls.push([
2371
+ value.binding.scope === "document" ? "" : value.owner.instanceKey,
2372
+ value.binding.nodeKey,
2373
+ channel
2374
+ ]);
2375
+ };
2376
+ record(props.value, "value");
2377
+ record(props.checked, "checked");
2378
+ if (controls.length === 0) return "";
2379
+ return " " + import_constants.SIGNAL_CONTROL_ATTR + '="' + escapeAttr(JSON.stringify([1, ownerKey, controls])) + '"';
2380
+ }
2108
2381
  function resolveFormControlSources(sources) {
2109
2382
  const resolved = {
2110
2383
  value: void 0,
@@ -2155,6 +2428,7 @@ function resolveFormControlSources(sources) {
2155
2428
  return resolved;
2156
2429
  }
2157
2430
  function ssrTextareaValue(v) {
2431
+ v = unwrapSsrSignalControlValue(v);
2158
2432
  if (v == null) return "";
2159
2433
  const s = escapeHtml(typeof v === "string" ? v : String(v));
2160
2434
  return s.charCodeAt(0) === 10 ? "\n" + s : s;
@@ -2163,8 +2437,8 @@ function ssrTextareaValueSources(sources) {
2163
2437
  const props = resolveFormControlSources(sources);
2164
2438
  if (process.env.NODE_ENV !== "production") {
2165
2439
  devValidateSsrFormProps("textarea", {
2166
- value: props.value,
2167
- defaultValue: props.defaultValue
2440
+ value: unwrapSsrSignalControlValue(props.value),
2441
+ defaultValue: unwrapSsrSignalControlValue(props.defaultValue)
2168
2442
  });
2169
2443
  }
2170
2444
  const value = props.value ?? props.defaultValue;
@@ -2176,6 +2450,8 @@ function ssrSelectAttrs(sources) {
2176
2450
  }
2177
2451
  const SELECT_STACK = [];
2178
2452
  function ssrSelectScope(value, defaultValue, multiple, children) {
2453
+ value = unwrapSsrSignalControlValue(value);
2454
+ defaultValue = unwrapSsrSignalControlValue(defaultValue);
2179
2455
  if (process.env.NODE_ENV !== "production") {
2180
2456
  devValidateSsrFormProps("select", { value, defaultValue, multiple });
2181
2457
  }
@@ -2364,6 +2640,28 @@ function snapshotSet(set) {
2364
2640
  function snapshotList(list) {
2365
2641
  return list == null || list.length === 0 ? EMPTY_SNAPSHOT_LIST : list.slice();
2366
2642
  }
2643
+ function snapshotStyles(css) {
2644
+ if (css === null || css.size === 0) return snapshotMap(css);
2645
+ return css.replay ??= snapshotMap(css);
2646
+ }
2647
+ const EMPTY_HEAD_REPLAY = {
2648
+ hints: EMPTY_SNAPSHOT_SET,
2649
+ sheets: null,
2650
+ hintHtml: null,
2651
+ preloadXfer: null
2652
+ };
2653
+ function snapshotHeadCollections(head) {
2654
+ if (head === null) return null;
2655
+ if (head.replay !== null) return head.replay;
2656
+ if (head.hints.size === 0 && head.sheets === null && head.hintHtml === null && head.preloadXfer === null)
2657
+ return EMPTY_HEAD_REPLAY;
2658
+ return head.replay = {
2659
+ hints: snapshotSet(head.hints),
2660
+ sheets: snapshotMap(head.sheets),
2661
+ hintHtml: snapshotMap(head.hintHtml),
2662
+ preloadXfer: snapshotMap(head.preloadXfer)
2663
+ };
2664
+ }
2367
2665
  function snapshotVtStack() {
2368
2666
  return VT_SSR_STACK.length === 0 ? EMPTY_SNAPSHOT_LIST : VT_SSR_STACK.map((candidate) => ({ candidate, consumed: candidate.consumed }));
2369
2667
  }
@@ -2381,6 +2679,7 @@ function restoreScopedCounts(snapshot) {
2381
2679
  function captureComponentReplayState(scope, frame) {
2382
2680
  const css = CSS;
2383
2681
  const head = HEAD;
2682
+ const headCollections = snapshotHeadCollections(head);
2384
2683
  const serial = SERIAL;
2385
2684
  const susp = SUSPENDED;
2386
2685
  const jobs = DEFERRED;
@@ -2393,15 +2692,15 @@ function captureComponentReplayState(scope, frame) {
2393
2692
  nativeMixed: NATIVE_SERVER_READS?.mixed ?? false,
2394
2693
  nativeFailures: NATIVE_SERVER_FAILURES,
2395
2694
  css,
2396
- cssEntries: snapshotMap(css),
2695
+ cssEntries: snapshotStyles(css),
2397
2696
  head,
2398
2697
  headLength: head !== null ? head.html.length : 0,
2399
2698
  headCharsetLength: head !== null ? head.charset.length : 0,
2400
2699
  headViewportLength: head !== null ? head.viewport.length : 0,
2401
- headHints: snapshotSet(head?.hints),
2402
- headSheets: snapshotMap(head?.sheets),
2403
- headHintHtml: snapshotMap(head?.hintHtml),
2404
- headXfer: snapshotMap(head?.preloadXfer),
2700
+ headHints: headCollections?.hints ?? null,
2701
+ headSheets: headCollections?.sheets ?? null,
2702
+ headHintHtml: headCollections?.hintHtml ?? null,
2703
+ headXfer: headCollections?.preloadXfer ?? null,
2405
2704
  serial,
2406
2705
  serialLength: serial !== null ? serial.length : 0,
2407
2706
  susp,
@@ -2437,10 +2736,12 @@ function rewindComponentReplayState(snapshot, scope, frame) {
2437
2736
  NATIVE_SERVER_FAILURES = snapshot.nativeFailures;
2438
2737
  ASYNC_SCOPE = snapshot.asyncScope;
2439
2738
  if (snapshot.css !== null && snapshot.cssEntries !== null) {
2739
+ snapshot.css.replay = null;
2440
2740
  snapshot.css.clear();
2441
2741
  for (const [hash, sheet] of snapshot.cssEntries) snapshot.css.set(hash, sheet);
2442
2742
  }
2443
2743
  if (snapshot.head !== null && snapshot.headHints !== null) {
2744
+ snapshot.head.replay = null;
2444
2745
  snapshot.head.html = snapshot.head.html.slice(0, snapshot.headLength);
2445
2746
  snapshot.head.charset = snapshot.head.charset.slice(0, snapshot.headCharsetLength);
2446
2747
  snapshot.head.viewport = snapshot.head.viewport.slice(0, snapshot.headViewportLength);
@@ -2509,10 +2810,96 @@ function replayUpdatedComponentBody(comp, props, scope, frame, hp, snapshot, war
2509
2810
  hp.occ = null;
2510
2811
  rewindComponentReplayState(snapshot, scope, frame);
2511
2812
  ACTIVE_PU_WARM_PLANS.length = warmPlanCheckpoint;
2512
- out = comp(props ?? {}, scope, void 0);
2813
+ out = invokeServerSignalComponent(comp, props, scope, serverSignalOwner(frame));
2513
2814
  } while (hp.update);
2514
2815
  return out;
2515
2816
  }
2817
+ function signalIdentityKey(value) {
2818
+ if (value === null) return "null";
2819
+ const kind = typeof value;
2820
+ return kind === "string" || kind === "number" || kind === "bigint" || kind === "boolean" ? kind.charCodeAt(0).toString(36) + ":" + String(value) : kind === "undefined" ? "u:" : "o:" + String(value);
2821
+ }
2822
+ function serverStructuralSignalInstanceKey(invocationSite, key) {
2823
+ return resolveServerSignalInstanceKey(SIGNAL_COMPONENT_INSTANCE_KEY) + JSON.stringify([
2824
+ invocationSite ?? "legacy",
2825
+ SIGNAL_LIST_KEYS,
2826
+ key != null ? signalIdentityKey(key) : ""
2827
+ ]);
2828
+ }
2829
+ function resolveServerSignalInstanceKey(identity) {
2830
+ if (typeof identity === "string") return identity;
2831
+ if (identity.signalInstanceKey !== void 0) return identity.signalInstanceKey;
2832
+ const pending = [];
2833
+ while (typeof identity !== "string") {
2834
+ if (identity.signalInstanceKey !== void 0) {
2835
+ identity = identity.signalInstanceKey;
2836
+ break;
2837
+ }
2838
+ pending.push(identity);
2839
+ identity = identity.signalParentKey;
2840
+ }
2841
+ for (let index = pending.length - 1; index >= 0; index--) {
2842
+ const frame = pending[index];
2843
+ identity += JSON.stringify([
2844
+ frame.signalInvocationSite ?? "legacy",
2845
+ frame.signalListKeys,
2846
+ frame.signalKey
2847
+ ]);
2848
+ frame.signalInstanceKey = identity;
2849
+ }
2850
+ return identity;
2851
+ }
2852
+ function serverSignalOwner(_frame) {
2853
+ const resolved = RESOLVED;
2854
+ if (resolved !== null && SERVER_SIGNAL_BINDINGS_ENABLED && resolved.signalOwner === void 0) {
2855
+ ensureServerSignalOwner();
2856
+ }
2857
+ if (resolved === null || resolved.signalOwner === void 0 || resolved.signalInstances === void 0)
2858
+ return;
2859
+ const instanceKey = resolveServerSignalInstanceKey(SIGNAL_COMPONENT_INSTANCE_KEY) || JSON.stringify([SIGNAL_INSTANCE_PREFIX, "root"]);
2860
+ let owner = resolved.signalInstances.get(instanceKey);
2861
+ if (owner === void 0) {
2862
+ owner = Object.freeze({
2863
+ scopeKey: resolved.signalOwner.scopeKey,
2864
+ documentOwner: resolved.signalOwner,
2865
+ instanceOwner: Object.freeze({}),
2866
+ instanceKey
2867
+ });
2868
+ resolved.signalInstances.set(instanceKey, owner);
2869
+ }
2870
+ return owner;
2871
+ }
2872
+ function ensureServerSignalOwner() {
2873
+ const resolved = RESOLVED;
2874
+ if (resolved.signalOwner !== void 0 && resolved.signalInstances !== void 0) return;
2875
+ const ambient = (0, import_owner_context.currentSignalOwner)();
2876
+ resolved.signalOwner = ambient === null ? Object.freeze({ scopeKey: "octane:document" }) : isRendererSignalOwner(ambient) ? ambient.documentOwner : ambient;
2877
+ resolved.ownedSignalOwner = ambient === null;
2878
+ resolved.signalInstances = /* @__PURE__ */ new Map();
2879
+ }
2880
+ function invokeServerSignalComponent(comp, props, scope, owner) {
2881
+ if (owner === void 0) return comp(props ?? {}, scope, void 0);
2882
+ const invoke = () => {
2883
+ const previous = SERVER_SIGNAL_OWNER_ACTIVE;
2884
+ SERVER_SIGNAL_OWNER_ACTIVE = true;
2885
+ try {
2886
+ return comp(props ?? {}, scope, void 0);
2887
+ } finally {
2888
+ SERVER_SIGNAL_OWNER_ACTIVE = previous;
2889
+ }
2890
+ };
2891
+ const injection = RESOLVED?.resourceOptions?.injection;
2892
+ const observe = injection?.observeSignalAttempt;
2893
+ return (0, import_owner_context.runWithSignalOwner)(
2894
+ owner,
2895
+ () => observe === void 0 ? invoke() : (0, import_query_attempt_observer.runWithServerSignalQueryAttemptObserver)(
2896
+ owner,
2897
+ (attempt) => observe(attempt, (0, import_owner_context.captureSignalOwner)(owner)),
2898
+ injection.createSignalAttemptObservations,
2899
+ invoke
2900
+ )
2901
+ );
2902
+ }
2516
2903
  function invokeComponentBody(comp, props, scope, frame) {
2517
2904
  const prevHP = HOOK_PASS;
2518
2905
  const hp = { hooks: null, occ: null, update: false };
@@ -2521,7 +2908,7 @@ function invokeComponentBody(comp, props, scope, frame) {
2521
2908
  HOOK_PASS = hp;
2522
2909
  try {
2523
2910
  ACTIVE_PU_WARM_PLANS.length = warmPlanCheckpoint;
2524
- let out = comp(props ?? {}, scope, void 0);
2911
+ let out = invokeServerSignalComponent(comp, props, scope, serverSignalOwner(frame));
2525
2912
  if (hp.update) {
2526
2913
  out = replayUpdatedComponentBody(comp, props, scope, frame, hp, snapshot, warmPlanCheckpoint);
2527
2914
  }
@@ -2533,14 +2920,25 @@ function invokeComponentBody(comp, props, scope, frame) {
2533
2920
  HOOK_PASS = prevHP;
2534
2921
  }
2535
2922
  }
2536
- function renderComponentFramed(comp, props, parent, frame, inherit) {
2537
- const prevScope = CURRENT_SCOPE;
2538
- const prevFrame = FRAME;
2539
- const prevComp = CURRENT_COMP;
2540
- const prevProps = CURRENT_PROPS;
2541
- const prevParent = CURRENT_PARENT_SCOPE;
2542
- const prevAsyncScope = ASYNC_SCOPE;
2543
- const parentScope = parent ?? prevScope;
2923
+ function captureServerComponentContext() {
2924
+ return {
2925
+ scope: CURRENT_SCOPE,
2926
+ frame: FRAME,
2927
+ comp: CURRENT_COMP,
2928
+ props: CURRENT_PROPS,
2929
+ parent: CURRENT_PARENT_SCOPE,
2930
+ asyncScope: ASYNC_SCOPE,
2931
+ signalInstance: SIGNAL_COMPONENT_INSTANCE_KEY,
2932
+ signalOwnerActive: SERVER_SIGNAL_OWNER_ACTIVE,
2933
+ signalControl: SIGNAL_CONTROL_SITE,
2934
+ signalListKeys: SIGNAL_LIST_KEYS,
2935
+ owner: void 0,
2936
+ previousOwner: void 0
2937
+ };
2938
+ }
2939
+ function renderComponentFramed(comp, props, parent, frame, inherit, instanceKey, bindingMarker) {
2940
+ const previous = captureServerComponentContext();
2941
+ const parentScope = parent ?? previous.scope;
2544
2942
  const scope = ssrScope(parentScope);
2545
2943
  CURRENT_SCOPE = scope;
2546
2944
  FRAME = frame;
@@ -2548,6 +2946,9 @@ function renderComponentFramed(comp, props, parent, frame, inherit) {
2548
2946
  CURRENT_PROPS = props;
2549
2947
  CURRENT_PARENT_SCOPE = parentScope;
2550
2948
  ASYNC_SCOPE = frame.asyncScope;
2949
+ if (instanceKey !== void 0) SIGNAL_COMPONENT_INSTANCE_KEY = instanceKey;
2950
+ SIGNAL_CONTROL_SITE = "";
2951
+ SIGNAL_LIST_KEYS = EMPTY_SIGNAL_LIST_KEYS;
2551
2952
  const nativeToken = NATIVE_READ_COLLECTOR === null ? -1 : beginActiveNativeReadScope(scope);
2552
2953
  let nativeCompleted = false;
2553
2954
  try {
@@ -2559,7 +2960,20 @@ function renderComponentFramed(comp, props, parent, frame, inherit) {
2559
2960
  HOOK_PASS = hookPass;
2560
2961
  try {
2561
2962
  ACTIVE_PU_WARM_PLANS.length = warmPlanCheckpoint;
2562
- out = comp(props ?? {}, scope, void 0);
2963
+ previous.owner = serverSignalOwner(frame);
2964
+ if (previous.owner === void 0) {
2965
+ out = comp(props ?? {}, scope, void 0);
2966
+ } else if (RESOLVED?.resourceOptions?.injection?.observeSignalAttempt !== void 0 || (previous.previousOwner = (0, import_owner_context.enterSynchronousSignalOwner)(previous.owner)) === void 0) {
2967
+ out = invokeServerSignalComponent(comp, props, scope, previous.owner);
2968
+ } else {
2969
+ try {
2970
+ SERVER_SIGNAL_OWNER_ACTIVE = true;
2971
+ out = comp(props ?? {}, scope, void 0);
2972
+ } finally {
2973
+ SERVER_SIGNAL_OWNER_ACTIVE = previous.signalOwnerActive;
2974
+ (0, import_owner_context.restoreSynchronousSignalOwner)(previous.previousOwner);
2975
+ }
2976
+ }
2563
2977
  if (hookPass.update) {
2564
2978
  out = replayUpdatedComponentBody(
2565
2979
  comp,
@@ -2577,22 +2991,29 @@ function renderComponentFramed(comp, props, parent, frame, inherit) {
2577
2991
  }
2578
2992
  const inner = serverComponentOutput(out, scope);
2579
2993
  nativeCompleted = true;
2580
- return MARKERS && !inherit ? import_constants.BLOCK_OPEN + inner + import_constants.BLOCK_CLOSE : inner;
2994
+ if (!MARKERS || inherit) return inner;
2995
+ const marker = bindingMarker ?? (out !== null && typeof out === "object" ? out[BINDING_HTML_ROOT] : void 0);
2996
+ return (marker === void 0 ? import_constants.BLOCK_OPEN : "<!--" + marker + "-->") + inner + import_constants.BLOCK_CLOSE;
2581
2997
  } catch (error) {
2582
2998
  throw normalizeThrownServerThenable(error);
2583
2999
  } finally {
2584
3000
  if (nativeToken >= 0) NATIVE_READ_COLLECTOR.endScope(nativeToken, nativeCompleted);
2585
- CURRENT_SCOPE = prevScope;
2586
- FRAME = prevFrame;
2587
- CURRENT_COMP = prevComp;
2588
- CURRENT_PROPS = prevProps;
2589
- CURRENT_PARENT_SCOPE = prevParent;
2590
- ASYNC_SCOPE = prevAsyncScope;
2591
- }
2592
- }
2593
- function ssrComponent(parent, comp, props, inherit, key, identityScoped) {
3001
+ CURRENT_SCOPE = previous.scope;
3002
+ FRAME = previous.frame;
3003
+ CURRENT_COMP = previous.comp;
3004
+ CURRENT_PROPS = previous.props;
3005
+ CURRENT_PARENT_SCOPE = previous.parent;
3006
+ ASYNC_SCOPE = previous.asyncScope;
3007
+ SIGNAL_COMPONENT_INSTANCE_KEY = previous.signalInstance;
3008
+ SERVER_SIGNAL_OWNER_ACTIVE = previous.signalOwnerActive;
3009
+ SIGNAL_CONTROL_SITE = previous.signalControl;
3010
+ SIGNAL_LIST_KEYS = previous.signalListKeys;
3011
+ }
3012
+ }
3013
+ function ssrComponent(parent, comp, props, inherit, key, identityScoped, invocationSite, bindingMarker) {
2594
3014
  const activity = comp === Activity;
2595
3015
  if (activity && key === void 0) key = props?.key;
3016
+ let signalInstanceKey = SERVER_SIGNAL_BINDINGS_ENABLED ? serverStructuralSignalInstanceKey(invocationSite, key) : void 0;
2596
3017
  const previousIdentityScope = ASYNC_SCOPE;
2597
3018
  if (identityScoped !== true) {
2598
3019
  ASYNC_SCOPE = previousIdentityScope + "|@component-type:" + asyncIdentityKey(comp, false);
@@ -2647,17 +3068,41 @@ function ssrComponent(parent, comp, props, inherit, key, identityScoped) {
2647
3068
  asyncScope: ASYNC_SCOPE,
2648
3069
  namespace: explicitNamespace ?? pf.namespace
2649
3070
  };
2650
- return renderComponentFramed(comp, props, parent, frame, inherit);
3071
+ if (signalInstanceKey === void 0 && SERVER_SIGNAL_BINDINGS_POTENTIAL) {
3072
+ frame.signalParentKey = SIGNAL_COMPONENT_INSTANCE_KEY;
3073
+ frame.signalInvocationSite = invocationSite;
3074
+ frame.signalListKeys = SIGNAL_LIST_KEYS;
3075
+ frame.signalKey = key != null ? signalIdentityKey(key) : "";
3076
+ signalInstanceKey = frame;
3077
+ }
3078
+ return renderComponentFramed(
3079
+ comp,
3080
+ props,
3081
+ parent,
3082
+ frame,
3083
+ inherit,
3084
+ signalInstanceKey,
3085
+ bindingMarker
3086
+ );
2651
3087
  } finally {
2652
3088
  if (identityScoped !== true) ASYNC_SCOPE = previousIdentityScope;
2653
3089
  }
2654
3090
  }
2655
3091
  let NEXT_COMPONENT_NAMESPACE = null;
2656
- function ssrComponentNS(parent, comp, props, namespace, inherit, key) {
3092
+ function ssrComponentNS(parent, comp, props, namespace, inherit, key, invocationSite, bindingMarker) {
2657
3093
  const previous = NEXT_COMPONENT_NAMESPACE;
2658
3094
  NEXT_COMPONENT_NAMESPACE = namespace;
2659
3095
  try {
2660
- return ssrComponent(parent, comp, props, inherit, key);
3096
+ return ssrComponent(
3097
+ parent,
3098
+ comp,
3099
+ props,
3100
+ inherit,
3101
+ key,
3102
+ void 0,
3103
+ invocationSite,
3104
+ bindingMarker
3105
+ );
2661
3106
  } finally {
2662
3107
  NEXT_COMPONENT_NAMESPACE = previous;
2663
3108
  }
@@ -2682,6 +3127,50 @@ function streamTokenForPendingHtml(html) {
2682
3127
  const stream = STREAM;
2683
3128
  return stream !== null && html.includes(import_constants.STREAM_BOUNDARY_ATTR + '="' + stream.token + "-") ? stream.token : null;
2684
3129
  }
3130
+ function ssrIndependentHydrateSidecar(props, instanceId) {
3131
+ const independent = props.__independent;
3132
+ if (independent === void 0) return "";
3133
+ const registry = RESOLVED?.resourceOptions?.independentHydration;
3134
+ if (registry === void 0) {
3135
+ throw new Error((0, import_error_codes_server_generated.formatServerError)(69));
3136
+ }
3137
+ const build = registry.resolve(independent.manifestTemplate.boundaryId);
3138
+ if (build === void 0) {
3139
+ throw new Error((0, import_error_codes_server_generated.formatServerError)(70));
3140
+ }
3141
+ const manifest = (0, import_independent_hydration_protocol.createIndependentHydrateManifest)(
3142
+ independent.manifestTemplate,
3143
+ independent.captures,
3144
+ instanceId,
3145
+ registry.buildId,
3146
+ build
3147
+ );
3148
+ return '<script type="application/json" ' + import_constants.INDEPENDENT_HYDRATE_MANIFEST_ATTR + NONCE_ATTR + ">" + (0, import_independent_hydration_protocol.serializeIndependentHydrateManifest)(manifest) + "</script>";
3149
+ }
3150
+ function withServerIndependentIdentity(prefix, idSeed, render) {
3151
+ const previous = SIGNAL_INSTANCE_PREFIX;
3152
+ const previousInstance = SIGNAL_COMPONENT_INSTANCE_KEY;
3153
+ const previousControl = SIGNAL_CONTROL_SITE;
3154
+ const previousListKeys = SIGNAL_LIST_KEYS;
3155
+ const previousIdPrefix = ID_PREFIX;
3156
+ const previousIdCounter = ID_COUNTER;
3157
+ SIGNAL_INSTANCE_PREFIX = prefix;
3158
+ SIGNAL_COMPONENT_INSTANCE_KEY = JSON.stringify([prefix, "root"]);
3159
+ SIGNAL_CONTROL_SITE = "";
3160
+ SIGNAL_LIST_KEYS = EMPTY_SIGNAL_LIST_KEYS;
3161
+ ID_PREFIX = prefix + "-";
3162
+ ID_COUNTER = idSeed;
3163
+ try {
3164
+ return render();
3165
+ } finally {
3166
+ SIGNAL_INSTANCE_PREFIX = previous;
3167
+ SIGNAL_COMPONENT_INSTANCE_KEY = previousInstance;
3168
+ SIGNAL_CONTROL_SITE = previousControl;
3169
+ SIGNAL_LIST_KEYS = previousListKeys;
3170
+ ID_PREFIX = previousIdPrefix;
3171
+ ID_COUNTER = previousIdCounter + ID_COUNTER - idSeed;
3172
+ }
3173
+ }
2685
3174
  function ssrHydrateAttrs(id, when, idCount, permanentStaticAncestor = false, streamToken = null) {
2686
3175
  const direct = typeof when !== "function" && when !== null ? when : null;
2687
3176
  let attrs = ssrAttr(import_constants.HYDRATE_ID_ATTR, id, "div") + ssrAttr(
@@ -2739,7 +3228,8 @@ const PermanentStaticHydrate = /* @__PURE__ */ (0, import_component_flags.markCo
2739
3228
  "PermanentStaticHydrate"
2740
3229
  );
2741
3230
  const hydrate = /* @__PURE__ */ (0, import_component_flags.markComponentFlags)(
2742
- function Hydrate(props, scope) {
3231
+ function Hydrate(rawProps, scope) {
3232
+ const props = rawProps;
2743
3233
  const id = useId();
2744
3234
  return ssrHtml(
2745
3235
  withSsrElementContext(
@@ -2757,7 +3247,7 @@ const hydrate = /* @__PURE__ */ (0, import_component_flags.markComponentFlags)(
2757
3247
  let children;
2758
3248
  let nativeReads = null;
2759
3249
  try {
2760
- children = ssrBlock(
3250
+ const renderChildren = () => ssrBlock(
2761
3251
  ssrTry(
2762
3252
  scope,
2763
3253
  "jsx-hydrate",
@@ -2767,6 +3257,11 @@ const hydrate = /* @__PURE__ */ (0, import_component_flags.markComponentFlags)(
2767
3257
  "html"
2768
3258
  )
2769
3259
  );
3260
+ children = props.__independent === void 0 ? renderChildren() : withServerIndependentIdentity(
3261
+ id,
3262
+ props.__independent.manifestTemplate.idSeed,
3263
+ renderChildren
3264
+ );
2770
3265
  } finally {
2771
3266
  nativeReads = finishNativeSeedCapture(nativeCapture, previousNativeReads, false);
2772
3267
  }
@@ -2784,7 +3279,8 @@ const hydrate = /* @__PURE__ */ (0, import_component_flags.markComponentFlags)(
2784
3279
  const seedSidecar = seedJson === null || seedJson === "[]" ? "" : '<script type="application/json" ' + import_constants.HYDRATE_SEED_ATTR + NONCE_ATTR + ">" + seedJson + "</script>";
2785
3280
  const nativeSeeds = permanentStaticAncestor ? void 0 : NATIVE_READ_COLLECTOR?.serialize(nativeReads);
2786
3281
  const nativeSidecar = nativeSeeds === void 0 ? "" : serializeNativeSignalSeeds(nativeSeeds, NONCE_ATTR);
2787
- return "<div" + attrs + ">" + children + seedSidecar + nativeSidecar + "</div>";
3282
+ const independentSidecar = permanentStaticAncestor ? "" : ssrIndependentHydrateSidecar(props, id);
3283
+ return "<div" + attrs + (props.__independent === void 0 ? "" : " " + import_constants.HYDRATE_INDEPENDENT_ATTR + '=""') + ">" + children + seedSidecar + nativeSidecar + independentSidecar + "</div>";
2788
3284
  }),
2789
3285
  "html"
2790
3286
  )
@@ -2819,43 +3315,14 @@ const Suspense = /* @__PURE__ */ (0, import_component_flags.markComponentFlags)(
2819
3315
  );
2820
3316
  let VT_SSR_TRY_SEQ = 0;
2821
3317
  let VT_SSR_HAS_CANDIDATES = false;
3318
+ let VT_SSR_HAS_RAW_HTML = false;
2822
3319
  const VT_SSR_STACK = [];
2823
3320
  function vtSsrResolve(props, kind) {
2824
- let v = props[kind];
2825
- if (v == null) v = props.default;
2826
- if (v == null) return "auto";
2827
- if (typeof v === "string") return v;
2828
- return v.default != null ? v.default : "auto";
2829
- }
2830
- function vtSsrFirstVisibleOpenTag(html) {
2831
- const n = html.length;
2832
- let i = 0;
2833
- while (i < n) {
2834
- const lt = html.indexOf("<", i);
2835
- if (lt === -1) return -1;
2836
- if (html.startsWith("<!--", lt)) {
2837
- const close = html.indexOf("-->", lt + 4);
2838
- if (close === -1) return -1;
2839
- i = close + 3;
2840
- continue;
2841
- }
2842
- const c = html.charCodeAt(lt + 1);
2843
- if (!(c >= 65 && c <= 90 || c >= 97 && c <= 122)) {
2844
- i = lt + 1;
2845
- continue;
2846
- }
2847
- let e = lt + 1;
2848
- while (e < n && /[a-zA-Z0-9-]/.test(html[e])) e++;
2849
- if (e - lt === 9 && html.slice(lt + 1, e).toLowerCase() === "template") {
2850
- const j = vtSsrOpenTagEnd(html, e);
2851
- if (j === -1) return -1;
2852
- const close = html.indexOf("</template>", j);
2853
- i = close === -1 ? j + 1 : close + 11;
2854
- continue;
2855
- }
2856
- return lt;
2857
- }
2858
- return -1;
3321
+ const value = props[kind];
3322
+ const resolved = typeof value === "string" ? value : value?.default;
3323
+ if (resolved != null) return resolved;
3324
+ const fallback = props.default;
3325
+ return (typeof fallback === "string" ? fallback : fallback?.default) ?? "auto";
2859
3326
  }
2860
3327
  function vtSsrOpenTagEnd(html, from) {
2861
3328
  let quote = 0;
@@ -2871,45 +3338,297 @@ function vtSsrOpenTagEnd(html, from) {
2871
3338
  }
2872
3339
  return -1;
2873
3340
  }
2874
- function vtSsrAnnotate(html, attrs) {
2875
- const start = vtSsrFirstVisibleOpenTag(html);
2876
- if (start === -1) return html;
2877
- const end = vtSsrOpenTagEnd(html, start + 1);
2878
- if (end === -1) return html;
2879
- const open = html.slice(start, end);
3341
+ function vtSsrMapTags(html, visit, visitText, visitAllElements = false, rootOnly = false) {
3342
+ let depth = 0;
3343
+ let from = 0;
3344
+ let copied = 0;
3345
+ let out = "";
3346
+ while (from < html.length) {
3347
+ const start = html.indexOf("<", from);
3348
+ if (visitText && (!rootOnly || depth === 0))
3349
+ visitText(html.slice(from, start < 0 ? html.length : start), depth);
3350
+ if (start < 0) break;
3351
+ if (html.startsWith("<!--", start)) {
3352
+ const end2 = html.indexOf("-->", start + 4);
3353
+ if (end2 < 0) break;
3354
+ from = end2 + 3;
3355
+ continue;
3356
+ }
3357
+ const closing = html[start + 1] === "/";
3358
+ const nameStart = start + (closing ? 2 : 1);
3359
+ const initial = html.charCodeAt(nameStart);
3360
+ if (!(initial >= 65 && initial <= 90 || initial >= 97 && initial <= 122)) {
3361
+ from = start + 1;
3362
+ continue;
3363
+ }
3364
+ let nameEnd = nameStart + 1;
3365
+ while (nameEnd < html.length) {
3366
+ const code = html.charCodeAt(nameEnd);
3367
+ if (!(code >= 65 && code <= 90 || code >= 97 && code <= 122 || code >= 48 && code <= 57 || code === 58 || code === 45))
3368
+ break;
3369
+ nameEnd++;
3370
+ }
3371
+ const tag = html.slice(nameStart, nameEnd).toLowerCase();
3372
+ const end = vtSsrOpenTagEnd(html, nameStart + tag.length);
3373
+ if (end < 0) break;
3374
+ from = end + 1;
3375
+ if (closing) {
3376
+ depth = Math.max(0, depth - 1);
3377
+ continue;
3378
+ }
3379
+ const inert = tag === "template" || tag === "script" || tag === "style" || tag === "title";
3380
+ const isVoid = import_constants.VOID_ELEMENTS.has(tag) || html[end - 1] === "/";
3381
+ if ((!rootOnly || depth === 0) && (visitAllElements || !inert && tag !== "link" && tag !== "meta" && tag !== "base" && tag !== "option")) {
3382
+ const open = html.slice(start, end + 1);
3383
+ const next = visit(open, depth, tag);
3384
+ if (next !== open) {
3385
+ out += html.slice(copied, start) + next;
3386
+ copied = end + 1;
3387
+ }
3388
+ }
3389
+ if (inert) {
3390
+ const close = new RegExp("</" + tag + "[\\t\\n\\f\\r ]*>", "gi");
3391
+ close.lastIndex = from;
3392
+ from = close.exec(html) === null ? html.length : close.lastIndex;
3393
+ continue;
3394
+ }
3395
+ if (!isVoid) depth++;
3396
+ }
3397
+ return copied === 0 ? html : out + html.slice(copied);
3398
+ }
3399
+ function vtSsrInject(open, attrs) {
3400
+ let existing;
3401
+ if (/vt-/i.test(open)) {
3402
+ existing = /* @__PURE__ */ new Set();
3403
+ vtSsrAttributes(open, (name) => {
3404
+ existing.add(name);
3405
+ });
3406
+ }
2880
3407
  let inject = "";
2881
- for (let index = 0; index < attrs.length; index++) {
2882
- if (open.indexOf(attrs[index][0] + '="') === -1) {
2883
- inject += " " + attrs[index][0] + '="' + escapeAttr(attrs[index][1]) + '"';
3408
+ for (const [name, value] of attrs) {
3409
+ if (!existing?.has(name)) inject += " " + name + '="' + escapeAttr(value) + '"';
3410
+ }
3411
+ if (inject === "") return open;
3412
+ const insertion = open[open.length - 2] === "/" ? open.length - 2 : open.length - 1;
3413
+ return open.slice(0, insertion) + inject + open.slice(insertion);
3414
+ }
3415
+ function vtSsrAnnotate(html, attrs) {
3416
+ let index = 0;
3417
+ return vtSsrMapTags(
3418
+ html,
3419
+ (open, depth) => {
3420
+ if (depth !== 0) return open;
3421
+ const suffix = index++;
3422
+ return vtSsrInject(
3423
+ open,
3424
+ suffix === 0 ? attrs : attrs.map(([name, value]) => [name, name === "vt-name" ? value + "-" + suffix : value])
3425
+ );
3426
+ },
3427
+ void 0,
3428
+ false,
3429
+ true
3430
+ );
3431
+ }
3432
+ function vtSsrSpace(code) {
3433
+ return code === 32 || code === 9 || code === 10 || code === 12 || code === 13;
3434
+ }
3435
+ function vtSsrAttributes(open, visit) {
3436
+ let i = 1;
3437
+ while (i < open.length && !vtSsrSpace(open.charCodeAt(i)) && open[i] !== "/" && open[i] !== ">")
3438
+ i++;
3439
+ while (i < open.length) {
3440
+ while (vtSsrSpace(open.charCodeAt(i))) i++;
3441
+ if (i >= open.length || open[i] === ">" || open[i] === "/") break;
3442
+ const start = i;
3443
+ while (i < open.length && !vtSsrSpace(open.charCodeAt(i)) && open[i] !== "=" && open[i] !== "/" && open[i] !== ">")
3444
+ i++;
3445
+ const nameEnd = i;
3446
+ const name = open.slice(start, i).toLowerCase();
3447
+ while (vtSsrSpace(open.charCodeAt(i))) i++;
3448
+ if (open[i] !== "=") {
3449
+ if (visit(name, nameEnd, nameEnd, "", start, nameEnd)) return;
3450
+ continue;
2884
3451
  }
3452
+ i++;
3453
+ while (vtSsrSpace(open.charCodeAt(i))) i++;
3454
+ const quote = open[i] === '"' || open[i] === "'" ? open[i++] : "";
3455
+ const valueStart = i;
3456
+ if (quote) {
3457
+ const closing = open.indexOf(quote, i);
3458
+ i = closing < 0 ? open.length : closing;
3459
+ } else {
3460
+ while (i < open.length && !vtSsrSpace(open.charCodeAt(i)) && open[i] !== ">") i++;
3461
+ }
3462
+ const valueEnd = i;
3463
+ if (quote) i++;
3464
+ if (visit(name, valueStart, valueEnd, quote, start, nameEnd)) return;
2885
3465
  }
2886
- if (inject === "") return html;
2887
- const insertion = html[end - 1] === "/" ? end - 1 : end;
2888
- return html.slice(0, insertion) + inject + html.slice(insertion);
3466
+ }
3467
+ function vtSsrAttribute(open, wanted) {
3468
+ let result = null;
3469
+ vtSsrAttributes(open, (name, start, end, quote, nameStart, nameEnd) => {
3470
+ if (name !== wanted) return;
3471
+ result = { start, end, quote, nameStart, nameEnd };
3472
+ return true;
3473
+ });
3474
+ return result;
3475
+ }
3476
+ function vtSsrAnnotateScope(html) {
3477
+ let roots = 0;
3478
+ let sentinel = false;
3479
+ let text = false;
3480
+ vtSsrMapTags(
3481
+ html,
3482
+ (open, depth, tag) => {
3483
+ if (depth === 0) {
3484
+ if (tag === "template" && vtSsrAttribute(open, import_constants.STREAM_BOUNDARY_ATTR) !== null)
3485
+ sentinel = true;
3486
+ else roots++;
3487
+ }
3488
+ return open;
3489
+ },
3490
+ (value, depth) => {
3491
+ if (depth === 0 && /\S/.test(value)) text = true;
3492
+ },
3493
+ true,
3494
+ true
3495
+ );
3496
+ const valid = roots === 1 && !sentinel && !text;
3497
+ if (valid)
3498
+ injectStyle(
3499
+ "octane-view-transition-scope",
3500
+ '[vt-scope="element"]{view-transition-scope:all!important}'
3501
+ );
3502
+ return vtSsrMapTags(
3503
+ html,
3504
+ (open) => vtSsrInject(open, [["vt-scope", valid ? "element" : "none"]]),
3505
+ void 0,
3506
+ true,
3507
+ true
3508
+ );
2889
3509
  }
2890
3510
  function vtSsrClaimArm(html, kind) {
2891
3511
  if (!VT_SSR_HAS_CANDIDATES) return html;
2892
- const start = vtSsrFirstVisibleOpenTag(html);
2893
- if (start === -1) return html;
2894
- const end = vtSsrOpenTagEnd(html, start + 1);
2895
- if (end === -1) return html;
2896
- const marker = " vt-" + kind + '-x="';
2897
- const offset = html.slice(start, end).indexOf(marker);
2898
- if (offset === -1) return html;
2899
- const insertion = start + offset;
2900
- return html.slice(0, insertion) + " vt-" + kind + '="' + html.slice(insertion + marker.length);
2901
- }
2902
- function vtSsrStrip(html) {
2903
- if (html.indexOf(" vt-e") === -1) return html;
2904
- return html.replace(/ vt-(?:enter|exit)-x="[^"]*"/g, "");
3512
+ const active = [];
3513
+ const eventName = "vt-" + kind;
3514
+ const candidateName = eventName + "-x";
3515
+ const relayName = "vt-parent-" + kind + "-x";
3516
+ return vtSsrMapTags(html, (open, depth) => {
3517
+ let candidate;
3518
+ let candidateEnd = -1;
3519
+ let event;
3520
+ let eventStart = Infinity;
3521
+ let relay;
3522
+ let relayEnd = -1;
3523
+ if (/vt-/i.test(open))
3524
+ vtSsrAttributes(open, (name, start, end, _quote, nameStart, nameEnd) => {
3525
+ if (name === candidateName && candidate === void 0) {
3526
+ candidate = open.slice(start, end);
3527
+ candidateEnd = nameEnd;
3528
+ } else if (name === eventName && event === void 0) {
3529
+ event = open.slice(start, end);
3530
+ eventStart = nameStart;
3531
+ } else if (name === relayName && relay === void 0) {
3532
+ relay = open.slice(start, end);
3533
+ relayEnd = nameEnd;
3534
+ }
3535
+ });
3536
+ let claimEnd = -1;
3537
+ if (depth === 0 && candidate !== void 0 && candidate !== "none") {
3538
+ claimEnd = candidateEnd;
3539
+ if (candidateEnd < eventStart) event = candidate;
3540
+ }
3541
+ const parentActive = depth > 0 && active[depth - 1];
3542
+ if (parentActive && relay !== void 0 && relay !== "none" && relay !== "auto") {
3543
+ claimEnd = relayEnd;
3544
+ }
3545
+ active[depth] = event !== void 0 && event !== "none" || parentActive && (relay === void 0 || relay !== "none");
3546
+ return claimEnd < 0 ? open : open.slice(0, claimEnd - 2) + open.slice(claimEnd);
3547
+ });
3548
+ }
3549
+ const VT_SSR_STRIP = / vt-(?:parent-)?(?:enter|exit)-x="[^"]*"(?=[^<>"]*(?:"[^"]*"[^<>"]*)*>)/gi;
3550
+ const VT_SSR_OPAQUE = /<!--|<(script|style|title|template)(?=[\t\n\f\r />])/gi;
3551
+ const VT_SSR_CANDIDATE = /vt-(?:parent-)?(?:enter|exit)-x/i;
3552
+ function vtSsrStrip(html, rawHtml) {
3553
+ if (!rawHtml) {
3554
+ let lower = html.indexOf('-x="');
3555
+ let upper = html.indexOf('-X="');
3556
+ if (lower < 0 && upper < 0) return html;
3557
+ const advance = (from2) => {
3558
+ if (lower >= 0 && lower < from2) lower = html.indexOf('-x="', from2);
3559
+ if (upper >= 0 && upper < from2) upper = html.indexOf('-X="', from2);
3560
+ return lower < 0 ? upper : upper < 0 ? lower : Math.min(lower, upper);
3561
+ };
3562
+ let candidate = advance(0);
3563
+ let from = 0;
3564
+ let copied = 0;
3565
+ let out = "";
3566
+ VT_SSR_OPAQUE.lastIndex = 0;
3567
+ let opaque;
3568
+ while ((opaque = VT_SSR_OPAQUE.exec(html)) !== null) {
3569
+ const start = opaque.index;
3570
+ const attr = html.slice(from, start).lastIndexOf('="');
3571
+ if (attr >= 0 && html.indexOf('"', from + attr + 2) > start) {
3572
+ rawHtml = true;
3573
+ break;
3574
+ }
3575
+ if (candidate < start) {
3576
+ const part = html.slice(from, start);
3577
+ const next = part.replace(VT_SSR_STRIP, "");
3578
+ if (next !== part) {
3579
+ out += html.slice(copied, from) + next;
3580
+ copied = start;
3581
+ }
3582
+ candidate = advance(start);
3583
+ if (candidate < 0) return copied === 0 ? html : out + html.slice(copied);
3584
+ }
3585
+ const tag = opaque[1];
3586
+ let end;
3587
+ if (tag === void 0) {
3588
+ const close = html.indexOf("-->", start + 4);
3589
+ end = close < 0 ? html.length : close + 3;
3590
+ } else {
3591
+ const openingEnd = vtSsrOpenTagEnd(html, start + tag.length + 1) + 1;
3592
+ const close = html.indexOf("</" + tag + ">", openingEnd);
3593
+ if (close >= 0) end = close + tag.length + 3;
3594
+ else {
3595
+ const closing = new RegExp("</" + tag + "[\\t\\n\\f\\r ]*>", "gi");
3596
+ closing.lastIndex = openingEnd;
3597
+ end = closing.exec(html) === null ? html.length : closing.lastIndex;
3598
+ }
3599
+ }
3600
+ if (candidate < end) {
3601
+ candidate = advance(end);
3602
+ if (candidate < 0) return copied === 0 ? html : out + html.slice(copied);
3603
+ }
3604
+ from = VT_SSR_OPAQUE.lastIndex = end;
3605
+ }
3606
+ if (!rawHtml)
3607
+ return out + html.slice(copied, from) + html.slice(from).replace(VT_SSR_STRIP, "");
3608
+ }
3609
+ if (!VT_SSR_CANDIDATE.test(html)) return html;
3610
+ return vtSsrMapTags(html, (open) => {
3611
+ if (!VT_SSR_CANDIDATE.test(open)) return open;
3612
+ let out = "";
3613
+ let copied = 0;
3614
+ vtSsrAttributes(open, (name, _start, end, quote, nameStart) => {
3615
+ if (name === "vt-enter-x" || name === "vt-exit-x" || name === "vt-parent-enter-x" || name === "vt-parent-exit-x") {
3616
+ const start = vtSsrSpace(open.charCodeAt(nameStart - 1)) ? nameStart - 1 : nameStart;
3617
+ out += open.slice(copied, start);
3618
+ copied = end + (quote ? 1 : 0);
3619
+ }
3620
+ });
3621
+ return copied === 0 ? open : out + open.slice(copied);
3622
+ });
2905
3623
  }
2906
3624
  const ViewTransition = /* @__PURE__ */ (0, import_component_flags.markComponentFlags)(
2907
3625
  function ViewTransition2(props, scope) {
2908
3626
  VT_SSR_HAS_CANDIDATES = true;
2909
- const explicit = typeof props.name === "string";
3627
+ const explicit = typeof props.name === "string" && props.name !== "auto";
2910
3628
  const frame = FRAME;
2911
3629
  const cand = {
2912
- name: explicit ? props.name : "_O" + (frame !== null ? framePath(frame).replace(/\//g, "-") : "") + "_",
3630
+ elementScope: props.scope === "element",
3631
+ name: explicit ? props.name : "_O" + ID_PREFIX + (STREAM !== null ? STREAM.token + "-" : "") + (frame !== null ? framePath(frame).replace(/\//g, "-") : "") + "_",
2913
3632
  share: vtSsrResolve(props, "share"),
2914
3633
  update: vtSsrResolve(props, "update"),
2915
3634
  consumed: false
@@ -2922,14 +3641,21 @@ const ViewTransition = /* @__PURE__ */ (0, import_component_flags.markComponentF
2922
3641
  } finally {
2923
3642
  VT_SSR_STACK.pop();
2924
3643
  }
2925
- const named = explicit || VT_SSR_TRY_SEQ !== seqBefore;
3644
+ const named = explicit || props.scope !== "element" && VT_SSR_TRY_SEQ !== seqBefore;
2926
3645
  const attrs = [];
2927
3646
  if (named) attrs.push(["vt-name", cand.name]);
2928
3647
  attrs.push(["vt-update", cand.update]);
2929
3648
  attrs.push(["vt-enter-x", vtSsrResolve(props, "enter")]);
2930
3649
  attrs.push(["vt-exit-x", vtSsrResolve(props, "exit")]);
2931
- if (named) attrs.push(["vt-share", cand.share]);
2932
- return ssrHtml(ssrBlock(vtSsrAnnotate(inner, attrs)));
3650
+ if (named) attrs.push(["vt-share", VT_SSR_TRY_SEQ !== seqBefore ? cand.update : cand.share]);
3651
+ for (const kind of ["Enter", "Exit"]) {
3652
+ const prop = props["parent" + kind];
3653
+ const value = prop === void 0 ? void 0 : vtSsrResolve(props, "parent" + kind);
3654
+ const handler = props["onParent" + kind];
3655
+ attrs.push(["vt-parent-" + kind.toLowerCase() + "-x", value ?? (handler ? "auto" : "none")]);
3656
+ }
3657
+ const annotated = vtSsrAnnotate(inner, attrs);
3658
+ return ssrHtml(ssrBlock(props.scope === "element" ? vtSsrAnnotateScope(annotated) : annotated));
2933
3659
  },
2934
3660
  import_component_flags.COMPONENT_FLAG_BOUNDARY,
2935
3661
  "ViewTransition"
@@ -3028,7 +3754,8 @@ function normalizeThrownServerThenable(error) {
3028
3754
  comp: CURRENT_COMP,
3029
3755
  props: CURRENT_PROPS,
3030
3756
  parentScope: CURRENT_PARENT_SCOPE,
3031
- frame
3757
+ frame,
3758
+ signalInstanceKey: SIGNAL_COMPONENT_INSTANCE_KEY
3032
3759
  });
3033
3760
  }
3034
3761
  return SSR_SUSPENSE;
@@ -3300,7 +4027,8 @@ function use(usable, siteKey, directSite) {
3300
4027
  comp: CURRENT_COMP,
3301
4028
  props: CURRENT_PROPS,
3302
4029
  parentScope: CURRENT_PARENT_SCOPE,
3303
- frame
4030
+ frame,
4031
+ signalInstanceKey: SIGNAL_COMPONENT_INSTANCE_KEY
3304
4032
  });
3305
4033
  }
3306
4034
  throw SSR_SUSPENSE;
@@ -3467,7 +4195,8 @@ function puBatch(thenables, warm) {
3467
4195
  comp: CURRENT_COMP,
3468
4196
  props: CURRENT_PROPS,
3469
4197
  parentScope: CURRENT_PARENT_SCOPE,
3470
- frame
4198
+ frame,
4199
+ signalInstanceKey: SIGNAL_COMPONENT_INSTANCE_KEY
3471
4200
  });
3472
4201
  }
3473
4202
  throw SSR_SUSPENSE;
@@ -3631,7 +4360,8 @@ function lazy(load) {
3631
4360
  comp: CURRENT_COMP,
3632
4361
  props: CURRENT_PROPS,
3633
4362
  parentScope: CURRENT_PARENT_SCOPE,
3634
- frame
4363
+ frame,
4364
+ signalInstanceKey: SIGNAL_COMPONENT_INSTANCE_KEY
3635
4365
  });
3636
4366
  }
3637
4367
  throw SSR_SUSPENSE;
@@ -3958,7 +4688,12 @@ function isChildrenBlock(value) {
3958
4688
  return typeof value === "function" && value[CHILDREN_BLOCK] === true;
3959
4689
  }
3960
4690
  function injectStyle(id, css, nonce) {
3961
- if (CSS !== null) CSS.set(id, nonce === void 0 ? { css } : { css, nonce });
4691
+ if (CSS !== null) {
4692
+ const previous = CSS.get(id);
4693
+ if (previous !== void 0 && previous.css === css && previous.nonce === nonce) return;
4694
+ CSS.replay = null;
4695
+ CSS.set(id, nonce === void 0 ? { css } : { css, nonce });
4696
+ }
3962
4697
  }
3963
4698
  function styleMap(id, css, map, applied = []) {
3964
4699
  let touching = false;
@@ -4112,9 +4847,26 @@ function serializeNativeSignalSeeds(signals, nonceAttr, attr = import_native_rea
4112
4847
  const json = JSON.stringify(signals).replace(/</g, "\\u003c");
4113
4848
  return '<script type="application/json" ' + attr + nonceAttr + ">" + json + "</script>";
4114
4849
  }
4850
+ let SERVER_SIGNAL_BINDINGS_ENABLED = false;
4851
+ let SERVER_SIGNAL_BINDINGS_POTENTIAL = false;
4852
+ function enableServerSignalBindings(abi = 1, potentialOnly = false) {
4853
+ if (abi !== 1) throw new TypeError((0, import_error_codes_server_generated.formatServerError)(71));
4854
+ SERVER_SIGNAL_BINDINGS_POTENTIAL = true;
4855
+ if (!potentialOnly) SERVER_SIGNAL_BINDINGS_ENABLED = true;
4856
+ }
4857
+ function isRendererSignalOwner(owner) {
4858
+ return "documentOwner" in owner;
4859
+ }
4115
4860
  function newResolvedMap(resourceOptions) {
4116
4861
  const m = /* @__PURE__ */ new Map();
4117
4862
  if (resourceOptions !== void 0) m.resourceOptions = resourceOptions;
4863
+ if (SERVER_SIGNAL_BINDINGS_ENABLED || resourceOptions?.signalOwner !== void 0) {
4864
+ const ambient = (0, import_owner_context.currentSignalOwner)();
4865
+ const configured = resourceOptions?.signalOwner ?? ambient;
4866
+ m.signalOwner = configured === void 0 || configured === null ? Object.freeze({ scopeKey: "octane:document" }) : isRendererSignalOwner(configured) ? configured.documentOwner : configured;
4867
+ m.ownedSignalOwner = configured === void 0 || configured === null;
4868
+ m.signalInstances = /* @__PURE__ */ new Map();
4869
+ }
4118
4870
  m.asyncIdentities = /* @__PURE__ */ new Map();
4119
4871
  m.asyncPositionIdentities = /* @__PURE__ */ new Map();
4120
4872
  m.nextAsyncIdentity = 0;
@@ -4148,8 +4900,23 @@ function getServerRenderResourceContext() {
4148
4900
  return resources;
4149
4901
  }
4150
4902
  function releaseServerRenderResources(resolved) {
4903
+ const settlements = resolved.streamSettlements;
4904
+ if (settlements !== void 0) {
4905
+ resolved.streamSettlements = void 0;
4906
+ settlements.resolved = null;
4907
+ settlements.wake = null;
4908
+ for (const recorder of settlements.pending.values()) recorder.keys = null;
4909
+ settlements.pending.clear();
4910
+ }
4151
4911
  const resources = resolved.resources;
4152
4912
  resolved.resourceOptions = void 0;
4913
+ if (resolved.signalInstances !== void 0) {
4914
+ for (const owner of resolved.signalInstances.values()) (0, import_owner_context.retireSignalOwnerIdentity)(owner);
4915
+ resolved.signalInstances.clear();
4916
+ }
4917
+ if (resolved.ownedSignalOwner && resolved.signalOwner !== void 0) {
4918
+ (0, import_owner_context.retireSignalOwnerIdentity)(resolved.signalOwner);
4919
+ }
4153
4920
  if (resources !== void 0) resolved.resources = void 0;
4154
4921
  if (resources === void 0 || resources.finished) return;
4155
4922
  resources.finished = true;
@@ -4175,6 +4942,11 @@ function saveAmbient() {
4175
4942
  warmClaims: CURRENT_PU_WARM_CLAIMS,
4176
4943
  id: ID_COUNTER,
4177
4944
  idPrefix: ID_PREFIX,
4945
+ signalInstancePrefix: SIGNAL_INSTANCE_PREFIX,
4946
+ signalComponentInstanceKey: SIGNAL_COMPONENT_INSTANCE_KEY,
4947
+ signalOwnerActive: SERVER_SIGNAL_OWNER_ACTIVE,
4948
+ signalControlSite: SIGNAL_CONTROL_SITE,
4949
+ signalListKeys: SIGNAL_LIST_KEYS,
4178
4950
  css: CSS,
4179
4951
  nonceAttr: NONCE_ATTR,
4180
4952
  markers: MARKERS,
@@ -4194,6 +4966,7 @@ function saveAmbient() {
4194
4966
  nestingWarnings: SSR_NESTING_WARNINGS,
4195
4967
  vtTrySeq: VT_SSR_TRY_SEQ,
4196
4968
  vtHasCandidates: VT_SSR_HAS_CANDIDATES,
4969
+ vtHasRawHtml: VT_SSR_HAS_RAW_HTML,
4197
4970
  vtStack: snapshotVtStack()
4198
4971
  };
4199
4972
  }
@@ -4227,6 +5000,11 @@ function restoreAmbient(a) {
4227
5000
  CURRENT_PU_WARM_CLAIMS = a.warmClaims;
4228
5001
  ID_COUNTER = a.id;
4229
5002
  ID_PREFIX = a.idPrefix;
5003
+ SIGNAL_INSTANCE_PREFIX = a.signalInstancePrefix;
5004
+ SIGNAL_COMPONENT_INSTANCE_KEY = a.signalComponentInstanceKey;
5005
+ SERVER_SIGNAL_OWNER_ACTIVE = a.signalOwnerActive;
5006
+ SIGNAL_CONTROL_SITE = a.signalControlSite;
5007
+ SIGNAL_LIST_KEYS = a.signalListKeys;
4230
5008
  CSS = a.css;
4231
5009
  NONCE_ATTR = a.nonceAttr;
4232
5010
  MARKERS = a.markers;
@@ -4246,6 +5024,7 @@ function restoreAmbient(a) {
4246
5024
  SSR_NESTING_WARNINGS = a.nestingWarnings;
4247
5025
  VT_SSR_TRY_SEQ = a.vtTrySeq;
4248
5026
  VT_SSR_HAS_CANDIDATES = a.vtHasCandidates;
5027
+ VT_SSR_HAS_RAW_HTML = a.vtHasRawHtml;
4249
5028
  VT_SSR_STACK.length = 0;
4250
5029
  for (const snapshot of a.vtStack) {
4251
5030
  snapshot.candidate.consumed = snapshot.consumed;
@@ -4266,15 +5045,22 @@ function runFullFramedPass(component, props, resolved, nonceAttr = "", identifie
4266
5045
  CURRENT_PU_WARM_CLAIMS = null;
4267
5046
  ID_COUNTER = 0;
4268
5047
  ID_PREFIX = identifierPrefix;
5048
+ SIGNAL_INSTANCE_PREFIX = identifierPrefix;
5049
+ SIGNAL_COMPONENT_INSTANCE_KEY = JSON.stringify([identifierPrefix, "root"]);
5050
+ SERVER_SIGNAL_OWNER_ACTIVE = false;
5051
+ SIGNAL_CONTROL_SITE = "";
5052
+ SIGNAL_LIST_KEYS = EMPTY_SIGNAL_LIST_KEYS;
4269
5053
  NONCE_ATTR = nonceAttr;
4270
5054
  ASYNC_SCOPE = "";
4271
5055
  MARKERS = markers;
4272
5056
  PERMANENT_STATIC_HYDRATE_DEPTH = 0;
4273
5057
  VT_SSR_TRY_SEQ = 0;
4274
5058
  VT_SSR_HAS_CANDIDATES = false;
5059
+ VT_SSR_HAS_RAW_HTML = false;
4275
5060
  VT_SSR_STACK.length = 0;
4276
- const cssMap = CSS = /* @__PURE__ */ new Map();
5061
+ const cssMap = CSS = newStyleCollector();
4277
5062
  const headBuf = HEAD = {
5063
+ replay: null,
4278
5064
  html: "",
4279
5065
  charset: "",
4280
5066
  viewport: "",
@@ -4309,6 +5095,7 @@ function runFullFramedPass(component, props, resolved, nonceAttr = "", identifie
4309
5095
  CURRENT_PARENT_SCOPE = null;
4310
5096
  let body = "";
4311
5097
  let vtCandidates = false;
5098
+ let rawHtml = false;
4312
5099
  let rootSuspended = false;
4313
5100
  let signals;
4314
5101
  let nativePassCompleted = false;
@@ -4316,6 +5103,10 @@ function runFullFramedPass(component, props, resolved, nonceAttr = "", identifie
4316
5103
  try {
4317
5104
  const out = invokeComponentBody(component, props, root, FRAME);
4318
5105
  body = serverComponentOutput(out, root);
5106
+ if (markers && out !== null && typeof out === "object") {
5107
+ const marker = out[BINDING_HTML_ROOT];
5108
+ if (marker !== void 0) body = ssrBindingBlock(body, marker);
5109
+ }
4319
5110
  nativePassCompleted = true;
4320
5111
  } catch (err) {
4321
5112
  err = normalizeThrownServerThenable(err);
@@ -4323,12 +5114,18 @@ function runFullFramedPass(component, props, resolved, nonceAttr = "", identifie
4323
5114
  rootSuspended = true;
4324
5115
  } finally {
4325
5116
  vtCandidates = VT_SSR_HAS_CANDIDATES;
5117
+ rawHtml = VT_SSR_HAS_RAW_HTML;
4326
5118
  try {
4327
5119
  if (nativeToken >= 0) NATIVE_READ_COLLECTOR.endScope(nativeToken, nativePassCompleted);
4328
5120
  if (markers && nativePassCompleted)
4329
5121
  signals = NATIVE_READ_COLLECTOR?.serialize(NATIVE_SERVER_READS);
4330
5122
  } finally {
4331
- restoreAmbient(saved);
5123
+ try {
5124
+ restoreAmbient(saved);
5125
+ } finally {
5126
+ cssMap.replay = null;
5127
+ headBuf.replay = null;
5128
+ }
4332
5129
  }
4333
5130
  }
4334
5131
  if (resolved.bufferedErrors !== void 0) {
@@ -4352,8 +5149,10 @@ function runFullFramedPass(component, props, resolved, nonceAttr = "", identifie
4352
5149
  deferred,
4353
5150
  rootSuspended,
4354
5151
  vtCandidates,
5152
+ rawHtml,
4355
5153
  cssEntries: cssMap,
4356
- sheets: headBuf.sheets
5154
+ sheets: headBuf.sheets,
5155
+ hasSignalControls: resolved.hasSignalControls === true
4357
5156
  };
4358
5157
  if (signals !== void 0) result.signals = signals;
4359
5158
  return result;
@@ -4368,15 +5167,22 @@ function runDiscoveryRound(jobs, resolved, identifierPrefix) {
4368
5167
  CURRENT_PU_WARM_CLAIMS = null;
4369
5168
  ID_COUNTER = 0;
4370
5169
  ID_PREFIX = identifierPrefix;
5170
+ SIGNAL_INSTANCE_PREFIX = identifierPrefix;
5171
+ SIGNAL_COMPONENT_INSTANCE_KEY = JSON.stringify([identifierPrefix, "root"]);
5172
+ SERVER_SIGNAL_OWNER_ACTIVE = false;
5173
+ SIGNAL_CONTROL_SITE = "";
5174
+ SIGNAL_LIST_KEYS = EMPTY_SIGNAL_LIST_KEYS;
4371
5175
  NONCE_ATTR = "";
4372
5176
  ASYNC_SCOPE = "";
4373
5177
  MARKERS = true;
4374
5178
  PERMANENT_STATIC_HYDRATE_DEPTH = 0;
4375
5179
  VT_SSR_TRY_SEQ = 0;
4376
5180
  VT_SSR_HAS_CANDIDATES = false;
5181
+ VT_SSR_HAS_RAW_HTML = false;
4377
5182
  VT_SSR_STACK.length = 0;
4378
- CSS = /* @__PURE__ */ new Map();
5183
+ CSS = newStyleCollector();
4379
5184
  HEAD = {
5185
+ replay: null,
4380
5186
  html: "",
4381
5187
  charset: "",
4382
5188
  viewport: "",
@@ -4412,7 +5218,14 @@ function runDiscoveryRound(jobs, resolved, identifierPrefix) {
4412
5218
  namespace: void 0
4413
5219
  };
4414
5220
  try {
4415
- renderComponentFramed(job.comp, job.props, job.parentScope, frame);
5221
+ renderComponentFramed(
5222
+ job.comp,
5223
+ job.props,
5224
+ job.parentScope,
5225
+ frame,
5226
+ void 0,
5227
+ job.signalInstanceKey
5228
+ );
4416
5229
  } catch (err) {
4417
5230
  if (!ssrIsSuspense(err)) continue;
4418
5231
  }
@@ -4471,30 +5284,62 @@ async function settleSuspended(suspended, resolved, timeoutMs, signal) {
4471
5284
  await raceSettleGuards(settleAll, timeoutMs, signal);
4472
5285
  }
4473
5286
  const yieldMacrotask = typeof setImmediate === "function" ? () => new Promise((resolve) => setImmediate(resolve)) : () => new Promise((resolve) => setTimeout(resolve, 0));
5287
+ async function recordStreamSettlement(settlements, recorder) {
5288
+ let outcome;
5289
+ try {
5290
+ outcome = { value: await recorder.promise, thenable: recorder.promise };
5291
+ } catch (reason) {
5292
+ outcome = { reason, thenable: recorder.promise };
5293
+ }
5294
+ const resolved = settlements.resolved;
5295
+ if (resolved === null) return;
5296
+ if (!resolved.has(recorder.key)) resolved.set(recorder.key, outcome);
5297
+ if (recorder.keys !== null) {
5298
+ for (const key of recorder.keys) {
5299
+ if (!resolved.has(key)) resolved.set(key, outcome);
5300
+ }
5301
+ recorder.keys = null;
5302
+ }
5303
+ if (recorder.batch && !resolved.pu.resolvedT.has(recorder.promise)) {
5304
+ resolved.pu.resolvedT.set(recorder.promise, outcome);
5305
+ }
5306
+ settlements.pending.delete(recorder.promise);
5307
+ if (recorder.wave === settlements.wave) settlements.wake?.();
5308
+ }
4474
5309
  async function settleFirstOfWave(suspended, resolved, timeoutMs, signal) {
4475
5310
  const pu = resolved.pu;
4476
5311
  pu.recreate ??= { strikes: 0, prevCreated: pu.created.size };
4477
- const recorders = [];
5312
+ const settlements = resolved.streamSettlements ??= {
5313
+ resolved,
5314
+ pending: /* @__PURE__ */ new Map(),
5315
+ wave: 0,
5316
+ wake: null
5317
+ };
5318
+ const wave = ++settlements.wave;
5319
+ let waiting = false;
4478
5320
  for (const { promise, key } of suspended) {
4479
5321
  if (resolved.has(key)) continue;
4480
- const isPu = key.startsWith("|pu#");
4481
- recorders.push(
4482
- (async () => {
4483
- try {
4484
- const value = await promise;
4485
- const outcome = { value, thenable: promise };
4486
- if (!resolved.has(key)) resolved.set(key, outcome);
4487
- if (isPu && !pu.resolvedT.has(promise)) pu.resolvedT.set(promise, outcome);
4488
- } catch (reason) {
4489
- const outcome = { reason, thenable: promise };
4490
- if (!resolved.has(key)) resolved.set(key, outcome);
4491
- if (isPu && !pu.resolvedT.has(promise)) pu.resolvedT.set(promise, outcome);
4492
- }
4493
- })()
4494
- );
5322
+ let recorder = settlements.pending.get(promise);
5323
+ if (recorder === void 0) {
5324
+ recorder = { promise, key, keys: null, batch: key.startsWith("|pu#"), wave };
5325
+ settlements.pending.set(promise, recorder);
5326
+ void recordStreamSettlement(settlements, recorder);
5327
+ } else {
5328
+ if (key !== recorder.key) (recorder.keys ??= /* @__PURE__ */ new Set()).add(key);
5329
+ if (key.startsWith("|pu#")) recorder.batch = true;
5330
+ recorder.wave = wave;
5331
+ }
5332
+ waiting = true;
5333
+ }
5334
+ if (!waiting) return;
5335
+ const first = new Promise((resolve) => {
5336
+ settlements.wake = resolve;
5337
+ });
5338
+ try {
5339
+ await raceSettleGuards(first, timeoutMs, signal);
5340
+ } finally {
5341
+ settlements.wake = null;
4495
5342
  }
4496
- if (recorders.length === 0) return;
4497
- await raceSettleGuards(Promise.race(recorders), timeoutMs, signal);
4498
5343
  await yieldMacrotask();
4499
5344
  let size = resolved.size;
4500
5345
  for (; ; ) {
@@ -4598,38 +5443,129 @@ async function runBuffered(component, props, options, nonceAttr, resolved) {
4598
5443
  if (resolved.pu.touched !== void 0) resolved.pu.touched = /* @__PURE__ */ new Set();
4599
5444
  }
4600
5445
  }
4601
- function passToResult(pass, nonceAttr, separateHead = false) {
5446
+ function passToResult(pass, nonceAttr, separateHead = false, independentHydration = false, externalSignalBootstrap = false) {
4602
5447
  let body = pass.body;
4603
5448
  if (pass.serial.length > 0) body += serializeSuspenseSeeds(pass.serial, nonceAttr);
4604
5449
  if (pass.signals !== void 0) body += serializeNativeSignalSeeds(pass.signals, nonceAttr);
5450
+ if (!externalSignalBootstrap && (pass.hasSignalControls || independentHydration)) {
5451
+ body += "<script " + import_constants.STREAM_SCRIPT_ATTR + nonceAttr + ">" + (0, import_early_signals.streamedSignalBootstrapJs)(independentHydration) + "</script>";
5452
+ }
4605
5453
  let result;
4606
5454
  if (separateHead) {
4607
5455
  result = {
4608
- html: pass.vtCandidates ? vtSsrStrip(body) : body,
5456
+ html: pass.vtCandidates ? vtSsrStrip(body, pass.rawHtml) : body,
4609
5457
  css: pass.css,
4610
- head: pass.vtCandidates ? vtSsrStrip(pass.head) : pass.head
5458
+ head: pass.vtCandidates ? vtSsrStrip(pass.head, pass.rawHtml) : pass.head
4611
5459
  };
4612
5460
  } else {
4613
5461
  const html = spliceHead(body, pass.head);
4614
- result = { html: pass.vtCandidates ? vtSsrStrip(html) : html, css: pass.css };
5462
+ result = { html: pass.vtCandidates ? vtSsrStrip(html, pass.rawHtml) : html, css: pass.css };
4615
5463
  }
4616
5464
  if (pass.signals !== void 0) result.signals = pass.signals;
4617
5465
  return result;
4618
5466
  }
5467
+ async function collectBufferedInjection(injection, signal) {
5468
+ let revision = 0;
5469
+ let wake;
5470
+ let settled = false;
5471
+ let failed = false;
5472
+ let failure;
5473
+ const notify = () => {
5474
+ revision++;
5475
+ const resume = wake;
5476
+ wake = void 0;
5477
+ resume?.();
5478
+ };
5479
+ const unsubscribe = injection.subscribe(notify);
5480
+ signal?.addEventListener("abort", notify, { once: true });
5481
+ injection.done.then(
5482
+ () => {
5483
+ settled = true;
5484
+ notify();
5485
+ },
5486
+ (error) => {
5487
+ failed = true;
5488
+ failure = error;
5489
+ settled = true;
5490
+ notify();
5491
+ }
5492
+ );
5493
+ let html = "";
5494
+ try {
5495
+ injection.renderComplete?.();
5496
+ for (; ; ) {
5497
+ signal?.throwIfAborted();
5498
+ const chunk = injection.take();
5499
+ if (chunk !== "") {
5500
+ html += chunk;
5501
+ injection.accepted?.();
5502
+ continue;
5503
+ }
5504
+ if (settled) {
5505
+ if (failed) throw failure;
5506
+ return html;
5507
+ }
5508
+ const observed = revision;
5509
+ await new Promise((resolve) => {
5510
+ wake = resolve;
5511
+ if (settled || revision !== observed) {
5512
+ wake = void 0;
5513
+ resolve();
5514
+ }
5515
+ });
5516
+ }
5517
+ } finally {
5518
+ unsubscribe();
5519
+ signal?.removeEventListener("abort", notify);
5520
+ }
5521
+ }
5522
+ function insertBufferedInjection(pass, injection) {
5523
+ if (injection === "") return;
5524
+ const tailStart = documentTailStart(pass.body);
5525
+ pass.body = tailStart === -1 ? pass.body + injection : pass.body.slice(0, tailStart) + injection + pass.body.slice(tailStart);
5526
+ }
4619
5527
  async function prerender(entryComponent, props, options) {
4620
5528
  const component = typeof entryComponent === "function" ? entryComponent : renderEntryValue;
4621
5529
  if (typeof entryComponent !== "function") {
4622
5530
  options ??= props;
4623
5531
  props = { value: entryComponent };
4624
5532
  }
4625
- const nonceAttr = nonceAttrOf(options);
4626
- const resolved = newResolvedMap(options ?? null);
5533
+ const preparedOptions = needsAutomaticSignalInjection(options) ? await prepareAutomaticSignalInjection(options) : options;
5534
+ const injection = preparedOptions?.injection;
5535
+ const cancelRender = injection === void 0 ? void 0 : new AbortController();
5536
+ injection?.done.then(NOOP, (error) => cancelRender.abort(error));
5537
+ const renderOptions = cancelRender === void 0 ? preparedOptions : {
5538
+ ...preparedOptions,
5539
+ signal: preparedOptions?.signal === void 0 ? cancelRender.signal : AbortSignal.any([preparedOptions.signal, cancelRender.signal])
5540
+ };
5541
+ const nonceAttr = nonceAttrOf(renderOptions);
5542
+ const resolved = newResolvedMap(renderOptions ?? null);
4627
5543
  try {
5544
+ const pass = await runBuffered(component, props, renderOptions, nonceAttr, resolved);
5545
+ if (injection !== void 0) {
5546
+ try {
5547
+ insertBufferedInjection(
5548
+ pass,
5549
+ await collectBufferedInjection(injection, renderOptions?.signal)
5550
+ );
5551
+ } catch (error) {
5552
+ renderOptions?.onError?.(error);
5553
+ throw error;
5554
+ }
5555
+ }
4628
5556
  return passToResult(
4629
- await runBuffered(component, props, options, nonceAttr, resolved),
5557
+ pass,
4630
5558
  nonceAttr,
4631
- options?.headChannel === "separate"
5559
+ renderOptions?.headChannel === "separate",
5560
+ renderOptions?.independentHydration !== void 0,
5561
+ renderOptions?.earlySignalBootstrap === "external"
4632
5562
  );
5563
+ } catch (error) {
5564
+ try {
5565
+ injection?.cancel?.(error);
5566
+ } catch {
5567
+ }
5568
+ throw error;
4633
5569
  } finally {
4634
5570
  releaseServerRenderResources(resolved);
4635
5571
  }
@@ -4719,7 +5655,7 @@ function renderHostedAttempt(session, component, props, options) {
4719
5655
  let body = pass.body;
4720
5656
  if (pass.serial.length > 0) body += serializeSuspenseSeeds(pass.serial, nonceAttr);
4721
5657
  if (pass.signals !== void 0) body += serializeNativeSignalSeeds(pass.signals, nonceAttr);
4722
- if (pass.vtCandidates) body = vtSsrStrip(body);
5658
+ if (pass.vtCandidates) body = vtSsrStrip(body, pass.rawHtml);
4723
5659
  return { status: "complete", html: body, head: pass.head, cssEntries: pass.cssEntries };
4724
5660
  }
4725
5661
  function renderToString(entryComponent, props, options) {
@@ -4744,7 +5680,13 @@ function renderToString(entryComponent, props, options) {
4744
5680
  } finally {
4745
5681
  releaseServerRenderResources(resolved);
4746
5682
  }
4747
- return passToResult(pass, nonceAttr, options?.headChannel === "separate");
5683
+ return passToResult(
5684
+ pass,
5685
+ nonceAttr,
5686
+ options?.headChannel === "separate",
5687
+ options?.independentHydration !== void 0,
5688
+ options?.earlySignalBootstrap === "external"
5689
+ );
4748
5690
  }
4749
5691
  function renderToStaticMarkup(entryComponent, props, options) {
4750
5692
  const component = typeof entryComponent === "function" ? entryComponent : renderEntryValue;
@@ -4777,13 +5719,19 @@ function renderToStaticMarkup(entryComponent, props, options) {
4777
5719
  }
4778
5720
  if (options?.headChannel === "separate") {
4779
5721
  return {
4780
- html: pass.vtCandidates ? vtSsrStrip(pass.body) : pass.body,
5722
+ html: pass.vtCandidates ? vtSsrStrip(pass.body, pass.rawHtml) : pass.body,
4781
5723
  css: pass.css,
4782
- head: pass.vtCandidates ? vtSsrStrip(pass.head) : pass.head
5724
+ head: pass.vtCandidates ? vtSsrStrip(pass.head, pass.rawHtml) : pass.head
4783
5725
  };
4784
5726
  }
4785
5727
  const html = spliceHead(pass.body, pass.head);
4786
- return { html: pass.vtCandidates ? vtSsrStrip(html) : html, css: pass.css };
5728
+ return { html: pass.vtCandidates ? vtSsrStrip(html, pass.rawHtml) : html, css: pass.css };
5729
+ }
5730
+ function hasPendingStreamBoundary(stream) {
5731
+ for (const boundary of stream.boundaries.values()) {
5732
+ if (boundary.state === "pending") return true;
5733
+ }
5734
+ return false;
4787
5735
  }
4788
5736
  function recordStreamBoundaryMutation(stream, key) {
4789
5737
  if (stream.replay === null) return;
@@ -4867,7 +5815,7 @@ function ssrTry(scope, siteKey, tryFn, pendFn, catchFn, namespace = FRAME?.names
4867
5815
  let vtOuter = null;
4868
5816
  if (VT_SSR_STACK.length > 0) {
4869
5817
  const top = VT_SSR_STACK[VT_SSR_STACK.length - 1];
4870
- if (!top.consumed) {
5818
+ if (!top.consumed && !top.elementScope) {
4871
5819
  top.consumed = true;
4872
5820
  vtOuter = top;
4873
5821
  }
@@ -5000,15 +5948,16 @@ function ssrTry(scope, siteKey, tryFn, pendFn, catchFn, namespace = FRAME?.names
5000
5948
  const deferredStart = DEFERRED?.length ?? 0;
5001
5949
  const serialStart2 = SERIAL?.length ?? 0;
5002
5950
  const css = CSS;
5003
- const cssSnapshot = snapshotMap(css);
5951
+ const cssSnapshot = snapshotStyles(css);
5004
5952
  const head = HEAD;
5953
+ const headCollections = snapshotHeadCollections(head);
5005
5954
  const headHtml = head?.html;
5006
5955
  const headCharset = head?.charset;
5007
5956
  const headViewport = head?.viewport;
5008
- const headHints = snapshotSet(head?.hints);
5009
- const headSheets = snapshotMap(head?.sheets);
5010
- const headHintHtml = snapshotMap(head?.hintHtml);
5011
- const headXfer = snapshotMap(head?.preloadXfer);
5957
+ const headHints = headCollections?.hints ?? null;
5958
+ const headSheets = headCollections?.sheets ?? null;
5959
+ const headHintHtml = headCollections?.hintHtml ?? null;
5960
+ const headXfer = headCollections?.preloadXfer ?? null;
5012
5961
  const vtTrySeq = VT_SSR_TRY_SEQ;
5013
5962
  const vtHasCandidates = VT_SSR_HAS_CANDIDATES;
5014
5963
  const vtStack = snapshotVtStack();
@@ -5024,10 +5973,12 @@ function ssrTry(scope, siteKey, tryFn, pendFn, catchFn, namespace = FRAME?.names
5024
5973
  if (DEFERRED !== null) DEFERRED.length = deferredStart;
5025
5974
  if (SERIAL !== null) SERIAL.length = serialStart2;
5026
5975
  if (css !== null && cssSnapshot !== null) {
5976
+ css.replay = null;
5027
5977
  css.clear();
5028
5978
  for (const [hash, sheet] of cssSnapshot) css.set(hash, sheet);
5029
5979
  }
5030
5980
  if (head !== null && headHints !== null) {
5981
+ head.replay = null;
5031
5982
  head.html = headHtml;
5032
5983
  head.charset = headCharset;
5033
5984
  head.viewport = headViewport;
@@ -5087,10 +6038,11 @@ function ssrTry(scope, siteKey, tryFn, pendFn, catchFn, namespace = FRAME?.names
5087
6038
  if (!entry.serverOwnedStatic)
5088
6039
  entry.signals = NATIVE_READ_COLLECTOR?.serialize(nativeReads);
5089
6040
  entry.state = "done";
6041
+ entry.rawHtml = VT_SSR_HAS_RAW_HTML;
5090
6042
  entry.html = vtOuter !== null ? vtSsrAnnotate(inner, [
5091
6043
  ["vt-name", vtOuter.name],
5092
6044
  ["vt-update", vtOuter.update],
5093
- ["vt-share", vtOuter.share]
6045
+ ["vt-share", vtOuter.update]
5094
6046
  ]) : inner;
5095
6047
  if (SERIAL !== null) {
5096
6048
  if (!entry.serverOwnedStatic) entry.seeds = SERIAL.slice(serialStart);
@@ -5130,6 +6082,7 @@ function ssrTry(scope, siteKey, tryFn, pendFn, catchFn, namespace = FRAME?.names
5130
6082
  state: "pending",
5131
6083
  serverOwnedStatic: PERMANENT_STATIC_HYDRATE_DEPTH !== 0,
5132
6084
  html: "",
6085
+ rawHtml: false,
5133
6086
  seeds: [],
5134
6087
  pendingIdOffset,
5135
6088
  namespace,
@@ -5172,6 +6125,7 @@ function ssrTry(scope, siteKey, tryFn, pendFn, catchFn, namespace = FRAME?.names
5172
6125
  }
5173
6126
  entry.state = "done";
5174
6127
  entry.html = inner;
6128
+ entry.rawHtml = VT_SSR_HAS_RAW_HTML;
5175
6129
  entry.seeds = nativeFresh ? [] : caughtSeeds;
5176
6130
  pruneUnrepresentedStreamDescendants(stream, key, entry.html);
5177
6131
  } else if (SERIAL !== null) {
@@ -5197,6 +6151,7 @@ function ssrTry(scope, siteKey, tryFn, pendFn, catchFn, namespace = FRAME?.names
5197
6151
  serverOwnedStatic: false,
5198
6152
  error: e,
5199
6153
  html: "",
6154
+ rawHtml: false,
5200
6155
  seeds: [],
5201
6156
  pendingIdOffset,
5202
6157
  namespace,
@@ -5236,7 +6191,230 @@ function ssrTry(scope, siteKey, tryFn, pendFn, catchFn, namespace = FRAME?.names
5236
6191
  }
5237
6192
  let STREAM_RUNTIME_JS;
5238
6193
  function streamRuntimeJs() {
5239
- 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[" + import_constants.STREAM_BOUNDARY_ATTR + `="'+id+'"]');var s=d.querySelector('[` + import_constants.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[` + import_constants.STREAM_SEED_ATTR + ']");if(sd){S[id]=sd.textContent;sd.parentNode.removeChild(sd);}var ns=c.firstElementChild;while(ns&&!(ns.localName==="script"&&ns.hasAttribute("' + import_native_read_seeds.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("' + import_constants.STREAM_SEED_COMMENT + `"+id),t);s.parentNode.removeChild(s);};window.$OCTRX=function(id,so){var t=d.querySelector('template[` + import_constants.STREAM_BOUNDARY_ATTR + `="'+id+'"]');if(t){if(so)t.remove();else t.setAttribute("data-oct-err","");}};window.$OCTRH=function(id){var c=d.querySelector('[` + import_constants.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();};})();`;
6194
+ 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("' + import_constants.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[` + import_constants.STREAM_BOUNDARY_ATTR + `="'+id+'"]');var s=d.querySelector('[` + import_constants.STREAM_SEGMENT_ATTR + `="'+id+'"]');if(!s)return;if(!t){s.remove();return;}var c=P(s);if(!c)return;var sd=c.querySelector("script[` + import_constants.STREAM_SEED_ATTR + ']");if(sd){S[id]=sd.textContent;sd.parentNode.removeChild(sd);}var ns=c.firstElementChild;while(ns&&!(ns.localName==="script"&&ns.hasAttribute("' + import_native_read_seeds.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("' + import_constants.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[` + import_constants.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('[` + import_constants.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();};})();`;
6195
+ }
6196
+ let STREAM_VIEW_TRANSITION_RUNTIME_JS;
6197
+ function streamViewTransitionRuntimeJs() {
6198
+ return STREAM_VIEW_TRANSITION_RUNTIME_JS ??= `(function(){
6199
+ var w=window,d=document;
6200
+ if(w.$OCTVT)return;
6201
+ w.$OCTVT=true;
6202
+ var reveal=w.$OCTRC,queue=[],scheduled=false,callbackOnly=new WeakSet(),ready=new WeakSet(),waitReady=new WeakSet(),waitFinish=new WeakSet();
6203
+ w.$OCTRC=function(id,nc){
6204
+ if(typeof d.startViewTransition!=="function"&&typeof Element.prototype.startViewTransition!=="function"){reveal(id,nc);return;}
6205
+ queue.push([id,nc]);later();
6206
+ };
6207
+ function later(){if(queue.length&&!scheduled){scheduled=true;queueMicrotask(function(){scheduled=false;drain();});}}
6208
+ function watch(handle,untilReady){
6209
+ var watched=untilReady?waitReady:waitFinish;
6210
+ if(watched.has(handle))return;
6211
+ watched.add(handle);
6212
+ if(untilReady)handle.ready.then(function(){ready.add(handle);later();},function(){watch(handle,false);});
6213
+ else handle.finished.then(later,later);
6214
+ }
6215
+ function ownerOf(t){
6216
+ var scope=t.closest("[vt-scope]");
6217
+ return scope?(scope.getAttribute("vt-scope")==="element"?scope:null):d;
6218
+ }
6219
+ function blocked(owner){
6220
+ var handle=d.__octaneViewTransition,blocked=false;
6221
+ if(handle&&!(owner&&owner!==d&&ready.has(handle))){watch(handle,!!owner&&owner!==d);blocked=true;}
6222
+ var scopes=d.__octaneViewTransitionScopes;
6223
+ if(scopes)scopes.forEach(function(active,element){
6224
+ if(!owner||owner===d||owner===element||owner.contains(element)){watch(active,false);blocked=true;}
6225
+ else if(element.contains(owner)&&!ready.has(active)){watch(active,true);blocked=true;}
6226
+ });
6227
+ return blocked;
6228
+ }
6229
+ function drain(){
6230
+ if(!queue.length)return;
6231
+ var selected=[],pending=[],groups=[],owners=new Map();
6232
+ for(var i=0;i<queue.length;i++){
6233
+ var item=queue[i],t=d.querySelector('template[${import_constants.STREAM_BOUNDARY_ATTR}="'+item[0]+'"]'),owner=t?ownerOf(t):null;
6234
+ if(blocked(owner)){pending.push(item);continue;}
6235
+ selected.push(item);
6236
+ var group=owners.get(owner);
6237
+ if(!group){group={owner:owner,items:[],restore:[],changed:new Set(),prepared:[],arrived:false};owners.set(owner,group);groups.push(group);}
6238
+ group.items.push(item);
6239
+ }
6240
+ queue=pending;
6241
+ if(!selected.length)return;
6242
+ var committed=false,animated=false,images=[],resourceWait;
6243
+ function commit(){
6244
+ if(committed)return resourceWait;
6245
+ committed=true;for(var i=0;i<selected.length;i++)reveal(selected[i][0],selected[i][1]);
6246
+ if(!animated)return;
6247
+ var blockers=[],cleanups=[];
6248
+ d.documentElement.clientHeight;
6249
+ if(d.fonts&&d.fonts.status!=="loaded")blockers.push(d.fonts.ready);
6250
+ for(var i=0;i<images.length;i++){
6251
+ var img=images[i],bounds=img.getBoundingClientRect();
6252
+ if(!img.complete&&bounds.bottom>0&&bounds.right>0&&bounds.top<w.innerHeight&&bounds.left<w.innerWidth){
6253
+ blockers.push(new Promise(function(resolve){
6254
+ var image=img;image.addEventListener("load",resolve);image.addEventListener("error",resolve);
6255
+ cleanups.push(function(){image.removeEventListener("load",resolve);image.removeEventListener("error",resolve);});
6256
+ }));
6257
+ }
6258
+ }
6259
+ images.length=0;
6260
+ if(blockers.length)resourceWait=new Promise(function(resolve){
6261
+ var timer=setTimeout(done,500),settled=false;
6262
+ function done(){if(settled)return;settled=true;clearTimeout(timer);for(var i=0;i<cleanups.length;i++)cleanups[i]();cleanups.length=0;resolve();}
6263
+ Promise.all(blockers).then(done,done);
6264
+ });
6265
+ return resourceWait;
6266
+ }
6267
+ function reset(group){
6268
+ var restore=group.restore;
6269
+ for(var i=restore.length-1;i>=0;i--){
6270
+ var entry=restore[i],el=entry[0],style=el.style;
6271
+ if(style.getPropertyValue("view-transition-name")===entry[5]&&style.getPropertyPriority("view-transition-name")===entry[8]){
6272
+ if(entry[1])style.setProperty("view-transition-name",entry[1],entry[2]);
6273
+ else style.removeProperty("view-transition-name");
6274
+ }
6275
+ if(style.getPropertyValue("view-transition-class")===entry[6]&&style.getPropertyPriority("view-transition-class")===entry[9]){
6276
+ if(entry[3])style.setProperty("view-transition-class",entry[3],entry[4]);
6277
+ else style.removeProperty("view-transition-class");
6278
+ }
6279
+ if(!style.length&&!entry[7])el.removeAttribute("style");
6280
+ }
6281
+ restore.length=0;group.changed.clear();
6282
+ }
6283
+ function prepare(group){
6284
+ var owner=group.owner,restore=group.restore,changed=group.changed,appearing=new Map();
6285
+ if(!owner||typeof owner.startViewTransition!=="function")return;
6286
+ function owns(el,content){
6287
+ for(var node=el;node&&node.nodeType===1;node=node.parentElement){
6288
+ if(node===owner)return true;
6289
+ if(node.getAttribute("vt-scope")==="element")return false;
6290
+ if(node===content)return true;
6291
+ }
6292
+ return owner===d;
6293
+ }
6294
+ function apply(el,attr,content){
6295
+ var cls=el.getAttribute(attr);
6296
+ if(!cls||cls==="none"||changed.has(el)||!owns(el,content))return;
6297
+ var style=el.style;
6298
+ if(!style)return;
6299
+ var explicit=el.getAttribute("vt-name"),name=explicit||("_OT_"+restore.length+"_");
6300
+ 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")];
6301
+ if(el!==owner||explicit)style.setProperty("view-transition-name",w.CSS.escape(name));
6302
+ if(cls!=="auto")style.setProperty("view-transition-class",cls);
6303
+ entry[5]=style.getPropertyValue("view-transition-name");entry[6]=style.getPropertyValue("view-transition-class");
6304
+ entry[8]=style.getPropertyPriority("view-transition-name");entry[9]=style.getPropertyPriority("view-transition-class");
6305
+ restore.push(entry);changed.add(el);
6306
+ }
6307
+ function descendants(el,attr,content){
6308
+ var nodes=el.querySelectorAll("["+attr+"]");
6309
+ for(var i=0;i<nodes.length;i++)apply(nodes[i],attr,content);
6310
+ }
6311
+ for(var k=0;k<group.items.length;k++){
6312
+ var id=group.items[k][0],nc=group.items[k][1];
6313
+ var t=d.querySelector('template[${import_constants.STREAM_BOUNDARY_ATTR}="'+id+'"]');
6314
+ var s=d.querySelector('[${import_constants.STREAM_SEGMENT_ATTR}="'+id+'"]');
6315
+ if(!t||!s)continue;
6316
+ var parent=t.parentNode,rect=parent.getBoundingClientRect();
6317
+ if(!rect.width&&!rect.height&&!rect.left&&!rect.top)continue;
6318
+ var parsed=reveal.parse(s);
6319
+ if(!parsed)continue;
6320
+ if(parsed!==s)s.replaceChildren(parsed);
6321
+ var content=reveal.content(s,nc);
6322
+ if(!content)continue;
6323
+ group.prepared.push([t,content,parent]);
6324
+ var matches=content.querySelectorAll("[vt-share]");
6325
+ 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]);
6326
+ var pendingImages=content.querySelectorAll('img[src]:not([loading="lazy"])');
6327
+ for(var i=0;i<pendingImages.length;i++)if(owns(pendingImages[i],content))images.push(pendingImages[i]);
6328
+ }
6329
+ function pair(el){
6330
+ if(!owns(el))return false;
6331
+ var other=appearing.get(el.getAttribute("vt-name"));
6332
+ if(other&&el.getAttribute("vt-share")&&el.getAttribute("vt-share")!=="none"){
6333
+ apply(el,"vt-share");apply(other,"vt-share",other.closest('[${import_constants.STREAM_SEGMENT_ATTR}]'));appearing.delete(el.getAttribute("vt-name"));return true;
6334
+ }
6335
+ return false;
6336
+ }
6337
+ for(var k=0;k<group.prepared.length;k++){
6338
+ var t=group.prepared[k][0],content=group.prepared[k][1],parent=group.prepared[k][2];
6339
+ var node=t.nextSibling,depth=1;
6340
+ while(node){
6341
+ if(node.nodeType===8){
6342
+ var v=node.data;
6343
+ if(reveal.marker(v,"["))depth++;else if(reveal.marker(v,"]")&&!--depth)break;
6344
+ }else if(node.nodeType===1){
6345
+ if(!pair(node))apply(node,"vt-exit");
6346
+ matches=node.querySelectorAll("[vt-share]");for(var j=0;j<matches.length;j++)pair(matches[j]);
6347
+ descendants(node,"vt-parent-exit");
6348
+ }
6349
+ node=node.nextSibling;
6350
+ }
6351
+ for(var el=content.firstElementChild;el;el=el.nextElementSibling){apply(el,"vt-enter",content);descendants(el,"vt-parent-enter",content);}
6352
+ do{
6353
+ for(var sibling=parent.firstElementChild;sibling;sibling=sibling.nextElementSibling)apply(sibling,"vt-update");
6354
+ if(parent===owner)break;
6355
+ parent=parent.parentNode;
6356
+ }while(parent&&parent.nodeType===1&&parent.getAttribute("vt-update")!=="none");
6357
+ }
6358
+ if(owner!==d&&group.prepared.length)apply(owner,"vt-update");
6359
+ }
6360
+ var captures=[],documentGroup=null,elementsToEnter=0,remaining=0,resolveGate,rejectGate;
6361
+ var gate=new Promise(function(resolve,reject){resolveGate=resolve;rejectGate=reject;});
6362
+ gate.catch(function(){});
6363
+ for(var i=0;i<groups.length;i++){
6364
+ try{prepare(groups[i]);}catch(error){reset(groups[i]);}
6365
+ if(groups[i].restore.length){captures.push(groups[i]);if(groups[i].owner===d)documentGroup=groups[i];else elementsToEnter++;}
6366
+ }
6367
+ remaining=captures.length;animated=remaining>0;
6368
+ if(!remaining){images.length=0;commit();later();return;}
6369
+ function arrive(group){
6370
+ if(group.arrived)return gate;
6371
+ group.arrived=true;remaining--;
6372
+ if(group.owner!==d&&!--elementsToEnter&&documentGroup)start(documentGroup);
6373
+ if(!remaining){try{Promise.resolve(commit()).then(resolveGate,rejectGate);}catch(error){rejectGate(error);}}
6374
+ return gate;
6375
+ }
6376
+ function start(group){
6377
+ if(group.started)return;group.started=true;
6378
+ var owner=group.owner,transition,startNative=owner.startViewTransition,update=function(){return arrive(group);};
6379
+ try{
6380
+ if(callbackOnly.has(startNative))transition=startNative.call(owner,update);
6381
+ else{
6382
+ try{transition=startNative.call(owner,{update:update,types:[]});}
6383
+ catch(error){
6384
+ if(!(error instanceof TypeError))throw error;
6385
+ transition=startNative.call(owner,update);callbackOnly.add(startNative);
6386
+ }
6387
+ }
6388
+ if(owner===d)d.__octaneViewTransition=transition;
6389
+ else (d.__octaneViewTransitionScopes||(d.__octaneViewTransitionScopes=new Map())).set(owner,transition);
6390
+ transition.ready.then(function(){ready.add(transition);reset(group);later();},function(){reset(group);});
6391
+ function complete(){
6392
+ reset(group);
6393
+ if(owner===d){if(d.__octaneViewTransition===transition)d.__octaneViewTransition=null;}
6394
+ else{var scopes=d.__octaneViewTransitionScopes;if(scopes&&scopes.get(owner)===transition)scopes.delete(owner);}
6395
+ drain();
6396
+ }
6397
+ transition.finished.then(complete,complete);
6398
+ }catch(error){reset(group);arrive(group);if(!error||(error.name!=="AbortError"&&error.name!=="InvalidStateError"))console.error(error);}
6399
+ }
6400
+ for(var i=0;i<captures.length;i++)if(captures[i].owner!==d)start(captures[i]);
6401
+ if(!elementsToEnter&&documentGroup&&!documentGroup.arrived)start(documentGroup);
6402
+ }
6403
+ })();`;
6404
+ }
6405
+ function needsAutomaticSignalInjection(options) {
6406
+ return options?.streamedSignals !== void 0 && options?.injection?.observeSignalAttempt === void 0;
6407
+ }
6408
+ async function prepareAutomaticSignalInjection(options) {
6409
+ const config = options.streamedSignals;
6410
+ const { createAutomaticStreamedSignalInjection } = await import("./server/streamed-signals.js");
6411
+ return {
6412
+ ...options,
6413
+ injection: createAutomaticStreamedSignalInjection(
6414
+ { ...config, nonce: options.nonce },
6415
+ options.injection
6416
+ )
6417
+ };
5240
6418
  }
5241
6419
  function withStream(stream, fn) {
5242
6420
  const prev = STREAM;
@@ -5331,7 +6509,7 @@ function segmentChunk(b, nonceAttr) {
5331
6509
  }
5332
6510
  }
5333
6511
  if (b.signals !== void 0) seedScript += serializeNativeSignalSeeds(b.signals, nonceAttr);
5334
- const html = vtSsrStrip(b.html);
6512
+ const html = vtSsrStrip(b.html, b.rawHtml);
5335
6513
  const content = b.namespace === "svg" ? seedScript + "<svg>" + html + "</svg>" : b.namespace === "mathml" ? seedScript + "<math>" + html + "</math>" : seedScript + html;
5336
6514
  const hasNamespaceCarrier = b.namespace === "html" ? "" : ",1";
5337
6515
  const payload = JSON.stringify(content).replace(/<(?=\/?script)/gi, "\\u003c");
@@ -5417,7 +6595,14 @@ async function runStream(component, props, options, sink, resolved) {
5417
6595
  return;
5418
6596
  }
5419
6597
  if (!html) return;
5420
- return write(html, false, rememberUnaccepted);
6598
+ const written = write(html, false, rememberUnaccepted);
6599
+ if (written === void 0) {
6600
+ injection.accepted?.();
6601
+ return;
6602
+ }
6603
+ return written.then(() => {
6604
+ injection.accepted?.();
6605
+ });
5421
6606
  };
5422
6607
  const recoveryInjection = injection === void 0 ? void 0 : async () => {
5423
6608
  if (signal?.aborted) {
@@ -5474,14 +6659,20 @@ async function runStream(component, props, options, sink, resolved) {
5474
6659
  const done = [];
5475
6660
  const reachable = new Set(flushedSegments);
5476
6661
  for (; ; ) {
5477
- const next = [...stream.boundaries.values()].filter((boundary) => {
5478
- if (boundary.state !== "done" || reachable.has(boundary.id)) return false;
6662
+ const next = [];
6663
+ for (const boundary of stream.boundaries.values()) {
6664
+ if (boundary.state !== "done" || reachable.has(boundary.id)) continue;
6665
+ let visible = true;
5479
6666
  for (let i = boundary.ancestors.length - 1; i >= 0; i--) {
5480
6667
  const ancestor = stream.boundaries.get(boundary.ancestors[i]);
5481
- if (ancestor !== void 0) return reachable.has(ancestor.id);
6668
+ if (ancestor !== void 0) {
6669
+ visible = reachable.has(ancestor.id);
6670
+ break;
6671
+ }
5482
6672
  }
5483
- return true;
5484
- }).sort((a, b) => a.order - b.order);
6673
+ if (visible) next.push(boundary);
6674
+ }
6675
+ next.sort((a, b) => a.order - b.order);
5485
6676
  if (next.length === 0) return done;
5486
6677
  for (const boundary of next) {
5487
6678
  done.push(boundary);
@@ -5496,14 +6687,22 @@ async function runStream(component, props, options, sink, resolved) {
5496
6687
  options?.onError?.(boundary.error);
5497
6688
  }
5498
6689
  };
5499
- const reachableErroredBoundaries = () => [...stream.boundaries.values()].filter((boundary) => {
5500
- if (boundary.state !== "errored" || boundary.errorFlushed) return false;
5501
- for (let i = boundary.ancestors.length - 1; i >= 0; i--) {
5502
- const ancestor = stream.boundaries.get(boundary.ancestors[i]);
5503
- if (ancestor !== void 0) return flushedSegments.has(ancestor.id);
6690
+ const reachableErroredBoundaries = () => {
6691
+ const errors = [];
6692
+ for (const boundary of stream.boundaries.values()) {
6693
+ if (boundary.state !== "errored" || boundary.errorFlushed) continue;
6694
+ let visible = true;
6695
+ for (let i = boundary.ancestors.length - 1; i >= 0; i--) {
6696
+ const ancestor = stream.boundaries.get(boundary.ancestors[i]);
6697
+ if (ancestor !== void 0) {
6698
+ visible = flushedSegments.has(ancestor.id);
6699
+ break;
6700
+ }
6701
+ }
6702
+ if (visible) errors.push(boundary);
5504
6703
  }
5505
- return true;
5506
- }).sort((a, b) => a.order - b.order);
6704
+ return errors.sort((a, b) => a.order - b.order);
6705
+ };
5507
6706
  const flushRecoverableBoundaryErrors = () => {
5508
6707
  const errors = reachableErroredBoundaries();
5509
6708
  if (errors.length === 0) return;
@@ -5574,7 +6773,7 @@ async function runStream(component, props, options, sink, resolved) {
5574
6773
  const separateHead = options?.headChannel === "separate";
5575
6774
  if (separateHead) {
5576
6775
  try {
5577
- options?.onHeadReady?.(pass.vtCandidates ? vtSsrStrip(pass.head) : pass.head);
6776
+ options?.onHeadReady?.(pass.vtCandidates ? vtSsrStrip(pass.head, pass.rawHtml) : pass.head);
5578
6777
  } catch (err) {
5579
6778
  try {
5580
6779
  completeInjection();
@@ -5603,11 +6802,19 @@ async function runStream(component, props, options, sink, resolved) {
5603
6802
  }
5604
6803
  if (pass.serial.length > 0) shell += serializeSuspenseSeeds(pass.serial, nonceAttr);
5605
6804
  if (pass.signals !== void 0) shell += serializeNativeSignalSeeds(pass.signals, nonceAttr);
6805
+ if (options?.earlySignalBootstrap !== "external" && (injection?.streamedRenderer === true || pass.hasSignalControls || options?.independentHydration !== void 0)) {
6806
+ shell += "<script " + import_constants.STREAM_SCRIPT_ATTR + nonceAttr + ">" + (0, import_early_signals.streamedSignalBootstrapJs)(options?.independentHydration !== void 0) + "</script>";
6807
+ }
6808
+ if (injection?.takeInitialSelections !== void 0) shell += injection.takeInitialSelections();
5606
6809
  const anyPending = stream.boundaries.size > 0;
6810
+ let sentViewTransitions = pass.vtCandidates;
5607
6811
  if (anyPending)
5608
- shell += "<script " + import_constants.STREAM_SCRIPT_ATTR + nonceAttr + ">" + streamRuntimeJs() + "</script>";
6812
+ shell += "<script " + import_constants.STREAM_SCRIPT_ATTR + nonceAttr + ">" + streamRuntimeJs() + (sentViewTransitions ? streamViewTransitionRuntimeJs() : "") + "</script>";
5609
6813
  try {
5610
- const shellWrite = write(pass.vtCandidates ? vtSsrStrip(shell) : shell);
6814
+ if (injection?.streamedRenderer === true || pass.hasSignalControls || options?.independentHydration !== void 0) {
6815
+ options?.onEarlyHydrationReady?.();
6816
+ }
6817
+ const shellWrite = write(pass.vtCandidates ? vtSsrStrip(shell, pass.rawHtml) : shell);
5611
6818
  if (shellWrite !== void 0) await shellWrite;
5612
6819
  } catch (err) {
5613
6820
  try {
@@ -5642,7 +6849,7 @@ async function runStream(component, props, options, sink, resolved) {
5642
6849
  if (initiallyDone.length > 0) {
5643
6850
  let chunk = "";
5644
6851
  for (const boundary of initiallyDone) chunk += segmentChunk(boundary, nonceAttr);
5645
- const segmentWrite = write(pass.vtCandidates ? vtSsrStrip(chunk) : chunk);
6852
+ const segmentWrite = write(pass.vtCandidates ? vtSsrStrip(chunk, pass.rawHtml) : chunk);
5646
6853
  if (segmentWrite !== void 0) await segmentWrite;
5647
6854
  for (const boundary of initiallyDone) {
5648
6855
  flushedSegments.add(boundary.id);
@@ -5651,7 +6858,7 @@ async function runStream(component, props, options, sink, resolved) {
5651
6858
  }
5652
6859
  const initialErrorWrite = flushRecoverableBoundaryErrors();
5653
6860
  if (initialErrorWrite !== void 0) await initialErrorWrite;
5654
- while ([...stream.boundaries.values()].some((b) => b.state === "pending")) {
6861
+ while (hasPendingStreamBoundary(stream)) {
5655
6862
  signal?.throwIfAborted();
5656
6863
  if (suspended.length === 0) {
5657
6864
  throw new Error((0, import_error_codes_server_generated.formatServerError)(36));
@@ -5697,9 +6904,13 @@ async function runStream(component, props, options, sink, resolved) {
5697
6904
  if (madeProgress) attempt = 0;
5698
6905
  retryWithoutSettling = observeSuspenseWave(resolved, settledWave, suspended, madeProgress);
5699
6906
  const done = reachableDoneSegments();
6907
+ if (!sentViewTransitions && pass.vtCandidates && done.length > 0) {
6908
+ sentViewTransitions = true;
6909
+ chunk += "<script " + import_constants.STREAM_SCRIPT_ATTR + nonceAttr + ">" + streamViewTransitionRuntimeJs() + "</script>";
6910
+ }
5700
6911
  for (const b of done) chunk += segmentChunk(b, nonceAttr);
5701
6912
  if (chunk !== "") {
5702
- const segmentWrite = write(pass.vtCandidates ? vtSsrStrip(chunk) : chunk);
6913
+ const segmentWrite = write(pass.vtCandidates ? vtSsrStrip(chunk, pass.rawHtml) : chunk);
5703
6914
  if (segmentWrite !== void 0) await segmentWrite;
5704
6915
  for (const b of done) flushedSegments.add(b.id);
5705
6916
  }
@@ -5707,9 +6918,10 @@ async function runStream(component, props, options, sink, resolved) {
5707
6918
  if (errorWrite !== void 0) await errorWrite;
5708
6919
  }
5709
6920
  } catch (err) {
5710
- const pendingBoundaryCount = [...stream.boundaries.values()].filter(
5711
- (boundary) => boundary.state === "pending" && !flushedSegments.has(boundary.id)
5712
- ).length;
6921
+ let pendingBoundaryCount = 0;
6922
+ for (const boundary of stream.boundaries.values()) {
6923
+ if (boundary.state === "pending" && !flushedSegments.has(boundary.id)) pendingBoundaryCount++;
6924
+ }
5713
6925
  const reports = signal?.aborted ? Math.max(1, pendingBoundaryCount) : 1;
5714
6926
  for (let i = 0; i < reports; i++) options?.onError?.(err);
5715
6927
  if (injection !== void 0) {
@@ -5932,10 +7144,8 @@ function renderToPipeableStream(entryComponent, props, options) {
5932
7144
  finishEnd();
5933
7145
  };
5934
7146
  let started = false;
5935
- const startRender = () => {
5936
- if (started) return;
5937
- started = true;
5938
- const renderOptions = { ...options, signal: controller.signal };
7147
+ const beginRender = (preparedOptions) => {
7148
+ const renderOptions = { ...preparedOptions, signal: controller.signal };
5939
7149
  const resolved = newResolvedMap(renderOptions);
5940
7150
  void runStream(
5941
7151
  component,
@@ -5972,6 +7182,18 @@ function renderToPipeableStream(entryComponent, props, options) {
5972
7182
  flushEnd();
5973
7183
  });
5974
7184
  };
7185
+ const startRender = () => {
7186
+ if (started) return;
7187
+ started = true;
7188
+ if (needsAutomaticSignalInjection(options)) {
7189
+ void prepareAutomaticSignalInjection(options).then(beginRender, (error) => {
7190
+ shellFailure = { error };
7191
+ options?.onShellError?.(error);
7192
+ options?.onError?.(error);
7193
+ flushEnd();
7194
+ });
7195
+ } else beginRender(options);
7196
+ };
5975
7197
  queueMicrotask(startRender);
5976
7198
  return {
5977
7199
  pipe(dest) {
@@ -6008,6 +7230,11 @@ function renderToReadableStream(entryComponent, props, options) {
6008
7230
  options ??= props;
6009
7231
  props = { value: entryComponent };
6010
7232
  }
7233
+ if (needsAutomaticSignalInjection(options)) {
7234
+ return prepareAutomaticSignalInjection(options).then(
7235
+ (prepared) => renderToReadableStream(component, props, prepared)
7236
+ );
7237
+ }
6011
7238
  return new Promise((resolveShell, rejectShell) => {
6012
7239
  const encoder = new TextEncoder();
6013
7240
  const renderController = new AbortController();
@@ -6203,6 +7430,7 @@ function renderToReadableStream(entryComponent, props, options) {
6203
7430
  function emitHeadHint(key, html) {
6204
7431
  if (HEAD === null) return;
6205
7432
  if (HEAD.hints.has(key)) return;
7433
+ HEAD.replay = null;
6206
7434
  HEAD.hints.add(key);
6207
7435
  (HEAD.hintHtml ??= /* @__PURE__ */ new Map()).set(key, html);
6208
7436
  }
@@ -6268,7 +7496,10 @@ function preload(href, options) {
6268
7496
  const v = options[k];
6269
7497
  if (v != null) (subset ??= {})[k] = v;
6270
7498
  }
6271
- if (subset !== null) (HEAD.preloadXfer ??= /* @__PURE__ */ new Map()).set(as + ":" + value, subset);
7499
+ if (subset !== null) {
7500
+ HEAD.replay = null;
7501
+ (HEAD.preloadXfer ??= /* @__PURE__ */ new Map()).set(as + ":" + value, subset);
7502
+ }
6272
7503
  }
6273
7504
  }
6274
7505
  const imageSrcSet = as === "image" ? options.imageSrcSet : void 0;
@@ -6292,6 +7523,7 @@ function preinit(href, options) {
6292
7523
  if (as !== "style" && as !== "script") return;
6293
7524
  let seeded = null;
6294
7525
  if (HEAD !== null) {
7526
+ HEAD.replay = null;
6295
7527
  const xfer = HEAD.preloadXfer?.get(as + ":" + value);
6296
7528
  if (xfer !== void 0) {
6297
7529
  seeded = xfer;
@@ -6378,9 +7610,11 @@ function ssrStylesheetResource(attrs, invalidReason) {
6378
7610
  if (typeof href !== "string" || href === "") return "";
6379
7611
  const key = "sheet:" + href;
6380
7612
  if (HEAD.hints.has(key)) return "";
7613
+ HEAD.replay = null;
6381
7614
  HEAD.hints.add(key);
6382
7615
  const precedence = attrs.precedence == null ? "" : String(attrs.precedence);
6383
7616
  const tag = '<link rel="stylesheet" href="' + escapeAttr((0, import_sanitize_url.sanitizeURL)(href)) + '" data-precedence="' + escapeAttr(precedence) + '"' + resourceAttrs(attrs, "link") + ">";
7617
+ HEAD.replay = null;
6384
7618
  const sheets = HEAD.sheets ??= /* @__PURE__ */ new Map();
6385
7619
  sheets.set(href, { precedence, html: tag });
6386
7620
  return "";
@@ -6412,9 +7646,11 @@ function ssrStyleResource(attrs, css, development) {
6412
7646
  }
6413
7647
  HEAD.hints.add("dev-inline-style:" + href);
6414
7648
  }
7649
+ HEAD.replay = null;
6415
7650
  HEAD.hints.add(key);
6416
7651
  const precedence = attrs.precedence == null ? "" : String(attrs.precedence);
6417
7652
  const tag = '<style data-precedence="' + escapeAttr(precedence) + '" data-href="' + escapeAttr(href) + '"' + resourceAttrs(attrs, "link") + ">" + css + "</style>";
7653
+ HEAD.replay = null;
6418
7654
  const sheets = HEAD.sheets ??= /* @__PURE__ */ new Map();
6419
7655
  sheets.set(href, { precedence, html: tag });
6420
7656
  return "";
@@ -6425,6 +7661,7 @@ function ssrScriptResource(attrs) {
6425
7661
  if (typeof src !== "string" || src === "") return "";
6426
7662
  const key = "script:" + src;
6427
7663
  if (HEAD.hints.has(key) || HEAD.hints.has("module:" + src)) return "";
7664
+ HEAD.replay = null;
6428
7665
  HEAD.hints.add(key);
6429
7666
  HEAD.html += '<script src="' + escapeAttr((0, import_sanitize_url.sanitizeURL)(src)) + '" async data-oct-res=""' + resourceAttrs(attrs, "script") + "></script>";
6430
7667
  return "";
@@ -6483,16 +7720,20 @@ function preinitModule(href, options) {
6483
7720
  addTransitionType,
6484
7721
  beginNativeReadScope,
6485
7722
  beginNativeReadWitness,
7723
+ bindPresentationView,
6486
7724
  callWithReceiver,
6487
7725
  cloneElement,
6488
7726
  createContext,
6489
7727
  createElement,
7728
+ createElementAt,
7729
+ createElementFromConfig,
6490
7730
  createHostedServerSession,
6491
7731
  createPortal,
6492
7732
  createScopedElement,
6493
7733
  createScopedValue,
6494
7734
  descriptorChildren,
6495
7735
  enableNativeReadCollection,
7736
+ enableServerSignalBindings,
6496
7737
  encodeAsyncIdentityString,
6497
7738
  endNativeReadScope,
6498
7739
  escapeAttr,
@@ -6531,6 +7772,8 @@ function preinitModule(href, options) {
6531
7772
  prerenderToNodeStream,
6532
7773
  puBatch,
6533
7774
  puMemo,
7775
+ readNativeDomProps,
7776
+ readNativeDomStyle,
6534
7777
  renderHostedAttempt,
6535
7778
  renderToPipeableStream,
6536
7779
  renderToReadableStream,
@@ -6543,6 +7786,11 @@ function preinitModule(href, options) {
6543
7786
  ssrArm,
6544
7787
  ssrAttr,
6545
7788
  ssrAttrs,
7789
+ ssrBindingBlock,
7790
+ ssrBindingChild,
7791
+ ssrBindingClass,
7792
+ ssrBindingHtml,
7793
+ ssrBindingKey,
6546
7794
  ssrBlock,
6547
7795
  ssrCheckedAttr,
6548
7796
  ssrChild,
@@ -6574,6 +7822,9 @@ function preinitModule(href, options) {
6574
7822
  ssrSelectAttrs,
6575
7823
  ssrSelectScope,
6576
7824
  ssrSelectScopeSources,
7825
+ ssrSignalControlAttrs,
7826
+ ssrSignalControlValue,
7827
+ ssrSignalValue,
6577
7828
  ssrSnapshotSpread,
6578
7829
  ssrSpread,
6579
7830
  ssrSpreadContent,
@@ -6590,6 +7841,7 @@ function preinitModule(href, options) {
6590
7841
  startTransition,
6591
7842
  styleMap,
6592
7843
  touchStyleMap,
7844
+ trustHTML,
6593
7845
  use,
6594
7846
  useActionState,
6595
7847
  useCallback,