octane 0.2.12 → 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 (243) 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/css.cjs +6 -27
  8. package/dist/cjs/data-encoding.cjs +160 -0
  9. package/dist/cjs/dom-binding-handoff.cjs +93 -0
  10. package/dist/cjs/dom-binding-protocol.cjs +115 -0
  11. package/dist/cjs/dom-binding-styles.cjs +292 -0
  12. package/dist/cjs/dom-bindings.cjs +700 -0
  13. package/dist/cjs/dom-focused-move.cjs +66 -0
  14. package/dist/cjs/dom-tables.cjs +4 -94
  15. package/dist/cjs/error-codes.client.generated.cjs +33 -0
  16. package/dist/cjs/error-codes.server.generated.cjs +19 -0
  17. package/dist/cjs/hydration/control-capture.cjs +244 -0
  18. package/dist/cjs/hydration/event-capture.cjs +125 -43
  19. package/dist/cjs/hydration/interaction-config.cjs +50 -2
  20. package/dist/cjs/hydration-markers.cjs +37 -0
  21. package/dist/cjs/independent-hydration-protocol.cjs +106 -0
  22. package/dist/cjs/index.cjs +6 -0
  23. package/dist/cjs/runtime.cjs +2791 -215
  24. package/dist/cjs/runtime.server.cjs +716 -76
  25. package/dist/cjs/server/early-signals.cjs +45 -0
  26. package/dist/cjs/server/index.cjs +44 -0
  27. package/dist/cjs/server/rpc-batch.cjs +149 -0
  28. package/dist/cjs/server/rpc-stream.cjs +146 -0
  29. package/dist/cjs/server/rpc.cjs +34 -15
  30. package/dist/cjs/server/signal-query-observation.cjs +158 -0
  31. package/dist/cjs/server/streamed-region.cjs +52 -0
  32. package/dist/cjs/server/streamed-signals.cjs +512 -0
  33. package/dist/cjs/server-call.cjs +103 -0
  34. package/dist/cjs/server-rpc-batch-client.cjs +141 -0
  35. package/dist/cjs/server-rpc-client.cjs +94 -27
  36. package/dist/cjs/server-rpc-protocol.cjs +141 -0
  37. package/dist/cjs/server-rpc-stream-client.cjs +118 -0
  38. package/dist/cjs/signals/actions.cjs +474 -0
  39. package/dist/cjs/signals/client.cjs +4 -1
  40. package/dist/cjs/signals/computations.cjs +460 -0
  41. package/dist/cjs/signals/control-binding.cjs +368 -0
  42. package/dist/cjs/signals/derived-facade.cjs +50 -0
  43. package/dist/cjs/signals/document-owner.cjs +71 -0
  44. package/dist/cjs/signals/early-values.cjs +155 -0
  45. package/dist/cjs/signals/encoding.cjs +6 -95
  46. package/dist/cjs/signals/engine.cjs +276 -12
  47. package/dist/cjs/signals/errors.cjs +18 -0
  48. package/dist/cjs/signals/facade.cjs +477 -0
  49. package/dist/cjs/signals/graph.cjs +163 -20
  50. package/dist/cjs/signals/handle-protocol.cjs +36 -0
  51. package/dist/cjs/signals/index.cjs +81 -2
  52. package/dist/cjs/signals/native-read-client.cjs +10 -0
  53. package/dist/cjs/signals/owner-context.cjs +112 -0
  54. package/dist/cjs/signals/query-attempt-observer.cjs +68 -0
  55. package/dist/cjs/signals/query-facade.cjs +72 -0
  56. package/dist/cjs/signals/read-protocol.cjs +32 -0
  57. package/dist/cjs/signals/requests.cjs +287 -14
  58. package/dist/cjs/signals/scalar-computations.cjs +76 -0
  59. package/dist/cjs/signals/server.cjs +4 -1
  60. package/dist/cjs/signals/transition-candidate.cjs +567 -0
  61. package/dist/cjs/signals/transition-state.cjs +106 -0
  62. package/dist/cjs/signals/types.cjs +50 -0
  63. package/dist/cjs/stream-protocol.cjs +3 -0
  64. package/dist/cjs/streamed-signals-protocol.cjs +159 -0
  65. package/dist/cjs/style-values.cjs +122 -0
  66. package/dist/cjs/version.cjs +1 -1
  67. package/dist/class-names.d.ts +5 -0
  68. package/dist/class-names.js +25 -0
  69. package/dist/compiler/bundler.js +34 -6
  70. package/dist/compiler/compile.js +2234 -559
  71. package/dist/compiler/dom-binding-program.js +935 -0
  72. package/dist/compiler/dom-binding-request.js +57 -0
  73. package/dist/compiler/dom-bindings.js +2245 -0
  74. package/dist/compiler/hook-deps.js +26 -0
  75. package/dist/compiler/hydrate-boundaries.js +358 -15
  76. package/dist/compiler/index.d.ts +38 -1
  77. package/dist/compiler/index.js +1 -0
  78. package/dist/compiler/native-attribute-reads.js +127 -0
  79. package/dist/compiler/native-read-diagnostics.js +48 -9
  80. package/dist/compiler/native-read-types.js +55 -32
  81. package/dist/compiler/server-context.js +118 -0
  82. package/dist/compiler/signal-attempt-reads.js +479 -0
  83. package/dist/compiler/signal-declarations.js +557 -0
  84. package/dist/compiler/signal-start-reads.js +413 -0
  85. package/dist/compiler/slot-hooks.js +57 -10
  86. package/dist/compiler/template-ir.js +200 -0
  87. package/dist/compiler/typescript.d.ts +2 -0
  88. package/dist/compiler/typescript.js +2 -0
  89. package/dist/compiler/vite.d.ts +3 -1
  90. package/dist/compiler/vite.js +122 -4
  91. package/dist/compiler/volar.d.ts +6 -1
  92. package/dist/compiler/volar.js +674 -143
  93. package/dist/constants.d.ts +1 -0
  94. package/dist/constants.js +10 -0
  95. package/dist/css.d.ts +2 -5
  96. package/dist/css.js +2 -23
  97. package/dist/data-encoding.d.ts +9 -0
  98. package/dist/data-encoding.js +134 -0
  99. package/dist/dom-binding-classes.d.ts +15 -0
  100. package/dist/dom-binding-classes.js +129 -0
  101. package/dist/dom-binding-controls.d.ts +2 -0
  102. package/dist/dom-binding-controls.js +6 -0
  103. package/dist/dom-binding-handoff.d.ts +55 -0
  104. package/dist/dom-binding-handoff.js +62 -0
  105. package/dist/dom-binding-program.d.ts +300 -0
  106. package/dist/dom-binding-program.js +1625 -0
  107. package/dist/dom-binding-projections.d.ts +15 -0
  108. package/dist/dom-binding-projections.js +187 -0
  109. package/dist/dom-binding-protocol.d.ts +13 -0
  110. package/dist/dom-binding-protocol.js +88 -0
  111. package/dist/dom-binding-signals.d.ts +21 -0
  112. package/dist/dom-binding-signals.js +109 -0
  113. package/dist/dom-binding-styles.d.ts +17 -0
  114. package/dist/dom-binding-styles.js +272 -0
  115. package/dist/dom-bindings.d.ts +89 -0
  116. package/dist/dom-bindings.js +670 -0
  117. package/dist/dom-focused-move.d.ts +6 -0
  118. package/dist/dom-focused-move.js +42 -0
  119. package/dist/dom-tables.d.ts +1 -3
  120. package/dist/dom-tables.js +1 -91
  121. package/dist/error-codes.client.generated.d.ts +9 -0
  122. package/dist/error-codes.client.generated.js +33 -0
  123. package/dist/error-codes.server.generated.d.ts +5 -0
  124. package/dist/error-codes.server.generated.js +19 -0
  125. package/dist/hydration/control-capture.d.ts +62 -0
  126. package/dist/hydration/control-capture.js +223 -0
  127. package/dist/hydration/document-lifecycle.d.ts +23 -0
  128. package/dist/hydration/document-lifecycle.js +80 -0
  129. package/dist/hydration/event-capture.d.ts +20 -1
  130. package/dist/hydration/event-capture.js +128 -42
  131. package/dist/hydration/independent-island.d.ts +45 -0
  132. package/dist/hydration/independent-island.js +233 -0
  133. package/dist/hydration/index.d.ts +8 -1
  134. package/dist/hydration/index.js +55 -1
  135. package/dist/hydration/interaction-config.d.ts +5 -0
  136. package/dist/hydration/interaction-config.js +44 -1
  137. package/dist/hydration/stream-delivery.d.ts +32 -0
  138. package/dist/hydration/stream-delivery.js +333 -0
  139. package/dist/hydration/stream-receiver.d.ts +26 -0
  140. package/dist/hydration/stream-receiver.js +204 -0
  141. package/dist/hydration/stream-result-receiver.d.ts +70 -0
  142. package/dist/hydration/stream-result-receiver.js +246 -0
  143. package/dist/hydration/streamed-signals.d.ts +44 -0
  144. package/dist/hydration/streamed-signals.js +186 -0
  145. package/dist/hydration/types.d.ts +6 -0
  146. package/dist/hydration-markers.d.ts +7 -0
  147. package/dist/hydration-markers.js +10 -0
  148. package/dist/independent-hydration-protocol.d.ts +31 -0
  149. package/dist/independent-hydration-protocol.js +80 -0
  150. package/dist/index.d.ts +2 -0
  151. package/dist/index.js +4 -0
  152. package/dist/internal/signal-read.d.ts +1 -0
  153. package/dist/internal/signal-read.js +4 -0
  154. package/dist/jsx-runtime.d.ts +45 -6
  155. package/dist/public-types.d.ts +15 -1
  156. package/dist/runtime.d.ts +259 -21
  157. package/dist/runtime.js +2812 -220
  158. package/dist/runtime.server.d.ts +86 -6
  159. package/dist/runtime.server.js +712 -76
  160. package/dist/server/early-signals.d.ts +14 -0
  161. package/dist/server/early-signals.js +34 -0
  162. package/dist/server/index.d.ts +10 -2
  163. package/dist/server/index.js +48 -1
  164. package/dist/server/rpc-batch.d.ts +17 -0
  165. package/dist/server/rpc-batch.js +129 -0
  166. package/dist/server/rpc-stream.d.ts +9 -0
  167. package/dist/server/rpc-stream.js +125 -0
  168. package/dist/server/rpc.d.ts +5 -1
  169. package/dist/server/rpc.js +37 -13
  170. package/dist/server/signal-query-observation.d.ts +3 -0
  171. package/dist/server/signal-query-observation.js +134 -0
  172. package/dist/server/streamed-region.d.ts +15 -0
  173. package/dist/server/streamed-region.js +30 -0
  174. package/dist/server/streamed-signals.d.ts +45 -0
  175. package/dist/server/streamed-signals.js +488 -0
  176. package/dist/server-call.d.ts +41 -0
  177. package/dist/server-call.js +75 -0
  178. package/dist/server-rpc-batch-client.d.ts +7 -0
  179. package/dist/server-rpc-batch-client.js +119 -0
  180. package/dist/server-rpc-client.d.ts +3 -1
  181. package/dist/server-rpc-client.js +99 -27
  182. package/dist/server-rpc-protocol.d.ts +47 -0
  183. package/dist/server-rpc-protocol.js +109 -0
  184. package/dist/server-rpc-stream-client.d.ts +5 -0
  185. package/dist/server-rpc-stream-client.js +98 -0
  186. package/dist/signals/actions.d.ts +12 -0
  187. package/dist/signals/actions.js +466 -0
  188. package/dist/signals/client.d.ts +2 -0
  189. package/dist/signals/client.js +1 -0
  190. package/dist/signals/computations.d.ts +37 -0
  191. package/dist/signals/computations.js +455 -0
  192. package/dist/signals/control-binding.d.ts +31 -0
  193. package/dist/signals/control-binding.js +353 -0
  194. package/dist/signals/derived-facade.d.ts +3 -0
  195. package/dist/signals/derived-facade.js +25 -0
  196. package/dist/signals/document-owner.d.ts +10 -0
  197. package/dist/signals/document-owner.js +43 -0
  198. package/dist/signals/early-values.d.ts +24 -0
  199. package/dist/signals/early-values.js +124 -0
  200. package/dist/signals/encoding.d.ts +1 -3
  201. package/dist/signals/encoding.js +3 -93
  202. package/dist/signals/engine.d.ts +53 -4
  203. package/dist/signals/engine.js +275 -16
  204. package/dist/signals/errors.d.ts +7 -0
  205. package/dist/signals/errors.js +16 -0
  206. package/dist/signals/facade.d.ts +74 -0
  207. package/dist/signals/facade.js +452 -0
  208. package/dist/signals/graph.d.ts +50 -5
  209. package/dist/signals/graph.js +170 -19
  210. package/dist/signals/handle-protocol.d.ts +4 -0
  211. package/dist/signals/handle-protocol.js +11 -0
  212. package/dist/signals/index.d.ts +12 -3
  213. package/dist/signals/index.js +71 -2
  214. package/dist/signals/native-read-client.d.ts +3 -0
  215. package/dist/signals/native-read-client.js +10 -0
  216. package/dist/signals/owner-context.d.ts +22 -0
  217. package/dist/signals/owner-context.js +77 -0
  218. package/dist/signals/query-attempt-observer.d.ts +49 -0
  219. package/dist/signals/query-attempt-observer.js +41 -0
  220. package/dist/signals/query-facade.d.ts +3 -0
  221. package/dist/signals/query-facade.js +49 -0
  222. package/dist/signals/read-protocol.d.ts +32 -3
  223. package/dist/signals/read-protocol.js +26 -0
  224. package/dist/signals/requests.d.ts +38 -5
  225. package/dist/signals/requests.js +298 -15
  226. package/dist/signals/scalar-computations.d.ts +2 -0
  227. package/dist/signals/scalar-computations.js +60 -0
  228. package/dist/signals/server.d.ts +2 -0
  229. package/dist/signals/server.js +1 -0
  230. package/dist/signals/transition-candidate.d.ts +71 -0
  231. package/dist/signals/transition-candidate.js +557 -0
  232. package/dist/signals/transition-state.d.ts +51 -0
  233. package/dist/signals/transition-state.js +70 -0
  234. package/dist/signals/types.d.ts +95 -5
  235. package/dist/signals/types.js +20 -0
  236. package/dist/stream-protocol.d.ts +0 -5
  237. package/dist/stream-protocol.js +3 -0
  238. package/dist/streamed-signals-protocol.d.ts +60 -0
  239. package/dist/streamed-signals-protocol.js +130 -0
  240. package/dist/style-values.d.ts +3 -0
  241. package/dist/style-values.js +96 -0
  242. package/dist/version.js +1 -1
  243. package/package.json +37 -1
@@ -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,
@@ -95,6 +109,11 @@ __export(runtime_server_exports, {
95
109
  ssrArm: () => ssrArm,
96
110
  ssrAttr: () => ssrAttr,
97
111
  ssrAttrs: () => ssrAttrs,
112
+ ssrBindingBlock: () => ssrBindingBlock,
113
+ ssrBindingChild: () => ssrBindingChild,
114
+ ssrBindingClass: () => ssrBindingClass,
115
+ ssrBindingHtml: () => ssrBindingHtml,
116
+ ssrBindingKey: () => ssrBindingKey,
98
117
  ssrBlock: () => ssrBlock,
99
118
  ssrCheckedAttr: () => ssrCheckedAttr,
100
119
  ssrChild: () => ssrChild,
@@ -126,6 +145,9 @@ __export(runtime_server_exports, {
126
145
  ssrSelectAttrs: () => ssrSelectAttrs,
127
146
  ssrSelectScope: () => ssrSelectScope,
128
147
  ssrSelectScopeSources: () => ssrSelectScopeSources,
148
+ ssrSignalControlAttrs: () => ssrSignalControlAttrs,
149
+ ssrSignalControlValue: () => ssrSignalControlValue,
150
+ ssrSignalValue: () => ssrSignalValue,
129
151
  ssrSnapshotSpread: () => ssrSnapshotSpread,
130
152
  ssrSpread: () => ssrSpread,
131
153
  ssrSpreadContent: () => ssrSpreadContent,
@@ -173,12 +195,15 @@ module.exports = __toCommonJS(runtime_server_exports);
173
195
  var import_trusted_html = require("./trusted-html.cjs");
174
196
  var import_read_protocol = require("./signals/read-protocol.cjs");
175
197
  var import_hook_slot_cache = require("./hook-slot-cache.cjs");
198
+ var import_dom_binding_protocol = require("./dom-binding-protocol.cjs");
176
199
  var import_constants = require("./constants.cjs");
200
+ var import_independent_hydration_protocol = require("./independent-hydration-protocol.cjs");
177
201
  var import_has_own = require("./has-own.cjs");
178
202
  var import_head_ownership = require("./head-ownership.cjs");
179
203
  var import_resource_hint_diagnostics = require("./resource-hint-diagnostics.cjs");
180
204
  var import_aria_diagnostics = require("./aria-diagnostics.cjs");
181
205
  var import_host_property_diagnostics = require("./host-property-diagnostics.cjs");
206
+ var import_early_signals = require("./server/early-signals.cjs");
182
207
  var import_shared_value_helpers = require("./shared-value-helpers.cjs");
183
208
  var import_css = require("./css.cjs");
184
209
  var import_html_tree_validation = require("./html-tree-validation.cjs");
@@ -190,6 +215,64 @@ var import_renderer_bridge = require("./renderer-bridge.cjs");
190
215
  var import_native_read_collector = require("./signals/native-read-collector.cjs");
191
216
  var import_native_read_server = require("./signals/native-read-server.cjs");
192
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
+ }
193
276
  const NATIVE_ARRAY_MAP = Array.prototype.map;
194
277
  const NATIVE_REFLECT_APPLY = Reflect.apply;
195
278
  const NATIVE_ARRAY_SPECIES_GETTER = Object.getOwnPropertyDescriptor(Array, Symbol.species)?.get;
@@ -283,6 +366,12 @@ const ACTIVE_PU_WARM_PLANS = [];
283
366
  let CURRENT_PU_WARM_CLAIMS = null;
284
367
  let ID_COUNTER = 0;
285
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;
286
375
  function newStyleCollector() {
287
376
  const collector = /* @__PURE__ */ new Map();
288
377
  collector.replay = null;
@@ -505,6 +594,13 @@ const SCOPED_VALUE_PROPERTIES = {
505
594
  get() {
506
595
  return this[SCOPED_VALUE_RESOLVER]().children;
507
596
  }
597
+ },
598
+ __octaneInvocationSite: {
599
+ configurable: true,
600
+ enumerable: false,
601
+ get() {
602
+ return this[SCOPED_VALUE_RESOLVER]().__octaneInvocationSite;
603
+ }
508
604
  }
509
605
  };
510
606
  function restoreWritableScopedChildren(props, name, value) {
@@ -660,10 +756,15 @@ function scopedValueDescriptor(resolve) {
660
756
  Object.defineProperty(descriptor, "key", SCOPED_VALUE_PROPERTIES.key);
661
757
  Object.defineProperty(descriptor, "ref", SCOPED_VALUE_PROPERTIES.ref);
662
758
  Object.defineProperty(descriptor, "children", SCOPED_VALUE_PROPERTIES.children);
759
+ Object.defineProperty(
760
+ descriptor,
761
+ "__octaneInvocationSite",
762
+ SCOPED_VALUE_PROPERTIES.__octaneInvocationSite
763
+ );
663
764
  if (process.env.NODE_ENV !== "production") Object.freeze(descriptor);
664
765
  return descriptor;
665
766
  }
666
- function createScopedElement(type, props, readChildren) {
767
+ function createScopedElement(type, props, readChildren, invocationSite) {
667
768
  const src = props ?? null;
668
769
  const key = hasElementConfigKey(src) ? "" + src.key : null;
669
770
  const copiedProps = copyScopedElementConfig(type, src);
@@ -680,9 +781,9 @@ function createScopedElement(type, props, readChildren) {
680
781
  }
681
782
  return resolvedChildren;
682
783
  };
683
- return scopedElementDescriptor(type, copiedProps, key, children);
784
+ return scopedElementDescriptor(type, copiedProps, key, children, invocationSite);
684
785
  }
685
- function nativeCreateScopedElement(type, props, readChildren) {
786
+ function nativeCreateScopedElement(type, props, readChildren, invocationSite) {
686
787
  const src = props ?? null;
687
788
  const key = hasElementConfigKey(src) ? "" + src.key : null;
688
789
  const copiedProps = copyScopedElementConfig(type, src);
@@ -690,10 +791,11 @@ function nativeCreateScopedElement(type, props, readChildren) {
690
791
  type,
691
792
  copiedProps,
692
793
  key,
693
- createNativeServerScopedResolver(readChildren)
794
+ createNativeServerScopedResolver(readChildren),
795
+ invocationSite
694
796
  );
695
797
  }
696
- function scopedElementDescriptor(type, copiedProps, key, children) {
798
+ function scopedElementDescriptor(type, copiedProps, key, children, invocationSite) {
697
799
  setScopedChildrenResolver(copiedProps, children);
698
800
  SCOPED_ELEMENT_PROPS.add(copiedProps);
699
801
  const descriptor = {
@@ -703,31 +805,43 @@ function scopedElementDescriptor(type, copiedProps, key, children) {
703
805
  key,
704
806
  ref: copiedProps.ref !== void 0 ? copiedProps.ref : null
705
807
  };
808
+ if (invocationSite !== void 0) descriptor.__octaneInvocationSite = invocationSite;
706
809
  Object.defineProperty(descriptor, "children", SCOPED_CHILDREN_PROPERTY);
707
810
  setScopedChildrenResolver(descriptor, children);
708
811
  return finalizeElementDescriptor(descriptor);
709
812
  }
710
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) {
711
820
  if (typeof type === "function" && (0, import_renderer_bridge.isRendererContext)(type)) {
712
821
  (0, import_renderer_bridge.registerServerRendererContextProvider)(renderServerContextProvider);
713
822
  }
714
823
  const src = props ?? null;
715
824
  const key = hasElementConfigKey(src) ? "" + src.key : null;
716
- let kids = children.length > 0 ? children.length === 1 ? children[0] : children : src?.children;
717
- if (children.length > 1) POSITIONAL_CHILDREN.add(children);
718
- 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
+ }
719
831
  const p = copyElementConfig(src);
720
- if (children.length > 0) p.children = kids;
832
+ if (hasPositional) p.children = kids;
721
833
  (0, import_shared_value_helpers.applyElementDefaultProps)(type, p);
722
834
  kids = p.children;
723
- return finalizeElementDescriptor({
835
+ const descriptor = {
724
836
  $$kind: ELEMENT_TAG,
725
837
  type,
726
838
  props: p,
727
839
  key,
728
840
  ref: p.ref !== void 0 ? p.ref : null,
729
841
  children: kids ?? null
730
- });
842
+ };
843
+ if (invocationSite !== void 0) descriptor.__octaneInvocationSite = invocationSite;
844
+ return finalizeElementDescriptor(descriptor);
731
845
  }
732
846
  const POSITIONAL_CHILDREN = /* @__PURE__ */ new WeakSet();
733
847
  function positionalChildren(children) {
@@ -959,6 +1073,8 @@ function cloneElement(element, config, ...children) {
959
1073
  children: kids ?? null
960
1074
  };
961
1075
  }
1076
+ if (element.__octaneInvocationSite !== void 0)
1077
+ descriptor.__octaneInvocationSite = element.__octaneInvocationSite;
962
1078
  return finalizeElementDescriptor(descriptor);
963
1079
  }
964
1080
  function cloneAndReplaceElementKey(element, key) {
@@ -1181,6 +1297,15 @@ function ssrHtml(html) {
1181
1297
  if (CURRENT_SCOPE === null) VT_SSR_HAS_RAW_HTML = false;
1182
1298
  return new RawServerHtml(html);
1183
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);
1308
+ }
1184
1309
  function serverComponentOutput(out, scope) {
1185
1310
  if (out == null) return "";
1186
1311
  if (typeof out === "string") return escapeHtml(out);
@@ -1218,21 +1343,53 @@ function ssrTextPre(v) {
1218
1343
  }
1219
1344
  function ssrComponentDescriptor(d, scope) {
1220
1345
  if (SCOPED_ELEMENT_PROPS.has(d.props)) {
1221
- 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
+ );
1222
1355
  }
1223
1356
  const children = d.children;
1224
1357
  if (children == null || children === d.props?.children) {
1225
- 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
+ );
1226
1367
  }
1227
- return ssrComponent(scope, d.type, {
1228
- ...d.props,
1229
- children
1230
- });
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
+ );
1231
1377
  }
1232
1378
  function ssrChild(v, scope) {
1379
+ if (isSignalHandle(v)) {
1380
+ v = readSignalBinding(v);
1381
+ }
1233
1382
  if (probingDangerHtmlChild(v)) return "";
1234
1383
  return ssrChildValue(v, scope, true);
1235
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
+ }
1236
1393
  function ssrChildValue(v, scope, includeKeyedSingle, selfMarkItem = false) {
1237
1394
  if (v !== null && typeof v === "object" && SERVER_HTML in v) {
1238
1395
  return v[SERVER_HTML];
@@ -1483,6 +1640,20 @@ function ssrDescriptorContent(v, scope) {
1483
1640
  function ssrBlock(content) {
1484
1641
  return MARKERS ? import_constants.BLOCK_OPEN + content + import_constants.BLOCK_CLOSE : String(content);
1485
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
+ }
1486
1657
  function ssrFragmentMarker(open, _ref) {
1487
1658
  return MARKERS ? open ? "<!--frag-->" : "<!--/frag-->" : "";
1488
1659
  }
@@ -1565,31 +1736,48 @@ function withAsyncListScope(kind, fn) {
1565
1736
  function ssrControl(siteKey, fn) {
1566
1737
  const frame = FRAME;
1567
1738
  const occurrence = frame === null ? 0 : nextFrameOccurrence(frame, "@control:" + siteKey);
1568
- 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
+ }
1569
1746
  }
1570
- function enterAsyncArm(armKey) {
1747
+ function enterAsyncArm(armKey, mapped = false) {
1571
1748
  const previous = ASYNC_SCOPE;
1572
1749
  const frame = FRAME;
1573
1750
  const occurrence = frame === null ? 0 : nextFrameOccurrence(frame, "@arm-position:");
1574
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
+ }
1575
1758
  ASYNC_SCOPE = previous + "|@arm:" + asyncIdentityKey(armKey, false, fallbackPosition);
1576
- return previous;
1577
1759
  }
1578
1760
  function ssrArm(armKey, fn) {
1579
- const previous = enterAsyncArm(armKey);
1761
+ const previous = ASYNC_SCOPE;
1762
+ const previousSignalKeys = SIGNAL_LIST_KEYS;
1580
1763
  try {
1764
+ enterAsyncArm(armKey);
1581
1765
  return fn();
1582
1766
  } finally {
1583
1767
  ASYNC_SCOPE = previous;
1768
+ SIGNAL_LIST_KEYS = previousSignalKeys;
1584
1769
  }
1585
1770
  }
1586
- function ssrForItem(armKey, fn, item, index, scope, block) {
1587
- 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;
1588
1774
  try {
1775
+ enterAsyncArm(armKey, mapped);
1589
1776
  const html = index === void 0 ? fn(item, scope) : fn(item, index, scope);
1590
1777
  return block ? ssrBlock(html) : html;
1591
1778
  } finally {
1592
1779
  ASYNC_SCOPE = previous;
1780
+ SIGNAL_LIST_KEYS = previousSignalKeys;
1593
1781
  }
1594
1782
  }
1595
1783
  function ssrPortal() {
@@ -1998,14 +2186,32 @@ function ssrClass(sources) {
1998
2186
  }
1999
2187
  return found ? ssrAttr("class", value) : "";
2000
2188
  }
2001
- function ssrSnapshotSpread(obj) {
2189
+ function ssrSnapshotSpread(obj, controlSite, deferStyle = false) {
2002
2190
  if (obj == null) return null;
2003
2191
  const source = Object(obj);
2004
2192
  const snapshot = /* @__PURE__ */ Object.create(null);
2005
2193
  for (const key of Reflect.ownKeys(source)) {
2006
2194
  if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue;
2007
- const value = source[key];
2008
- 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;
2009
2215
  }
2010
2216
  return snapshot;
2011
2217
  }
@@ -2130,24 +2336,48 @@ function ssrFormAuthoringDiagnostics(tag, sources) {
2130
2336
  return "";
2131
2337
  }
2132
2338
  function ssrValueAttr(v) {
2339
+ v = unwrapSsrSignalControlValue(v);
2133
2340
  if (v == null || typeof v === "function" || typeof v === "symbol") return "";
2134
2341
  return ' value="' + escapeAttr(typeof v === "string" ? v : String(v)) + '"';
2135
2342
  }
2136
2343
  function ssrCheckedAttr(v) {
2344
+ v = unwrapSsrSignalControlValue(v);
2137
2345
  return v == null || !v ? "" : " checked";
2138
2346
  }
2139
2347
  function ssrInputAttrs(sources) {
2140
2348
  const props = resolveFormControlSources(sources);
2141
2349
  if (process.env.NODE_ENV !== "production") {
2142
2350
  devValidateSsrFormProps("input", {
2143
- value: props.value,
2144
- defaultValue: props.defaultValue,
2145
- checked: props.checked,
2146
- defaultChecked: props.defaultChecked
2351
+ value: unwrapSsrSignalControlValue(props.value),
2352
+ defaultValue: unwrapSsrSignalControlValue(props.defaultValue),
2353
+ checked: unwrapSsrSignalControlValue(props.checked),
2354
+ defaultChecked: unwrapSsrSignalControlValue(props.defaultChecked)
2147
2355
  });
2148
2356
  }
2149
2357
  return ssrValueAttr(props.value ?? props.defaultValue) + ssrCheckedAttr(props.checked ?? props.defaultChecked);
2150
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
+ }
2151
2381
  function resolveFormControlSources(sources) {
2152
2382
  const resolved = {
2153
2383
  value: void 0,
@@ -2198,6 +2428,7 @@ function resolveFormControlSources(sources) {
2198
2428
  return resolved;
2199
2429
  }
2200
2430
  function ssrTextareaValue(v) {
2431
+ v = unwrapSsrSignalControlValue(v);
2201
2432
  if (v == null) return "";
2202
2433
  const s = escapeHtml(typeof v === "string" ? v : String(v));
2203
2434
  return s.charCodeAt(0) === 10 ? "\n" + s : s;
@@ -2206,8 +2437,8 @@ function ssrTextareaValueSources(sources) {
2206
2437
  const props = resolveFormControlSources(sources);
2207
2438
  if (process.env.NODE_ENV !== "production") {
2208
2439
  devValidateSsrFormProps("textarea", {
2209
- value: props.value,
2210
- defaultValue: props.defaultValue
2440
+ value: unwrapSsrSignalControlValue(props.value),
2441
+ defaultValue: unwrapSsrSignalControlValue(props.defaultValue)
2211
2442
  });
2212
2443
  }
2213
2444
  const value = props.value ?? props.defaultValue;
@@ -2219,6 +2450,8 @@ function ssrSelectAttrs(sources) {
2219
2450
  }
2220
2451
  const SELECT_STACK = [];
2221
2452
  function ssrSelectScope(value, defaultValue, multiple, children) {
2453
+ value = unwrapSsrSignalControlValue(value);
2454
+ defaultValue = unwrapSsrSignalControlValue(defaultValue);
2222
2455
  if (process.env.NODE_ENV !== "production") {
2223
2456
  devValidateSsrFormProps("select", { value, defaultValue, multiple });
2224
2457
  }
@@ -2577,10 +2810,96 @@ function replayUpdatedComponentBody(comp, props, scope, frame, hp, snapshot, war
2577
2810
  hp.occ = null;
2578
2811
  rewindComponentReplayState(snapshot, scope, frame);
2579
2812
  ACTIVE_PU_WARM_PLANS.length = warmPlanCheckpoint;
2580
- out = comp(props ?? {}, scope, void 0);
2813
+ out = invokeServerSignalComponent(comp, props, scope, serverSignalOwner(frame));
2581
2814
  } while (hp.update);
2582
2815
  return out;
2583
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
+ }
2584
2903
  function invokeComponentBody(comp, props, scope, frame) {
2585
2904
  const prevHP = HOOK_PASS;
2586
2905
  const hp = { hooks: null, occ: null, update: false };
@@ -2589,7 +2908,7 @@ function invokeComponentBody(comp, props, scope, frame) {
2589
2908
  HOOK_PASS = hp;
2590
2909
  try {
2591
2910
  ACTIVE_PU_WARM_PLANS.length = warmPlanCheckpoint;
2592
- let out = comp(props ?? {}, scope, void 0);
2911
+ let out = invokeServerSignalComponent(comp, props, scope, serverSignalOwner(frame));
2593
2912
  if (hp.update) {
2594
2913
  out = replayUpdatedComponentBody(comp, props, scope, frame, hp, snapshot, warmPlanCheckpoint);
2595
2914
  }
@@ -2601,14 +2920,25 @@ function invokeComponentBody(comp, props, scope, frame) {
2601
2920
  HOOK_PASS = prevHP;
2602
2921
  }
2603
2922
  }
2604
- function renderComponentFramed(comp, props, parent, frame, inherit) {
2605
- const prevScope = CURRENT_SCOPE;
2606
- const prevFrame = FRAME;
2607
- const prevComp = CURRENT_COMP;
2608
- const prevProps = CURRENT_PROPS;
2609
- const prevParent = CURRENT_PARENT_SCOPE;
2610
- const prevAsyncScope = ASYNC_SCOPE;
2611
- 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;
2612
2942
  const scope = ssrScope(parentScope);
2613
2943
  CURRENT_SCOPE = scope;
2614
2944
  FRAME = frame;
@@ -2616,6 +2946,9 @@ function renderComponentFramed(comp, props, parent, frame, inherit) {
2616
2946
  CURRENT_PROPS = props;
2617
2947
  CURRENT_PARENT_SCOPE = parentScope;
2618
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;
2619
2952
  const nativeToken = NATIVE_READ_COLLECTOR === null ? -1 : beginActiveNativeReadScope(scope);
2620
2953
  let nativeCompleted = false;
2621
2954
  try {
@@ -2627,7 +2960,20 @@ function renderComponentFramed(comp, props, parent, frame, inherit) {
2627
2960
  HOOK_PASS = hookPass;
2628
2961
  try {
2629
2962
  ACTIVE_PU_WARM_PLANS.length = warmPlanCheckpoint;
2630
- 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
+ }
2631
2977
  if (hookPass.update) {
2632
2978
  out = replayUpdatedComponentBody(
2633
2979
  comp,
@@ -2645,22 +2991,29 @@ function renderComponentFramed(comp, props, parent, frame, inherit) {
2645
2991
  }
2646
2992
  const inner = serverComponentOutput(out, scope);
2647
2993
  nativeCompleted = true;
2648
- 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;
2649
2997
  } catch (error) {
2650
2998
  throw normalizeThrownServerThenable(error);
2651
2999
  } finally {
2652
3000
  if (nativeToken >= 0) NATIVE_READ_COLLECTOR.endScope(nativeToken, nativeCompleted);
2653
- CURRENT_SCOPE = prevScope;
2654
- FRAME = prevFrame;
2655
- CURRENT_COMP = prevComp;
2656
- CURRENT_PROPS = prevProps;
2657
- CURRENT_PARENT_SCOPE = prevParent;
2658
- ASYNC_SCOPE = prevAsyncScope;
2659
- }
2660
- }
2661
- 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) {
2662
3014
  const activity = comp === Activity;
2663
3015
  if (activity && key === void 0) key = props?.key;
3016
+ let signalInstanceKey = SERVER_SIGNAL_BINDINGS_ENABLED ? serverStructuralSignalInstanceKey(invocationSite, key) : void 0;
2664
3017
  const previousIdentityScope = ASYNC_SCOPE;
2665
3018
  if (identityScoped !== true) {
2666
3019
  ASYNC_SCOPE = previousIdentityScope + "|@component-type:" + asyncIdentityKey(comp, false);
@@ -2715,17 +3068,41 @@ function ssrComponent(parent, comp, props, inherit, key, identityScoped) {
2715
3068
  asyncScope: ASYNC_SCOPE,
2716
3069
  namespace: explicitNamespace ?? pf.namespace
2717
3070
  };
2718
- 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
+ );
2719
3087
  } finally {
2720
3088
  if (identityScoped !== true) ASYNC_SCOPE = previousIdentityScope;
2721
3089
  }
2722
3090
  }
2723
3091
  let NEXT_COMPONENT_NAMESPACE = null;
2724
- function ssrComponentNS(parent, comp, props, namespace, inherit, key) {
3092
+ function ssrComponentNS(parent, comp, props, namespace, inherit, key, invocationSite, bindingMarker) {
2725
3093
  const previous = NEXT_COMPONENT_NAMESPACE;
2726
3094
  NEXT_COMPONENT_NAMESPACE = namespace;
2727
3095
  try {
2728
- 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
+ );
2729
3106
  } finally {
2730
3107
  NEXT_COMPONENT_NAMESPACE = previous;
2731
3108
  }
@@ -2750,6 +3127,50 @@ function streamTokenForPendingHtml(html) {
2750
3127
  const stream = STREAM;
2751
3128
  return stream !== null && html.includes(import_constants.STREAM_BOUNDARY_ATTR + '="' + stream.token + "-") ? stream.token : null;
2752
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
+ }
2753
3174
  function ssrHydrateAttrs(id, when, idCount, permanentStaticAncestor = false, streamToken = null) {
2754
3175
  const direct = typeof when !== "function" && when !== null ? when : null;
2755
3176
  let attrs = ssrAttr(import_constants.HYDRATE_ID_ATTR, id, "div") + ssrAttr(
@@ -2807,7 +3228,8 @@ const PermanentStaticHydrate = /* @__PURE__ */ (0, import_component_flags.markCo
2807
3228
  "PermanentStaticHydrate"
2808
3229
  );
2809
3230
  const hydrate = /* @__PURE__ */ (0, import_component_flags.markComponentFlags)(
2810
- function Hydrate(props, scope) {
3231
+ function Hydrate(rawProps, scope) {
3232
+ const props = rawProps;
2811
3233
  const id = useId();
2812
3234
  return ssrHtml(
2813
3235
  withSsrElementContext(
@@ -2825,7 +3247,7 @@ const hydrate = /* @__PURE__ */ (0, import_component_flags.markComponentFlags)(
2825
3247
  let children;
2826
3248
  let nativeReads = null;
2827
3249
  try {
2828
- children = ssrBlock(
3250
+ const renderChildren = () => ssrBlock(
2829
3251
  ssrTry(
2830
3252
  scope,
2831
3253
  "jsx-hydrate",
@@ -2835,6 +3257,11 @@ const hydrate = /* @__PURE__ */ (0, import_component_flags.markComponentFlags)(
2835
3257
  "html"
2836
3258
  )
2837
3259
  );
3260
+ children = props.__independent === void 0 ? renderChildren() : withServerIndependentIdentity(
3261
+ id,
3262
+ props.__independent.manifestTemplate.idSeed,
3263
+ renderChildren
3264
+ );
2838
3265
  } finally {
2839
3266
  nativeReads = finishNativeSeedCapture(nativeCapture, previousNativeReads, false);
2840
3267
  }
@@ -2852,7 +3279,8 @@ const hydrate = /* @__PURE__ */ (0, import_component_flags.markComponentFlags)(
2852
3279
  const seedSidecar = seedJson === null || seedJson === "[]" ? "" : '<script type="application/json" ' + import_constants.HYDRATE_SEED_ATTR + NONCE_ATTR + ">" + seedJson + "</script>";
2853
3280
  const nativeSeeds = permanentStaticAncestor ? void 0 : NATIVE_READ_COLLECTOR?.serialize(nativeReads);
2854
3281
  const nativeSidecar = nativeSeeds === void 0 ? "" : serializeNativeSignalSeeds(nativeSeeds, NONCE_ATTR);
2855
- 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>";
2856
3284
  }),
2857
3285
  "html"
2858
3286
  )
@@ -3326,7 +3754,8 @@ function normalizeThrownServerThenable(error) {
3326
3754
  comp: CURRENT_COMP,
3327
3755
  props: CURRENT_PROPS,
3328
3756
  parentScope: CURRENT_PARENT_SCOPE,
3329
- frame
3757
+ frame,
3758
+ signalInstanceKey: SIGNAL_COMPONENT_INSTANCE_KEY
3330
3759
  });
3331
3760
  }
3332
3761
  return SSR_SUSPENSE;
@@ -3598,7 +4027,8 @@ function use(usable, siteKey, directSite) {
3598
4027
  comp: CURRENT_COMP,
3599
4028
  props: CURRENT_PROPS,
3600
4029
  parentScope: CURRENT_PARENT_SCOPE,
3601
- frame
4030
+ frame,
4031
+ signalInstanceKey: SIGNAL_COMPONENT_INSTANCE_KEY
3602
4032
  });
3603
4033
  }
3604
4034
  throw SSR_SUSPENSE;
@@ -3765,7 +4195,8 @@ function puBatch(thenables, warm) {
3765
4195
  comp: CURRENT_COMP,
3766
4196
  props: CURRENT_PROPS,
3767
4197
  parentScope: CURRENT_PARENT_SCOPE,
3768
- frame
4198
+ frame,
4199
+ signalInstanceKey: SIGNAL_COMPONENT_INSTANCE_KEY
3769
4200
  });
3770
4201
  }
3771
4202
  throw SSR_SUSPENSE;
@@ -3929,7 +4360,8 @@ function lazy(load) {
3929
4360
  comp: CURRENT_COMP,
3930
4361
  props: CURRENT_PROPS,
3931
4362
  parentScope: CURRENT_PARENT_SCOPE,
3932
- frame
4363
+ frame,
4364
+ signalInstanceKey: SIGNAL_COMPONENT_INSTANCE_KEY
3933
4365
  });
3934
4366
  }
3935
4367
  throw SSR_SUSPENSE;
@@ -4415,9 +4847,26 @@ function serializeNativeSignalSeeds(signals, nonceAttr, attr = import_native_rea
4415
4847
  const json = JSON.stringify(signals).replace(/</g, "\\u003c");
4416
4848
  return '<script type="application/json" ' + attr + nonceAttr + ">" + json + "</script>";
4417
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
+ }
4418
4860
  function newResolvedMap(resourceOptions) {
4419
4861
  const m = /* @__PURE__ */ new Map();
4420
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
+ }
4421
4870
  m.asyncIdentities = /* @__PURE__ */ new Map();
4422
4871
  m.asyncPositionIdentities = /* @__PURE__ */ new Map();
4423
4872
  m.nextAsyncIdentity = 0;
@@ -4461,6 +4910,13 @@ function releaseServerRenderResources(resolved) {
4461
4910
  }
4462
4911
  const resources = resolved.resources;
4463
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
+ }
4464
4920
  if (resources !== void 0) resolved.resources = void 0;
4465
4921
  if (resources === void 0 || resources.finished) return;
4466
4922
  resources.finished = true;
@@ -4486,6 +4942,11 @@ function saveAmbient() {
4486
4942
  warmClaims: CURRENT_PU_WARM_CLAIMS,
4487
4943
  id: ID_COUNTER,
4488
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,
4489
4950
  css: CSS,
4490
4951
  nonceAttr: NONCE_ATTR,
4491
4952
  markers: MARKERS,
@@ -4539,6 +5000,11 @@ function restoreAmbient(a) {
4539
5000
  CURRENT_PU_WARM_CLAIMS = a.warmClaims;
4540
5001
  ID_COUNTER = a.id;
4541
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;
4542
5008
  CSS = a.css;
4543
5009
  NONCE_ATTR = a.nonceAttr;
4544
5010
  MARKERS = a.markers;
@@ -4579,6 +5045,11 @@ function runFullFramedPass(component, props, resolved, nonceAttr = "", identifie
4579
5045
  CURRENT_PU_WARM_CLAIMS = null;
4580
5046
  ID_COUNTER = 0;
4581
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;
4582
5053
  NONCE_ATTR = nonceAttr;
4583
5054
  ASYNC_SCOPE = "";
4584
5055
  MARKERS = markers;
@@ -4632,6 +5103,10 @@ function runFullFramedPass(component, props, resolved, nonceAttr = "", identifie
4632
5103
  try {
4633
5104
  const out = invokeComponentBody(component, props, root, FRAME);
4634
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
+ }
4635
5110
  nativePassCompleted = true;
4636
5111
  } catch (err) {
4637
5112
  err = normalizeThrownServerThenable(err);
@@ -4676,7 +5151,8 @@ function runFullFramedPass(component, props, resolved, nonceAttr = "", identifie
4676
5151
  vtCandidates,
4677
5152
  rawHtml,
4678
5153
  cssEntries: cssMap,
4679
- sheets: headBuf.sheets
5154
+ sheets: headBuf.sheets,
5155
+ hasSignalControls: resolved.hasSignalControls === true
4680
5156
  };
4681
5157
  if (signals !== void 0) result.signals = signals;
4682
5158
  return result;
@@ -4691,6 +5167,11 @@ function runDiscoveryRound(jobs, resolved, identifierPrefix) {
4691
5167
  CURRENT_PU_WARM_CLAIMS = null;
4692
5168
  ID_COUNTER = 0;
4693
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;
4694
5175
  NONCE_ATTR = "";
4695
5176
  ASYNC_SCOPE = "";
4696
5177
  MARKERS = true;
@@ -4737,7 +5218,14 @@ function runDiscoveryRound(jobs, resolved, identifierPrefix) {
4737
5218
  namespace: void 0
4738
5219
  };
4739
5220
  try {
4740
- 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
+ );
4741
5229
  } catch (err) {
4742
5230
  if (!ssrIsSuspense(err)) continue;
4743
5231
  }
@@ -4955,10 +5443,13 @@ async function runBuffered(component, props, options, nonceAttr, resolved) {
4955
5443
  if (resolved.pu.touched !== void 0) resolved.pu.touched = /* @__PURE__ */ new Set();
4956
5444
  }
4957
5445
  }
4958
- function passToResult(pass, nonceAttr, separateHead = false) {
5446
+ function passToResult(pass, nonceAttr, separateHead = false, independentHydration = false, externalSignalBootstrap = false) {
4959
5447
  let body = pass.body;
4960
5448
  if (pass.serial.length > 0) body += serializeSuspenseSeeds(pass.serial, nonceAttr);
4961
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
+ }
4962
5453
  let result;
4963
5454
  if (separateHead) {
4964
5455
  result = {
@@ -4973,20 +5464,108 @@ function passToResult(pass, nonceAttr, separateHead = false) {
4973
5464
  if (pass.signals !== void 0) result.signals = pass.signals;
4974
5465
  return result;
4975
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
+ }
4976
5527
  async function prerender(entryComponent, props, options) {
4977
5528
  const component = typeof entryComponent === "function" ? entryComponent : renderEntryValue;
4978
5529
  if (typeof entryComponent !== "function") {
4979
5530
  options ??= props;
4980
5531
  props = { value: entryComponent };
4981
5532
  }
4982
- const nonceAttr = nonceAttrOf(options);
4983
- 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);
4984
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
+ }
4985
5556
  return passToResult(
4986
- await runBuffered(component, props, options, nonceAttr, resolved),
5557
+ pass,
4987
5558
  nonceAttr,
4988
- options?.headChannel === "separate"
5559
+ renderOptions?.headChannel === "separate",
5560
+ renderOptions?.independentHydration !== void 0,
5561
+ renderOptions?.earlySignalBootstrap === "external"
4989
5562
  );
5563
+ } catch (error) {
5564
+ try {
5565
+ injection?.cancel?.(error);
5566
+ } catch {
5567
+ }
5568
+ throw error;
4990
5569
  } finally {
4991
5570
  releaseServerRenderResources(resolved);
4992
5571
  }
@@ -5101,7 +5680,13 @@ function renderToString(entryComponent, props, options) {
5101
5680
  } finally {
5102
5681
  releaseServerRenderResources(resolved);
5103
5682
  }
5104
- 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
+ );
5105
5690
  }
5106
5691
  function renderToStaticMarkup(entryComponent, props, options) {
5107
5692
  const component = typeof entryComponent === "function" ? entryComponent : renderEntryValue;
@@ -5817,6 +6402,20 @@ function drain(){
5817
6402
  }
5818
6403
  })();`;
5819
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
+ };
6418
+ }
5820
6419
  function withStream(stream, fn) {
5821
6420
  const prev = STREAM;
5822
6421
  STREAM = stream;
@@ -5996,7 +6595,14 @@ async function runStream(component, props, options, sink, resolved) {
5996
6595
  return;
5997
6596
  }
5998
6597
  if (!html) return;
5999
- 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
+ });
6000
6606
  };
6001
6607
  const recoveryInjection = injection === void 0 ? void 0 : async () => {
6002
6608
  if (signal?.aborted) {
@@ -6196,11 +6802,18 @@ async function runStream(component, props, options, sink, resolved) {
6196
6802
  }
6197
6803
  if (pass.serial.length > 0) shell += serializeSuspenseSeeds(pass.serial, nonceAttr);
6198
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();
6199
6809
  const anyPending = stream.boundaries.size > 0;
6200
6810
  let sentViewTransitions = pass.vtCandidates;
6201
6811
  if (anyPending)
6202
6812
  shell += "<script " + import_constants.STREAM_SCRIPT_ATTR + nonceAttr + ">" + streamRuntimeJs() + (sentViewTransitions ? streamViewTransitionRuntimeJs() : "") + "</script>";
6203
6813
  try {
6814
+ if (injection?.streamedRenderer === true || pass.hasSignalControls || options?.independentHydration !== void 0) {
6815
+ options?.onEarlyHydrationReady?.();
6816
+ }
6204
6817
  const shellWrite = write(pass.vtCandidates ? vtSsrStrip(shell, pass.rawHtml) : shell);
6205
6818
  if (shellWrite !== void 0) await shellWrite;
6206
6819
  } catch (err) {
@@ -6531,10 +7144,8 @@ function renderToPipeableStream(entryComponent, props, options) {
6531
7144
  finishEnd();
6532
7145
  };
6533
7146
  let started = false;
6534
- const startRender = () => {
6535
- if (started) return;
6536
- started = true;
6537
- const renderOptions = { ...options, signal: controller.signal };
7147
+ const beginRender = (preparedOptions) => {
7148
+ const renderOptions = { ...preparedOptions, signal: controller.signal };
6538
7149
  const resolved = newResolvedMap(renderOptions);
6539
7150
  void runStream(
6540
7151
  component,
@@ -6571,6 +7182,18 @@ function renderToPipeableStream(entryComponent, props, options) {
6571
7182
  flushEnd();
6572
7183
  });
6573
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
+ };
6574
7197
  queueMicrotask(startRender);
6575
7198
  return {
6576
7199
  pipe(dest) {
@@ -6607,6 +7230,11 @@ function renderToReadableStream(entryComponent, props, options) {
6607
7230
  options ??= props;
6608
7231
  props = { value: entryComponent };
6609
7232
  }
7233
+ if (needsAutomaticSignalInjection(options)) {
7234
+ return prepareAutomaticSignalInjection(options).then(
7235
+ (prepared) => renderToReadableStream(component, props, prepared)
7236
+ );
7237
+ }
6610
7238
  return new Promise((resolveShell, rejectShell) => {
6611
7239
  const encoder = new TextEncoder();
6612
7240
  const renderController = new AbortController();
@@ -7092,16 +7720,20 @@ function preinitModule(href, options) {
7092
7720
  addTransitionType,
7093
7721
  beginNativeReadScope,
7094
7722
  beginNativeReadWitness,
7723
+ bindPresentationView,
7095
7724
  callWithReceiver,
7096
7725
  cloneElement,
7097
7726
  createContext,
7098
7727
  createElement,
7728
+ createElementAt,
7729
+ createElementFromConfig,
7099
7730
  createHostedServerSession,
7100
7731
  createPortal,
7101
7732
  createScopedElement,
7102
7733
  createScopedValue,
7103
7734
  descriptorChildren,
7104
7735
  enableNativeReadCollection,
7736
+ enableServerSignalBindings,
7105
7737
  encodeAsyncIdentityString,
7106
7738
  endNativeReadScope,
7107
7739
  escapeAttr,
@@ -7154,6 +7786,11 @@ function preinitModule(href, options) {
7154
7786
  ssrArm,
7155
7787
  ssrAttr,
7156
7788
  ssrAttrs,
7789
+ ssrBindingBlock,
7790
+ ssrBindingChild,
7791
+ ssrBindingClass,
7792
+ ssrBindingHtml,
7793
+ ssrBindingKey,
7157
7794
  ssrBlock,
7158
7795
  ssrCheckedAttr,
7159
7796
  ssrChild,
@@ -7185,6 +7822,9 @@ function preinitModule(href, options) {
7185
7822
  ssrSelectAttrs,
7186
7823
  ssrSelectScope,
7187
7824
  ssrSelectScopeSources,
7825
+ ssrSignalControlAttrs,
7826
+ ssrSignalControlValue,
7827
+ ssrSignalValue,
7188
7828
  ssrSnapshotSpread,
7189
7829
  ssrSpread,
7190
7830
  ssrSpreadContent,