@vuepress/core 2.0.0-beta.6 → 2.0.0-beta.60

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