@vuepress/core 2.0.0-beta.50 → 2.0.0-beta.51
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/dist/index.d.ts +2 -26
- package/dist/index.js +21 -57
- package/package.json +5 -5
package/dist/index.d.ts
CHANGED
|
@@ -299,10 +299,6 @@ interface ThemeObject extends Omit<PluginObject, 'multiple'> {
|
|
|
299
299
|
* Extended parent theme
|
|
300
300
|
*/
|
|
301
301
|
extends?: Theme;
|
|
302
|
-
/**
|
|
303
|
-
* Specify the layouts directory or components map
|
|
304
|
-
*/
|
|
305
|
-
layouts?: string | Record<string, string>;
|
|
306
302
|
/**
|
|
307
303
|
* Allow using plugins in theme
|
|
308
304
|
*/
|
|
@@ -320,10 +316,6 @@ interface ThemeObject extends Omit<PluginObject, 'multiple'> {
|
|
|
320
316
|
* Resolved theme info
|
|
321
317
|
*/
|
|
322
318
|
interface ThemeInfo {
|
|
323
|
-
/**
|
|
324
|
-
* Layout components
|
|
325
|
-
*/
|
|
326
|
-
layouts: Record<string, string>;
|
|
327
319
|
/**
|
|
328
320
|
* Plugins, including theme itself and plugins used by theme
|
|
329
321
|
*/
|
|
@@ -504,12 +496,6 @@ interface App {
|
|
|
504
496
|
* Should be called after `app.init()`.
|
|
505
497
|
*/
|
|
506
498
|
prepare: () => Promise<void>;
|
|
507
|
-
/**
|
|
508
|
-
* Layout components.
|
|
509
|
-
*
|
|
510
|
-
* Only available after initialization
|
|
511
|
-
*/
|
|
512
|
-
layouts: Record<string, string>;
|
|
513
499
|
/**
|
|
514
500
|
* Markdown-it instance.
|
|
515
501
|
*
|
|
@@ -551,11 +537,6 @@ interface BuildApp extends App {
|
|
|
551
537
|
*/
|
|
552
538
|
declare const prepareClientConfigs: (app: App) => Promise<void>;
|
|
553
539
|
|
|
554
|
-
/**
|
|
555
|
-
* Generate layout components temp file
|
|
556
|
-
*/
|
|
557
|
-
declare const prepareLayoutComponents: (app: App) => Promise<void>;
|
|
558
|
-
|
|
559
540
|
/**
|
|
560
541
|
* Generate page component temp file of a single page
|
|
561
542
|
*/
|
|
@@ -654,7 +635,7 @@ declare const resolveAppSiteData: (options: AppOptions) => SiteData;
|
|
|
654
635
|
/**
|
|
655
636
|
* Resolve version of vuepress app
|
|
656
637
|
*/
|
|
657
|
-
declare const resolveAppVersion: () =>
|
|
638
|
+
declare const resolveAppVersion: () => string;
|
|
658
639
|
|
|
659
640
|
/**
|
|
660
641
|
* Resolve write temp file util for vuepress app
|
|
@@ -671,11 +652,6 @@ declare const resolvePluginObject: <T extends PluginObject = PluginObject>(app:
|
|
|
671
652
|
*/
|
|
672
653
|
declare const resolveThemeInfo: (app: App, theme: Theme) => ThemeInfo;
|
|
673
654
|
|
|
674
|
-
/**
|
|
675
|
-
* Resolve layouts from `layouts` option
|
|
676
|
-
*/
|
|
677
|
-
declare const resolveThemeLayouts: (layouts?: ThemeObject['layouts']) => Record<string, string>;
|
|
678
|
-
|
|
679
655
|
declare const createPage: (app: App, options: PageOptions) => Promise<Page>;
|
|
680
656
|
|
|
681
657
|
/**
|
|
@@ -847,4 +823,4 @@ declare const normalizeAliasDefineHook: (hook: AliasDefineHook['exposed']) => Al
|
|
|
847
823
|
*/
|
|
848
824
|
declare const normalizeClientConfigFileHook: (hook: ClientConfigFileHook['exposed']) => ClientConfigFileHook['normalized'];
|
|
849
825
|
|
|
850
|
-
export { AliasDefineHook, App, AppConfig, AppConfigBuild, AppConfigCommon, AppConfigDev, AppDir, AppDirFunction, AppEnv, AppOptions, AppWriteTemp, BuildApp, Bundler, ClientConfigFileHook, DevApp, ExtendsHook, Hook, HookItem, HookQueue, Hooks, HooksExposed, HooksName, HooksNormalized, HooksResult, LifeCycleHook, Page, PageOptions, Plugin, PluginApi, PluginConfig, PluginFunction, PluginObject, Theme, ThemeFunction, ThemeInfo, ThemeObject, appInit, appPrepare, appUse, createAppDirFunction, createBaseApp, createBuildApp, createDevApp, createHookQueue, createPage, createPluginApi, createPluginApiHooks, createPluginApiRegisterHooks, inferPagePath, normalizeAliasDefineHook, normalizeClientConfigFileHook, prepareClientConfigs,
|
|
826
|
+
export { AliasDefineHook, App, AppConfig, AppConfigBuild, AppConfigCommon, AppConfigDev, AppDir, AppDirFunction, AppEnv, AppOptions, AppWriteTemp, BuildApp, Bundler, ClientConfigFileHook, DevApp, ExtendsHook, Hook, HookItem, HookQueue, Hooks, HooksExposed, HooksName, HooksNormalized, HooksResult, LifeCycleHook, Page, PageOptions, Plugin, PluginApi, PluginConfig, PluginFunction, PluginObject, Theme, ThemeFunction, ThemeInfo, ThemeObject, appInit, appPrepare, appUse, createAppDirFunction, createBaseApp, createBuildApp, createDevApp, createHookQueue, createPage, createPluginApi, createPluginApiHooks, createPluginApiRegisterHooks, inferPagePath, normalizeAliasDefineHook, normalizeClientConfigFileHook, prepareClientConfigs, preparePageComponent, preparePageData, preparePagesComponents, preparePagesData, preparePagesRoutes, prepareSiteData, renderPageContent, resolveAppDir, resolveAppEnv, resolveAppOptions, resolveAppPages, resolveAppSiteData, resolveAppVersion, resolveAppWriteTemp, resolvePageComponentInfo, resolvePageDataInfo, resolvePageDate, resolvePageFileContent, resolvePageFilePath, resolvePageHtmlInfo, resolvePageKey, resolvePageLang, resolvePagePath, resolvePagePermalink, resolvePageRouteMeta, resolvePageSlug, resolvePluginObject, resolveThemeInfo };
|
package/dist/index.js
CHANGED
|
@@ -12,19 +12,6 @@ ${clientConfigFiles.map((_, index) => ` clientConfig${index},`).join("\n")}
|
|
|
12
12
|
await app.writeTemp("internal/clientConfigs.js", content);
|
|
13
13
|
};
|
|
14
14
|
|
|
15
|
-
// src/app/prepare/prepareLayoutComponents.ts
|
|
16
|
-
var prepareLayoutComponents = async (app) => {
|
|
17
|
-
const content = `import { defineAsyncComponent } from 'vue'
|
|
18
|
-
|
|
19
|
-
export const layoutComponents = {${Object.entries(app.layouts).map(
|
|
20
|
-
([name, path10]) => `
|
|
21
|
-
${JSON.stringify(name)}: defineAsyncComponent(() => import(${app.env.isDebug ? `/* webpackChunkName: "layout-${name}" */` : ""}${JSON.stringify(path10)})),`
|
|
22
|
-
).join("")}
|
|
23
|
-
}
|
|
24
|
-
`;
|
|
25
|
-
await app.writeTemp("internal/layoutComponents.js", content);
|
|
26
|
-
};
|
|
27
|
-
|
|
28
15
|
// src/app/prepare/preparePageComponent.ts
|
|
29
16
|
var preparePageComponent = async (app, page) => {
|
|
30
17
|
await app.writeTemp(
|
|
@@ -71,8 +58,8 @@ var preparePagesComponents = async (app) => {
|
|
|
71
58
|
const content = `import { defineAsyncComponent } from 'vue'
|
|
72
59
|
|
|
73
60
|
export const pagesComponents = {${app.pages.map(
|
|
74
|
-
({ key, path:
|
|
75
|
-
// path: ${
|
|
61
|
+
({ key, path: path9, componentFilePath, componentFileChunkName }) => `
|
|
62
|
+
// path: ${path9}
|
|
76
63
|
${JSON.stringify(key)}: defineAsyncComponent(() => import(${componentFileChunkName ? `/* webpackChunkName: "${componentFileChunkName}" */` : ""}${JSON.stringify(componentFilePath)})),`
|
|
77
64
|
).join("")}
|
|
78
65
|
}
|
|
@@ -83,8 +70,8 @@ export const pagesComponents = {${app.pages.map(
|
|
|
83
70
|
// src/app/prepare/preparePagesData.ts
|
|
84
71
|
var preparePagesData = async (app) => {
|
|
85
72
|
const content = `export const pagesData = {${app.pages.map(
|
|
86
|
-
({ key, path:
|
|
87
|
-
// path: ${
|
|
73
|
+
({ key, path: path9, dataFilePath, dataFileChunkName }) => `
|
|
74
|
+
// path: ${path9}
|
|
88
75
|
${JSON.stringify(key)}: () => import(${dataFileChunkName ? `/* webpackChunkName: "${dataFileChunkName}" */` : ""}${JSON.stringify(dataFilePath)}).then(({ data }) => data),`
|
|
89
76
|
).join("")}
|
|
90
77
|
}
|
|
@@ -96,17 +83,17 @@ var preparePagesData = async (app) => {
|
|
|
96
83
|
import { ensureLeadingSlash } from "@vuepress/shared";
|
|
97
84
|
var resolvePageRouteItem = ({
|
|
98
85
|
key,
|
|
99
|
-
path:
|
|
86
|
+
path: path9,
|
|
100
87
|
pathInferred,
|
|
101
88
|
filePathRelative,
|
|
102
89
|
routeMeta
|
|
103
90
|
}) => {
|
|
104
91
|
const redirectsSet = /* @__PURE__ */ new Set();
|
|
105
|
-
redirectsSet.add(decodeURI(
|
|
106
|
-
if (
|
|
107
|
-
redirectsSet.add(
|
|
92
|
+
redirectsSet.add(decodeURI(path9));
|
|
93
|
+
if (path9.endsWith("/")) {
|
|
94
|
+
redirectsSet.add(path9 + "index.html");
|
|
108
95
|
} else {
|
|
109
|
-
redirectsSet.add(
|
|
96
|
+
redirectsSet.add(path9.replace(/.html$/, ""));
|
|
110
97
|
}
|
|
111
98
|
if (pathInferred !== null) {
|
|
112
99
|
redirectsSet.add(pathInferred);
|
|
@@ -117,8 +104,8 @@ var resolvePageRouteItem = ({
|
|
|
117
104
|
redirectsSet.add(filenamePath);
|
|
118
105
|
redirectsSet.add(encodeURI(filenamePath));
|
|
119
106
|
}
|
|
120
|
-
redirectsSet.delete(
|
|
121
|
-
return [key,
|
|
107
|
+
redirectsSet.delete(path9);
|
|
108
|
+
return [key, path9, routeMeta, [...redirectsSet]];
|
|
122
109
|
};
|
|
123
110
|
var preparePagesRoutes = async (app) => {
|
|
124
111
|
const routeItems = app.pages.map(resolvePageRouteItem);
|
|
@@ -380,7 +367,7 @@ var resolvePageHtmlInfo = ({
|
|
|
380
367
|
|
|
381
368
|
// src/page/resolvePageKey.ts
|
|
382
369
|
import { hash } from "@vuepress/utils";
|
|
383
|
-
var resolvePageKey = ({ path:
|
|
370
|
+
var resolvePageKey = ({ path: path9 }) => `v-${hash(path9)}`;
|
|
384
371
|
|
|
385
372
|
// src/page/resolvePageLang.ts
|
|
386
373
|
import { isString as isString2 } from "@vuepress/shared";
|
|
@@ -509,11 +496,11 @@ var createPage = async (app, options) => {
|
|
|
509
496
|
pathInferred,
|
|
510
497
|
pathLocale
|
|
511
498
|
});
|
|
512
|
-
const
|
|
513
|
-
const key = resolvePageKey({ path:
|
|
499
|
+
const path9 = resolvePagePath({ permalink, pathInferred, options });
|
|
500
|
+
const key = resolvePageKey({ path: path9 });
|
|
514
501
|
const { htmlFilePath, htmlFilePathRelative } = resolvePageHtmlInfo({
|
|
515
502
|
app,
|
|
516
|
-
path:
|
|
503
|
+
path: path9
|
|
517
504
|
});
|
|
518
505
|
const {
|
|
519
506
|
componentFilePath,
|
|
@@ -528,7 +515,7 @@ var createPage = async (app, options) => {
|
|
|
528
515
|
const page = {
|
|
529
516
|
data: {
|
|
530
517
|
key,
|
|
531
|
-
path:
|
|
518
|
+
path: path9,
|
|
532
519
|
title,
|
|
533
520
|
lang,
|
|
534
521
|
frontmatter,
|
|
@@ -536,7 +523,7 @@ var createPage = async (app, options) => {
|
|
|
536
523
|
headers
|
|
537
524
|
},
|
|
538
525
|
key,
|
|
539
|
-
path:
|
|
526
|
+
path: path9,
|
|
540
527
|
title,
|
|
541
528
|
lang,
|
|
542
529
|
frontmatter,
|
|
@@ -584,7 +571,7 @@ var resolveAppPages = async (app) => {
|
|
|
584
571
|
await createPage(app, {
|
|
585
572
|
path: "/404.html",
|
|
586
573
|
frontmatter: {
|
|
587
|
-
layout: "
|
|
574
|
+
layout: "NotFound"
|
|
588
575
|
}
|
|
589
576
|
})
|
|
590
577
|
);
|
|
@@ -618,7 +605,6 @@ var appPrepare = async (app) => {
|
|
|
618
605
|
}
|
|
619
606
|
await preparePagesData(app);
|
|
620
607
|
await preparePagesRoutes(app);
|
|
621
|
-
await prepareLayoutComponents(app);
|
|
622
608
|
await prepareSiteData(app);
|
|
623
609
|
await prepareClientConfigs(app);
|
|
624
610
|
await app.pluginApi.hooks.onPrepared.process(app);
|
|
@@ -892,8 +878,8 @@ var resolveAppSiteData = (options) => ({
|
|
|
892
878
|
import { createRequire as createRequire3 } from "module";
|
|
893
879
|
import { fs as fs3 } from "@vuepress/utils";
|
|
894
880
|
var require4 = createRequire3(import.meta.url);
|
|
895
|
-
var resolveAppVersion =
|
|
896
|
-
const pkgJson =
|
|
881
|
+
var resolveAppVersion = () => {
|
|
882
|
+
const pkgJson = fs3.readJsonSync(
|
|
897
883
|
require4.resolve("@vuepress/core/package.json")
|
|
898
884
|
);
|
|
899
885
|
return pkgJson.version;
|
|
@@ -915,28 +901,10 @@ var resolveAppWriteTemp = (dir) => {
|
|
|
915
901
|
return writeTemp;
|
|
916
902
|
};
|
|
917
903
|
|
|
918
|
-
// src/app/resolveThemeLayouts.ts
|
|
919
|
-
import { isPlainObject } from "@vuepress/shared";
|
|
920
|
-
import { chalk as chalk3, fs as fs5, logger as logger5, path as path9 } from "@vuepress/utils";
|
|
921
|
-
var resolveThemeLayouts = (layouts = {}) => {
|
|
922
|
-
if (isPlainObject(layouts)) {
|
|
923
|
-
return layouts;
|
|
924
|
-
}
|
|
925
|
-
if (!fs5.pathExistsSync(layouts)) {
|
|
926
|
-
throw logger5.createError(
|
|
927
|
-
`layouts directory does not exist: ${chalk3.magenta(layouts)}`
|
|
928
|
-
);
|
|
929
|
-
}
|
|
930
|
-
return Object.fromEntries(
|
|
931
|
-
fs5.readdirSync(layouts).filter((file) => /\.(vue|ts|js)$/.test(file)).map((file) => [path9.trimExt(file), path9.resolve(layouts, file)])
|
|
932
|
-
);
|
|
933
|
-
};
|
|
934
|
-
|
|
935
904
|
// src/app/resolveThemeInfo.ts
|
|
936
905
|
var resolveThemeInfo = (app, theme) => {
|
|
937
906
|
const themeObject = resolvePluginObject(app, theme);
|
|
938
907
|
const themeInfo = {
|
|
939
|
-
layouts: resolveThemeLayouts(themeObject.layouts),
|
|
940
908
|
plugins: [...themeObject.plugins ?? [], themeObject],
|
|
941
909
|
templateBuild: themeObject.templateBuild,
|
|
942
910
|
templateDev: themeObject.templateDev
|
|
@@ -946,7 +914,6 @@ var resolveThemeInfo = (app, theme) => {
|
|
|
946
914
|
}
|
|
947
915
|
const parentThemeInfo = resolveThemeInfo(app, themeObject.extends);
|
|
948
916
|
return {
|
|
949
|
-
layouts: { ...parentThemeInfo.layouts, ...themeInfo.layouts },
|
|
950
917
|
plugins: [...parentThemeInfo.plugins, ...themeInfo.plugins],
|
|
951
918
|
templateBuild: themeObject.templateBuild ?? parentThemeInfo.templateBuild,
|
|
952
919
|
templateDev: themeObject.templateDev ?? parentThemeInfo.templateDev
|
|
@@ -956,7 +923,6 @@ var resolveThemeInfo = (app, theme) => {
|
|
|
956
923
|
// src/app/setupAppThemeAndPlugins.ts
|
|
957
924
|
var setupAppThemeAndPlugins = (app, config) => {
|
|
958
925
|
const themeInfo = resolveThemeInfo(app, app.options.theme);
|
|
959
|
-
app.layouts = themeInfo.layouts;
|
|
960
926
|
app.options.templateDev = config.templateDev ?? themeInfo.templateDev ?? app.options.templateDev;
|
|
961
927
|
app.options.templateBuild = config.templateBuild ?? themeInfo.templateBuild ?? app.options.templateBuild;
|
|
962
928
|
[...themeInfo.plugins, ...app.options.plugins].flat().forEach((plugin) => app.use(plugin));
|
|
@@ -1017,7 +983,6 @@ export {
|
|
|
1017
983
|
normalizeAliasDefineHook,
|
|
1018
984
|
normalizeClientConfigFileHook,
|
|
1019
985
|
prepareClientConfigs,
|
|
1020
|
-
prepareLayoutComponents,
|
|
1021
986
|
preparePageComponent,
|
|
1022
987
|
preparePageData,
|
|
1023
988
|
preparePagesComponents,
|
|
@@ -1045,6 +1010,5 @@ export {
|
|
|
1045
1010
|
resolvePageRouteMeta,
|
|
1046
1011
|
resolvePageSlug,
|
|
1047
1012
|
resolvePluginObject,
|
|
1048
|
-
resolveThemeInfo
|
|
1049
|
-
resolveThemeLayouts
|
|
1013
|
+
resolveThemeInfo
|
|
1050
1014
|
};
|
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.51",
|
|
4
4
|
"description": "Core package of VuePress",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"vuepress",
|
|
@@ -27,10 +27,10 @@
|
|
|
27
27
|
"dist"
|
|
28
28
|
],
|
|
29
29
|
"dependencies": {
|
|
30
|
-
"@vuepress/client": "2.0.0-beta.
|
|
31
|
-
"@vuepress/markdown": "2.0.0-beta.
|
|
32
|
-
"@vuepress/shared": "2.0.0-beta.
|
|
33
|
-
"@vuepress/utils": "2.0.0-beta.
|
|
30
|
+
"@vuepress/client": "2.0.0-beta.51",
|
|
31
|
+
"@vuepress/markdown": "2.0.0-beta.51",
|
|
32
|
+
"@vuepress/shared": "2.0.0-beta.51",
|
|
33
|
+
"@vuepress/utils": "2.0.0-beta.51",
|
|
34
34
|
"vue": "^3.2.37"
|
|
35
35
|
},
|
|
36
36
|
"publishConfig": {
|