@vuepress/core 2.0.0-beta.9 → 2.0.0-rc.1

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 (156) hide show
  1. package/LICENSE +1 -1
  2. package/README.md +12 -0
  3. package/dist/index.d.ts +845 -0
  4. package/dist/index.js +1039 -0
  5. package/package.json +36 -19
  6. package/CHANGELOG.md +0 -338
  7. package/lib/app/appInit.d.ts +0 -7
  8. package/lib/app/appInit.js +0 -26
  9. package/lib/app/appPrepare.d.ts +0 -10
  10. package/lib/app/appPrepare.js +0 -46
  11. package/lib/app/appUse.d.ts +0 -2
  12. package/lib/app/appUse.js +0 -28
  13. package/lib/app/appUseByConfig.d.ts +0 -2
  14. package/lib/app/appUseByConfig.js +0 -11
  15. package/lib/app/createApp.d.ts +0 -5
  16. package/lib/app/createApp.js +0 -55
  17. package/lib/app/createAppDir.d.ts +0 -9
  18. package/lib/app/createAppDir.js +0 -32
  19. package/lib/app/createAppEnv.d.ts +0 -5
  20. package/lib/app/createAppEnv.js +0 -14
  21. package/lib/app/createAppOptions.d.ts +0 -5
  22. package/lib/app/createAppOptions.js +0 -47
  23. package/lib/app/createAppPages.d.ts +0 -5
  24. package/lib/app/createAppPages.js +0 -36
  25. package/lib/app/createAppSiteData.d.ts +0 -7
  26. package/lib/app/createAppSiteData.js +0 -19
  27. package/lib/app/createAppVersion.d.ts +0 -4
  28. package/lib/app/createAppVersion.js +0 -10
  29. package/lib/app/createAppWriteTemp.d.ts +0 -5
  30. package/lib/app/createAppWriteTemp.js +0 -21
  31. package/lib/app/index.d.ts +0 -16
  32. package/lib/app/index.js +0 -28
  33. package/lib/app/normalizePlugin.d.ts +0 -2
  34. package/lib/app/normalizePlugin.js +0 -17
  35. package/lib/app/normalizePluginConfig.d.ts +0 -2
  36. package/lib/app/normalizePluginConfig.js +0 -15
  37. package/lib/app/prepare/index.d.ts +0 -12
  38. package/lib/app/prepare/index.js +0 -24
  39. package/lib/app/prepare/prepareClientAppEnhances.d.ts +0 -5
  40. package/lib/app/prepare/prepareClientAppEnhances.js +0 -24
  41. package/lib/app/prepare/prepareClientAppRootComponents.d.ts +0 -5
  42. package/lib/app/prepare/prepareClientAppRootComponents.js +0 -24
  43. package/lib/app/prepare/prepareClientAppSetups.d.ts +0 -5
  44. package/lib/app/prepare/prepareClientAppSetups.js +0 -24
  45. package/lib/app/prepare/prepareLayoutComponents.d.ts +0 -5
  46. package/lib/app/prepare/prepareLayoutComponents.js +0 -20
  47. package/lib/app/prepare/preparePageComponent.d.ts +0 -5
  48. package/lib/app/prepare/preparePageComponent.js +0 -10
  49. package/lib/app/prepare/preparePageData.d.ts +0 -5
  50. package/lib/app/prepare/preparePageData.js +0 -37
  51. package/lib/app/prepare/preparePageRoutes.d.ts +0 -5
  52. package/lib/app/prepare/preparePageRoutes.js +0 -57
  53. package/lib/app/prepare/preparePagesComponent.d.ts +0 -5
  54. package/lib/app/prepare/preparePagesComponent.js +0 -23
  55. package/lib/app/prepare/preparePagesData.d.ts +0 -5
  56. package/lib/app/prepare/preparePagesData.js +0 -19
  57. package/lib/app/prepare/preparePagesRoutes.d.ts +0 -5
  58. package/lib/app/prepare/preparePagesRoutes.js +0 -25
  59. package/lib/app/prepare/prepareSiteData.d.ts +0 -5
  60. package/lib/app/prepare/prepareSiteData.js +0 -31
  61. package/lib/app/prepare/resolvePageData.d.ts +0 -5
  62. package/lib/app/prepare/resolvePageData.js +0 -18
  63. package/lib/app/resolveBundler.d.ts +0 -2
  64. package/lib/app/resolveBundler.js +0 -10
  65. package/lib/app/resolvePlugin.d.ts +0 -5
  66. package/lib/app/resolvePlugin.js +0 -20
  67. package/lib/index.d.ts +0 -5
  68. package/lib/index.js +0 -17
  69. package/lib/page/createPage.d.ts +0 -2
  70. package/lib/page/createPage.js +0 -112
  71. package/lib/page/index.d.ts +0 -18
  72. package/lib/page/index.js +0 -30
  73. package/lib/page/inferPagePath.d.ts +0 -11
  74. package/lib/page/inferPagePath.js +0 -27
  75. package/lib/page/resolvePageComponentInfo.d.ts +0 -20
  76. package/lib/page/resolvePageComponentInfo.js +0 -38
  77. package/lib/page/resolvePageContent.d.ts +0 -11
  78. package/lib/page/resolvePageContent.js +0 -30
  79. package/lib/page/resolvePageDataInfo.d.ts +0 -12
  80. package/lib/page/resolvePageDataInfo.js +0 -17
  81. package/lib/page/resolvePageDate.d.ts +0 -10
  82. package/lib/page/resolvePageDate.js +0 -46
  83. package/lib/page/resolvePageExcerpt.d.ts +0 -10
  84. package/lib/page/resolvePageExcerpt.js +0 -16
  85. package/lib/page/resolvePageFileContent.d.ts +0 -8
  86. package/lib/page/resolvePageFileContent.js +0 -24
  87. package/lib/page/resolvePageFilePath.d.ts +0 -11
  88. package/lib/page/resolvePageFilePath.js +0 -29
  89. package/lib/page/resolvePageFrontmatter.d.ts +0 -8
  90. package/lib/page/resolvePageFrontmatter.js +0 -12
  91. package/lib/page/resolvePageHtmlInfo.d.ts +0 -11
  92. package/lib/page/resolvePageHtmlInfo.js +0 -18
  93. package/lib/page/resolvePageKey.d.ts +0 -6
  94. package/lib/page/resolvePageKey.js +0 -9
  95. package/lib/page/resolvePageLang.d.ts +0 -9
  96. package/lib/page/resolvePageLang.js +0 -15
  97. package/lib/page/resolvePagePath.d.ts +0 -9
  98. package/lib/page/resolvePagePath.js +0 -19
  99. package/lib/page/resolvePagePermalink.d.ts +0 -11
  100. package/lib/page/resolvePagePermalink.js +0 -32
  101. package/lib/page/resolvePageRoutesInfo.d.ts +0 -11
  102. package/lib/page/resolvePageRoutesInfo.js +0 -15
  103. package/lib/page/resolvePageSlug.d.ts +0 -6
  104. package/lib/page/resolvePageSlug.js +0 -17
  105. package/lib/page/resolvePageTitle.d.ts +0 -9
  106. package/lib/page/resolvePageTitle.js +0 -26
  107. package/lib/pluginApi/createHookQueue.d.ts +0 -5
  108. package/lib/pluginApi/createHookQueue.js +0 -81
  109. package/lib/pluginApi/createPluginApi.d.ts +0 -2
  110. package/lib/pluginApi/createPluginApi.js +0 -16
  111. package/lib/pluginApi/createPluginApiHooks.d.ts +0 -2
  112. package/lib/pluginApi/createPluginApiHooks.js +0 -24
  113. package/lib/pluginApi/createPluginApiRegisterHooks.d.ts +0 -2
  114. package/lib/pluginApi/createPluginApiRegisterHooks.js +0 -54
  115. package/lib/pluginApi/index.d.ts +0 -6
  116. package/lib/pluginApi/index.js +0 -18
  117. package/lib/pluginApi/normalizeClientFilesHook.d.ts +0 -5
  118. package/lib/pluginApi/normalizeClientFilesHook.js +0 -28
  119. package/lib/pluginApi/normalizeReturnObjectHook.d.ts +0 -5
  120. package/lib/pluginApi/normalizeReturnObjectHook.js +0 -9
  121. package/lib/themeApi/createThemeApi.d.ts +0 -7
  122. package/lib/themeApi/createThemeApi.js +0 -30
  123. package/lib/themeApi/index.d.ts +0 -3
  124. package/lib/themeApi/index.js +0 -15
  125. package/lib/themeApi/resolveThemeInfo.d.ts +0 -2
  126. package/lib/themeApi/resolveThemeInfo.js +0 -32
  127. package/lib/themeApi/resolveThemeLayouts.d.ts +0 -5
  128. package/lib/themeApi/resolveThemeLayouts.js +0 -32
  129. package/lib/types/app/app.d.ts +0 -30
  130. package/lib/types/app/app.js +0 -2
  131. package/lib/types/app/index.d.ts +0 -3
  132. package/lib/types/app/index.js +0 -15
  133. package/lib/types/app/options.d.ts +0 -31
  134. package/lib/types/app/options.js +0 -2
  135. package/lib/types/app/utils.d.ts +0 -29
  136. package/lib/types/app/utils.js +0 -2
  137. package/lib/types/bundler.d.ts +0 -34
  138. package/lib/types/bundler.js +0 -2
  139. package/lib/types/index.d.ts +0 -9
  140. package/lib/types/index.js +0 -19
  141. package/lib/types/page.d.ts +0 -110
  142. package/lib/types/page.js +0 -2
  143. package/lib/types/plugin.d.ts +0 -48
  144. package/lib/types/plugin.js +0 -2
  145. package/lib/types/pluginApi/hooks.d.ts +0 -75
  146. package/lib/types/pluginApi/hooks.js +0 -2
  147. package/lib/types/pluginApi/index.d.ts +0 -2
  148. package/lib/types/pluginApi/index.js +0 -14
  149. package/lib/types/pluginApi/pluginApi.d.ts +0 -23
  150. package/lib/types/pluginApi/pluginApi.js +0 -2
  151. package/lib/types/theme.d.ts +0 -33
  152. package/lib/types/theme.js +0 -2
  153. package/lib/types/themeApi/index.d.ts +0 -1
  154. package/lib/types/themeApi/index.js +0 -13
  155. package/lib/types/themeApi/themeApi.d.ts +0 -44
  156. package/lib/types/themeApi/themeApi.js +0 -2
@@ -0,0 +1,845 @@
1
+ import { MarkdownLink, MarkdownSfcBlocks, MarkdownOptions, Markdown, MarkdownHeader } from '@vuepress/markdown';
2
+ import { PageBase, PageData, PageFrontmatter, 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';
5
+
6
+ /**
7
+ * Vuepress bundler
8
+ *
9
+ * It provides abilities to:
10
+ * - dev: run dev server for development
11
+ * - build: bundle assets for deployment
12
+ */
13
+ interface Bundler {
14
+ name: string;
15
+ dev: (app: App) => Promise<() => Promise<void>>;
16
+ build: (app: App) => Promise<void>;
17
+ }
18
+
19
+ /**
20
+ * Vuepress Page
21
+ */
22
+ type Page<ExtraPageData extends Record<any, any> = Record<never, never>, ExtraPageFrontmatter extends Record<any, any> = Record<string, unknown>, ExtraPageFields extends Record<any, any> = Record<never, never>> = PageBase<ExtraPageFrontmatter> & ExtraPageFields & {
23
+ /**
24
+ * Data of the page, which will be available in client code
25
+ */
26
+ data: PageData<ExtraPageData, ExtraPageFrontmatter>;
27
+ /**
28
+ * Raw Content of the page
29
+ */
30
+ content: string;
31
+ /**
32
+ * Rendered content of the page
33
+ */
34
+ contentRendered: string;
35
+ /**
36
+ * Date of the page, in 'yyyy-MM-dd' format
37
+ *
38
+ * @example '2020-09-09'
39
+ */
40
+ date: string;
41
+ /**
42
+ * Dependencies of the page
43
+ */
44
+ deps: string[];
45
+ /**
46
+ * Links of the page
47
+ */
48
+ links: MarkdownLink[];
49
+ /**
50
+ * Markdown env object of the page
51
+ */
52
+ markdownEnv: Record<string, unknown>;
53
+ /**
54
+ * Path of the page that inferred from file path
55
+ *
56
+ * If the page does not come from a file, it would be `null`
57
+ *
58
+ * @example '/guide/index.html'
59
+ */
60
+ pathInferred: string | null;
61
+ /**
62
+ * Locale path prefix of the page
63
+ *
64
+ * @example '/getting-started.html' -> '/'
65
+ * @example '/en/getting-started.html' -> '/en/'
66
+ * @example '/zh/getting-started.html' -> '/zh/'
67
+ */
68
+ pathLocale: string;
69
+ /**
70
+ * Permalink of the page
71
+ *
72
+ * If the page does not have a permalink, it would be `null`
73
+ */
74
+ permalink: string | null;
75
+ /**
76
+ * Custom data to be attached to the page route record of vue-router
77
+ *
78
+ * @see https://router.vuejs.org/api/#meta
79
+ */
80
+ routeMeta: Record<string, unknown>;
81
+ /**
82
+ * Extracted sfc blocks of the page
83
+ */
84
+ sfcBlocks: MarkdownSfcBlocks;
85
+ /**
86
+ * Slug of the page
87
+ */
88
+ slug: string;
89
+ /**
90
+ * Source file path
91
+ *
92
+ * If the page does not come from a file, it would be `null`
93
+ */
94
+ filePath: string | null;
95
+ /**
96
+ * Source file path relative to source directory
97
+ *
98
+ * If the page does not come from a file, it would be `null`
99
+ */
100
+ filePathRelative: string | null;
101
+ /**
102
+ * Component file path
103
+ */
104
+ componentFilePath: string;
105
+ /**
106
+ * Component file path relative to temp directory
107
+ */
108
+ componentFilePathRelative: string;
109
+ /**
110
+ * Component file chunk name
111
+ *
112
+ * Only take effect in webpack
113
+ */
114
+ componentFileChunkName: string;
115
+ /**
116
+ * Page data file path
117
+ */
118
+ dataFilePath: string;
119
+ /**
120
+ * Page data file path relative to temp directory
121
+ */
122
+ dataFilePathRelative: string;
123
+ /**
124
+ * Page data file chunk name
125
+ *
126
+ * Only take effect in webpack
127
+ */
128
+ dataFileChunkName: string;
129
+ /**
130
+ * Rendered html file path
131
+ */
132
+ htmlFilePath: string;
133
+ /**
134
+ * Rendered html file path relative to dest directory
135
+ */
136
+ htmlFilePathRelative: string;
137
+ };
138
+ /**
139
+ * Options to create vuepress page
140
+ */
141
+ interface PageOptions {
142
+ /**
143
+ * If `filePath` is not set, this option will be used as the raw
144
+ * markdown content of the page.
145
+ *
146
+ * If `filePath` is set, this option will be ignored, while the
147
+ * content of the file will be used.
148
+ */
149
+ content?: string;
150
+ /**
151
+ * Absolute file path of the markdown source file.
152
+ */
153
+ filePath?: string;
154
+ /**
155
+ * Default frontmatter of the page, which could be overridden by
156
+ * the frontmatter of the markdown content.
157
+ */
158
+ frontmatter?: PageFrontmatter;
159
+ /**
160
+ * If this option is set, it will be used as the final route path
161
+ * of the page, ignoring the relative path and permalink.
162
+ */
163
+ path?: string;
164
+ }
165
+
166
+ type PromiseOrNot<T> = Promise<T> | T;
167
+ interface Closable {
168
+ close(): void;
169
+ }
170
+ interface Hook<Exposed, Normalized = Exposed, Result = Normalized extends (...args: any) => infer U ? U extends Promise<infer V> ? V : U : void> {
171
+ exposed: Exposed;
172
+ normalized: Normalized;
173
+ result: Result;
174
+ }
175
+ type LifeCycleHook<T extends unknown[] = []> = Hook<(app: App, ...args: T) => PromiseOrNot<void>>;
176
+ type ExtendsHook<T> = Hook<(extendable: T, app: App) => PromiseOrNot<void>>;
177
+ type ClientConfigFileHook = Hook<string | ((app: App) => PromiseOrNot<string>), (app: App) => Promise<string>>;
178
+ type AliasDefineHook = Hook<Record<string, any> | ((app: App, isServer: boolean) => PromiseOrNot<Record<string, any>>), (app: App, isServer: boolean) => Promise<Record<string, any>>>;
179
+ /**
180
+ * List of hooks
181
+ */
182
+ interface Hooks {
183
+ onInitialized: LifeCycleHook;
184
+ onPrepared: LifeCycleHook;
185
+ onWatched: LifeCycleHook<[watchers: Closable[], restart: () => Promise<void>]>;
186
+ onGenerated: LifeCycleHook;
187
+ extendsMarkdownOptions: ExtendsHook<MarkdownOptions>;
188
+ extendsMarkdown: ExtendsHook<Markdown>;
189
+ extendsPageOptions: ExtendsHook<PageOptions>;
190
+ extendsPage: ExtendsHook<Page>;
191
+ extendsBundlerOptions: ExtendsHook<any>;
192
+ clientConfigFile: ClientConfigFileHook;
193
+ alias: AliasDefineHook;
194
+ define: AliasDefineHook;
195
+ }
196
+ /**
197
+ * Name of hooks
198
+ */
199
+ type HooksName = keyof Hooks;
200
+ /**
201
+ * Exposed hooks API that can be accessed by a plugin
202
+ */
203
+ type HooksExposed = {
204
+ [K in HooksName]: Hooks[K]['exposed'];
205
+ };
206
+ /**
207
+ * Normalized hooks
208
+ */
209
+ type HooksNormalized = {
210
+ [K in HooksName]: Hooks[K]['normalized'];
211
+ };
212
+ /**
213
+ * Result of hooks
214
+ */
215
+ type HooksResult = {
216
+ [K in HooksName]: Hooks[K]['result'];
217
+ };
218
+ /**
219
+ * Hook item
220
+ */
221
+ interface HookItem<T extends HooksName> {
222
+ pluginName: string;
223
+ hook: HooksNormalized[T];
224
+ }
225
+ /**
226
+ * Hook items queue
227
+ */
228
+ interface HookQueue<T extends HooksName> {
229
+ name: T;
230
+ items: HookItem<T>[];
231
+ add: (item: HookItem<T>) => void;
232
+ process: (...args: Parameters<HooksNormalized[T]>) => Promise<HooksResult[T][]>;
233
+ }
234
+
235
+ /**
236
+ * Vuepress plugin system
237
+ */
238
+ interface PluginApi {
239
+ /**
240
+ * Plugins that have been used
241
+ */
242
+ plugins: PluginObject[];
243
+ /**
244
+ * All available hooks
245
+ */
246
+ hooks: {
247
+ [K in HooksName]: HookQueue<K>;
248
+ };
249
+ /**
250
+ * Register hooks of plugins
251
+ *
252
+ * Should be invoked before applying a hook
253
+ */
254
+ registerHooks: () => void;
255
+ }
256
+
257
+ /**
258
+ * Vuepress plugin
259
+ *
260
+ * A plugin should be rather:
261
+ * - an object (`PluginObject`)
262
+ * - a function that returns an object (`PluginFunction`)
263
+ *
264
+ * A plugin package should have a `Plugin` as the default export
265
+ */
266
+ type Plugin<T extends PluginObject = PluginObject> = T | PluginFunction<T>;
267
+ /**
268
+ * Vuepress plugin function
269
+ *
270
+ * It accepts plugin options and vuepress app, returns plugin object
271
+ */
272
+ type PluginFunction<T extends PluginObject = PluginObject> = (app: App) => T;
273
+ /**
274
+ * Vuepress plugin object
275
+ */
276
+ interface PluginObject extends Partial<HooksExposed> {
277
+ name: string;
278
+ multiple?: boolean;
279
+ }
280
+ /**
281
+ * Config field for plugins
282
+ */
283
+ type PluginConfig = (Plugin | Plugin[])[];
284
+
285
+ /**
286
+ * Vuepress theme
287
+ *
288
+ * Theme is a special type of plugin, it should be rather:
289
+ * - an object (`ThemeObject`)
290
+ * - a function that returns an object (`ThemeFunction`)
291
+ *
292
+ * A theme package should have a `Theme` as the default export
293
+ */
294
+ type Theme = Plugin<ThemeObject>;
295
+ /**
296
+ * Vuepress theme function
297
+ */
298
+ type ThemeFunction = PluginFunction<ThemeObject>;
299
+ /**
300
+ * Vuepress theme object
301
+ */
302
+ interface ThemeObject extends Omit<PluginObject, 'multiple'> {
303
+ /**
304
+ * Extended parent theme
305
+ */
306
+ extends?: Theme;
307
+ /**
308
+ * Allow using plugins in theme
309
+ */
310
+ plugins?: PluginConfig;
311
+ /**
312
+ * Allow overriding default templateBuild
313
+ */
314
+ templateBuild?: string;
315
+ /**
316
+ * Allow specifying custom template renderer
317
+ */
318
+ templateBuildRenderer?: TemplateRenderer;
319
+ /**
320
+ * Allow overriding default templateDev
321
+ */
322
+ templateDev?: string;
323
+ }
324
+ /**
325
+ * Resolved theme info
326
+ */
327
+ interface ThemeInfo {
328
+ /**
329
+ * Plugins, including theme itself and plugins used by theme
330
+ */
331
+ plugins: PluginConfig;
332
+ /**
333
+ * Default build template
334
+ */
335
+ templateBuild?: string;
336
+ /**
337
+ * Default build template renderer
338
+ */
339
+ templateBuildRenderer?: TemplateRenderer;
340
+ /**
341
+ * Default dev template
342
+ */
343
+ templateDev?: string;
344
+ }
345
+
346
+ /**
347
+ * Vuepress app common config that shared between dev and build
348
+ */
349
+ interface AppConfigCommon extends Partial<SiteData> {
350
+ source: string;
351
+ dest?: string;
352
+ temp?: string;
353
+ cache?: string;
354
+ public?: string;
355
+ debug?: boolean;
356
+ markdown?: MarkdownOptions;
357
+ pagePatterns?: string[];
358
+ permalinkPattern?: string | null;
359
+ bundler: Bundler;
360
+ theme: Theme;
361
+ plugins?: PluginConfig;
362
+ }
363
+ /**
364
+ * Vuepress app config for dev
365
+ */
366
+ interface AppConfigDev {
367
+ /**
368
+ * Specify the host to use for the dev server
369
+ *
370
+ * @default '0.0.0.0'
371
+ */
372
+ host?: string;
373
+ /**
374
+ * Specify the port to use for the dev server
375
+ *
376
+ * @default 8080
377
+ */
378
+ port?: number;
379
+ /**
380
+ * Whether to open the browser after dev-server had been started
381
+ *
382
+ * @default false
383
+ */
384
+ open?: boolean;
385
+ /**
386
+ * Specify the path of the HTML template to be used for dev
387
+ *
388
+ * @default '@vuepress/client/templates/dev.html'
389
+ */
390
+ templateDev?: string;
391
+ }
392
+ /**
393
+ * Vuepress app config for build
394
+ */
395
+ interface AppConfigBuild {
396
+ /**
397
+ * Determine what resource files should be preloaded. Use boolean value to
398
+ * totally enable / disable.
399
+ *
400
+ * @default true
401
+ */
402
+ shouldPreload?: ((file: string, type: string) => boolean) | boolean;
403
+ /**
404
+ * Determine what resource files should be prefetched. Use boolean value to
405
+ * totally enable / disable.
406
+ *
407
+ * @default true
408
+ */
409
+ shouldPrefetch?: ((file: string, type: string) => boolean) | boolean;
410
+ /**
411
+ * Specify the path of the HTML template to be used for build
412
+ *
413
+ * @default '@vuepress/client/templates/build.html'
414
+ */
415
+ templateBuild?: string;
416
+ /**
417
+ * Specify the HTML template renderer to be used for build
418
+ *
419
+ * @default templateRenderer from '@vuepress/utils'
420
+ */
421
+ templateBuildRenderer?: TemplateRenderer;
422
+ }
423
+ /**
424
+ * Vuepress app config
425
+ */
426
+ type AppConfig = AppConfigCommon & AppConfigDev & AppConfigBuild;
427
+ /**
428
+ * Vuepress app options
429
+ */
430
+ type AppOptions = Required<AppConfig>;
431
+
432
+ /**
433
+ * Directory util function
434
+ */
435
+ type AppDirFunction = (...args: string[]) => string;
436
+ /**
437
+ * Directory utils
438
+ */
439
+ interface AppDir {
440
+ cache: AppDirFunction;
441
+ temp: AppDirFunction;
442
+ source: AppDirFunction;
443
+ dest: AppDirFunction;
444
+ public: AppDirFunction;
445
+ client: AppDirFunction;
446
+ }
447
+ /**
448
+ * Environment flags
449
+ */
450
+ interface AppEnv {
451
+ /**
452
+ * Is running in build mode or not
453
+ */
454
+ isBuild: boolean;
455
+ /**
456
+ * Is running in dev mode or not
457
+ */
458
+ isDev: boolean;
459
+ /**
460
+ * Is debug mode enabled or not
461
+ */
462
+ isDebug: boolean;
463
+ }
464
+ /**
465
+ * Write temp file util
466
+ */
467
+ type AppWriteTemp = (file: string, content: string) => Promise<string>;
468
+
469
+ /**
470
+ * Vuepress app
471
+ */
472
+ interface App {
473
+ /**
474
+ * Directory utils
475
+ */
476
+ dir: AppDir;
477
+ /**
478
+ * Environment flags
479
+ */
480
+ env: AppEnv;
481
+ /**
482
+ * Options that filled all optional fields with a default value
483
+ */
484
+ options: AppOptions;
485
+ /**
486
+ * Plugin system
487
+ */
488
+ pluginApi: PluginApi;
489
+ /**
490
+ * Site data, which will be used in client side
491
+ */
492
+ siteData: SiteData;
493
+ /**
494
+ * Version of vuepress core
495
+ */
496
+ version: string;
497
+ /**
498
+ * Write temp file
499
+ */
500
+ writeTemp: AppWriteTemp;
501
+ /**
502
+ * Use a plugin
503
+ */
504
+ use: (plugin: Plugin) => this;
505
+ /**
506
+ * Initialize app.
507
+ *
508
+ * - Theme and plugin will be loaded.
509
+ * - Layouts and pages will be resolved.
510
+ */
511
+ init: () => Promise<void>;
512
+ /**
513
+ * Prepare data for client and write temp files.
514
+ *
515
+ * Should be called after `app.init()`.
516
+ */
517
+ prepare: () => Promise<void>;
518
+ /**
519
+ * Markdown-it instance.
520
+ *
521
+ * Only available after initialization
522
+ */
523
+ markdown: Markdown;
524
+ /**
525
+ * Page objects.
526
+ *
527
+ * Only available after initialization
528
+ */
529
+ pages: Page[];
530
+ }
531
+ /**
532
+ * Vuepress dev app
533
+ */
534
+ interface DevApp extends App {
535
+ /**
536
+ * Start dev server
537
+ *
538
+ * Should be called after `app.prepare()`.
539
+ */
540
+ dev: () => ReturnType<Bundler['dev']>;
541
+ }
542
+ /**
543
+ * Vuepress build app
544
+ */
545
+ interface BuildApp extends App {
546
+ /**
547
+ * Build static files
548
+ *
549
+ * Should be called after `app.prepare()`.
550
+ */
551
+ build: () => ReturnType<Bundler['build']>;
552
+ }
553
+
554
+ /**
555
+ * Generate client configs temp file
556
+ */
557
+ declare const prepareClientConfigs: (app: App) => Promise<void>;
558
+
559
+ /**
560
+ * Generate page component temp file of a single page
561
+ */
562
+ declare const preparePageComponent: (app: App, page: Page) => Promise<void>;
563
+
564
+ /**
565
+ * Generate page data temp file of a single page
566
+ */
567
+ declare const preparePageData: (app: App, page: Page) => Promise<void>;
568
+
569
+ /**
570
+ * Generate page key to page component map temp file
571
+ */
572
+ declare const preparePagesComponents: (app: App) => Promise<void>;
573
+
574
+ /**
575
+ * Generate page path to page data map temp file
576
+ */
577
+ declare const preparePagesData: (app: App) => Promise<void>;
578
+
579
+ /**
580
+ * Generate routes temp file
581
+ */
582
+ declare const preparePagesRoutes: (app: App) => Promise<void>;
583
+
584
+ /**
585
+ * Generate site data temp file
586
+ */
587
+ declare const prepareSiteData: (app: App) => Promise<void>;
588
+
589
+ /**
590
+ * Initialize a vuepress app
591
+ *
592
+ * Plugins should be used before initialization.
593
+ */
594
+ declare const appInit: (app: App) => Promise<void>;
595
+
596
+ /**
597
+ * Prepare files for development or build
598
+ *
599
+ * - page components
600
+ * - routes
601
+ * - site data
602
+ * - other files that generated by plugins
603
+ */
604
+ declare const appPrepare: (app: App) => Promise<void>;
605
+
606
+ declare const appUse: (app: App, rawPlugin: Plugin) => App;
607
+
608
+ /**
609
+ * Create vuepress app
610
+ */
611
+ declare const createBaseApp: (config: AppConfig, isBuild?: boolean) => App;
612
+
613
+ /**
614
+ * Create vuepress build app
615
+ */
616
+ declare const createBuildApp: (config: AppConfig) => BuildApp;
617
+
618
+ /**
619
+ * Create vuepress dev app
620
+ */
621
+ declare const createDevApp: (config: AppConfig) => DevApp;
622
+
623
+ /**
624
+ * Create directory util function
625
+ */
626
+ declare const createAppDirFunction: (baseDir: string) => AppDirFunction;
627
+ /**
628
+ * Resolve directory utils for vuepress app
629
+ */
630
+ declare const resolveAppDir: (options: AppOptions) => AppDir;
631
+
632
+ /**
633
+ * Resolve environment flags for vuepress app
634
+ */
635
+ declare const resolveAppEnv: (options: AppOptions, isBuild: boolean) => AppEnv;
636
+
637
+ /**
638
+ * Create app options with default values
639
+ */
640
+ declare const resolveAppOptions: ({ base, lang, title, description, head, locales, source, dest, temp, cache, public: publicDir, host, port, open, templateDev, shouldPreload, shouldPrefetch, templateBuild, bundler, debug, markdown, pagePatterns, permalinkPattern, plugins, theme, }: AppConfig) => AppOptions;
641
+
642
+ /**
643
+ * Resolve pages for vuepress app
644
+ */
645
+ declare const resolveAppPages: (app: App) => Promise<Page[]>;
646
+
647
+ /**
648
+ * Resolve site data for vuepress app
649
+ *
650
+ * Site data will also be used in client
651
+ */
652
+ declare const resolveAppSiteData: (options: AppOptions) => SiteData;
653
+
654
+ /**
655
+ * Resolve version of vuepress app
656
+ */
657
+ declare const resolveAppVersion: () => string;
658
+
659
+ /**
660
+ * Resolve write temp file util for vuepress app
661
+ */
662
+ declare const resolveAppWriteTemp: (dir: AppDir) => AppWriteTemp;
663
+
664
+ /**
665
+ * Resolve a plugin object according to name / path / module and config
666
+ */
667
+ declare const resolvePluginObject: <T extends PluginObject = PluginObject>(app: App, plugin: Plugin<T>) => T;
668
+
669
+ /**
670
+ * Resolve theme info and its parent theme info
671
+ */
672
+ declare const resolveThemeInfo: (app: App, theme: Theme) => ThemeInfo;
673
+
674
+ declare const createPage: (app: App, options: PageOptions) => Promise<Page>;
675
+
676
+ /**
677
+ * Infer page path according to file path
678
+ */
679
+ declare const inferPagePath: ({ app, filePathRelative, }: {
680
+ app: App;
681
+ filePathRelative: string | null;
682
+ }) => {
683
+ pathInferred: string | null;
684
+ pathLocale: string;
685
+ };
686
+
687
+ /**
688
+ * Render page content and extract related info
689
+ */
690
+ declare const renderPageContent: ({ app, content, filePath, filePathRelative, options, }: {
691
+ app: App;
692
+ content: string;
693
+ filePath: string | null;
694
+ filePathRelative: string | null;
695
+ options: PageOptions;
696
+ }) => {
697
+ contentRendered: string;
698
+ deps: string[];
699
+ markdownEnv: Record<string, unknown>;
700
+ frontmatter: PageFrontmatter;
701
+ headers: MarkdownHeader[];
702
+ links: MarkdownLink[];
703
+ sfcBlocks: MarkdownSfcBlocks;
704
+ title: string;
705
+ };
706
+
707
+ /**
708
+ * Resolve page component and related info
709
+ */
710
+ declare const resolvePageComponentInfo: ({ app, htmlFilePathRelative, key, }: {
711
+ app: App;
712
+ htmlFilePathRelative: string;
713
+ key: string;
714
+ }) => Promise<{
715
+ componentFilePath: string;
716
+ componentFilePathRelative: string;
717
+ componentFileChunkName: string;
718
+ }>;
719
+
720
+ /**
721
+ * Resolve page data file path
722
+ */
723
+ declare const resolvePageDataInfo: ({ app, htmlFilePathRelative, key, }: {
724
+ app: App;
725
+ htmlFilePathRelative: string;
726
+ key: string;
727
+ }) => {
728
+ dataFilePath: string;
729
+ dataFilePathRelative: string;
730
+ dataFileChunkName: string;
731
+ };
732
+
733
+ /**
734
+ * Resolve page date according to frontmatter or file path
735
+ *
736
+ * It will be resolved as 'yyyy-MM-dd' format
737
+ */
738
+ declare const resolvePageDate: ({ frontmatter, filePathRelative, }: {
739
+ frontmatter: PageFrontmatter;
740
+ filePathRelative: string | null;
741
+ }) => string;
742
+
743
+ /**
744
+ * Resolve page file content according to filePath or options content
745
+ */
746
+ declare const resolvePageFileContent: ({ filePath, options, }: {
747
+ filePath: string | null;
748
+ options: PageOptions;
749
+ }) => Promise<string>;
750
+
751
+ /**
752
+ * Resolve absolute and relative path of page file
753
+ */
754
+ declare const resolvePageFilePath: ({ app, options, }: {
755
+ app: App;
756
+ options: PageOptions;
757
+ }) => {
758
+ filePath: string | null;
759
+ filePathRelative: string | null;
760
+ };
761
+
762
+ /**
763
+ * Resolve page rendered html file path
764
+ */
765
+ declare const resolvePageHtmlInfo: ({ app, path: pagePath, }: {
766
+ app: App;
767
+ path: string;
768
+ }) => {
769
+ htmlFilePath: string;
770
+ htmlFilePathRelative: string;
771
+ };
772
+
773
+ /**
774
+ * Resolve page key to identify the page
775
+ */
776
+ declare const resolvePageKey: ({ path }: {
777
+ path: string;
778
+ }) => string;
779
+
780
+ /**
781
+ * Resolve language of page
782
+ */
783
+ declare const resolvePageLang: ({ app, frontmatter, pathLocale, }: {
784
+ app: App;
785
+ frontmatter: PageFrontmatter;
786
+ pathLocale: string;
787
+ }) => string;
788
+
789
+ /**
790
+ * Resolve the final route path of a page
791
+ */
792
+ declare const resolvePagePath: ({ permalink, pathInferred, options, }: {
793
+ permalink: string | null;
794
+ pathInferred: string | null;
795
+ options: PageOptions;
796
+ }) => string;
797
+
798
+ /**
799
+ * Resolve page permalink from frontmatter / options / pattern
800
+ */
801
+ declare const resolvePagePermalink: ({ app, frontmatter, slug, date, pathInferred, pathLocale, }: {
802
+ app: App;
803
+ frontmatter: PageFrontmatter;
804
+ slug: string;
805
+ date: string;
806
+ pathInferred: string | null;
807
+ pathLocale: string;
808
+ }) => string | null;
809
+
810
+ /**
811
+ * Resolve page route meta
812
+ */
813
+ declare const resolvePageRouteMeta: ({ frontmatter, }: {
814
+ frontmatter: PageFrontmatter;
815
+ }) => Record<string, unknown>;
816
+
817
+ /**
818
+ * Resolve page slug from filename
819
+ */
820
+ declare const resolvePageSlug: ({ filePathRelative, }: {
821
+ filePathRelative: string | null;
822
+ }) => string;
823
+
824
+ /**
825
+ * Create hook queue for plugin system
826
+ */
827
+ declare const createHookQueue: <T extends keyof Hooks>(name: T) => HookQueue<T>;
828
+
829
+ declare const createPluginApi: () => PluginApi;
830
+
831
+ declare const createPluginApiHooks: () => PluginApi['hooks'];
832
+
833
+ declare const createPluginApiRegisterHooks: (plugins: PluginApi['plugins'], hooks: PluginApi['hooks']) => PluginApi['registerHooks'];
834
+
835
+ /**
836
+ * Normalize alias and define hook
837
+ */
838
+ declare const normalizeAliasDefineHook: (hook: AliasDefineHook['exposed']) => AliasDefineHook['normalized'];
839
+
840
+ /**
841
+ * Normalize hook for client config file
842
+ */
843
+ declare const normalizeClientConfigFileHook: (hook: ClientConfigFileHook['exposed']) => ClientConfigFileHook['normalized'];
844
+
845
+ export { type AliasDefineHook, type App, type AppConfig, type AppConfigBuild, type AppConfigCommon, type AppConfigDev, type AppDir, type AppDirFunction, type AppEnv, type AppOptions, type AppWriteTemp, type BuildApp, type Bundler, type ClientConfigFileHook, 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, appInit, appPrepare, appUse, createAppDirFunction, createBaseApp, createBuildApp, createDevApp, createHookQueue, createPage, createPluginApi, createPluginApiHooks, createPluginApiRegisterHooks, inferPagePath, normalizeAliasDefineHook, normalizeClientConfigFileHook, prepareClientConfigs, preparePageComponent, preparePageData, preparePagesComponents, preparePagesData, preparePagesRoutes, prepareSiteData, renderPageContent, resolveAppDir, resolveAppEnv, resolveAppOptions, resolveAppPages, resolveAppSiteData, resolveAppVersion, resolveAppWriteTemp, resolvePageComponentInfo, resolvePageDataInfo, resolvePageDate, resolvePageFileContent, resolvePageFilePath, resolvePageHtmlInfo, resolvePageKey, resolvePageLang, resolvePagePath, resolvePagePermalink, resolvePageRouteMeta, resolvePageSlug, resolvePluginObject, resolveThemeInfo };