@vuepress/core 2.0.0-beta.49 → 2.0.0-beta.50-pre.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (131) hide show
  1. package/dist/index.d.ts +850 -0
  2. package/dist/index.js +1050 -0
  3. package/package.json +29 -10
  4. package/lib/app/appInit.d.ts +0 -7
  5. package/lib/app/appInit.js +0 -27
  6. package/lib/app/appPrepare.d.ts +0 -10
  7. package/lib/app/appPrepare.js +0 -39
  8. package/lib/app/appUse.d.ts +0 -2
  9. package/lib/app/appUse.js +0 -28
  10. package/lib/app/createBaseApp.d.ts +0 -5
  11. package/lib/app/createBaseApp.js +0 -46
  12. package/lib/app/createBuildApp.d.ts +0 -5
  13. package/lib/app/createBuildApp.js +0 -13
  14. package/lib/app/createDevApp.d.ts +0 -5
  15. package/lib/app/createDevApp.js +0 -13
  16. package/lib/app/index.d.ts +0 -17
  17. package/lib/app/index.js +0 -33
  18. package/lib/app/prepare/index.d.ts +0 -8
  19. package/lib/app/prepare/index.js +0 -24
  20. package/lib/app/prepare/prepareClientConfigs.d.ts +0 -5
  21. package/lib/app/prepare/prepareClientConfigs.js +0 -22
  22. package/lib/app/prepare/prepareLayoutComponents.d.ts +0 -5
  23. package/lib/app/prepare/prepareLayoutComponents.js +0 -20
  24. package/lib/app/prepare/preparePageComponent.d.ts +0 -5
  25. package/lib/app/prepare/preparePageComponent.js +0 -16
  26. package/lib/app/prepare/preparePageData.d.ts +0 -5
  27. package/lib/app/prepare/preparePageData.js +0 -31
  28. package/lib/app/prepare/preparePagesComponents.d.ts +0 -5
  29. package/lib/app/prepare/preparePagesComponents.js +0 -24
  30. package/lib/app/prepare/preparePagesData.d.ts +0 -5
  31. package/lib/app/prepare/preparePagesData.js +0 -20
  32. package/lib/app/prepare/preparePagesRoutes.d.ts +0 -5
  33. package/lib/app/prepare/preparePagesRoutes.js +0 -48
  34. package/lib/app/prepare/prepareSiteData.d.ts +0 -5
  35. package/lib/app/prepare/prepareSiteData.js +0 -31
  36. package/lib/app/resolveAppDir.d.ts +0 -9
  37. package/lib/app/resolveAppDir.js +0 -32
  38. package/lib/app/resolveAppEnv.d.ts +0 -5
  39. package/lib/app/resolveAppEnv.js +0 -12
  40. package/lib/app/resolveAppMarkdown.d.ts +0 -6
  41. package/lib/app/resolveAppMarkdown.js +0 -16
  42. package/lib/app/resolveAppOptions.d.ts +0 -5
  43. package/lib/app/resolveAppOptions.js +0 -45
  44. package/lib/app/resolveAppPages.d.ts +0 -5
  45. package/lib/app/resolveAppPages.js +0 -31
  46. package/lib/app/resolveAppSiteData.d.ts +0 -7
  47. package/lib/app/resolveAppSiteData.js +0 -17
  48. package/lib/app/resolveAppVersion.d.ts +0 -4
  49. package/lib/app/resolveAppVersion.js +0 -10
  50. package/lib/app/resolveAppWriteTemp.d.ts +0 -5
  51. package/lib/app/resolveAppWriteTemp.js +0 -21
  52. package/lib/app/resolvePluginObject.d.ts +0 -5
  53. package/lib/app/resolvePluginObject.js +0 -9
  54. package/lib/app/resolveThemeInfo.d.ts +0 -5
  55. package/lib/app/resolveThemeInfo.js +0 -31
  56. package/lib/app/resolveThemeLayouts.d.ts +0 -5
  57. package/lib/app/resolveThemeLayouts.js +0 -25
  58. package/lib/app/setupAppThemeAndPlugins.d.ts +0 -5
  59. package/lib/app/setupAppThemeAndPlugins.js +0 -21
  60. package/lib/index.d.ts +0 -4
  61. package/lib/index.js +0 -20
  62. package/lib/page/createPage.d.ts +0 -2
  63. package/lib/page/createPage.js +0 -118
  64. package/lib/page/index.d.ts +0 -15
  65. package/lib/page/index.js +0 -31
  66. package/lib/page/inferPagePath.d.ts +0 -11
  67. package/lib/page/inferPagePath.js +0 -27
  68. package/lib/page/renderPageContent.d.ts +0 -21
  69. package/lib/page/renderPageContent.js +0 -28
  70. package/lib/page/resolvePageComponentInfo.d.ts +0 -13
  71. package/lib/page/resolvePageComponentInfo.js +0 -19
  72. package/lib/page/resolvePageDataInfo.d.ts +0 -13
  73. package/lib/page/resolvePageDataInfo.js +0 -18
  74. package/lib/page/resolvePageDate.d.ts +0 -10
  75. package/lib/page/resolvePageDate.js +0 -45
  76. package/lib/page/resolvePageFileContent.d.ts +0 -8
  77. package/lib/page/resolvePageFileContent.js +0 -23
  78. package/lib/page/resolvePageFilePath.d.ts +0 -11
  79. package/lib/page/resolvePageFilePath.js +0 -24
  80. package/lib/page/resolvePageHtmlInfo.d.ts +0 -11
  81. package/lib/page/resolvePageHtmlInfo.js +0 -18
  82. package/lib/page/resolvePageKey.d.ts +0 -6
  83. package/lib/page/resolvePageKey.js +0 -9
  84. package/lib/page/resolvePageLang.d.ts +0 -9
  85. package/lib/page/resolvePageLang.js +0 -14
  86. package/lib/page/resolvePagePath.d.ts +0 -9
  87. package/lib/page/resolvePagePath.js +0 -19
  88. package/lib/page/resolvePagePermalink.d.ts +0 -12
  89. package/lib/page/resolvePagePermalink.js +0 -41
  90. package/lib/page/resolvePageRouteMeta.d.ts +0 -7
  91. package/lib/page/resolvePageRouteMeta.js +0 -8
  92. package/lib/page/resolvePageSlug.d.ts +0 -6
  93. package/lib/page/resolvePageSlug.js +0 -17
  94. package/lib/pluginApi/createHookQueue.d.ts +0 -5
  95. package/lib/pluginApi/createHookQueue.js +0 -42
  96. package/lib/pluginApi/createPluginApi.d.ts +0 -2
  97. package/lib/pluginApi/createPluginApi.js +0 -16
  98. package/lib/pluginApi/createPluginApiHooks.d.ts +0 -2
  99. package/lib/pluginApi/createPluginApiHooks.js +0 -23
  100. package/lib/pluginApi/createPluginApiRegisterHooks.d.ts +0 -2
  101. package/lib/pluginApi/createPluginApiRegisterHooks.js +0 -42
  102. package/lib/pluginApi/index.d.ts +0 -6
  103. package/lib/pluginApi/index.js +0 -22
  104. package/lib/pluginApi/normalizeClientConfigFileHook.d.ts +0 -5
  105. package/lib/pluginApi/normalizeClientConfigFileHook.js +0 -19
  106. package/lib/pluginApi/normalizeReturnObjectHook.d.ts +0 -5
  107. package/lib/pluginApi/normalizeReturnObjectHook.js +0 -9
  108. package/lib/types/app/app.d.ts +0 -98
  109. package/lib/types/app/app.js +0 -2
  110. package/lib/types/app/index.d.ts +0 -3
  111. package/lib/types/app/index.js +0 -19
  112. package/lib/types/app/options.d.ts +0 -84
  113. package/lib/types/app/options.js +0 -2
  114. package/lib/types/app/utils.d.ts +0 -36
  115. package/lib/types/app/utils.js +0 -2
  116. package/lib/types/bundler.d.ts +0 -13
  117. package/lib/types/bundler.js +0 -2
  118. package/lib/types/index.d.ts +0 -8
  119. package/lib/types/index.js +0 -22
  120. package/lib/types/page.d.ts +0 -144
  121. package/lib/types/page.js +0 -2
  122. package/lib/types/plugin.d.ts +0 -29
  123. package/lib/types/plugin.js +0 -2
  124. package/lib/types/pluginApi/hooks.d.ts +0 -72
  125. package/lib/types/pluginApi/hooks.js +0 -2
  126. package/lib/types/pluginApi/index.d.ts +0 -2
  127. package/lib/types/pluginApi/index.js +0 -18
  128. package/lib/types/pluginApi/pluginApi.d.ts +0 -23
  129. package/lib/types/pluginApi/pluginApi.js +0 -2
  130. package/lib/types/theme.d.ts +0 -61
  131. package/lib/types/theme.js +0 -2
@@ -1,13 +0,0 @@
1
- import type { App } from '../types';
2
- /**
3
- * Resolve page component and related info
4
- */
5
- export declare const resolvePageComponentInfo: ({ app, htmlFilePathRelative, key, }: {
6
- app: App;
7
- htmlFilePathRelative: string;
8
- key: string;
9
- }) => Promise<{
10
- componentFilePath: string;
11
- componentFilePathRelative: string;
12
- componentFileChunkName: string;
13
- }>;
@@ -1,19 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.resolvePageComponentInfo = void 0;
4
- const utils_1 = require("@vuepress/utils");
5
- /**
6
- * Resolve page component and related info
7
- */
8
- const resolvePageComponentInfo = async ({ app, htmlFilePathRelative, key, }) => {
9
- // resolve component file path
10
- const componentFilePathRelative = utils_1.path.join('pages', `${htmlFilePathRelative}.vue`);
11
- const componentFilePath = app.dir.temp(componentFilePathRelative);
12
- const componentFileChunkName = key;
13
- return {
14
- componentFilePath,
15
- componentFilePathRelative,
16
- componentFileChunkName,
17
- };
18
- };
19
- exports.resolvePageComponentInfo = resolvePageComponentInfo;
@@ -1,13 +0,0 @@
1
- import type { App } from '../types';
2
- /**
3
- * Resolve page data file path
4
- */
5
- export declare const resolvePageDataInfo: ({ app, htmlFilePathRelative, key, }: {
6
- app: App;
7
- htmlFilePathRelative: string;
8
- key: string;
9
- }) => {
10
- dataFilePath: string;
11
- dataFilePathRelative: string;
12
- dataFileChunkName: string;
13
- };
@@ -1,18 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.resolvePageDataInfo = void 0;
4
- const utils_1 = require("@vuepress/utils");
5
- /**
6
- * Resolve page data file path
7
- */
8
- const resolvePageDataInfo = ({ app, htmlFilePathRelative, key, }) => {
9
- const dataFilePathRelative = utils_1.path.join('pages', `${htmlFilePathRelative}.js`);
10
- const dataFilePath = app.dir.temp(dataFilePathRelative);
11
- const dataFileChunkName = key;
12
- return {
13
- dataFilePath,
14
- dataFilePathRelative,
15
- dataFileChunkName,
16
- };
17
- };
18
- exports.resolvePageDataInfo = resolvePageDataInfo;
@@ -1,10 +0,0 @@
1
- import type { PageFrontmatter } from '../types';
2
- /**
3
- * Resolve page date according to frontmatter or file path
4
- *
5
- * It will be resolved as 'yyyy-MM-dd' format
6
- */
7
- export declare const resolvePageDate: ({ frontmatter, filePathRelative, }: {
8
- frontmatter: PageFrontmatter;
9
- filePathRelative: string | null;
10
- }) => string;
@@ -1,45 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.resolvePageDate = void 0;
4
- const shared_1 = require("@vuepress/shared");
5
- const utils_1 = require("@vuepress/utils");
6
- const FILENAME_DATE_RE = /^(\d{4})-(\d{1,2})(?:-(\d{1,2}))?-(.*)$/;
7
- const DIRNAME_DATE_RE = /(\d{4})\/(\d{1,2})(?:\/(\d{1,2}))?(\/|$)/;
8
- const DEFAULT_DATE = '0000-00-00';
9
- /**
10
- * Resolve page date according to frontmatter or file path
11
- *
12
- * It will be resolved as 'yyyy-MM-dd' format
13
- */
14
- const resolvePageDate = ({ frontmatter, filePathRelative, }) => {
15
- // `frontmatter.date` could be parsed as UTC Date directly
16
- if (frontmatter.date instanceof Date) {
17
- return (0, shared_1.formatDateString)([
18
- frontmatter.date.getUTCFullYear(),
19
- frontmatter.date.getUTCMonth() + 1,
20
- frontmatter.date.getUTCDate(),
21
- ].join('-'), DEFAULT_DATE);
22
- }
23
- if ((0, shared_1.isString)(frontmatter.date)) {
24
- return (0, shared_1.formatDateString)(frontmatter.date, DEFAULT_DATE);
25
- }
26
- if (filePathRelative === null) {
27
- return DEFAULT_DATE;
28
- }
29
- const filename = utils_1.path.parse(filePathRelative).name;
30
- if (filename) {
31
- const matches = filename.match(FILENAME_DATE_RE);
32
- if (matches) {
33
- return (0, shared_1.formatDateString)(`${matches[1]}-${matches[2]}-${matches[3] ?? '01'}`, DEFAULT_DATE);
34
- }
35
- }
36
- const dirname = utils_1.path.dirname(filePathRelative);
37
- if (dirname !== '.') {
38
- const matches = dirname.match(DIRNAME_DATE_RE);
39
- if (matches) {
40
- return (0, shared_1.formatDateString)(`${matches[1]}-${matches[2]}-${matches[3] ?? '01'}`, DEFAULT_DATE);
41
- }
42
- }
43
- return DEFAULT_DATE;
44
- };
45
- exports.resolvePageDate = resolvePageDate;
@@ -1,8 +0,0 @@
1
- import type { PageOptions } from '../types';
2
- /**
3
- * Resolve page file content according to filePath or options content
4
- */
5
- export declare const resolvePageFileContent: ({ filePath, options, }: {
6
- filePath: string | null;
7
- options: PageOptions;
8
- }) => Promise<string>;
@@ -1,23 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.resolvePageFileContent = void 0;
4
- const utils_1 = require("@vuepress/utils");
5
- const log = (0, utils_1.debug)('vuepress:core/page');
6
- /**
7
- * Resolve page file content according to filePath or options content
8
- */
9
- const resolvePageFileContent = async ({ filePath, options, }) => {
10
- if (filePath) {
11
- try {
12
- // read page content from file
13
- const content = await utils_1.fs.readFile(filePath, 'utf-8');
14
- return content;
15
- }
16
- catch (e) {
17
- log(e instanceof Error ? e.message : e);
18
- }
19
- }
20
- // load raw content from options
21
- return options.content ?? '';
22
- };
23
- exports.resolvePageFileContent = resolvePageFileContent;
@@ -1,11 +0,0 @@
1
- import type { App, PageOptions } from '../types';
2
- /**
3
- * Resolve absolute and relative path of page file
4
- */
5
- export declare const resolvePageFilePath: ({ app, options, }: {
6
- app: App;
7
- options: PageOptions;
8
- }) => {
9
- filePath: string | null;
10
- filePathRelative: string | null;
11
- };
@@ -1,24 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.resolvePageFilePath = void 0;
4
- const utils_1 = require("@vuepress/utils");
5
- /**
6
- * Resolve absolute and relative path of page file
7
- */
8
- const resolvePageFilePath = ({ app, options, }) => {
9
- // empty file path
10
- if (!options.filePath) {
11
- return {
12
- filePath: null,
13
- filePathRelative: null,
14
- };
15
- }
16
- if (!utils_1.path.isAbsolute(options.filePath)) {
17
- throw utils_1.logger.createError(`filePath is not absolute file path: ${options.filePath}}`);
18
- }
19
- return {
20
- filePath: options.filePath,
21
- filePathRelative: utils_1.path.relative(app.dir.source(), options.filePath),
22
- };
23
- };
24
- exports.resolvePageFilePath = resolvePageFilePath;
@@ -1,11 +0,0 @@
1
- import type { App } from '../types';
2
- /**
3
- * Resolve page rendered html file path
4
- */
5
- export declare const resolvePageHtmlInfo: ({ app, path: pagePath, }: {
6
- app: App;
7
- path: string;
8
- }) => {
9
- htmlFilePath: string;
10
- htmlFilePathRelative: string;
11
- };
@@ -1,18 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.resolvePageHtmlInfo = void 0;
4
- const shared_1 = require("@vuepress/shared");
5
- /**
6
- * Resolve page rendered html file path
7
- */
8
- const resolvePageHtmlInfo = ({ app, path: pagePath, }) => {
9
- // /foo.html -> foo.html
10
- // /foo/ -> foo/index.html
11
- const htmlFilePathRelative = (0, shared_1.removeLeadingSlash)(decodeURI(pagePath.replace(/\/$/, '/index.html')));
12
- const htmlFilePath = app.dir.dest(htmlFilePathRelative);
13
- return {
14
- htmlFilePath,
15
- htmlFilePathRelative,
16
- };
17
- };
18
- exports.resolvePageHtmlInfo = resolvePageHtmlInfo;
@@ -1,6 +0,0 @@
1
- /**
2
- * Resolve page key to identify the page
3
- */
4
- export declare const resolvePageKey: ({ path }: {
5
- path: string;
6
- }) => string;
@@ -1,9 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.resolvePageKey = void 0;
4
- const utils_1 = require("@vuepress/utils");
5
- /**
6
- * Resolve page key to identify the page
7
- */
8
- const resolvePageKey = ({ path }) => `v-${(0, utils_1.hash)(path)}`;
9
- exports.resolvePageKey = resolvePageKey;
@@ -1,9 +0,0 @@
1
- import type { App, PageFrontmatter } from '../types';
2
- /**
3
- * Resolve language of page
4
- */
5
- export declare const resolvePageLang: ({ app, frontmatter, pathLocale, }: {
6
- app: App;
7
- frontmatter: PageFrontmatter;
8
- pathLocale: string;
9
- }) => string;
@@ -1,14 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.resolvePageLang = void 0;
4
- const shared_1 = require("@vuepress/shared");
5
- /**
6
- * Resolve language of page
7
- */
8
- const resolvePageLang = ({ app, frontmatter, pathLocale, }) => {
9
- if ((0, shared_1.isString)(frontmatter.lang) && frontmatter.lang) {
10
- return frontmatter.lang;
11
- }
12
- return app.siteData.locales[pathLocale]?.lang ?? app.siteData.lang;
13
- };
14
- exports.resolvePageLang = resolvePageLang;
@@ -1,9 +0,0 @@
1
- import type { PageOptions } from '../types';
2
- /**
3
- * Resolve the final route path of a page
4
- */
5
- export declare const resolvePagePath: ({ permalink, pathInferred, options, }: {
6
- permalink: string | null;
7
- pathInferred: string | null;
8
- options: PageOptions;
9
- }) => string;
@@ -1,19 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.resolvePagePath = void 0;
4
- const shared_1 = require("@vuepress/shared");
5
- const utils_1 = require("@vuepress/utils");
6
- /**
7
- * Resolve the final route path of a page
8
- */
9
- const resolvePagePath = ({ permalink, pathInferred, options, }) => {
10
- let pagePath = options.path || permalink || pathInferred;
11
- if (!pagePath) {
12
- throw utils_1.logger.createError(`page path is empty, page options: ${JSON.stringify(options, null, 2)}`);
13
- }
14
- if (!pagePath.endsWith('.html')) {
15
- pagePath = (0, shared_1.ensureEndingSlash)(pagePath);
16
- }
17
- return encodeURI(pagePath);
18
- };
19
- exports.resolvePagePath = resolvePagePath;
@@ -1,12 +0,0 @@
1
- import type { App, PageFrontmatter } from '../types';
2
- /**
3
- * Resolve page permalink from frontmatter / options / pattern
4
- */
5
- export declare const resolvePagePermalink: ({ app, frontmatter, slug, date, pathInferred, pathLocale, }: {
6
- app: App;
7
- frontmatter: PageFrontmatter;
8
- slug: string;
9
- date: string;
10
- pathInferred: string | null;
11
- pathLocale: string;
12
- }) => string | null;
@@ -1,41 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.resolvePagePermalink = void 0;
4
- const shared_1 = require("@vuepress/shared");
5
- const utils_1 = require("@vuepress/utils");
6
- /**
7
- * Resolve page permalink from frontmatter / options / pattern
8
- */
9
- const resolvePagePermalink = ({ app, frontmatter, slug, date, pathInferred, pathLocale, }) => {
10
- // use permalink in frontmatter directly
11
- if ((0, shared_1.isString)(frontmatter.permalink)) {
12
- return frontmatter.permalink;
13
- }
14
- // get permalink pattern
15
- const permalinkPattern = getPermalinkPattern({ app, frontmatter });
16
- if (permalinkPattern === null) {
17
- return null;
18
- }
19
- // resolve permalink according to the pattern
20
- const [year, month, day] = date.split('-');
21
- const link = utils_1.path.join(pathLocale, permalinkPattern
22
- .replace(/:year/, year)
23
- .replace(/:month/, month)
24
- .replace(/:day/, day)
25
- .replace(/:slug/, slug)
26
- .replace(/:raw/, pathInferred?.replace(/^\//, '') ?? ''));
27
- return (0, shared_1.ensureLeadingSlash)(link);
28
- };
29
- exports.resolvePagePermalink = resolvePagePermalink;
30
- /**
31
- * Get permalink pattern from frontmatter or app options
32
- */
33
- const getPermalinkPattern = ({ app, frontmatter, }) => {
34
- if (frontmatter.permalinkPattern === null) {
35
- return null;
36
- }
37
- if ((0, shared_1.isString)(frontmatter.permalinkPattern)) {
38
- return frontmatter.permalinkPattern;
39
- }
40
- return app.options.permalinkPattern;
41
- };
@@ -1,7 +0,0 @@
1
- import type { PageFrontmatter } from '../types';
2
- /**
3
- * Resolve page route meta
4
- */
5
- export declare const resolvePageRouteMeta: ({ frontmatter, }: {
6
- frontmatter: PageFrontmatter;
7
- }) => Record<string, unknown>;
@@ -1,8 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.resolvePageRouteMeta = void 0;
4
- /**
5
- * Resolve page route meta
6
- */
7
- const resolvePageRouteMeta = ({ frontmatter, }) => frontmatter.routeMeta ?? {};
8
- exports.resolvePageRouteMeta = resolvePageRouteMeta;
@@ -1,6 +0,0 @@
1
- /**
2
- * Resolve page slug from filename
3
- */
4
- export declare const resolvePageSlug: ({ filePathRelative, }: {
5
- filePathRelative: string | null;
6
- }) => string;
@@ -1,17 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.resolvePageSlug = void 0;
4
- const utils_1 = require("@vuepress/utils");
5
- const DATE_RE = /(\d{4}-\d{1,2}(-\d{1,2})?)-(.*)/;
6
- /**
7
- * Resolve page slug from filename
8
- */
9
- const resolvePageSlug = ({ filePathRelative, }) => {
10
- if (!filePathRelative) {
11
- return '';
12
- }
13
- const filename = utils_1.path.parse(filePathRelative).name;
14
- const match = filename.match(DATE_RE);
15
- return match ? match[3] : filename;
16
- };
17
- exports.resolvePageSlug = resolvePageSlug;
@@ -1,5 +0,0 @@
1
- import type { HookQueue } from '../types';
2
- /**
3
- * Create hook queue for plugin system
4
- */
5
- export declare const createHookQueue: <T extends keyof import("../types").Hooks>(name: T) => HookQueue<T>;
@@ -1,42 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.createHookQueue = void 0;
4
- const utils_1 = require("@vuepress/utils");
5
- const log = (0, utils_1.debug)('vuepress:core/plugin-api');
6
- /**
7
- * Create hook queue for plugin system
8
- */
9
- const createHookQueue = (name) => {
10
- const items = [];
11
- const hookQueue = {
12
- name,
13
- items,
14
- add: (item) => {
15
- items.push(item);
16
- },
17
- process: async (...args) => {
18
- // store the results of all hook items
19
- const results = [];
20
- // process all hook items
21
- for (const item of items) {
22
- log(`process ${utils_1.chalk.magenta(name)} from ${utils_1.chalk.magenta(item.pluginName)}`);
23
- try {
24
- // process and get the result of the the hook item
25
- // @ts-expect-error: the types could not be narrowed correctly
26
- const result = (await item.hook(...args));
27
- // push the result to results array
28
- if (result !== undefined) {
29
- results.push(result);
30
- }
31
- }
32
- catch (e) {
33
- utils_1.logger.error(`error in hook ${utils_1.chalk.magenta(name)} from ${utils_1.chalk.magenta(item.pluginName)}`);
34
- throw e;
35
- }
36
- }
37
- return results;
38
- },
39
- };
40
- return hookQueue;
41
- };
42
- exports.createHookQueue = createHookQueue;
@@ -1,2 +0,0 @@
1
- import type { PluginApi } from '../types';
2
- export declare const createPluginApi: () => PluginApi;
@@ -1,16 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.createPluginApi = void 0;
4
- const createPluginApiHooks_1 = require("./createPluginApiHooks");
5
- const createPluginApiRegisterHooks_1 = require("./createPluginApiRegisterHooks");
6
- const createPluginApi = () => {
7
- const plugins = [];
8
- const hooks = (0, createPluginApiHooks_1.createPluginApiHooks)();
9
- const registerHooks = (0, createPluginApiRegisterHooks_1.createPluginApiRegisterHooks)(plugins, hooks);
10
- return {
11
- plugins,
12
- hooks,
13
- registerHooks,
14
- };
15
- };
16
- exports.createPluginApi = createPluginApi;
@@ -1,2 +0,0 @@
1
- import type { PluginApi } from '../types';
2
- export declare const createPluginApiHooks: () => PluginApi['hooks'];
@@ -1,23 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.createPluginApiHooks = void 0;
4
- const createHookQueue_1 = require("./createHookQueue");
5
- const createPluginApiHooks = () => ({
6
- // life cycle hooks
7
- onInitialized: (0, createHookQueue_1.createHookQueue)('onInitialized'),
8
- onPrepared: (0, createHookQueue_1.createHookQueue)('onPrepared'),
9
- onWatched: (0, createHookQueue_1.createHookQueue)('onWatched'),
10
- onGenerated: (0, createHookQueue_1.createHookQueue)('onGenerated'),
11
- // extends hooks
12
- extendsMarkdownOptions: (0, createHookQueue_1.createHookQueue)('extendsMarkdownOptions'),
13
- extendsMarkdown: (0, createHookQueue_1.createHookQueue)('extendsMarkdown'),
14
- extendsPageOptions: (0, createHookQueue_1.createHookQueue)('extendsPageOptions'),
15
- extendsPage: (0, createHookQueue_1.createHookQueue)('extendsPage'),
16
- extendsBundlerOptions: (0, createHookQueue_1.createHookQueue)('extendsBundlerOptions'),
17
- // client config file hooks
18
- clientConfigFile: (0, createHookQueue_1.createHookQueue)('clientConfigFile'),
19
- // bundler hooks
20
- alias: (0, createHookQueue_1.createHookQueue)('alias'),
21
- define: (0, createHookQueue_1.createHookQueue)('define'),
22
- });
23
- exports.createPluginApiHooks = createPluginApiHooks;
@@ -1,2 +0,0 @@
1
- import type { PluginApi } from '../types';
2
- export declare const createPluginApiRegisterHooks: (plugins: PluginApi['plugins'], hooks: PluginApi['hooks']) => PluginApi['registerHooks'];
@@ -1,42 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.createPluginApiRegisterHooks = void 0;
4
- const normalizeClientConfigFileHook_1 = require("./normalizeClientConfigFileHook");
5
- const normalizeReturnObjectHook_1 = require("./normalizeReturnObjectHook");
6
- const createPluginApiRegisterHooks = (plugins, hooks) => () => {
7
- plugins.forEach(({ name: pluginName, alias, define, clientConfigFile, ...commonHooks }) => {
8
- /**
9
- * hooks that need to be normalized
10
- */
11
- if (alias) {
12
- hooks.alias.add({
13
- pluginName,
14
- hook: (0, normalizeReturnObjectHook_1.normalizeReturnObjectHook)(alias),
15
- });
16
- }
17
- if (define) {
18
- hooks.define.add({
19
- pluginName,
20
- hook: (0, normalizeReturnObjectHook_1.normalizeReturnObjectHook)(define),
21
- });
22
- }
23
- if (clientConfigFile) {
24
- hooks.clientConfigFile.add({
25
- pluginName,
26
- hook: (0, normalizeClientConfigFileHook_1.normalizeClientConfigFileHook)(clientConfigFile),
27
- });
28
- }
29
- /**
30
- * common hooks
31
- */
32
- Object.entries(commonHooks).forEach(([key, hook]) => {
33
- if (hooks[key] && hook) {
34
- hooks[key].add({
35
- pluginName,
36
- hook,
37
- });
38
- }
39
- });
40
- });
41
- };
42
- exports.createPluginApiRegisterHooks = createPluginApiRegisterHooks;
@@ -1,6 +0,0 @@
1
- export * from './createHookQueue';
2
- export * from './createPluginApi';
3
- export * from './createPluginApiHooks';
4
- export * from './createPluginApiRegisterHooks';
5
- export * from './normalizeClientConfigFileHook';
6
- export * from './normalizeReturnObjectHook';
@@ -1,22 +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
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
- };
16
- Object.defineProperty(exports, "__esModule", { value: true });
17
- __exportStar(require("./createHookQueue"), exports);
18
- __exportStar(require("./createPluginApi"), exports);
19
- __exportStar(require("./createPluginApiHooks"), exports);
20
- __exportStar(require("./createPluginApiRegisterHooks"), exports);
21
- __exportStar(require("./normalizeClientConfigFileHook"), exports);
22
- __exportStar(require("./normalizeReturnObjectHook"), exports);
@@ -1,5 +0,0 @@
1
- import type { ClientConfigFileHook } from '../types';
2
- /**
3
- * Normalize hook for client config file
4
- */
5
- export declare const normalizeClientConfigFileHook: (hook: ClientConfigFileHook['exposed']) => ClientConfigFileHook['normalized'];
@@ -1,19 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.normalizeClientConfigFileHook = void 0;
4
- const shared_1 = require("@vuepress/shared");
5
- const utils_1 = require("@vuepress/utils");
6
- /**
7
- * Normalize hook for client config file
8
- */
9
- const normalizeClientConfigFileHook = (hook) => async (app) => {
10
- // resolve clientConfigFile result
11
- const clientConfigFileResult = (0, shared_1.isFunction)(hook) ? await hook(app) : hook;
12
- // filter files that do not exist
13
- const isExisted = await utils_1.fs.pathExists(clientConfigFileResult);
14
- if (!isExisted) {
15
- throw utils_1.logger.createError(`client config file does not exist: ${clientConfigFileResult}`);
16
- }
17
- return clientConfigFileResult;
18
- };
19
- exports.normalizeClientConfigFileHook = normalizeClientConfigFileHook;
@@ -1,5 +0,0 @@
1
- import type { ReturnObjectHook } from '../types';
2
- /**
3
- * Normalize hook that returns an object
4
- */
5
- export declare const normalizeReturnObjectHook: (hook: ReturnObjectHook['exposed']) => ReturnObjectHook['normalized'];
@@ -1,9 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.normalizeReturnObjectHook = void 0;
4
- const shared_1 = require("@vuepress/shared");
5
- /**
6
- * Normalize hook that returns an object
7
- */
8
- const normalizeReturnObjectHook = (hook) => async (app) => (0, shared_1.isFunction)(hook) ? hook(app) : hook;
9
- exports.normalizeReturnObjectHook = normalizeReturnObjectHook;