@revojs/vue 0.1.3 → 0.1.4
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/client/index.d.ts +6 -0
- package/dist/client/index.js +11 -0
- package/dist/index.js +1 -0
- package/dist/module/app.ts +11 -3
- package/dist/module/index.html +2 -1
- package/dist/module/main.vue +8 -1
- package/dist/module/routes/[...]/index.get.ts +1 -1
- package/package.json +5 -1
- package/src/types/index.d.ts +1 -1
package/dist/index.js
CHANGED
package/dist/module/app.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { isServer, Radix, toRoutePath,
|
|
1
|
+
import { isServer, Radix, Scope, toRoutePath, useUrl, type Node } from "revojs";
|
|
2
2
|
import { type Component, createSSRApp } from "vue";
|
|
3
3
|
import { createMemoryHistory, createRouter, createWebHistory, RouterView, type RouteRecordRaw } from "vue-router";
|
|
4
4
|
import Main from "#alias/vue/main";
|
|
@@ -30,7 +30,7 @@ function toRoute(path: string, node: Node<Component>): RouteRecordRaw {
|
|
|
30
30
|
return route;
|
|
31
31
|
}
|
|
32
32
|
|
|
33
|
-
export default () => {
|
|
33
|
+
export default async (scope: Scope) => {
|
|
34
34
|
const radix = new Radix<Component>();
|
|
35
35
|
|
|
36
36
|
for (const name in pages) {
|
|
@@ -47,5 +47,13 @@ export default () => {
|
|
|
47
47
|
routes: Object.entries(radix.rootNode.children).map(([path, node]) => toRoute(path, node)),
|
|
48
48
|
});
|
|
49
49
|
|
|
50
|
-
|
|
50
|
+
if (isServer()) {
|
|
51
|
+
const { pathname } = useUrl(scope);
|
|
52
|
+
|
|
53
|
+
await router.push(pathname);
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
await router.isReady();
|
|
57
|
+
|
|
58
|
+
return createSSRApp(Main).use(router).provide("REVOJS_SCOPE", scope);
|
|
51
59
|
};
|
package/dist/module/index.html
CHANGED
|
@@ -8,9 +8,10 @@
|
|
|
8
8
|
<body>
|
|
9
9
|
<div id="app"><!-- MAIN --></div>
|
|
10
10
|
<script type="module">
|
|
11
|
+
import { Scope } from "revojs";
|
|
11
12
|
import createApp from "#alias/vue/app";
|
|
12
13
|
|
|
13
|
-
createApp().mount("#app");
|
|
14
|
+
await createApp(new Scope()).then((app) => app.mount("#app"));
|
|
14
15
|
</script>
|
|
15
16
|
</body>
|
|
16
17
|
</html>
|
package/dist/module/main.vue
CHANGED
|
@@ -5,6 +5,6 @@ import client from "#virtual/client";
|
|
|
5
5
|
|
|
6
6
|
export default defineRoute({
|
|
7
7
|
async fetch(scope) {
|
|
8
|
-
return sendHtml(scope, client.replace("<!-- MAIN -->", await renderToString(createApp())));
|
|
8
|
+
return sendHtml(scope, client.replace("<!-- MAIN -->", await renderToString(await createApp(scope))));
|
|
9
9
|
},
|
|
10
10
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@revojs/vue",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.4",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"repository": "coverbase/revojs",
|
|
6
6
|
"license": "MIT",
|
|
@@ -9,6 +9,10 @@
|
|
|
9
9
|
"types": "./dist/index.d.ts",
|
|
10
10
|
"import": "./dist/index.js"
|
|
11
11
|
},
|
|
12
|
+
"./client": {
|
|
13
|
+
"types": "./dist/client/index.d.ts",
|
|
14
|
+
"import": "./dist/client/index.js"
|
|
15
|
+
},
|
|
12
16
|
"./types": {
|
|
13
17
|
"types": "./src/types/index.d.ts"
|
|
14
18
|
}
|