@vuepress/core 2.0.0-rc.26 → 2.0.0-rc.27

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.
Files changed (3) hide show
  1. package/dist/index.d.ts +507 -501
  2. package/dist/index.js +957 -986
  3. package/package.json +12 -18
package/dist/index.d.ts CHANGED
@@ -1,8 +1,8 @@
1
- import { MarkdownLink, MarkdownSfcBlocks, MarkdownOptions, Markdown } from '@vuepress/markdown';
2
- import { PageFrontmatter, PageBase, PageData, PageHeader, SiteData } from '@vuepress/shared';
3
- export { HeadAttrsConfig, HeadConfig, HeadTag, HeadTagEmpty, HeadTagNonEmpty, LocaleConfig, LocaleData, PageData, PageFrontmatter, PageHeader, SiteData, SiteLocaleConfig } from '@vuepress/shared';
4
- import { TemplateRenderer } from '@vuepress/utils';
1
+ import { HeadAttrsConfig, HeadConfig, HeadTag, HeadTagEmpty, HeadTagNonEmpty, LocaleConfig, LocaleData, PageBase, PageData, PageData as PageData$1, PageFrontmatter, PageFrontmatter as PageFrontmatter$1, PageHeader, PageHeader as PageHeader$1, SiteData, SiteData as SiteData$1, SiteLocaleConfig } from "@vuepress/shared";
2
+ import { TemplateRenderer } from "@vuepress/utils";
3
+ import { Markdown, MarkdownLink, MarkdownOptions, MarkdownSfcBlocks } from "@vuepress/markdown";
5
4
 
5
+ //#region src/types/bundler.d.ts
6
6
  /**
7
7
  * Vuepress bundler
8
8
  *
@@ -11,171 +11,165 @@ import { TemplateRenderer } from '@vuepress/utils';
11
11
  * - build: bundle assets for deployment
12
12
  */
13
13
  interface Bundler {
14
- /**
15
- * Name of the bundler
16
- */
17
- name: string;
18
- /**
19
- * Method to run vuepress app in dev mode, starting dev server
20
- */
21
- dev: (app: App) => Promise<() => Promise<void>>;
22
- /**
23
- * Method to run vuepress app in build mode, generating static pages and assets
24
- */
25
- build: (app: App) => Promise<void>;
14
+ /**
15
+ * Name of the bundler
16
+ */
17
+ name: string;
18
+ /**
19
+ * Method to run vuepress app in dev mode, starting dev server
20
+ */
21
+ dev: (app: App) => Promise<() => Promise<void>>;
22
+ /**
23
+ * Method to run vuepress app in build mode, generating static pages and assets
24
+ */
25
+ build: (app: App) => Promise<void>;
26
26
  }
27
27
  type BundlerOptions = Record<string, unknown>;
28
-
28
+ //#endregion
29
+ //#region src/types/page.d.ts
29
30
  /**
30
31
  * Vuepress Page
31
32
  */
32
33
  type Page<ExtraPageData extends Record<string, unknown> = Record<string, unknown>, ExtraPageFrontmatter extends Record<string, unknown> = Record<string, unknown>, ExtraPageFields extends Record<string, unknown> = Record<string, unknown>> = ExtraPageFields & PageBase<ExtraPageFrontmatter> & {
33
- /**
34
- * Data of the page, which will be available in client code
35
- */
36
- data: PageData<ExtraPageData, ExtraPageFrontmatter>;
37
- /**
38
- * Raw Content of the page
39
- */
40
- content: string;
41
- /**
42
- * Rendered content of the page
43
- */
44
- contentRendered: string;
45
- /**
46
- * Date of the page, in 'yyyy-MM-dd' format
47
- *
48
- * @example '2020-09-09'
49
- */
50
- date: string;
51
- /**
52
- * Dependencies of the page
53
- */
54
- deps: string[];
55
- /**
56
- * Headers of the page
57
- */
58
- headers: PageHeader[];
59
- /**
60
- * Links of the page
61
- */
62
- links: MarkdownLink[];
63
- /**
64
- * Markdown env object of the page
65
- */
66
- markdownEnv: Record<string, unknown>;
67
- /**
68
- * Path of the page that inferred from file path
69
- *
70
- * If the page does not come from a file, it would be `null`
71
- *
72
- * @example '/guide/index.html'
73
- */
74
- pathInferred: string | null;
75
- /**
76
- * Locale path prefix of the page
77
- *
78
- * @example '/getting-started.html' -> '/'
79
- * @example '/en/getting-started.html' -> '/en/'
80
- * @example '/zh/getting-started.html' -> '/zh/'
81
- */
82
- pathLocale: string;
83
- /**
84
- * Permalink of the page
85
- *
86
- * If the page does not have a permalink, it would be `null`
87
- */
88
- permalink: string | null;
89
- /**
90
- * Custom data to be attached to route record
91
- */
92
- routeMeta: Record<string, unknown>;
93
- /**
94
- * Extracted sfc blocks of the page
95
- */
96
- sfcBlocks: MarkdownSfcBlocks;
97
- /**
98
- * Slug of the page
99
- */
100
- slug: string;
101
- /**
102
- * Source file path
103
- *
104
- * If the page does not come from a file, it would be `null`
105
- */
106
- filePath: string | null;
107
- /**
108
- * Source file path relative to source directory
109
- *
110
- * If the page does not come from a file, it would be `null`
111
- */
112
- filePathRelative: string | null;
113
- /**
114
- * Component file path
115
- */
116
- componentFilePath: string;
117
- /**
118
- * Component file path relative to temp directory
119
- */
120
- componentFilePathRelative: string;
121
- /**
122
- * Chunk file path
123
- */
124
- chunkFilePath: string;
125
- /**
126
- * Chunk file path relative to temp directory
127
- */
128
- chunkFilePathRelative: string;
129
- /**
130
- * Chunk name
131
- *
132
- * This will only take effect in webpack
133
- */
134
- chunkName: string;
135
- /**
136
- * Rendered html file path
137
- */
138
- htmlFilePath: string;
139
- /**
140
- * Rendered html file path relative to dest directory
141
- */
142
- htmlFilePathRelative: string;
34
+ /**
35
+ * Data of the page, which will be available in client code
36
+ */
37
+ data: PageData$1<ExtraPageData, ExtraPageFrontmatter>;
38
+ /**
39
+ * Raw Content of the page
40
+ */
41
+ content: string;
42
+ /**
43
+ * Rendered content of the page
44
+ */
45
+ contentRendered: string;
46
+ /**
47
+ * Date of the page, in 'yyyy-MM-dd' format
48
+ *
49
+ * @example '2020-09-09'
50
+ */
51
+ date: string;
52
+ /**
53
+ * Dependencies of the page
54
+ */
55
+ deps: string[];
56
+ /**
57
+ * Headers of the page
58
+ */
59
+ headers: PageHeader$1[];
60
+ /**
61
+ * Links of the page
62
+ */
63
+ links: MarkdownLink[];
64
+ /**
65
+ * Markdown env object of the page
66
+ */
67
+ markdownEnv: Record<string, unknown>;
68
+ /**
69
+ * Path of the page that inferred from file path
70
+ *
71
+ * If the page does not come from a file, it would be `null`
72
+ *
73
+ * @example '/guide/index.html'
74
+ */
75
+ pathInferred: string | null;
76
+ /**
77
+ * Locale path prefix of the page
78
+ *
79
+ * @example '/getting-started.html' -> '/'
80
+ * @example '/en/getting-started.html' -> '/en/'
81
+ * @example '/zh/getting-started.html' -> '/zh/'
82
+ */
83
+ pathLocale: string;
84
+ /**
85
+ * Permalink of the page
86
+ *
87
+ * If the page does not have a permalink, it would be `null`
88
+ */
89
+ permalink: string | null;
90
+ /**
91
+ * Custom data to be attached to route record
92
+ */
93
+ routeMeta: Record<string, unknown>;
94
+ /**
95
+ * Extracted sfc blocks of the page
96
+ */
97
+ sfcBlocks: MarkdownSfcBlocks;
98
+ /**
99
+ * Slug of the page
100
+ */
101
+ slug: string;
102
+ /**
103
+ * Source file path
104
+ *
105
+ * If the page does not come from a file, it would be `null`
106
+ */
107
+ filePath: string | null;
108
+ /**
109
+ * Source file path relative to source directory
110
+ *
111
+ * If the page does not come from a file, it would be `null`
112
+ */
113
+ filePathRelative: string | null;
114
+ /**
115
+ * Chunk file path
116
+ */
117
+ chunkFilePath: string;
118
+ /**
119
+ * Chunk file path relative to temp directory
120
+ */
121
+ chunkFilePathRelative: string;
122
+ /**
123
+ * Chunk name
124
+ *
125
+ * This will only take effect in webpack
126
+ */
127
+ chunkName: string;
128
+ /**
129
+ * Rendered html file path
130
+ */
131
+ htmlFilePath: string;
132
+ /**
133
+ * Rendered html file path relative to dest directory
134
+ */
135
+ htmlFilePathRelative: string;
143
136
  };
144
137
  /**
145
138
  * Options to create vuepress page
146
139
  */
147
140
  interface PageOptions {
148
- /**
149
- * The raw markdown content of the page.
150
- *
151
- * If `content` is not provided, the file content of the `filePath`
152
- * will be used.
153
- */
154
- content?: string;
155
- /**
156
- * Absolute file path of the markdown source file.
157
- */
158
- filePath?: string;
159
- /**
160
- * Default frontmatter of the page, which could be overridden by
161
- * the frontmatter of the markdown content.
162
- */
163
- frontmatter?: PageFrontmatter;
164
- /**
165
- * If this option is set, it will be used as the final route path
166
- * of the page, ignoring the relative path and permalink.
167
- */
168
- path?: string;
141
+ /**
142
+ * The raw markdown content of the page.
143
+ *
144
+ * If `content` is not provided, the file content of the `filePath`
145
+ * will be used.
146
+ */
147
+ content?: string;
148
+ /**
149
+ * Absolute file path of the markdown source file.
150
+ */
151
+ filePath?: string;
152
+ /**
153
+ * Default frontmatter of the page, which could be overridden by
154
+ * the frontmatter of the markdown content.
155
+ */
156
+ frontmatter?: PageFrontmatter$1;
157
+ /**
158
+ * If this option is set, it will be used as the final route path
159
+ * of the page, ignoring the relative path and permalink.
160
+ */
161
+ path?: string;
169
162
  }
170
-
163
+ //#endregion
164
+ //#region src/types/pluginApi/hooks.d.ts
171
165
  type PromiseOrNot<T> = Promise<T> | T;
172
166
  interface Closable {
173
- close(): void;
167
+ close(): void;
174
168
  }
175
- interface Hook<Exposed, Normalized = Exposed, Result = Normalized extends (...args: any) => infer U ? U extends Promise<infer V> ? V : U : never> {
176
- exposed: Exposed;
177
- normalized: Normalized;
178
- result: Result;
169
+ interface Hook<Exposed, Normalized = Exposed, Result = (Normalized extends ((...args: any) => infer U) ? U extends Promise<infer V> ? V : U : never)> {
170
+ exposed: Exposed;
171
+ normalized: Normalized;
172
+ result: Result;
179
173
  }
180
174
  type LifeCycleHook<T extends unknown[] = []> = Hook<(app: App, ...args: T) => PromiseOrNot<void>>;
181
175
  type ExtendsHook<T> = Hook<(extendable: T, app: App) => PromiseOrNot<void>>;
@@ -186,18 +180,19 @@ type DefineHook = Hook<Record<string, unknown> | ((app: App, isServer: boolean)
186
180
  * List of hooks
187
181
  */
188
182
  interface Hooks {
189
- onInitialized: LifeCycleHook;
190
- onPrepared: LifeCycleHook;
191
- onWatched: LifeCycleHook<[watchers: Closable[], restart: () => Promise<void>]>;
192
- onGenerated: LifeCycleHook;
193
- extendsMarkdownOptions: ExtendsHook<MarkdownOptions>;
194
- extendsMarkdown: ExtendsHook<Markdown>;
195
- extendsPageOptions: ExtendsHook<PageOptions>;
196
- extendsPage: ExtendsHook<Page>;
197
- extendsBundlerOptions: ExtendsHook<BundlerOptions>;
198
- clientConfigFile: ClientConfigFileHook;
199
- alias: AliasHook;
200
- define: DefineHook;
183
+ onInitialized: LifeCycleHook;
184
+ onPrepared: LifeCycleHook;
185
+ onWatched: LifeCycleHook<[watchers: Closable[], restart: () => Promise<void>]>;
186
+ onPageUpdated: LifeCycleHook<[type: 'create' | 'delete' | 'update', page: Page, oldPage: Page | null]>;
187
+ onGenerated: LifeCycleHook;
188
+ extendsMarkdownOptions: ExtendsHook<MarkdownOptions>;
189
+ extendsMarkdown: ExtendsHook<Markdown>;
190
+ extendsPageOptions: ExtendsHook<PageOptions>;
191
+ extendsPage: ExtendsHook<Page>;
192
+ extendsBundlerOptions: ExtendsHook<BundlerOptions>;
193
+ clientConfigFile: ClientConfigFileHook;
194
+ alias: AliasHook;
195
+ define: DefineHook;
201
196
  }
202
197
  /**
203
198
  * Name of hooks
@@ -206,60 +201,54 @@ type HooksName = keyof Hooks;
206
201
  /**
207
202
  * Exposed hooks API that can be accessed by a plugin
208
203
  */
209
- type HooksExposed = {
210
- [K in HooksName]: Hooks[K]['exposed'];
211
- };
204
+ type HooksExposed = { [K in HooksName]: Hooks[K]['exposed'] };
212
205
  /**
213
206
  * Normalized hooks
214
207
  */
215
- type HooksNormalized = {
216
- [K in HooksName]: Hooks[K]['normalized'];
217
- };
208
+ type HooksNormalized = { [K in HooksName]: Hooks[K]['normalized'] };
218
209
  /**
219
210
  * Result of hooks
220
211
  */
221
- type HooksResult = {
222
- [K in HooksName]: Hooks[K]['result'];
223
- };
212
+ type HooksResult = { [K in HooksName]: Hooks[K]['result'] };
224
213
  /**
225
214
  * Hook item
226
215
  */
227
216
  interface HookItem<T extends HooksName> {
228
- pluginName: string;
229
- hook: HooksNormalized[T];
217
+ pluginName: string;
218
+ hook: HooksNormalized[T];
230
219
  }
231
220
  /**
232
221
  * Hook items queue
233
222
  */
234
223
  interface HookQueue<T extends HooksName> {
235
- name: T;
236
- items: HookItem<T>[];
237
- add: (item: HookItem<T>) => void;
238
- process: (...args: Parameters<HooksNormalized[T]>) => Promise<HooksResult[T][]>;
224
+ name: T;
225
+ items: HookItem<T>[];
226
+ add: (item: HookItem<T>) => void;
227
+ process: (...args: Parameters<HooksNormalized[T]>) => Promise<HooksResult[T][]>;
239
228
  }
240
-
229
+ //#endregion
230
+ //#region src/types/pluginApi/pluginApi.d.ts
241
231
  /**
242
232
  * Vuepress plugin system
243
233
  */
244
234
  interface PluginApi {
245
- /**
246
- * Plugins that have been used
247
- */
248
- plugins: PluginObject[];
249
- /**
250
- * All available hooks
251
- */
252
- hooks: {
253
- [K in HooksName]: HookQueue<K>;
254
- };
255
- /**
256
- * Register hooks of plugins
257
- *
258
- * Should be invoked before applying a hook
259
- */
260
- registerHooks: () => void;
235
+ /**
236
+ * Plugins that have been used
237
+ */
238
+ plugins: PluginObject[];
239
+ /**
240
+ * All available hooks
241
+ */
242
+ hooks: { [K in HooksName]: HookQueue<K> };
243
+ /**
244
+ * Register hooks of plugins
245
+ *
246
+ * Should be invoked before applying a hook
247
+ */
248
+ registerHooks: () => void;
261
249
  }
262
-
250
+ //#endregion
251
+ //#region src/types/plugin.d.ts
263
252
  /**
264
253
  * Vuepress plugin
265
254
  *
@@ -280,20 +269,21 @@ type PluginFunction<T extends PluginObject = PluginObject> = (app: App) => T;
280
269
  * Vuepress plugin object
281
270
  */
282
271
  interface PluginObject extends Partial<HooksExposed> {
283
- /**
284
- * Name of the plugin
285
- */
286
- name: string;
287
- /**
288
- * Allow the plugin to be used multiple times or not
289
- */
290
- multiple?: boolean;
272
+ /**
273
+ * Name of the plugin
274
+ */
275
+ name: string;
276
+ /**
277
+ * Allow the plugin to be used multiple times or not
278
+ */
279
+ multiple?: boolean;
291
280
  }
292
281
  /**
293
282
  * Config field for plugins
294
283
  */
295
284
  type PluginConfig = (Plugin | Plugin[])[];
296
-
285
+ //#endregion
286
+ //#region src/types/theme.d.ts
297
287
  /**
298
288
  * Vuepress theme
299
289
  *
@@ -312,195 +302,196 @@ type ThemeFunction = PluginFunction<ThemeObject>;
312
302
  * Vuepress theme object
313
303
  */
314
304
  interface ThemeObject extends Omit<PluginObject, 'multiple'> {
315
- /**
316
- * Extended parent theme
317
- */
318
- extends?: Theme;
319
- /**
320
- * Allow using plugins in theme
321
- */
322
- plugins?: PluginConfig;
323
- /**
324
- * Allow overriding default templateBuild
325
- */
326
- templateBuild?: string;
327
- /**
328
- * Allow specifying custom template renderer
329
- */
330
- templateBuildRenderer?: TemplateRenderer;
331
- /**
332
- * Allow overriding default templateDev
333
- */
334
- templateDev?: string;
305
+ /**
306
+ * Extended parent theme
307
+ */
308
+ extends?: Theme;
309
+ /**
310
+ * Allow using plugins in theme
311
+ */
312
+ plugins?: PluginConfig;
313
+ /**
314
+ * Allow overriding default templateBuild
315
+ */
316
+ templateBuild?: string;
317
+ /**
318
+ * Allow specifying custom template renderer
319
+ */
320
+ templateBuildRenderer?: TemplateRenderer;
321
+ /**
322
+ * Allow overriding default templateDev
323
+ */
324
+ templateDev?: string;
335
325
  }
336
326
  /**
337
327
  * Resolved theme info
338
328
  */
339
329
  interface ThemeInfo {
340
- /**
341
- * Plugins, including theme itself and plugins used by theme
342
- */
343
- plugins: PluginConfig;
344
- /**
345
- * Default build template
346
- */
347
- templateBuild?: string;
348
- /**
349
- * Default build template renderer
350
- */
351
- templateBuildRenderer?: TemplateRenderer;
352
- /**
353
- * Default dev template
354
- */
355
- templateDev?: string;
330
+ /**
331
+ * Plugins, including theme itself and plugins used by theme
332
+ */
333
+ plugins: PluginConfig;
334
+ /**
335
+ * Default build template
336
+ */
337
+ templateBuild?: string;
338
+ /**
339
+ * Default build template renderer
340
+ */
341
+ templateBuildRenderer?: TemplateRenderer;
342
+ /**
343
+ * Default dev template
344
+ */
345
+ templateDev?: string;
356
346
  }
357
-
347
+ //#endregion
348
+ //#region src/types/app/options.d.ts
358
349
  /**
359
350
  * Vuepress app common config that shared between dev and build
360
351
  */
361
- interface AppConfigCommon extends Partial<SiteData> {
362
- /**
363
- * Source directory of the markdown files.
364
- *
365
- * Vuepress will load markdown files from this directory.
366
- *
367
- * @required
368
- */
369
- source: string;
370
- /**
371
- * Destination directory of the output files.
372
- *
373
- * Vuepress will output the static site files to this directory.
374
- *
375
- * @default `${source}/.vuepress/dist`
376
- */
377
- dest?: string;
378
- /**
379
- * Temp files directory.
380
- *
381
- * Vuepress will write temp files to this directory.
382
- *
383
- * @default `${source}/.vuepress/.temp`
384
- */
385
- temp?: string;
386
- /**
387
- * Cache files directory.
388
- *
389
- * Vuepress will write cache files to this directory.
390
- *
391
- * @default `${source}/.vuepress/.cache`
392
- */
393
- cache?: string;
394
- /**
395
- * Public files directory.
396
- *
397
- * Vuepress will copy the files from public directory to the output directory.
398
- *
399
- * @default `${source}/.vuepress/public`
400
- */
401
- public?: string;
402
- /**
403
- * Whether to enable debug mode
404
- *
405
- * @default false
406
- */
407
- debug?: boolean;
408
- /**
409
- * Markdown options
410
- *
411
- * @default {}
412
- */
413
- markdown?: MarkdownOptions;
414
- /**
415
- * Patterns to match the markdown files as pages
416
- *
417
- * @default ['**\/*.md', '!.vuepress', '!node_modules']
418
- */
419
- pagePatterns?: string[];
420
- /**
421
- * Pattern to generate permalink for pages
422
- *
423
- * @default null
424
- */
425
- permalinkPattern?: string | null;
426
- /**
427
- * Vuepress bundler
428
- *
429
- * @required
430
- */
431
- bundler: Bundler;
432
- /**
433
- * Vuepress theme
434
- *
435
- * @required
436
- */
437
- theme: Theme;
438
- /**
439
- * Vuepress plugins
440
- *
441
- * @default []
442
- */
443
- plugins?: PluginConfig;
352
+ interface AppConfigCommon extends Partial<SiteData$1> {
353
+ /**
354
+ * Source directory of the markdown files.
355
+ *
356
+ * Vuepress will load markdown files from this directory.
357
+ *
358
+ * @required
359
+ */
360
+ source: string;
361
+ /**
362
+ * Destination directory of the output files.
363
+ *
364
+ * Vuepress will output the static site files to this directory.
365
+ *
366
+ * @default `${source}/.vuepress/dist`
367
+ */
368
+ dest?: string;
369
+ /**
370
+ * Temp files directory.
371
+ *
372
+ * Vuepress will write temp files to this directory.
373
+ *
374
+ * @default `${source}/.vuepress/.temp`
375
+ */
376
+ temp?: string;
377
+ /**
378
+ * Cache files directory.
379
+ *
380
+ * Vuepress will write cache files to this directory.
381
+ *
382
+ * @default `${source}/.vuepress/.cache`
383
+ */
384
+ cache?: string;
385
+ /**
386
+ * Public files directory.
387
+ *
388
+ * Vuepress will copy the files from public directory to the output directory.
389
+ *
390
+ * @default `${source}/.vuepress/public`
391
+ */
392
+ public?: string;
393
+ /**
394
+ * Whether to enable debug mode
395
+ *
396
+ * @default false
397
+ */
398
+ debug?: boolean;
399
+ /**
400
+ * Markdown options
401
+ *
402
+ * @default {}
403
+ */
404
+ markdown?: MarkdownOptions;
405
+ /**
406
+ * Patterns to match the markdown files as pages
407
+ *
408
+ * @default ['**\/*.md', '!.vuepress', '!node_modules']
409
+ */
410
+ pagePatterns?: string[];
411
+ /**
412
+ * Pattern to generate permalink for pages
413
+ *
414
+ * @default null
415
+ */
416
+ permalinkPattern?: string | null;
417
+ /**
418
+ * Vuepress bundler
419
+ *
420
+ * @required
421
+ */
422
+ bundler: Bundler;
423
+ /**
424
+ * Vuepress theme
425
+ *
426
+ * @required
427
+ */
428
+ theme: Theme;
429
+ /**
430
+ * Vuepress plugins
431
+ *
432
+ * @default []
433
+ */
434
+ plugins?: PluginConfig;
444
435
  }
445
436
  /**
446
437
  * Vuepress app config for dev
447
438
  */
448
439
  interface AppConfigDev {
449
- /**
450
- * Specify the host to use for the dev server
451
- *
452
- * @default '0.0.0.0'
453
- */
454
- host?: string;
455
- /**
456
- * Specify the port to use for the dev server
457
- *
458
- * @default 8080
459
- */
460
- port?: number;
461
- /**
462
- * Whether to open the browser after dev-server had been started
463
- *
464
- * @default false
465
- */
466
- open?: boolean;
467
- /**
468
- * Specify the path of the HTML template to be used for dev
469
- *
470
- * @default '@vuepress/client/templates/dev.html'
471
- */
472
- templateDev?: string;
440
+ /**
441
+ * Specify the host to use for the dev server
442
+ *
443
+ * @default '0.0.0.0'
444
+ */
445
+ host?: string;
446
+ /**
447
+ * Specify the port to use for the dev server
448
+ *
449
+ * @default 8080
450
+ */
451
+ port?: number;
452
+ /**
453
+ * Whether to open the browser after dev-server had been started
454
+ *
455
+ * @default false
456
+ */
457
+ open?: boolean;
458
+ /**
459
+ * Specify the path of the HTML template to be used for dev
460
+ *
461
+ * @default '@vuepress/client/templates/dev.html'
462
+ */
463
+ templateDev?: string;
473
464
  }
474
465
  /**
475
466
  * Vuepress app config for build
476
467
  */
477
468
  interface AppConfigBuild {
478
- /**
479
- * Determine what resource files should be preloaded. Use boolean value to
480
- * totally enable / disable.
481
- *
482
- * @default true
483
- */
484
- shouldPreload?: boolean | ((file: string, type: string) => boolean);
485
- /**
486
- * Determine what resource files should be prefetched. Use boolean value to
487
- * totally enable / disable.
488
- *
489
- * @default true
490
- */
491
- shouldPrefetch?: boolean | ((file: string, type: string) => boolean);
492
- /**
493
- * Specify the path of the HTML template to be used for build
494
- *
495
- * @default '@vuepress/client/templates/build.html'
496
- */
497
- templateBuild?: string;
498
- /**
499
- * Specify the HTML template renderer to be used for build
500
- *
501
- * @default `import { templateRenderer } from '@vuepress/utils'`
502
- */
503
- templateBuildRenderer?: TemplateRenderer;
469
+ /**
470
+ * Determine what resource files should be preloaded. Use boolean value to
471
+ * totally enable / disable.
472
+ *
473
+ * @default true
474
+ */
475
+ shouldPreload?: boolean | ((file: string, type: string) => boolean);
476
+ /**
477
+ * Determine what resource files should be prefetched. Use boolean value to
478
+ * totally enable / disable.
479
+ *
480
+ * @default true
481
+ */
482
+ shouldPrefetch?: boolean | ((file: string, type: string) => boolean);
483
+ /**
484
+ * Specify the path of the HTML template to be used for build
485
+ *
486
+ * @default '@vuepress/client/templates/build.html'
487
+ */
488
+ templateBuild?: string;
489
+ /**
490
+ * Specify the HTML template renderer to be used for build
491
+ *
492
+ * @default `import { templateRenderer } from '@vuepress/utils'`
493
+ */
494
+ templateBuildRenderer?: TemplateRenderer;
504
495
  }
505
496
  /**
506
497
  * Vuepress app user config.
@@ -514,7 +505,8 @@ type AppConfig = AppConfigBuild & AppConfigCommon & AppConfigDev;
514
505
  * It fills all optional fields with a default value.
515
506
  */
516
507
  type AppOptions = Required<AppConfig>;
517
-
508
+ //#endregion
509
+ //#region src/types/app/utils.d.ts
518
510
  /**
519
511
  * Directory util function
520
512
  */
@@ -523,121 +515,128 @@ type AppDirFunction = (...args: string[]) => string;
523
515
  * Directory utils
524
516
  */
525
517
  interface AppDir {
526
- /**
527
- * Resolve file path in cache directory
528
- */
529
- cache: AppDirFunction;
530
- /**
531
- * Resolve file path in temp directory
532
- */
533
- temp: AppDirFunction;
534
- /**
535
- * Resolve file path in source directory
536
- */
537
- source: AppDirFunction;
538
- /**
539
- * Resolve file path in dest directory
540
- */
541
- dest: AppDirFunction;
542
- /**
543
- * Resolve file path in public directory
544
- */
545
- public: AppDirFunction;
546
- /**
547
- * Resolve file path in client directory
548
- */
549
- client: AppDirFunction;
518
+ /**
519
+ * Resolve file path in cache directory
520
+ */
521
+ cache: AppDirFunction;
522
+ /**
523
+ * Resolve file path in temp directory
524
+ */
525
+ temp: AppDirFunction;
526
+ /**
527
+ * Resolve file path in source directory
528
+ */
529
+ source: AppDirFunction;
530
+ /**
531
+ * Resolve file path in dest directory
532
+ */
533
+ dest: AppDirFunction;
534
+ /**
535
+ * Resolve file path in public directory
536
+ */
537
+ public: AppDirFunction;
538
+ /**
539
+ * Resolve file path in client directory
540
+ */
541
+ client: AppDirFunction;
550
542
  }
551
543
  /**
552
544
  * Environment flags
553
545
  */
554
546
  interface AppEnv {
555
- /**
556
- * Is running in build mode or not
557
- */
558
- isBuild: boolean;
559
- /**
560
- * Is running in dev mode or not
561
- */
562
- isDev: boolean;
563
- /**
564
- * Is debug mode enabled or not
565
- */
566
- isDebug: boolean;
547
+ /**
548
+ * Is running in build mode or not
549
+ */
550
+ isBuild: boolean;
551
+ /**
552
+ * Is running in dev mode or not
553
+ */
554
+ isDev: boolean;
555
+ /**
556
+ * Is debug mode enabled or not
557
+ */
558
+ isDebug: boolean;
567
559
  }
568
560
  /**
569
561
  * Write temp file util
570
562
  */
571
563
  type AppWriteTemp = (file: string, content: string) => Promise<string>;
572
-
564
+ //#endregion
565
+ //#region src/types/app/app.d.ts
573
566
  /**
574
567
  * App base properties, will be available after creation, even before initialization
575
568
  */
576
569
  interface AppPropertiesBase {
577
- /**
578
- * Directory utils.
579
- */
580
- dir: AppDir;
581
- /**
582
- * Environment flags.
583
- */
584
- env: AppEnv;
585
- /**
586
- * Options that filled all optional fields with a default value.
587
- */
588
- options: AppOptions;
589
- /**
590
- * Plugin system.
591
- */
592
- pluginApi: PluginApi;
593
- /**
594
- * Site data, which will be used in client side.
595
- */
596
- siteData: SiteData;
597
- /**
598
- * Version of vuepress core.
599
- */
600
- version: string;
601
- /**
602
- * Initialize app.
603
- *
604
- * - Theme and plugin will be loaded.
605
- * - Layouts and pages will be resolved.
606
- */
607
- init: () => Promise<void>;
608
- /**
609
- * Prepare data for client and write temp files.
610
- *
611
- * Should be called after `app.init()`.
612
- */
613
- prepare: () => Promise<void>;
614
- /**
615
- * Use a plugin.
616
- *
617
- * Should be called before `app.init()`.
618
- */
619
- use: (plugin: Plugin) => this;
620
- /**
621
- * Util to write temp file
622
- */
623
- writeTemp: AppWriteTemp;
570
+ /**
571
+ * Directory utils.
572
+ */
573
+ dir: AppDir;
574
+ /**
575
+ * Environment flags.
576
+ */
577
+ env: AppEnv;
578
+ /**
579
+ * Options that filled all optional fields with a default value.
580
+ */
581
+ options: AppOptions;
582
+ /**
583
+ * Plugin system.
584
+ */
585
+ pluginApi: PluginApi;
586
+ /**
587
+ * Site data, which will be used in client side.
588
+ */
589
+ siteData: SiteData$1;
590
+ /**
591
+ * Version of vuepress core.
592
+ */
593
+ version: string;
594
+ /**
595
+ * Initialize app.
596
+ *
597
+ * - Theme and plugin will be loaded.
598
+ * - Layouts and pages will be resolved.
599
+ */
600
+ init: () => Promise<void>;
601
+ /**
602
+ * Prepare data for client and write temp files.
603
+ *
604
+ * Should be called after `app.init()`.
605
+ */
606
+ prepare: () => Promise<void>;
607
+ /**
608
+ * Use a plugin.
609
+ *
610
+ * Should be called before `app.init()`.
611
+ */
612
+ use: (plugin: Plugin) => this;
613
+ /**
614
+ * Util to write temp file
615
+ */
616
+ writeTemp: AppWriteTemp;
624
617
  }
625
618
  /**
626
619
  * App initialized properties, will only be available after initialization
627
620
  */
628
621
  interface AppPropertiesInitialized {
629
- /**
630
- * Markdown-it instance.
631
- *
632
- * Only available after initialization
633
- */
634
- markdown: Markdown;
635
- /**
636
- * Page objects.
637
- *
638
- * Only available after initialization
639
- */
640
- pages: Page[];
622
+ /**
623
+ * Markdown-it instance.
624
+ *
625
+ * Only available after initialization
626
+ */
627
+ markdown: Markdown;
628
+ /**
629
+ * Page objects.
630
+ *
631
+ * Only available after initialization
632
+ */
633
+ pages: Page[];
634
+ /**
635
+ * Page source filepath map.
636
+ *
637
+ * Only available after initialization
638
+ */
639
+ pagesMap: Record<string, Page | undefined>;
641
640
  }
642
641
  /**
643
642
  * Vuepress app instance
@@ -647,58 +646,65 @@ type App = AppPropertiesBase & AppPropertiesInitialized;
647
646
  * Vuepress dev app
648
647
  */
649
648
  interface DevApp extends App {
650
- /**
651
- * Start dev server
652
- *
653
- * Should be called after `app.prepare()`.
654
- */
655
- dev: () => ReturnType<Bundler['dev']>;
649
+ /**
650
+ * Start dev server
651
+ *
652
+ * Should be called after `app.prepare()`.
653
+ */
654
+ dev: () => ReturnType<Bundler['dev']>;
656
655
  }
657
656
  /**
658
657
  * Vuepress build app
659
658
  */
660
659
  interface BuildApp extends App {
661
- /**
662
- * Build static files
663
- *
664
- * Should be called after `app.prepare()`.
665
- */
666
- build: () => ReturnType<Bundler['build']>;
660
+ /**
661
+ * Build static files
662
+ *
663
+ * Should be called after `app.prepare()`.
664
+ */
665
+ build: () => ReturnType<Bundler['build']>;
667
666
  }
668
-
667
+ //#endregion
668
+ //#region src/app/prepare/preparePageChunk.d.ts
669
669
  /**
670
- * Generate page chunk temp file of a single page
670
+ * Generate temp file if the page does not have a source file
671
671
  */
672
672
  declare const preparePageChunk: (app: App, page: Page) => Promise<void>;
673
-
674
- /**
675
- * Generate page component temp file of a single page
676
- */
677
- declare const preparePageComponent: (app: App, page: Page) => Promise<void>;
678
-
673
+ //#endregion
674
+ //#region src/app/prepare/prepareRoutes.d.ts
679
675
  /**
680
676
  * Generate routes temp file
681
677
  */
682
678
  declare const prepareRoutes: (app: App) => Promise<void>;
683
-
679
+ //#endregion
680
+ //#region src/app/createBuildApp.d.ts
684
681
  /**
685
682
  * Create vuepress build app.
686
683
  */
687
684
  declare const createBuildApp: (config: AppConfig) => BuildApp;
688
-
685
+ //#endregion
686
+ //#region src/app/createDevApp.d.ts
689
687
  /**
690
688
  * Create vuepress dev app.
691
689
  */
692
690
  declare const createDevApp: (config: AppConfig) => DevApp;
693
-
691
+ //#endregion
692
+ //#region src/app/resolveAppDir.d.ts
694
693
  /**
695
694
  * Resolve directory utils for vuepress app
696
695
  */
697
696
  declare const resolveAppDir: (options: AppOptions) => AppDir;
698
-
697
+ //#endregion
698
+ //#region src/page/createPage.d.ts
699
699
  /**
700
700
  * Create vuepress page object
701
701
  */
702
702
  declare const createPage: (app: App, options: PageOptions) => Promise<Page>;
703
-
704
- export { type AliasHook, type App, type AppConfig, type AppConfigBuild, type AppConfigCommon, type AppConfigDev, type AppDir, type AppDirFunction, type AppEnv, type AppOptions, type AppPropertiesBase, type AppPropertiesInitialized, type AppWriteTemp, type BuildApp, type Bundler, type BundlerOptions, type ClientConfigFileHook, type DefineHook, type DevApp, type ExtendsHook, type Hook, type HookItem, type HookQueue, type Hooks, type HooksExposed, type HooksName, type HooksNormalized, type HooksResult, type LifeCycleHook, type Page, type PageOptions, type Plugin, type PluginApi, type PluginConfig, type PluginFunction, type PluginObject, type Theme, type ThemeFunction, type ThemeInfo, type ThemeObject, createBuildApp, createDevApp, createPage, preparePageChunk, preparePageComponent, prepareRoutes, resolveAppDir };
703
+ //#endregion
704
+ //#region src/page/renderPageToVue.d.ts
705
+ /**
706
+ * Render page to vue component
707
+ */
708
+ declare const renderPageToVue: (app: App, page: Page) => string;
709
+ //#endregion
710
+ export { AliasHook, App, AppConfig, AppConfigBuild, AppConfigCommon, AppConfigDev, AppDir, AppDirFunction, AppEnv, AppOptions, AppPropertiesBase, AppPropertiesInitialized, AppWriteTemp, BuildApp, Bundler, BundlerOptions, ClientConfigFileHook, DefineHook, DevApp, ExtendsHook, type HeadAttrsConfig, type HeadConfig, type HeadTag, type HeadTagEmpty, type HeadTagNonEmpty, Hook, HookItem, HookQueue, Hooks, HooksExposed, HooksName, HooksNormalized, HooksResult, LifeCycleHook, type LocaleConfig, type LocaleData, Page, type PageData, type PageFrontmatter, type PageHeader, PageOptions, Plugin, PluginApi, PluginConfig, PluginFunction, PluginObject, type SiteData, type SiteLocaleConfig, Theme, ThemeFunction, ThemeInfo, ThemeObject, createBuildApp, createDevApp, createPage, preparePageChunk, prepareRoutes, renderPageToVue, resolveAppDir };