@vuepress/bundlerutils 2.0.0-rc.16
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/LICENSE +21 -0
- package/README.md +12 -0
- package/dist/index.d.ts +34 -0
- package/dist/index.js +41 -0
- package/package.json +59 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
The MIT License (MIT)
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2018-present, VuePress Community
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
|
13
|
+
all copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
21
|
+
THE SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
# @vuepress/bundlerutils
|
|
2
|
+
|
|
3
|
+
[](https://www.npmjs.com/package/@vuepress/bundlerutils)
|
|
4
|
+
[](https://github.com/vuepress/core/blob/main/LICENSE)
|
|
5
|
+
|
|
6
|
+
## Documentation
|
|
7
|
+
|
|
8
|
+
https://vuepress.vuejs.org
|
|
9
|
+
|
|
10
|
+
## License
|
|
11
|
+
|
|
12
|
+
[MIT](https://github.com/vuepress/core/blob/main/LICENSE)
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
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
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Create vue app and router for server side rendering
|
|
9
|
+
*/
|
|
10
|
+
declare const createVueServerApp: (serverAppPath: string) => Promise<{
|
|
11
|
+
vueApp: App;
|
|
12
|
+
vueRouter: Router;
|
|
13
|
+
}>;
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Util to read the ssr template file
|
|
17
|
+
*/
|
|
18
|
+
declare const getSsrTemplate: (app: App$1) => Promise<string>;
|
|
19
|
+
|
|
20
|
+
type PageSSRContext = SSRContext & VuepressSSRContext;
|
|
21
|
+
/**
|
|
22
|
+
* Render a vuepress page to string
|
|
23
|
+
*/
|
|
24
|
+
declare const renderPageToString: <T extends PageSSRContext = PageSSRContext>({ page, vueApp, vueRouter, ssrContextInit, }: {
|
|
25
|
+
page: Page;
|
|
26
|
+
vueApp: App;
|
|
27
|
+
vueRouter: Router;
|
|
28
|
+
ssrContextInit?: Partial<T>;
|
|
29
|
+
}) => Promise<{
|
|
30
|
+
ssrContext: T;
|
|
31
|
+
ssrString: string;
|
|
32
|
+
}>;
|
|
33
|
+
|
|
34
|
+
export { type PageSSRContext, createVueServerApp, getSsrTemplate, renderPageToString };
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
// src/build/createVueServerApp.ts
|
|
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
|
|
15
|
+
import { ssrContextKey } from "vue";
|
|
16
|
+
var renderPageToString = async ({
|
|
17
|
+
page,
|
|
18
|
+
vueApp,
|
|
19
|
+
vueRouter,
|
|
20
|
+
ssrContextInit
|
|
21
|
+
}) => {
|
|
22
|
+
await vueRouter.push(page.path);
|
|
23
|
+
await vueRouter.isReady();
|
|
24
|
+
delete vueApp._context.provides[ssrContextKey];
|
|
25
|
+
const ssrContext = {
|
|
26
|
+
lang: "en",
|
|
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
|
+
};
|
|
36
|
+
};
|
|
37
|
+
export {
|
|
38
|
+
createVueServerApp,
|
|
39
|
+
getSsrTemplate,
|
|
40
|
+
renderPageToString
|
|
41
|
+
};
|
package/package.json
ADDED
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@vuepress/bundlerutils",
|
|
3
|
+
"version": "2.0.0-rc.16",
|
|
4
|
+
"description": "Utils package of VuePress bundler",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"bundler",
|
|
7
|
+
"vuepress",
|
|
8
|
+
"utils"
|
|
9
|
+
],
|
|
10
|
+
"homepage": "https://github.com/vuepress",
|
|
11
|
+
"bugs": {
|
|
12
|
+
"url": "https://github.com/vuepress/core/issues"
|
|
13
|
+
},
|
|
14
|
+
"repository": {
|
|
15
|
+
"type": "git",
|
|
16
|
+
"url": "git+https://github.com/vuepress/core.git"
|
|
17
|
+
},
|
|
18
|
+
"license": "MIT",
|
|
19
|
+
"author": "meteorlxy",
|
|
20
|
+
"type": "module",
|
|
21
|
+
"exports": {
|
|
22
|
+
".": "./dist/index.js",
|
|
23
|
+
"./package.json": "./package.json"
|
|
24
|
+
},
|
|
25
|
+
"main": "./dist/index.js",
|
|
26
|
+
"types": "./dist/index.d.ts",
|
|
27
|
+
"files": [
|
|
28
|
+
"dist"
|
|
29
|
+
],
|
|
30
|
+
"dependencies": {
|
|
31
|
+
"vue": "^3.5.10",
|
|
32
|
+
"vue-router": "^4.4.5",
|
|
33
|
+
"@vuepress/core": "2.0.0-rc.16",
|
|
34
|
+
"@vuepress/client": "2.0.0-rc.16",
|
|
35
|
+
"@vuepress/shared": "2.0.0-rc.16",
|
|
36
|
+
"@vuepress/utils": "2.0.0-rc.16"
|
|
37
|
+
},
|
|
38
|
+
"publishConfig": {
|
|
39
|
+
"access": "public"
|
|
40
|
+
},
|
|
41
|
+
"tsup": {
|
|
42
|
+
"clean": true,
|
|
43
|
+
"dts": "./src/index.ts",
|
|
44
|
+
"entry": [
|
|
45
|
+
"./src/index.ts"
|
|
46
|
+
],
|
|
47
|
+
"format": [
|
|
48
|
+
"esm"
|
|
49
|
+
],
|
|
50
|
+
"outDir": "./dist",
|
|
51
|
+
"sourcemap": false,
|
|
52
|
+
"target": "es2022",
|
|
53
|
+
"tsconfig": "../../tsconfig.dts.json"
|
|
54
|
+
},
|
|
55
|
+
"scripts": {
|
|
56
|
+
"build": "tsup",
|
|
57
|
+
"clean": "rimraf dist"
|
|
58
|
+
}
|
|
59
|
+
}
|