@vuepress/core 2.0.0-beta.5 → 2.0.0-beta.50

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 +850 -0
  2. package/dist/index.js +1050 -0
  3. package/package.json +34 -17
  4. package/CHANGELOG.md +0 -271
  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,850 @@
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
+ declare 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
+ declare type PromiseOrNot<T> = Promise<T> | T;
162
+ declare type Closable = {
163
+ close(): void;
164
+ };
165
+ declare 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
+ declare type LifeCycleHook<T extends unknown[] = []> = Hook<(app: App, ...args: T) => PromiseOrNot<void>>;
171
+ declare type ExtendsHook<T> = Hook<(extendable: T, app: App) => PromiseOrNot<void>>;
172
+ declare type ClientConfigFileHook = Hook<string | ((app: App) => PromiseOrNot<string>), (app: App) => Promise<string>>;
173
+ declare 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
+ declare type HooksName = keyof Hooks;
195
+ /**
196
+ * Exposed hooks API that can be accessed by a plugin
197
+ */
198
+ declare type HooksExposed = {
199
+ [K in HooksName]: Hooks[K]['exposed'];
200
+ };
201
+ /**
202
+ * Normalized hooks
203
+ */
204
+ declare type HooksNormalized = {
205
+ [K in HooksName]: Hooks[K]['normalized'];
206
+ };
207
+ /**
208
+ * Result of hooks
209
+ */
210
+ declare 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
+ declare 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
+ declare 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
+ declare 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
+ declare type Theme = Plugin<ThemeObject>;
290
+ /**
291
+ * Vuepress theme function
292
+ */
293
+ declare 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
+ * Specify the layouts directory or components map
304
+ */
305
+ layouts?: string | Record<string, string>;
306
+ /**
307
+ * Allow using plugins in theme
308
+ */
309
+ plugins?: PluginConfig;
310
+ /**
311
+ * Allow overriding default templateBuild
312
+ */
313
+ templateBuild?: string;
314
+ /**
315
+ * Allow overriding default templateDev
316
+ */
317
+ templateDev?: string;
318
+ }
319
+ /**
320
+ * Resolved theme info
321
+ */
322
+ interface ThemeInfo {
323
+ /**
324
+ * Layout components
325
+ */
326
+ layouts: Record<string, string>;
327
+ /**
328
+ * Plugins, including theme itself and plugins used by theme
329
+ */
330
+ plugins: PluginConfig;
331
+ /**
332
+ * Default build template
333
+ */
334
+ templateBuild?: string;
335
+ /**
336
+ * Default dev template
337
+ */
338
+ templateDev?: string;
339
+ }
340
+
341
+ /**
342
+ * Vuepress app common config that shared between dev and build
343
+ */
344
+ interface AppConfigCommon extends Partial<SiteData> {
345
+ source: string;
346
+ dest?: string;
347
+ temp?: string;
348
+ cache?: string;
349
+ public?: string;
350
+ debug?: boolean;
351
+ markdown?: MarkdownOptions;
352
+ pagePatterns?: string[];
353
+ permalinkPattern?: string | null;
354
+ bundler: Bundler;
355
+ theme: Theme;
356
+ plugins?: PluginConfig;
357
+ }
358
+ /**
359
+ * Vuepress app config for dev
360
+ */
361
+ interface AppConfigDev {
362
+ /**
363
+ * Specify the host to use for the dev server
364
+ *
365
+ * @default '0.0.0.0'
366
+ */
367
+ host?: string;
368
+ /**
369
+ * Specify the port to use for the dev server
370
+ *
371
+ * @default 8080
372
+ */
373
+ port?: number;
374
+ /**
375
+ * Whether to open the browser after dev-server had been started
376
+ *
377
+ * @default false
378
+ */
379
+ open?: boolean;
380
+ /**
381
+ * Specify the path of the HTML template to be used for dev
382
+ *
383
+ * @default '@vuepress/client/templates/dev.html'
384
+ */
385
+ templateDev?: string;
386
+ }
387
+ /**
388
+ * Vuepress app config for build
389
+ */
390
+ interface AppConfigBuild {
391
+ /**
392
+ * Determine what resource files should be preloaded. Use boolean value to
393
+ * totally enable / disable.
394
+ *
395
+ * @default true
396
+ */
397
+ shouldPreload?: ((file: string, type: string) => boolean) | boolean;
398
+ /**
399
+ * Determine what resource files should be prefetched. Use boolean value to
400
+ * totally enable / disable.
401
+ *
402
+ * @default false
403
+ */
404
+ shouldPrefetch?: ((file: string, type: string) => boolean) | boolean;
405
+ /**
406
+ * Specify the path of the HTML template to be used for build
407
+ *
408
+ * @default '@vuepress/client/templates/build.html'
409
+ */
410
+ templateBuild?: string;
411
+ }
412
+ /**
413
+ * Vuepress app config
414
+ */
415
+ declare type AppConfig = AppConfigCommon & AppConfigDev & AppConfigBuild;
416
+ /**
417
+ * Vuepress app options
418
+ */
419
+ declare type AppOptions = Required<AppConfig>;
420
+
421
+ /**
422
+ * Directory util function
423
+ */
424
+ declare type AppDirFunction = (...args: string[]) => string;
425
+ /**
426
+ * Directory utils
427
+ */
428
+ interface AppDir {
429
+ cache: AppDirFunction;
430
+ temp: AppDirFunction;
431
+ source: AppDirFunction;
432
+ dest: AppDirFunction;
433
+ public: AppDirFunction;
434
+ client: AppDirFunction;
435
+ }
436
+ /**
437
+ * Environment flags
438
+ */
439
+ interface AppEnv {
440
+ /**
441
+ * Is running in build mode or not
442
+ */
443
+ isBuild: boolean;
444
+ /**
445
+ * Is running in dev mode or not
446
+ */
447
+ isDev: boolean;
448
+ /**
449
+ * Is debug mode enabled or not
450
+ */
451
+ isDebug: boolean;
452
+ }
453
+ /**
454
+ * Write temp file util
455
+ */
456
+ declare type AppWriteTemp = (file: string, content: string) => Promise<string>;
457
+
458
+ /**
459
+ * Vuepress app
460
+ */
461
+ interface App {
462
+ /**
463
+ * Directory utils
464
+ */
465
+ dir: AppDir;
466
+ /**
467
+ * Environment flags
468
+ */
469
+ env: AppEnv;
470
+ /**
471
+ * Options that filled all optional fields with a default value
472
+ */
473
+ options: AppOptions;
474
+ /**
475
+ * Plugin system
476
+ */
477
+ pluginApi: PluginApi;
478
+ /**
479
+ * Site data, which will be used in client side
480
+ */
481
+ siteData: SiteData;
482
+ /**
483
+ * Version of vuepress core
484
+ */
485
+ version: string;
486
+ /**
487
+ * Write temp file
488
+ */
489
+ writeTemp: AppWriteTemp;
490
+ /**
491
+ * Use a plugin
492
+ */
493
+ use: (plugin: Plugin) => this;
494
+ /**
495
+ * Initialize app.
496
+ *
497
+ * - Theme and plugin will be loaded.
498
+ * - Layouts and pages will be resolved.
499
+ */
500
+ init: () => Promise<void>;
501
+ /**
502
+ * Prepare data for client and write temp files.
503
+ *
504
+ * Should be called after `app.init()`.
505
+ */
506
+ prepare: () => Promise<void>;
507
+ /**
508
+ * Layout components.
509
+ *
510
+ * Only available after initialization
511
+ */
512
+ layouts: Record<string, string>;
513
+ /**
514
+ * Markdown-it instance.
515
+ *
516
+ * Only available after initialization
517
+ */
518
+ markdown: Markdown;
519
+ /**
520
+ * Page objects.
521
+ *
522
+ * Only available after initialization
523
+ */
524
+ pages: Page[];
525
+ }
526
+ /**
527
+ * Vuepress dev app
528
+ */
529
+ interface DevApp extends App {
530
+ /**
531
+ * Start dev server
532
+ *
533
+ * Should be called after `app.prepare()`.
534
+ */
535
+ dev: () => ReturnType<Bundler['dev']>;
536
+ }
537
+ /**
538
+ * Vuepress build app
539
+ */
540
+ interface BuildApp extends App {
541
+ /**
542
+ * Build static files
543
+ *
544
+ * Should be called after `app.prepare()`.
545
+ */
546
+ build: () => ReturnType<Bundler['build']>;
547
+ }
548
+
549
+ /**
550
+ * Generate client configs temp file
551
+ */
552
+ declare const prepareClientConfigs: (app: App) => Promise<void>;
553
+
554
+ /**
555
+ * Generate layout components temp file
556
+ */
557
+ declare const prepareLayoutComponents: (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: () => Promise<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
+ /**
675
+ * Resolve layouts from `layouts` option
676
+ */
677
+ declare const resolveThemeLayouts: (layouts?: ThemeObject['layouts']) => Record<string, string>;
678
+
679
+ declare const createPage: (app: App, options: PageOptions) => Promise<Page>;
680
+
681
+ /**
682
+ * Infer page path according to file path
683
+ */
684
+ declare const inferPagePath: ({ app, filePathRelative, }: {
685
+ app: App;
686
+ filePathRelative: string | null;
687
+ }) => {
688
+ pathInferred: string | null;
689
+ pathLocale: string;
690
+ };
691
+
692
+ /**
693
+ * Render page content and extract related info
694
+ */
695
+ declare const renderPageContent: ({ app, content, filePath, filePathRelative, options, }: {
696
+ app: App;
697
+ content: string;
698
+ filePath: string | null;
699
+ filePathRelative: string | null;
700
+ options: PageOptions;
701
+ }) => Promise<{
702
+ contentRendered: string;
703
+ deps: string[];
704
+ excerpt: string;
705
+ frontmatter: PageFrontmatter;
706
+ headers: MarkdownHeader[];
707
+ links: MarkdownLink[];
708
+ sfcBlocks: MarkdownSfcBlocks;
709
+ title: string;
710
+ }>;
711
+
712
+ /**
713
+ * Resolve page component and related info
714
+ */
715
+ declare const resolvePageComponentInfo: ({ app, htmlFilePathRelative, key, }: {
716
+ app: App;
717
+ htmlFilePathRelative: string;
718
+ key: string;
719
+ }) => Promise<{
720
+ componentFilePath: string;
721
+ componentFilePathRelative: string;
722
+ componentFileChunkName: string;
723
+ }>;
724
+
725
+ /**
726
+ * Resolve page data file path
727
+ */
728
+ declare const resolvePageDataInfo: ({ app, htmlFilePathRelative, key, }: {
729
+ app: App;
730
+ htmlFilePathRelative: string;
731
+ key: string;
732
+ }) => {
733
+ dataFilePath: string;
734
+ dataFilePathRelative: string;
735
+ dataFileChunkName: string;
736
+ };
737
+
738
+ /**
739
+ * Resolve page date according to frontmatter or file path
740
+ *
741
+ * It will be resolved as 'yyyy-MM-dd' format
742
+ */
743
+ declare const resolvePageDate: ({ frontmatter, filePathRelative, }: {
744
+ frontmatter: PageFrontmatter;
745
+ filePathRelative: string | null;
746
+ }) => string;
747
+
748
+ /**
749
+ * Resolve page file content according to filePath or options content
750
+ */
751
+ declare const resolvePageFileContent: ({ filePath, options, }: {
752
+ filePath: string | null;
753
+ options: PageOptions;
754
+ }) => Promise<string>;
755
+
756
+ /**
757
+ * Resolve absolute and relative path of page file
758
+ */
759
+ declare const resolvePageFilePath: ({ app, options, }: {
760
+ app: App;
761
+ options: PageOptions;
762
+ }) => {
763
+ filePath: string | null;
764
+ filePathRelative: string | null;
765
+ };
766
+
767
+ /**
768
+ * Resolve page rendered html file path
769
+ */
770
+ declare const resolvePageHtmlInfo: ({ app, path: pagePath, }: {
771
+ app: App;
772
+ path: string;
773
+ }) => {
774
+ htmlFilePath: string;
775
+ htmlFilePathRelative: string;
776
+ };
777
+
778
+ /**
779
+ * Resolve page key to identify the page
780
+ */
781
+ declare const resolvePageKey: ({ path }: {
782
+ path: string;
783
+ }) => string;
784
+
785
+ /**
786
+ * Resolve language of page
787
+ */
788
+ declare const resolvePageLang: ({ app, frontmatter, pathLocale, }: {
789
+ app: App;
790
+ frontmatter: PageFrontmatter;
791
+ pathLocale: string;
792
+ }) => string;
793
+
794
+ /**
795
+ * Resolve the final route path of a page
796
+ */
797
+ declare const resolvePagePath: ({ permalink, pathInferred, options, }: {
798
+ permalink: string | null;
799
+ pathInferred: string | null;
800
+ options: PageOptions;
801
+ }) => string;
802
+
803
+ /**
804
+ * Resolve page permalink from frontmatter / options / pattern
805
+ */
806
+ declare const resolvePagePermalink: ({ app, frontmatter, slug, date, pathInferred, pathLocale, }: {
807
+ app: App;
808
+ frontmatter: PageFrontmatter;
809
+ slug: string;
810
+ date: string;
811
+ pathInferred: string | null;
812
+ pathLocale: string;
813
+ }) => string | null;
814
+
815
+ /**
816
+ * Resolve page route meta
817
+ */
818
+ declare const resolvePageRouteMeta: ({ frontmatter, }: {
819
+ frontmatter: PageFrontmatter;
820
+ }) => Record<string, unknown>;
821
+
822
+ /**
823
+ * Resolve page slug from filename
824
+ */
825
+ declare const resolvePageSlug: ({ filePathRelative, }: {
826
+ filePathRelative: string | null;
827
+ }) => string;
828
+
829
+ /**
830
+ * Create hook queue for plugin system
831
+ */
832
+ declare const createHookQueue: <T extends keyof Hooks>(name: T) => HookQueue<T>;
833
+
834
+ declare const createPluginApi: () => PluginApi;
835
+
836
+ declare const createPluginApiHooks: () => PluginApi['hooks'];
837
+
838
+ declare const createPluginApiRegisterHooks: (plugins: PluginApi['plugins'], hooks: PluginApi['hooks']) => PluginApi['registerHooks'];
839
+
840
+ /**
841
+ * Normalize alias and define hook
842
+ */
843
+ declare const normalizeAliasDefineHook: (hook: AliasDefineHook['exposed']) => AliasDefineHook['normalized'];
844
+
845
+ /**
846
+ * Normalize hook for client config file
847
+ */
848
+ declare const normalizeClientConfigFileHook: (hook: ClientConfigFileHook['exposed']) => ClientConfigFileHook['normalized'];
849
+
850
+ 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, prepareLayoutComponents, 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, resolveThemeLayouts };