/** * @file * * Generates a JavaScript expression that calls a serialized function with serialized arguments. */ import type { App } from 'obsidian'; import type { Promisable } from 'type-fest'; /** * Parameters with `ensureLayoutReady` function. */ export interface EnsureLayoutReadyParams { /** * Waits for the Obsidian workspace layout to be ready. * * @param params - Parameters including the `app` instance. * @returns A promise that resolves when the layout is ready. */ readonly ensureLayoutReady: (params: GenerateFunctionCallParams) => Promise; } /** * Parameters for `generateFunctionCall`. * * @typeParam Params - The type of the additional parameters to pass to the function being called. */ export type GenerateFunctionCallParams = AppParams & Params; /** * Parameters for {@link generateNamespaceCall}. */ export interface GenerateNamespaceCallParams { /** The user function to evaluate inside Obsidian. */ readonly callback: (...input: never[]) => unknown; /** Optional context ID for persistent storage. */ readonly contextId?: string; /** User-supplied arguments to pass to the function. */ readonly input?: Record; } interface AppParams { readonly app: App; } /** * Generates a JavaScript expression string that immediately invokes the given * function with the given arguments. * * The function is serialized via {@link getFunctionExpressionString} and the * arguments are serialized via {@link jsonWithFunctions}, producing a * self-contained IIFE of the form `(fnExpr)(argsExpr)`. * * @param callback - The function to call. * @param params - The arguments to pass. When omitted, the function is called with no arguments. * @returns A JavaScript expression string. */ /** * Waits for the Obsidian workspace layout to be ready. * * @param params - The parameters, including the `app` instance. * @returns A promise that resolves when the layout is ready. */ export declare function ensureLayoutReady(params: GenerateFunctionCallParams): Promise; /** * Generates a JavaScript expression string that immediately invokes the given * function with the given arguments. * * @param callback - The function to call. * @param params - The arguments to pass. * @returns A JavaScript expression string. */ export declare function generateFunctionCall(callback: (params: GenerateFunctionCallParams) => Promisable, params: Params): string; /** * Generates a lightweight JavaScript expression that calls the pre-registered * `evalWrapper` on the `window.__obsidianIntegrationTesting` namespace. * * Unlike {@link generateFunctionCall}, this does not serialize infrastructure * functions — only the user's `callback`, `input`, and `contextId`. The infrastructure * must already be bootstrapped via {@link ensureNamespaceBootstrapped}. * * @param params - The user function, arguments, and optional context ID. * @returns A JavaScript expression string. */ export declare function generateNamespaceCall(params: GenerateNamespaceCallParams): string; export {};