/** * Typed DI tokens for internal seams. * * The internal seam pattern — a symbol token plus a structurally-typed * provide helper (`provideAsyncEngine`, `provideSSRSerializerHandlers`, * `provideHydrateDefaults`) — used to declare plain `unique symbol` tokens, * forcing an `as X | undefined` cast at every read. The same applied to bare * tokens set directly on a provides Map (`ERROR_SCOPE_TOKEN`). * An `InjectionToken` is still a plain symbol at runtime, but carries its * value type at the type level so `getProvided`/`setProvided` (and the typed * `lookupProvided` overload) infer `T` at the call site. * * Tokens are created with `Symbol(description)`, deliberately NOT * `Symbol.for(...)`: DI identity must live in ONE module graph. A registry * symbol would keep resolving across duplicated copies of this package and * silently mask the dual-module-graph misconfiguration that * `@sigx/vite`'s `ssr.noExternal` handling exists to prevent — with added * cross-version collision risk. A duplicated graph should fail loudly * (provides not found), not blur versions together. * * Internal only — exported via `sigx/internals`, not the public API. */ /** * A DI token that carries its value type. Runtime value: a plain `symbol` * (assignable wherever a symbol is expected); the phantom property exists * only at the type level. * @internal */ export type InjectionToken = symbol & { readonly __sigxTokenType?: T; }; /** * Create a typed DI token. `description` names the token in diagnostics * (`symbol.description`). A typed alias of `Symbol` — zero runtime wrapper. * @internal */ export declare const createToken: (description: string) => InjectionToken; /** * Read a token's value from a provides Map, typed by the token. Accepts a * missing Map so callers can pass optional `provides` fields directly. * @internal */ export declare const getProvided: (provides: Map | null | undefined, token: InjectionToken) => T | undefined; /** * Write a token's value into a provides Map, typed by the token. * @internal */ export declare const setProvided: (provides: Map, token: InjectionToken, value: T) => void; /** * Was this token provided by a DIFFERENT copy of the module that defines it? * * The "fail loudly" half of the one-module-graph rule above. A miss on a * provides Map is ambiguous — nothing provided it, or something provided it * through a second copy of this package — and every seam reads the ambiguity * as the former, so a duplicated graph degrades to defaults in silence. That * is how #425 shipped a plugin-less SSR render: `getSSRPlugins()` returned * `[]` and the renderer simply believed the app had installed no packs. * * The signal is a key carrying this token's description that is NOT this * token. That reads as a duplicated graph under the seam contract — token * descriptions are namespaced (`sigx:*`) and minted in exactly one place, so * the only thing that legitimately produces a second one is a second copy of * the defining module. It is not a general JavaScript guarantee: any code * MAY call `Symbol('sigx:ssrPlugins')`, and a token accidentally declared * twice with one description would trip this too — which is itself worth * knowing. Treat a hit as "these provides were written by something that * isn't us", and keep descriptions unique. * * Call it on the MISS path only, from `__DEV__` blocks — never from * `getProvided`, the hot injection path where a miss is ordinarily * legitimate. * * @internal */ export declare const hasForeignToken: (provides: Map | null | undefined, token: InjectionToken) => boolean; //# sourceMappingURL=token.d.ts.map