@revojs/vue 0.1.39 → 0.1.41
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.mjs +1 -3
- package/dist/index.mjs +21 -9
- package/dist/module/app.ts +11 -3
- package/dist/module/routes/[...]/get.ts +2 -5
- package/package.json +4 -4
- package/src/types/pages.d.ts +3 -1
package/dist/client/index.mjs
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { $fetch, defineHook, getState, isClient, isServer, setState } from "revojs";
|
|
2
2
|
import { customRef, inject, isRef, onScopeDispose, ref, toValue, watch } from "vue";
|
|
3
|
-
|
|
4
3
|
//#region src/client/index.ts
|
|
5
4
|
function useScope() {
|
|
6
5
|
const scope = inject("REVOJS_SCOPE");
|
|
@@ -62,6 +61,5 @@ async function refreshAsync(scope, input) {
|
|
|
62
61
|
}
|
|
63
62
|
const isServerSideRendering = import.meta.SERVER_SIDE_RENDERING ?? globalThis?.import?.meta?.SERVER_SIDE_RENDERING;
|
|
64
63
|
const REFRESH_ASYNC_HOOK = defineHook("REFRESH_ASYNC_HOOK");
|
|
65
|
-
|
|
66
64
|
//#endregion
|
|
67
|
-
export { REFRESH_ASYNC_HOOK, isServerSideRendering, refreshAsync, useAsync, useFetch, useScope, useState };
|
|
65
|
+
export { REFRESH_ASYNC_HOOK, isServerSideRendering, refreshAsync, useAsync, useFetch, useScope, useState };
|
package/dist/index.mjs
CHANGED
|
@@ -1,17 +1,18 @@
|
|
|
1
1
|
import { addAlias, addRoutes, addTypes, useKit } from "revojs/kit";
|
|
2
|
-
|
|
3
2
|
//#region src/index.ts
|
|
4
3
|
function addPages(app, path) {
|
|
5
4
|
app.config.sources.pages?.entries.push(path);
|
|
6
5
|
}
|
|
7
6
|
function vue(options) {
|
|
8
7
|
return {
|
|
9
|
-
config
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
8
|
+
config() {
|
|
9
|
+
return {
|
|
10
|
+
variables: { SERVER_SIDE_RENDERING: options?.serverSideRendering ?? true },
|
|
11
|
+
sources: { pages: {
|
|
12
|
+
match: "**/{page,layout}.vue",
|
|
13
|
+
entries: ["./routes"]
|
|
14
|
+
} }
|
|
15
|
+
};
|
|
15
16
|
},
|
|
16
17
|
setup(app) {
|
|
17
18
|
const { fromModule } = useKit(import.meta.url);
|
|
@@ -19,6 +20,18 @@ function vue(options) {
|
|
|
19
20
|
tagName: "script",
|
|
20
21
|
attributes: { type: "module" },
|
|
21
22
|
children: [`import "${fromModule("./module/entry.ts")}"`]
|
|
23
|
+
}, {
|
|
24
|
+
tagName: "script",
|
|
25
|
+
attributes: {
|
|
26
|
+
id: "states",
|
|
27
|
+
type: "application/json"
|
|
28
|
+
},
|
|
29
|
+
children: ["<!-- STATES -->"]
|
|
30
|
+
});
|
|
31
|
+
app.config.template.body.children.push({
|
|
32
|
+
tagName: "div",
|
|
33
|
+
attributes: { id: "app" },
|
|
34
|
+
children: ["<!-- APP -->"]
|
|
22
35
|
});
|
|
23
36
|
addRoutes(app, fromModule("./module/routes"));
|
|
24
37
|
addAlias(app, "vue/app", fromModule("./module/app.ts"));
|
|
@@ -27,6 +40,5 @@ function vue(options) {
|
|
|
27
40
|
}
|
|
28
41
|
};
|
|
29
42
|
}
|
|
30
|
-
|
|
31
43
|
//#endregion
|
|
32
|
-
export { addPages, vue };
|
|
44
|
+
export { addPages, vue };
|
package/dist/module/app.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import Main from "#alias/vue/main";
|
|
2
|
-
import
|
|
2
|
+
import pages from "#pages";
|
|
3
3
|
import { isServer, Radix, Scope, useUrl, type Node } from "revojs";
|
|
4
4
|
import { createApp, createSSRApp, type Component } from "vue";
|
|
5
5
|
import {
|
|
@@ -25,6 +25,14 @@ function toRoute(path: string, node: Node<Component>, index: number): RouteRecor
|
|
|
25
25
|
children.push({ path: "", component: node.value });
|
|
26
26
|
}
|
|
27
27
|
|
|
28
|
+
if (node.type === "WILDCARD") {
|
|
29
|
+
path = ":" + node.parameter + "(.*)*";
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
if (node.type === "OPTIONAL-WILDCARD") {
|
|
33
|
+
path = ":" + node.parameter + "(.*)?";
|
|
34
|
+
}
|
|
35
|
+
|
|
28
36
|
if (node.type === "OPTIONAL-PARAMETER") {
|
|
29
37
|
path = ":" + node.parameter + "?";
|
|
30
38
|
}
|
|
@@ -45,7 +53,7 @@ function toRoute(path: string, node: Node<Component>, index: number): RouteRecor
|
|
|
45
53
|
export default async (scope: Scope) => {
|
|
46
54
|
const radix = new Radix<Component>();
|
|
47
55
|
|
|
48
|
-
for (const path in
|
|
56
|
+
for (const path in pages) {
|
|
49
57
|
const segments = path.split("/");
|
|
50
58
|
|
|
51
59
|
for (const attribute of segments.pop()?.split(".") ?? []) {
|
|
@@ -56,7 +64,7 @@ export default async (scope: Scope) => {
|
|
|
56
64
|
segments.push(attribute);
|
|
57
65
|
}
|
|
58
66
|
|
|
59
|
-
radix.use(segments,
|
|
67
|
+
radix.use(segments, pages[path]);
|
|
60
68
|
}
|
|
61
69
|
|
|
62
70
|
const rootNode = toRoute("/", radix.rootNode, 0);
|
|
@@ -16,7 +16,7 @@ export default defineRoute({
|
|
|
16
16
|
let exception;
|
|
17
17
|
app.config.errorHandler = (value) => (exception = value);
|
|
18
18
|
|
|
19
|
-
content = content.replace("<!--
|
|
19
|
+
content = content.replace("<!-- APP -->", await renderToString(app));
|
|
20
20
|
|
|
21
21
|
if (exception) {
|
|
22
22
|
throw exception;
|
|
@@ -30,9 +30,6 @@ export default defineRoute({
|
|
|
30
30
|
.replace(/\u2028/g, "\\u2028")
|
|
31
31
|
.replace(/\u2029/g, "\\u2029");
|
|
32
32
|
|
|
33
|
-
return sendHtml(
|
|
34
|
-
scope,
|
|
35
|
-
content.replace("<!-- HEAD -->", "<script id='STATES' type='application/json'>" + value + "</script>"),
|
|
36
|
-
);
|
|
33
|
+
return sendHtml(scope, content.replace(`<!-- STATES -->`, value));
|
|
37
34
|
},
|
|
38
35
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@revojs/vue",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.41",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"repository": "tellua/revojs",
|
|
6
6
|
"files": [
|
|
@@ -30,11 +30,11 @@
|
|
|
30
30
|
},
|
|
31
31
|
"dependencies": {
|
|
32
32
|
"revojs": "*",
|
|
33
|
-
"vue": "^3.5.
|
|
34
|
-
"vue-router": "^5.0.
|
|
33
|
+
"vue": "^3.5.30",
|
|
34
|
+
"vue-router": "^5.0.3"
|
|
35
35
|
},
|
|
36
36
|
"devDependencies": {
|
|
37
37
|
"@revojs/tsconfig": "*",
|
|
38
|
-
"tsdown": "^0.
|
|
38
|
+
"tsdown": "^0.21.2"
|
|
39
39
|
}
|
|
40
40
|
}
|