@primate/vue 0.7.0 → 0.10.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/LICENSE +19 -0
- package/package.json +26 -7
- package/src/private/build/index.js +18 -0
- package/src/private/build/server.js +6 -0
- package/src/private/extension.js +1 -0
- package/src/private/name.js +1 -0
- package/src/private/pkgname.js +1 -0
- package/src/private/serve/handler.js +11 -0
- package/src/private/serve/index.js +7 -0
- package/src/private/serve/render.js +1 -0
- package/src/public/default.js +10 -0
- package/src/public/runtime.js +8 -0
- package/README.md +0 -6
- package/src/exports.js +0 -1
- package/src/module.js +0 -43
package/LICENSE
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
Copyright (c) Terrablue <terrablue@proton.me> and contributors.
|
|
2
|
+
|
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
4
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
5
|
+
in the Software without restriction, including without limitation the rights
|
|
6
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
7
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
8
|
+
furnished to do so, subject to the following conditions:
|
|
9
|
+
|
|
10
|
+
The above copyright notice and this permission notice shall be included in
|
|
11
|
+
all copies or substantial portions of the Software.
|
|
12
|
+
|
|
13
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
14
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
15
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
|
16
|
+
THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
17
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
18
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
19
|
+
THE SOFTWARE.
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@primate/vue",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"description": "Primate Vue
|
|
3
|
+
"version": "0.10.0",
|
|
4
|
+
"description": "Primate Vue frontend",
|
|
5
5
|
"homepage": "https://primatejs.com/modules/vue",
|
|
6
6
|
"bugs": "https://github.com/primatejs/primate/issues",
|
|
7
7
|
"license": "MIT",
|
|
@@ -15,12 +15,31 @@
|
|
|
15
15
|
"directory": "packages/vue"
|
|
16
16
|
},
|
|
17
17
|
"dependencies": {
|
|
18
|
-
"
|
|
19
|
-
"vue": "^3.3.4"
|
|
18
|
+
"@primate/frontend": "^0.16.0"
|
|
20
19
|
},
|
|
21
20
|
"peerDependencies": {
|
|
22
|
-
"
|
|
21
|
+
"vue": "3",
|
|
22
|
+
"primate": "^0.32.0"
|
|
23
23
|
},
|
|
24
24
|
"type": "module",
|
|
25
|
-
"
|
|
26
|
-
|
|
25
|
+
"imports": {
|
|
26
|
+
"#*": {
|
|
27
|
+
"@primate/lt": "./src/private/*.js",
|
|
28
|
+
"default": "./src/private/*.js"
|
|
29
|
+
},
|
|
30
|
+
"#build": {
|
|
31
|
+
"@primate/lt": "./src/private/build/index.js",
|
|
32
|
+
"default": "./src/private/build/index.js"
|
|
33
|
+
},
|
|
34
|
+
"#serve": {
|
|
35
|
+
"@primate/lt": "./src/private/serve/index.js",
|
|
36
|
+
"default": "./src/private/serve/index.js"
|
|
37
|
+
}
|
|
38
|
+
},
|
|
39
|
+
"exports": {
|
|
40
|
+
".": {
|
|
41
|
+
"runtime": "./src/public/runtime.js",
|
|
42
|
+
"default": "./src/public/default.js"
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import name from "#name";
|
|
2
|
+
import compile from "@primate/frontend/core/compile";
|
|
3
|
+
import server from "./server.js";
|
|
4
|
+
|
|
5
|
+
export default extension => async (app, next) => {
|
|
6
|
+
app.register(extension, {
|
|
7
|
+
...await compile({
|
|
8
|
+
app,
|
|
9
|
+
extension,
|
|
10
|
+
name,
|
|
11
|
+
compile: { server },
|
|
12
|
+
}),
|
|
13
|
+
// no support for hydration
|
|
14
|
+
client: _ => _,
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
return next(app);
|
|
18
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export default ".vue";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export default "vue";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export default "@primate/vue";
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { createSSRApp } from "vue";
|
|
2
|
+
import render from "./render.js";
|
|
3
|
+
|
|
4
|
+
export default (name, props = {}, options = {}) => async app => {
|
|
5
|
+
const component = createSSRApp({
|
|
6
|
+
render: (await app.get_component(name)).render,
|
|
7
|
+
data: () => props,
|
|
8
|
+
});
|
|
9
|
+
|
|
10
|
+
return app.view({ body: await render(component), ...options });
|
|
11
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { renderToString as default } from "vue/server-renderer";
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import build from "#build";
|
|
2
|
+
import default_extension from "#extension";
|
|
3
|
+
import pkgname from "#name";
|
|
4
|
+
import serve from "#serve";
|
|
5
|
+
|
|
6
|
+
export default ({ extension = default_extension } = {}) => ({
|
|
7
|
+
name: pkgname,
|
|
8
|
+
build: build(extension),
|
|
9
|
+
serve: serve(extension),
|
|
10
|
+
});
|
package/README.md
DELETED
package/src/exports.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {default} from "./module.js";
|
package/src/module.js
DELETED
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
import {Response, Status, MediaType} from "runtime-compat/http";
|
|
2
|
-
import {createSSRApp} from "vue";
|
|
3
|
-
import {renderToString} from "vue/server-renderer";
|
|
4
|
-
import {parse} from "vue/compiler-sfc";
|
|
5
|
-
|
|
6
|
-
const render = (template, props) => {
|
|
7
|
-
const app = createSSRApp({data: () => props, template});
|
|
8
|
-
return renderToString(app);
|
|
9
|
-
};
|
|
10
|
-
|
|
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`);
|
|
14
|
-
const body = await render(await target.text(), props);
|
|
15
|
-
|
|
16
|
-
return new Response(await app.render({body}), {
|
|
17
|
-
status,
|
|
18
|
-
headers: {...app.headers(), "Content-Type": MediaType.TEXT_HTML},
|
|
19
|
-
});
|
|
20
|
-
};
|
|
21
|
-
|
|
22
|
-
export default _ => ({
|
|
23
|
-
name: "@primate/vue",
|
|
24
|
-
register(app, next) {
|
|
25
|
-
app.register("vue", handler);
|
|
26
|
-
return next(app);
|
|
27
|
-
},
|
|
28
|
-
async compile(app, next) {
|
|
29
|
-
const source = app.build.paths.components;
|
|
30
|
-
const target = app.build.paths.server.join(app.config.build.app);
|
|
31
|
-
await target.file.create();
|
|
32
|
-
const vue = ".vue";
|
|
33
|
-
const components = await source.list(filename => filename.endsWith(vue));
|
|
34
|
-
await Promise.all(components.map(async component => {
|
|
35
|
-
const file = await component.file.read();
|
|
36
|
-
const {descriptor} = parse(file);
|
|
37
|
-
const to = target.join(`${component.path}.js`.replace(source, ""));
|
|
38
|
-
await to.file.write(descriptor.template.content);
|
|
39
|
-
}));
|
|
40
|
-
|
|
41
|
-
return next(app);
|
|
42
|
-
},
|
|
43
|
-
});
|