@vuepress/core 2.0.0-beta.26 → 2.0.0-beta.32
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/lib/app/appInit.js +6 -5
- package/lib/app/appPrepare.js +11 -11
- package/lib/app/appUse.js +4 -4
- package/lib/app/createBaseApp.js +24 -26
- package/lib/app/createBuildApp.d.ts +1 -1
- package/lib/app/createBuildApp.js +2 -2
- package/lib/app/createDevApp.d.ts +1 -1
- package/lib/app/createDevApp.js +2 -2
- package/lib/app/index.d.ts +9 -9
- package/lib/app/index.js +9 -9
- package/lib/app/normalizePluginConfig.d.ts +1 -1
- package/lib/app/normalizePluginConfig.js +1 -1
- package/lib/app/prepare/preparePagesRoutes.js +5 -5
- package/lib/app/{createAppDir.d.ts → resolveAppDir.d.ts} +2 -2
- package/lib/app/resolveAppDir.js +32 -0
- package/lib/app/resolveAppEnv.d.ts +5 -0
- package/lib/app/resolveAppEnv.js +12 -0
- package/lib/app/resolveAppMarkdown.d.ts +6 -0
- package/lib/app/resolveAppMarkdown.js +16 -0
- package/lib/app/resolveAppOptions.d.ts +5 -0
- package/lib/app/{createAppOptions.js → resolveAppOptions.js} +7 -7
- package/lib/app/resolveAppPages.d.ts +5 -0
- package/lib/app/resolveAppPages.js +39 -0
- package/lib/app/resolveAppSiteData.d.ts +7 -0
- package/lib/app/{createAppSiteData.js → resolveAppSiteData.js} +4 -4
- package/lib/app/resolveAppVersion.d.ts +4 -0
- package/lib/app/resolveAppVersion.js +10 -0
- package/lib/app/resolveAppWriteTemp.d.ts +5 -0
- package/lib/app/{createAppWriteTemp.js → resolveAppWriteTemp.js} +4 -4
- package/lib/app/resolveBundler.js +1 -1
- package/lib/app/resolvePluginModule.js +2 -2
- package/lib/app/resolvePluginObject.d.ts +5 -0
- package/lib/app/resolvePluginObject.js +22 -0
- package/lib/app/resolvePluginsFromConfig.d.ts +1 -1
- package/lib/app/resolvePluginsFromConfig.js +4 -4
- package/lib/app/resolveThemeInfo.d.ts +2 -2
- package/lib/app/resolveThemeInfo.js +10 -7
- package/lib/app/resolveThemeLayouts.js +1 -1
- package/lib/app/resolveThemeObject.d.ts +5 -0
- package/lib/app/resolveThemeObject.js +22 -0
- package/lib/page/createPage.d.ts +1 -1
- package/lib/page/createPage.js +32 -24
- package/lib/page/index.d.ts +1 -2
- package/lib/page/index.js +1 -2
- package/lib/page/inferPagePath.js +2 -2
- package/lib/page/resolvePageContent.js +1 -1
- package/lib/page/resolvePageDate.d.ts +1 -1
- package/lib/page/resolvePageDate.js +5 -5
- package/lib/page/resolvePageFileContent.js +2 -2
- package/lib/page/resolvePageHtmlInfo.js +1 -1
- package/lib/page/resolvePageKey.js +1 -1
- package/lib/page/resolvePageLang.js +1 -1
- package/lib/page/resolvePagePath.js +1 -1
- package/lib/page/resolvePagePermalink.js +3 -3
- package/lib/page/resolvePageRouteMeta.d.ts +7 -0
- package/lib/page/resolvePageRouteMeta.js +8 -0
- package/lib/pluginApi/createHookQueue.js +3 -3
- package/lib/pluginApi/createPluginApi.js +2 -2
- package/lib/pluginApi/createPluginApiHooks.js +14 -14
- package/lib/pluginApi/createPluginApiRegisterHooks.js +5 -5
- package/lib/pluginApi/normalizeClientFilesHook.js +2 -2
- package/lib/pluginApi/normalizeReturnObjectHook.js +1 -1
- package/lib/types/app/app.d.ts +17 -15
- package/lib/types/app/options.d.ts +36 -25
- package/lib/types/index.d.ts +1 -1
- package/lib/types/page.d.ts +9 -3
- package/lib/types/pluginApi/hooks.d.ts +6 -7
- package/package.json +6 -6
- package/lib/app/createAppDir.js +0 -32
- package/lib/app/createAppEnv.d.ts +0 -5
- package/lib/app/createAppEnv.js +0 -12
- package/lib/app/createAppOptions.d.ts +0 -5
- package/lib/app/createAppPages.d.ts +0 -5
- package/lib/app/createAppPages.js +0 -31
- package/lib/app/createAppSiteData.d.ts +0 -7
- package/lib/app/createAppVersion.d.ts +0 -4
- package/lib/app/createAppVersion.js +0 -10
- package/lib/app/createAppWriteTemp.d.ts +0 -5
- package/lib/app/resolvePlugin.d.ts +0 -5
- package/lib/app/resolvePlugin.js +0 -22
- package/lib/app/resolveTheme.d.ts +0 -5
- package/lib/app/resolveTheme.js +0 -22
- package/lib/page/resolvePageData.d.ts +0 -8
- package/lib/page/resolvePageData.js +0 -23
- package/lib/page/resolvePageOptions.d.ts +0 -8
- package/lib/page/resolvePageOptions.js +0 -15
package/lib/app/appInit.js
CHANGED
|
@@ -2,8 +2,9 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.appInit = void 0;
|
|
4
4
|
const utils_1 = require("@vuepress/utils");
|
|
5
|
-
const
|
|
6
|
-
const
|
|
5
|
+
const resolveAppMarkdown_1 = require("./resolveAppMarkdown");
|
|
6
|
+
const resolveAppPages_1 = require("./resolveAppPages");
|
|
7
|
+
const log = (0, utils_1.debug)('vuepress:core/app');
|
|
7
8
|
/**
|
|
8
9
|
* Initialize a vuepress app
|
|
9
10
|
*
|
|
@@ -15,10 +16,10 @@ const appInit = async (app) => {
|
|
|
15
16
|
// plugins should be used before `registerHooks()`
|
|
16
17
|
// hooks in plugins will take effect after `registerHooks()`
|
|
17
18
|
app.pluginApi.registerHooks();
|
|
18
|
-
//
|
|
19
|
-
await
|
|
19
|
+
// create markdown
|
|
20
|
+
app.markdown = await (0, resolveAppMarkdown_1.resolveAppMarkdown)(app);
|
|
20
21
|
// create pages
|
|
21
|
-
app.pages = await
|
|
22
|
+
app.pages = await (0, resolveAppPages_1.resolveAppPages)(app);
|
|
22
23
|
// plugin hook: onInitialized
|
|
23
24
|
await app.pluginApi.hooks.onInitialized.process(app);
|
|
24
25
|
log('init finish');
|
package/lib/app/appPrepare.js
CHANGED
|
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.appPrepare = void 0;
|
|
4
4
|
const utils_1 = require("@vuepress/utils");
|
|
5
5
|
const prepare_1 = require("./prepare");
|
|
6
|
-
const log = utils_1.debug('vuepress:core/app');
|
|
6
|
+
const log = (0, utils_1.debug)('vuepress:core/app');
|
|
7
7
|
/**
|
|
8
8
|
* Prepare files for development or build
|
|
9
9
|
*
|
|
@@ -16,26 +16,26 @@ const appPrepare = async (app) => {
|
|
|
16
16
|
log('prepare start');
|
|
17
17
|
// generate page component files
|
|
18
18
|
for (const page of app.pages) {
|
|
19
|
-
await prepare_1.preparePageComponent(app, page);
|
|
19
|
+
await (0, prepare_1.preparePageComponent)(app, page);
|
|
20
20
|
}
|
|
21
|
-
await prepare_1.preparePagesComponents(app);
|
|
21
|
+
await (0, prepare_1.preparePagesComponents)(app);
|
|
22
22
|
// generate page data files
|
|
23
23
|
for (const page of app.pages) {
|
|
24
|
-
await prepare_1.preparePageData(app, page);
|
|
24
|
+
await (0, prepare_1.preparePageData)(app, page);
|
|
25
25
|
}
|
|
26
|
-
await prepare_1.preparePagesData(app);
|
|
26
|
+
await (0, prepare_1.preparePagesData)(app);
|
|
27
27
|
// generate routes file
|
|
28
|
-
await prepare_1.preparePagesRoutes(app);
|
|
28
|
+
await (0, prepare_1.preparePagesRoutes)(app);
|
|
29
29
|
// generate layout components map file
|
|
30
|
-
await prepare_1.prepareLayoutComponents(app);
|
|
30
|
+
await (0, prepare_1.prepareLayoutComponents)(app);
|
|
31
31
|
// generate site data file
|
|
32
|
-
await prepare_1.prepareSiteData(app);
|
|
32
|
+
await (0, prepare_1.prepareSiteData)(app);
|
|
33
33
|
// generate client app enhances file
|
|
34
|
-
await prepare_1.prepareClientAppEnhances(app);
|
|
34
|
+
await (0, prepare_1.prepareClientAppEnhances)(app);
|
|
35
35
|
// generate client app root components file
|
|
36
|
-
await prepare_1.prepareClientAppRootComponents(app);
|
|
36
|
+
await (0, prepare_1.prepareClientAppRootComponents)(app);
|
|
37
37
|
// generate client app setups file
|
|
38
|
-
await prepare_1.prepareClientAppSetups(app);
|
|
38
|
+
await (0, prepare_1.prepareClientAppSetups)(app);
|
|
39
39
|
// plugin hook: onPrepared
|
|
40
40
|
await app.pluginApi.hooks.onPrepared.process(app);
|
|
41
41
|
log('prepare finish');
|
package/lib/app/appUse.js
CHANGED
|
@@ -2,10 +2,10 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.appUse = void 0;
|
|
4
4
|
const utils_1 = require("@vuepress/utils");
|
|
5
|
-
const
|
|
6
|
-
const log = utils_1.debug('vuepress:core/app');
|
|
5
|
+
const resolvePluginObject_1 = require("./resolvePluginObject");
|
|
6
|
+
const log = (0, utils_1.debug)('vuepress:core/app');
|
|
7
7
|
const appUse = (app, rawPlugin, config) => {
|
|
8
|
-
const plugin =
|
|
8
|
+
const plugin = (0, resolvePluginObject_1.resolvePluginObject)(app, rawPlugin, config);
|
|
9
9
|
log(`use plugin ${utils_1.chalk.magenta(plugin.name)}`);
|
|
10
10
|
if (plugin.multiple !== true) {
|
|
11
11
|
// remove duplicated plugin
|
|
@@ -13,7 +13,7 @@ const appUse = (app, rawPlugin, config) => {
|
|
|
13
13
|
if (duplicateIndex !== -1) {
|
|
14
14
|
app.pluginApi.plugins.splice(duplicateIndex, 1);
|
|
15
15
|
// show warning when duplicate plugins are detected
|
|
16
|
-
utils_1.warn(`plugin ${utils_1.chalk.magenta(plugin.name)} has been used multiple times, only the last one will take effect`);
|
|
16
|
+
(0, utils_1.warn)(`plugin ${utils_1.chalk.magenta(plugin.name)} has been used multiple times, only the last one will take effect`);
|
|
17
17
|
}
|
|
18
18
|
}
|
|
19
19
|
// use plugin
|
package/lib/app/createBaseApp.js
CHANGED
|
@@ -1,51 +1,49 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.createBaseApp = void 0;
|
|
4
|
-
const markdown_1 = require("@vuepress/markdown");
|
|
5
4
|
const pluginApi_1 = require("../pluginApi");
|
|
6
5
|
const appInit_1 = require("./appInit");
|
|
7
6
|
const appPrepare_1 = require("./appPrepare");
|
|
8
7
|
const appUse_1 = require("./appUse");
|
|
9
|
-
const
|
|
10
|
-
const
|
|
11
|
-
const
|
|
12
|
-
const
|
|
13
|
-
const
|
|
14
|
-
const
|
|
8
|
+
const resolveAppDir_1 = require("./resolveAppDir");
|
|
9
|
+
const resolveAppEnv_1 = require("./resolveAppEnv");
|
|
10
|
+
const resolveAppOptions_1 = require("./resolveAppOptions");
|
|
11
|
+
const resolveAppSiteData_1 = require("./resolveAppSiteData");
|
|
12
|
+
const resolveAppVersion_1 = require("./resolveAppVersion");
|
|
13
|
+
const resolveAppWriteTemp_1 = require("./resolveAppWriteTemp");
|
|
15
14
|
const resolvePluginsFromConfig_1 = require("./resolvePluginsFromConfig");
|
|
16
15
|
const resolveThemeInfo_1 = require("./resolveThemeInfo");
|
|
17
16
|
/**
|
|
18
17
|
* Create vuepress app
|
|
19
18
|
*/
|
|
20
19
|
const createBaseApp = (config, isBuild = false) => {
|
|
21
|
-
const
|
|
22
|
-
const
|
|
23
|
-
const
|
|
24
|
-
const
|
|
25
|
-
const siteData =
|
|
26
|
-
const
|
|
27
|
-
const
|
|
28
|
-
const writeTemp = createAppWriteTemp_1.createAppWriteTemp(dir);
|
|
20
|
+
const options = (0, resolveAppOptions_1.resolveAppOptions)(config);
|
|
21
|
+
const dir = (0, resolveAppDir_1.resolveAppDir)(options);
|
|
22
|
+
const env = (0, resolveAppEnv_1.resolveAppEnv)(options, isBuild);
|
|
23
|
+
const pluginApi = (0, pluginApi_1.createPluginApi)();
|
|
24
|
+
const siteData = (0, resolveAppSiteData_1.resolveAppSiteData)(options);
|
|
25
|
+
const version = (0, resolveAppVersion_1.resolveAppVersion)();
|
|
26
|
+
const writeTemp = (0, resolveAppWriteTemp_1.resolveAppWriteTemp)(dir);
|
|
29
27
|
const app = {
|
|
30
|
-
version,
|
|
31
28
|
options,
|
|
29
|
+
siteData,
|
|
30
|
+
version,
|
|
31
|
+
// utils
|
|
32
32
|
dir,
|
|
33
33
|
env,
|
|
34
|
-
siteData,
|
|
35
|
-
markdown,
|
|
36
34
|
pluginApi,
|
|
37
35
|
writeTemp,
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
36
|
+
// methods
|
|
37
|
+
use: (...args) => (0, appUse_1.appUse)(app, ...args),
|
|
38
|
+
init: () => (0, appInit_1.appInit)(app),
|
|
39
|
+
prepare: () => (0, appPrepare_1.appPrepare)(app),
|
|
41
40
|
};
|
|
42
|
-
// resolve theme info and
|
|
43
|
-
const themeInfo = resolveThemeInfo_1.resolveThemeInfo(app, options.theme);
|
|
44
|
-
themeInfo.plugins.forEach((plugin) => app.use(plugin));
|
|
41
|
+
// resolve theme info and set app layouts
|
|
42
|
+
const themeInfo = (0, resolveThemeInfo_1.resolveThemeInfo)(app, options.theme, options.themeConfig);
|
|
45
43
|
app.layouts = themeInfo.layouts;
|
|
46
44
|
// resolve plugins
|
|
47
|
-
const plugins = resolvePluginsFromConfig_1.resolvePluginsFromConfig(app, options.plugins);
|
|
48
|
-
plugins.forEach((plugin) => app.use(plugin));
|
|
45
|
+
const plugins = (0, resolvePluginsFromConfig_1.resolvePluginsFromConfig)(app, options.plugins);
|
|
46
|
+
[...themeInfo.plugins, ...plugins].forEach((plugin) => app.use(plugin));
|
|
49
47
|
return app;
|
|
50
48
|
};
|
|
51
49
|
exports.createBaseApp = createBaseApp;
|
|
@@ -7,8 +7,8 @@ const resolveBundler_1 = require("./resolveBundler");
|
|
|
7
7
|
* Create vuepress build app
|
|
8
8
|
*/
|
|
9
9
|
const createBuildApp = (config) => {
|
|
10
|
-
const app = createBaseApp_1.createBaseApp(config, true);
|
|
11
|
-
app.build = () => resolveBundler_1.resolveBundler(app.options).build(app);
|
|
10
|
+
const app = (0, createBaseApp_1.createBaseApp)(config, true);
|
|
11
|
+
app.build = () => (0, resolveBundler_1.resolveBundler)(app.options).build(app);
|
|
12
12
|
return app;
|
|
13
13
|
};
|
|
14
14
|
exports.createBuildApp = createBuildApp;
|
package/lib/app/createDevApp.js
CHANGED
|
@@ -7,8 +7,8 @@ const resolveBundler_1 = require("./resolveBundler");
|
|
|
7
7
|
* Create vuepress dev app
|
|
8
8
|
*/
|
|
9
9
|
const createDevApp = (config) => {
|
|
10
|
-
const app = createBaseApp_1.createBaseApp(config, false);
|
|
11
|
-
app.dev = () => resolveBundler_1.resolveBundler(app.options).dev(app);
|
|
10
|
+
const app = (0, createBaseApp_1.createBaseApp)(config, false);
|
|
11
|
+
app.dev = () => (0, resolveBundler_1.resolveBundler)(app.options).dev(app);
|
|
12
12
|
return app;
|
|
13
13
|
};
|
|
14
14
|
exports.createDevApp = createDevApp;
|
package/lib/app/index.d.ts
CHANGED
|
@@ -2,21 +2,21 @@ export * from './prepare';
|
|
|
2
2
|
export * from './appInit';
|
|
3
3
|
export * from './appPrepare';
|
|
4
4
|
export * from './appUse';
|
|
5
|
-
export * from './createAppDir';
|
|
6
|
-
export * from './createAppEnv';
|
|
7
|
-
export * from './createAppOptions';
|
|
8
|
-
export * from './createAppPages';
|
|
9
|
-
export * from './createAppSiteData';
|
|
10
|
-
export * from './createAppVersion';
|
|
11
|
-
export * from './createAppWriteTemp';
|
|
12
5
|
export * from './createBaseApp';
|
|
13
6
|
export * from './createBuildApp';
|
|
14
7
|
export * from './createDevApp';
|
|
15
8
|
export * from './normalizePluginConfig';
|
|
9
|
+
export * from './resolveAppDir';
|
|
10
|
+
export * from './resolveAppEnv';
|
|
11
|
+
export * from './resolveAppOptions';
|
|
12
|
+
export * from './resolveAppPages';
|
|
13
|
+
export * from './resolveAppSiteData';
|
|
14
|
+
export * from './resolveAppVersion';
|
|
15
|
+
export * from './resolveAppWriteTemp';
|
|
16
16
|
export * from './resolveBundler';
|
|
17
|
-
export * from './
|
|
17
|
+
export * from './resolvePluginObject';
|
|
18
18
|
export * from './resolvePluginModule';
|
|
19
19
|
export * from './resolvePluginsFromConfig';
|
|
20
|
-
export * from './
|
|
20
|
+
export * from './resolveThemeObject';
|
|
21
21
|
export * from './resolveThemeInfo';
|
|
22
22
|
export * from './resolveThemeLayouts';
|
package/lib/app/index.js
CHANGED
|
@@ -14,21 +14,21 @@ __exportStar(require("./prepare"), exports);
|
|
|
14
14
|
__exportStar(require("./appInit"), exports);
|
|
15
15
|
__exportStar(require("./appPrepare"), exports);
|
|
16
16
|
__exportStar(require("./appUse"), exports);
|
|
17
|
-
__exportStar(require("./createAppDir"), exports);
|
|
18
|
-
__exportStar(require("./createAppEnv"), exports);
|
|
19
|
-
__exportStar(require("./createAppOptions"), exports);
|
|
20
|
-
__exportStar(require("./createAppPages"), exports);
|
|
21
|
-
__exportStar(require("./createAppSiteData"), exports);
|
|
22
|
-
__exportStar(require("./createAppVersion"), exports);
|
|
23
|
-
__exportStar(require("./createAppWriteTemp"), exports);
|
|
24
17
|
__exportStar(require("./createBaseApp"), exports);
|
|
25
18
|
__exportStar(require("./createBuildApp"), exports);
|
|
26
19
|
__exportStar(require("./createDevApp"), exports);
|
|
27
20
|
__exportStar(require("./normalizePluginConfig"), exports);
|
|
21
|
+
__exportStar(require("./resolveAppDir"), exports);
|
|
22
|
+
__exportStar(require("./resolveAppEnv"), exports);
|
|
23
|
+
__exportStar(require("./resolveAppOptions"), exports);
|
|
24
|
+
__exportStar(require("./resolveAppPages"), exports);
|
|
25
|
+
__exportStar(require("./resolveAppSiteData"), exports);
|
|
26
|
+
__exportStar(require("./resolveAppVersion"), exports);
|
|
27
|
+
__exportStar(require("./resolveAppWriteTemp"), exports);
|
|
28
28
|
__exportStar(require("./resolveBundler"), exports);
|
|
29
|
-
__exportStar(require("./
|
|
29
|
+
__exportStar(require("./resolvePluginObject"), exports);
|
|
30
30
|
__exportStar(require("./resolvePluginModule"), exports);
|
|
31
31
|
__exportStar(require("./resolvePluginsFromConfig"), exports);
|
|
32
|
-
__exportStar(require("./
|
|
32
|
+
__exportStar(require("./resolveThemeObject"), exports);
|
|
33
33
|
__exportStar(require("./resolveThemeInfo"), exports);
|
|
34
34
|
__exportStar(require("./resolveThemeLayouts"), exports);
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { PluginConfig, PluginConfigNormalized, PluginOptions } from '../types';
|
|
2
2
|
export declare const normalizePluginConfig: <T extends PluginOptions>(pluginConfig: PluginConfig<T>) => PluginConfigNormalized<T>;
|
|
@@ -6,7 +6,7 @@ const normalizePluginConfig = (pluginConfig) => {
|
|
|
6
6
|
var _a;
|
|
7
7
|
// ['container'] -> ['container', true]
|
|
8
8
|
// ['container', options] -> ['container', options]
|
|
9
|
-
if (shared_1.isArray(pluginConfig)) {
|
|
9
|
+
if ((0, shared_1.isArray)(pluginConfig)) {
|
|
10
10
|
return [pluginConfig[0], (_a = pluginConfig[1]) !== null && _a !== void 0 ? _a : true];
|
|
11
11
|
}
|
|
12
12
|
// 'container' -> ['container', true]
|
|
@@ -11,9 +11,9 @@ import { Vuepress } from '@vuepress/client/lib/components/Vuepress'
|
|
|
11
11
|
|
|
12
12
|
const routeItems = [\
|
|
13
13
|
${app.pages
|
|
14
|
-
.map(({ key, path, pathInferred, filePathRelative,
|
|
14
|
+
.map(({ key, path, pathInferred, filePathRelative, routeMeta }) => {
|
|
15
15
|
const redirects = [];
|
|
16
|
-
const routeItem = [key, path,
|
|
16
|
+
const routeItem = [key, path, routeMeta, redirects];
|
|
17
17
|
// paths that should redirect to this page
|
|
18
18
|
const redirectsSet = new Set();
|
|
19
19
|
// redirect from decoded path
|
|
@@ -33,7 +33,7 @@ ${app.pages
|
|
|
33
33
|
}
|
|
34
34
|
// redirect from filename path
|
|
35
35
|
if (filePathRelative !== null) {
|
|
36
|
-
const filenamePath = shared_1.ensureLeadingSlash(filePathRelative);
|
|
36
|
+
const filenamePath = (0, shared_1.ensureLeadingSlash)(filePathRelative);
|
|
37
37
|
redirectsSet.add(filenamePath);
|
|
38
38
|
redirectsSet.add(encodeURI(filenamePath));
|
|
39
39
|
}
|
|
@@ -47,13 +47,13 @@ ${app.pages
|
|
|
47
47
|
]
|
|
48
48
|
|
|
49
49
|
export const pagesRoutes = routeItems.reduce(
|
|
50
|
-
(result, [name, path,
|
|
50
|
+
(result, [name, path, meta, redirects]) => {
|
|
51
51
|
result.push(
|
|
52
52
|
{
|
|
53
53
|
name,
|
|
54
54
|
path,
|
|
55
55
|
component: Vuepress,
|
|
56
|
-
meta
|
|
56
|
+
meta,
|
|
57
57
|
},
|
|
58
58
|
...redirects.map((item) => ({
|
|
59
59
|
path: item,
|
|
@@ -4,6 +4,6 @@ import type { AppDir, AppDirFunction, AppOptions } from '../types';
|
|
|
4
4
|
*/
|
|
5
5
|
export declare const createAppDirFunction: (baseDir: string) => AppDirFunction;
|
|
6
6
|
/**
|
|
7
|
-
*
|
|
7
|
+
* Resolve directory utils for vuepress app
|
|
8
8
|
*/
|
|
9
|
-
export declare const
|
|
9
|
+
export declare const resolveAppDir: (options: AppOptions) => AppDir;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.resolveAppDir = exports.createAppDirFunction = void 0;
|
|
4
|
+
const utils_1 = require("@vuepress/utils");
|
|
5
|
+
/**
|
|
6
|
+
* Create directory util function
|
|
7
|
+
*/
|
|
8
|
+
const createAppDirFunction = (baseDir) => {
|
|
9
|
+
return (...args) => utils_1.path.resolve(baseDir, ...args);
|
|
10
|
+
};
|
|
11
|
+
exports.createAppDirFunction = createAppDirFunction;
|
|
12
|
+
/**
|
|
13
|
+
* Resolve directory utils for vuepress app
|
|
14
|
+
*/
|
|
15
|
+
const resolveAppDir = (options) => {
|
|
16
|
+
const cache = (0, exports.createAppDirFunction)(options.cache);
|
|
17
|
+
const temp = (0, exports.createAppDirFunction)(options.temp);
|
|
18
|
+
const source = (0, exports.createAppDirFunction)(options.source);
|
|
19
|
+
const dest = (0, exports.createAppDirFunction)(options.dest);
|
|
20
|
+
const publicDir = (0, exports.createAppDirFunction)(options.public);
|
|
21
|
+
// @vuepress/client
|
|
22
|
+
const client = (0, exports.createAppDirFunction)(utils_1.path.resolve(require.resolve('@vuepress/client/package.json'), '..'));
|
|
23
|
+
return {
|
|
24
|
+
cache,
|
|
25
|
+
temp,
|
|
26
|
+
source,
|
|
27
|
+
dest,
|
|
28
|
+
client,
|
|
29
|
+
public: publicDir,
|
|
30
|
+
};
|
|
31
|
+
};
|
|
32
|
+
exports.resolveAppDir = resolveAppDir;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.resolveAppEnv = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Resolve environment flags for vuepress app
|
|
6
|
+
*/
|
|
7
|
+
const resolveAppEnv = (options, isBuild) => ({
|
|
8
|
+
isBuild,
|
|
9
|
+
isDev: !isBuild,
|
|
10
|
+
isDebug: options.debug,
|
|
11
|
+
});
|
|
12
|
+
exports.resolveAppEnv = resolveAppEnv;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.resolveAppMarkdown = void 0;
|
|
4
|
+
const markdown_1 = require("@vuepress/markdown");
|
|
5
|
+
/**
|
|
6
|
+
* Resolve markdown-it instance for vuepress app
|
|
7
|
+
*/
|
|
8
|
+
const resolveAppMarkdown = async (app) => {
|
|
9
|
+
// plugin hook: extendsMarkdownOptions
|
|
10
|
+
await app.pluginApi.hooks.extendsMarkdownOptions.process(app.options.markdown, app);
|
|
11
|
+
const markdown = (0, markdown_1.createMarkdown)(app.options.markdown);
|
|
12
|
+
// plugin hook: extendsMarkdown
|
|
13
|
+
await app.pluginApi.hooks.extendsMarkdown.process(markdown, app);
|
|
14
|
+
return markdown;
|
|
15
|
+
};
|
|
16
|
+
exports.resolveAppMarkdown = resolveAppMarkdown;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { AppConfig, AppOptions } from '../types';
|
|
2
|
+
/**
|
|
3
|
+
* Create app options with default values
|
|
4
|
+
*/
|
|
5
|
+
export declare const resolveAppOptions: ({ base, lang, title, description, head, locales, theme, themeConfig, bundler, bundlerConfig, source, dest, temp, cache, public: publicDir, markdown, host, port, debug, open, pagePatterns, templateDev, templateBuild, shouldPreload, shouldPrefetch, plugins, }: AppConfig) => AppOptions;
|
|
@@ -1,23 +1,23 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.resolveAppOptions = void 0;
|
|
4
4
|
const utils_1 = require("@vuepress/utils");
|
|
5
5
|
/**
|
|
6
6
|
* Create app options with default values
|
|
7
7
|
*/
|
|
8
|
-
const
|
|
8
|
+
const resolveAppOptions = ({
|
|
9
9
|
// site config
|
|
10
10
|
base = '/', lang = 'en-US', title = '', description = '', head = [], locales = {},
|
|
11
11
|
// theme config
|
|
12
|
-
theme = '@vuepress/default', themeConfig = {},
|
|
12
|
+
theme = '@vuepress/theme-default', themeConfig = {},
|
|
13
13
|
// bundler config
|
|
14
|
-
bundler = '@vuepress/
|
|
14
|
+
bundler = '@vuepress/bundler-vite', bundlerConfig = {},
|
|
15
15
|
// directory config
|
|
16
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
17
|
// markdown config
|
|
18
18
|
markdown = {},
|
|
19
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')),
|
|
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')), templateBuild = utils_1.path.normalize(require.resolve('@vuepress/client/templates/index.build.html')), shouldPreload = true, shouldPrefetch = false,
|
|
21
21
|
// plugin config
|
|
22
22
|
plugins = [], }) => ({
|
|
23
23
|
base,
|
|
@@ -42,9 +42,9 @@ plugins = [], }) => ({
|
|
|
42
42
|
open,
|
|
43
43
|
pagePatterns,
|
|
44
44
|
templateDev,
|
|
45
|
-
|
|
45
|
+
templateBuild,
|
|
46
46
|
shouldPreload,
|
|
47
47
|
shouldPrefetch,
|
|
48
48
|
plugins,
|
|
49
49
|
});
|
|
50
|
-
exports.
|
|
50
|
+
exports.resolveAppOptions = resolveAppOptions;
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.resolveAppPages = void 0;
|
|
4
|
+
const utils_1 = require("@vuepress/utils");
|
|
5
|
+
const page_1 = require("../page");
|
|
6
|
+
const log = (0, utils_1.debug)('vuepress:core/app');
|
|
7
|
+
/**
|
|
8
|
+
* Resolve pages for vuepress app
|
|
9
|
+
*/
|
|
10
|
+
const resolveAppPages = async (app) => {
|
|
11
|
+
log('resolveAppPages start');
|
|
12
|
+
// resolve page absolute file paths according to the page patterns
|
|
13
|
+
const pageFilePaths = await (0, utils_1.globby)(app.options.pagePatterns, {
|
|
14
|
+
absolute: true,
|
|
15
|
+
cwd: app.dir.source(),
|
|
16
|
+
});
|
|
17
|
+
// create pages from files
|
|
18
|
+
const pages = await Promise.all(pageFilePaths.map(async (filePath) => {
|
|
19
|
+
const pageOptions = { filePath };
|
|
20
|
+
// plugin hook: extendsPageOptions
|
|
21
|
+
await app.pluginApi.hooks.extendsPageOptions.process(pageOptions, app);
|
|
22
|
+
const page = await (0, page_1.createPage)(app, pageOptions);
|
|
23
|
+
// plugin hook: extendsPage
|
|
24
|
+
await app.pluginApi.hooks.extendsPage.process(page, app);
|
|
25
|
+
return page;
|
|
26
|
+
}));
|
|
27
|
+
// if there is no 404 page, add one
|
|
28
|
+
if (!pages.some((page) => page.path === '/404.html')) {
|
|
29
|
+
pages.push(await (0, page_1.createPage)(app, {
|
|
30
|
+
path: '/404.html',
|
|
31
|
+
frontmatter: {
|
|
32
|
+
layout: '404',
|
|
33
|
+
},
|
|
34
|
+
}));
|
|
35
|
+
}
|
|
36
|
+
log('resolveAppPages finish');
|
|
37
|
+
return pages;
|
|
38
|
+
};
|
|
39
|
+
exports.resolveAppPages = resolveAppPages;
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.resolveAppSiteData = void 0;
|
|
4
4
|
/**
|
|
5
|
-
*
|
|
5
|
+
* Resolve site data for vuepress app
|
|
6
6
|
*
|
|
7
7
|
* Site data will also be used in client
|
|
8
8
|
*/
|
|
9
|
-
const
|
|
9
|
+
const resolveAppSiteData = (options) => ({
|
|
10
10
|
base: options.base,
|
|
11
11
|
lang: options.lang,
|
|
12
12
|
title: options.title,
|
|
@@ -14,4 +14,4 @@ const createAppSiteData = (options) => ({
|
|
|
14
14
|
head: options.head,
|
|
15
15
|
locales: options.locales,
|
|
16
16
|
});
|
|
17
|
-
exports.
|
|
17
|
+
exports.resolveAppSiteData = resolveAppSiteData;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.resolveAppVersion = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Resolve version of vuepress app
|
|
6
|
+
*/
|
|
7
|
+
const resolveAppVersion = () => {
|
|
8
|
+
return require('../../package.json').version;
|
|
9
|
+
};
|
|
10
|
+
exports.resolveAppVersion = resolveAppVersion;
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.resolveAppWriteTemp = void 0;
|
|
4
4
|
const utils_1 = require("@vuepress/utils");
|
|
5
5
|
/**
|
|
6
|
-
*
|
|
6
|
+
* Resolve write temp file util for vuepress app
|
|
7
7
|
*/
|
|
8
|
-
const
|
|
8
|
+
const resolveAppWriteTemp = (dir) => {
|
|
9
9
|
const tempCache = new Map();
|
|
10
10
|
const writeTemp = async (file, content) => {
|
|
11
11
|
const filePath = dir.temp(file);
|
|
@@ -18,4 +18,4 @@ const createAppWriteTemp = (dir) => {
|
|
|
18
18
|
};
|
|
19
19
|
return writeTemp;
|
|
20
20
|
};
|
|
21
|
-
exports.
|
|
21
|
+
exports.resolveAppWriteTemp = resolveAppWriteTemp;
|
|
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.resolveBundler = void 0;
|
|
4
4
|
const shared_1 = require("@vuepress/shared");
|
|
5
5
|
const resolveBundler = ({ bundler, bundlerConfig, }) => {
|
|
6
|
-
const bundlerPackage = shared_1.normalizePackageName(bundler, 'vuepress', 'bundler');
|
|
6
|
+
const bundlerPackage = (0, shared_1.normalizePackageName)(bundler, 'vuepress', 'bundler');
|
|
7
7
|
const { createBundler } = require(bundlerPackage);
|
|
8
8
|
return createBundler(bundlerConfig);
|
|
9
9
|
};
|
|
@@ -9,12 +9,12 @@ const utils_1 = require("@vuepress/utils");
|
|
|
9
9
|
const resolvePluginModule = (pluginName) => {
|
|
10
10
|
const pluginEntry = utils_1.path.isAbsolute(pluginName)
|
|
11
11
|
? pluginName
|
|
12
|
-
: utils_1.requireResolve(shared_1.normalizePackageName(pluginName, 'vuepress', 'plugin'));
|
|
12
|
+
: (0, utils_1.requireResolve)((0, shared_1.normalizePackageName)(pluginName, 'vuepress', 'plugin'));
|
|
13
13
|
if (pluginEntry === null) {
|
|
14
14
|
return null;
|
|
15
15
|
}
|
|
16
16
|
const pluginModule = require(pluginEntry);
|
|
17
17
|
// allow default export
|
|
18
|
-
return utils_1.hasExportDefault(pluginModule) ? pluginModule.default : pluginModule;
|
|
18
|
+
return (0, utils_1.hasExportDefault)(pluginModule) ? pluginModule.default : pluginModule;
|
|
19
19
|
};
|
|
20
20
|
exports.resolvePluginModule = resolvePluginModule;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { App, Plugin, PluginObject, PluginOptions } from '../types';
|
|
2
|
+
/**
|
|
3
|
+
* Resolve a plugin object according to name / path / module and config
|
|
4
|
+
*/
|
|
5
|
+
export declare const resolvePluginObject: <T extends PluginOptions = PluginOptions, U extends PluginObject = PluginObject>(app: App, plugin: string | Plugin<T, U>, pluginConfig?: Partial<T>) => U;
|