import { Action, ListItem, ListRenderFunction, TemplateExports } from './type/index.js'; export { DocIndex, DocTemplateArgs, DocTemplateExport, Feature, FilePayload, FilesAction, FilesMatchCmd, FilesPayload, ImageAction, ImageMatchCmd, ListTemplateArgs, ListTemplateExport, NoneTemplateArgs, NoneTemplateExport, OverMatchCmd, Platform, RegexMatchCmd, StringAction, TemplateExport, WindowAction, WindowMatchCmd, WindowPayload } from './type/index.js'; declare function isUTools(): boolean; declare function isBrowser(): boolean; /** * 隐藏并退出当前 uTools 插件 */ declare function hideAndOutPlugin(): void; type KeyFn = (item: T, index: number) => K; type ValFn = (item: T, index: number) => V; /** * 将数组转为哈希表,自定义生成键 */ declare function toMap(arr: V[], keyFn: KeyFn): Map; /** * 将数组转为哈希表,自定义生成键和值 */ declare function toMap(arr: T[], keyFn: KeyFn, valFn: ValFn): Map; /** * 搜索器 */ type Searcher = (item: T, word: string) => boolean; /** * 实体搜索器 */ declare function entitySearcher(keys: Array): Searcher; /** * 关键词搜索,忽略大小写搜索指定对象属性的值 */ declare function searchList(list: Array, word: string, searcher: Searcher): T[]; /** * 多关键词搜索,忽略大小写搜索指定对象属性的值 */ declare function searchList(list: Array, words: string[], searcher: Searcher): T[]; interface PinyinMatchOptions { /** * 匹配时按字母小写、大写、不敏感匹配 * @default "lower" */ case?: 'lower' | 'upper' | 'sensitive'; /** * 拼音分隔符,仅在 `pinyin` 为 `string` 时生效 * @default " " */ separator?: string; } interface PinyinMatchResult { /** * 匹配到相对 `pinyin` 的起始下标 */ from: number; /** * 匹配到相对 `pinyin` 的结束下标 */ to: number; } /** * 匹配目标串拼音 * @param pinyin 目标串拼音 * @param pattern 模式串 * @param options 选项 */ declare function pinyinMatch(pinyin: string[] | string, pattern: string, options?: PinyinMatchOptions): PinyinMatchResult | null; interface Storable { get(key: string): T | null; get(key: string, defaultVal: T): T; like(prefix: string): T[]; set(key: string, value: any): void; remove(key: string): void; } declare abstract class AbstractStorage implements Storable { get(key: string, defaultVal?: T): T | null; protected abstract getItem(key: string): T | null; abstract like(prefix: string): T[]; abstract set(key: string, value: any): void; abstract remove(key: string): void; } declare class BrowserStorageAdapter extends AbstractStorage { private storage; constructor(storage: Storage); protected getItem(key: string): T | null; like(prefix: string): T[]; set(key: string, value: any): void; remove(key: string): void; } /** * 同步存储,在所有设备上同步 */ declare const sync: Storable; /** * 本地存储,只在本机同步 */ declare const local: Storable; interface Template { code: string; } /** * 无 UI 模板 */ interface NoneTemplate extends Template { /** * 进入插件时调用 */ enter(action: Action): void; } interface ListTemplate extends Template { /** * 输入框占位符 * @default "搜索" */ placeholder?: string; /** * 输入框改变时调用。 * * 如果不实现该方法,则会使用 `searchWord`,忽略大小写搜索字段 `title` 和 `description`。参见 {@link search} 方法 */ search?(action: Action, searchWord: string, render: ListRenderFunction): void; } interface ImmutableListItem extends ListItem { /** * 选中当前项的处理函数 */ handler: (action: Action) => void; } /** * 不可变列表模板,列表项是固定的 */ interface ImmutableListTemplate extends ListTemplate { list: Array; } /** * 可变列表模板,列表项是动态的 */ interface MutableListTemplate extends ListTemplate { /** * 存放初始动态列表数据,默认搜索使用到,在 `enter` 中调用 `render` 函数时会刷新。在实现类中定义后可直接使用,也可以忽略 */ $list?: Array; /** * 进入插件时调用 */ enter?(action: Action, render: ListRenderFunction): void; /** * 使用回车键选择某项时调用 */ select(action: Action, item: ListItem): void; } /** * 关键词搜索,忽略大小写搜索 `title` 和 `description` */ declare function searchListItems(listItems: Array, word: string): ListItem[]; declare class TemplateBuilder { private readonly exports; /** * 根据无 UI 模板构建 * @param templates 无 UI 模板 */ none(...templates: Array): this; /** * 根据不可变列表模板构建 * @param templates 不可变列表模板,列表项是固定的 */ immutableList(...templates: Array): this; /** * 根据可变列表模板构建 * @param templates 可变列表模板,列表项是动态的 */ mutableList(...templates: Array): this; /** * 获取构建结果 */ build(): TemplateExports; } /** * 模板构建器 */ declare function templateBuilder(): TemplateBuilder; export { AbstractStorage, Action, BrowserStorageAdapter, ImmutableListItem, ImmutableListTemplate, ListItem, ListRenderFunction, MutableListTemplate, NoneTemplate, PinyinMatchOptions, PinyinMatchResult, Searcher, Storable, TemplateExports, entitySearcher, hideAndOutPlugin, isBrowser, isUTools, local, pinyinMatch, searchList, searchListItems, sync, templateBuilder, toMap };