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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (154) hide show
  1. package/dist/index.d.ts +845 -0
  2. package/dist/index.js +1039 -0
  3. package/package.json +34 -17
  4. package/CHANGELOG.md +0 -338
  5. package/lib/app/appInit.d.ts +0 -7
  6. package/lib/app/appInit.js +0 -26
  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 -28
  11. package/lib/app/appUseByConfig.d.ts +0 -2
  12. package/lib/app/appUseByConfig.js +0 -11
  13. package/lib/app/createApp.d.ts +0 -5
  14. package/lib/app/createApp.js +0 -55
  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 -47
  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 -10
  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 -17
  33. package/lib/app/normalizePluginConfig.d.ts +0 -2
  34. package/lib/app/normalizePluginConfig.js +0 -15
  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 -112
  69. package/lib/page/index.d.ts +0 -18
  70. package/lib/page/index.js +0 -30
  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 -38
  75. package/lib/page/resolvePageContent.d.ts +0 -11
  76. package/lib/page/resolvePageContent.js +0 -30
  77. package/lib/page/resolvePageDataInfo.d.ts +0 -12
  78. package/lib/page/resolvePageDataInfo.js +0 -17
  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 -10
  82. package/lib/page/resolvePageExcerpt.js +0 -16
  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/resolvePageHtmlInfo.d.ts +0 -11
  90. package/lib/page/resolvePageHtmlInfo.js +0 -18
  91. package/lib/page/resolvePageKey.d.ts +0 -6
  92. package/lib/page/resolvePageKey.js +0 -9
  93. package/lib/page/resolvePageLang.d.ts +0 -9
  94. package/lib/page/resolvePageLang.js +0 -15
  95. package/lib/page/resolvePagePath.d.ts +0 -9
  96. package/lib/page/resolvePagePath.js +0 -19
  97. package/lib/page/resolvePagePermalink.d.ts +0 -11
  98. package/lib/page/resolvePagePermalink.js +0 -32
  99. package/lib/page/resolvePageRoutesInfo.d.ts +0 -11
  100. package/lib/page/resolvePageRoutesInfo.js +0 -15
  101. package/lib/page/resolvePageSlug.d.ts +0 -6
  102. package/lib/page/resolvePageSlug.js +0 -17
  103. package/lib/page/resolvePageTitle.d.ts +0 -9
  104. package/lib/page/resolvePageTitle.js +0 -26
  105. package/lib/pluginApi/createHookQueue.d.ts +0 -5
  106. package/lib/pluginApi/createHookQueue.js +0 -81
  107. package/lib/pluginApi/createPluginApi.d.ts +0 -2
  108. package/lib/pluginApi/createPluginApi.js +0 -16
  109. package/lib/pluginApi/createPluginApiHooks.d.ts +0 -2
  110. package/lib/pluginApi/createPluginApiHooks.js +0 -24
  111. package/lib/pluginApi/createPluginApiRegisterHooks.d.ts +0 -2
  112. package/lib/pluginApi/createPluginApiRegisterHooks.js +0 -54
  113. package/lib/pluginApi/index.d.ts +0 -6
  114. package/lib/pluginApi/index.js +0 -18
  115. package/lib/pluginApi/normalizeClientFilesHook.d.ts +0 -5
  116. package/lib/pluginApi/normalizeClientFilesHook.js +0 -28
  117. package/lib/pluginApi/normalizeReturnObjectHook.d.ts +0 -5
  118. package/lib/pluginApi/normalizeReturnObjectHook.js +0 -9
  119. package/lib/themeApi/createThemeApi.d.ts +0 -7
  120. package/lib/themeApi/createThemeApi.js +0 -30
  121. package/lib/themeApi/index.d.ts +0 -3
  122. package/lib/themeApi/index.js +0 -15
  123. package/lib/themeApi/resolveThemeInfo.d.ts +0 -2
  124. package/lib/themeApi/resolveThemeInfo.js +0 -32
  125. package/lib/themeApi/resolveThemeLayouts.d.ts +0 -5
  126. package/lib/themeApi/resolveThemeLayouts.js +0 -32
  127. package/lib/types/app/app.d.ts +0 -30
  128. package/lib/types/app/app.js +0 -2
  129. package/lib/types/app/index.d.ts +0 -3
  130. package/lib/types/app/index.js +0 -15
  131. package/lib/types/app/options.d.ts +0 -31
  132. package/lib/types/app/options.js +0 -2
  133. package/lib/types/app/utils.d.ts +0 -29
  134. package/lib/types/app/utils.js +0 -2
  135. package/lib/types/bundler.d.ts +0 -34
  136. package/lib/types/bundler.js +0 -2
  137. package/lib/types/index.d.ts +0 -9
  138. package/lib/types/index.js +0 -19
  139. package/lib/types/page.d.ts +0 -110
  140. package/lib/types/page.js +0 -2
  141. package/lib/types/plugin.d.ts +0 -48
  142. package/lib/types/plugin.js +0 -2
  143. package/lib/types/pluginApi/hooks.d.ts +0 -75
  144. package/lib/types/pluginApi/hooks.js +0 -2
  145. package/lib/types/pluginApi/index.d.ts +0 -2
  146. package/lib/types/pluginApi/index.js +0 -14
  147. package/lib/types/pluginApi/pluginApi.d.ts +0 -23
  148. package/lib/types/pluginApi/pluginApi.js +0 -2
  149. package/lib/types/theme.d.ts +0 -33
  150. package/lib/types/theme.js +0 -2
  151. package/lib/types/themeApi/index.d.ts +0 -1
  152. package/lib/types/themeApi/index.js +0 -13
  153. package/lib/types/themeApi/themeApi.d.ts +0 -44
  154. package/lib/types/themeApi/themeApi.js +0 -2
@@ -1,5 +0,0 @@
1
- import type { AppConfig, AppOptions } from '../types';
2
- /**
3
- * Create app options with default values
4
- */
5
- export declare const createAppOptions: ({ base, lang, title, description, head, locales, theme, themeConfig, bundler, bundlerConfig, source, dest, temp, cache, public: publicDir, markdown, host, port, debug, open, pagePatterns, templateDev, templateSSR, shouldPreload, shouldPrefetch, }: AppConfig) => AppOptions;
@@ -1,47 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.createAppOptions = void 0;
4
- const utils_1 = require("@vuepress/utils");
5
- /**
6
- * Create app options with default values
7
- */
8
- const createAppOptions = ({
9
- // site config
10
- base = '/', lang = 'en-US', title = '', description = '', head = [], locales = {},
11
- // theme config
12
- theme = '@vuepress/default', themeConfig = {},
13
- // bundler config
14
- bundler = '@vuepress/webpack', bundlerConfig = {},
15
- // directory config
16
- source, dest = utils_1.path.resolve(source, '.vuepress/dist'), temp = utils_1.path.resolve(source, '.vuepress/.temp'), cache = utils_1.path.resolve(source, '.vuepress/.cache'), public: publicDir = utils_1.path.resolve(source, '.vuepress/public'),
17
- // markdown config
18
- markdown = {},
19
- // development config
20
- host = '0.0.0.0', port = 8080, debug = false, open = false, pagePatterns = ['**/*.md', '!.vuepress', '!node_modules'], templateDev = utils_1.path.normalize(require.resolve('@vuepress/client/templates/index.dev.html')), templateSSR = utils_1.path.normalize(require.resolve('@vuepress/client/templates/index.ssr.html')), shouldPreload = true, shouldPrefetch = false, }) => ({
21
- base,
22
- lang,
23
- title,
24
- description,
25
- head,
26
- locales,
27
- theme,
28
- themeConfig,
29
- bundler,
30
- bundlerConfig,
31
- source,
32
- dest,
33
- temp,
34
- cache,
35
- public: publicDir,
36
- markdown,
37
- debug,
38
- host,
39
- port,
40
- open,
41
- pagePatterns,
42
- templateDev,
43
- templateSSR,
44
- shouldPreload,
45
- shouldPrefetch,
46
- });
47
- exports.createAppOptions = createAppOptions;
@@ -1,5 +0,0 @@
1
- import type { App, Page } from '../types';
2
- /**
3
- * Create pages for vuepress app
4
- */
5
- export declare const createAppPages: (app: App) => Promise<Page[]>;
@@ -1,36 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.createAppPages = void 0;
4
- const utils_1 = require("@vuepress/utils");
5
- const page_1 = require("../page");
6
- const log = utils_1.debug('vuepress:core/app');
7
- /**
8
- * Create pages for vuepress app
9
- */
10
- const createAppPages = async (app) => {
11
- log('createAppPages start');
12
- // resolve page file paths according to the page patterns
13
- const pagePaths = await utils_1.globby(app.options.pagePatterns, {
14
- cwd: app.dir.source(),
15
- });
16
- // create pages from files
17
- const pages = await Promise.all(pagePaths.map(async (filePath) => {
18
- const pageOptions = { filePath };
19
- // plugin hook: extendsPageOptions
20
- const extendsPageOptions = await app.pluginApi.hooks.extendsPageOptions.process(filePath, app);
21
- extendsPageOptions.forEach((item) => Object.assign(pageOptions, item));
22
- return page_1.createPage(app, pageOptions);
23
- }));
24
- // if there is no 404 page, add one
25
- if (!pages.some((page) => page.path === '/404.html')) {
26
- pages.push(await page_1.createPage(app, {
27
- path: '/404.html',
28
- frontmatter: {
29
- layout: '404',
30
- },
31
- }));
32
- }
33
- log('createAppPages finish');
34
- return pages;
35
- };
36
- exports.createAppPages = createAppPages;
@@ -1,7 +0,0 @@
1
- import type { AppOptions, SiteData } from '../types';
2
- /**
3
- * Create site data for vuepress app
4
- *
5
- * Site data will also be used in client
6
- */
7
- export declare const createAppSiteData: (options: AppOptions) => SiteData;
@@ -1,19 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.createAppSiteData = void 0;
4
- /**
5
- * Create site data for vuepress app
6
- *
7
- * Site data will also be used in client
8
- */
9
- const createAppSiteData = (options) => {
10
- return {
11
- base: options.base,
12
- lang: options.lang,
13
- title: options.title,
14
- description: options.description,
15
- head: options.head,
16
- locales: options.locales,
17
- };
18
- };
19
- exports.createAppSiteData = createAppSiteData;
@@ -1,4 +0,0 @@
1
- /**
2
- * Create version of vuepress app
3
- */
4
- export declare const createAppVersion: () => string;
@@ -1,10 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.createAppVersion = void 0;
4
- /**
5
- * Create version of vuepress app
6
- */
7
- const createAppVersion = () => {
8
- return require('../../package.json').version;
9
- };
10
- exports.createAppVersion = createAppVersion;
@@ -1,5 +0,0 @@
1
- import type { AppDir, AppWriteTemp } from '../types';
2
- /**
3
- * Create write temp file util for vuepress app
4
- */
5
- export declare const createAppWriteTemp: (dir: AppDir) => AppWriteTemp;
@@ -1,21 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.createAppWriteTemp = void 0;
4
- const utils_1 = require("@vuepress/utils");
5
- /**
6
- * Create write temp file util for vuepress app
7
- */
8
- const createAppWriteTemp = (dir) => {
9
- const tempCache = new Map();
10
- const writeTemp = async (file, content) => {
11
- const filePath = dir.temp(file);
12
- const contentCached = tempCache.get(filePath);
13
- if (contentCached !== content) {
14
- await utils_1.fs.outputFile(filePath, content);
15
- tempCache.set(filePath, content);
16
- }
17
- return filePath;
18
- };
19
- return writeTemp;
20
- };
21
- exports.createAppWriteTemp = createAppWriteTemp;
@@ -1,16 +0,0 @@
1
- export * from './prepare';
2
- export * from './appInit';
3
- export * from './appPrepare';
4
- export * from './appUse';
5
- export * from './appUseByConfig';
6
- export * from './createApp';
7
- export * from './createAppDir';
8
- export * from './createAppEnv';
9
- export * from './createAppOptions';
10
- export * from './createAppPages';
11
- export * from './createAppSiteData';
12
- export * from './createAppVersion';
13
- export * from './createAppWriteTemp';
14
- export * from './normalizePlugin';
15
- export * from './normalizePluginConfig';
16
- export * from './resolvePlugin';
package/lib/app/index.js DELETED
@@ -1,28 +0,0 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
5
- }) : (function(o, m, k, k2) {
6
- if (k2 === undefined) k2 = k;
7
- o[k2] = m[k];
8
- }));
9
- var __exportStar = (this && this.__exportStar) || function(m, exports) {
10
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
11
- };
12
- Object.defineProperty(exports, "__esModule", { value: true });
13
- __exportStar(require("./prepare"), exports);
14
- __exportStar(require("./appInit"), exports);
15
- __exportStar(require("./appPrepare"), exports);
16
- __exportStar(require("./appUse"), exports);
17
- __exportStar(require("./appUseByConfig"), exports);
18
- __exportStar(require("./createApp"), exports);
19
- __exportStar(require("./createAppDir"), exports);
20
- __exportStar(require("./createAppEnv"), exports);
21
- __exportStar(require("./createAppOptions"), exports);
22
- __exportStar(require("./createAppPages"), exports);
23
- __exportStar(require("./createAppSiteData"), exports);
24
- __exportStar(require("./createAppVersion"), exports);
25
- __exportStar(require("./createAppWriteTemp"), exports);
26
- __exportStar(require("./normalizePlugin"), exports);
27
- __exportStar(require("./normalizePluginConfig"), exports);
28
- __exportStar(require("./resolvePlugin"), exports);
@@ -1,2 +0,0 @@
1
- import type { App, Plugin, PluginObject, PluginOptions } from '../types';
2
- export declare const normalizePlugin: <T extends PluginOptions = PluginOptions, U extends PluginObject = PluginObject>(app: App, plugin: string | Plugin<T, U>, config?: Partial<T> | undefined) => U;
@@ -1,17 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.normalizePlugin = void 0;
4
- const shared_1 = require("@vuepress/shared");
5
- const utils_1 = require("@vuepress/utils");
6
- const resolvePlugin_1 = require("./resolvePlugin");
7
- const normalizePlugin = (app, plugin, config) => {
8
- const resolvedPlugin = shared_1.isString(plugin) ? resolvePlugin_1.resolvePlugin(plugin) : plugin;
9
- if (resolvedPlugin === null) {
10
- throw utils_1.logger.createError(`plugin is not found: ${utils_1.chalk.magenta(plugin)}`);
11
- }
12
- const pluginObject = shared_1.isFunction(resolvedPlugin)
13
- ? resolvedPlugin(config !== null && config !== void 0 ? config : {}, app)
14
- : resolvedPlugin;
15
- return pluginObject;
16
- };
17
- exports.normalizePlugin = normalizePlugin;
@@ -1,2 +0,0 @@
1
- import type { PluginOptions, PluginConfig, PluginConfigNormalized } from '../types';
2
- export declare const normalizePluginConfig: <T extends PluginOptions>(pluginConfig: PluginConfig<T>) => PluginConfigNormalized<T>;
@@ -1,15 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.normalizePluginConfig = void 0;
4
- const shared_1 = require("@vuepress/shared");
5
- const normalizePluginConfig = (pluginConfig) => {
6
- var _a;
7
- // ['container'] -> ['container', true]
8
- // ['container', options] -> ['container', options]
9
- if (shared_1.isArray(pluginConfig)) {
10
- return [pluginConfig[0], (_a = pluginConfig[1]) !== null && _a !== void 0 ? _a : true];
11
- }
12
- // 'container' -> ['container', true]
13
- return [pluginConfig, true];
14
- };
15
- exports.normalizePluginConfig = normalizePluginConfig;
@@ -1,12 +0,0 @@
1
- export * from './prepareClientAppEnhances';
2
- export * from './prepareClientAppRootComponents';
3
- export * from './prepareClientAppSetups';
4
- export * from './prepareLayoutComponents';
5
- export * from './preparePageComponent';
6
- export * from './preparePageData';
7
- export * from './preparePageRoutes';
8
- export * from './preparePagesComponent';
9
- export * from './preparePagesData';
10
- export * from './preparePagesRoutes';
11
- export * from './prepareSiteData';
12
- export * from './resolvePageData';
@@ -1,24 +0,0 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
5
- }) : (function(o, m, k, k2) {
6
- if (k2 === undefined) k2 = k;
7
- o[k2] = m[k];
8
- }));
9
- var __exportStar = (this && this.__exportStar) || function(m, exports) {
10
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
11
- };
12
- Object.defineProperty(exports, "__esModule", { value: true });
13
- __exportStar(require("./prepareClientAppEnhances"), exports);
14
- __exportStar(require("./prepareClientAppRootComponents"), exports);
15
- __exportStar(require("./prepareClientAppSetups"), exports);
16
- __exportStar(require("./prepareLayoutComponents"), exports);
17
- __exportStar(require("./preparePageComponent"), exports);
18
- __exportStar(require("./preparePageData"), exports);
19
- __exportStar(require("./preparePageRoutes"), exports);
20
- __exportStar(require("./preparePagesComponent"), exports);
21
- __exportStar(require("./preparePagesData"), exports);
22
- __exportStar(require("./preparePagesRoutes"), exports);
23
- __exportStar(require("./prepareSiteData"), exports);
24
- __exportStar(require("./resolvePageData"), exports);
@@ -1,5 +0,0 @@
1
- import type { App } from '../../types';
2
- /**
3
- * Generate client app enhances temp file
4
- */
5
- export declare const prepareClientAppEnhances: (app: App) => Promise<void>;
@@ -1,24 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.prepareClientAppEnhances = void 0;
4
- /**
5
- * Generate client app enhances temp file
6
- */
7
- const prepareClientAppEnhances = async (app) => {
8
- // plugin hook: clientAppEnhanceFiles
9
- const clientAppEnhanceFiles = await app.pluginApi.hooks.clientAppEnhanceFiles.process(app);
10
- // flat the hook result to get the file paths array
11
- const filePaths = clientAppEnhanceFiles.flat();
12
- // generate client app enhance files entry
13
- const content = `\
14
- ${filePaths
15
- .map((filePath, index) => `import clientAppEnhance${index} from '${filePath}'`)
16
- .join('\n')}
17
-
18
- export const clientAppEnhances = [
19
- ${filePaths.map((_, index) => ` clientAppEnhance${index},`).join('\n')}
20
- ]
21
- `;
22
- await app.writeTemp('internal/clientAppEnhances.js', content);
23
- };
24
- exports.prepareClientAppEnhances = prepareClientAppEnhances;
@@ -1,5 +0,0 @@
1
- import type { App } from '../../types';
2
- /**
3
- * Generate client app root components temp file
4
- */
5
- export declare const prepareClientAppRootComponents: (app: App) => Promise<void>;
@@ -1,24 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.prepareClientAppRootComponents = void 0;
4
- /**
5
- * Generate client app root components temp file
6
- */
7
- const prepareClientAppRootComponents = async (app) => {
8
- // plugin hook: clientAppRootComponentFiles
9
- const clientAppRootComponentFiles = await app.pluginApi.hooks.clientAppRootComponentFiles.process(app);
10
- // flat the hook result to get the file paths array
11
- const filePaths = clientAppRootComponentFiles.flat();
12
- // generate client app root components files entry
13
- const content = `\
14
- ${filePaths
15
- .map((filePath, index) => `import clientAppRootComponent${index} from '${filePath}'`)
16
- .join('\n')}
17
-
18
- export const clientAppRootComponents = [
19
- ${filePaths.map((_, index) => ` clientAppRootComponent${index},`).join('\n')}
20
- ]
21
- `;
22
- await app.writeTemp('internal/clientAppRootComponents.js', content);
23
- };
24
- exports.prepareClientAppRootComponents = prepareClientAppRootComponents;
@@ -1,5 +0,0 @@
1
- import type { App } from '../../types';
2
- /**
3
- * Generate client app setups temp file
4
- */
5
- export declare const prepareClientAppSetups: (app: App) => Promise<void>;
@@ -1,24 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.prepareClientAppSetups = void 0;
4
- /**
5
- * Generate client app setups temp file
6
- */
7
- const prepareClientAppSetups = async (app) => {
8
- // plugin hook: clientAppSetupFiles
9
- const clientAppSetupFiles = await app.pluginApi.hooks.clientAppSetupFiles.process(app);
10
- // flat the hook result to get the file paths array
11
- const filePaths = clientAppSetupFiles.flat();
12
- // generate client app setup files entry
13
- const content = `\
14
- ${filePaths
15
- .map((filePath, index) => `import clientAppSetup${index} from '${filePath}'`)
16
- .join('\n')}
17
-
18
- export const clientAppSetups = [
19
- ${filePaths.map((_, index) => ` clientAppSetup${index},`).join('\n')}
20
- ]
21
- `;
22
- await app.writeTemp('internal/clientAppSetups.js', content);
23
- };
24
- exports.prepareClientAppSetups = prepareClientAppSetups;
@@ -1,5 +0,0 @@
1
- import type { App } from '../../types';
2
- /**
3
- * Generate layout components temp file
4
- */
5
- export declare const prepareLayoutComponents: (app: App) => Promise<void>;
@@ -1,20 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.prepareLayoutComponents = void 0;
4
- /**
5
- * Generate layout components temp file
6
- */
7
- const prepareLayoutComponents = async (app) => {
8
- const content = `\
9
- import { defineAsyncComponent } from 'vue'
10
-
11
- export const layoutComponents = {\
12
- ${app.themeApi.layouts
13
- .map(({ name, path }) => `
14
- ${JSON.stringify(name)}: defineAsyncComponent(() => import(${app.env.isDebug ? `/* webpackChunkName: "layout-${name}" */` : ''}${JSON.stringify(path)})),`)
15
- .join('')}
16
- }
17
- `;
18
- await app.writeTemp('internal/layoutComponents.js', content);
19
- };
20
- exports.prepareLayoutComponents = prepareLayoutComponents;
@@ -1,5 +0,0 @@
1
- import type { App, Page } from '../../types';
2
- /**
3
- * Generate page component temp file of a single page
4
- */
5
- export declare const preparePageComponent: (app: App, page: Page) => Promise<void>;
@@ -1,10 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.preparePageComponent = void 0;
4
- /**
5
- * Generate page component temp file of a single page
6
- */
7
- const preparePageComponent = async (app, page) => {
8
- await app.writeTemp(page.componentFilePathRelative, page.componentFileContent);
9
- };
10
- exports.preparePageComponent = preparePageComponent;
@@ -1,5 +0,0 @@
1
- import type { App, Page } from '../../types';
2
- /**
3
- * Generate page data temp file of a single page
4
- */
5
- export declare const preparePageData: (app: App, page: Page) => Promise<void>;
@@ -1,37 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.preparePageData = void 0;
4
- const resolvePageData_1 = require("./resolvePageData");
5
- const HMR_CODE = `
6
- if (import.meta.webpackHot) {
7
- import.meta.webpackHot.accept()
8
- if (__VUE_HMR_RUNTIME__.updatePageData) {
9
- __VUE_HMR_RUNTIME__.updatePageData(data)
10
- }
11
- }
12
-
13
- if (import.meta.hot) {
14
- import.meta.hot.accept(({ data }) => {
15
- __VUE_HMR_RUNTIME__.updatePageData(data)
16
- })
17
- }
18
- `;
19
- /**
20
- * Generate page data temp file of a single page
21
- */
22
- const preparePageData = async (app, page) => {
23
- // resolve default page data
24
- const pageData = resolvePageData_1.resolvePageData(page);
25
- // plugin hook: extendsPageData
26
- const extendsPageData = await app.pluginApi.hooks.extendsPageData.process(page, app);
27
- // extends default page data
28
- extendsPageData.forEach((item) => Object.assign(pageData, item));
29
- // page data file content
30
- let content = `export const data = ${JSON.stringify(pageData, null, 2)}\n`;
31
- // inject HMR code
32
- if (app.env.isDev) {
33
- content += HMR_CODE;
34
- }
35
- await app.writeTemp(page.dataFilePathRelative, content);
36
- };
37
- exports.preparePageData = preparePageData;
@@ -1,5 +0,0 @@
1
- import type { App, Page } from '../../types';
2
- /**
3
- * Generate page routes temp file of a single page
4
- */
5
- export declare const preparePageRoutes: (app: App, { key, path, pathInferred, filePathRelative, title, routesFilePathRelative, }: Page) => Promise<void>;
@@ -1,57 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.preparePageRoutes = void 0;
4
- const shared_1 = require("@vuepress/shared");
5
- /**
6
- * Generate page routes temp file of a single page
7
- */
8
- const preparePageRoutes = async (app, { key, path, pathInferred, filePathRelative, title, routesFilePathRelative, }) => {
9
- const routes = [];
10
- // add page route
11
- routes.push(`
12
- {
13
- name: ${JSON.stringify(key)},
14
- path: ${JSON.stringify(path)},
15
- component: Vuepress,
16
- meta: { title: ${JSON.stringify(title)} },
17
- },`);
18
- // paths that should redirect to this page
19
- const redirects = new Set();
20
- // redirect from decoded path
21
- redirects.add(decodeURI(path));
22
- // redirect from index path
23
- if (/\/$/.test(path)) {
24
- const indexPath = path + 'index.html';
25
- redirects.add(indexPath);
26
- }
27
- // redirect from inferred path
28
- if (pathInferred !== null) {
29
- redirects.add(pathInferred);
30
- redirects.add(encodeURI(pathInferred));
31
- }
32
- // redirect from filename path
33
- if (filePathRelative !== null) {
34
- const filenamePath = shared_1.ensureLeadingSlash(filePathRelative);
35
- redirects.add(filenamePath);
36
- redirects.add(encodeURI(filenamePath));
37
- }
38
- // avoid redirect from the page path itself
39
- redirects.delete(path);
40
- // add redirect routes
41
- redirects.forEach((redirect) => {
42
- routes.push(`
43
- {
44
- path: ${JSON.stringify(redirect)},
45
- redirect: ${JSON.stringify(path)},
46
- },`);
47
- });
48
- const content = `\
49
- import { Vuepress } from '@vuepress/client/lib/components/Vuepress'
50
-
51
- export default [\
52
- ${routes.join('')}
53
- ]
54
- `;
55
- await app.writeTemp(routesFilePathRelative, content);
56
- };
57
- exports.preparePageRoutes = preparePageRoutes;
@@ -1,5 +0,0 @@
1
- import type { App } from '../../types';
2
- /**
3
- * Generate page key to page component map temp file
4
- */
5
- export declare const preparePagesComponent: (app: App) => Promise<void>;
@@ -1,23 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.preparePagesComponent = void 0;
4
- /**
5
- * Generate page key to page component map temp file
6
- */
7
- const preparePagesComponent = async (app) => {
8
- // generate page component map file
9
- const content = `\
10
- import { defineAsyncComponent } from 'vue'
11
-
12
- export const pagesComponent = {\
13
- ${app.pages
14
- .map(({ path, componentFilePath, componentFileChunkName }) => `
15
- ${JSON.stringify(path)}: defineAsyncComponent(() => import(${componentFileChunkName
16
- ? `/* webpackChunkName: "${componentFileChunkName}" */`
17
- : ''}${JSON.stringify(componentFilePath)})),`)
18
- .join('')}
19
- }
20
- `;
21
- await app.writeTemp('internal/pagesComponent.js', content);
22
- };
23
- exports.preparePagesComponent = preparePagesComponent;
@@ -1,5 +0,0 @@
1
- import type { App } from '../../types';
2
- /**
3
- * Generate page path to page data map temp file
4
- */
5
- export declare const preparePagesData: (app: App) => Promise<void>;
@@ -1,19 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.preparePagesData = void 0;
4
- /**
5
- * Generate page path to page data map temp file
6
- */
7
- const preparePagesData = async (app) => {
8
- // generate page data map
9
- const content = `\
10
- export const pagesData = {
11
- ${app.pages
12
- .map(({ path, dataFilePath, dataFileChunkName }) => `\
13
- ${JSON.stringify(path)}: () => import(${dataFileChunkName ? `/* webpackChunkName: "${dataFileChunkName}" */` : ''}${JSON.stringify(dataFilePath)}).then(({ data }) => data),`)
14
- .join('\n')}
15
- }
16
- `;
17
- await app.writeTemp('internal/pagesData.js', content);
18
- };
19
- exports.preparePagesData = preparePagesData;
@@ -1,5 +0,0 @@
1
- import type { App } from '../../types';
2
- /**
3
- * Generate routes temp file
4
- */
5
- export declare const preparePagesRoutes: (app: App) => Promise<void>;
@@ -1,25 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.preparePagesRoutes = void 0;
4
- /**
5
- * Generate routes temp file
6
- */
7
- const preparePagesRoutes = async (app) => {
8
- const content = `\
9
- import { Vuepress } from '@vuepress/client/lib/components/Vuepress'
10
- ${app.pages
11
- .map(({ routesFilePath }, index) => `import pageRoutes${index} from '${routesFilePath}'`)
12
- .join('\n')}
13
-
14
- export const pagesRoutes = [
15
- ${app.pages.map((_, index) => ` ...pageRoutes${index},`).join('\n')}
16
- {
17
- name: "404",
18
- path: "/:catchAll(.*)",
19
- component: Vuepress,
20
- },
21
- ]
22
- `;
23
- await app.writeTemp('internal/pagesRoutes.js', content);
24
- };
25
- exports.preparePagesRoutes = preparePagesRoutes;