import { Options } from '../internal/resolveValue.ts'; import { Observer } from '../Observer/Observer.ts'; /** * Configuration options for setting cookies. */ export type CookieOptions = { /** Expiration date or number of days from now. */ expires?: Date | number; /** Maximum age of the cookie in seconds. Takes precedence over `expires` in modern browsers. */ maxAge?: number; /** Domain where the cookie is accessible. */ domain?: string; /** Path where the cookie is accessible. Defaults to `/`. */ path?: string; /** Send only over HTTPS. Auto-enabled when `sameSite: 'none'`. */ secure?: boolean; /** SameSite attribute. Defaults to `'lax'` (matches modern browser defaults). */ sameSite?: "strict" | "lax" | "none"; }; /** * Cookie-backed state management. * * Defaults applied by `set()`: * - `path: '/'` — cookie is readable from every page of the host. * Without this, browsers scope the cookie to the path of the page that * wrote it, which is almost never what you want and was the root cause * of the "cookies don't persist between pages" bug. * - `sameSite: 'lax'` — matches modern browser defaults and avoids warnings. * - `secure` auto-enabled when `sameSite: 'none'` (browser requirement). */ export declare class CookieState extends Observer { static get(key: string, options: Options & { strict: true; }): T; static get(key: string, options: Options & { fallback: T; }): T; static get(key: string, options?: Options): T | undefined; /** * Stores a value as a cookie. * * @throws when the cookie name contains forbidden characters, when the * value is not JSON-serialisable, or when SameSite=None is used * without Secure (browser would reject it silently). */ static set(key: string, value: T, options?: CookieOptions): void; /** * Removes a cookie. * * IMPORTANT: to successfully delete a cookie, `path` and `domain` MUST * match the values used when the cookie was set. By default this method * uses `path: '/'`, which matches the default of `set()`. If you set a * cookie with a custom path or domain, pass the same values here. */ static remove(key: string, options?: Pick): void; /** * Clears all cookies visible to the current document at `path=/`. * * Caveat: cookies set with a non-default `path` or `domain` may NOT be * cleared, because browsers require exact path/domain match to delete. */ static clear(): void; static has(key: string): boolean; }