+4
-0
@@ -982,2 +982,5 @@ 'use strict'; | ||
| } | ||
| function runInServerComponentScope(fn) { | ||
| return fn(); | ||
| } | ||
| const DEV = signals.DEV ; | ||
@@ -1162,2 +1165,3 @@ if (globalThis) { | ||
| exports.lazy = lazy; | ||
| exports.runInServerComponentScope = runInServerComponentScope; | ||
| exports.sharedConfig = sharedConfig; | ||
@@ -1164,0 +1168,0 @@ exports.ssrHandleError = ssrHandleError; |
+4
-1
@@ -981,2 +981,5 @@ import { getContext, createMemo as createMemo$1, flatten, createRoot, setContext, getOwner, untrack, createOwner, runWithOwner, createEffect as createEffect$1, createErrorBoundary as createErrorBoundary$1, createLoadingBoundary as createLoadingBoundary$1, createOptimistic as createOptimistic$1, createOptimisticStore as createOptimisticStore$1, createProjection as createProjection$1, createRenderEffect as createRenderEffect$1, createRevealOrder as createRevealOrder$1, createSignal as createSignal$1, createStore as createStore$1, setSnapshotCapture, releaseSnapshotScope, peekNextChildId, getNextChildId, clearSnapshots, flush, markSnapshotScope, onCleanup, isDisposed, mapArray, repeat, DEV as DEV$1 } from '@solidjs/signals'; | ||
| } | ||
| function runInServerComponentScope(fn) { | ||
| return fn(); | ||
| } | ||
| const DEV = DEV$1 ; | ||
@@ -987,2 +990,2 @@ if (globalThis) { | ||
| export { $DEVCOMP, DEV, Errored, For, Hydration, Loading, Match, NoHydrateContext, NoHydration, Repeat, Reveal, Show, Switch, children, createComponent, createContext, createEffect, createErrorBoundary, createLoadingBoundary, createMemo, createOptimistic, createOptimisticStore, createProjection, createRenderEffect, createRevealOrder, createSignal, createStore, createUniqueId, enableHydration, lazy, sharedConfig, ssrHandleError, ssrScope, useContext }; | ||
| export { $DEVCOMP, DEV, Errored, For, Hydration, Loading, Match, NoHydrateContext, NoHydration, Repeat, Reveal, Show, Switch, children, createComponent, createContext, createEffect, createErrorBoundary, createLoadingBoundary, createMemo, createOptimistic, createOptimisticStore, createProjection, createRenderEffect, createRevealOrder, createSignal, createStore, createUniqueId, enableHydration, lazy, runInServerComponentScope, sharedConfig, ssrHandleError, ssrScope, useContext }; |
+38
-1
@@ -1049,2 +1049,30 @@ 'use strict'; | ||
| } | ||
| const ServerComponentContext = { | ||
| id: Symbol("ServerComponentContext")}; | ||
| function runInServerComponentScope(fn) { | ||
| const owner = createOwner({ | ||
| transparent: true | ||
| }); | ||
| const inherited = owner._context; | ||
| const scoped = { | ||
| [ServerComponentContext.id]: true | ||
| }; | ||
| if (inherited[ErrorContext.id] !== undefined) { | ||
| scoped[ErrorContext.id] = inherited[ErrorContext.id]; | ||
| } | ||
| if (inherited[RevealGroupContext.id] !== undefined) { | ||
| scoped[RevealGroupContext.id] = inherited[RevealGroupContext.id]; | ||
| } | ||
| if (inherited[NoHydrateContext.id] !== undefined) { | ||
| scoped[NoHydrateContext.id] = inherited[NoHydrateContext.id]; | ||
| } | ||
| owner._context = scoped; | ||
| return runWithOwner(owner, fn); | ||
| } | ||
| function serverComponentContextError(context) { | ||
| const o = currentOwner; | ||
| if (!o || o._context[ServerComponentContext.id] !== true) return null; | ||
| const name = context.id.description; | ||
| return new Error(`Context${name ? ` "${name}"` : ""} cannot be read inside a server component. ` + "Server components render standalone on refetches and mutations, so app-level " + "providers do not cross the boundary. Pass the value as an argument, render the " + "provider inside the server component, or read per-request state via getRequestEvent()."); | ||
| } | ||
| function createRevealOrder(fn, _options) { | ||
@@ -1101,3 +1129,11 @@ const o = createOwner(); | ||
| function useContext(context) { | ||
| return getContext(context); | ||
| try { | ||
| return getContext(context); | ||
| } catch (err) { | ||
| if (err instanceof signals.ContextNotFoundError) { | ||
| const barrier = serverComponentContextError(context); | ||
| if (barrier) throw barrier; | ||
| } | ||
| throw err; | ||
| } | ||
| } | ||
@@ -1743,2 +1779,3 @@ function children(fn) { | ||
| exports.resolve = resolve; | ||
| exports.runInServerComponentScope = runInServerComponentScope; | ||
| exports.runWithOwner = runWithOwner; | ||
@@ -1745,0 +1782,0 @@ exports.sharedConfig = sharedConfig; |
+38
-2
@@ -1048,2 +1048,30 @@ import { NotReadyError, $REFRESH, merge as merge$1, isWrappable, NoOwnerError, ContextNotFoundError, $PROXY, flatten } from '@solidjs/signals'; | ||
| } | ||
| const ServerComponentContext = { | ||
| id: Symbol("ServerComponentContext")}; | ||
| function runInServerComponentScope(fn) { | ||
| const owner = createOwner({ | ||
| transparent: true | ||
| }); | ||
| const inherited = owner._context; | ||
| const scoped = { | ||
| [ServerComponentContext.id]: true | ||
| }; | ||
| if (inherited[ErrorContext.id] !== undefined) { | ||
| scoped[ErrorContext.id] = inherited[ErrorContext.id]; | ||
| } | ||
| if (inherited[RevealGroupContext.id] !== undefined) { | ||
| scoped[RevealGroupContext.id] = inherited[RevealGroupContext.id]; | ||
| } | ||
| if (inherited[NoHydrateContext.id] !== undefined) { | ||
| scoped[NoHydrateContext.id] = inherited[NoHydrateContext.id]; | ||
| } | ||
| owner._context = scoped; | ||
| return runWithOwner(owner, fn); | ||
| } | ||
| function serverComponentContextError(context) { | ||
| const o = currentOwner; | ||
| if (!o || o._context[ServerComponentContext.id] !== true) return null; | ||
| const name = context.id.description; | ||
| return new Error(`Context${name ? ` "${name}"` : ""} cannot be read inside a server component. ` + "Server components render standalone on refetches and mutations, so app-level " + "providers do not cross the boundary. Pass the value as an argument, render the " + "provider inside the server component, or read per-request state via getRequestEvent()."); | ||
| } | ||
| function createRevealOrder(fn, _options) { | ||
@@ -1100,3 +1128,11 @@ const o = createOwner(); | ||
| function useContext(context) { | ||
| return getContext(context); | ||
| try { | ||
| return getContext(context); | ||
| } catch (err) { | ||
| if (err instanceof ContextNotFoundError) { | ||
| const barrier = serverComponentContextError(context); | ||
| if (barrier) throw barrier; | ||
| } | ||
| throw err; | ||
| } | ||
| } | ||
@@ -1641,2 +1677,2 @@ function children(fn) { | ||
| export { $DEVCOMP, DEV, Errored, For, Hydration, Loading, Match, NoHydrateContext, NoHydration, Repeat, Reveal, Show, Switch, action, affects, children, createComponent, createContext, createDeepProxy, createEffect, createErrorBoundary, createLoadingBoundary, createMemo, createOptimistic, createOptimisticStore, createOwner, createProjection, createReaction, createRenderEffect, createRevealOrder, createRoot, createSignal, createStore, createTrackedEffect, createUniqueId, deep, enableHydration, flush, getNextChildId, getObserver, getOwner, isDisposed, isPending, latest, lazy, mapArray, merge, onCleanup, onSettled, reconcile, refresh, repeat, resolve, runWithOwner, sharedConfig, ssrHandleError, ssrScope, untrack, useContext }; | ||
| export { $DEVCOMP, DEV, Errored, For, Hydration, Loading, Match, NoHydrateContext, NoHydration, Repeat, Reveal, Show, Switch, action, affects, children, createComponent, createContext, createDeepProxy, createEffect, createErrorBoundary, createLoadingBoundary, createMemo, createOptimistic, createOptimisticStore, createOwner, createProjection, createReaction, createRenderEffect, createRevealOrder, createRoot, createSignal, createStore, createTrackedEffect, createUniqueId, deep, enableHydration, flush, getNextChildId, getObserver, getOwner, isDisposed, isPending, latest, lazy, mapArray, merge, onCleanup, onSettled, reconcile, refresh, repeat, resolve, runInServerComponentScope, runWithOwner, sharedConfig, ssrHandleError, ssrScope, untrack, useContext }; |
+4
-0
@@ -951,2 +951,5 @@ 'use strict'; | ||
| } | ||
| function runInServerComponentScope(fn) { | ||
| return fn(); | ||
| } | ||
| const DEV = undefined; | ||
@@ -1128,2 +1131,3 @@ | ||
| exports.lazy = lazy; | ||
| exports.runInServerComponentScope = runInServerComponentScope; | ||
| exports.sharedConfig = sharedConfig; | ||
@@ -1130,0 +1134,0 @@ exports.ssrHandleError = ssrHandleError; |
+4
-1
@@ -950,4 +950,7 @@ import { getContext, createMemo as createMemo$1, flatten, createRoot, setContext, createOwner, runWithOwner, createEffect as createEffect$1, createErrorBoundary as createErrorBoundary$1, createLoadingBoundary as createLoadingBoundary$1, createOptimistic as createOptimistic$1, createOptimisticStore as createOptimisticStore$1, createProjection as createProjection$1, createRenderEffect as createRenderEffect$1, createRevealOrder as createRevealOrder$1, createSignal as createSignal$1, createStore as createStore$1, setSnapshotCapture, releaseSnapshotScope, getOwner, peekNextChildId, getNextChildId, clearSnapshots, flush, markSnapshotScope, onCleanup, isDisposed, untrack, mapArray, repeat } from '@solidjs/signals'; | ||
| } | ||
| function runInServerComponentScope(fn) { | ||
| return fn(); | ||
| } | ||
| const DEV = undefined; | ||
| export { $DEVCOMP, DEV, Errored, For, Hydration, Loading, Match, NoHydrateContext, NoHydration, Repeat, Reveal, Show, Switch, children, createComponent, createContext, createEffect, createErrorBoundary, createLoadingBoundary, createMemo, createOptimistic, createOptimisticStore, createProjection, createRenderEffect, createRevealOrder, createSignal, createStore, createUniqueId, enableHydration, lazy, sharedConfig, ssrHandleError, ssrScope, useContext }; | ||
| export { $DEVCOMP, DEV, Errored, For, Hydration, Loading, Match, NoHydrateContext, NoHydration, Repeat, Reveal, Show, Switch, children, createComponent, createContext, createEffect, createErrorBoundary, createLoadingBoundary, createMemo, createOptimistic, createOptimisticStore, createProjection, createRenderEffect, createRevealOrder, createSignal, createStore, createUniqueId, enableHydration, lazy, runInServerComponentScope, sharedConfig, ssrHandleError, ssrScope, useContext }; |
+2
-2
| { | ||
| "name": "solid-js", | ||
| "description": "Reactive JavaScript library for building user interfaces. Compiles JSX to real DOM with fine-grained signal-based updates — no virtual DOM.", | ||
| "version": "2.0.0-beta.28", | ||
| "version": "2.0.0-beta.29", | ||
| "author": "Ryan Carniato", | ||
@@ -131,3 +131,3 @@ "license": "MIT", | ||
| "dependencies": { | ||
| "@solidjs/signals": "^2.0.0-beta.28", | ||
| "@solidjs/signals": "^2.0.0-beta.29", | ||
| "csstype": "^3.1.0", | ||
@@ -134,0 +134,0 @@ "seroval": "~1.5.4", |
@@ -13,2 +13,4 @@ export { $PROXY, $REFRESH, $TRACK, action, affects, createOwner, createReaction, createRoot, createTrackedEffect, deep, flatten, flush, getNextChildId, getObserver, getOwner, isDisposed, isEqual, isPending, isWrappable, mapArray, merge, omit, onCleanup, onSettled, latest, reconcile, refresh, repeat, resolve, NotReadyError, runWithOwner, enableExternalSource, enforceLoadingBoundary, snapshot, storePath, untrack } from "@solidjs/signals"; | ||
| export declare function ssrScope<T>(fn: () => T): () => T; | ||
| /** @internal */ | ||
| export declare function runInServerComponentScope<T>(fn: () => T): T; | ||
| import { type Dev } from "@solidjs/signals"; | ||
@@ -15,0 +17,0 @@ export declare const DEV: Dev | undefined; |
@@ -30,2 +30,8 @@ import type { Accessor, EffectOptions } from "./signals.cjs"; | ||
| * Provider is mounted and the context was created without a default. | ||
| * | ||
| * Inside a server component the miss is upgraded to an error explaining the | ||
| * boundary: app-level providers exist at t=0 (the component renders inline | ||
| * in the document) but not on refetches or mutation regions (it renders | ||
| * standalone), so context deliberately never crosses a server-component | ||
| * root — surfacing "no provider" there would point at the wrong problem. | ||
| */ | ||
@@ -32,0 +38,0 @@ export declare function useContext<T>(context: Context<T>): T; |
@@ -1,2 +0,2 @@ | ||
| export { $PROXY, $REFRESH, $TRACK, action, affects, createEffect, createMemo, createOptimistic, createOptimisticStore, createErrorBoundary, createOwner, createProjection, createReaction, createRenderEffect, createRevealOrder, createRoot, createSignal, createStore, createTrackedEffect, deep, flatten, flush, getNextChildId, getObserver, getOwner, isDisposed, isEqual, isPending, isWrappable, mapArray, merge, omit, onCleanup, onSettled, latest, reconcile, refresh, repeat, resolve, NotReadyError, runWithOwner, snapshot, storePath, createDeepProxy, enableExternalSource, enforceLoadingBoundary, untrack } from "./signals.cjs"; | ||
| export { $PROXY, $REFRESH, $TRACK, action, affects, createEffect, createMemo, createOptimistic, createOptimisticStore, createErrorBoundary, createOwner, createProjection, createReaction, createRenderEffect, createRevealOrder, createRoot, createSignal, createStore, createTrackedEffect, deep, flatten, flush, getNextChildId, getObserver, getOwner, isDisposed, isEqual, isPending, isWrappable, mapArray, merge, omit, onCleanup, onSettled, latest, reconcile, refresh, repeat, resolve, NotReadyError, runInServerComponentScope, runWithOwner, snapshot, storePath, createDeepProxy, enableExternalSource, enforceLoadingBoundary, untrack } from "./signals.cjs"; | ||
| export type { Accessor, ComputeFunction, EffectFunction, EffectOptions, ExternalSource, ExternalSourceConfig, ExternalSourceFactory, Merge, NoInfer, NotWrappable, Omit, Owner, Refreshable, Signal, SignalOptions, Setter, Store, SolidStore, StoreNode, StoreSetter, StorePathRange, ArrayFilterFn, CustomPartial, Part, PathSetter, PatchOp } from "./signals.cjs"; | ||
@@ -3,0 +3,0 @@ export { $DEVCOMP, children, createContext, useContext } from "./core.cjs"; |
@@ -186,2 +186,39 @@ import { $REFRESH } from "@solidjs/signals"; | ||
| }): Accessor<T | U>; | ||
| /** | ||
| * Runs `fn` under a context barrier — the render root of a server | ||
| * component. | ||
| * | ||
| * A server component renders standalone on every response after the first | ||
| * (refetches, mutation regions): there is no surrounding app tree, so app | ||
| * context can never reach it there. At t=0 it renders INLINE in the | ||
| * document tree, where an app-level provider WOULD resolve — a silent | ||
| * divergence where context "works" once and breaks on the next response. | ||
| * The barrier makes t=0 behave like every later render by construction: | ||
| * the scope owner gets a rebuilt context record carrying only the boundary | ||
| * plumbing, so | ||
| * | ||
| * - `Loading` / `Errored` / reveal-group coordination still crosses (the | ||
| * back-and-forth between a server component's async content and the | ||
| * enclosing boundaries at t=0 is intentional — `ErrorContext`, | ||
| * `RevealGroupContext`, and `NoHydrateContext` are copied through); | ||
| * - providers rendered INSIDE the server component work normally; | ||
| * - defaulted contexts read their default (both paths agree); | ||
| * - default-less contexts throw — `useContext` upgrades the miss to an | ||
| * error that explains the boundary. | ||
| * | ||
| * The owner is transparent, so hydration-id chains are untouched. | ||
| * | ||
| * @internal | ||
| */ | ||
| export declare function runInServerComponentScope<T>(fn: () => T): T; | ||
| /** | ||
| * Builds the explanatory error for a context read that missed INSIDE a | ||
| * server-component scope, or returns `null` when the current owner isn't | ||
| * inside one (the caller rethrows its original error). Called by | ||
| * `useContext` only on the failure path — the success path stays a plain | ||
| * record read. | ||
| * | ||
| * @internal | ||
| */ | ||
| export declare function serverComponentContextError(context: Context<any>): Error | null; | ||
| export type RevealOrder = "sequential" | "together" | "natural"; | ||
@@ -188,0 +225,0 @@ export declare function createRevealOrder<T>(fn: () => T, _options?: { |
+2
-0
@@ -13,2 +13,4 @@ export { $PROXY, $REFRESH, $TRACK, action, affects, createOwner, createReaction, createRoot, createTrackedEffect, deep, flatten, flush, getNextChildId, getObserver, getOwner, isDisposed, isEqual, isPending, isWrappable, mapArray, merge, omit, onCleanup, onSettled, latest, reconcile, refresh, repeat, resolve, NotReadyError, runWithOwner, enableExternalSource, enforceLoadingBoundary, snapshot, storePath, untrack } from "@solidjs/signals"; | ||
| export declare function ssrScope<T>(fn: () => T): () => T; | ||
| /** @internal */ | ||
| export declare function runInServerComponentScope<T>(fn: () => T): T; | ||
| import { type Dev } from "@solidjs/signals"; | ||
@@ -15,0 +17,0 @@ export declare const DEV: Dev | undefined; |
@@ -30,2 +30,8 @@ import type { Accessor, EffectOptions } from "./signals.js"; | ||
| * Provider is mounted and the context was created without a default. | ||
| * | ||
| * Inside a server component the miss is upgraded to an error explaining the | ||
| * boundary: app-level providers exist at t=0 (the component renders inline | ||
| * in the document) but not on refetches or mutation regions (it renders | ||
| * standalone), so context deliberately never crosses a server-component | ||
| * root — surfacing "no provider" there would point at the wrong problem. | ||
| */ | ||
@@ -32,0 +38,0 @@ export declare function useContext<T>(context: Context<T>): T; |
@@ -1,2 +0,2 @@ | ||
| export { $PROXY, $REFRESH, $TRACK, action, affects, createEffect, createMemo, createOptimistic, createOptimisticStore, createErrorBoundary, createOwner, createProjection, createReaction, createRenderEffect, createRevealOrder, createRoot, createSignal, createStore, createTrackedEffect, deep, flatten, flush, getNextChildId, getObserver, getOwner, isDisposed, isEqual, isPending, isWrappable, mapArray, merge, omit, onCleanup, onSettled, latest, reconcile, refresh, repeat, resolve, NotReadyError, runWithOwner, snapshot, storePath, createDeepProxy, enableExternalSource, enforceLoadingBoundary, untrack } from "./signals.js"; | ||
| export { $PROXY, $REFRESH, $TRACK, action, affects, createEffect, createMemo, createOptimistic, createOptimisticStore, createErrorBoundary, createOwner, createProjection, createReaction, createRenderEffect, createRevealOrder, createRoot, createSignal, createStore, createTrackedEffect, deep, flatten, flush, getNextChildId, getObserver, getOwner, isDisposed, isEqual, isPending, isWrappable, mapArray, merge, omit, onCleanup, onSettled, latest, reconcile, refresh, repeat, resolve, NotReadyError, runInServerComponentScope, runWithOwner, snapshot, storePath, createDeepProxy, enableExternalSource, enforceLoadingBoundary, untrack } from "./signals.js"; | ||
| export type { Accessor, ComputeFunction, EffectFunction, EffectOptions, ExternalSource, ExternalSourceConfig, ExternalSourceFactory, Merge, NoInfer, NotWrappable, Omit, Owner, Refreshable, Signal, SignalOptions, Setter, Store, SolidStore, StoreNode, StoreSetter, StorePathRange, ArrayFilterFn, CustomPartial, Part, PathSetter, PatchOp } from "./signals.js"; | ||
@@ -3,0 +3,0 @@ export { $DEVCOMP, children, createContext, useContext } from "./core.js"; |
@@ -186,2 +186,39 @@ import { $REFRESH } from "@solidjs/signals"; | ||
| }): Accessor<T | U>; | ||
| /** | ||
| * Runs `fn` under a context barrier — the render root of a server | ||
| * component. | ||
| * | ||
| * A server component renders standalone on every response after the first | ||
| * (refetches, mutation regions): there is no surrounding app tree, so app | ||
| * context can never reach it there. At t=0 it renders INLINE in the | ||
| * document tree, where an app-level provider WOULD resolve — a silent | ||
| * divergence where context "works" once and breaks on the next response. | ||
| * The barrier makes t=0 behave like every later render by construction: | ||
| * the scope owner gets a rebuilt context record carrying only the boundary | ||
| * plumbing, so | ||
| * | ||
| * - `Loading` / `Errored` / reveal-group coordination still crosses (the | ||
| * back-and-forth between a server component's async content and the | ||
| * enclosing boundaries at t=0 is intentional — `ErrorContext`, | ||
| * `RevealGroupContext`, and `NoHydrateContext` are copied through); | ||
| * - providers rendered INSIDE the server component work normally; | ||
| * - defaulted contexts read their default (both paths agree); | ||
| * - default-less contexts throw — `useContext` upgrades the miss to an | ||
| * error that explains the boundary. | ||
| * | ||
| * The owner is transparent, so hydration-id chains are untouched. | ||
| * | ||
| * @internal | ||
| */ | ||
| export declare function runInServerComponentScope<T>(fn: () => T): T; | ||
| /** | ||
| * Builds the explanatory error for a context read that missed INSIDE a | ||
| * server-component scope, or returns `null` when the current owner isn't | ||
| * inside one (the caller rethrows its original error). Called by | ||
| * `useContext` only on the failure path — the success path stays a plain | ||
| * record read. | ||
| * | ||
| * @internal | ||
| */ | ||
| export declare function serverComponentContextError(context: Context<any>): Error | null; | ||
| export type RevealOrder = "sequential" | "together" | "natural"; | ||
@@ -188,0 +225,0 @@ export declare function createRevealOrder<T>(fn: () => T, _options?: { |
462661
1.73%10248
1.32%