Skip to main content

JSEDITORAPI_TS_PREAMBLE

Constant JSEDITORAPI_TS_PREAMBLE 

Source
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";
Expand description

TypeScript preamble (header, getEditor, ProcessHandle, BufferId, SplitId)

Combine with ts-rs types and EDITOR_API to create fresh.d.ts