/** * Shareable URL state — a keyed map of app view state that round-trips through * the host page's `state` query param, so the address bar is always a link to * the current view. * * Inside the Lightdash iframe the seed arrives synchronously in the hash * (written there by the host from its own `?state=`) and changes are posted to * the parent; top-level (local dev) the app reads and writes its own `?state=`. * See the "Shareable URL state" section of docs/data-apps.md. * * Seeded values come from a user-editable URL — treat them as untrusted. */ export type UrlStateMap = Record; /** Iframe → parent. The host writes `state` into its page URL. */ export type SdkUrlStateChangeMessage = { type: 'lightdash:sdk:url-state-change'; state: UrlStateMap; }; export declare const URL_STATE_CHANGE_MESSAGE = "lightdash:sdk:url-state-change"; export declare const URL_STATE_PARAM = "state"; /** Keep in sync with the parent-side caps in useAppSdkBridge and * useAppUrlStateSync (packages/frontend). */ export declare const MAX_URL_STATE_CHARS = 4096; /** * Parse the seed map. The iframe hash wins (that's where the host forwards its * `?state=`); the search param is the top-level fallback. */ export declare function parseUrlStateSeed(location: { hash: string; search: string; }): UrlStateMap; /** * Serialize a state map, or null when it can't be published (non-JSON values, * or over the size cap). Warns so the author sees why state stopped persisting. */ export declare function serializeUrlState(state: UrlStateMap): string | null; export type UrlStateStore = { getState: () => UrlStateMap; setKey: (key: string, value: unknown) => void; subscribe: (listener: () => void) => () => void; }; /** * Minimal external store: synchronous reads for useSyncExternalStore, trailing- * edge publish on writes. Exported for tests — app code uses `useUrlState`. */ export declare function createUrlStateStore(options: { seed: UrlStateMap; publish: (state: UrlStateMap) => void; debounceMs?: number; }): UrlStateStore; /** * `useState`-shaped hook whose value round-trips through the page URL: * * const [period, setPeriod] = useUrlState('period', 'last_month'); * * Values must be JSON-serializable. All call sites share one map keyed by * `key`, so no provider is needed. */ export declare function useUrlState(key: string, defaultValue: T): [T, (next: T | ((prev: T) => T)) => void];