@primate/vue 0.6.0 → 0.7.0
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/package.json +3 -3
- package/src/module.js +11 -11
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@primate/vue",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.7.0",
|
|
4
4
|
"description": "Primate Vue module",
|
|
5
5
|
"homepage": "https://primatejs.com/modules/vue",
|
|
6
6
|
"bugs": "https://github.com/primatejs/primate/issues",
|
|
@@ -15,11 +15,11 @@
|
|
|
15
15
|
"directory": "packages/vue"
|
|
16
16
|
},
|
|
17
17
|
"dependencies": {
|
|
18
|
-
"runtime-compat": "^0.
|
|
18
|
+
"runtime-compat": "^0.24.1",
|
|
19
19
|
"vue": "^3.3.4"
|
|
20
20
|
},
|
|
21
21
|
"peerDependencies": {
|
|
22
|
-
"primate": "0.
|
|
22
|
+
"primate": "0.21"
|
|
23
23
|
},
|
|
24
24
|
"type": "module",
|
|
25
25
|
"main": "./src/exports.js"
|
package/src/module.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import {Response, Status, MediaType} from "runtime-compat/http";
|
|
1
2
|
import {createSSRApp} from "vue";
|
|
2
3
|
import {renderToString} from "vue/server-renderer";
|
|
3
4
|
import {parse} from "vue/compiler-sfc";
|
|
@@ -7,27 +8,26 @@ const render = (template, props) => {
|
|
|
7
8
|
return renderToString(app);
|
|
8
9
|
};
|
|
9
10
|
|
|
10
|
-
const handler =
|
|
11
|
-
const {
|
|
12
|
-
const target = paths.server.join(config.build.app).join(`${name}.js`);
|
|
11
|
+
const handler = (name, props = {}, {status = Status.OK} = {}) => async app => {
|
|
12
|
+
const {build, config} = app;
|
|
13
|
+
const target = build.paths.server.join(config.build.app).join(`${name}.js`);
|
|
13
14
|
const body = await render(await target.text(), props);
|
|
14
15
|
|
|
15
|
-
|
|
16
|
-
return [await app.render({body}), {
|
|
16
|
+
return new Response(await app.render({body}), {
|
|
17
17
|
status,
|
|
18
|
-
headers: {...app.headers(), "Content-Type":
|
|
19
|
-
}
|
|
18
|
+
headers: {...app.headers(), "Content-Type": MediaType.TEXT_HTML},
|
|
19
|
+
});
|
|
20
20
|
};
|
|
21
21
|
|
|
22
|
-
export default
|
|
22
|
+
export default _ => ({
|
|
23
23
|
name: "@primate/vue",
|
|
24
24
|
register(app, next) {
|
|
25
|
-
app.register("vue", handler
|
|
25
|
+
app.register("vue", handler);
|
|
26
26
|
return next(app);
|
|
27
27
|
},
|
|
28
28
|
async compile(app, next) {
|
|
29
|
-
const source =
|
|
30
|
-
const target = app.paths.server.join(app.config.build.app);
|
|
29
|
+
const source = app.build.paths.components;
|
|
30
|
+
const target = app.build.paths.server.join(app.config.build.app);
|
|
31
31
|
await target.file.create();
|
|
32
32
|
const vue = ".vue";
|
|
33
33
|
const components = await source.list(filename => filename.endsWith(vue));
|