Files
fuc-new/doc/node_modules/vuepress-plugin-md-power/lib/node/index.d.ts
T
hellcat 6adbc04d4b 1
2025-10-03 17:17:08 +08:00

567 lines
15 KiB
TypeScript

import Token from "markdown-it/lib/token.mjs";
import { App } from "vuepress";
import { Markdown, MarkdownEnv } from "vuepress/markdown";
import { BuiltinTheme, ThemeRegistration } from "shiki";
import "markdown-it";
import { Plugin } from "vuepress/core";
//#region src/shared/caniuse.d.ts
type CanIUseMode = "embed" | "image";
interface CanIUseTokenMeta {
feature: string;
mode: CanIUseMode;
versions: string;
}
interface CanIUseOptions {
/**
* 嵌入模式
*
* embed 通过iframe嵌入,提供可交互视图
*
* image 通过图片嵌入,静态
*
* @default 'embed'
*/
mode?: CanIUseMode;
}
//#endregion
//#region src/shared/size.d.ts
interface SizeOptions {
width?: string;
height?: string;
ratio?: number | string;
}
//#endregion
//#region src/shared/codepen.d.ts
interface CodepenTokenMeta extends SizeOptions {
title?: string;
user?: string;
slash?: string;
tab?: string;
theme?: string;
preview?: boolean;
editable?: boolean;
}
//#endregion
//#region src/shared/codeSandbox.d.ts
interface CodeSandboxTokenMeta extends SizeOptions {
user?: string;
id?: string;
layout?: string;
type?: "button" | "embed";
title?: string;
filepath?: string;
navbar?: boolean;
console?: boolean;
}
//#endregion
//#region src/shared/codeTabs.d.ts
interface CodeTabsOptions {
icon?: boolean | {
named?: false | string[];
extensions?: false | string[];
};
}
//#endregion
//#region src/shared/demo.d.ts
interface DemoFile {
type: "vue" | "normal" | "css" | "markdown";
export?: string;
path: string;
gitignore?: boolean;
}
interface MarkdownDemoEnv extends MarkdownEnv {
demoFiles?: DemoFile[];
}
interface DemoMeta {
type: "vue" | "normal" | "markdown";
url: string;
title?: string;
desc?: string;
codeSetting?: string;
expanded?: boolean;
}
interface DemoContainerRender {
before: (app: App, md: Markdown, env: MarkdownDemoEnv, meta: DemoMeta, codeMap: Record<string, string>) => string;
after: () => string;
token?: (token: Token, tokens: Token[], index: number) => void;
}
//#endregion
//#region src/shared/fileTree.d.ts
type FileTreeIconMode = "simple" | "colored";
interface FileTreeOptions {
icon?: FileTreeIconMode;
}
//#endregion
//#region src/shared/icon.d.ts
type IconOptions = IconifyProvider | IconFontProvider | FontAwesomeProvider;
interface IconProviderBase {
/**
* The provider of the icon
*
* 图标提供商
* @default 'iconify'
*/
provider?: "iconify" | "iconfont" | "fontawesome";
/**
* The size of the icon
* @default '1em'
*/
size?: string | number;
/**
* The color of the icon
* @default 'currentColor'
*/
color?: string;
}
interface IconFontProvider extends IconProviderBase {
provider?: "iconfont";
/**
* The prefix of the iconfont
* @default 'iconfont icon-'
*/
prefix?: string;
/**
* The assets of the iconfont
*/
assets?: IconAssetLink | IconAssetLink[];
}
interface FontAwesomeProvider extends IconProviderBase {
provider?: "fontawesome";
/**
* The prefix of the fontawesome icon
* @default 'fas'
*/
prefix?: LiteralUnion<FontAwesomePrefix>;
/**
* The assets of the fontawesome
* @default 'fontawesome'
*/
assets?: FontAwesomeAssetBuiltIn | IconAssetLink | (IconAssetLink | FontAwesomeAssetBuiltIn)[];
}
interface IconifyProvider extends IconProviderBase {
provider?: "iconify";
/**
* The prefix of the icon
* @default ''
*/
prefix?: LiteralUnion<IconifyPrefix>;
}
type FontAwesomeAssetBuiltIn = "fontawesome" | "fontawesome-with-brands";
type IconAssetLink = `//${string}` | `//${string}` | `https://${string}` | `http://${string}`;
type FontAwesomePrefix = "fas" | "s" | "far" | "r" | "fal" | "l" | "fat" | "t" | "fads" | "ds" | "fass" | "ss" | "fasr" | "sr" | "fasl" | "sl" | "fast" | "st" | "fasds" | "sds" | "fab" | "b";
type IconifyPrefix = "material-symbols" | "material-symbols-light" | "ic" | "mdi" | "mdi-light" | "line-md" | "solar" | "tabler" | "hugeicons" | "mingcute" | "ri" | "mynaui" | "iconamoon" | "iconoir" | "lucide" | "lucide-lab" | "uil" | "tdesign" | "si" | "bx" | "bxs" | "majesticons" | "gg" | "flowbite" | "basil" | "pixelarticons" | "pixel" | "akar-icons" | "ci" | "proicons" | "typcn" | "meteor-icons" | "prime" | "circum" | "fe" | "eos-icons" | "bitcoin-icons" | "humbleicons" | "uim" | "uit" | "uis" | "gridicons" | "mi" | "cuida" | "weui" | "duo-icons" | "svg-spinners" | "lets-icons" | "mage" | "stash" | "lineicons" | "icon-park-outline" | "icon-park-solid" | "icon-park-twotone" | "jam" | "guidance" | "carbon" | "ion" | "famicons" | "ant-design" | "lsicon" | "gravity-ui" | "cil" | "ep" | "charm" | "quill" | "bytesize" | "bi" | "rivet-icons" | "nimbus" | "formkit" | "fluent" | "ph" | "teenyicons" | "clarity" | "ix" | "octicon" | "memory" | "system-uicons" | "radix-icons" | "zondicons" | "uiw" | "maki" | "codex" | "ei" | "heroicons" | "pepicons-pop" | "pepicons-print" | "pepicons-pencil" | "f7" | "pajamas" | "garden" | "streamline" | "fa6-solid" | "fa6-regular" | "picon" | "ooui" | "oui" | "nrk" | "qlementine-icons" | "fluent-color" | "icon-park" | "marketeq" | "vscode-icons" | "codicon" | "material-icon-theme" | "file-icons" | "devicon" | "devicon-plain" | "catppuccin" | "skill-icons" | "unjs" | "simple-icons" | "logos" | "cib" | "fa6-brands" | "bxl" | "nonicons" | "arcticons" | "cbi" | "brandico" | "entypo-social" | "token" | "token-branded" | "cryptocurrency" | "cryptocurrency-color" | "openmoji" | "twemoji" | "noto" | "fluent-emoji" | "fluent-emoji-flat" | "fluent-emoji-high-contrast" | "noto-v1" | "emojione" | "emojione-monotone" | "emojione-v1" | "fxemoji" | "streamline-emojis" | "circle-flags" | "flag" | "flagpack" | "cif" | "gis" | "map" | "geo" | "game-icons" | "fad" | "academicons" | "wi" | "meteocons" | "healthicons" | "medical-icon" | "covid" | "la" | "eva" | "dashicons" | "flat-color-icons" | "entypo" | "foundation" | "raphael" | "icons8" | "iwwa" | "gala" | "heroicons-outline" | "heroicons-solid" | "fa-solid" | "fa-regular" | "fa-brands" | "fa" | "fluent-mdl2" | "fontisto" | "icomoon-free" | "subway" | "oi" | "wpf" | "simple-line-icons" | "et" | "el" | "vaadin" | "grommet-icons" | "whh" | "si-glyph" | "zmdi" | "ls" | "bpmn" | "flat-ui" | "vs" | "topcoat" | "il" | "websymbol" | "fontelico" | "ps" | "feather" | "mono-icons" | "pepicons";
type LiteralUnion<Union extends Base, Base = string> = Union | (Base & {
zz_IGNORE_ME?: never;
});
//#endregion
//#region src/shared/jsfiddle.d.ts
interface JSFiddleTokenMeta extends SizeOptions {
source: string;
title?: string;
theme?: string;
tab?: string;
}
//#endregion
//#region src/shared/npmTo.d.ts
type NpmToPackageManager = "npm" | "pnpm" | "yarn" | "bun" | "deno";
type NpmToOptions = NpmToPackageManager[] | {
tabs?: NpmToPackageManager[];
};
//#endregion
//#region src/shared/pdf.d.ts
type PDFEmbedType = "iframe" | "embed" | "pdfjs";
interface PDFTokenMeta extends SizeOptions {
page?: number;
noToolbar?: boolean;
zoom?: number;
src?: string;
title?: string;
}
interface PDFOptions {
/**
* pdfjs url
*/
pdfjsUrl?: string;
}
//#endregion
//#region src/shared/plot.d.ts
/**
* 是否启用 `!! !!` markdown (该标记为非标准标记,脱离插件将不生效)
*/
interface PlotOptions {
/**
* 触发方式
*
* @default 'hover'
*/
trigger?: "hover" | "click";
/**
* 遮罩层效果
*
* @default 'mask'
*/
effect?: "mask" | "blur";
}
//#endregion
//#region src/shared/codeTree.d.ts
interface CodeTreeOptions {
icon?: FileTreeIconMode;
height?: string | number;
}
//#endregion
//#region src/shared/repl.d.ts
type ThemeOptions = BuiltinTheme | {
light: BuiltinTheme;
dark: BuiltinTheme;
};
interface ReplOptions {
theme?: ThemeOptions;
go?: boolean;
kotlin?: boolean;
rust?: boolean;
python?: boolean;
}
interface ReplEditorData {
grammars: {
go?: any;
kotlin?: any;
rust?: any;
python?: any;
};
theme: ThemeRegistration | {
light: ThemeRegistration;
dark: ThemeRegistration;
};
}
//#endregion
//#region src/shared/table.d.ts
interface TableContainerOptions {
/**
* 表格对齐方式
* - 'left': 左对齐
* - 'center': 居中对齐
* - 'right': 右对齐
*
* @default 'left'
*/
align?: "left" | "center" | "right";
/**
* 表格复制
* - true: 等同于 `all`,支持复制为 html 和 markdown 格式
* - 'all': 支持复制为 html 和 markdown 格式
* - 'html': 只支持复制为 html 格式
* - 'md': 只支持复制为 markdown 格式
* - `false`: 禁用复制
*
* @default true
*/
copy?: boolean | "all" | "html" | "md";
/**
* 表格宽度是否为最大内容宽度
*
* 最大内容宽度时,行内元素不再自动换行,超出容器宽度时表格显示滚动条
*
* @default false
*/
maxContent?: boolean;
}
//#endregion
//#region src/shared/plugin.d.ts
interface MarkdownPowerPluginOptions {
/**
* 是否启用注释
* @default false
*/
annotation?: boolean;
/**
* 是否启用 abbr 语法
* @default false
*/
abbr?: boolean;
/**
* 配置代码块分组
*/
codeTabs?: CodeTabsOptions;
/**
* 是否启用 npm-to 容器
*/
npmTo?: boolean | NpmToOptions;
/**
* 是否启用 PDF 嵌入语法
*
* `@[pdf](pdf_url)`
*
* @default false
*/
pdf?: boolean | PDFOptions;
/**
* 是否启用 图标支持
* - iconify - `::collect:icon_name::` => `<VPIcon name="collect:icon_name" />`
* - iconfont - `::name::` => `<i class="iconfont icon-name"></i>`
* - fontawesome - `::fas:name::` => `<i class="fa-solid fa-name"></i>`
*
* @default false
*/
icon?: IconOptions;
/**
* 是否启用 iconify 图标嵌入语法
*
* `::collect:icon_name::`
*
* @default false
* @deprecated use `icon` instead 该配置已弃用,请使用 `icon` 代替
*/
icons?: boolean | IconOptions;
/**
* 是否启用 隐秘文本 语法
*
* `!!plot_content!!`
*
* @default false
*/
plot?: boolean | PlotOptions;
/**
* 是否启用 timeline 语法
*
* ```md
* ::: timeline
* - title
* time="Q1" icon="ri:clockwise-line" line="dashed" type="warning" color="red"
*
* xxx
* :::
* ```
*
* @default false
*/
timeline?: boolean;
/**
* 是否启用 collapse 折叠面板 语法
*
* ```md
* ::: collapse accordion
* - + title
*
* content
*
* - - title
*
* content
* :::
* ```
*
* @default false
*/
collapse?: boolean;
/**
* 是否启用 chat 容器 语法
*
* ```md
* ::: chat
* {:date}
*
* {user}
* message
*
* {.}
* message
* :::
* ```
* @default false
*/
chat?: boolean;
/**
* 是否启用 field / field-group 容器
*
* @default false
*/
field?: boolean;
/**
* 是否启用 acfun 视频嵌入
*
* `@[acfun](acid)`
*
* @default false
*/
acfun?: boolean;
/**
* 是否启用 bilibili 视频嵌入
*
* `@[bilibili](bid)`
*
* @default false
*/
bilibili?: boolean;
/**
* 是否启用 youtube 视频嵌入
*
* `@[youtube](video_id)`
*
* @default false
*/
youtube?: boolean;
/**
* 是否启用 artPlayer 视频嵌入
*
* `@[artPlayer](url)`
*/
artPlayer?: boolean;
/**
* 是否启用 audioReader 音频嵌入
*
* `@[audioReader](url)`
*/
audioReader?: boolean;
/**
* 是否启用 codepen 嵌入
*
* `@[codepen](pen_id)`
*
* @default false
*/
codepen?: boolean;
/**
* @deprecated
*/
replit?: boolean;
/**
* 是否启用 codeSandbox 嵌入
*
* `@[codesandbox](codesandbox_id)`
*
* @default false
*/
codeSandbox?: boolean;
/**
* 是否启用 jsfiddle 嵌入
*
* `@[jsfiddle](jsfiddle_id)`
*
* @default false
*/
jsfiddle?: boolean;
/**
* 是否启用 REPL 容器语法
*
* @default false
*/
repl?: false | ReplOptions;
/**
* 是否启用 文件树 容器语法
*
* @default false
*/
fileTree?: boolean | FileTreeOptions;
/**
* 是否启用 代码树 容器语法 和 嵌入语法
*
* ```md
* ::: code-tree
* :::
* ```
*
* `@[code-tree](file_path)`
*
*
* @default false
*/
codeTree?: boolean | CodeTreeOptions;
/**
* 是否启用 demo 语法
*/
demo?: boolean;
/**
* 是否启用 caniuse 嵌入语法
*
* `@[caniuse](feature_name)`
*
* @default false
*/
caniuse?: boolean | CanIUseOptions;
/**
* 是否启用 table 容器语法,为表格提供增强功能
*
* - `copy`: 是否启用复制功能,支持复制为 html 格式 和 markdown 格式
*
* @default false
*/
table?: boolean | TableContainerOptions;
/**
* 是否启用 自动填充 图片宽高属性
*
* __请注意,无论是否启用,该功能仅在构建生产包时生效__
*
* - 如果为 `true` ,等同于 `'local'`
* - 如果为 `local`,则仅对本地图片 添加 width 和 height
* - 如果为 `all`,则对所有图片(即包括 本地 和 远程) 添加 width 和 height
*
* 图片在加载过程中如果比较慢,从加载到完成的过程会导致页面布局不稳定,导致内容闪烁等。
* 此功能通过给图片添加 `width` 和 `height` 属性来解决该问题。
*
* 请谨慎使用 `all` 选项,该选项会在构建阶段发起网络请求,尝试加载远程图片以获取图片尺寸信息,
* 这可能会导致 构建时间变得更长(幸运的是获取尺寸信息只需要加载图片 几 KB 的数据包,因此耗时不会过长)
*
* @default false
*/
imageSize?: boolean | "local" | "all";
}
//#endregion
//#region src/shared/replit.d.ts
interface ReplitTokenMeta extends SizeOptions {
title?: string;
source?: string;
theme?: string;
}
//#endregion
//#region src/shared/video.d.ts
interface VideoOptions {
bilibili?: boolean;
youtube?: boolean;
}
interface AcFunTokenMeta extends SizeOptions {
title?: string;
id: string;
}
interface BilibiliTokenMeta extends SizeOptions {
title?: string;
bvid?: string;
aid?: string;
cid?: string;
autoplay?: boolean;
time?: string | number;
page?: number;
}
interface YoutubeTokenMeta extends SizeOptions {
title?: string;
id: string;
autoplay?: boolean;
loop?: boolean;
start?: string | number;
end?: string | number;
}
interface ArtPlayerTokenMeta extends SizeOptions {
muted?: boolean;
autoplay?: boolean;
autoMini?: boolean;
loop?: boolean;
volume?: number;
poster?: string;
url: string;
type?: string;
}
//#endregion
//#region src/node/container/codeTabs.d.ts
declare function createCodeTabIconGetter(options?: CodeTabsOptions): (filename: string) => string | void;
//#endregion
//#region src/node/enhance/imageSize.d.ts
interface ImgSize {
width: number;
height: number;
}
declare function resolveImageSize(app: App, url: string, remote?: boolean): Promise<ImgSize>;
//#endregion
//#region src/node/plugin.d.ts
declare function markdownPowerPlugin(options?: MarkdownPowerPluginOptions): Plugin;
//#endregion
export { AcFunTokenMeta, ArtPlayerTokenMeta, BilibiliTokenMeta, CanIUseMode, CanIUseOptions, CanIUseTokenMeta, CodeSandboxTokenMeta, CodeTabsOptions, CodepenTokenMeta, DemoContainerRender, DemoFile, DemoMeta, FileTreeIconMode, FileTreeOptions, FontAwesomeAssetBuiltIn, FontAwesomePrefix, FontAwesomeProvider, IconAssetLink, IconFontProvider, IconOptions, IconProviderBase, IconifyPrefix, IconifyProvider, JSFiddleTokenMeta, LiteralUnion, MarkdownDemoEnv, MarkdownPowerPluginOptions, NpmToOptions, NpmToPackageManager, PDFEmbedType, PDFOptions, PDFTokenMeta, PlotOptions, ReplEditorData, ReplOptions, ReplitTokenMeta, SizeOptions, ThemeOptions, VideoOptions, YoutubeTokenMeta, createCodeTabIconGetter, markdownPowerPlugin, resolveImageSize };