@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,12 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.resolvePageFrontmatter = void 0;
4
- /**
5
- * Resolve page frontmatter from user frontmatter and options frontmatter
6
- */
7
- const resolvePageFrontmatter = ({ frontmatterRaw, options, }) => ({
8
- // raw frontmatter take priority over options frontmatter
9
- ...options.frontmatter,
10
- ...frontmatterRaw,
11
- });
12
- exports.resolvePageFrontmatter = resolvePageFrontmatter;
@@ -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 = shared_1.removeLeadingSlash(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-${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,15 +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
- var _a, _b;
10
- if (shared_1.isString(frontmatter.lang) && frontmatter.lang) {
11
- return frontmatter.lang;
12
- }
13
- return (_b = (_a = app.siteData.locales[pathLocale]) === null || _a === void 0 ? void 0 : _a.lang) !== null && _b !== void 0 ? _b : app.siteData.lang;
14
- };
15
- 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 = permalink || pathInferred || options.path;
11
- if (!pagePath) {
12
- throw utils_1.logger.createError(`page path is empty, page options: ${JSON.stringify(options)}`);
13
- }
14
- if (!pagePath.endsWith('.html')) {
15
- pagePath = shared_1.ensureEndingSlash(pagePath);
16
- }
17
- return encodeURI(pagePath);
18
- };
19
- exports.resolvePagePath = resolvePagePath;
@@ -1,11 +0,0 @@
1
- import type { PageFrontmatter } from '../types';
2
- /**
3
- * Resolve page permalink from frontmatter / options / pattern
4
- */
5
- export declare const resolvePagePermalink: ({ frontmatter, slug, date, pathInferred, pathLocale, }: {
6
- frontmatter: PageFrontmatter;
7
- slug: string;
8
- date: string;
9
- pathInferred: string | null;
10
- pathLocale: string;
11
- }) => string | null;
@@ -1,32 +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 = ({ frontmatter, slug, date, pathInferred, pathLocale, }) => {
10
- var _a;
11
- // use permalink in frontmatter directly
12
- if (shared_1.isString(frontmatter.permalink)) {
13
- return frontmatter.permalink;
14
- }
15
- // get permalink pattern from frontmatter or options
16
- const pattern = shared_1.isString(frontmatter.permalinkPattern)
17
- ? frontmatter.permalinkPattern
18
- : null;
19
- if (!pattern) {
20
- return null;
21
- }
22
- // resolve permalink according to the pattern
23
- const [year, month, day] = date.split('-');
24
- const link = utils_1.path.join(pathLocale, pattern
25
- .replace(/:year/, year)
26
- .replace(/:month/, month)
27
- .replace(/:day/, day)
28
- .replace(/:slug/, slug)
29
- .replace(/:raw/, (_a = pathInferred === null || pathInferred === void 0 ? void 0 : pathInferred.replace(/^\//, '')) !== null && _a !== void 0 ? _a : ''));
30
- return shared_1.ensureLeadingSlash(link);
31
- };
32
- exports.resolvePagePermalink = resolvePagePermalink;
@@ -1,11 +0,0 @@
1
- import type { App } from '../types';
2
- /**
3
- * Resolve page routes file path
4
- */
5
- export declare const resolvePageRoutesInfo: ({ app, key, }: {
6
- app: App;
7
- key: string;
8
- }) => {
9
- routesFilePath: string;
10
- routesFilePathRelative: string;
11
- };
@@ -1,15 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.resolvePageRoutesInfo = void 0;
4
- /**
5
- * Resolve page routes file path
6
- */
7
- const resolvePageRoutesInfo = ({ app, key, }) => {
8
- const routesFilePathRelative = `internal/pageRoutes/${key}.js`;
9
- const routesFilePath = app.dir.temp(routesFilePathRelative);
10
- return {
11
- routesFilePath,
12
- routesFilePathRelative,
13
- };
14
- };
15
- exports.resolvePageRoutesInfo = resolvePageRoutesInfo;
@@ -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,9 +0,0 @@
1
- import type { PageFrontmatter, PageHeader } from '../types';
2
- /**
3
- * Resolve page title from frontmatter / file content
4
- */
5
- export declare const resolvePageTitle: ({ content, frontmatter, headers, }: {
6
- content: string;
7
- frontmatter: PageFrontmatter;
8
- headers: PageHeader[];
9
- }) => string;
@@ -1,26 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.resolvePageTitle = void 0;
4
- const markdown_1 = require("@vuepress/markdown");
5
- const shared_1 = require("@vuepress/shared");
6
- /**
7
- * Resolve page title from frontmatter / file content
8
- */
9
- const resolvePageTitle = ({ content, frontmatter, headers, }) => {
10
- // use title in frontmatter
11
- if (shared_1.isString(frontmatter.title)) {
12
- return markdown_1.parseEmoji(frontmatter.title);
13
- }
14
- // if the first header is <h1>, use it as the title
15
- const firstHeader = headers[0];
16
- if ((firstHeader === null || firstHeader === void 0 ? void 0 : firstHeader.level) === 1) {
17
- return firstHeader.title;
18
- }
19
- // try to get the first `# title` from markdown content
20
- const matchTitle = content.trimStart().match(/^#\s+(.*)/);
21
- if (matchTitle) {
22
- return markdown_1.parseEmoji(matchTitle[1]);
23
- }
24
- return '';
25
- };
26
- exports.resolvePageTitle = resolvePageTitle;
@@ -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, parallel?: boolean) => HookQueue<T>;
@@ -1,81 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.createHookQueue = void 0;
4
- const shared_1 = require("@vuepress/shared");
5
- const utils_1 = require("@vuepress/utils");
6
- const log = utils_1.debug('vuepress:core/plugin-api');
7
- /**
8
- * Create hook queue for plugin system
9
- */
10
- const createHookQueue = (name, parallel = false) => {
11
- const items = [];
12
- const hookQueue = {
13
- // hook name
14
- name,
15
- // hook items array
16
- items,
17
- // add hook item to queue
18
- add: (item) => {
19
- items.push(item);
20
- },
21
- // process the hook queue and get the results
22
- process: async (...args) => {
23
- // store the results of all hook items
24
- const results = [];
25
- // process a hook item and store the result
26
- const processItem = async (item, ...args) => {
27
- log(`process ${utils_1.chalk.magenta(name)} from ${utils_1.chalk.magenta(item.pluginName)}`);
28
- try {
29
- // process and get the result of the the hook item
30
- // @ts-ignore
31
- const result = (await item.hook(...args));
32
- // push the result to results array
33
- if (result !== undefined) {
34
- results.push(result);
35
- }
36
- }
37
- catch (error) {
38
- utils_1.logger.error(`error in hook ${utils_1.chalk.magenta(name)} from ${utils_1.chalk.magenta(item.pluginName)}`);
39
- throw error;
40
- }
41
- };
42
- // process all hook items in current queue
43
- if (parallel) {
44
- // process in parallel
45
- await Promise.all(items.map((item) => processItem(item, ...args)));
46
- }
47
- else {
48
- // process in serial
49
- for (const item of items) {
50
- await processItem(item, ...args);
51
- }
52
- }
53
- return results;
54
- },
55
- // process the hook queue and get the results
56
- processSync: (...args) => {
57
- // store the results of all hook items
58
- const results = [];
59
- // process all hook items
60
- for (const item of items) {
61
- log(`processSync ${utils_1.chalk.magenta(name)} from ${utils_1.chalk.magenta(item.pluginName)}`);
62
- try {
63
- // @ts-ignore
64
- // process and get the result of the the hook item
65
- const result = item.hook(...args);
66
- // push the result to results array
67
- if (result !== undefined && !shared_1.isPromise(result)) {
68
- results.push(result);
69
- }
70
- }
71
- catch (error) {
72
- utils_1.logger.error(`error in hook ${utils_1.chalk.magenta(name)} from ${utils_1.chalk.magenta(item.pluginName)}`);
73
- throw error;
74
- }
75
- }
76
- return results;
77
- },
78
- };
79
- return hookQueue;
80
- };
81
- 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 = createPluginApiHooks_1.createPluginApiHooks();
9
- const registerHooks = 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,24 +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: createHookQueue_1.createHookQueue('onInitialized'),
8
- onPrepared: createHookQueue_1.createHookQueue('onPrepared'),
9
- onWatched: createHookQueue_1.createHookQueue('onWatched'),
10
- onGenerated: createHookQueue_1.createHookQueue('onGenerated'),
11
- // page hooks
12
- extendsPageOptions: createHookQueue_1.createHookQueue('extendsPageOptions'),
13
- extendsPageData: createHookQueue_1.createHookQueue('extendsPageData'),
14
- // markdown hooks
15
- extendsMarkdown: createHookQueue_1.createHookQueue('extendsMarkdown'),
16
- // client files hooks
17
- clientAppEnhanceFiles: createHookQueue_1.createHookQueue('clientAppEnhanceFiles', true),
18
- clientAppRootComponentFiles: createHookQueue_1.createHookQueue('clientAppRootComponentFiles', true),
19
- clientAppSetupFiles: createHookQueue_1.createHookQueue('clientAppSetupFiles', true),
20
- // bundler hooks
21
- alias: createHookQueue_1.createHookQueue('alias'),
22
- define: createHookQueue_1.createHookQueue('define'),
23
- });
24
- 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,54 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.createPluginApiRegisterHooks = void 0;
4
- const normalizeReturnObjectHook_1 = require("./normalizeReturnObjectHook");
5
- const normalizeClientFilesHook_1 = require("./normalizeClientFilesHook");
6
- const createPluginApiRegisterHooks = (plugins, hooks) => () => {
7
- plugins.forEach(({ name: pluginName, alias, define, clientAppEnhanceFiles, clientAppRootComponentFiles, clientAppSetupFiles, ...commonHooks }) => {
8
- /**
9
- * hooks that need to be normalized
10
- */
11
- if (alias) {
12
- hooks.alias.add({
13
- pluginName,
14
- hook: normalizeReturnObjectHook_1.normalizeReturnObjectHook(alias),
15
- });
16
- }
17
- if (define) {
18
- hooks.define.add({
19
- pluginName,
20
- hook: normalizeReturnObjectHook_1.normalizeReturnObjectHook(define),
21
- });
22
- }
23
- if (clientAppEnhanceFiles) {
24
- hooks.clientAppEnhanceFiles.add({
25
- pluginName,
26
- hook: normalizeClientFilesHook_1.normalizeClientFilesHook(clientAppEnhanceFiles),
27
- });
28
- }
29
- if (clientAppRootComponentFiles) {
30
- hooks.clientAppRootComponentFiles.add({
31
- pluginName,
32
- hook: normalizeClientFilesHook_1.normalizeClientFilesHook(clientAppRootComponentFiles),
33
- });
34
- }
35
- if (clientAppSetupFiles) {
36
- hooks.clientAppSetupFiles.add({
37
- pluginName,
38
- hook: normalizeClientFilesHook_1.normalizeClientFilesHook(clientAppSetupFiles),
39
- });
40
- }
41
- /**
42
- * common hooks
43
- */
44
- Object.entries(commonHooks).forEach(([key, hook]) => {
45
- if (hooks[key] && hook) {
46
- hooks[key].add({
47
- pluginName,
48
- hook,
49
- });
50
- }
51
- });
52
- });
53
- };
54
- 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 './normalizeReturnObjectHook';
6
- export * from './normalizeClientFilesHook';
@@ -1,18 +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("./createHookQueue"), exports);
14
- __exportStar(require("./createPluginApi"), exports);
15
- __exportStar(require("./createPluginApiHooks"), exports);
16
- __exportStar(require("./createPluginApiRegisterHooks"), exports);
17
- __exportStar(require("./normalizeReturnObjectHook"), exports);
18
- __exportStar(require("./normalizeClientFilesHook"), exports);
@@ -1,5 +0,0 @@
1
- import type { ClientFilesHook } from '../types';
2
- /**
3
- * Normalize hook for client files
4
- */
5
- export declare const normalizeClientFilesHook: (hook: ClientFilesHook['exposed']) => ClientFilesHook['normalized'];
@@ -1,28 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.normalizeClientFilesHook = void 0;
4
- const shared_1 = require("@vuepress/shared");
5
- const utils_1 = require("@vuepress/utils");
6
- /**
7
- * Normalize hook for client files
8
- */
9
- const normalizeClientFilesHook = (hook) => async (app) => {
10
- // resolve clientFiles result
11
- const clientFilesResult = shared_1.isFunction(hook) ? await hook(app) : hook;
12
- const clientFiles = shared_1.isArray(clientFilesResult)
13
- ? clientFilesResult
14
- : [clientFilesResult];
15
- // filter files that do not exist
16
- const result = [];
17
- for (const filePath of clientFiles) {
18
- const isExisted = await utils_1.fs.pathExists(filePath);
19
- if (isExisted) {
20
- result.push(filePath);
21
- }
22
- else {
23
- throw utils_1.logger.createError(`client file does not exist: ${filePath}`);
24
- }
25
- }
26
- return result;
27
- };
28
- exports.normalizeClientFilesHook = normalizeClientFilesHook;
@@ -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) => (app) => shared_1.isFunction(hook) ? hook(app) : hook;
9
- exports.normalizeReturnObjectHook = normalizeReturnObjectHook;
@@ -1,7 +0,0 @@
1
- import type { App, ThemeApi } from '../types';
2
- /**
3
- * Create vuepress theme-api
4
- *
5
- * Resolve current theme, parent theme, theme layouts
6
- */
7
- export declare const createThemeApi: (app: App) => ThemeApi;
@@ -1,30 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.createThemeApi = void 0;
4
- const resolveThemeInfo_1 = require("./resolveThemeInfo");
5
- /**
6
- * Create vuepress theme-api
7
- *
8
- * Resolve current theme, parent theme, theme layouts
9
- */
10
- const createThemeApi = (app) => {
11
- // resolve theme info
12
- const theme = resolveThemeInfo_1.resolveThemeInfo(app, app.options.theme);
13
- // resolve parent theme info
14
- const parentTheme = theme.plugin.extends
15
- ? resolveThemeInfo_1.resolveThemeInfo(app, theme.plugin.extends)
16
- : null;
17
- // resolve theme layouts
18
- const layouts = theme.layouts;
19
- // layouts in child theme will override
20
- // those with the same name in parent theme
21
- if (parentTheme !== null) {
22
- layouts.unshift(...parentTheme.layouts.filter(({ name: parentLayoutName }) => !theme.layouts.some(({ name: childLayoutName }) => childLayoutName === parentLayoutName)));
23
- }
24
- return {
25
- theme,
26
- parentTheme,
27
- layouts,
28
- };
29
- };
30
- exports.createThemeApi = createThemeApi;
@@ -1,3 +0,0 @@
1
- export * from './createThemeApi';
2
- export * from './resolveThemeInfo';
3
- export * from './resolveThemeLayouts';
@@ -1,15 +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("./createThemeApi"), exports);
14
- __exportStar(require("./resolveThemeInfo"), exports);
15
- __exportStar(require("./resolveThemeLayouts"), exports);
@@ -1,2 +0,0 @@
1
- import type { App, ThemeInfo } from '../types';
2
- export declare const resolveThemeInfo: (app: App, themeName: string) => ThemeInfo;
@@ -1,32 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.resolveThemeInfo = void 0;
4
- const shared_1 = require("@vuepress/shared");
5
- const utils_1 = require("@vuepress/utils");
6
- const app_1 = require("../app");
7
- const resolveThemeLayouts_1 = require("./resolveThemeLayouts");
8
- const resolveThemeInfo = (app, themeName) => {
9
- // resolve theme entry according to theme name
10
- const themeEntry = utils_1.requireResolve(utils_1.path.isAbsolute(themeName)
11
- ? themeName
12
- : shared_1.normalizePackageName(themeName, 'vuepress', 'theme'));
13
- if (themeEntry === null) {
14
- throw utils_1.logger.createError(`theme is not found: ${utils_1.chalk.magenta(themeName)}`);
15
- }
16
- // normalize theme plugin from theme entry
17
- const themePlugin = app_1.normalizePlugin(app, themeEntry, app.options.themeConfig);
18
- // get theme path
19
- const themePath = themeEntry.match(/.(js|ts)$/)
20
- ? utils_1.path.dirname(themeEntry)
21
- : themeEntry;
22
- // resolve theme layouts
23
- const layouts = resolveThemeLayouts_1.resolveThemeLayouts({
24
- themePath,
25
- themePlugin,
26
- });
27
- return {
28
- plugin: themePlugin,
29
- layouts,
30
- };
31
- };
32
- exports.resolveThemeInfo = resolveThemeInfo;
@@ -1,5 +0,0 @@
1
- import type { ThemeObject, ThemeLayout } from '../types';
2
- export declare const resolveThemeLayouts: ({ themePath, themePlugin, }: {
3
- themePath: string;
4
- themePlugin: ThemeObject;
5
- }) => ThemeLayout[];