pub const JSEDITORAPI_TS_PREAMBLE: &str = "/**\n * Fresh Editor TypeScript Plugin API\n *\n * This file provides type definitions for the Fresh editor\'s TypeScript plugin system.\n * Plugins have access to the global `editor` object which provides methods to:\n * - Query editor state (buffers, cursors, viewports)\n * - Modify buffer content (insert, delete text)\n * - Add visual decorations (overlays, highlighting)\n * - Interact with the editor UI (status messages, prompts)\n *\n * AUTO-GENERATED FILE - DO NOT EDIT MANUALLY\n * Generated by fresh-plugin-api-macros + ts-rs from JsEditorApi impl\n */\n\n/**\n * Get the editor API instance.\n * Plugins must call this at the top of their file to get a scoped editor object.\n */\ndeclare function getEditor(): EditorAPI;\n\n/**\n * Register a function as a named handler on the global scope.\n *\n * Handler functions registered this way can be referenced by name in\n * `editor.registerCommand()`, `editor.on()`, and mode keybindings.\n *\n * The `fn` parameter is typed as `Function` because the runtime passes\n * different argument shapes depending on the caller: command handlers\n * receive no arguments, event handlers receive an event-specific data\n * object (e.g. `{ buffer_id: number }`), and prompt handlers receive\n * `{ prompt_type: string, input: string }`. Type-annotate your handler\n * parameters to match the event you are handling.\n *\n * @param name - Handler name (referenced by registerCommand, on, etc.)\n * @param fn - The handler function\n */\ndeclare function registerHandler(name: string, fn: Function): void;\n\n/** Handle for a cancellable async operation */\ninterface ProcessHandle<T> extends PromiseLike<T> {\n /** Promise that resolves to the result when complete */\n readonly result: Promise<T>;\n /** Cancel/kill the operation. Returns true if cancelled, false if already completed */\n kill(): Promise<boolean>;\n}\n\n/** Buffer identifier */\ntype BufferId = number;\n\n/** Split identifier */\ntype SplitId = number;\n\n/**\n * Payload delivered to handlers registered with `editor.on(\"mouse_click\", ...)`.\n *\n * All coordinate fields are in cell (terminal character) units. `buffer_*`\n * fields are `null` when the click did not land in any buffer panel.\n */\ninterface MouseClickHookArgs {\n /** Screen column (0-indexed). */\n column: number;\n /** Screen row (0-indexed). */\n row: number;\n /** Mouse button: \"left\", \"right\", \"middle\". */\n button: string;\n /** Modifier keys (e.g. \"shift\"). */\n modifiers: string;\n /** X offset of the content area the click landed in. */\n content_x: number;\n /** Y offset of the content area the click landed in. */\n content_y: number;\n /** Buffer under the click, or `null` when outside any buffer panel. */\n buffer_id: number | null;\n /** 0-indexed buffer row (line number) of the click, accounting for scroll. */\n buffer_row: number | null;\n /** 0-indexed byte column inside the buffer row. */\n buffer_col: number | null;\n}\n\n/**\n * Registry of typed plugin APIs surfaced through\n * `editor.exportPluginApi` / `editor.getPluginApi`.\n *\n * Plugins that want their surface to be typed for downstream\n * consumers augment this interface in their own source:\n *\n * ```ts\n * // in my_plugin.ts\n * export type MyPluginApi = { doThing(): void };\n * declare global {\n * interface FreshPluginRegistry {\n * \"my-plugin\": MyPluginApi;\n * }\n * }\n * ```\n *\n * `editor.getPluginApi(\"my-plugin\")` then returns\n * `MyPluginApi | null` without any `as`-cast on the consumer side.\n * Plugins that skip the augmentation still work \u{2014} the untyped\n * `getPluginApi<T = unknown>(name: string): T | null` overload\n * takes over.\n *\n * Each plugin\'s augmentation is emitted to\n * `<config_dir>/types/plugins.d.ts` at load time (via oxc\'s\n * isolated-declarations), so init.ts sees every loaded plugin\'s\n * registry entry automatically.\n */\ninterface FreshPluginRegistry {}\n\n";Expand description
TypeScript preamble (header, getEditor, ProcessHandle, BufferId, SplitId)
Combine with ts-rs types and EDITOR_API to create fresh.d.ts