@vuepress/core 2.0.0-beta.5 → 2.0.0-beta.50-pre
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.
- package/package.json +34 -17
- package/CHANGELOG.md +0 -271
- package/lib/app/appInit.d.ts +0 -7
- package/lib/app/appInit.js +0 -37
- package/lib/app/appPrepare.d.ts +0 -10
- package/lib/app/appPrepare.js +0 -46
- package/lib/app/appUse.d.ts +0 -2
- package/lib/app/appUse.js +0 -26
- package/lib/app/appUseByConfig.d.ts +0 -2
- package/lib/app/appUseByConfig.js +0 -14
- package/lib/app/createApp.d.ts +0 -5
- package/lib/app/createApp.js +0 -44
- package/lib/app/createAppDir.d.ts +0 -9
- package/lib/app/createAppDir.js +0 -32
- package/lib/app/createAppEnv.d.ts +0 -5
- package/lib/app/createAppEnv.js +0 -14
- package/lib/app/createAppOptions.d.ts +0 -5
- package/lib/app/createAppOptions.js +0 -48
- package/lib/app/createAppPages.d.ts +0 -5
- package/lib/app/createAppPages.js +0 -36
- package/lib/app/createAppSiteData.d.ts +0 -7
- package/lib/app/createAppSiteData.js +0 -19
- package/lib/app/createAppVersion.d.ts +0 -4
- package/lib/app/createAppVersion.js +0 -11
- package/lib/app/createAppWriteTemp.d.ts +0 -5
- package/lib/app/createAppWriteTemp.js +0 -21
- package/lib/app/index.d.ts +0 -16
- package/lib/app/index.js +0 -28
- package/lib/app/normalizePlugin.d.ts +0 -2
- package/lib/app/normalizePlugin.js +0 -19
- package/lib/app/normalizePluginConfig.d.ts +0 -2
- package/lib/app/normalizePluginConfig.js +0 -18
- package/lib/app/prepare/index.d.ts +0 -12
- package/lib/app/prepare/index.js +0 -24
- package/lib/app/prepare/prepareClientAppEnhances.d.ts +0 -5
- package/lib/app/prepare/prepareClientAppEnhances.js +0 -24
- package/lib/app/prepare/prepareClientAppRootComponents.d.ts +0 -5
- package/lib/app/prepare/prepareClientAppRootComponents.js +0 -24
- package/lib/app/prepare/prepareClientAppSetups.d.ts +0 -5
- package/lib/app/prepare/prepareClientAppSetups.js +0 -24
- package/lib/app/prepare/prepareLayoutComponents.d.ts +0 -5
- package/lib/app/prepare/prepareLayoutComponents.js +0 -20
- package/lib/app/prepare/preparePageComponent.d.ts +0 -5
- package/lib/app/prepare/preparePageComponent.js +0 -10
- package/lib/app/prepare/preparePageData.d.ts +0 -5
- package/lib/app/prepare/preparePageData.js +0 -37
- package/lib/app/prepare/preparePageRoutes.d.ts +0 -5
- package/lib/app/prepare/preparePageRoutes.js +0 -57
- package/lib/app/prepare/preparePagesComponent.d.ts +0 -5
- package/lib/app/prepare/preparePagesComponent.js +0 -23
- package/lib/app/prepare/preparePagesData.d.ts +0 -5
- package/lib/app/prepare/preparePagesData.js +0 -19
- package/lib/app/prepare/preparePagesRoutes.d.ts +0 -5
- package/lib/app/prepare/preparePagesRoutes.js +0 -25
- package/lib/app/prepare/prepareSiteData.d.ts +0 -5
- package/lib/app/prepare/prepareSiteData.js +0 -31
- package/lib/app/prepare/resolvePageData.d.ts +0 -5
- package/lib/app/prepare/resolvePageData.js +0 -18
- package/lib/app/resolveBundler.d.ts +0 -2
- package/lib/app/resolveBundler.js +0 -10
- package/lib/app/resolvePlugin.d.ts +0 -5
- package/lib/app/resolvePlugin.js +0 -20
- package/lib/index.d.ts +0 -5
- package/lib/index.js +0 -17
- package/lib/page/createPage.d.ts +0 -2
- package/lib/page/createPage.js +0 -98
- package/lib/page/index.d.ts +0 -17
- package/lib/page/index.js +0 -29
- package/lib/page/inferPagePath.d.ts +0 -11
- package/lib/page/inferPagePath.js +0 -27
- package/lib/page/resolvePageComponentInfo.d.ts +0 -20
- package/lib/page/resolvePageComponentInfo.js +0 -41
- package/lib/page/resolvePageContent.d.ts +0 -11
- package/lib/page/resolvePageContent.js +0 -31
- package/lib/page/resolvePageDataInfo.d.ts +0 -12
- package/lib/page/resolvePageDataInfo.js +0 -18
- package/lib/page/resolvePageDate.d.ts +0 -10
- package/lib/page/resolvePageDate.js +0 -46
- package/lib/page/resolvePageExcerpt.d.ts +0 -9
- package/lib/page/resolvePageExcerpt.js +0 -15
- package/lib/page/resolvePageFileContent.d.ts +0 -8
- package/lib/page/resolvePageFileContent.js +0 -24
- package/lib/page/resolvePageFilePath.d.ts +0 -11
- package/lib/page/resolvePageFilePath.js +0 -29
- package/lib/page/resolvePageFrontmatter.d.ts +0 -8
- package/lib/page/resolvePageFrontmatter.js +0 -12
- package/lib/page/resolvePageKey.d.ts +0 -6
- package/lib/page/resolvePageKey.js +0 -9
- package/lib/page/resolvePageLang.d.ts +0 -9
- package/lib/page/resolvePageLang.js +0 -15
- package/lib/page/resolvePagePath.d.ts +0 -9
- package/lib/page/resolvePagePath.js +0 -8
- package/lib/page/resolvePagePermalink.d.ts +0 -11
- package/lib/page/resolvePagePermalink.js +0 -32
- package/lib/page/resolvePageRoutesInfo.d.ts +0 -11
- package/lib/page/resolvePageRoutesInfo.js +0 -16
- package/lib/page/resolvePageSlug.d.ts +0 -6
- package/lib/page/resolvePageSlug.js +0 -17
- package/lib/page/resolvePageTitle.d.ts +0 -9
- package/lib/page/resolvePageTitle.js +0 -26
- package/lib/pluginApi/createHookQueue.d.ts +0 -5
- package/lib/pluginApi/createHookQueue.js +0 -81
- package/lib/pluginApi/createPluginApi.d.ts +0 -2
- package/lib/pluginApi/createPluginApi.js +0 -16
- package/lib/pluginApi/createPluginApiHooks.d.ts +0 -2
- package/lib/pluginApi/createPluginApiHooks.js +0 -24
- package/lib/pluginApi/createPluginApiRegisterHooks.d.ts +0 -2
- package/lib/pluginApi/createPluginApiRegisterHooks.js +0 -54
- package/lib/pluginApi/index.d.ts +0 -6
- package/lib/pluginApi/index.js +0 -18
- package/lib/pluginApi/normalizeClientFilesHook.d.ts +0 -5
- package/lib/pluginApi/normalizeClientFilesHook.js +0 -25
- package/lib/pluginApi/normalizeReturnObjectHook.d.ts +0 -5
- package/lib/pluginApi/normalizeReturnObjectHook.js +0 -9
- package/lib/themeApi/createThemeApi.d.ts +0 -7
- package/lib/themeApi/createThemeApi.js +0 -30
- package/lib/themeApi/index.d.ts +0 -1
- package/lib/themeApi/index.js +0 -13
- package/lib/themeApi/resolveThemeInfo.d.ts +0 -2
- package/lib/themeApi/resolveThemeInfo.js +0 -34
- package/lib/themeApi/resolveThemeLayouts.d.ts +0 -5
- package/lib/themeApi/resolveThemeLayouts.js +0 -33
- package/lib/types/app/app.d.ts +0 -30
- package/lib/types/app/app.js +0 -2
- package/lib/types/app/index.d.ts +0 -3
- package/lib/types/app/index.js +0 -15
- package/lib/types/app/options.d.ts +0 -32
- package/lib/types/app/options.js +0 -2
- package/lib/types/app/utils.d.ts +0 -29
- package/lib/types/app/utils.js +0 -2
- package/lib/types/bundler.d.ts +0 -34
- package/lib/types/bundler.js +0 -2
- package/lib/types/index.d.ts +0 -9
- package/lib/types/index.js +0 -19
- package/lib/types/page.d.ts +0 -98
- package/lib/types/page.js +0 -2
- package/lib/types/plugin-api/hooks.d.ts +0 -75
- package/lib/types/plugin-api/hooks.js +0 -2
- package/lib/types/plugin-api/index.d.ts +0 -2
- package/lib/types/plugin-api/index.js +0 -14
- package/lib/types/plugin-api/pluginApi.d.ts +0 -23
- package/lib/types/plugin-api/pluginApi.js +0 -2
- package/lib/types/plugin.d.ts +0 -48
- package/lib/types/plugin.js +0 -2
- package/lib/types/theme-api/index.d.ts +0 -1
- package/lib/types/theme-api/index.js +0 -13
- package/lib/types/theme-api/themeApi.d.ts +0 -44
- package/lib/types/theme-api/themeApi.js +0 -2
- package/lib/types/theme.d.ts +0 -33
- package/lib/types/theme.js +0 -2
|
@@ -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,8 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.resolvePagePath = void 0;
|
|
4
|
-
/**
|
|
5
|
-
* Resolve the final route path of a page
|
|
6
|
-
*/
|
|
7
|
-
const resolvePagePath = ({ permalink, pathInferred, options, }) => encodeURI(permalink || pathInferred || options.path || '');
|
|
8
|
-
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,16 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.resolvePageRoutesInfo = void 0;
|
|
4
|
-
const utils_1 = require("@vuepress/utils");
|
|
5
|
-
/**
|
|
6
|
-
* Resolve page routes file path
|
|
7
|
-
*/
|
|
8
|
-
const resolvePageRoutesInfo = ({ app, key, }) => {
|
|
9
|
-
const routesFilePathRelative = utils_1.path.join(`internal/pageRoutes/${key}.js`);
|
|
10
|
-
const routesFilePath = app.dir.temp(routesFilePathRelative);
|
|
11
|
-
return {
|
|
12
|
-
routesFilePath,
|
|
13
|
-
routesFilePathRelative,
|
|
14
|
-
};
|
|
15
|
-
};
|
|
16
|
-
exports.resolvePageRoutesInfo = resolvePageRoutesInfo;
|
|
@@ -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,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,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,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,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;
|
package/lib/pluginApi/index.d.ts
DELETED
package/lib/pluginApi/index.js
DELETED
|
@@ -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,25 +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
|
-
}
|
|
23
|
-
return result;
|
|
24
|
-
};
|
|
25
|
-
exports.normalizeClientFilesHook = normalizeClientFilesHook;
|
|
@@ -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,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 = async (app) => {
|
|
11
|
-
// resolve theme info
|
|
12
|
-
const theme = await resolveThemeInfo_1.resolveThemeInfo(app, app.options.theme);
|
|
13
|
-
// resolve parent theme info
|
|
14
|
-
const parentTheme = theme.plugin.extends
|
|
15
|
-
? await 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;
|
package/lib/themeApi/index.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './createThemeApi';
|
package/lib/themeApi/index.js
DELETED
|
@@ -1,13 +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);
|
|
@@ -1,34 +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 = async (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
|
-
const message = `theme ${themeName} is not found`;
|
|
15
|
-
utils_1.logger.error(message);
|
|
16
|
-
throw new Error(message);
|
|
17
|
-
}
|
|
18
|
-
// normalize theme plugin from theme entry
|
|
19
|
-
const themePlugin = app_1.normalizePlugin(app, themeEntry, app.options.themeConfig);
|
|
20
|
-
// get theme path
|
|
21
|
-
const themePath = themeEntry.match(/.(js|ts)$/)
|
|
22
|
-
? utils_1.path.dirname(themeEntry)
|
|
23
|
-
: themeEntry;
|
|
24
|
-
// resolve theme layouts
|
|
25
|
-
const layouts = await resolveThemeLayouts_1.resolveThemeLayouts({
|
|
26
|
-
themePath,
|
|
27
|
-
themePlugin,
|
|
28
|
-
});
|
|
29
|
-
return {
|
|
30
|
-
plugin: themePlugin,
|
|
31
|
-
layouts,
|
|
32
|
-
};
|
|
33
|
-
};
|
|
34
|
-
exports.resolveThemeInfo = resolveThemeInfo;
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.resolveThemeLayouts = void 0;
|
|
4
|
-
const shared_1 = require("@vuepress/shared");
|
|
5
|
-
const utils_1 = require("@vuepress/utils");
|
|
6
|
-
const resolveThemeLayouts = async ({ themePath, themePlugin, }) => {
|
|
7
|
-
// use the layouts component map directly
|
|
8
|
-
if (shared_1.isPlainObject(themePlugin.layouts)) {
|
|
9
|
-
return Object.entries(themePlugin.layouts).map(([name, file]) => ({
|
|
10
|
-
name,
|
|
11
|
-
path: file,
|
|
12
|
-
}));
|
|
13
|
-
}
|
|
14
|
-
// resolve the layouts directory
|
|
15
|
-
const dirLayout = shared_1.isString(themePlugin.layouts) && utils_1.path.isAbsolute(themePlugin.layouts)
|
|
16
|
-
? themePlugin.layouts
|
|
17
|
-
: utils_1.path.resolve(themePath, 'layouts');
|
|
18
|
-
if (!(await utils_1.fs.pathExists(dirLayout))) {
|
|
19
|
-
utils_1.logger.warn(`layout path ${utils_1.chalk.magenta(dirLayout)} does not exist`);
|
|
20
|
-
return [];
|
|
21
|
-
}
|
|
22
|
-
// load all files in layouts directory
|
|
23
|
-
const files = await utils_1.fs.readdir(dirLayout);
|
|
24
|
-
// take matched files as theme layouts
|
|
25
|
-
const layouts = files
|
|
26
|
-
.filter((file) => /\.(vue|ts|js)$/.test(file))
|
|
27
|
-
.map((file) => ({
|
|
28
|
-
name: utils_1.path.trimExt(file),
|
|
29
|
-
path: utils_1.path.resolve(dirLayout, file),
|
|
30
|
-
}));
|
|
31
|
-
return layouts;
|
|
32
|
-
};
|
|
33
|
-
exports.resolveThemeLayouts = resolveThemeLayouts;
|
package/lib/types/app/app.d.ts
DELETED
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
import type { Markdown } from '@vuepress/markdown';
|
|
2
|
-
import type { SiteData } from '@vuepress/shared';
|
|
3
|
-
import type { BundlerDev, BundlerBuild } from '../bundler';
|
|
4
|
-
import type { Page } from '../page';
|
|
5
|
-
import type { Plugin, PluginOptions, PluginConfig } from '../plugin';
|
|
6
|
-
import type { PluginApi } from '../plugin-api';
|
|
7
|
-
import type { ThemeApi } from '../theme-api';
|
|
8
|
-
import type { AppOptions } from './options';
|
|
9
|
-
import type { AppDir, AppEnv, AppWriteTemp } from './utils';
|
|
10
|
-
/**
|
|
11
|
-
* Vuepress app
|
|
12
|
-
*/
|
|
13
|
-
export interface App {
|
|
14
|
-
version: string;
|
|
15
|
-
options: AppOptions;
|
|
16
|
-
dir: AppDir;
|
|
17
|
-
env: AppEnv;
|
|
18
|
-
siteData: SiteData;
|
|
19
|
-
markdown: Markdown;
|
|
20
|
-
pluginApi: PluginApi;
|
|
21
|
-
use: <T extends PluginOptions>(plugin: Plugin<T> | string, config?: Partial<T>) => void;
|
|
22
|
-
useByConfig: <T extends PluginOptions>(pluginConfig: PluginConfig<T>) => void;
|
|
23
|
-
init: () => Promise<void>;
|
|
24
|
-
prepare: () => Promise<void>;
|
|
25
|
-
dev: () => ReturnType<BundlerDev>;
|
|
26
|
-
build: () => ReturnType<BundlerBuild>;
|
|
27
|
-
writeTemp: AppWriteTemp;
|
|
28
|
-
themeApi: ThemeApi;
|
|
29
|
-
pages: Page[];
|
|
30
|
-
}
|
package/lib/types/app/app.js
DELETED
package/lib/types/app/index.d.ts
DELETED
package/lib/types/app/index.js
DELETED
|
@@ -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("./app"), exports);
|
|
14
|
-
__exportStar(require("./options"), exports);
|
|
15
|
-
__exportStar(require("./utils"), exports);
|