octane 0.4.2 → 0.4.3

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 (57) hide show
  1. package/dist/cjs/context-identity.cjs +29 -0
  2. package/dist/cjs/dom-stage.cjs +24 -18
  3. package/dist/cjs/error-codes.server.generated.cjs +5 -0
  4. package/dist/cjs/hydration-markers.cjs +12 -0
  5. package/dist/cjs/index.cjs +2 -0
  6. package/dist/cjs/runtime.cjs +253 -393
  7. package/dist/cjs/runtime.server.cjs +137 -35
  8. package/dist/cjs/server/index.cjs +2 -0
  9. package/dist/cjs/server/streamed-signals.cjs +41 -9
  10. package/dist/cjs/signals/client.cjs +1 -6
  11. package/dist/cjs/signals/engine.cjs +1 -12
  12. package/dist/cjs/version.cjs +1 -1
  13. package/dist/compiler/client-only-server.js +1 -28
  14. package/dist/compiler/compile-renderer-boundaries.js +1 -22
  15. package/dist/compiler/compile-universal.js +1 -22
  16. package/dist/compiler/compile.js +782 -359
  17. package/dist/compiler/dom-binding-fixed-props.js +11 -1
  18. package/dist/compiler/generated-origin.js +46 -0
  19. package/dist/compiler/hydrate-boundaries.js +88 -52
  20. package/dist/compiler/plain-hook-memo.js +5 -1
  21. package/dist/compiler/pure-factories.js +66 -0
  22. package/dist/compiler/register.js +4 -1
  23. package/dist/compiler/slot-hooks.js +113 -186
  24. package/dist/compiler/typescript-lowering.js +763 -0
  25. package/dist/compiler/void-roots.js +239 -0
  26. package/dist/compiler/volar.js +91 -38
  27. package/dist/context-identity.d.ts +14 -0
  28. package/dist/context-identity.js +28 -0
  29. package/dist/dom-stage.js +24 -18
  30. package/dist/error-codes.server.generated.d.ts +1 -0
  31. package/dist/error-codes.server.generated.js +5 -0
  32. package/dist/hydration/idle.js +1 -0
  33. package/dist/hydration/independent-island.js +53 -2
  34. package/dist/hydration/media.js +1 -0
  35. package/dist/hydration/types.d.ts +5 -0
  36. package/dist/hydration/visible.js +1 -0
  37. package/dist/hydration-markers.d.ts +8 -0
  38. package/dist/hydration-markers.js +8 -0
  39. package/dist/index.d.ts +1 -1
  40. package/dist/index.js +2 -0
  41. package/dist/runtime.d.ts +25 -40
  42. package/dist/runtime.js +254 -398
  43. package/dist/runtime.server.d.ts +23 -2
  44. package/dist/runtime.server.js +142 -36
  45. package/dist/server/index.d.ts +1 -1
  46. package/dist/server/index.js +2 -0
  47. package/dist/server/streamed-signals.js +41 -9
  48. package/dist/signals/client.js +3 -8
  49. package/dist/signals/engine.d.ts +0 -2
  50. package/dist/signals/engine.js +1 -13
  51. package/dist/universal-core.js +1 -1
  52. package/dist/version.js +1 -1
  53. package/package.json +1 -1
  54. package/dist/cjs/signals/diagnostic-local-hook.cjs +0 -37
  55. package/dist/compiler/local-void-roots.js +0 -154
  56. package/dist/signals/diagnostic-local-hook.d.ts +0 -8
  57. package/dist/signals/diagnostic-local-hook.js +0 -12
@@ -51,7 +51,9 @@ interface ServerSignalListKeys {
51
51
  parent: ServerSignalListKeys | null;
52
52
  key: unknown;
53
53
  mapped: boolean;
54
- values: readonly string[] | null;
54
+ signalSite: string | undefined;
55
+ position: number;
56
+ values: readonly ServerSignalIdentityToken[] | null;
55
57
  }
56
58
  interface InjectedStyle {
57
59
  css: string;
@@ -149,6 +151,15 @@ export declare function escapeHtml(v: unknown): string;
149
151
  export declare function escapeAttr(v: unknown): string;
150
152
  /** A dynamic text hole. null/false/undefined render as empty (React parity). */
151
153
  export declare function ssrText(v: unknown): string;
154
+ /**
155
+ * A dynamic text hole that shares its parent with sibling nodes. The client
156
+ * reserves one `<!>` position for it and walks later siblings from there, so
157
+ * an empty value must still occupy one server node: the HTML parser produces
158
+ * no Text node for '', which would shift every later sibling onto the wrong
159
+ * server node. The empty anchor comment stands in and hydration swaps it for
160
+ * the hole's empty Text node. Non-empty values pay nothing.
161
+ */
162
+ export declare function ssrTextSlot(text: string): string;
152
163
  /**
153
164
  * A dynamic text hole in FIRST-CHILD position of a newline-eating element
154
165
  * (`<pre>`/`<textarea>`/`<listing>`): the HTML parser discards a newline that
@@ -219,7 +230,7 @@ export declare function ssrControl<T>(siteKey: string, fn: () => T): T;
219
230
  /** Compiler-emitted identity membrane for one arm/item inside ssrControl. */
220
231
  export declare function ssrArm<T>(armKey: unknown, fn: () => T): T;
221
232
  /** Invoke a compiled list body without allocating a callback per item. */
222
- export declare function ssrForItem(armKey: unknown, fn: (...args: any[]) => string, item: unknown, index: number | undefined, scope: SSRScope, block: boolean, mapped?: boolean): string;
233
+ export declare function ssrForItem(armKey: unknown, fn: (...args: any[]) => string, item: unknown, index: number | undefined, scope: SSRScope, block: boolean, mapped?: boolean, signalSite?: string): string;
223
234
  /**
224
235
  * A portal's site marker. The portal body renders into a foreign target at the
225
236
  * client, so server-side it leaves a single anchor comment placeholder.
@@ -354,6 +365,15 @@ type ServerHookSlot = symbol | string | number;
354
365
  export declare function hookSlots(count: number): number;
355
366
  /** @internal Server local hooks live only for this synchronous rendering pass. */
356
367
  export declare function nativeLocalHook<T>(name: string, initialize: () => T, dispose: (value: T) => void, slot?: ServerHookSlot): T;
368
+ type ServerSignalIdentityToken = string | {
369
+ value: object | symbol;
370
+ position?: number;
371
+ };
372
+ interface ServerOpaqueSignalKeys {
373
+ ids: Map<string, number>;
374
+ used: Set<number>;
375
+ next: number;
376
+ }
357
377
  /**
358
378
  * Render a child component into the string: fresh scope + frame, body → HTML.
359
379
  * `inherit` (M3): the compiled call site is the sole root of its parent's
@@ -747,6 +767,7 @@ type ResolvedMap = Map<string, SuspenseOutcome> & {
747
767
  signalOwner?: SignalOwner;
748
768
  ownedSignalOwner?: boolean;
749
769
  signalInstances?: Map<string, SignalRendererOwnerIdentity>;
770
+ signalIdentityKeys?: Map<string, ServerOpaqueSignalKeys>;
750
771
  hasSignalControls?: boolean;
751
772
  /** Render-local stable ids for non-primitive and long string control/list keys. */
752
773
  asyncIdentities: Map<unknown, number>;
@@ -77,6 +77,12 @@ import {
77
77
  invalidHostPropertiesWarning,
78
78
  unsupportedAttributeCoercionWarning
79
79
  } from "./host-property-diagnostics.js";
80
+ import {
81
+ HYDRATE_IDLE_TIMEOUT_ATTR,
82
+ HYDRATE_MEDIA_ATTR,
83
+ HYDRATE_VISIBLE_MARGIN_ATTR,
84
+ HYDRATE_VISIBLE_THRESHOLD_ATTR
85
+ } from "./hydration-markers.js";
80
86
  import { streamedSignalBootstrapJs } from "./server/early-signals.js";
81
87
  import {
82
88
  applyElementDefaultProps,
@@ -108,7 +114,7 @@ import {
108
114
  import { formatServerError } from "./error-codes.server.generated.js";
109
115
  import { formAuthoringDiagnostics } from "./form-diagnostics.js";
110
116
  import { isRendererContext, registerServerRendererContextProvider } from "./renderer-bridge.js";
111
- import { registerContext } from "./context-identity.js";
117
+ import { defineRemovedContextMembers, registerContext } from "./context-identity.js";
112
118
  import {
113
119
  validateNativeReadWitness
114
120
  } from "./signals/native-read-collector.js";
@@ -1250,6 +1256,9 @@ function ssrText(v) {
1250
1256
  if (v == null || v === false) return "";
1251
1257
  return escapeHtml(v);
1252
1258
  }
1259
+ function ssrTextSlot(text) {
1260
+ return text === "" ? EMPTY_COMMENT : text;
1261
+ }
1253
1262
  function ssrTextPre(v) {
1254
1263
  const s = ssrText(v);
1255
1264
  return s.charCodeAt(0) === 10 ? "\n" + s : s;
@@ -1657,13 +1666,20 @@ function ssrControl(siteKey, fn) {
1657
1666
  SIGNAL_CONTROL_SITE = previousSignalControl;
1658
1667
  }
1659
1668
  }
1660
- function enterAsyncArm(armKey, mapped = false) {
1669
+ function enterAsyncArm(armKey, mapped = false, signalSite) {
1661
1670
  const previous = ASYNC_SCOPE;
1662
1671
  const frame = FRAME;
1663
1672
  const occurrence = frame === null ? 0 : nextFrameOccurrence(frame, "@arm-position:");
1664
1673
  const fallbackPosition = armKey !== null && (typeof armKey === "object" || typeof armKey === "function" || typeof armKey === "symbol") ? previous + "|@arm-position:" + occurrence : void 0;
1665
1674
  if (SERVER_SIGNAL_BINDINGS_POTENTIAL && SIGNAL_CONTROL_SITE.charCodeAt(0) === 102) {
1666
- SIGNAL_LIST_KEYS = { parent: SIGNAL_LIST_KEYS, key: armKey, mapped, values: null };
1675
+ SIGNAL_LIST_KEYS = {
1676
+ parent: SIGNAL_LIST_KEYS,
1677
+ key: armKey,
1678
+ mapped,
1679
+ signalSite,
1680
+ position: occurrence,
1681
+ values: null
1682
+ };
1667
1683
  }
1668
1684
  ASYNC_SCOPE = previous + "|@arm:" + asyncIdentityKey(armKey, false, fallbackPosition);
1669
1685
  }
@@ -1678,18 +1694,47 @@ function ssrArm(armKey, fn) {
1678
1694
  SIGNAL_LIST_KEYS = previousSignalKeys;
1679
1695
  }
1680
1696
  }
1681
- function ssrForItem(armKey, fn, item, index, scope, block, mapped = false) {
1697
+ function ssrForItem(armKey, fn, item, index, scope, block, mapped = false, signalSite) {
1682
1698
  const previous = ASYNC_SCOPE;
1683
1699
  const previousSignalKeys = SIGNAL_LIST_KEYS;
1700
+ const previousSignalOwnerActive = SERVER_SIGNAL_OWNER_ACTIVE;
1701
+ let previousOwner;
1684
1702
  try {
1685
- enterAsyncArm(armKey, mapped);
1686
- const html = index === void 0 ? fn(item, scope) : fn(item, index, scope);
1703
+ enterAsyncArm(armKey, mapped, signalSite);
1704
+ const owner = signalSite !== void 0 && RESOLVED !== null && (SERVER_SIGNAL_BINDINGS_ENABLED || RESOLVED.signalOwner !== void 0) ? serverSignalOwner(FRAME, serverStructuralSignalInstanceKey(signalSite, void 0)) : void 0;
1705
+ let html;
1706
+ if (owner === void 0) {
1707
+ html = index === void 0 ? fn(item, scope) : fn(item, index, scope);
1708
+ } else {
1709
+ SERVER_SIGNAL_OWNER_ACTIVE = true;
1710
+ const injection = RESOLVED?.resourceOptions?.injection;
1711
+ if (injection?.observeSignalAttempt !== void 0 || (previousOwner = enterSynchronousSignalOwner(owner)) === void 0) {
1712
+ html = invokeServerSignalForItem(owner, fn, item, index, scope);
1713
+ } else {
1714
+ html = index === void 0 ? fn(item, scope) : fn(item, index, scope);
1715
+ }
1716
+ }
1687
1717
  return block ? ssrBlock(html) : html;
1688
1718
  } finally {
1719
+ if (previousOwner !== void 0) restoreSynchronousSignalOwner(previousOwner);
1720
+ SERVER_SIGNAL_OWNER_ACTIVE = previousSignalOwnerActive;
1689
1721
  ASYNC_SCOPE = previous;
1690
1722
  SIGNAL_LIST_KEYS = previousSignalKeys;
1691
1723
  }
1692
1724
  }
1725
+ function invokeServerSignalForItem(owner, fn, item, index, scope) {
1726
+ const invoke = () => index === void 0 ? fn(item, scope) : fn(item, index, scope);
1727
+ const injection = RESOLVED?.resourceOptions?.injection;
1728
+ return runWithSignalOwner(
1729
+ owner,
1730
+ () => injection?.observeSignalAttempt === void 0 ? invoke() : runWithServerSignalQueryAttemptObserver(
1731
+ owner,
1732
+ (attempt) => injection.observeSignalAttempt(attempt, captureSignalOwner(owner)),
1733
+ injection.createSignalAttemptObservations,
1734
+ invoke
1735
+ )
1736
+ );
1737
+ }
1693
1738
  function ssrPortal() {
1694
1739
  return EMPTY_COMMENT;
1695
1740
  }
@@ -2724,18 +2769,60 @@ function replayUpdatedComponentBody(comp, props, scope, frame, hp, snapshot, war
2724
2769
  } while (hp.update);
2725
2770
  return out;
2726
2771
  }
2727
- function signalIdentityKey(value) {
2772
+ function signalIdentityToken(value, position) {
2728
2773
  if (value === null) return "null";
2729
2774
  const kind = typeof value;
2730
- return kind === "string" || kind === "number" || kind === "bigint" || kind === "boolean" ? kind.charCodeAt(0).toString(36) + ":" + String(value) : kind === "undefined" ? "u:" : "o:" + String(value);
2775
+ return kind === "string" || kind === "number" || kind === "bigint" || kind === "boolean" ? kind.charCodeAt(0).toString(36) + ":" + String(value) : kind === "undefined" ? "u:" : { value, position };
2731
2776
  }
2732
- function serverStructuralSignalInstanceKey(invocationSite, key) {
2733
- return resolveServerSignalInstanceKey(SIGNAL_COMPONENT_INSTANCE_KEY) + JSON.stringify([
2777
+ function signalIdentityKey(token, base, site, parents, componentKey) {
2778
+ if (typeof token === "string") return token;
2779
+ const resolved = RESOLVED;
2780
+ const namespace = base + JSON.stringify([site ?? "legacy", parents, componentKey]);
2781
+ const namespaces = resolved.signalIdentityKeys ??= /* @__PURE__ */ new Map();
2782
+ let keys = namespaces.get(namespace);
2783
+ if (keys === void 0) {
2784
+ keys = { ids: /* @__PURE__ */ new Map(), used: /* @__PURE__ */ new Set(), next: 0 };
2785
+ namespaces.set(namespace, keys);
2786
+ }
2787
+ const value = asyncIdentityKey(token.value, false);
2788
+ let id = keys.ids.get(value);
2789
+ if (id === void 0) {
2790
+ id = token.position;
2791
+ if (id === void 0 || keys.used.has(id)) {
2792
+ while (keys.used.has(keys.next)) keys.next++;
2793
+ id = keys.next++;
2794
+ }
2795
+ keys.used.add(id);
2796
+ keys.ids.set(value, id);
2797
+ }
2798
+ return "o:" + id.toString(36);
2799
+ }
2800
+ function serverSignalSegmentKey(base, invocationSite, listKeys, key) {
2801
+ const tokens = resolveServerSignalListKeys(listKeys);
2802
+ let itemKeys = tokens;
2803
+ for (const token of tokens) {
2804
+ if (typeof token === "string") continue;
2805
+ const values = [];
2806
+ for (const entry of tokens) {
2807
+ values.push(signalIdentityKey(entry, base, invocationSite, values, false));
2808
+ }
2809
+ itemKeys = values;
2810
+ break;
2811
+ }
2812
+ return base + JSON.stringify([
2734
2813
  invocationSite ?? "legacy",
2735
- resolveServerSignalListKeys(SIGNAL_LIST_KEYS),
2736
- key != null ? signalIdentityKey(key) : ""
2814
+ itemKeys,
2815
+ key != null ? signalIdentityKey(signalIdentityToken(key), base, invocationSite, itemKeys, true) : ""
2737
2816
  ]);
2738
2817
  }
2818
+ function serverStructuralSignalInstanceKey(invocationSite, key) {
2819
+ return serverSignalSegmentKey(
2820
+ resolveServerSignalInstanceKey(SIGNAL_COMPONENT_INSTANCE_KEY),
2821
+ invocationSite,
2822
+ SIGNAL_LIST_KEYS,
2823
+ key
2824
+ );
2825
+ }
2739
2826
  function resolveServerSignalListKeys(keys) {
2740
2827
  if (keys === null) return EMPTY_SIGNAL_LIST_KEYS;
2741
2828
  if (keys.values !== null) return keys.values;
@@ -2748,7 +2835,10 @@ function resolveServerSignalListKeys(keys) {
2748
2835
  let values = parent?.values ?? EMPTY_SIGNAL_LIST_KEYS;
2749
2836
  for (let index = pending.length - 1; index >= 0; index--) {
2750
2837
  const entry = pending[index];
2751
- values = [...values, signalIdentityKey(entry.mapped ? "k" + String(entry.key) : entry.key)];
2838
+ values = [
2839
+ ...values,
2840
+ signalIdentityToken(entry.mapped ? "k" + String(entry.key) : entry.key, entry.position)
2841
+ ];
2752
2842
  entry.values = values;
2753
2843
  }
2754
2844
  return values;
@@ -2767,23 +2857,27 @@ function resolveServerSignalInstanceKey(identity) {
2767
2857
  }
2768
2858
  for (let index = pending.length - 1; index >= 0; index--) {
2769
2859
  const frame = pending[index];
2770
- identity += JSON.stringify([
2771
- frame.signalInvocationSite ?? "legacy",
2772
- resolveServerSignalListKeys(frame.signalListKeys ?? null),
2773
- frame.signalKey != null ? signalIdentityKey(frame.signalKey) : ""
2774
- ]);
2860
+ identity = serverSignalSegmentKey(
2861
+ identity,
2862
+ frame.signalInvocationSite,
2863
+ frame.signalListKeys ?? null,
2864
+ frame.signalKey
2865
+ );
2775
2866
  frame.signalInstanceKey = identity;
2776
2867
  }
2777
2868
  return identity;
2778
2869
  }
2779
- function serverSignalOwner(_frame) {
2870
+ function serverSignalOwner(_frame, rowInstanceKey) {
2780
2871
  const resolved = RESOLVED;
2781
2872
  if (resolved !== null && SERVER_SIGNAL_BINDINGS_ENABLED && resolved.signalOwner === void 0) {
2782
2873
  ensureServerSignalOwner();
2783
2874
  }
2784
2875
  if (resolved === null || resolved.signalOwner === void 0 || resolved.signalInstances === void 0)
2785
2876
  return;
2786
- const instanceKey = resolveServerSignalInstanceKey(SIGNAL_COMPONENT_INSTANCE_KEY) || JSON.stringify([SIGNAL_INSTANCE_PREFIX, "root"]);
2877
+ if (rowInstanceKey === void 0 && SIGNAL_LIST_KEYS?.signalSite !== void 0) {
2878
+ rowInstanceKey = serverStructuralSignalInstanceKey(SIGNAL_LIST_KEYS.signalSite, void 0);
2879
+ }
2880
+ const instanceKey = (rowInstanceKey ?? resolveServerSignalInstanceKey(SIGNAL_COMPONENT_INSTANCE_KEY)) || JSON.stringify([SIGNAL_INSTANCE_PREFIX, "root"]);
2787
2881
  let owner = resolved.signalInstances.get(instanceKey);
2788
2882
  if (owner === void 0) {
2789
2883
  owner = Object.freeze({
@@ -2940,7 +3034,7 @@ function renderComponentFramed(comp, props, parent, frame, inherit, instanceKey,
2940
3034
  function ssrComponent(parent, comp, props, inherit, key, identityScoped, invocationSite, bindingMarker) {
2941
3035
  const activity = comp === Activity;
2942
3036
  if (activity && key === void 0) key = props?.key;
2943
- let signalInstanceKey = SERVER_SIGNAL_BINDINGS_ENABLED ? serverStructuralSignalInstanceKey(invocationSite, key) : void 0;
3037
+ let signalInstanceKey = SERVER_SIGNAL_BINDINGS_ENABLED && RESOLVED !== null ? serverStructuralSignalInstanceKey(invocationSite, key) : void 0;
2944
3038
  const previousIdentityScope = ASYNC_SCOPE;
2945
3039
  if (identityScoped !== true) {
2946
3040
  ASYNC_SCOPE = previousIdentityScope + "|@component-type:" + asyncIdentityKey(comp, false);
@@ -3059,6 +3153,10 @@ function streamTokenForPendingHtml(html) {
3059
3153
  function ssrIndependentHydrateSidecar(props, instanceId) {
3060
3154
  const independent = props.__independent;
3061
3155
  if (independent === void 0) return "";
3156
+ const when = typeof props.when === "function" ? "dynamic" : props.when?._t;
3157
+ if (when === "dynamic" || when === "condition") {
3158
+ throw new Error(formatServerError(80, when));
3159
+ }
3062
3160
  const registry = RESOLVED?.resourceOptions?.independentHydration;
3063
3161
  if (registry === void 0) {
3064
3162
  throw new Error(formatServerError(69));
@@ -3100,7 +3198,23 @@ function withServerIndependentIdentity(prefix, idSeed, render) {
3100
3198
  ID_COUNTER = previousIdCounter + ID_COUNTER - idSeed;
3101
3199
  }
3102
3200
  }
3103
- function ssrHydrateAttrs(id, when, idCount, permanentStaticAncestor = false, streamToken = null) {
3201
+ function ssrIndependentStrategyAttrs(strategy) {
3202
+ const params = strategy._p;
3203
+ if (strategy._t === "media") return ssrAttr(HYDRATE_MEDIA_ATTR, params, "div");
3204
+ if (params === null || typeof params !== "object") return "";
3205
+ if (strategy._t === "idle") {
3206
+ const { timeout } = params;
3207
+ return timeout === void 0 ? "" : ssrAttr(HYDRATE_IDLE_TIMEOUT_ATTR, timeout, "div");
3208
+ }
3209
+ if (strategy._t !== "visible") return "";
3210
+ const { rootMargin, threshold } = params;
3211
+ return (rootMargin === void 0 ? "" : ssrAttr(HYDRATE_VISIBLE_MARGIN_ATTR, rootMargin, "div")) + (threshold === void 0 ? "" : ssrAttr(
3212
+ HYDRATE_VISIBLE_THRESHOLD_ATTR,
3213
+ Array.isArray(threshold) ? threshold.join(",") : threshold,
3214
+ "div"
3215
+ ));
3216
+ }
3217
+ function ssrHydrateAttrs(id, when, idCount, permanentStaticAncestor = false, streamToken = null, independent = false) {
3104
3218
  const direct = typeof when !== "function" && when !== null ? when : null;
3105
3219
  let attrs = ssrAttr(HYDRATE_ID_ATTR, id, "div") + ssrAttr(
3106
3220
  HYDRATE_WHEN_ATTR,
@@ -3109,6 +3223,7 @@ function ssrHydrateAttrs(id, when, idCount, permanentStaticAncestor = false, str
3109
3223
  ) + ssrAttr(HYDRATE_ID_COUNT_ATTR, idCount, "div");
3110
3224
  if (streamToken !== null) attrs += ssrAttr(HYDRATE_STREAM_TOKEN_ATTR, streamToken, "div");
3111
3225
  if (permanentStaticAncestor) return attrs;
3226
+ if (independent && direct !== null) attrs += ssrIndependentStrategyAttrs(direct);
3112
3227
  const strategyAttrs = direct?._a?.();
3113
3228
  if (strategyAttrs === void 0) return attrs;
3114
3229
  for (const name of Object.keys(strategyAttrs)) {
@@ -3202,7 +3317,8 @@ const hydrate = /* @__PURE__ */ markComponentFlags(
3202
3317
  props.when,
3203
3318
  idCount,
3204
3319
  permanentStaticAncestor,
3205
- streamTokenForPendingHtml(children)
3320
+ streamTokenForPendingHtml(children),
3321
+ props.__independent !== void 0
3206
3322
  );
3207
3323
  const seedJson = permanentStaticAncestor || childSeeds.length === 0 ? null : serializeSuspenseSeedJson(childSeeds);
3208
3324
  const seedSidecar = seedJson === null || seedJson === "[]" ? "" : '<script type="application/json" ' + HYDRATE_SEED_ATTR + NONCE_ATTR + ">" + seedJson + "</script>";
@@ -3623,19 +3739,7 @@ function createContext(defaultValue) {
3623
3739
  ctx.defaultValue = defaultValue;
3624
3740
  registerContext(ctx);
3625
3741
  if (process.env.NODE_ENV !== "production") {
3626
- let consumerWarned = false;
3627
- Object.defineProperty(ctx, "Consumer", {
3628
- configurable: true,
3629
- get() {
3630
- if (!consumerWarned) {
3631
- consumerWarned = true;
3632
- console.error(
3633
- "Octane has no Context.Consumer. Read the context directly with use(Context) or useContext(Context) in the child component \u2014 Octane hooks are call-site keyed, so the read is legal behind any condition the render-prop form was working around."
3634
- );
3635
- }
3636
- return void 0;
3637
- }
3638
- });
3742
+ defineRemovedContextMembers(ctx);
3639
3743
  }
3640
3744
  return ctx;
3641
3745
  }
@@ -4836,6 +4940,7 @@ function releaseServerRenderResources(resolved) {
4836
4940
  for (const owner of resolved.signalInstances.values()) retireSignalOwnerIdentity(owner);
4837
4941
  resolved.signalInstances.clear();
4838
4942
  }
4943
+ resolved.signalIdentityKeys?.clear();
4839
4944
  if (resolved.ownedSignalOwner && resolved.signalOwner !== void 0) {
4840
4945
  retireSignalOwnerIdentity(resolved.signalOwner);
4841
4946
  }
@@ -7775,6 +7880,7 @@ export {
7775
7880
  ssrStylesheetResource,
7776
7881
  ssrText,
7777
7882
  ssrTextPre,
7883
+ ssrTextSlot,
7778
7884
  ssrTextareaValue,
7779
7885
  ssrTextareaValueSources,
7780
7886
  ssrTry,
@@ -35,4 +35,4 @@ export { version } from '../version.js';
35
35
  export { StrictMode, unstable_batchedUpdates } from '../compatibility.js';
36
36
  export { createSubSlot, subSlot, type SubSlot, type SlotlessSubSlot, type SubSlotOptions, } from '../sub-slot.js';
37
37
  export { __methodDep } from '../method-dep.js';
38
- export { renderToString, renderToStaticMarkup, renderToPipeableStream, renderToReadableStream, type RenderResult, type RenderOptions, type ServerRenderNode, type StreamOptions, type StreamInjectionSource, setSsrSuspenseTimeout, getSsrSuspenseTimeout, EXTERNAL_HYDRATION_PROMISE, HYDRATION_RANGE_BOUNDARY, useState, useLinkedState, useReducer, __useStateWithGetter, __useLinkedStateWithGetter, __useReducerWithGetter, type LinkedStatePrevious, type LinkedStateOptions, useEffect, useLayoutEffect, useInsertionEffect, useImperativeHandle, useMemo, useCallback, useRef, useId, useEffectEvent, useTransition, useDeferredValue, useSyncExternalStore, useActionState, useActionState as useFormState, useFormStatus, useOptimistic, useDebugValue, memo, lazy, hookSlots, withSlot, manualHook, invokeManualHook, startTransition, flushSync, isChildrenBlock, isValidElement, cloneElement, Children, createPortal, requestFormReset, preload, preinit, preloadModule, preinitModule, preconnect, prefetchDNS, Suspense, ErrorBoundary, Hydrate, Fragment, Activity, Activity as unstable_Activity, ViewTransition, ViewTransition as unstable_ViewTransition, addTransitionType, addTransitionType as unstable_addTransitionType, createContext, use, useContext, ssrIsSuspense, type Context, type FormStatus, markChildrenBlock, markWarm, ssrHtml, ssrChildTextPre, ssrChildPre, descriptorChildren, createElement, createScopedValue, createScopedElement, positionalChildren, escapeHtml, escapeAttr, ssrText, ssrTextPre, ssrNestingText, ssrChild, ssrChildText, ssrAttr, normalizeClass, ssrStyle, ssrClass, ssrAttrs, ssrSignalValue, ssrSignalControlValue, ssrSignalControlAttrs, ssrSnapshotSpread, enableServerSignalBindings, ssrSpread, ssrInnerHtml, ssrScriptInnerHtml, ssrChildrenSources, ssrSpreadContent, ssrVoidContent, ssrValueAttr, ssrCheckedAttr, ssrInputAttrs, ssrFormAuthoringDiagnostics, ssrTextareaValue, ssrTextareaValueSources, ssrSelectAttrs, ssrSelectScope, ssrSelectScopeSources, ssrOptionValueSources, ssrOption, ssrElement, ssrComponent, ssrComponentNS, ssrInNamespace, ssrBlock, ssrFragmentMarker, ssrActivity, ssrForBlock, mapSlot, ssrControl, ssrArm, ssrForItem, ssrTry, ssrPortal, injectStyle, ssrHeadEl, styleMap, touchStyleMap, ssrStylesheetResource, ssrStyleResource, ssrScriptResource, namespaceHead, namespaceHeadElement, puMemo, puBatch, warmMemo, warmChild, } from '../runtime.server.js';
38
+ export { renderToString, renderToStaticMarkup, renderToPipeableStream, renderToReadableStream, type RenderResult, type RenderOptions, type ServerRenderNode, type StreamOptions, type StreamInjectionSource, setSsrSuspenseTimeout, getSsrSuspenseTimeout, EXTERNAL_HYDRATION_PROMISE, HYDRATION_RANGE_BOUNDARY, useState, useLinkedState, useReducer, __useStateWithGetter, __useLinkedStateWithGetter, __useReducerWithGetter, type LinkedStatePrevious, type LinkedStateOptions, useEffect, useLayoutEffect, useInsertionEffect, useImperativeHandle, useMemo, useCallback, useRef, useId, useEffectEvent, useTransition, useDeferredValue, useSyncExternalStore, useActionState, useActionState as useFormState, useFormStatus, useOptimistic, useDebugValue, memo, lazy, hookSlots, withSlot, manualHook, invokeManualHook, startTransition, flushSync, isChildrenBlock, isValidElement, cloneElement, Children, createPortal, requestFormReset, preload, preinit, preloadModule, preinitModule, preconnect, prefetchDNS, Suspense, ErrorBoundary, Hydrate, Fragment, Activity, Activity as unstable_Activity, ViewTransition, ViewTransition as unstable_ViewTransition, addTransitionType, addTransitionType as unstable_addTransitionType, createContext, use, useContext, ssrIsSuspense, type Context, type FormStatus, markChildrenBlock, markWarm, ssrHtml, ssrChildTextPre, ssrChildPre, descriptorChildren, createElement, createScopedValue, createScopedElement, positionalChildren, escapeHtml, escapeAttr, ssrText, ssrTextPre, ssrTextSlot, ssrNestingText, ssrChild, ssrChildText, ssrAttr, normalizeClass, ssrStyle, ssrClass, ssrAttrs, ssrSignalValue, ssrSignalControlValue, ssrSignalControlAttrs, ssrSnapshotSpread, enableServerSignalBindings, ssrSpread, ssrInnerHtml, ssrScriptInnerHtml, ssrChildrenSources, ssrSpreadContent, ssrVoidContent, ssrValueAttr, ssrCheckedAttr, ssrInputAttrs, ssrFormAuthoringDiagnostics, ssrTextareaValue, ssrTextareaValueSources, ssrSelectAttrs, ssrSelectScope, ssrSelectScopeSources, ssrOptionValueSources, ssrOption, ssrElement, ssrComponent, ssrComponentNS, ssrInNamespace, ssrBlock, ssrFragmentMarker, ssrActivity, ssrForBlock, mapSlot, ssrControl, ssrArm, ssrForItem, ssrTry, ssrPortal, injectStyle, ssrHeadEl, styleMap, touchStyleMap, ssrStylesheetResource, ssrStyleResource, ssrScriptResource, namespaceHead, namespaceHeadElement, puMemo, puBatch, warmMemo, warmChild, } from '../runtime.server.js';
@@ -112,6 +112,7 @@ import {
112
112
  escapeAttr,
113
113
  ssrText,
114
114
  ssrTextPre,
115
+ ssrTextSlot,
115
116
  ssrNestingText,
116
117
  ssrChild,
117
118
  ssrChildText,
@@ -290,6 +291,7 @@ export {
290
291
  ssrStylesheetResource,
291
292
  ssrText,
292
293
  ssrTextPre,
294
+ ssrTextSlot,
293
295
  ssrTextareaValue,
294
296
  ssrTextareaValueSources,
295
297
  ssrTry,
@@ -26,23 +26,54 @@ function limits(options) {
26
26
  function isAsyncIterable(value) {
27
27
  return value !== null && (typeof value === "object" || typeof value === "function") && typeof value[Symbol.asyncIterator] === "function";
28
28
  }
29
- async function* createStreamedSignalResultFrames(identity, result, options = {}) {
29
+ const CANCELLED = /* @__PURE__ */ Symbol("octane.streamedSignalResultCancelled");
30
+ function createStreamedSignalResultFrames(identity, result, options = {}) {
31
+ let cancelled = false;
32
+ let reject;
33
+ const waits = {
34
+ wait(value) {
35
+ if (cancelled) return Promise.reject(CANCELLED);
36
+ return new Promise((resolve, fail) => {
37
+ reject = fail;
38
+ Promise.resolve(value).then(resolve, fail);
39
+ });
40
+ },
41
+ interrupt(reason) {
42
+ const fail = reject;
43
+ reject = void 0;
44
+ fail?.(reason);
45
+ }
46
+ };
47
+ const frames = produceStreamedSignalResultFrames(identity, result, options, waits);
48
+ const returnFrames = frames.return;
49
+ frames.return = (value) => {
50
+ cancelled = true;
51
+ waits.interrupt(CANCELLED);
52
+ return returnFrames.call(frames, value);
53
+ };
54
+ return frames;
55
+ }
56
+ async function* produceStreamedSignalResultFrames(identity, result, options, waits) {
30
57
  if (!isStreamFrameIdentity(identity)) throw new TypeError("Invalid streamed signal identity.");
31
58
  let sequence = 0;
32
59
  let resource = "promise";
33
60
  let iterator;
34
61
  const run = options.run ?? ((callback) => callback());
62
+ const signal = options.signal;
63
+ const abort = () => waits.interrupt(signal.reason);
64
+ signal?.addEventListener("abort", abort, { once: true });
35
65
  try {
36
- const resolved = await result;
37
- options.signal?.throwIfAborted();
66
+ signal?.throwIfAborted();
67
+ const resolved = await waits.wait(result);
68
+ signal?.throwIfAborted();
38
69
  if (isAsyncIterable(resolved)) {
39
70
  resource = "stream";
40
71
  iterator = run(() => resolved[Symbol.asyncIterator]());
41
72
  yield { identity, sequence: sequence++, channel: "result", kind: "open", resource: "stream" };
42
73
  for (; ; ) {
43
- options.signal?.throwIfAborted();
44
- const next = await run(() => iterator.next());
45
- options.signal?.throwIfAborted();
74
+ signal?.throwIfAborted();
75
+ const next = await waits.wait(run(() => iterator.next()));
76
+ signal?.throwIfAborted();
46
77
  if (next.done) break;
47
78
  yield {
48
79
  identity,
@@ -70,12 +101,14 @@ async function* createStreamedSignalResultFrames(identity, result, options = {})
70
101
  };
71
102
  }
72
103
  yield { identity, sequence, channel: "result", kind: "complete" };
73
- } catch {
104
+ } catch (error) {
105
+ if (error === CANCELLED) return;
74
106
  if (sequence === 0) {
75
107
  yield { identity, sequence: sequence++, channel: "result", kind: "open", resource };
76
108
  }
77
109
  yield { identity, sequence, channel: "result", kind: "error", code: "SERVER_RESULT_FAILED" };
78
110
  } finally {
111
+ signal?.removeEventListener("abort", abort);
79
112
  if (iterator !== void 0) {
80
113
  try {
81
114
  await run(() => iterator.return?.());
@@ -446,12 +479,11 @@ function createAutomaticStreamedSignalInjection(options, external) {
446
479
  attempt.release();
447
480
  return;
448
481
  }
482
+ observedAttempts.add(attemptKey);
449
483
  if (children.size >= 256) {
450
484
  attempt.release();
451
- fail(new Error("Automatic streamed signals exceeded their channel budget."));
452
485
  return;
453
486
  }
454
- observedAttempts.add(attemptKey);
455
487
  hasSignalAttempts = true;
456
488
  const identity = {
457
489
  protocol: 1,
@@ -1,7 +1,6 @@
1
1
  export * from "./index.js";
2
- import { isNativeSignalDiagnosticProbe, nativeLocalHook } from "../runtime.js";
3
- import { createNativeSignalDiagnosticInitializer } from "./diagnostic-local-hook.js";
4
- import { createDiagnosticLocalScope, createLocalScope } from "./engine.js";
2
+ import { nativeLocalHook } from "../runtime.js";
3
+ import { createLocalScope } from "./engine.js";
5
4
  function disposeLocalSignal(cell) {
6
5
  cell.scope.dispose();
7
6
  }
@@ -14,11 +13,7 @@ function useSignal$(initial, slot) {
14
13
  return { scope, signal$: scope.signal$("value", value) };
15
14
  },
16
15
  disposeLocalSignal,
17
- slot,
18
- process.env.NODE_ENV === "production" || typeof initial === "function" || !isNativeSignalDiagnosticProbe() ? void 0 : createNativeSignalDiagnosticInitializer(() => {
19
- const scope = createDiagnosticLocalScope("octane/useSignal$");
20
- return { scope, signal$: scope.signal$("value", initial) };
21
- })
16
+ slot
22
17
  );
23
18
  return cell.signal$;
24
19
  }
@@ -105,8 +105,6 @@ declare class AdoptionFrameImpl implements AdoptionFrame {
105
105
  export declare function createScope(options: ScopeOptions): Scope;
106
106
  /** Only the native hook adapter may create a component-owned, non-serializable scope. */
107
107
  export declare function createLocalScope(scopeKey: string): Scope;
108
- /** @internal Isolated historical useSignal$ state, never a live presentation cell. */
109
- export declare function createDiagnosticLocalScope(scopeKey: string): Scope;
110
108
  export declare function createDeclaredSignalCell<T>(owner: Scope, key: string, initial: T, preferInitial?: boolean): WritableSignal<T>;
111
109
  export declare function createDerivedCellWith<T>(owner: Scope, key: string, compute: DerivedCompute<T>, options: DerivedOptions | undefined, Binding: DerivedBindingFactory<T>): DerivedSignal<T>;
112
110
  export declare function createResourceCellWith<T>(owner: Scope, key: string, describe: () => QueryRequest<T> | typeof skip, initialize: typeof initializeResource, unique?: boolean): Resource<T>;
@@ -30,8 +30,6 @@ import {
30
30
  beginNativeWriteGuard,
31
31
  endNativeWriteGuard,
32
32
  getNativeAdoptionResolver,
33
- getNativeReadObserver,
34
- isNativeWriteGuarded,
35
33
  registerNativeBatchHooks,
36
34
  reportNativeRead
37
35
  } from "./read-protocol.js";
@@ -101,7 +99,6 @@ function decodeSeed(scopeKey, seed) {
101
99
  }
102
100
  return entries;
103
101
  }
104
- const DIAGNOSTIC_LOCAL_SCOPES = /* @__PURE__ */ new WeakSet();
105
102
  class ScopeImpl {
106
103
  constructor(key, options, seedable = true) {
107
104
  this.key = key;
@@ -588,8 +585,7 @@ class ScopeImpl {
588
585
  }
589
586
  dispose() {
590
587
  if (this.disposed) return;
591
- if (process.env.NODE_ENV === "production" || !DIAGNOSTIC_LOCAL_SCOPES.has(this))
592
- assertWritable();
588
+ assertWritable();
593
589
  signalBatch(() => {
594
590
  this.disposed = true;
595
591
  this.lifetime++;
@@ -732,13 +728,6 @@ function createScope(options) {
732
728
  function createLocalScope(scopeKey) {
733
729
  return new ScopeImpl(scopeKey, { scopeKey }, false);
734
730
  }
735
- function createDiagnosticLocalScope(scopeKey) {
736
- if (process.env.NODE_ENV === "production" || !isNativeWriteGuarded() || getNativeReadObserver() !== null)
737
- throw new SignalFrameError("Diagnostic local scopes require an isolated historical read.");
738
- const scope = new ScopeImpl(scopeKey, { scopeKey }, false);
739
- DIAGNOSTIC_LOCAL_SCOPES.add(scope);
740
- return scope;
741
- }
742
731
  function createDeclaredSignalCell(owner, key, initial, preferInitial = false) {
743
732
  if (!(owner instanceof ScopeImpl)) throw new TypeError("A direct signal needs an Octane scope.");
744
733
  return owner.createSignalDeclaration(key, initial, preferInitial);
@@ -780,7 +769,6 @@ export {
780
769
  bindScopeStreamedSelection,
781
770
  createDeclaredSignalCell,
782
771
  createDerivedCellWith,
783
- createDiagnosticLocalScope,
784
772
  createLocalScope,
785
773
  createResourceCellWith,
786
774
  createScope,
@@ -1287,7 +1287,7 @@ function retainCommittedTryArm(owner) {
1287
1287
  if (!owner.record.mounted) return null;
1288
1288
  const childRecord = owner.record.children.find((child2) => Object.is(child2.key, "try"));
1289
1289
  if (childRecord === void 0) return null;
1290
- const range = findLogicalRange(owner.record.root.rootRecordForRetention(), childRecord.rangeKey);
1290
+ const range = childRecord.range ?? findLogicalRange(owner.record.root.rootRecordForRetention(), childRecord.rangeKey);
1291
1291
  if (range === null) return null;
1292
1292
  resetDraftChildren(owner);
1293
1293
  const child = draftOwner(childRecord, owner, null);
package/dist/version.js CHANGED
@@ -1,4 +1,4 @@
1
- const version = "0.4.2";
1
+ const version = "0.4.3";
2
2
  export {
3
3
  version
4
4
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "octane",
3
- "version": "0.4.2",
3
+ "version": "0.4.3",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "sideEffects": [
@@ -1,37 +0,0 @@
1
- "use strict";
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __export = (target, all) => {
7
- for (var name in all)
8
- __defProp(target, name, { get: all[name], enumerable: true });
9
- };
10
- var __copyProps = (to, from, except, desc) => {
11
- if (from && typeof from === "object" || typeof from === "function") {
12
- for (let key of __getOwnPropNames(from))
13
- if (!__hasOwnProp.call(to, key) && key !== except)
14
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
- }
16
- return to;
17
- };
18
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
- var diagnostic_local_hook_exports = {};
20
- __export(diagnostic_local_hook_exports, {
21
- createNativeSignalDiagnosticInitializer: () => createNativeSignalDiagnosticInitializer,
22
- isNativeSignalDiagnosticInitializer: () => isNativeSignalDiagnosticInitializer
23
- });
24
- module.exports = __toCommonJS(diagnostic_local_hook_exports);
25
- const DIAGNOSTIC_SIGNAL_INITIALIZERS = /* @__PURE__ */ new WeakSet();
26
- function createNativeSignalDiagnosticInitializer(initialize) {
27
- DIAGNOSTIC_SIGNAL_INITIALIZERS.add(initialize);
28
- return initialize;
29
- }
30
- function isNativeSignalDiagnosticInitializer(value) {
31
- return DIAGNOSTIC_SIGNAL_INITIALIZERS.has(value);
32
- }
33
- // Annotate the CommonJS export names for ESM import in node:
34
- 0 && (module.exports = {
35
- createNativeSignalDiagnosticInitializer,
36
- isNativeSignalDiagnosticInitializer
37
- });