@vuepress/bundlerutils 2.0.0-rc.26 → 2.0.0-rc.28
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 +26 -18
- package/dist/index.js +39 -38
- package/package.json +25 -31
package/dist/index.d.ts
CHANGED
|
@@ -1,34 +1,42 @@
|
|
|
1
|
-
import { App } from
|
|
2
|
-
import { Router } from
|
|
3
|
-
import { App as App$1, Page } from
|
|
4
|
-
import { VuepressSSRContext } from
|
|
5
|
-
import { SSRContext } from
|
|
1
|
+
import { App } from "vue";
|
|
2
|
+
import { Router } from "vue-router";
|
|
3
|
+
import { App as App$1, Page } from "@vuepress/core";
|
|
4
|
+
import { VuepressSSRContext } from "@vuepress/shared";
|
|
5
|
+
import { SSRContext } from "vue/server-renderer";
|
|
6
6
|
|
|
7
|
+
//#region src/build/createVueServerApp.d.ts
|
|
7
8
|
/**
|
|
8
9
|
* Create vue app and router for server side rendering
|
|
9
10
|
*/
|
|
10
11
|
declare const createVueServerApp: (serverAppPath: string) => Promise<{
|
|
11
|
-
|
|
12
|
-
|
|
12
|
+
vueApp: App;
|
|
13
|
+
vueRouter: Router;
|
|
13
14
|
}>;
|
|
14
|
-
|
|
15
|
+
//#endregion
|
|
16
|
+
//#region src/build/getSsrTemplate.d.ts
|
|
15
17
|
/**
|
|
16
18
|
* Util to read the ssr template file
|
|
17
19
|
*/
|
|
18
20
|
declare const getSsrTemplate: (app: App$1) => Promise<string>;
|
|
19
|
-
|
|
21
|
+
//#endregion
|
|
22
|
+
//#region src/build/renderPageToString.d.ts
|
|
20
23
|
type PageSSRContext = SSRContext & VuepressSSRContext;
|
|
21
24
|
/**
|
|
22
25
|
* Render a vuepress page to string
|
|
23
26
|
*/
|
|
24
|
-
declare const renderPageToString: <T extends PageSSRContext = PageSSRContext>({
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
27
|
+
declare const renderPageToString: <T extends PageSSRContext = PageSSRContext>({
|
|
28
|
+
page,
|
|
29
|
+
vueApp,
|
|
30
|
+
vueRouter,
|
|
31
|
+
ssrContextInit
|
|
32
|
+
}: {
|
|
33
|
+
page: Page;
|
|
34
|
+
vueApp: App;
|
|
35
|
+
vueRouter: Router;
|
|
36
|
+
ssrContextInit?: Partial<T>;
|
|
29
37
|
}) => Promise<{
|
|
30
|
-
|
|
31
|
-
|
|
38
|
+
ssrContext: T;
|
|
39
|
+
ssrString: string;
|
|
32
40
|
}>;
|
|
33
|
-
|
|
34
|
-
export {
|
|
41
|
+
//#endregion
|
|
42
|
+
export { PageSSRContext, createVueServerApp, getSsrTemplate, renderPageToString };
|
package/dist/index.js
CHANGED
|
@@ -1,41 +1,42 @@
|
|
|
1
|
-
|
|
2
|
-
import { importFile, importFileDefault } from "@vuepress/utils";
|
|
3
|
-
var createVueServerApp = async (serverAppPath) => {
|
|
4
|
-
const importer = serverAppPath.endsWith(".cjs") ? importFileDefault : importFile;
|
|
5
|
-
const { createVueApp } = await importer(serverAppPath);
|
|
6
|
-
const { app, router } = await createVueApp();
|
|
7
|
-
return { vueApp: app, vueRouter: router };
|
|
8
|
-
};
|
|
9
|
-
|
|
10
|
-
// src/build/getSsrTemplate.ts
|
|
11
|
-
import { fs } from "@vuepress/utils";
|
|
12
|
-
var getSsrTemplate = async (app) => fs.readFile(app.options.templateBuild, { encoding: "utf8" });
|
|
13
|
-
|
|
14
|
-
// src/build/renderPageToString.ts
|
|
1
|
+
import { fs, importFile, importFileDefault } from "@vuepress/utils";
|
|
15
2
|
import { ssrContextKey } from "vue";
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
})
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
head: [],
|
|
28
|
-
...ssrContextInit
|
|
29
|
-
};
|
|
30
|
-
const { renderToString } = await import("vue/server-renderer");
|
|
31
|
-
const ssrString = await renderToString(vueApp, ssrContext);
|
|
32
|
-
return {
|
|
33
|
-
ssrContext,
|
|
34
|
-
ssrString
|
|
35
|
-
};
|
|
3
|
+
//#region src/build/createVueServerApp.ts
|
|
4
|
+
/**
|
|
5
|
+
* Create vue app and router for server side rendering
|
|
6
|
+
*/
|
|
7
|
+
const createVueServerApp = async (serverAppPath) => {
|
|
8
|
+
const { createVueApp } = await (serverAppPath.endsWith(".cjs") ? importFileDefault : importFile)(serverAppPath);
|
|
9
|
+
const { app, router } = await createVueApp();
|
|
10
|
+
return {
|
|
11
|
+
vueApp: app,
|
|
12
|
+
vueRouter: router
|
|
13
|
+
};
|
|
36
14
|
};
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
15
|
+
//#endregion
|
|
16
|
+
//#region src/build/getSsrTemplate.ts
|
|
17
|
+
/**
|
|
18
|
+
* Util to read the ssr template file
|
|
19
|
+
*/
|
|
20
|
+
const getSsrTemplate = async (app) => fs.readFile(app.options.templateBuild, { encoding: "utf8" });
|
|
21
|
+
//#endregion
|
|
22
|
+
//#region src/build/renderPageToString.ts
|
|
23
|
+
/**
|
|
24
|
+
* Render a vuepress page to string
|
|
25
|
+
*/
|
|
26
|
+
const renderPageToString = async ({ page, vueApp, vueRouter, ssrContextInit }) => {
|
|
27
|
+
await vueRouter.push(page.path);
|
|
28
|
+
await vueRouter.isReady();
|
|
29
|
+
delete vueApp._context.provides[ssrContextKey];
|
|
30
|
+
const ssrContext = {
|
|
31
|
+
lang: "en",
|
|
32
|
+
head: [],
|
|
33
|
+
...ssrContextInit
|
|
34
|
+
};
|
|
35
|
+
const { renderToString } = await import("vue/server-renderer");
|
|
36
|
+
return {
|
|
37
|
+
ssrContext,
|
|
38
|
+
ssrString: await renderToString(vueApp, ssrContext)
|
|
39
|
+
};
|
|
41
40
|
};
|
|
41
|
+
//#endregion
|
|
42
|
+
export { createVueServerApp, getSsrTemplate, renderPageToString };
|
package/package.json
CHANGED
|
@@ -1,60 +1,54 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vuepress/bundlerutils",
|
|
3
|
-
"version": "2.0.0-rc.
|
|
3
|
+
"version": "2.0.0-rc.28",
|
|
4
4
|
"description": "Utils package of VuePress bundler",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"bundler",
|
|
7
|
-
"
|
|
8
|
-
"
|
|
7
|
+
"utils",
|
|
8
|
+
"vuepress"
|
|
9
9
|
],
|
|
10
10
|
"homepage": "https://github.com/vuepress",
|
|
11
11
|
"bugs": {
|
|
12
12
|
"url": "https://github.com/vuepress/core/issues"
|
|
13
13
|
},
|
|
14
|
+
"license": "MIT",
|
|
15
|
+
"author": "meteorlxy",
|
|
14
16
|
"repository": {
|
|
15
17
|
"type": "git",
|
|
16
18
|
"url": "git+https://github.com/vuepress/core.git"
|
|
17
19
|
},
|
|
18
|
-
"
|
|
19
|
-
|
|
20
|
+
"files": [
|
|
21
|
+
"dist"
|
|
22
|
+
],
|
|
20
23
|
"type": "module",
|
|
21
|
-
"exports": {
|
|
22
|
-
".": "./dist/index.js",
|
|
23
|
-
"./package.json": "./package.json"
|
|
24
|
-
},
|
|
25
24
|
"main": "./dist/index.js",
|
|
26
25
|
"module": "./dist/index.js",
|
|
27
26
|
"types": "./dist/index.d.ts",
|
|
28
|
-
"
|
|
29
|
-
"dist"
|
|
30
|
-
|
|
31
|
-
"dependencies": {
|
|
32
|
-
"vue": "^3.5.22",
|
|
33
|
-
"vue-router": "^4.6.0",
|
|
34
|
-
"@vuepress/client": "2.0.0-rc.26",
|
|
35
|
-
"@vuepress/shared": "2.0.0-rc.26",
|
|
36
|
-
"@vuepress/core": "2.0.0-rc.26",
|
|
37
|
-
"@vuepress/utils": "2.0.0-rc.26"
|
|
27
|
+
"exports": {
|
|
28
|
+
".": "./dist/index.js",
|
|
29
|
+
"./package.json": "./package.json"
|
|
38
30
|
},
|
|
39
31
|
"publishConfig": {
|
|
40
32
|
"access": "public"
|
|
41
33
|
},
|
|
42
|
-
"
|
|
43
|
-
"
|
|
44
|
-
"
|
|
45
|
-
"
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
"
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
"
|
|
52
|
-
"
|
|
34
|
+
"dependencies": {
|
|
35
|
+
"vue": "^3.5.31",
|
|
36
|
+
"vue-router": "^5.0.4",
|
|
37
|
+
"@vuepress/client": "2.0.0-rc.28",
|
|
38
|
+
"@vuepress/shared": "2.0.0-rc.28",
|
|
39
|
+
"@vuepress/core": "2.0.0-rc.28",
|
|
40
|
+
"@vuepress/utils": "2.0.0-rc.28"
|
|
41
|
+
},
|
|
42
|
+
"tsdown": {
|
|
43
|
+
"dts": true,
|
|
44
|
+
"entry": "./src/index.ts",
|
|
45
|
+
"fixedExtension": false,
|
|
46
|
+
"format": "esm",
|
|
53
47
|
"target": "es2023",
|
|
54
48
|
"tsconfig": "../../tsconfig.dts.json"
|
|
55
49
|
},
|
|
56
50
|
"scripts": {
|
|
57
|
-
"build": "
|
|
51
|
+
"build": "tsdown",
|
|
58
52
|
"clean": "rimraf dist"
|
|
59
53
|
}
|
|
60
54
|
}
|