@vuepress/bundlerutils 2.0.0-rc.30 → 2.0.0-rc.31
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 +48 -14
- package/dist/index.js +50 -1
- package/package.json +8 -7
package/dist/index.d.ts
CHANGED
|
@@ -1,15 +1,31 @@
|
|
|
1
|
-
import { App } from "
|
|
2
|
-
import {
|
|
3
|
-
import { App as App$1, Page } from "@vuepress/core";
|
|
1
|
+
import { App, Page } from "@vuepress/core";
|
|
2
|
+
import { App as App$1 } from "vue";
|
|
4
3
|
import { VuepressSSRContext } from "@vuepress/shared";
|
|
4
|
+
import { Router } from "vue-router";
|
|
5
5
|
import { SSRContext } from "vue/server-renderer";
|
|
6
|
-
|
|
6
|
+
import { MarkdownLink } from "@vuepress/markdown";
|
|
7
|
+
//#region src/build/types.d.ts
|
|
8
|
+
/**
|
|
9
|
+
* Map from page route path to its chunk output file names.
|
|
10
|
+
* Used by prefetch/preload strategy.
|
|
11
|
+
*/
|
|
12
|
+
type PageChunkFilesMap = Map<string, string[]>;
|
|
13
|
+
//#endregion
|
|
14
|
+
//#region src/build/createPageChunkFilesMap.d.ts
|
|
15
|
+
/**
|
|
16
|
+
* Create a map from page route paths to their chunk output file names.
|
|
17
|
+
*/
|
|
18
|
+
declare const createPageChunkFilesMap: ({ pages, resolvePageChunkFiles }: {
|
|
19
|
+
pages: Page[];
|
|
20
|
+
resolvePageChunkFiles: (page: Page) => string[];
|
|
21
|
+
}) => PageChunkFilesMap;
|
|
22
|
+
//#endregion
|
|
7
23
|
//#region src/build/createVueServerApp.d.ts
|
|
8
24
|
/**
|
|
9
25
|
* Create vue app and router for server side rendering
|
|
10
26
|
*/
|
|
11
27
|
declare const createVueServerApp: (serverAppPath: string) => Promise<{
|
|
12
|
-
vueApp: App;
|
|
28
|
+
vueApp: App$1;
|
|
13
29
|
vueRouter: Router;
|
|
14
30
|
}>;
|
|
15
31
|
//#endregion
|
|
@@ -17,21 +33,16 @@ declare const createVueServerApp: (serverAppPath: string) => Promise<{
|
|
|
17
33
|
/**
|
|
18
34
|
* Util to read the ssr template file
|
|
19
35
|
*/
|
|
20
|
-
declare const getSsrTemplate: (app: App
|
|
36
|
+
declare const getSsrTemplate: (app: App) => Promise<string>;
|
|
21
37
|
//#endregion
|
|
22
38
|
//#region src/build/renderPageToString.d.ts
|
|
23
39
|
type PageSSRContext = SSRContext & VuepressSSRContext;
|
|
24
40
|
/**
|
|
25
41
|
* Render a vuepress page to string
|
|
26
42
|
*/
|
|
27
|
-
declare const renderPageToString: <T extends PageSSRContext = PageSSRContext>({
|
|
28
|
-
page,
|
|
29
|
-
vueApp,
|
|
30
|
-
vueRouter,
|
|
31
|
-
ssrContextInit
|
|
32
|
-
}: {
|
|
43
|
+
declare const renderPageToString: <T extends PageSSRContext = PageSSRContext>({ page, vueApp, vueRouter, ssrContextInit }: {
|
|
33
44
|
page: Page;
|
|
34
|
-
vueApp: App;
|
|
45
|
+
vueApp: App$1;
|
|
35
46
|
vueRouter: Router;
|
|
36
47
|
ssrContextInit?: Partial<T>;
|
|
37
48
|
}) => Promise<{
|
|
@@ -39,4 +50,27 @@ declare const renderPageToString: <T extends PageSSRContext = PageSSRContext>({
|
|
|
39
50
|
ssrString: string;
|
|
40
51
|
}>;
|
|
41
52
|
//#endregion
|
|
42
|
-
|
|
53
|
+
//#region src/build/resolveLinkRoutePath.d.ts
|
|
54
|
+
/**
|
|
55
|
+
* Normalize a MarkdownLink to a route path
|
|
56
|
+
* that can be matched against Page.path.
|
|
57
|
+
*
|
|
58
|
+
* Returns null if the link is unresolvable.
|
|
59
|
+
*/
|
|
60
|
+
declare const resolveLinkRoutePath: ({ base, current, link }: {
|
|
61
|
+
base: string;
|
|
62
|
+
current: string;
|
|
63
|
+
link: MarkdownLink;
|
|
64
|
+
}) => string | null;
|
|
65
|
+
//#endregion
|
|
66
|
+
//#region src/build/resolveLinkedPageChunkFiles.d.ts
|
|
67
|
+
/**
|
|
68
|
+
* Resolve the chunk output file names of pages linked from the current page.
|
|
69
|
+
*/
|
|
70
|
+
declare const resolveLinkedPageChunkFiles: ({ base, page, pageChunkFilesMap }: {
|
|
71
|
+
base: string;
|
|
72
|
+
page: Page;
|
|
73
|
+
pageChunkFilesMap: PageChunkFilesMap;
|
|
74
|
+
}) => Set<string>;
|
|
75
|
+
//#endregion
|
|
76
|
+
export { type PageChunkFilesMap, PageSSRContext, createPageChunkFilesMap, createVueServerApp, getSsrTemplate, renderPageToString, resolveLinkRoutePath, resolveLinkedPageChunkFiles };
|
package/dist/index.js
CHANGED
|
@@ -1,5 +1,22 @@
|
|
|
1
|
+
import { resolvePageRedirects } from "@vuepress/core";
|
|
1
2
|
import { fs, importFile, importFileDefault } from "@vuepress/utils";
|
|
2
3
|
import { ssrContextKey } from "vue";
|
|
4
|
+
import { inferRoutePath, normalizeRoutePath } from "@vuepress/shared";
|
|
5
|
+
//#region src/build/createPageChunkFilesMap.ts
|
|
6
|
+
/**
|
|
7
|
+
* Create a map from page route paths to their chunk output file names.
|
|
8
|
+
*/
|
|
9
|
+
const createPageChunkFilesMap = ({ pages, resolvePageChunkFiles }) => {
|
|
10
|
+
const pageChunkFilesMap = /* @__PURE__ */ new Map();
|
|
11
|
+
const pagePaths = new Set(pages.map((page) => page.path));
|
|
12
|
+
for (const page of pages) {
|
|
13
|
+
const pageChunkFiles = resolvePageChunkFiles(page);
|
|
14
|
+
pageChunkFilesMap.set(page.path, pageChunkFiles);
|
|
15
|
+
for (const redirect of resolvePageRedirects(page)) if (!pagePaths.has(redirect)) pageChunkFilesMap.set(redirect, pageChunkFiles);
|
|
16
|
+
}
|
|
17
|
+
return pageChunkFilesMap;
|
|
18
|
+
};
|
|
19
|
+
//#endregion
|
|
3
20
|
//#region src/build/createVueServerApp.ts
|
|
4
21
|
/**
|
|
5
22
|
* Create vue app and router for server side rendering
|
|
@@ -39,4 +56,36 @@ const renderPageToString = async ({ page, vueApp, vueRouter, ssrContextInit }) =
|
|
|
39
56
|
};
|
|
40
57
|
};
|
|
41
58
|
//#endregion
|
|
42
|
-
|
|
59
|
+
//#region src/build/resolveLinkRoutePath.ts
|
|
60
|
+
/**
|
|
61
|
+
* Normalize a MarkdownLink to a route path
|
|
62
|
+
* that can be matched against Page.path.
|
|
63
|
+
*
|
|
64
|
+
* Returns null if the link is unresolvable.
|
|
65
|
+
*/
|
|
66
|
+
const resolveLinkRoutePath = ({ base, current, link }) => {
|
|
67
|
+
if (!link.absolute) return link.relative ? normalizeRoutePath(link.relative, current) : null;
|
|
68
|
+
return inferRoutePath(link.absolute.startsWith(base) ? `/${link.absolute.slice(base.length)}` : link.absolute);
|
|
69
|
+
};
|
|
70
|
+
//#endregion
|
|
71
|
+
//#region src/build/resolveLinkedPageChunkFiles.ts
|
|
72
|
+
/**
|
|
73
|
+
* Resolve the chunk output file names of pages linked from the current page.
|
|
74
|
+
*/
|
|
75
|
+
const resolveLinkedPageChunkFiles = ({ base, page, pageChunkFilesMap }) => {
|
|
76
|
+
const linkedPageChunkFiles = /* @__PURE__ */ new Set();
|
|
77
|
+
for (const link of page.links) {
|
|
78
|
+
const routePath = resolveLinkRoutePath({
|
|
79
|
+
base,
|
|
80
|
+
current: page.path,
|
|
81
|
+
link
|
|
82
|
+
});
|
|
83
|
+
if (routePath) {
|
|
84
|
+
const targetChunks = pageChunkFilesMap.get(routePath);
|
|
85
|
+
if (targetChunks) for (const file of targetChunks) linkedPageChunkFiles.add(file);
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
return linkedPageChunkFiles;
|
|
89
|
+
};
|
|
90
|
+
//#endregion
|
|
91
|
+
export { createPageChunkFilesMap, createVueServerApp, getSsrTemplate, renderPageToString, resolveLinkRoutePath, resolveLinkedPageChunkFiles };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vuepress/bundlerutils",
|
|
3
|
-
"version": "2.0.0-rc.
|
|
3
|
+
"version": "2.0.0-rc.31",
|
|
4
4
|
"description": "Utils package of VuePress bundler",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"bundler",
|
|
@@ -32,12 +32,13 @@
|
|
|
32
32
|
"access": "public"
|
|
33
33
|
},
|
|
34
34
|
"dependencies": {
|
|
35
|
-
"vue": "^3.5.
|
|
36
|
-
"vue-router": "^5.0
|
|
37
|
-
"@vuepress/client": "2.0.0-rc.
|
|
38
|
-
"@vuepress/
|
|
39
|
-
"@vuepress/
|
|
40
|
-
"@vuepress/
|
|
35
|
+
"vue": "^3.5.40",
|
|
36
|
+
"vue-router": "^5.2.0",
|
|
37
|
+
"@vuepress/client": "2.0.0-rc.31",
|
|
38
|
+
"@vuepress/shared": "2.0.0-rc.31",
|
|
39
|
+
"@vuepress/core": "2.0.0-rc.31",
|
|
40
|
+
"@vuepress/markdown": "2.0.0-rc.31",
|
|
41
|
+
"@vuepress/utils": "2.0.0-rc.31"
|
|
41
42
|
},
|
|
42
43
|
"tsdown": {
|
|
43
44
|
"dts": true,
|