/** * Key canonicalization + dev guards for `useData`. * * A key does three jobs at once — reactive trigger, cache/SSR identity, and * fetcher input — so identity must be canonical: tuples serialize to JSON * (`['user', 7]` → `'["user",7]"`), which also keeps them disjoint from * plain string keys used by other producers in the shared SSR blob (a * canonical tuple always starts with `[`). * * Pure module: no web globals, no blob access (that lives in ./restore.ts). */ /** All skip values — including '' so `str && tuple` getters type cleanly. */ export type Falsy = null | undefined | false | ''; /** Tuple elements are JSON primitives only — identity is canonical JSON. */ export type KeyTuple = readonly (string | number | boolean | null)[]; export type KeyValue = string | KeyTuple; /** * A server-fn reference usable AS a key (rfc-server §6.2, #452): any * callable carrying the build-stamped stable key (`/`). * Structural — runtime-core never imports `@sigx/server`; the brand is the * stamped property. As a key it canonicalizes to the key STRING in place * (`useData(getVotes)` → `'["/getVotes"]'`), so a mutation's * fn-ref `invalidates` pattern matches by tuple prefix. */ export interface ServerFnDataRef { (...args: A): R | Promise; /** Build-stamped stable key (`/`). */ __sigxKey: string; } /** Brand check — a function whose `__sigxKey` is a non-empty string. */ export declare function isServerFnDataRef(value: unknown): value is ServerFnDataRef; /** Per-cell dedup flags for the soft key warnings (warn once per cell). */ export interface KeyWarnFlags { emptyString?: boolean; emptyTuple?: boolean; negZero?: boolean; } /** * Resolve a key result to its canonical string identity, or `null` when the * read should be skipped (state `'idle'`, fetcher not run). * * Dev guards (stripped in production): * - `''` ⇒ skip + warn (almost always an interpolation bug) * - empty tuple ⇒ skip + warn * - non-primitive tuple element ⇒ throw * - non-finite number ⇒ throw (NaN/±Infinity JSON to `null` — identity collision) * - `-0` ⇒ warn (canonicalizes to `0`) */ export declare function resolveKeyResult(raw: KeyValue | Falsy, warns?: KeyWarnFlags): string | null; /** * Classify `useData`'s first argument. A static tuple is rejected by design: * a tuple exists to carry parameters, and parameters that change belong in a * reactive getter — a static tuple can never change. */ export declare function assertKeyArgShape(first: unknown): 'static' | 'getter'; //# sourceMappingURL=key.d.ts.map