vitepress-allyouneed 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +61 -0
- package/LICENSE +25 -0
- package/README.md +157 -0
- package/dist/index.cjs +1489 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +95 -0
- package/dist/index.d.ts +95 -0
- package/dist/index.js +1441 -0
- package/dist/index.js.map +1 -0
- package/dist/markdown-it.cjs +800 -0
- package/dist/markdown-it.cjs.map +1 -0
- package/dist/markdown-it.d.cts +34 -0
- package/dist/markdown-it.d.ts +34 -0
- package/dist/markdown-it.js +763 -0
- package/dist/markdown-it.js.map +1 -0
- package/dist/types-CapUIPbW.d.cts +262 -0
- package/dist/types-CapUIPbW.d.ts +262 -0
- package/dist/vite.cjs +783 -0
- package/dist/vite.cjs.map +1 -0
- package/dist/vite.d.cts +30 -0
- package/dist/vite.d.ts +30 -0
- package/dist/vite.js +748 -0
- package/dist/vite.js.map +1 -0
- package/dist/vitepress.cjs +1468 -0
- package/dist/vitepress.cjs.map +1 -0
- package/dist/vitepress.d.cts +36 -0
- package/dist/vitepress.d.ts +36 -0
- package/dist/vitepress.js +1431 -0
- package/dist/vitepress.js.map +1 -0
- package/package.json +98 -0
- package/style.css +159 -0
|
@@ -0,0 +1,262 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* vitepress-allyouneed —— 公共类型定义
|
|
3
|
+
*
|
|
4
|
+
* 这里集中定义所有跨模块共享的数据结构。VaultIndex 是核心数据库,
|
|
5
|
+
* 后续 callouts / tags / dataview / graph 模块都从此处取数。
|
|
6
|
+
*/
|
|
7
|
+
/**
|
|
8
|
+
* 单个 Markdown 笔记的索引条目。
|
|
9
|
+
*/
|
|
10
|
+
interface FileEntry {
|
|
11
|
+
/** 绝对路径(POSIX 风格)*/
|
|
12
|
+
absolutePath: string;
|
|
13
|
+
/** 相对 srcDir 的路径,POSIX 风格,不带前导 './' */
|
|
14
|
+
relativePath: string;
|
|
15
|
+
/** 不含扩展名的文件名 */
|
|
16
|
+
basename: string;
|
|
17
|
+
/** 不含点的扩展名,已小写 */
|
|
18
|
+
extension: string;
|
|
19
|
+
/** 最终 VitePress 路由(已应用 base + cleanUrls)*/
|
|
20
|
+
url: string;
|
|
21
|
+
/** 解析后的 frontmatter 全量 */
|
|
22
|
+
frontmatter: Record<string, unknown>;
|
|
23
|
+
/** frontmatter.aliases 归一化后的字符串数组 */
|
|
24
|
+
aliases: string[];
|
|
25
|
+
/** frontmatter.tags + 正文 #tag(后者由 tag 模块填充,v0.1 只读 frontmatter)*/
|
|
26
|
+
tags: string[];
|
|
27
|
+
/** 该文件所有 heading */
|
|
28
|
+
headings: HeadingEntry[];
|
|
29
|
+
/** 修改时间(毫秒) */
|
|
30
|
+
mtime: number;
|
|
31
|
+
/** 文件大小(字节) */
|
|
32
|
+
size: number;
|
|
33
|
+
/** 原始正文(去掉 frontmatter 之后);transclusion 用 */
|
|
34
|
+
content: string;
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* 单个 asset(图片/视频/音频/PDF/canvas 等)的索引条目。
|
|
38
|
+
*/
|
|
39
|
+
interface AssetEntry {
|
|
40
|
+
absolutePath: string;
|
|
41
|
+
/** 相对 srcDir 的路径,POSIX 风格 */
|
|
42
|
+
relativePath: string;
|
|
43
|
+
basename: string;
|
|
44
|
+
/** 不含点的扩展名,已小写 */
|
|
45
|
+
extension: string;
|
|
46
|
+
mtime: number;
|
|
47
|
+
size: number;
|
|
48
|
+
/** 哪些页面引用了此 asset(绝对路径集合)。build 时只输出被引用的 */
|
|
49
|
+
referencedBy: Set<string>;
|
|
50
|
+
/** build 期间填充:在 dist/ 中的最终相对路径 */
|
|
51
|
+
outputPath?: string;
|
|
52
|
+
/** build 期间填充:最终公开 URL(可能带 hash)*/
|
|
53
|
+
publicUrl?: string;
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Markdown heading 信息。
|
|
57
|
+
*/
|
|
58
|
+
interface HeadingEntry {
|
|
59
|
+
/** 1-6 */
|
|
60
|
+
level: number;
|
|
61
|
+
/** 原始 heading 文本 */
|
|
62
|
+
text: string;
|
|
63
|
+
/** 用 VitePress 同款 slugifier 算出的 anchor ID */
|
|
64
|
+
slug: string;
|
|
65
|
+
/** 在源文件中的行号(0 起)*/
|
|
66
|
+
line: number;
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* 反向链接条目。用于 graph 模块和"反向链接卡片"展示。
|
|
70
|
+
*/
|
|
71
|
+
interface BacklinkEntry {
|
|
72
|
+
/** 源文件绝对路径 */
|
|
73
|
+
fromPath: string;
|
|
74
|
+
/** 源文件最终 URL */
|
|
75
|
+
fromUrl: string;
|
|
76
|
+
/** 链接周围 50 字上下文(供未来卡片展示)*/
|
|
77
|
+
context: string;
|
|
78
|
+
/** true = ![[]],false = [[]] */
|
|
79
|
+
isEmbed: boolean;
|
|
80
|
+
/** 在源文件中的行号(0 起,若无法确定为 -1)*/
|
|
81
|
+
line: number;
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* 扫描期间的告警条目。
|
|
85
|
+
*/
|
|
86
|
+
interface ScanWarning {
|
|
87
|
+
kind: 'duplicate-basename' | 'duplicate-alias' | 'invalid-frontmatter' | 'unreadable-file' | 'symlink-loop' | 'unknown';
|
|
88
|
+
message: string;
|
|
89
|
+
/** 受影响的绝对路径列表 */
|
|
90
|
+
affected: string[];
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* 完整的 Vault 数据库。所有模块通过此对象访问数据。
|
|
94
|
+
*/
|
|
95
|
+
interface VaultIndex {
|
|
96
|
+
files: Map<string, FileEntry>;
|
|
97
|
+
assets: Map<string, AssetEntry>;
|
|
98
|
+
byBasename: Map<string, FileEntry[]>;
|
|
99
|
+
byBasenameLower: Map<string, FileEntry[]>;
|
|
100
|
+
byAlias: Map<string, FileEntry>;
|
|
101
|
+
byRelativePath: Map<string, FileEntry>;
|
|
102
|
+
byUrl: Map<string, FileEntry>;
|
|
103
|
+
assetsByBasename: Map<string, AssetEntry[]>;
|
|
104
|
+
assetsByBasenameLower: Map<string, AssetEntry[]>;
|
|
105
|
+
assetsByRelativePath: Map<string, AssetEntry>;
|
|
106
|
+
tags: Map<string, FileEntry[]>;
|
|
107
|
+
backlinks: Map<string, BacklinkEntry[]>;
|
|
108
|
+
/** 文件绝对路径 → headings(冗余,headings 也存在 FileEntry 上,这里方便跨页查 slug)*/
|
|
109
|
+
headings: Map<string, HeadingEntry[]>;
|
|
110
|
+
srcDir: string;
|
|
111
|
+
base: string;
|
|
112
|
+
cleanUrls: boolean;
|
|
113
|
+
scannedAt: number;
|
|
114
|
+
warnings: ScanWarning[];
|
|
115
|
+
}
|
|
116
|
+
/**
|
|
117
|
+
* markdown-it 渲染 wikilink 时回调给用户的上下文。
|
|
118
|
+
*/
|
|
119
|
+
interface PageLinkAttrsContext {
|
|
120
|
+
originalHref: string;
|
|
121
|
+
label: string;
|
|
122
|
+
/** 解析到的目标 entry;死链时为 undefined */
|
|
123
|
+
target?: FileEntry;
|
|
124
|
+
isDead: boolean;
|
|
125
|
+
hasUnmatchedAnchor: boolean;
|
|
126
|
+
}
|
|
127
|
+
/**
|
|
128
|
+
* markdown-it 渲染 image embed 时回调给用户的上下文。
|
|
129
|
+
*/
|
|
130
|
+
interface ImageEmbedAttrsContext {
|
|
131
|
+
originalHref: string;
|
|
132
|
+
altText: string | undefined;
|
|
133
|
+
/** 'NxN' / 'Nx' / 'xN' / 'N' / '' */
|
|
134
|
+
dimensions: string;
|
|
135
|
+
embedType: 'image';
|
|
136
|
+
}
|
|
137
|
+
type PageLinkAttrs = Record<string, string> | ((ctx: PageLinkAttrsContext) => Record<string, string>);
|
|
138
|
+
type ImageEmbedAttrs = Record<string, string> | ((ctx: ImageEmbedAttrsContext) => Record<string, string>);
|
|
139
|
+
interface WikilinksModuleOptions {
|
|
140
|
+
/** 处理 raw target(pipe 之前的部分)*/
|
|
141
|
+
postProcessLinkTarget?: (target: string) => string;
|
|
142
|
+
/** 处理 label(pipe 之后的部分)*/
|
|
143
|
+
postProcessLinkLabel?: (label: string) => string;
|
|
144
|
+
/** 是否允许 label 走 inline markdown 解析。默认 false(安全) */
|
|
145
|
+
allowLinkLabelFormatting?: boolean;
|
|
146
|
+
/** 默认 label 来源 */
|
|
147
|
+
linkText?: 'basename' | 'fullPath' | ((entry: FileEntry, fallback: string) => string);
|
|
148
|
+
/** 额外的 <a> 属性 */
|
|
149
|
+
htmlAttributes?: PageLinkAttrs;
|
|
150
|
+
}
|
|
151
|
+
interface EmbedsModuleOptions {
|
|
152
|
+
/** 视为图片的扩展名(无点,小写)*/
|
|
153
|
+
imageFileExt?: string[];
|
|
154
|
+
/** 缺省 alt 文本策略 */
|
|
155
|
+
defaultAltText?: boolean | string;
|
|
156
|
+
/** 处理 image target */
|
|
157
|
+
postProcessImageTarget?: (imageTarget: string) => string;
|
|
158
|
+
/** 处理 alt text */
|
|
159
|
+
postProcessAltText?: (altText: string) => string;
|
|
160
|
+
/** image URL 后缀(例如 '?v=1')*/
|
|
161
|
+
uriSuffix?: string;
|
|
162
|
+
/** 额外的 <img> 属性 */
|
|
163
|
+
htmlAttributes?: ImageEmbedAttrs;
|
|
164
|
+
/** transclusion 最大递归深度,防失控。默认 8 */
|
|
165
|
+
transclusionMaxDepth?: number;
|
|
166
|
+
}
|
|
167
|
+
interface ScanOptions {
|
|
168
|
+
include?: string[];
|
|
169
|
+
exclude?: string[];
|
|
170
|
+
followSymlinks?: boolean;
|
|
171
|
+
respectGitignore?: boolean;
|
|
172
|
+
/** 视为 asset 的扩展名 */
|
|
173
|
+
assetExtensions?: string[];
|
|
174
|
+
}
|
|
175
|
+
interface AssetsOptions {
|
|
176
|
+
/** v0.1 只支持 'auto';future 可能加 'public-only' / 'vite-import' */
|
|
177
|
+
mode?: 'auto';
|
|
178
|
+
/** 是否保留原 vault 内相对路径而非扁平化 + hash。默认 false */
|
|
179
|
+
preserveAssetPaths?: boolean;
|
|
180
|
+
/** build 输出目录(在 base 之后,默认 '_assets/')*/
|
|
181
|
+
outputDir?: string;
|
|
182
|
+
}
|
|
183
|
+
/**
|
|
184
|
+
* 顶层选项。
|
|
185
|
+
*/
|
|
186
|
+
interface AllYouNeedOptions {
|
|
187
|
+
srcDir?: string;
|
|
188
|
+
base?: string;
|
|
189
|
+
cleanUrls?: boolean;
|
|
190
|
+
caseSensitive?: boolean;
|
|
191
|
+
deadLink?: 'silent' | 'warn' | 'error';
|
|
192
|
+
onConflict?: 'shortest' | 'first' | 'error';
|
|
193
|
+
onAliasConflict?: 'first' | 'error';
|
|
194
|
+
scan?: ScanOptions;
|
|
195
|
+
assets?: AssetsOptions;
|
|
196
|
+
wikilinks?: WikilinksModuleOptions;
|
|
197
|
+
embeds?: EmbedsModuleOptions;
|
|
198
|
+
modules?: {
|
|
199
|
+
wikilinks?: boolean;
|
|
200
|
+
embeds?: boolean;
|
|
201
|
+
};
|
|
202
|
+
/**
|
|
203
|
+
* 自定义 slugifier。默认 @mdit-vue/shared 的 slugify。
|
|
204
|
+
* 必须和 VitePress 的 markdown.anchor.slugify 一致,否则锚点匹配失败。
|
|
205
|
+
*/
|
|
206
|
+
slugify?: (text: string) => string;
|
|
207
|
+
}
|
|
208
|
+
/**
|
|
209
|
+
* 已归一化的内部配置(所有字段都有值)。
|
|
210
|
+
*/
|
|
211
|
+
interface ResolvedOptions {
|
|
212
|
+
srcDir: string;
|
|
213
|
+
base: string;
|
|
214
|
+
cleanUrls: boolean;
|
|
215
|
+
caseSensitive: boolean;
|
|
216
|
+
deadLink: 'silent' | 'warn' | 'error';
|
|
217
|
+
onConflict: 'shortest' | 'first' | 'error';
|
|
218
|
+
onAliasConflict: 'first' | 'error';
|
|
219
|
+
scan: Required<ScanOptions>;
|
|
220
|
+
assets: Required<AssetsOptions>;
|
|
221
|
+
wikilinks: Required<Omit<WikilinksModuleOptions, 'htmlAttributes'>> & {
|
|
222
|
+
htmlAttributes: PageLinkAttrs;
|
|
223
|
+
};
|
|
224
|
+
embeds: Required<Omit<EmbedsModuleOptions, 'htmlAttributes'>> & {
|
|
225
|
+
htmlAttributes: ImageEmbedAttrs;
|
|
226
|
+
};
|
|
227
|
+
modules: {
|
|
228
|
+
wikilinks: boolean;
|
|
229
|
+
embeds: boolean;
|
|
230
|
+
};
|
|
231
|
+
slugify: (text: string) => string;
|
|
232
|
+
}
|
|
233
|
+
/**
|
|
234
|
+
* markdown-it state.env 上 vitepress-allyouneed 的命名空间。
|
|
235
|
+
* VitePress 自己也用 env 传 page 数据,我们用独立 key 不冲突。
|
|
236
|
+
*/
|
|
237
|
+
interface AllYouNeedEnv {
|
|
238
|
+
index: VaultIndex;
|
|
239
|
+
options: ResolvedOptions;
|
|
240
|
+
/** 当前正在渲染的页面绝对路径(若可知)*/
|
|
241
|
+
currentPath?: string;
|
|
242
|
+
/** transclusion 调用栈,用于循环检测 */
|
|
243
|
+
transclusionStack?: string[];
|
|
244
|
+
/** 当前 transclusion 深度 */
|
|
245
|
+
transclusionDepth?: number;
|
|
246
|
+
/** 引用过的 asset basename → AssetEntry,build 期间汇总 */
|
|
247
|
+
referencedAssets?: Set<AssetEntry>;
|
|
248
|
+
}
|
|
249
|
+
interface ResolveResult {
|
|
250
|
+
url: string;
|
|
251
|
+
/** 默认 label(用户未提供 alias 时使用)*/
|
|
252
|
+
defaultLabel: string;
|
|
253
|
+
isDead: boolean;
|
|
254
|
+
hasUnmatchedAnchor: boolean;
|
|
255
|
+
target?: FileEntry;
|
|
256
|
+
/** 'page' / 'image' / 'transclusion' */
|
|
257
|
+
kind: 'page' | 'image' | 'transclusion';
|
|
258
|
+
/** 仅 image/transclusion 时填充 */
|
|
259
|
+
asset?: AssetEntry;
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
export type { AllYouNeedEnv as A, BacklinkEntry as B, EmbedsModuleOptions as E, FileEntry as F, HeadingEntry as H, ImageEmbedAttrs as I, PageLinkAttrs as P, ResolveResult as R, ScanOptions as S, VaultIndex as V, WikilinksModuleOptions as W, AllYouNeedOptions as a, AssetEntry as b, AssetsOptions as c, ImageEmbedAttrsContext as d, PageLinkAttrsContext as e, ResolvedOptions as f, ScanWarning as g };
|