import type { ToolRegistry } from "@pixerate/editor/tools"; import { ChartController, ChartDirector, ChartPresence, type OfficeChartToolProviderOptions, type ChartScene, type ChartToolProviderOptions, type ChartActionResult, type ChartCommandOptions, type ChartControllerOptions, type ChartSelection, type ChartSpecPatch, type ChartState, type ChartType, type ChartSpec } from "@pixerate/editor/chart"; import type { EditorDocument } from "@pixerate/editor/persistence"; export interface SvelteChartEditor { readonly controller: ChartController; /** The save / load / undo contract (for `createEditorAutosave` or `createDocumentToolProvider`). */ readonly editorDocument: EditorDocument; /** The controller's state (reactive). */ readonly state: ChartState; /** Shorthand for `state.spec` (reactive). */ readonly spec: ChartState["spec"]; /** Shorthand for `state.selection` (reactive). */ readonly selection: ChartSelection | null; update(patch: ChartSpecPatch): ChartActionResult; setType(type: ChartType): ChartActionResult; setValue(seriesId: string, index: number, value: unknown): ChartActionResult; select(selection: ChartSelection | null): void; undo(): void; redo(): void; /** Stops listening to the controller. */ destroy(): void; } /** * Svelte 5 rune: subscribes to a `ChartController` (or creates one from options) and * exposes its state reactively with bound actions. */ export declare function createChartEditor(controllerOrOptions?: ChartController | ChartControllerOptions): SvelteChartEditor; /** Reactive state of a (possibly replaced) controller prop, for use inside components. */ export declare function chartStateOf(getController: () => ChartController): { readonly current: ChartState; }; /** Anything with `register(specs) → unregister` (a `CommandRegistry`). */ export interface ChartCommandTarget { register(specs: any): () => void; } /** * Registers the controller's palette / agent commands (`chart.describe`, `chart.update`, * `chart.setValues`, …) for the lifetime of the calling component (call it during * initialisation). Pass a getter to follow a changing registry. */ export declare function useChartCommands(registry: ChartCommandTarget | null | undefined | (() => ChartCommandTarget | null | undefined), controller: ChartController, options?: ChartCommandOptions): void; /** `useChartToolProvider` options: `rasterize` defaults to a canvas rasterizer in the browser (`false` turns PNG off). */ export type ChartToolProviderHookOptions = Omit & { rasterize?: ChartToolProviderOptions["rasterize"] | false; }; /** * Registers the chart's agent tools (`createChartToolProvider`) with a `ToolRegistry` for the * lifetime of the calling component. Pass a getter to follow a changing registry. In the * browser, `render_chart { format: "png" }` works out of the box (`createChartRasterizer`). */ export declare function useChartToolProvider(registry: ToolRegistry | null | undefined | (() => ToolRegistry | null | undefined), controller: ChartController, options?: ChartToolProviderHookOptions): void; /** * Registers the Office-file chart tools (`createOfficeChartToolProvider`: `list_file_charts`, * `get_file_chart`, and `load_file_chart` with a `controller`) for the lifetime of the calling * component. Pass a getter to follow a changing registry. */ export declare function useOfficeChartToolProvider(registry: ToolRegistry | null | undefined | (() => ToolRegistry | null | undefined), options?: OfficeChartToolProviderOptions): void; /** * A `ChartPresence` and `ChartDirector` for a chart: pass `presence` and `sceneRef` to * `ChartCanvas`, and `director` to `useChartToolProvider` so agent edits are acted out with a * cursor. */ export declare function createChartDirector(controller: ChartController, options?: { speed?: number; size?: { width: number; height: number; }; }): { presence: ChartPresence; director: ChartDirector; sceneRef: { current: ChartScene | null; }; };