@polyipseity/obsidian-plugin-library
Version:
Library for Obsidian plugins.
34 lines • 1.5 kB
TypeScript
import type { DeepReadonly } from "ts-essentials";
import { EventEmitterLite } from "./util.js";
import { ListModal } from "./modals.js";
import type { PluginContext } from "./plugin.js";
export type Rule = NormalRule | ErrorRule;
export interface NormalRule {
readonly type: "-" | "+";
readonly value: RegExp;
}
export interface ErrorRule {
readonly type: "error";
readonly value: unknown;
}
type Rules0 = readonly Rule[];
export interface Rules extends Rules0 {
}
export declare namespace Rules {
function parse(strings: readonly string[], interpreter?: typeof identityInterpreter): Rules;
function test(rules: Rules, str: string): boolean;
function identityInterpreter(str: string): RegExp;
function pathInterpreter(str: string): RegExp;
}
export declare class SettingRules<S extends PluginContext.Settings> {
protected readonly context: PluginContext<S>;
protected readonly accessor: (setting: DeepReadonly<S>) => readonly string[];
protected readonly interpreter?: ((str: string) => RegExp) | undefined;
rules: Rules;
readonly onChanged: EventEmitterLite<readonly []>;
constructor(context: PluginContext<S>, accessor: (setting: DeepReadonly<S>) => readonly string[], interpreter?: ((str: string) => RegExp) | undefined);
test(str: string): boolean;
}
export declare function rulesList(context: PluginContext, data: readonly string[], options?: ListModal.Options<string>): ListModal<string>;
export {};
//# sourceMappingURL=rules.d.ts.map