@polyipseity/obsidian-plugin-library
Version:
Library for Obsidian plugins.
65 lines • 3.86 kB
TypeScript
import { type Command, Component, type DataAdapter, type FrontMatterCache, Notice, Plugin, type PluginManifest, Setting, type View, type ViewStateResult } from "obsidian";
import type { AsyncOrSync } from "ts-essentials";
import type { PluginContext } from "./plugin.js";
export declare class LambdaComponent extends Component {
protected readonly onLoad: (this: LambdaComponent) => void;
protected readonly onUnload: (this: LambdaComponent) => void;
constructor(onLoad?: (this: LambdaComponent) => void, onUnload?: (this: LambdaComponent) => void);
onload(): void;
onunload(): void;
}
export declare abstract class ResourceComponent<T> extends Component {
#private;
protected static readonly sentinel: unique symbol;
get onLoaded(): Promise<T>;
get value(): T;
protected set value(value: T);
onload(): void;
protected abstract load0(): AsyncOrSync<T>;
}
export interface StatusUI {
readonly report: (status?: unknown) => void;
}
export declare class UpdatableUI {
#private;
new<V>(create: () => V, configure: ((value: V) => void) | null, destroy: ((value: V) => void) | null): this;
newSetting(element: HTMLElement, configure: (setting: Setting) => void): this;
finally(finalizer: () => void): this;
embed<U extends this>(create: () => U, configure?: ((ele: U) => void) | null, destroy?: ((ele: U) => void) | null): this;
update(): void;
destroy(): void;
}
export declare function statusUI(ui: UpdatableUI, element: HTMLElement): StatusUI;
export declare class UnnamespacedID<V extends string> {
readonly id: V;
constructor(id: V);
namespaced(context: Plugin | PluginManifest): string;
}
type AddCommandPredefinedOptions = {
readonly [K in "name"]: Command[K];
};
export declare function addCommand(context: PluginContext, name: () => string, command: Readonly<Omit<Command, keyof AddCommandPredefinedOptions>>): Command;
export declare function addRibbonIcon(context: PluginContext, id: string, icon: string, title: () => string, callback: (event: MouseEvent) => unknown): void;
export declare function awaitCSS(element: HTMLElement): Promise<void>;
export declare namespace awaitCSS {
const CLASS = "obsidian-plugin-library:await-css";
}
export declare function cleanFrontmatterCache(cache?: FrontMatterCache): Readonly<Record<string, unknown>>;
export declare function commandNamer(cmdNamer: () => string, pluginNamer: () => string, defaultPluginName: string, format: string): () => string;
export declare function printMalformedData(context: PluginContext, actual: unknown, expected?: unknown): void;
export declare function newCollaborativeState(context: Plugin | PluginManifest, states: ReadonlyMap<UnnamespacedID<string>, unknown>): unknown;
export declare function notice(message: () => DocumentFragment | string, timeout?: number, context?: PluginContext): Notice;
export declare function notice2(message: () => DocumentFragment | string, timeout?: number, context?: PluginContext): Notice;
export declare function printError(error: Error, message?: () => string, context?: PluginContext): void;
export declare function readStateCollaboratively(implType: string, state: unknown): unknown;
export declare function recordViewStateHistory(context: PluginContext, result: ViewStateResult): void;
export declare function saveFileAs(context: PluginContext, adapter: DataAdapter, data: File): Promise<void>;
export declare function updateView(context: PluginContext, view: View): void;
export declare function useSettings(element: HTMLElement): {
readonly element: HTMLElement;
readonly remover: () => void;
};
export declare function useSubsettings(element: HTMLElement): HTMLElement;
export declare function writeStateCollaboratively(state: unknown, implType: string, implState: unknown): unknown;
export {};
//# sourceMappingURL=obsidian.d.ts.map