@vuepress/core 2.0.0-beta.29 → 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 +4 -4
- package/lib/app/appUse.js +2 -2
- package/lib/app/createBaseApp.js +19 -18
- package/lib/app/index.d.ts +9 -9
- package/lib/app/index.js +9 -9
- 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/{createAppMarkdown.js → resolveAppMarkdown.js} +4 -4
- 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 +10 -7
- package/lib/app/resolveThemeObject.d.ts +5 -0
- package/lib/app/resolveThemeObject.js +22 -0
- package/lib/types/app/app.d.ts +10 -10
- package/lib/types/app/options.d.ts +35 -22
- package/package.json +6 -6
- package/lib/app/createAppEnv.d.ts +0 -5
- package/lib/app/createAppEnv.js +0 -12
- package/lib/app/createAppMarkdown.d.ts +0 -6
- 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/app/appInit.js
CHANGED
|
@@ -2,8 +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
|
|
6
|
-
const
|
|
5
|
+
const resolveAppMarkdown_1 = require("./resolveAppMarkdown");
|
|
6
|
+
const resolveAppPages_1 = require("./resolveAppPages");
|
|
7
7
|
const log = (0, utils_1.debug)('vuepress:core/app');
|
|
8
8
|
/**
|
|
9
9
|
* Initialize a vuepress app
|
|
@@ -17,9 +17,9 @@ const appInit = async (app) => {
|
|
|
17
17
|
// hooks in plugins will take effect after `registerHooks()`
|
|
18
18
|
app.pluginApi.registerHooks();
|
|
19
19
|
// create markdown
|
|
20
|
-
app.markdown = await (0,
|
|
20
|
+
app.markdown = await (0, resolveAppMarkdown_1.resolveAppMarkdown)(app);
|
|
21
21
|
// create pages
|
|
22
|
-
app.pages = await (0,
|
|
22
|
+
app.pages = await (0, resolveAppPages_1.resolveAppPages)(app);
|
|
23
23
|
// plugin hook: onInitialized
|
|
24
24
|
await app.pluginApi.hooks.onInitialized.process(app);
|
|
25
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
|
@@ -5,44 +5,45 @@ const pluginApi_1 = require("../pluginApi");
|
|
|
5
5
|
const appInit_1 = require("./appInit");
|
|
6
6
|
const appPrepare_1 = require("./appPrepare");
|
|
7
7
|
const appUse_1 = require("./appUse");
|
|
8
|
-
const
|
|
9
|
-
const
|
|
10
|
-
const
|
|
11
|
-
const
|
|
12
|
-
const
|
|
13
|
-
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
14
|
const resolvePluginsFromConfig_1 = require("./resolvePluginsFromConfig");
|
|
15
15
|
const resolveThemeInfo_1 = require("./resolveThemeInfo");
|
|
16
16
|
/**
|
|
17
17
|
* Create vuepress app
|
|
18
18
|
*/
|
|
19
19
|
const createBaseApp = (config, isBuild = false) => {
|
|
20
|
-
const
|
|
21
|
-
const
|
|
22
|
-
const
|
|
23
|
-
const env = (0, createAppEnv_1.createAppEnv)(options, isBuild);
|
|
24
|
-
const siteData = (0, createAppSiteData_1.createAppSiteData)(options);
|
|
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);
|
|
25
23
|
const pluginApi = (0, pluginApi_1.createPluginApi)();
|
|
26
|
-
const
|
|
24
|
+
const siteData = (0, resolveAppSiteData_1.resolveAppSiteData)(options);
|
|
25
|
+
const version = (0, resolveAppVersion_1.resolveAppVersion)();
|
|
26
|
+
const writeTemp = (0, resolveAppWriteTemp_1.resolveAppWriteTemp)(dir);
|
|
27
27
|
const app = {
|
|
28
|
-
version,
|
|
29
28
|
options,
|
|
29
|
+
siteData,
|
|
30
|
+
version,
|
|
31
|
+
// utils
|
|
30
32
|
dir,
|
|
31
33
|
env,
|
|
32
|
-
siteData,
|
|
33
34
|
pluginApi,
|
|
34
35
|
writeTemp,
|
|
36
|
+
// methods
|
|
35
37
|
use: (...args) => (0, appUse_1.appUse)(app, ...args),
|
|
36
38
|
init: () => (0, appInit_1.appInit)(app),
|
|
37
39
|
prepare: () => (0, appPrepare_1.appPrepare)(app),
|
|
38
40
|
};
|
|
39
|
-
// resolve theme info and
|
|
40
|
-
const themeInfo = (0, resolveThemeInfo_1.resolveThemeInfo)(app, options.theme);
|
|
41
|
-
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);
|
|
42
43
|
app.layouts = themeInfo.layouts;
|
|
43
44
|
// resolve plugins
|
|
44
45
|
const plugins = (0, resolvePluginsFromConfig_1.resolvePluginsFromConfig)(app, options.plugins);
|
|
45
|
-
plugins.forEach((plugin) => app.use(plugin));
|
|
46
|
+
[...themeInfo.plugins, ...plugins].forEach((plugin) => app.use(plugin));
|
|
46
47
|
return app;
|
|
47
48
|
};
|
|
48
49
|
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);
|
|
@@ -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;
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.resolveAppMarkdown = void 0;
|
|
4
4
|
const markdown_1 = require("@vuepress/markdown");
|
|
5
5
|
/**
|
|
6
|
-
*
|
|
6
|
+
* Resolve markdown-it instance for vuepress app
|
|
7
7
|
*/
|
|
8
|
-
const
|
|
8
|
+
const resolveAppMarkdown = async (app) => {
|
|
9
9
|
// plugin hook: extendsMarkdownOptions
|
|
10
10
|
await app.pluginApi.hooks.extendsMarkdownOptions.process(app.options.markdown, app);
|
|
11
11
|
const markdown = (0, markdown_1.createMarkdown)(app.options.markdown);
|
|
@@ -13,4 +13,4 @@ const createAppMarkdown = async (app) => {
|
|
|
13
13
|
await app.pluginApi.hooks.extendsMarkdown.process(markdown, app);
|
|
14
14
|
return markdown;
|
|
15
15
|
};
|
|
16
|
-
exports.
|
|
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/vite', bundlerConfig = {},
|
|
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,
|
|
@@ -33,7 +33,7 @@ const createAppPages = async (app) => {
|
|
|
33
33
|
},
|
|
34
34
|
}));
|
|
35
35
|
}
|
|
36
|
-
log('
|
|
36
|
+
log('resolveAppPages finish');
|
|
37
37
|
return pages;
|
|
38
38
|
};
|
|
39
|
-
exports.
|
|
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;
|
|
@@ -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,24 +2,27 @@
|
|
|
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
11
|
// resolve current theme info
|
|
12
|
-
const
|
|
12
|
+
const themeObject = (0, resolveThemeObject_1.resolveThemeObject)(app, theme, themeConfig);
|
|
13
13
|
const themeInfo = {
|
|
14
|
-
layouts: (0, resolveThemeLayouts_1.resolveThemeLayouts)(
|
|
15
|
-
plugins: [
|
|
14
|
+
layouts: (0, resolveThemeLayouts_1.resolveThemeLayouts)(themeObject.layouts),
|
|
15
|
+
plugins: [
|
|
16
|
+
...(0, resolvePluginsFromConfig_1.resolvePluginsFromConfig)(app, themeObject.plugins),
|
|
17
|
+
themeObject,
|
|
18
|
+
],
|
|
16
19
|
};
|
|
17
20
|
// return if current theme does not have a parent theme
|
|
18
|
-
if (!
|
|
21
|
+
if (!themeObject.extends) {
|
|
19
22
|
return themeInfo;
|
|
20
23
|
}
|
|
21
24
|
// resolve parent theme info recursively
|
|
22
|
-
const parentThemeInfo = (0, exports.resolveThemeInfo)(app,
|
|
25
|
+
const parentThemeInfo = (0, exports.resolveThemeInfo)(app, themeObject.extends, themeConfig);
|
|
23
26
|
return {
|
|
24
27
|
layouts: { ...parentThemeInfo.layouts, ...themeInfo.layouts },
|
|
25
28
|
plugins: [...parentThemeInfo.plugins, ...themeInfo.plugins],
|
|
@@ -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;
|
package/lib/types/app/app.d.ts
CHANGED
|
@@ -10,14 +10,6 @@ import type { AppDir, AppEnv, AppWriteTemp } from './utils';
|
|
|
10
10
|
* Vuepress app
|
|
11
11
|
*/
|
|
12
12
|
export interface App {
|
|
13
|
-
/**
|
|
14
|
-
* Version of vuepress core
|
|
15
|
-
*/
|
|
16
|
-
version: string;
|
|
17
|
-
/**
|
|
18
|
-
* Options that filled all optional fields with a default value
|
|
19
|
-
*/
|
|
20
|
-
options: AppOptions;
|
|
21
13
|
/**
|
|
22
14
|
* Directory utils
|
|
23
15
|
*/
|
|
@@ -27,13 +19,21 @@ export interface App {
|
|
|
27
19
|
*/
|
|
28
20
|
env: AppEnv;
|
|
29
21
|
/**
|
|
30
|
-
*
|
|
22
|
+
* Options that filled all optional fields with a default value
|
|
31
23
|
*/
|
|
32
|
-
|
|
24
|
+
options: AppOptions;
|
|
33
25
|
/**
|
|
34
26
|
* Plugin system
|
|
35
27
|
*/
|
|
36
28
|
pluginApi: PluginApi;
|
|
29
|
+
/**
|
|
30
|
+
* Site data, which will be used in client side
|
|
31
|
+
*/
|
|
32
|
+
siteData: SiteData;
|
|
33
|
+
/**
|
|
34
|
+
* Version of vuepress core
|
|
35
|
+
*/
|
|
36
|
+
version: string;
|
|
37
37
|
/**
|
|
38
38
|
* Write temp file
|
|
39
39
|
*/
|
|
@@ -4,28 +4,41 @@ import type { BundlerConfig } from '../bundler';
|
|
|
4
4
|
import type { PluginConfig } from '../plugin';
|
|
5
5
|
import type { ThemeConfig } from '../theme';
|
|
6
6
|
/**
|
|
7
|
-
*
|
|
7
|
+
* Config to create vuepress app
|
|
8
8
|
*/
|
|
9
|
-
export
|
|
10
|
-
theme
|
|
11
|
-
themeConfig
|
|
12
|
-
bundler
|
|
13
|
-
bundlerConfig
|
|
9
|
+
export declare type AppConfig<T extends ThemeConfig = ThemeConfig, U extends BundlerConfig = BundlerConfig> = Partial<SiteData> & AppConfigDev & AppConfigBuild & {
|
|
10
|
+
theme?: string;
|
|
11
|
+
themeConfig?: Partial<T>;
|
|
12
|
+
bundler?: string;
|
|
13
|
+
bundlerConfig?: Partial<U>;
|
|
14
14
|
source: string;
|
|
15
|
-
dest
|
|
16
|
-
temp
|
|
17
|
-
cache
|
|
18
|
-
public
|
|
19
|
-
debug
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
plugins
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
15
|
+
dest?: string;
|
|
16
|
+
temp?: string;
|
|
17
|
+
cache?: string;
|
|
18
|
+
public?: string;
|
|
19
|
+
debug?: boolean;
|
|
20
|
+
pagePatterns?: string[];
|
|
21
|
+
markdown?: MarkdownOptions;
|
|
22
|
+
plugins?: PluginConfig[];
|
|
23
|
+
};
|
|
24
|
+
/**
|
|
25
|
+
* Vuepress app config for dev
|
|
26
|
+
*/
|
|
27
|
+
export interface AppConfigDev {
|
|
28
|
+
host?: string;
|
|
29
|
+
port?: number;
|
|
30
|
+
open?: boolean;
|
|
31
|
+
templateDev?: string;
|
|
30
32
|
}
|
|
31
|
-
|
|
33
|
+
/**
|
|
34
|
+
* Vuepress app config for build
|
|
35
|
+
*/
|
|
36
|
+
export interface AppConfigBuild {
|
|
37
|
+
shouldPreload?: ((file: string, type: string) => boolean) | boolean;
|
|
38
|
+
shouldPrefetch?: ((file: string, type: string) => boolean) | boolean;
|
|
39
|
+
templateBuild?: string;
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Vuepress app options
|
|
43
|
+
*/
|
|
44
|
+
export declare type AppOptions<T extends ThemeConfig = ThemeConfig, U extends BundlerConfig = BundlerConfig> = Required<AppConfig<T, U>>;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vuepress/core",
|
|
3
|
-
"version": "2.0.0-beta.
|
|
3
|
+
"version": "2.0.0-beta.32",
|
|
4
4
|
"description": "Core package of VuePress",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"vuepress",
|
|
@@ -26,15 +26,15 @@
|
|
|
26
26
|
"clean": "rimraf lib *.tsbuildinfo"
|
|
27
27
|
},
|
|
28
28
|
"dependencies": {
|
|
29
|
-
"@vuepress/client": "2.0.0-beta.
|
|
30
|
-
"@vuepress/markdown": "2.0.0-beta.
|
|
31
|
-
"@vuepress/shared": "2.0.0-beta.
|
|
32
|
-
"@vuepress/utils": "2.0.0-beta.
|
|
29
|
+
"@vuepress/client": "2.0.0-beta.32",
|
|
30
|
+
"@vuepress/markdown": "2.0.0-beta.32",
|
|
31
|
+
"@vuepress/shared": "2.0.0-beta.32",
|
|
32
|
+
"@vuepress/utils": "2.0.0-beta.32",
|
|
33
33
|
"gray-matter": "^4.0.3",
|
|
34
34
|
"toml": "^3.0.0"
|
|
35
35
|
},
|
|
36
36
|
"publishConfig": {
|
|
37
37
|
"access": "public"
|
|
38
38
|
},
|
|
39
|
-
"gitHead": "
|
|
39
|
+
"gitHead": "8ffa71313607fe78f3956e3ccb886fcae0ddf5e9"
|
|
40
40
|
}
|
package/lib/app/createAppEnv.js
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.createAppEnv = void 0;
|
|
4
|
-
/**
|
|
5
|
-
* Create environment flags for vuepress app
|
|
6
|
-
*/
|
|
7
|
-
const createAppEnv = (options, isBuild) => ({
|
|
8
|
-
isBuild,
|
|
9
|
-
isDev: !isBuild,
|
|
10
|
-
isDebug: options.debug,
|
|
11
|
-
});
|
|
12
|
-
exports.createAppEnv = createAppEnv;
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
import type { AppConfig, AppOptions } from '../types';
|
|
2
|
-
/**
|
|
3
|
-
* Create app options with default values
|
|
4
|
-
*/
|
|
5
|
-
export declare const createAppOptions: ({ base, lang, title, description, head, locales, theme, themeConfig, bundler, bundlerConfig, source, dest, temp, cache, public: publicDir, markdown, host, port, debug, open, pagePatterns, templateDev, templateSSR, shouldPreload, shouldPrefetch, plugins, }: AppConfig) => AppOptions;
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.createAppVersion = void 0;
|
|
4
|
-
/**
|
|
5
|
-
* Create version of vuepress app
|
|
6
|
-
*/
|
|
7
|
-
const createAppVersion = () => {
|
|
8
|
-
return require('../../package.json').version;
|
|
9
|
-
};
|
|
10
|
-
exports.createAppVersion = createAppVersion;
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
import type { App, Plugin, PluginObject, PluginOptions } from '../types';
|
|
2
|
-
/**
|
|
3
|
-
* Resolve a plugin according to name / path / module and config
|
|
4
|
-
*/
|
|
5
|
-
export declare const resolvePlugin: <T extends PluginOptions = PluginOptions, U extends PluginObject = PluginObject>(app: App, plugin: string | Plugin<T, U>, config?: Partial<T>) => U;
|
package/lib/app/resolveTheme.js
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.resolveTheme = void 0;
|
|
4
|
-
const shared_1 = require("@vuepress/shared");
|
|
5
|
-
const utils_1 = require("@vuepress/utils");
|
|
6
|
-
const resolvePlugin_1 = require("./resolvePlugin");
|
|
7
|
-
/**
|
|
8
|
-
* Resolve a theme according to the theme name
|
|
9
|
-
*/
|
|
10
|
-
const resolveTheme = (app, themeName) => {
|
|
11
|
-
// resolve theme entry according to theme name
|
|
12
|
-
const themeEntry = (0, utils_1.requireResolve)(utils_1.path.isAbsolute(themeName)
|
|
13
|
-
? themeName
|
|
14
|
-
: (0, shared_1.normalizePackageName)(themeName, 'vuepress', 'theme'));
|
|
15
|
-
if (themeEntry === null) {
|
|
16
|
-
throw utils_1.logger.createError(`theme is not found: ${utils_1.chalk.magenta(themeName)}`);
|
|
17
|
-
}
|
|
18
|
-
// resolve theme from theme entry
|
|
19
|
-
const theme = (0, resolvePlugin_1.resolvePlugin)(app, themeEntry, app.options.themeConfig);
|
|
20
|
-
return theme;
|
|
21
|
-
};
|
|
22
|
-
exports.resolveTheme = resolveTheme;
|