import type { CanvasPalette, CanvasTokens } from "./canvas-tokens.js"; import { type CanvasAction } from "./internal/canvas-action-dispatch.js"; /** * Host theme for the current canvas. Semantic color groups (`text`, `bg`, * `fill`, `stroke`, `accent`, `diff`) live at the top level for ergonomic * inline-style access; `tokens` is also present as a self-reference for * callers that prefer a namespaced form. */ export interface CanvasHostTheme extends CanvasTokens { readonly kind: string; readonly tokens: CanvasTokens; readonly palette: CanvasPalette; } /** * Returns the current host theme. Falls back to dark mode when no host * state is available. * * Semantic color groups are available directly on the returned object — * `accent`, `text`, `bg`, `fill`, `stroke`, `diff` — as well as `kind` * (`"dark"` | `"light"` | …) and `palette` (the flat color palette). * * Call `useHostTheme()` inside each component that needs theme access — * the returned object is scoped to that component, not shared across * function boundaries. * * Stable paths for `style={{ ... }}` usage: * - `text.primary / secondary / tertiary / quaternary` — text hierarchy * - `bg.editor / chrome / elevated` — surface backgrounds * - `fill.primary / secondary / tertiary / quaternary` — tinted fills * - `stroke.primary / secondary / tertiary` — borders and dividers * - `accent.primary / control` — accent blue and button background * - `text.link` — link color * - `text.onAccent` — text on accent-colored surfaces * * Prefer built-in components (`Card`, `Button`, `Text`, etc.) over raw * token usage. Reach for tokens only when no component covers the case, * and stick to flat solid colors — no gradients, no box-shadows. * * @example * ```tsx * function Overview() { * const theme = useHostTheme(); * return ( *
* Accent text *
* ); * } * ``` */ export declare function useHostTheme(): CanvasHostTheme; /** * Setter for `useCanvasState`. Accepts either a new value or an updater * function that receives the previous value. */ export type SetCanvasState = (action: T | ((prev: T) => T)) => void; /** * Persistent state hook for canvas applications. Works like `React.useState` * but the value survives rebuilds, reloads, and IDE restarts — it is stored * in a `.canvas.data.json` sidecar file next to the canvas source. * * Each key is a unique string chosen by the canvas author. Keys are stable * regardless of hook call order or component tree structure. * * @param key - Unique string identifier for this piece of state. * @param defaultValue - Value returned when no persisted value exists for `key`. * @returns A `[value, setValue]` tuple, same shape as `React.useState`. * * @example * ```tsx * function Counter() { * const [count, setCount] = useCanvasState("count", 0); * return ; * } * ``` * * @example * ```tsx * interface Column { id: string; title: string; cardIds: string[] } * function KanbanBoard() { * const [columns, setColumns] = useCanvasState("columns", [ * { id: "todo", title: "To Do", cardIds: [] }, * { id: "doing", title: "In Progress", cardIds: [] }, * { id: "done", title: "Done", cardIds: [] }, * ]); * // ... * } * ``` */ export declare function useCanvasState(key: string, defaultValue: T): [T, SetCanvasState]; export type { CanvasAction }; /** * Returns a stable `dispatch` function for triggering IDE actions from * canvas buttons. Actions are fire-and-forget — the canvas does not * receive a response. * * ## Available actions * * **`openAgent`** — Navigate the IDE to an agent conversation. * `agentId` is the conversation UUID (the filename stem from the * `agent-transcripts/` directory). Works for both local and * cloud/background agents in Glass and classic IDE modes. * * @example * ```tsx * function AgentLink({ agentId, title }: { agentId: string; title: string }) { * const dispatch = useCanvasAction(); * return ( * * ); * } * ``` */ export declare function useCanvasAction(): (action: CanvasAction) => void; //# sourceMappingURL=hooks.d.ts.map