@revojs/vue 0.1.17 → 0.1.19
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
CHANGED
package/dist/client/index.js
CHANGED
package/dist/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import "
|
|
2
|
-
import
|
|
1
|
+
import { addAssets, addRoutes, useKit } from "revojs/vite";
|
|
2
|
+
import "revojs";
|
|
3
3
|
|
|
4
4
|
//#region src/index.ts
|
|
5
5
|
function addPages(app, path) {
|
|
@@ -8,7 +8,7 @@ function addPages(app, path) {
|
|
|
8
8
|
function vue() {
|
|
9
9
|
return {
|
|
10
10
|
config: { sources: { pages: {
|
|
11
|
-
match: "
|
|
11
|
+
match: "**/{page,layout}.vue",
|
|
12
12
|
entries: ["./routes"]
|
|
13
13
|
} } },
|
|
14
14
|
setup(app) {
|
package/dist/module/app.ts
CHANGED
|
@@ -5,10 +5,10 @@ import Main from "#alias/vue/main";
|
|
|
5
5
|
import pages from "#virtual/pages";
|
|
6
6
|
|
|
7
7
|
function toRoute(path: string, node: Node<Component>, index: number): RouteRecordRaw {
|
|
8
|
-
const layout = node.children["
|
|
8
|
+
const layout = node.children["LAYOUT"];
|
|
9
9
|
|
|
10
10
|
if (layout) {
|
|
11
|
-
delete node.children["
|
|
11
|
+
delete node.children["LAYOUT"];
|
|
12
12
|
}
|
|
13
13
|
|
|
14
14
|
const children = Object.entries(node.children).map(([path, node]) => toRoute(path, node, index + 1));
|
|
@@ -38,11 +38,11 @@ export default async (scope: Scope) => {
|
|
|
38
38
|
const radix = new Radix<Component>();
|
|
39
39
|
|
|
40
40
|
for (const name in pages) {
|
|
41
|
-
const [path] = toRoutePath(name);
|
|
41
|
+
const [path, target] = toRoutePath(name);
|
|
42
42
|
|
|
43
|
-
const
|
|
44
|
-
if (
|
|
45
|
-
radix.use(path,
|
|
43
|
+
const Component = pages[name];
|
|
44
|
+
if (Component) {
|
|
45
|
+
radix.use(target === "PAGE" ? path : path + "/" + target, Component);
|
|
46
46
|
}
|
|
47
47
|
}
|
|
48
48
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@revojs/vue",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.19",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"repository": "coverbase/revojs",
|
|
6
6
|
"license": "MIT",
|
|
@@ -29,9 +29,9 @@
|
|
|
29
29
|
"watch": "tsdown -w"
|
|
30
30
|
},
|
|
31
31
|
"dependencies": {
|
|
32
|
-
"@revojs/kit": "*",
|
|
33
32
|
"vue": "^3.5.19",
|
|
34
|
-
"vue-router": "^4.5.1"
|
|
33
|
+
"vue-router": "^4.5.1",
|
|
34
|
+
"revojs": "*"
|
|
35
35
|
},
|
|
36
36
|
"devDependencies": {
|
|
37
37
|
"@revojs/tsconfig": "*",
|
package/dist/dist-CID_dTbk.js
DELETED
|
@@ -1,110 +0,0 @@
|
|
|
1
|
-
//#region ../revojs/dist/index.js
|
|
2
|
-
function useServer(scope) {
|
|
3
|
-
return scope.getContext(SERVER_CONTEXT);
|
|
4
|
-
}
|
|
5
|
-
function getState(scope, name) {
|
|
6
|
-
if (import.meta.server) {
|
|
7
|
-
const { states } = useServer(scope);
|
|
8
|
-
return states[name];
|
|
9
|
-
} else {
|
|
10
|
-
if (STATES === void 0) {
|
|
11
|
-
const element = document.getElementById("STATES");
|
|
12
|
-
STATES = element?.textContent ? JSON.parse(element.textContent) : {};
|
|
13
|
-
}
|
|
14
|
-
return STATES[name];
|
|
15
|
-
}
|
|
16
|
-
}
|
|
17
|
-
function setState(scope, name, value) {
|
|
18
|
-
if (import.meta.server) {
|
|
19
|
-
const { states } = useServer(scope);
|
|
20
|
-
states[name] = value;
|
|
21
|
-
} else {
|
|
22
|
-
if (STATES === void 0) {
|
|
23
|
-
const element = document.getElementById("STATES");
|
|
24
|
-
STATES = element?.textContent ? JSON.parse(element.textContent) : {};
|
|
25
|
-
}
|
|
26
|
-
STATES[name] = value;
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
function sendRedirect(scope, path, config) {
|
|
30
|
-
const { response } = useServer(scope);
|
|
31
|
-
response.status = 302;
|
|
32
|
-
response.headers.set("Location", path);
|
|
33
|
-
return new Response(null, mergeObjects(response, config));
|
|
34
|
-
}
|
|
35
|
-
const ROUTER_CONTEXT = defineContext("ROUTER_CONTEXT");
|
|
36
|
-
const SERVER_CONTEXT = defineContext("SERVER_CONTEXT");
|
|
37
|
-
let STATES;
|
|
38
|
-
var StopEvent = class extends Event {
|
|
39
|
-
constructor() {
|
|
40
|
-
super("stop");
|
|
41
|
-
}
|
|
42
|
-
};
|
|
43
|
-
var Scope = class extends EventTarget {
|
|
44
|
-
parentScope;
|
|
45
|
-
context;
|
|
46
|
-
constructor(parentScope) {
|
|
47
|
-
super();
|
|
48
|
-
this.parentScope = parentScope;
|
|
49
|
-
this.parentScope?.onStop(() => this.stop());
|
|
50
|
-
this.context = {};
|
|
51
|
-
}
|
|
52
|
-
getContext(input) {
|
|
53
|
-
let scope = this;
|
|
54
|
-
while (scope) {
|
|
55
|
-
if (scope.context[input]) return scope.context[input];
|
|
56
|
-
scope = scope.parentScope;
|
|
57
|
-
}
|
|
58
|
-
return {};
|
|
59
|
-
}
|
|
60
|
-
setContext(input, value) {
|
|
61
|
-
this.context[input] = value;
|
|
62
|
-
}
|
|
63
|
-
onStop(input) {
|
|
64
|
-
this.addEventListener("stop", input, { once: true });
|
|
65
|
-
}
|
|
66
|
-
stop() {
|
|
67
|
-
return this.dispatchEvent(new StopEvent());
|
|
68
|
-
}
|
|
69
|
-
};
|
|
70
|
-
function defineContext(name) {
|
|
71
|
-
return name;
|
|
72
|
-
}
|
|
73
|
-
function mergeObjects(base, input) {
|
|
74
|
-
if (input === null || input === void 0) return mergeObjects(base, {});
|
|
75
|
-
const object = Object.assign({}, input);
|
|
76
|
-
for (const key in base) {
|
|
77
|
-
if (key === "__proto__" || key === "constructor") continue;
|
|
78
|
-
const value = base[key];
|
|
79
|
-
if (value === null || value === void 0) continue;
|
|
80
|
-
if (Array.isArray(value) && Array.isArray(object[key])) object[key] = [...value, ...object[key]];
|
|
81
|
-
else if (typeof value === "object" && typeof object[key] === "object") object[key] = mergeObjects(value, object[key]);
|
|
82
|
-
else object[key] = value;
|
|
83
|
-
}
|
|
84
|
-
return object;
|
|
85
|
-
}
|
|
86
|
-
async function $fetch(scope, input, options) {
|
|
87
|
-
let response;
|
|
88
|
-
if (import.meta.server) {
|
|
89
|
-
const { states, request, variables } = useServer(scope);
|
|
90
|
-
const next = new Scope();
|
|
91
|
-
const url = new URL(input.toString(), request.url);
|
|
92
|
-
next.setContext(SERVER_CONTEXT, {
|
|
93
|
-
states,
|
|
94
|
-
request: new Request(url, options),
|
|
95
|
-
response: { headers: new Headers() },
|
|
96
|
-
variables
|
|
97
|
-
});
|
|
98
|
-
const previous = new URL(request.url);
|
|
99
|
-
if (url.origin === previous.origin) response = await (await import("#virtual/server")).default.fetch(next);
|
|
100
|
-
}
|
|
101
|
-
response ??= await fetch(input, options);
|
|
102
|
-
if (response.ok === false) throw response;
|
|
103
|
-
switch (response.headers.get("Content-Type")?.split(";").shift() ?? "") {
|
|
104
|
-
case "application/json": return response.json();
|
|
105
|
-
default: return response;
|
|
106
|
-
}
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
//#endregion
|
|
110
|
-
export { $fetch, getState, sendRedirect, setState };
|
|
File without changes
|