Skip to main content

plugin_api_impl

Attribute Macro plugin_api_impl 

Source
#[plugin_api_impl]
Expand description

Generate TypeScript definitions from a QuickJS impl block

§Generated Constants

  • {IMPL_NAME}_TS_PREAMBLE: &str - Header comment + getEditor + ProcessHandle + BufferId/SplitId
  • {IMPL_NAME}_TS_EDITOR_API: &str - Just the EditorAPI interface with methods
  • {IMPL_NAME}_JS_METHODS: &[&str] - List of all JS method names

The main crate should combine these with ts-rs generated types to create fresh.d.ts.

§Example

#[plugin_api_impl]
#[rquickjs::methods(rename_all = "camelCase")]
impl JsEditorApi {
    /// Get the active buffer ID
    pub fn get_active_buffer_id(&self) -> u32 { ... }

    /// Spawn a process (cancellable)
    #[plugin_api(async_thenable, js_name = "spawnProcess", ts_return = "SpawnResult")]
    #[qjs(rename = "_spawnProcessStart")]
    pub fn spawn_process_start(&self, cmd: String) -> u64 { ... }
}

§Errors

Compile-time error if applied to non-impl items.