@vuepress/core 2.0.0-beta.50 → 2.0.0-beta.52
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 +26 -60
- package/package.json +6 -6
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);
|
|
@@ -218,6 +205,7 @@ var renderPageContent = async ({
|
|
|
218
205
|
template: null,
|
|
219
206
|
script: null,
|
|
220
207
|
scriptSetup: null,
|
|
208
|
+
scripts: [],
|
|
221
209
|
styles: [],
|
|
222
210
|
customBlocks: []
|
|
223
211
|
},
|
|
@@ -380,7 +368,7 @@ var resolvePageHtmlInfo = ({
|
|
|
380
368
|
|
|
381
369
|
// src/page/resolvePageKey.ts
|
|
382
370
|
import { hash } from "@vuepress/utils";
|
|
383
|
-
var resolvePageKey = ({ path:
|
|
371
|
+
var resolvePageKey = ({ path: path9 }) => `v-${hash(path9)}`;
|
|
384
372
|
|
|
385
373
|
// src/page/resolvePageLang.ts
|
|
386
374
|
import { isString as isString2 } from "@vuepress/shared";
|
|
@@ -509,11 +497,11 @@ var createPage = async (app, options) => {
|
|
|
509
497
|
pathInferred,
|
|
510
498
|
pathLocale
|
|
511
499
|
});
|
|
512
|
-
const
|
|
513
|
-
const key = resolvePageKey({ path:
|
|
500
|
+
const path9 = resolvePagePath({ permalink, pathInferred, options });
|
|
501
|
+
const key = resolvePageKey({ path: path9 });
|
|
514
502
|
const { htmlFilePath, htmlFilePathRelative } = resolvePageHtmlInfo({
|
|
515
503
|
app,
|
|
516
|
-
path:
|
|
504
|
+
path: path9
|
|
517
505
|
});
|
|
518
506
|
const {
|
|
519
507
|
componentFilePath,
|
|
@@ -528,7 +516,7 @@ var createPage = async (app, options) => {
|
|
|
528
516
|
const page = {
|
|
529
517
|
data: {
|
|
530
518
|
key,
|
|
531
|
-
path:
|
|
519
|
+
path: path9,
|
|
532
520
|
title,
|
|
533
521
|
lang,
|
|
534
522
|
frontmatter,
|
|
@@ -536,7 +524,7 @@ var createPage = async (app, options) => {
|
|
|
536
524
|
headers
|
|
537
525
|
},
|
|
538
526
|
key,
|
|
539
|
-
path:
|
|
527
|
+
path: path9,
|
|
540
528
|
title,
|
|
541
529
|
lang,
|
|
542
530
|
frontmatter,
|
|
@@ -584,7 +572,7 @@ var resolveAppPages = async (app) => {
|
|
|
584
572
|
await createPage(app, {
|
|
585
573
|
path: "/404.html",
|
|
586
574
|
frontmatter: {
|
|
587
|
-
layout: "
|
|
575
|
+
layout: "NotFound"
|
|
588
576
|
}
|
|
589
577
|
})
|
|
590
578
|
);
|
|
@@ -618,7 +606,6 @@ var appPrepare = async (app) => {
|
|
|
618
606
|
}
|
|
619
607
|
await preparePagesData(app);
|
|
620
608
|
await preparePagesRoutes(app);
|
|
621
|
-
await prepareLayoutComponents(app);
|
|
622
609
|
await prepareSiteData(app);
|
|
623
610
|
await prepareClientConfigs(app);
|
|
624
611
|
await app.pluginApi.hooks.onPrepared.process(app);
|
|
@@ -736,6 +723,7 @@ var createPluginApiRegisterHooks = (plugins, hooks) => () => {
|
|
|
736
723
|
plugins.forEach(
|
|
737
724
|
({
|
|
738
725
|
name: pluginName,
|
|
726
|
+
multiple,
|
|
739
727
|
alias,
|
|
740
728
|
define,
|
|
741
729
|
clientConfigFile,
|
|
@@ -759,11 +747,11 @@ var createPluginApiRegisterHooks = (plugins, hooks) => () => {
|
|
|
759
747
|
hook: normalizeClientConfigFileHook(clientConfigFile)
|
|
760
748
|
});
|
|
761
749
|
}
|
|
762
|
-
Object.
|
|
763
|
-
if (hooks[key] &&
|
|
750
|
+
Object.keys(commonHooks).forEach((key) => {
|
|
751
|
+
if (hooks[key] && commonHooks[key]) {
|
|
764
752
|
hooks[key].add({
|
|
765
753
|
pluginName,
|
|
766
|
-
hook
|
|
754
|
+
hook: commonHooks[key]
|
|
767
755
|
});
|
|
768
756
|
}
|
|
769
757
|
});
|
|
@@ -892,8 +880,8 @@ var resolveAppSiteData = (options) => ({
|
|
|
892
880
|
import { createRequire as createRequire3 } from "module";
|
|
893
881
|
import { fs as fs3 } from "@vuepress/utils";
|
|
894
882
|
var require4 = createRequire3(import.meta.url);
|
|
895
|
-
var resolveAppVersion =
|
|
896
|
-
const pkgJson =
|
|
883
|
+
var resolveAppVersion = () => {
|
|
884
|
+
const pkgJson = fs3.readJsonSync(
|
|
897
885
|
require4.resolve("@vuepress/core/package.json")
|
|
898
886
|
);
|
|
899
887
|
return pkgJson.version;
|
|
@@ -915,28 +903,10 @@ var resolveAppWriteTemp = (dir) => {
|
|
|
915
903
|
return writeTemp;
|
|
916
904
|
};
|
|
917
905
|
|
|
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
906
|
// src/app/resolveThemeInfo.ts
|
|
936
907
|
var resolveThemeInfo = (app, theme) => {
|
|
937
908
|
const themeObject = resolvePluginObject(app, theme);
|
|
938
909
|
const themeInfo = {
|
|
939
|
-
layouts: resolveThemeLayouts(themeObject.layouts),
|
|
940
910
|
plugins: [...themeObject.plugins ?? [], themeObject],
|
|
941
911
|
templateBuild: themeObject.templateBuild,
|
|
942
912
|
templateDev: themeObject.templateDev
|
|
@@ -946,7 +916,6 @@ var resolveThemeInfo = (app, theme) => {
|
|
|
946
916
|
}
|
|
947
917
|
const parentThemeInfo = resolveThemeInfo(app, themeObject.extends);
|
|
948
918
|
return {
|
|
949
|
-
layouts: { ...parentThemeInfo.layouts, ...themeInfo.layouts },
|
|
950
919
|
plugins: [...parentThemeInfo.plugins, ...themeInfo.plugins],
|
|
951
920
|
templateBuild: themeObject.templateBuild ?? parentThemeInfo.templateBuild,
|
|
952
921
|
templateDev: themeObject.templateDev ?? parentThemeInfo.templateDev
|
|
@@ -956,7 +925,6 @@ var resolveThemeInfo = (app, theme) => {
|
|
|
956
925
|
// src/app/setupAppThemeAndPlugins.ts
|
|
957
926
|
var setupAppThemeAndPlugins = (app, config) => {
|
|
958
927
|
const themeInfo = resolveThemeInfo(app, app.options.theme);
|
|
959
|
-
app.layouts = themeInfo.layouts;
|
|
960
928
|
app.options.templateDev = config.templateDev ?? themeInfo.templateDev ?? app.options.templateDev;
|
|
961
929
|
app.options.templateBuild = config.templateBuild ?? themeInfo.templateBuild ?? app.options.templateBuild;
|
|
962
930
|
[...themeInfo.plugins, ...app.options.plugins].flat().forEach((plugin) => app.use(plugin));
|
|
@@ -1017,7 +985,6 @@ export {
|
|
|
1017
985
|
normalizeAliasDefineHook,
|
|
1018
986
|
normalizeClientConfigFileHook,
|
|
1019
987
|
prepareClientConfigs,
|
|
1020
|
-
prepareLayoutComponents,
|
|
1021
988
|
preparePageComponent,
|
|
1022
989
|
preparePageData,
|
|
1023
990
|
preparePagesComponents,
|
|
@@ -1045,6 +1012,5 @@ export {
|
|
|
1045
1012
|
resolvePageRouteMeta,
|
|
1046
1013
|
resolvePageSlug,
|
|
1047
1014
|
resolvePluginObject,
|
|
1048
|
-
resolveThemeInfo
|
|
1049
|
-
resolveThemeLayouts
|
|
1015
|
+
resolveThemeInfo
|
|
1050
1016
|
};
|
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.52",
|
|
4
4
|
"description": "Core package of VuePress",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"vuepress",
|
|
@@ -27,11 +27,11 @@
|
|
|
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.
|
|
34
|
-
"vue": "^3.2.
|
|
30
|
+
"@vuepress/client": "2.0.0-beta.52",
|
|
31
|
+
"@vuepress/markdown": "2.0.0-beta.52",
|
|
32
|
+
"@vuepress/shared": "2.0.0-beta.52",
|
|
33
|
+
"@vuepress/utils": "2.0.0-beta.52",
|
|
34
|
+
"vue": "^3.2.41"
|
|
35
35
|
},
|
|
36
36
|
"publishConfig": {
|
|
37
37
|
"access": "public"
|