octane 0.3.0 → 0.3.2

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 (55) hide show
  1. package/dist/cjs/constants.cjs +18 -25
  2. package/dist/cjs/css.cjs +6 -0
  3. package/dist/cjs/dom-binding-protocol.cjs +37 -14
  4. package/dist/cjs/hydration/control-capture.cjs +12 -4
  5. package/dist/cjs/hydration/event-capture.cjs +6 -7
  6. package/dist/cjs/hydration-markers.cjs +40 -2
  7. package/dist/cjs/index.cjs +2 -0
  8. package/dist/cjs/runtime-tags.cjs +55 -0
  9. package/dist/cjs/runtime.cjs +235 -148
  10. package/dist/cjs/runtime.server.cjs +110 -80
  11. package/dist/cjs/server/streamed-signals.cjs +102 -64
  12. package/dist/cjs/signals/control-binding.cjs +2 -1
  13. package/dist/cjs/stream-protocol.cjs +9 -8
  14. package/dist/cjs/version.cjs +1 -1
  15. package/dist/compiler/compile.js +550 -35
  16. package/dist/compiler/dom-bindings.js +5 -0
  17. package/dist/compiler/hydrate-boundaries.js +118 -0
  18. package/dist/compiler/private-context.js +160 -0
  19. package/dist/constants.d.ts +7 -18
  20. package/dist/constants.js +11 -9
  21. package/dist/css.d.ts +7 -0
  22. package/dist/css.js +4 -0
  23. package/dist/dom-binding-program.js +12 -5
  24. package/dist/dom-binding-protocol.d.ts +14 -1
  25. package/dist/dom-binding-protocol.js +40 -14
  26. package/dist/hydration/control-capture.d.ts +2 -0
  27. package/dist/hydration/control-capture.js +18 -5
  28. package/dist/hydration/event-capture.js +1 -2
  29. package/dist/hydration/independent-island.js +5 -5
  30. package/dist/hydration/stream-delivery.d.ts +1 -1
  31. package/dist/hydration/stream-delivery.js +16 -9
  32. package/dist/hydration/stream-result-receiver.d.ts +1 -0
  33. package/dist/hydration/stream-result-receiver.js +8 -4
  34. package/dist/hydration-markers.d.ts +30 -0
  35. package/dist/hydration-markers.js +27 -1
  36. package/dist/index.d.ts +1 -1
  37. package/dist/index.js +2 -0
  38. package/dist/react/index.js +1 -1
  39. package/dist/react/react-compat-shared.js +5 -3
  40. package/dist/react/shared.d.ts +1 -3
  41. package/dist/react/shared.js +1 -1
  42. package/dist/runtime-tags.d.ts +34 -0
  43. package/dist/runtime-tags.js +22 -0
  44. package/dist/runtime.d.ts +9 -14
  45. package/dist/runtime.js +213 -106
  46. package/dist/runtime.server.d.ts +10 -5
  47. package/dist/runtime.server.js +101 -56
  48. package/dist/server/streamed-signals.d.ts +1 -0
  49. package/dist/server/streamed-signals.js +102 -64
  50. package/dist/signals/control-binding.js +4 -2
  51. package/dist/stream-protocol.js +20 -9
  52. package/dist/universal-core.js +8 -4
  53. package/dist/universal-native.js +1 -1
  54. package/dist/version.js +1 -1
  55. package/package.json +3 -3
@@ -196,6 +196,8 @@ var import_trusted_html = require("./trusted-html.cjs");
196
196
  var import_read_protocol = require("./signals/read-protocol.cjs");
197
197
  var import_hook_slot_cache = require("./hook-slot-cache.cjs");
198
198
  var import_dom_binding_protocol = require("./dom-binding-protocol.cjs");
199
+ var import_hydration_markers = require("./hydration-markers.cjs");
200
+ var import_runtime_tags = require("./runtime-tags.cjs");
199
201
  var import_constants = require("./constants.cjs");
200
202
  var import_independent_hydration_protocol = require("./independent-hydration-protocol.cjs");
201
203
  var import_has_own = require("./has-own.cjs");
@@ -372,7 +374,7 @@ let SIGNAL_COMPONENT_INSTANCE_KEY = "";
372
374
  let SERVER_SIGNAL_OWNER_ACTIVE = false;
373
375
  let SIGNAL_CONTROL_SITE = "";
374
376
  const EMPTY_SIGNAL_LIST_KEYS = [];
375
- let SIGNAL_LIST_KEYS = EMPTY_SIGNAL_LIST_KEYS;
377
+ let SIGNAL_LIST_KEYS = null;
376
378
  function newStyleCollector() {
377
379
  const collector = /* @__PURE__ */ new Map();
378
380
  collector.replay = null;
@@ -546,10 +548,8 @@ function ssrNestingText(value) {
546
548
  }
547
549
  const NOOP = () => {
548
550
  };
549
- const ELEMENT_TAG = /* @__PURE__ */ Symbol.for("octane.element");
550
- const PORTAL_TAG = /* @__PURE__ */ Symbol.for("octane.portal");
551
- const Fragment = /* @__PURE__ */ Symbol.for("octane.Fragment");
552
- const Activity = /* @__PURE__ */ Symbol.for("octane.Activity");
551
+ const Fragment = import_runtime_tags.FRAGMENT_TAG;
552
+ const Activity = import_runtime_tags.ACTIVITY_TAG;
553
553
  const SCOPED_ELEMENT_PROPS = /* @__PURE__ */ new WeakSet();
554
554
  const SCOPED_CHILDREN_RESOLVER = /* @__PURE__ */ Symbol("octane.scopedChildrenResolver");
555
555
  const SCOPED_VALUE_RESOLVER = /* @__PURE__ */ Symbol("octane.scopedValueResolver");
@@ -750,7 +750,7 @@ function nativeCreateScopedValue(readElement) {
750
750
  return scopedValueDescriptor(createNativeServerScopedResolver(readElement));
751
751
  }
752
752
  function scopedValueDescriptor(resolve) {
753
- const descriptor = { $$kind: ELEMENT_TAG };
753
+ const descriptor = { $$kind: import_runtime_tags.ELEMENT_TAG };
754
754
  Object.defineProperty(descriptor, SCOPED_VALUE_RESOLVER, { value: resolve });
755
755
  Object.defineProperty(descriptor, "type", SCOPED_VALUE_PROPERTIES.type);
756
756
  Object.defineProperty(descriptor, "props", SCOPED_VALUE_PROPERTIES.props);
@@ -800,7 +800,7 @@ function scopedElementDescriptor(type, copiedProps, key, children, invocationSit
800
800
  setScopedChildrenResolver(copiedProps, children);
801
801
  SCOPED_ELEMENT_PROPS.add(copiedProps);
802
802
  const descriptor = {
803
- $$kind: ELEMENT_TAG,
803
+ $$kind: import_runtime_tags.ELEMENT_TAG,
804
804
  type,
805
805
  props: copiedProps,
806
806
  key,
@@ -834,7 +834,7 @@ function createElementFromConfig(invocationSite, type, props, children) {
834
834
  (0, import_shared_value_helpers.applyElementDefaultProps)(type, p);
835
835
  kids = p.children;
836
836
  const descriptor = {
837
- $$kind: ELEMENT_TAG,
837
+ $$kind: import_runtime_tags.ELEMENT_TAG,
838
838
  type,
839
839
  props: p,
840
840
  key,
@@ -850,7 +850,7 @@ function positionalChildren(children) {
850
850
  return children;
851
851
  }
852
852
  function isElementDescriptor(v) {
853
- return v != null && v.$$kind === ELEMENT_TAG;
853
+ return v != null && v.$$kind === import_runtime_tags.ELEMENT_TAG;
854
854
  }
855
855
  function isFragmentDescriptor(value) {
856
856
  return isElementDescriptor(value) && value.type === Fragment;
@@ -862,7 +862,7 @@ function fragmentDescriptorChildren(value) {
862
862
  }
863
863
  function fragmentRefDescriptor(value) {
864
864
  return {
865
- $$kind: ELEMENT_TAG,
865
+ $$kind: import_runtime_tags.ELEMENT_TAG,
866
866
  type: renderFragmentRefDescriptor,
867
867
  props: value,
868
868
  key: value.key,
@@ -1052,7 +1052,7 @@ function cloneElement(element, config, ...children) {
1052
1052
  let descriptor;
1053
1053
  if (preserveScopedChildren) {
1054
1054
  descriptor = {
1055
- $$kind: ELEMENT_TAG,
1055
+ $$kind: import_runtime_tags.ELEMENT_TAG,
1056
1056
  type: element.type,
1057
1057
  props,
1058
1058
  key,
@@ -1066,7 +1066,7 @@ function cloneElement(element, config, ...children) {
1066
1066
  if (scopedResolver !== void 0) setScopedChildrenResolver(descriptor, scopedResolver);
1067
1067
  } else {
1068
1068
  descriptor = {
1069
- $$kind: ELEMENT_TAG,
1069
+ $$kind: import_runtime_tags.ELEMENT_TAG,
1070
1070
  type: element.type,
1071
1071
  props,
1072
1072
  key,
@@ -1085,7 +1085,7 @@ function cloneAndReplaceElementKey(element, key) {
1085
1085
  const get = Object.getOwnPropertyDescriptor(element, "children").get;
1086
1086
  const copiedGetter = get === SCOPED_VALUE_PROPERTIES.children.get ? () => get.call(element) : get;
1087
1087
  descriptor = {
1088
- $$kind: ELEMENT_TAG,
1088
+ $$kind: import_runtime_tags.ELEMENT_TAG,
1089
1089
  type: element.type,
1090
1090
  props: element.props,
1091
1091
  key,
@@ -1104,7 +1104,7 @@ function cloneAndReplaceElementKey(element, key) {
1104
1104
  }
1105
1105
  } else {
1106
1106
  descriptor = {
1107
- $$kind: ELEMENT_TAG,
1107
+ $$kind: import_runtime_tags.ELEMENT_TAG,
1108
1108
  type: element.type,
1109
1109
  props: element.props,
1110
1110
  key,
@@ -1167,7 +1167,7 @@ function mapIntoChildren(children, out, escapedPrefix, nameSoFar, callback) {
1167
1167
  children = null;
1168
1168
  type = "object";
1169
1169
  }
1170
- const isLeaf = children === null || type === "string" || type === "number" || type === "bigint" || isElementDescriptor(children) || children != null && children.$$kind === PORTAL_TAG;
1170
+ const isLeaf = children === null || type === "string" || type === "number" || type === "bigint" || isElementDescriptor(children) || children != null && children.$$kind === import_runtime_tags.PORTAL_TAG;
1171
1171
  if (isLeaf) {
1172
1172
  const child = children;
1173
1173
  let mapped = callback(child);
@@ -1266,7 +1266,7 @@ const Children = {
1266
1266
  };
1267
1267
  function createPortal(body, target, props = void 0) {
1268
1268
  const key = typeof props === "string" || typeof props === "number" ? String(props) : null;
1269
- return { $$kind: PORTAL_TAG, body, target, key, props: key === null ? props : void 0 };
1269
+ return { $$kind: import_runtime_tags.PORTAL_TAG, body, target, key, props: key === null ? props : void 0 };
1270
1270
  }
1271
1271
  const HTML_ESCAPE_RE = /[&<>]/;
1272
1272
  const SERVER_HTML = /* @__PURE__ */ Symbol.for("octane.serverHtml");
@@ -1301,7 +1301,7 @@ function ssrHtml(html) {
1301
1301
  const BINDING_HTML_ROOT = /* @__PURE__ */ Symbol.for("octane.binding.html");
1302
1302
  function ssrBindingHtml(html, id) {
1303
1303
  const output = new ServerHtml(html);
1304
- output[BINDING_HTML_ROOT] = "[b;" + id + ";root";
1304
+ output[BINDING_HTML_ROOT] = (0, import_dom_binding_protocol.bindingRootMarker)(id);
1305
1305
  return output;
1306
1306
  }
1307
1307
  function bindPresentationView(view, _id) {
@@ -1396,7 +1396,7 @@ function ssrChildValue(v, scope, includeKeyedSingle, selfMarkItem = false) {
1396
1396
  return v[SERVER_HTML];
1397
1397
  }
1398
1398
  if (v == null || v === false || v === true) return ssrBlock("");
1399
- if ((typeof v === "object" || typeof v === "function") && (v.$$kind === CONTEXT_TAG || typeof v.then === "function")) {
1399
+ if ((typeof v === "object" || typeof v === "function") && (v.$$kind === import_runtime_tags.CONTEXT_TAG || typeof v.then === "function")) {
1400
1400
  return ssrChildValue(
1401
1401
  use(v),
1402
1402
  scope,
@@ -1420,7 +1420,7 @@ function ssrChildValue(v, scope, includeKeyedSingle, selfMarkItem = false) {
1420
1420
  if (typeof v === "function")
1421
1421
  return ssrComponent(scope, v, {}, void 0, void 0, true);
1422
1422
  if (typeof v === "object") {
1423
- if (v.$$kind === ELEMENT_TAG) {
1423
+ if (v.$$kind === import_runtime_tags.ELEMENT_TAG) {
1424
1424
  const d = v;
1425
1425
  const render = () => {
1426
1426
  if (typeof d.type === "string") {
@@ -1435,7 +1435,7 @@ function ssrChildValue(v, scope, includeKeyedSingle, selfMarkItem = false) {
1435
1435
  const renderType = () => withAsyncIdentity("child-type", d.type, render);
1436
1436
  return d.key != null ? withAsyncIdentity("child-key", d.key, renderType, true) : renderType();
1437
1437
  }
1438
- if (v.$$kind === PORTAL_TAG) return ssrBlock(ssrPortal());
1438
+ if (v.$$kind === import_runtime_tags.PORTAL_TAG) return ssrBlock(ssrPortal());
1439
1439
  throw invalidChildError(v);
1440
1440
  }
1441
1441
  return ssrBlock(escapeHtml(v));
@@ -1576,14 +1576,14 @@ function ssrDeoptBlockChildren(children, scope) {
1576
1576
  }
1577
1577
  function serverDescNeedsBlocks(v) {
1578
1578
  if (v == null || typeof v !== "object") return false;
1579
- if (v.$$kind === CONTEXT_TAG || typeof v.then === "function") return true;
1579
+ if (v.$$kind === import_runtime_tags.CONTEXT_TAG || typeof v.then === "function") return true;
1580
1580
  if (Array.isArray(v)) {
1581
1581
  for (let i = 0; i < v.length; i++) if (serverDescNeedsBlocks(v[i])) return true;
1582
1582
  return false;
1583
1583
  }
1584
1584
  if (!isElementDescriptor(v) && (0, import_shared_value_helpers.childrenIterator)(v) !== null) return true;
1585
1585
  const d = v;
1586
- if (d.$$kind === ELEMENT_TAG) {
1586
+ if (d.$$kind === import_runtime_tags.ELEMENT_TAG) {
1587
1587
  if (d.type === Fragment || d.type === Activity) return true;
1588
1588
  return typeof d.type === "function" || serverDescNeedsBlocks(d.children);
1589
1589
  }
@@ -1607,7 +1607,7 @@ function serverHostHasPrimitiveChildren(children) {
1607
1607
  return children === null || typeof children !== "object" && typeof children !== "function";
1608
1608
  }
1609
1609
  function ssrDeoptItemContent(value, scope) {
1610
- if (value !== null && typeof value === "object" && value.$$kind === ELEMENT_TAG) {
1610
+ if (value !== null && typeof value === "object" && value.$$kind === import_runtime_tags.ELEMENT_TAG) {
1611
1611
  const descriptor = value;
1612
1612
  if (typeof descriptor.type === "string") {
1613
1613
  const type = descriptor.type;
@@ -1627,7 +1627,7 @@ function ssrDescriptorContent(v, scope) {
1627
1627
  for (let i = 0; i < v.length; i++) out += ssrDescriptorContent(v[i], scope);
1628
1628
  return out;
1629
1629
  }
1630
- if (typeof v === "object" && v.$$kind === ELEMENT_TAG) {
1630
+ if (typeof v === "object" && v.$$kind === import_runtime_tags.ELEMENT_TAG) {
1631
1631
  const d = v;
1632
1632
  if (typeof d.type === "string") return ssrHostElement(d.type, d.props, d.children, scope);
1633
1633
  return ssrComponentDescriptor(d, scope);
@@ -1751,10 +1751,7 @@ function enterAsyncArm(armKey, mapped = false) {
1751
1751
  const occurrence = frame === null ? 0 : nextFrameOccurrence(frame, "@arm-position:");
1752
1752
  const fallbackPosition = armKey !== null && (typeof armKey === "object" || typeof armKey === "function" || typeof armKey === "symbol") ? previous + "|@arm-position:" + occurrence : void 0;
1753
1753
  if (SERVER_SIGNAL_BINDINGS_POTENTIAL && SIGNAL_CONTROL_SITE.charCodeAt(0) === 102) {
1754
- SIGNAL_LIST_KEYS = [
1755
- ...SIGNAL_LIST_KEYS,
1756
- signalIdentityKey(mapped ? "k" + String(armKey) : armKey)
1757
- ];
1754
+ SIGNAL_LIST_KEYS = { parent: SIGNAL_LIST_KEYS, key: armKey, mapped, values: null };
1758
1755
  }
1759
1756
  ASYNC_SCOPE = previous + "|@arm:" + asyncIdentityKey(armKey, false, fallbackPosition);
1760
1757
  }
@@ -2823,10 +2820,27 @@ function signalIdentityKey(value) {
2823
2820
  function serverStructuralSignalInstanceKey(invocationSite, key) {
2824
2821
  return resolveServerSignalInstanceKey(SIGNAL_COMPONENT_INSTANCE_KEY) + JSON.stringify([
2825
2822
  invocationSite ?? "legacy",
2826
- SIGNAL_LIST_KEYS,
2823
+ resolveServerSignalListKeys(SIGNAL_LIST_KEYS),
2827
2824
  key != null ? signalIdentityKey(key) : ""
2828
2825
  ]);
2829
2826
  }
2827
+ function resolveServerSignalListKeys(keys) {
2828
+ if (keys === null) return EMPTY_SIGNAL_LIST_KEYS;
2829
+ if (keys.values !== null) return keys.values;
2830
+ const pending = [];
2831
+ let parent = keys;
2832
+ while (parent !== null && parent.values === null) {
2833
+ pending.push(parent);
2834
+ parent = parent.parent;
2835
+ }
2836
+ let values = parent?.values ?? EMPTY_SIGNAL_LIST_KEYS;
2837
+ for (let index = pending.length - 1; index >= 0; index--) {
2838
+ const entry = pending[index];
2839
+ values = [...values, signalIdentityKey(entry.mapped ? "k" + String(entry.key) : entry.key)];
2840
+ entry.values = values;
2841
+ }
2842
+ return values;
2843
+ }
2830
2844
  function resolveServerSignalInstanceKey(identity) {
2831
2845
  if (typeof identity === "string") return identity;
2832
2846
  if (identity.signalInstanceKey !== void 0) return identity.signalInstanceKey;
@@ -2843,8 +2857,8 @@ function resolveServerSignalInstanceKey(identity) {
2843
2857
  const frame = pending[index];
2844
2858
  identity += JSON.stringify([
2845
2859
  frame.signalInvocationSite ?? "legacy",
2846
- frame.signalListKeys,
2847
- frame.signalKey
2860
+ resolveServerSignalListKeys(frame.signalListKeys ?? null),
2861
+ frame.signalKey != null ? signalIdentityKey(frame.signalKey) : ""
2848
2862
  ]);
2849
2863
  frame.signalInstanceKey = identity;
2850
2864
  }
@@ -2949,7 +2963,7 @@ function renderComponentFramed(comp, props, parent, frame, inherit, instanceKey,
2949
2963
  ASYNC_SCOPE = frame.asyncScope;
2950
2964
  if (instanceKey !== void 0) SIGNAL_COMPONENT_INSTANCE_KEY = instanceKey;
2951
2965
  SIGNAL_CONTROL_SITE = "";
2952
- SIGNAL_LIST_KEYS = EMPTY_SIGNAL_LIST_KEYS;
2966
+ SIGNAL_LIST_KEYS = null;
2953
2967
  const nativeToken = NATIVE_READ_COLLECTOR === null ? -1 : beginActiveNativeReadScope(scope);
2954
2968
  let nativeCompleted = false;
2955
2969
  try {
@@ -3048,34 +3062,36 @@ function ssrComponent(parent, comp, props, inherit, key, identityScoped, invocat
3048
3062
  });
3049
3063
  }
3050
3064
  const pf = FRAME;
3051
- const frame = pf === null ? {
3052
- parent: null,
3053
- seg: 0,
3065
+ const seg = pf === null ? 0 : nextChildSegment(pf);
3066
+ const namespace = explicitNamespace ?? pf?.namespace;
3067
+ const potentialSignalKey = signalInstanceKey === void 0 && SERVER_SIGNAL_BINDINGS_POTENTIAL;
3068
+ const frame = potentialSignalKey ? {
3069
+ parent: pf,
3070
+ seg,
3054
3071
  nextChild: 0,
3055
3072
  scopedChildren: null,
3056
3073
  occ: null,
3057
3074
  path: null,
3058
3075
  deferred: false,
3059
3076
  asyncScope: ASYNC_SCOPE,
3060
- namespace: explicitNamespace ?? void 0
3077
+ namespace,
3078
+ signalParentKey: SIGNAL_COMPONENT_INSTANCE_KEY,
3079
+ signalInvocationSite: invocationSite,
3080
+ signalListKeys: SIGNAL_LIST_KEYS,
3081
+ signalKey: key,
3082
+ signalInstanceKey: void 0
3061
3083
  } : {
3062
3084
  parent: pf,
3063
- seg: nextChildSegment(pf),
3085
+ seg,
3064
3086
  nextChild: 0,
3065
3087
  scopedChildren: null,
3066
3088
  occ: null,
3067
3089
  path: null,
3068
3090
  deferred: false,
3069
3091
  asyncScope: ASYNC_SCOPE,
3070
- namespace: explicitNamespace ?? pf.namespace
3092
+ namespace
3071
3093
  };
3072
- if (signalInstanceKey === void 0 && SERVER_SIGNAL_BINDINGS_POTENTIAL) {
3073
- frame.signalParentKey = SIGNAL_COMPONENT_INSTANCE_KEY;
3074
- frame.signalInvocationSite = invocationSite;
3075
- frame.signalListKeys = SIGNAL_LIST_KEYS;
3076
- frame.signalKey = key != null ? signalIdentityKey(key) : "";
3077
- signalInstanceKey = frame;
3078
- }
3094
+ if (potentialSignalKey) signalInstanceKey = frame;
3079
3095
  return renderComponentFramed(
3080
3096
  comp,
3081
3097
  props,
@@ -3158,7 +3174,7 @@ function withServerIndependentIdentity(prefix, idSeed, render) {
3158
3174
  SIGNAL_INSTANCE_PREFIX = prefix;
3159
3175
  SIGNAL_COMPONENT_INSTANCE_KEY = JSON.stringify([prefix, "root"]);
3160
3176
  SIGNAL_CONTROL_SITE = "";
3161
- SIGNAL_LIST_KEYS = EMPTY_SIGNAL_LIST_KEYS;
3177
+ SIGNAL_LIST_KEYS = null;
3162
3178
  ID_PREFIX = prefix + "-";
3163
3179
  ID_COUNTER = idSeed;
3164
3180
  try {
@@ -3312,7 +3328,7 @@ const Suspense = /* @__PURE__ */ (0, import_component_flags.markComponentFlags)(
3312
3328
  },
3313
3329
  import_component_flags.COMPONENT_FLAG_BOUNDARY,
3314
3330
  "Suspense",
3315
- /* @__PURE__ */ Symbol.for("octane.suspense")
3331
+ import_runtime_tags.SUSPENSE_TAG
3316
3332
  );
3317
3333
  let VT_SSR_TRY_SEQ = 0;
3318
3334
  let VT_SSR_HAS_CANDIDATES = false;
@@ -3495,11 +3511,7 @@ function vtSsrAnnotateScope(html) {
3495
3511
  true
3496
3512
  );
3497
3513
  const valid = roots === 1 && !sentinel && !text;
3498
- if (valid)
3499
- injectStyle(
3500
- "octane-view-transition-scope",
3501
- '[vt-scope="element"]{view-transition-scope:all!important}'
3502
- );
3514
+ if (valid) injectStyle(import_css.VIEW_TRANSITION_SCOPE_STYLE_ID, import_css.VIEW_TRANSITION_SCOPE_CSS);
3503
3515
  return vtSsrMapTags(
3504
3516
  html,
3505
3517
  (open) => vtSsrInject(open, [["vt-scope", valid ? "element" : "none"]]),
@@ -3691,12 +3703,11 @@ const ErrorBoundary = /* @__PURE__ */ (0, import_component_flags.markComponentFl
3691
3703
  import_component_flags.COMPONENT_FLAG_BOUNDARY,
3692
3704
  "ErrorBoundary"
3693
3705
  );
3694
- const CONTEXT_TAG = /* @__PURE__ */ Symbol.for("octane.context");
3695
3706
  function createContext(defaultValue) {
3696
3707
  const ctx = function ProviderBody(props, scope) {
3697
3708
  return ssrHtml(renderServerContextProvider(ctx, props, scope));
3698
3709
  };
3699
- ctx.$$kind = CONTEXT_TAG;
3710
+ ctx.$$kind = import_runtime_tags.CONTEXT_TAG;
3700
3711
  ctx.defaultValue = defaultValue;
3701
3712
  (0, import_context_identity.registerContext)(ctx);
3702
3713
  if (process.env.NODE_ENV !== "production") {
@@ -3731,7 +3742,7 @@ function readContext(ctx) {
3731
3742
  return ctx.defaultValue;
3732
3743
  }
3733
3744
  function useContext(ctx) {
3734
- if (ctx && ctx.$$kind === CONTEXT_TAG) return readContext(ctx);
3745
+ if (ctx && ctx.$$kind === import_runtime_tags.CONTEXT_TAG) return readContext(ctx);
3735
3746
  return readHostedForeignContext(ctx, "useContext");
3736
3747
  }
3737
3748
  const SSR_SUSPENSE = /* @__PURE__ */ Symbol("octane.ssr.suspense");
@@ -3923,7 +3934,7 @@ function use(usable, siteKey, directSite) {
3923
3934
  "Do not call use() inside a useMemo() factory. Cached factories can skip context or promise reads; call use() before useMemo() and memoize the returned value instead."
3924
3935
  );
3925
3936
  }
3926
- if (usable && usable.$$kind === CONTEXT_TAG) {
3937
+ if (usable && usable.$$kind === import_runtime_tags.CONTEXT_TAG) {
3927
3938
  recordSkippedHydrationSite(SERIAL, directSite);
3928
3939
  return readContext(usable);
3929
3940
  }
@@ -4290,18 +4301,17 @@ function warmChild(comp, props) {
4290
4301
  }
4291
4302
  }
4292
4303
  let LAZY_ID = 0;
4293
- const LAZY_COMPONENT = /* @__PURE__ */ Symbol.for("octane.lazy");
4294
4304
  function resolveLazyModule(mod) {
4295
4305
  let comp = mod;
4296
4306
  if (mod != null) {
4297
4307
  const defaultExport = mod.default;
4298
4308
  if (defaultExport !== void 0) comp = defaultExport;
4299
4309
  }
4300
- if (typeof comp !== "function" || comp[LAZY_COMPONENT] === true) {
4310
+ if (typeof comp !== "function" || comp[import_runtime_tags.LAZY_COMPONENT_TAG] === true) {
4301
4311
  throw new Error(
4302
4312
  (0, import_error_codes_server_generated.formatServerError)(
4303
4313
  10,
4304
- comp?.[LAZY_COMPONENT] === true ? "lazy component" : typeof comp
4314
+ comp?.[import_runtime_tags.LAZY_COMPONENT_TAG] === true ? "lazy component" : typeof comp
4305
4315
  )
4306
4316
  );
4307
4317
  }
@@ -4367,7 +4377,7 @@ function lazy(load) {
4367
4377
  }
4368
4378
  throw SSR_SUSPENSE;
4369
4379
  };
4370
- Object.defineProperty(lazyWrapper, LAZY_COMPONENT, {
4380
+ Object.defineProperty(lazyWrapper, import_runtime_tags.LAZY_COMPONENT_TAG, {
4371
4381
  get() {
4372
4382
  return this === lazyWrapper;
4373
4383
  }
@@ -4539,7 +4549,7 @@ function useDebugValue(_value, _format) {
4539
4549
  function requestFormReset(_form) {
4540
4550
  }
4541
4551
  function useId() {
4542
- return ":" + ID_PREFIX + "in-" + (ID_COUNTER++).toString(36) + ":";
4552
+ return (0, import_hydration_markers.formatUseId)(ID_PREFIX, ID_COUNTER++);
4543
4553
  }
4544
4554
  function throwOnServerEffectEventCall() {
4545
4555
  throw new Error((0, import_error_codes_server_generated.formatServerError)(11));
@@ -4675,10 +4685,9 @@ function startTransition(fn) {
4675
4685
  function flushSync(fn) {
4676
4686
  return fn();
4677
4687
  }
4678
- const CHILDREN_BLOCK = /* @__PURE__ */ Symbol.for("octane.childrenBlock");
4679
4688
  function markChildrenBlock(fn) {
4680
4689
  if (typeof fn === "function") {
4681
- fn[CHILDREN_BLOCK] = true;
4690
+ fn[import_runtime_tags.CHILDREN_BLOCK_TAG] = true;
4682
4691
  }
4683
4692
  return fn;
4684
4693
  }
@@ -4686,7 +4695,7 @@ function descriptorChildren(component) {
4686
4695
  return component;
4687
4696
  }
4688
4697
  function isChildrenBlock(value) {
4689
- return typeof value === "function" && value[CHILDREN_BLOCK] === true;
4698
+ return typeof value === "function" && value[import_runtime_tags.CHILDREN_BLOCK_TAG] === true;
4690
4699
  }
4691
4700
  function injectStyle(id, css, nonce) {
4692
4701
  if (CSS !== null) {
@@ -5050,7 +5059,7 @@ function runFullFramedPass(component, props, resolved, nonceAttr = "", identifie
5050
5059
  SIGNAL_COMPONENT_INSTANCE_KEY = JSON.stringify([identifierPrefix, "root"]);
5051
5060
  SERVER_SIGNAL_OWNER_ACTIVE = false;
5052
5061
  SIGNAL_CONTROL_SITE = "";
5053
- SIGNAL_LIST_KEYS = EMPTY_SIGNAL_LIST_KEYS;
5062
+ SIGNAL_LIST_KEYS = null;
5054
5063
  NONCE_ATTR = nonceAttr;
5055
5064
  ASYNC_SCOPE = "";
5056
5065
  MARKERS = markers;
@@ -5172,7 +5181,7 @@ function runDiscoveryRound(jobs, resolved, identifierPrefix) {
5172
5181
  SIGNAL_COMPONENT_INSTANCE_KEY = JSON.stringify([identifierPrefix, "root"]);
5173
5182
  SERVER_SIGNAL_OWNER_ACTIVE = false;
5174
5183
  SIGNAL_CONTROL_SITE = "";
5175
- SIGNAL_LIST_KEYS = EMPTY_SIGNAL_LIST_KEYS;
5184
+ SIGNAL_LIST_KEYS = null;
5176
5185
  NONCE_ATTR = "";
5177
5186
  ASYNC_SCOPE = "";
5178
5187
  MARKERS = true;
@@ -6523,7 +6532,19 @@ function boundaryErrorChunk(b, nonceAttr) {
6523
6532
  const serverOwnedStatic = b.serverOwnedStatic ? ",1" : "";
6524
6533
  return "<script " + import_constants.STREAM_SCRIPT_ATTR + nonceAttr + ">$OCTRX(" + JSON.stringify(b.id).replace(/</g, "\\u003c") + serverOwnedStatic + ")</script>";
6525
6534
  }
6526
- async function runStream(component, props, options, sink, resolved) {
6535
+ function createInjectionCanceler(injection) {
6536
+ if (injection === void 0) return NOOP;
6537
+ let cancelled = false;
6538
+ return (error) => {
6539
+ if (cancelled) return;
6540
+ cancelled = true;
6541
+ try {
6542
+ injection.cancel?.(error);
6543
+ } catch {
6544
+ }
6545
+ };
6546
+ }
6547
+ async function runStream(component, props, options, sink, resolved, cancelInjection) {
6527
6548
  const timeoutMs = options?.timeoutMs ?? SUSPENSE_TIMEOUT_MS;
6528
6549
  const signal = options?.signal;
6529
6550
  const nonceAttr = nonceAttrOf(options);
@@ -6605,7 +6626,15 @@ async function runStream(component, props, options, sink, resolved) {
6605
6626
  injection.accepted?.();
6606
6627
  });
6607
6628
  };
6608
- const recoveryInjection = injection === void 0 ? void 0 : async () => {
6629
+ const recoveryInjection = injection === void 0 ? void 0 : async (error) => {
6630
+ let queued = "";
6631
+ if (!injectionFailed) {
6632
+ try {
6633
+ queued = injection.take();
6634
+ } catch {
6635
+ }
6636
+ }
6637
+ cancelInjection(error);
6609
6638
  if (signal?.aborted) {
6610
6639
  await writeChain;
6611
6640
  for (const html of unacceptedInjection) {
@@ -6614,13 +6643,6 @@ async function runStream(component, props, options, sink, resolved) {
6614
6643
  }
6615
6644
  unacceptedInjection.length = 0;
6616
6645
  }
6617
- if (injectionFailed) return "";
6618
- let queued;
6619
- try {
6620
- queued = injection.take();
6621
- } catch {
6622
- return "";
6623
- }
6624
6646
  if (queued !== "" && signal?.aborted) {
6625
6647
  const replay = write(queued, "recovery");
6626
6648
  if (replay !== void 0) await replay;
@@ -6936,7 +6958,7 @@ async function runStream(component, props, options, sink, resolved) {
6936
6958
  let tail = "";
6937
6959
  if (recoveryInjection !== void 0) {
6938
6960
  try {
6939
- tail = await recoveryInjection();
6961
+ tail = await recoveryInjection(err);
6940
6962
  } catch {
6941
6963
  }
6942
6964
  }
@@ -6980,7 +7002,7 @@ async function runStream(component, props, options, sink, resolved) {
6980
7002
  injectionUnsubscribe = void 0;
6981
7003
  let terminal = "";
6982
7004
  try {
6983
- terminal = await recoveryInjection();
7005
+ terminal = await recoveryInjection(err);
6984
7006
  } catch {
6985
7007
  }
6986
7008
  terminal += heldDocumentTail;
@@ -7148,6 +7170,7 @@ function renderToPipeableStream(entryComponent, props, options) {
7148
7170
  const beginRender = (preparedOptions) => {
7149
7171
  const renderOptions = { ...preparedOptions, signal: controller.signal };
7150
7172
  const resolved = newResolvedMap(renderOptions);
7173
+ const cancelInjection = createInjectionCanceler(renderOptions.injection);
7151
7174
  void runStream(
7152
7175
  component,
7153
7176
  props,
@@ -7160,6 +7183,7 @@ function renderToPipeableStream(entryComponent, props, options) {
7160
7183
  options?.onShellReady?.();
7161
7184
  },
7162
7185
  shellError(err) {
7186
+ cancelInjection(err);
7163
7187
  releaseServerRenderResources(resolved);
7164
7188
  shellFailure = { error: err };
7165
7189
  options?.onShellError?.(err);
@@ -7170,14 +7194,17 @@ function renderToPipeableStream(entryComponent, props, options) {
7170
7194
  options?.onAllReady?.();
7171
7195
  flushEnd();
7172
7196
  },
7173
- fatal() {
7197
+ fatal(err) {
7198
+ cancelInjection(err);
7174
7199
  releaseServerRenderResources(resolved);
7175
7200
  options?.onAllReady?.();
7176
7201
  flushEnd();
7177
7202
  }
7178
7203
  },
7179
- resolved
7204
+ resolved,
7205
+ cancelInjection
7180
7206
  ).catch((err) => {
7207
+ cancelInjection(err);
7181
7208
  releaseServerRenderResources(resolved);
7182
7209
  options?.onError?.(err);
7183
7210
  flushEnd();
@@ -7361,6 +7388,7 @@ function renderToReadableStream(entryComponent, props, options) {
7361
7388
  };
7362
7389
  }
7363
7390
  const resolved = newResolvedMap(renderOptions);
7391
+ const cancelInjection = createInjectionCanceler(renderOptions.injection);
7364
7392
  const release = () => {
7365
7393
  if (released) return;
7366
7394
  released = true;
@@ -7369,6 +7397,7 @@ function renderToReadableStream(entryComponent, props, options) {
7369
7397
  const settleFailure = (error) => {
7370
7398
  if (terminal) return;
7371
7399
  terminal = true;
7400
+ cancelInjection(error);
7372
7401
  try {
7373
7402
  release();
7374
7403
  } catch (err) {
@@ -7421,7 +7450,8 @@ function renderToReadableStream(entryComponent, props, options) {
7421
7450
  settleFailure(err);
7422
7451
  }
7423
7452
  },
7424
- resolved
7453
+ resolved,
7454
+ cancelInjection
7425
7455
  ).catch((err) => {
7426
7456
  renderOptions.onError?.(err);
7427
7457
  settleFailure(err);