@vuepress/core 2.0.0-beta.27 → 2.0.0-beta.33
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 +5 -4
- package/lib/app/appUse.js +2 -2
- package/lib/app/createBaseApp.js +23 -26
- package/lib/app/index.d.ts +9 -9
- package/lib/app/index.js +9 -9
- package/lib/app/prepare/preparePagesRoutes.js +4 -4
- package/lib/app/{createAppDir.d.ts → resolveAppDir.d.ts} +2 -2
- package/lib/app/{createAppDir.js → resolveAppDir.js} +4 -4
- 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/{createAppPages.js → resolveAppPages.js} +6 -6
- 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/resolvePluginObject.d.ts +5 -0
- package/lib/app/{resolvePlugin.js → resolvePluginObject.js} +5 -5
- package/lib/app/resolvePluginsFromConfig.d.ts +1 -1
- package/lib/app/resolvePluginsFromConfig.js +3 -3
- package/lib/app/resolveThemeInfo.d.ts +2 -2
- package/lib/app/resolveThemeInfo.js +15 -7
- package/lib/app/resolveThemeObject.d.ts +5 -0
- package/lib/app/resolveThemeObject.js +22 -0
- package/lib/app/setupAppPlugins.d.ts +5 -0
- package/lib/app/setupAppPlugins.js +14 -0
- package/lib/app/setupAppTheme.d.ts +5 -0
- package/lib/app/setupAppTheme.js +21 -0
- package/lib/page/createPage.d.ts +1 -1
- package/lib/page/createPage.js +22 -10
- package/lib/page/index.d.ts +1 -2
- package/lib/page/index.js +1 -2
- package/lib/page/resolvePageContent.js +1 -1
- package/lib/page/resolvePageRouteMeta.d.ts +7 -0
- package/lib/page/resolvePageRouteMeta.js +8 -0
- package/lib/pluginApi/createHookQueue.js +1 -1
- package/lib/pluginApi/createPluginApiHooks.js +4 -4
- package/lib/types/app/app.d.ts +16 -14
- package/lib/types/app/options.d.ts +36 -25
- package/lib/types/page.d.ts +9 -3
- package/lib/types/pluginApi/hooks.d.ts +6 -7
- package/lib/types/theme.d.ts +28 -0
- package/package.json +6 -6
- 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/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/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,7 +2,8 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.appInit = void 0;
|
|
4
4
|
const utils_1 = require("@vuepress/utils");
|
|
5
|
-
const
|
|
5
|
+
const resolveAppMarkdown_1 = require("./resolveAppMarkdown");
|
|
6
|
+
const resolveAppPages_1 = require("./resolveAppPages");
|
|
6
7
|
const log = (0, utils_1.debug)('vuepress:core/app');
|
|
7
8
|
/**
|
|
8
9
|
* Initialize a vuepress app
|
|
@@ -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 (0,
|
|
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/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
|
|
5
|
+
const resolvePluginObject_1 = require("./resolvePluginObject");
|
|
6
6
|
const log = (0, utils_1.debug)('vuepress:core/app');
|
|
7
7
|
const appUse = (app, rawPlugin, config) => {
|
|
8
|
-
const plugin = (0,
|
|
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
|
package/lib/app/createBaseApp.js
CHANGED
|
@@ -1,51 +1,48 @@
|
|
|
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
|
|
15
|
-
const
|
|
16
|
-
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");
|
|
14
|
+
const setupAppPlugins_1 = require("./setupAppPlugins");
|
|
15
|
+
const setupAppTheme_1 = require("./setupAppTheme");
|
|
17
16
|
/**
|
|
18
17
|
* Create vuepress app
|
|
19
18
|
*/
|
|
20
19
|
const createBaseApp = (config, isBuild = false) => {
|
|
21
|
-
const
|
|
22
|
-
const
|
|
23
|
-
const
|
|
24
|
-
const env = (0, createAppEnv_1.createAppEnv)(options, isBuild);
|
|
25
|
-
const siteData = (0, createAppSiteData_1.createAppSiteData)(options);
|
|
26
|
-
const markdown = (0, markdown_1.createMarkdown)(options.markdown);
|
|
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);
|
|
27
23
|
const pluginApi = (0, pluginApi_1.createPluginApi)();
|
|
28
|
-
const
|
|
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,
|
|
36
|
+
// methods
|
|
38
37
|
use: (...args) => (0, appUse_1.appUse)(app, ...args),
|
|
39
38
|
init: () => (0, appInit_1.appInit)(app),
|
|
40
39
|
prepare: () => (0, appPrepare_1.appPrepare)(app),
|
|
41
40
|
};
|
|
42
|
-
//
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
app
|
|
46
|
-
|
|
47
|
-
const plugins = (0, resolvePluginsFromConfig_1.resolvePluginsFromConfig)(app, options.plugins);
|
|
48
|
-
plugins.forEach((plugin) => app.use(plugin));
|
|
41
|
+
// setup theme and plugins
|
|
42
|
+
// notice that we setup theme before plugins,
|
|
43
|
+
// so user plugins could override theme plugins
|
|
44
|
+
(0, setupAppTheme_1.setupAppTheme)(app, config);
|
|
45
|
+
(0, setupAppPlugins_1.setupAppPlugins)(app);
|
|
49
46
|
return app;
|
|
50
47
|
};
|
|
51
48
|
exports.createBaseApp = createBaseApp;
|
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);
|
|
@@ -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
|
|
@@ -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;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.resolveAppDir = exports.createAppDirFunction = void 0;
|
|
4
4
|
const utils_1 = require("@vuepress/utils");
|
|
5
5
|
/**
|
|
6
6
|
* Create directory util function
|
|
@@ -10,9 +10,9 @@ const createAppDirFunction = (baseDir) => {
|
|
|
10
10
|
};
|
|
11
11
|
exports.createAppDirFunction = createAppDirFunction;
|
|
12
12
|
/**
|
|
13
|
-
*
|
|
13
|
+
* Resolve directory utils for vuepress app
|
|
14
14
|
*/
|
|
15
|
-
const
|
|
15
|
+
const resolveAppDir = (options) => {
|
|
16
16
|
const cache = (0, exports.createAppDirFunction)(options.cache);
|
|
17
17
|
const temp = (0, exports.createAppDirFunction)(options.temp);
|
|
18
18
|
const source = (0, exports.createAppDirFunction)(options.source);
|
|
@@ -29,4 +29,4 @@ const createAppDir = (options) => {
|
|
|
29
29
|
public: publicDir,
|
|
30
30
|
};
|
|
31
31
|
};
|
|
32
|
-
exports.
|
|
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;
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.resolveAppPages = void 0;
|
|
4
4
|
const utils_1 = require("@vuepress/utils");
|
|
5
5
|
const page_1 = require("../page");
|
|
6
6
|
const log = (0, utils_1.debug)('vuepress:core/app');
|
|
7
7
|
/**
|
|
8
|
-
*
|
|
8
|
+
* Resolve pages for vuepress app
|
|
9
9
|
*/
|
|
10
|
-
const
|
|
11
|
-
log('
|
|
10
|
+
const resolveAppPages = async (app) => {
|
|
11
|
+
log('resolveAppPages start');
|
|
12
12
|
// resolve page absolute file paths according to the page patterns
|
|
13
13
|
const pageFilePaths = await (0, utils_1.globby)(app.options.pagePatterns, {
|
|
14
14
|
absolute: true,
|
|
@@ -25,7 +25,7 @@ const createAppPages = async (app) => {
|
|
|
25
25
|
},
|
|
26
26
|
}));
|
|
27
27
|
}
|
|
28
|
-
log('
|
|
28
|
+
log('resolveAppPages finish');
|
|
29
29
|
return pages;
|
|
30
30
|
};
|
|
31
|
-
exports.
|
|
31
|
+
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;
|
|
@@ -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;
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.resolvePluginObject = void 0;
|
|
4
4
|
const shared_1 = require("@vuepress/shared");
|
|
5
5
|
const utils_1 = require("@vuepress/utils");
|
|
6
6
|
const resolvePluginModule_1 = require("./resolvePluginModule");
|
|
7
7
|
/**
|
|
8
|
-
* Resolve a plugin according to name / path / module and config
|
|
8
|
+
* Resolve a plugin object according to name / path / module and config
|
|
9
9
|
*/
|
|
10
|
-
const
|
|
10
|
+
const resolvePluginObject = (app, plugin, pluginConfig = {}) => {
|
|
11
11
|
const pluginModule = (0, shared_1.isString)(plugin)
|
|
12
12
|
? (0, resolvePluginModule_1.resolvePluginModule)(plugin)
|
|
13
13
|
: plugin;
|
|
@@ -15,8 +15,8 @@ const resolvePlugin = (app, plugin, config = {}) => {
|
|
|
15
15
|
throw utils_1.logger.createError(`plugin is not found: ${utils_1.chalk.magenta(plugin)}`);
|
|
16
16
|
}
|
|
17
17
|
const pluginObject = (0, shared_1.isFunction)(pluginModule)
|
|
18
|
-
? pluginModule(
|
|
18
|
+
? pluginModule(pluginConfig, app)
|
|
19
19
|
: pluginModule;
|
|
20
20
|
return pluginObject;
|
|
21
21
|
};
|
|
22
|
-
exports.
|
|
22
|
+
exports.resolvePluginObject = resolvePluginObject;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { App, PluginConfig, PluginObject } from '../types';
|
|
2
2
|
/**
|
|
3
|
-
* Resolve
|
|
3
|
+
* Resolve plugin objects from plugin config array
|
|
4
4
|
*/
|
|
5
5
|
export declare const resolvePluginsFromConfig: (app: App, plugins?: PluginConfig[]) => PluginObject[];
|
|
@@ -2,14 +2,14 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.resolvePluginsFromConfig = void 0;
|
|
4
4
|
const normalizePluginConfig_1 = require("./normalizePluginConfig");
|
|
5
|
-
const
|
|
5
|
+
const resolvePluginObject_1 = require("./resolvePluginObject");
|
|
6
6
|
/**
|
|
7
|
-
* Resolve
|
|
7
|
+
* Resolve plugin objects from plugin config array
|
|
8
8
|
*/
|
|
9
9
|
const resolvePluginsFromConfig = (app, plugins = []) => plugins.reduce((prev, item) => {
|
|
10
10
|
const [plugin, config] = (0, normalizePluginConfig_1.normalizePluginConfig)(item);
|
|
11
11
|
if (config !== false) {
|
|
12
|
-
prev.push((0,
|
|
12
|
+
prev.push((0, resolvePluginObject_1.resolvePluginObject)(app, plugin, config === true ? {} : config));
|
|
13
13
|
}
|
|
14
14
|
return prev;
|
|
15
15
|
}, []);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { App, ThemeInfo } from '../types';
|
|
1
|
+
import type { App, ThemeConfig, ThemeInfo } from '../types';
|
|
2
2
|
/**
|
|
3
3
|
* Resolve theme info and its parent theme info
|
|
4
4
|
*/
|
|
5
|
-
export declare const resolveThemeInfo: (app: App,
|
|
5
|
+
export declare const resolveThemeInfo: (app: App, theme: string, themeConfig: ThemeConfig) => ThemeInfo;
|
|
@@ -2,27 +2,35 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.resolveThemeInfo = void 0;
|
|
4
4
|
const resolvePluginsFromConfig_1 = require("./resolvePluginsFromConfig");
|
|
5
|
-
const resolveTheme_1 = require("./resolveTheme");
|
|
6
5
|
const resolveThemeLayouts_1 = require("./resolveThemeLayouts");
|
|
6
|
+
const resolveThemeObject_1 = require("./resolveThemeObject");
|
|
7
7
|
/**
|
|
8
8
|
* Resolve theme info and its parent theme info
|
|
9
9
|
*/
|
|
10
|
-
const resolveThemeInfo = (app,
|
|
10
|
+
const resolveThemeInfo = (app, theme, themeConfig) => {
|
|
11
|
+
var _a, _b;
|
|
11
12
|
// resolve current theme info
|
|
12
|
-
const
|
|
13
|
+
const themeObject = (0, resolveThemeObject_1.resolveThemeObject)(app, theme, themeConfig);
|
|
13
14
|
const themeInfo = {
|
|
14
|
-
layouts: (0, resolveThemeLayouts_1.resolveThemeLayouts)(
|
|
15
|
-
plugins: [
|
|
15
|
+
layouts: (0, resolveThemeLayouts_1.resolveThemeLayouts)(themeObject.layouts),
|
|
16
|
+
plugins: [
|
|
17
|
+
...(0, resolvePluginsFromConfig_1.resolvePluginsFromConfig)(app, themeObject.plugins),
|
|
18
|
+
themeObject,
|
|
19
|
+
],
|
|
20
|
+
templateBuild: themeObject.templateBuild,
|
|
21
|
+
templateDev: themeObject.templateDev,
|
|
16
22
|
};
|
|
17
23
|
// return if current theme does not have a parent theme
|
|
18
|
-
if (!
|
|
24
|
+
if (!themeObject.extends) {
|
|
19
25
|
return themeInfo;
|
|
20
26
|
}
|
|
21
27
|
// resolve parent theme info recursively
|
|
22
|
-
const parentThemeInfo = (0, exports.resolveThemeInfo)(app,
|
|
28
|
+
const parentThemeInfo = (0, exports.resolveThemeInfo)(app, themeObject.extends, themeConfig);
|
|
23
29
|
return {
|
|
24
30
|
layouts: { ...parentThemeInfo.layouts, ...themeInfo.layouts },
|
|
25
31
|
plugins: [...parentThemeInfo.plugins, ...themeInfo.plugins],
|
|
32
|
+
templateBuild: (_a = themeObject.templateBuild) !== null && _a !== void 0 ? _a : parentThemeInfo.templateBuild,
|
|
33
|
+
templateDev: (_b = themeObject.templateDev) !== null && _b !== void 0 ? _b : parentThemeInfo.templateDev,
|
|
26
34
|
};
|
|
27
35
|
};
|
|
28
36
|
exports.resolveThemeInfo = resolveThemeInfo;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.resolveThemeObject = void 0;
|
|
4
|
+
const shared_1 = require("@vuepress/shared");
|
|
5
|
+
const utils_1 = require("@vuepress/utils");
|
|
6
|
+
const resolvePluginObject_1 = require("./resolvePluginObject");
|
|
7
|
+
/**
|
|
8
|
+
* Resolve a theme object according to the theme name
|
|
9
|
+
*/
|
|
10
|
+
const resolveThemeObject = (app, theme, themeConfig) => {
|
|
11
|
+
// resolve theme entry according to theme name
|
|
12
|
+
const themeEntry = (0, utils_1.requireResolve)(utils_1.path.isAbsolute(theme)
|
|
13
|
+
? theme
|
|
14
|
+
: (0, shared_1.normalizePackageName)(theme, 'vuepress', 'theme'));
|
|
15
|
+
if (themeEntry === null) {
|
|
16
|
+
throw utils_1.logger.createError(`theme is not found: ${utils_1.chalk.magenta(theme)}`);
|
|
17
|
+
}
|
|
18
|
+
// resolve theme object from theme entry
|
|
19
|
+
const themeObject = (0, resolvePluginObject_1.resolvePluginObject)(app, themeEntry, themeConfig);
|
|
20
|
+
return themeObject;
|
|
21
|
+
};
|
|
22
|
+
exports.resolveThemeObject = resolveThemeObject;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.setupAppPlugins = void 0;
|
|
4
|
+
const resolvePluginsFromConfig_1 = require("./resolvePluginsFromConfig");
|
|
5
|
+
/**
|
|
6
|
+
* Setup plugins for vuepress app
|
|
7
|
+
*/
|
|
8
|
+
const setupAppPlugins = (app) => {
|
|
9
|
+
// resolve plugins from options
|
|
10
|
+
const plugins = (0, resolvePluginsFromConfig_1.resolvePluginsFromConfig)(app, app.options.plugins);
|
|
11
|
+
// use plugins
|
|
12
|
+
plugins.forEach((plugin) => app.use(plugin));
|
|
13
|
+
};
|
|
14
|
+
exports.setupAppPlugins = setupAppPlugins;
|