/** * @file * * Shared helper for enabling an Obsidian plugin with error capture. * Used by both the global setup and integration tests. */ import type { CommonArguments } from './eval-in-obsidian.mjs'; /** * Parameters for {@link enablePluginWithErrorCapture}. */ export interface EnablePluginParams { /** * The ID of the plugin to enable. */ readonly pluginId: string; } /** * Result of enabling a plugin with error capture. */ export interface EnablePluginResult { /** * The error message captured by the `loadPlugin` monkey-patch, or `undefined` * when the patch saw no throw. When Obsidian swallows the error *before* the * patch (leaving this empty) but the plugin still failed to load, the real * cause — if it reached the renderer console — is in {@link EnablePluginResult.rendererConsoleErrors}. */ readonly errorMessage: string | undefined; /** * Whether the plugin is in the enabled set after the enable attempt. * A plugin can be "enabled" (configured) but not "loaded" (failed to initialize). */ readonly isEnabled: boolean; /** * Whether the plugin instance actually exists in `app.plugins.plugins`. * This is the definitive check — a plugin that is enabled but not loaded has failed. */ readonly isLoaded: boolean; /** * Console/error output captured in the renderer during the enable window — * populated **only** when the plugin failed to load and the monkey-patch saw * no throw (`!errorMessage && !isLoaded`), i.e. exactly the case that would * otherwise surface the generic {@link getGenericPluginLoadFailureMessage} text. * `undefined` otherwise (including on success and when {@link EnablePluginResult.errorMessage} already has the error). */ readonly rendererConsoleErrors: string | undefined; } /** * Enables a plugin inside Obsidian and captures any load error. * * Monkey-patches `app.plugins.loadPlugin` to intercept errors before * Obsidian's `enablePlugin` try-catch swallows them. The original method * is always restored in a `finally` block. * * Designed to be passed as the `callback` argument to {@link evalInObsidian}. * * @param input - The common input plus the plugin ID. * @param input.app - The Obsidian app instance. * @param input.pluginId - The ID of the plugin to enable. * @returns The enable result with error message and enabled status. */ export declare function enablePluginWithErrorCapture({ app, pluginId }: CommonArguments & EnablePluginParams): Promise; /** * The generic last-resort message shown when a plugin is in the enabled set but * not loaded and no real error could be captured (neither the `loadPlugin` * monkey-patch nor the renderer console nor, on Android, `adb logcat` surfaced a * cause). * * Host-side helper — used by the setup orchestration to compose the final * failure message, so the renderer-injected {@link enablePluginWithErrorCapture} * stays self-contained. * * @param pluginId - The ID of the plugin that failed to load. * @returns The generic failure message. */ export declare function getGenericPluginLoadFailureMessage(pluginId: string): string;