@mauroandre/velojs 0.0.14 → 0.0.16
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/cli.js +18 -14
- package/dist/components.js +40 -32
- package/dist/hooks.js +37 -37
- package/dist/vite.js +36 -36
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -1,15 +1,19 @@
|
|
|
1
1
|
import { spawnSync as c } from "node:child_process";
|
|
2
2
|
import { resolve as a } from "node:path";
|
|
3
|
-
const
|
|
4
|
-
const
|
|
3
|
+
const o = process.argv.slice(2), r = o[0], l = (e, t = []) => {
|
|
4
|
+
const s = c(e, t, {
|
|
5
5
|
stdio: "inherit",
|
|
6
6
|
cwd: process.cwd()
|
|
7
7
|
});
|
|
8
|
-
process.exit(
|
|
8
|
+
process.exit(s.status ?? 0);
|
|
9
9
|
}, p = () => {
|
|
10
|
-
l("npx", ["vite", ...
|
|
11
|
-
},
|
|
12
|
-
const
|
|
10
|
+
l("npx", ["vite", ...o.slice(1)]);
|
|
11
|
+
}, u = (e) => {
|
|
12
|
+
const t = Date.now().toString(36), s = {
|
|
13
|
+
...process.env,
|
|
14
|
+
VELO_BUILD_HASH: t,
|
|
15
|
+
...e ? { VELO_STATIC: "1" } : {}
|
|
16
|
+
};
|
|
13
17
|
console.log("Building client..."), c("npx", ["vite", "build"], {
|
|
14
18
|
stdio: "inherit",
|
|
15
19
|
cwd: process.cwd(),
|
|
@@ -18,13 +22,13 @@ const t = process.argv.slice(2), r = t[0], l = (e, s = []) => {
|
|
|
18
22
|
stdio: "inherit",
|
|
19
23
|
cwd: process.cwd(),
|
|
20
24
|
env: s
|
|
21
|
-
}), console.log("Build complete!"), e &&
|
|
22
|
-
},
|
|
25
|
+
}), console.log("Build complete!"), e && v();
|
|
26
|
+
}, v = async () => {
|
|
23
27
|
process.env.NODE_ENV = "production", process.env.VELO_STATIC = "1";
|
|
24
|
-
const
|
|
25
|
-
(!
|
|
28
|
+
const t = await import(a(process.cwd(), "dist/server.js")), s = t.default, i = t.routes;
|
|
29
|
+
(!s || !i) && (console.error("Failed to load app or routes from dist/server.js"), process.exit(1));
|
|
26
30
|
const { generateStatic: d } = await import("./static.js");
|
|
27
|
-
await d(
|
|
31
|
+
await d(s, i);
|
|
28
32
|
}, m = () => {
|
|
29
33
|
process.env.NODE_ENV = "production";
|
|
30
34
|
const e = a(process.cwd(), "dist/server.js");
|
|
@@ -54,15 +58,15 @@ Examples:
|
|
|
54
58
|
switch (r) {
|
|
55
59
|
case "init": {
|
|
56
60
|
const { runInit: e } = await import("./init.js");
|
|
57
|
-
await e(
|
|
61
|
+
await e(o[1]);
|
|
58
62
|
break;
|
|
59
63
|
}
|
|
60
64
|
case "dev":
|
|
61
65
|
p();
|
|
62
66
|
break;
|
|
63
67
|
case "build": {
|
|
64
|
-
const e =
|
|
65
|
-
|
|
68
|
+
const e = o.includes("--static");
|
|
69
|
+
u(e);
|
|
66
70
|
break;
|
|
67
71
|
}
|
|
68
72
|
case "start":
|
package/dist/components.js
CHANGED
|
@@ -1,48 +1,56 @@
|
|
|
1
|
-
import { jsx as
|
|
2
|
-
import { Link as
|
|
3
|
-
import { __veloUpdatePending as
|
|
4
|
-
function
|
|
5
|
-
const
|
|
1
|
+
import { jsx as o, jsxs as p, Fragment as $ } from "preact/jsx-runtime";
|
|
2
|
+
import { useRouter as v, Link as E } from "wouter-preact";
|
|
3
|
+
import { __veloUpdatePending as y } from "./hooks.js";
|
|
4
|
+
function O({ basePath: e, favicon: t = "/favicon.ico" } = {}) {
|
|
5
|
+
const n = process.env.NODE_ENV !== "production";
|
|
6
6
|
e = e || process.env.STATIC_BASE_URL || (process.env.VELO_STATIC ? "/client" : "");
|
|
7
|
-
const i =
|
|
8
|
-
if (
|
|
9
|
-
return /* @__PURE__ */
|
|
7
|
+
const i = t !== !1 && /* @__PURE__ */ o("link", { rel: "icon", href: `${e}${t}`, type: "image/x-icon" });
|
|
8
|
+
if (n)
|
|
9
|
+
return /* @__PURE__ */ p($, { children: [
|
|
10
10
|
i,
|
|
11
|
-
/* @__PURE__ */
|
|
12
|
-
/* @__PURE__ */
|
|
11
|
+
/* @__PURE__ */ o("script", { type: "module", src: "/@vite/client" }),
|
|
12
|
+
/* @__PURE__ */ o("script", { type: "module", src: "/__velo_client.js" })
|
|
13
13
|
] });
|
|
14
|
-
const
|
|
15
|
-
return /* @__PURE__ */
|
|
14
|
+
const r = typeof __VELO_CLIENT_JS__ < "u" ? __VELO_CLIENT_JS__ : "client.js";
|
|
15
|
+
return /* @__PURE__ */ p($, { children: [
|
|
16
16
|
i,
|
|
17
|
-
/* @__PURE__ */
|
|
18
|
-
/* @__PURE__ */
|
|
17
|
+
/* @__PURE__ */ o("link", { rel: "stylesheet", href: `${e}/${typeof __VELO_CLIENT_CSS__ < "u" ? __VELO_CLIENT_CSS__ : "client.css"}` }),
|
|
18
|
+
/* @__PURE__ */ o("script", { type: "module", src: `${e}/${r}` })
|
|
19
19
|
] });
|
|
20
20
|
}
|
|
21
|
-
function
|
|
22
|
-
let
|
|
23
|
-
for (const [i,
|
|
24
|
-
|
|
25
|
-
return
|
|
21
|
+
function h(e, t) {
|
|
22
|
+
let n = e;
|
|
23
|
+
for (const [i, r] of Object.entries(t))
|
|
24
|
+
n = n.replace(`:${i}`, r);
|
|
25
|
+
return n;
|
|
26
26
|
}
|
|
27
|
-
function
|
|
28
|
-
const c = typeof e != "string", _ = c ? (i ? e.metadata?.fullPath : e.metadata?.path) ?? "/" : e,
|
|
29
|
-
if (typeof window < "u" &&
|
|
30
|
-
|
|
31
|
-
|
|
27
|
+
function j({ to: e, params: t, search: n, absolute: i, ...r }) {
|
|
28
|
+
const c = typeof e != "string", u = v(), _ = c ? (i ? e.metadata?.fullPath : e.metadata?.path) ?? "/" : e, l = t ? h(_, t) : _, L = c && i ? `~${l}` : l, a = n ? `?${new URLSearchParams(n).toString()}` : "", m = `${L}${a}`;
|
|
29
|
+
if (typeof window < "u" && y.value) {
|
|
30
|
+
let f;
|
|
31
|
+
if (c) {
|
|
32
|
+
const s = e.metadata?.fullPath ?? _;
|
|
33
|
+
f = `${t ? h(s, t) : s}${a}`;
|
|
34
|
+
} else {
|
|
35
|
+
const s = l.replace(/^~/, "");
|
|
36
|
+
f = `${!l.startsWith("~") && u.base ? u.base : ""}${s}${a}`;
|
|
37
|
+
}
|
|
38
|
+
const { onClick: d, ...S } = r;
|
|
39
|
+
return /* @__PURE__ */ o(
|
|
32
40
|
"a",
|
|
33
41
|
{
|
|
34
|
-
href:
|
|
35
|
-
onClick: (
|
|
36
|
-
|
|
42
|
+
href: f,
|
|
43
|
+
onClick: (s) => {
|
|
44
|
+
d && d(s), s.defaultPrevented || (s.preventDefault(), window.location.href = f);
|
|
37
45
|
},
|
|
38
|
-
...
|
|
46
|
+
...S
|
|
39
47
|
}
|
|
40
48
|
);
|
|
41
49
|
}
|
|
42
|
-
return /* @__PURE__ */
|
|
50
|
+
return /* @__PURE__ */ o(E, { to: m, ...r });
|
|
43
51
|
}
|
|
44
52
|
export {
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
53
|
+
j as Link,
|
|
54
|
+
O as Scripts,
|
|
55
|
+
h as substituteParams
|
|
48
56
|
};
|
package/dist/hooks.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import { signal as
|
|
2
|
-
import { useRef as
|
|
3
|
-
import { useLocation as
|
|
4
|
-
const
|
|
5
|
-
function
|
|
1
|
+
import { signal as _, useSignal as d } from "@preact/signals";
|
|
2
|
+
import { useRef as g, useEffect as h } from "preact/hooks";
|
|
3
|
+
import { useLocation as v, useParams as D } from "wouter-preact";
|
|
4
|
+
const p = _(!1);
|
|
5
|
+
function m(e) {
|
|
6
6
|
e.value !== null && typeof e.value == "object" && (e.value = { ...e.value });
|
|
7
7
|
}
|
|
8
|
-
function
|
|
9
|
-
const a =
|
|
8
|
+
function P(e) {
|
|
9
|
+
const a = _(!1);
|
|
10
10
|
if (typeof window > "u")
|
|
11
11
|
return { data: {
|
|
12
12
|
get value() {
|
|
@@ -14,50 +14,50 @@ function T(e) {
|
|
|
14
14
|
}
|
|
15
15
|
}, loading: a };
|
|
16
16
|
const t = window.__PAGE_DATA__, n = e && t?.[e] ? t[e] : null;
|
|
17
|
-
return { data:
|
|
17
|
+
return { data: _(n), loading: a };
|
|
18
18
|
}
|
|
19
|
-
function
|
|
19
|
+
function T(e, a) {
|
|
20
20
|
let t, n;
|
|
21
21
|
Array.isArray(e) ? n = e : (t = e, n = a);
|
|
22
22
|
let r = null;
|
|
23
23
|
if (typeof window > "u" && t) {
|
|
24
|
-
const
|
|
25
|
-
|
|
24
|
+
const c = globalThis.__veloServerData?.getStore?.();
|
|
25
|
+
c?.[t] && (r = c[t]);
|
|
26
26
|
}
|
|
27
27
|
if (typeof window < "u" && t) {
|
|
28
28
|
const o = window.__PAGE_DATA__;
|
|
29
29
|
o?.[t] && (r = o[t], delete o[t]);
|
|
30
30
|
}
|
|
31
|
-
const
|
|
31
|
+
const u = d(r), i = d(!1), l = () => {
|
|
32
32
|
if (typeof window > "u" || !t) return;
|
|
33
33
|
const o = window.location.pathname;
|
|
34
34
|
i.value = !0;
|
|
35
|
-
const
|
|
35
|
+
const w = typeof __VELO_STATIC__ < "u" && __VELO_STATIC__ ? `${o === "/" ? "" : o}/index.json` : (() => {
|
|
36
36
|
const s = new URLSearchParams(window.location.search);
|
|
37
37
|
return s.set("_data", "1"), `${o}?${s.toString()}`;
|
|
38
|
-
})()
|
|
39
|
-
fetch(
|
|
40
|
-
typeof __VELO_BUILD_HASH__ < "u" && s.__buildHash && s.__buildHash !== __VELO_BUILD_HASH__ && (
|
|
38
|
+
})();
|
|
39
|
+
fetch(w, { cache: "no-cache" }).then((s) => s.json()).then((s) => {
|
|
40
|
+
typeof __VELO_BUILD_HASH__ < "u" && s.__buildHash && s.__buildHash !== __VELO_BUILD_HASH__ && (p.value = !0), u.value = s[t], i.value = !1;
|
|
41
41
|
}).catch(() => {
|
|
42
42
|
i.value = !1;
|
|
43
43
|
});
|
|
44
|
-
},
|
|
45
|
-
return
|
|
46
|
-
if (
|
|
47
|
-
|
|
44
|
+
}, f = g(r !== null);
|
|
45
|
+
return h(() => {
|
|
46
|
+
if (f.current) {
|
|
47
|
+
f.current = !1;
|
|
48
48
|
return;
|
|
49
49
|
}
|
|
50
|
-
|
|
51
|
-
}, n ?? []), { data:
|
|
50
|
+
l();
|
|
51
|
+
}, n ?? []), { data: u, loading: i, refetch: l };
|
|
52
52
|
}
|
|
53
|
-
function
|
|
54
|
-
const [, e] =
|
|
53
|
+
function L() {
|
|
54
|
+
const [, e] = v();
|
|
55
55
|
return e;
|
|
56
56
|
}
|
|
57
|
-
function
|
|
58
|
-
return typeof window > "u" ? globalThis.__veloServerData?.getStore?.()?.__params ?? {} :
|
|
57
|
+
function E() {
|
|
58
|
+
return typeof window > "u" ? globalThis.__veloServerData?.getStore?.()?.__params ?? {} : D();
|
|
59
59
|
}
|
|
60
|
-
function
|
|
60
|
+
function b() {
|
|
61
61
|
if (typeof window > "u")
|
|
62
62
|
return globalThis.__veloServerData?.getStore?.()?.__query ?? {};
|
|
63
63
|
const e = window.__PAGE_DATA__;
|
|
@@ -68,16 +68,16 @@ function U() {
|
|
|
68
68
|
t[r] = n;
|
|
69
69
|
}), t;
|
|
70
70
|
}
|
|
71
|
-
function
|
|
72
|
-
return typeof window > "u" ? globalThis.__veloServerData?.getStore?.()?.__pathname ?? "/" : (
|
|
71
|
+
function H() {
|
|
72
|
+
return typeof window > "u" ? globalThis.__veloServerData?.getStore?.()?.__pathname ?? "/" : (v(), window.location.pathname);
|
|
73
73
|
}
|
|
74
74
|
export {
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
75
|
+
P as Loader,
|
|
76
|
+
p as __veloUpdatePending,
|
|
77
|
+
m as touch,
|
|
78
|
+
T as useLoader,
|
|
79
|
+
L as useNavigate,
|
|
80
|
+
E as useParams,
|
|
81
|
+
H as usePathname,
|
|
82
|
+
b as useQuery
|
|
83
83
|
};
|
package/dist/vite.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import d from "node:path";
|
|
2
|
-
import
|
|
2
|
+
import L from "node:fs";
|
|
3
3
|
import C from "@preact/preset-vite";
|
|
4
4
|
import F from "@hono/vite-dev-server";
|
|
5
5
|
import { parse as v } from "@babel/parser";
|
|
6
|
-
import
|
|
6
|
+
import b from "@babel/traverse";
|
|
7
7
|
import j from "@babel/generator";
|
|
8
8
|
import * as e from "@babel/types";
|
|
9
|
-
const m = typeof
|
|
9
|
+
const m = typeof b == "function" ? b : b.default, S = typeof j == "function" ? j : j.default;
|
|
10
10
|
function w(u, c, r, l) {
|
|
11
11
|
const i = v(u, {
|
|
12
12
|
sourceType: "module",
|
|
@@ -21,7 +21,7 @@ function w(u, c, r, l) {
|
|
|
21
21
|
const a = o.declarations[0];
|
|
22
22
|
if (a && e.isIdentifier(a.id, { name: "metadata" }) && e.isObjectExpression(a.init)) {
|
|
23
23
|
t = !0;
|
|
24
|
-
const
|
|
24
|
+
const f = a.init.properties.filter((y) => e.isObjectProperty(y) && e.isIdentifier(y.key) ? y.key.name !== "moduleId" && y.key.name !== "fullPath" && y.key.name !== "path" : !0), h = [
|
|
25
25
|
e.objectProperty(
|
|
26
26
|
e.identifier("moduleId"),
|
|
27
27
|
e.stringLiteral(c)
|
|
@@ -37,7 +37,7 @@ function w(u, c, r, l) {
|
|
|
37
37
|
e.identifier("path"),
|
|
38
38
|
e.stringLiteral(l)
|
|
39
39
|
)
|
|
40
|
-
), a.init.properties = [...h, ...
|
|
40
|
+
), a.init.properties = [...h, ...f];
|
|
41
41
|
}
|
|
42
42
|
}
|
|
43
43
|
}
|
|
@@ -80,8 +80,8 @@ function R(u, c) {
|
|
|
80
80
|
CallExpression(i) {
|
|
81
81
|
const t = i.node.callee, n = e.isIdentifier(t, { name: "Loader" }) || e.isTSInstantiationExpression(t) && e.isIdentifier(t.expression, { name: "Loader" }), s = e.isIdentifier(t, { name: "useLoader" }) || e.isTSInstantiationExpression(t) && e.isIdentifier(t.expression, { name: "useLoader" });
|
|
82
82
|
if (!n && !s) return;
|
|
83
|
-
const o = i.node.arguments, a = e.stringLiteral(c),
|
|
84
|
-
e.isStringLiteral(
|
|
83
|
+
const o = i.node.arguments, a = e.stringLiteral(c), p = o[0];
|
|
84
|
+
e.isStringLiteral(p) && p.value.includes("/") || (i.node.arguments = [a, ...o]);
|
|
85
85
|
}
|
|
86
86
|
}), S(r, { retainLines: !0 }).code;
|
|
87
87
|
}
|
|
@@ -100,12 +100,12 @@ function V(u, c) {
|
|
|
100
100
|
if (!s.startsWith("action_")) return;
|
|
101
101
|
const o = s.replace("action_", ""), a = n.init;
|
|
102
102
|
if (!e.isArrowFunctionExpression(a) || !a.async) return;
|
|
103
|
-
const
|
|
104
|
-
a.body = e.blockStatement([e.returnStatement(
|
|
103
|
+
const p = a.params, f = U(c, o, p);
|
|
104
|
+
a.body = e.blockStatement([e.returnStatement(f)]), W(a, p);
|
|
105
105
|
}
|
|
106
106
|
}), S(r, { retainLines: !0 }).code;
|
|
107
107
|
}
|
|
108
|
-
function
|
|
108
|
+
function U(u, c, r) {
|
|
109
109
|
const l = `/_action/${u}/${c}`;
|
|
110
110
|
return r.length === 0 ? e.callExpression(
|
|
111
111
|
e.memberExpression(
|
|
@@ -175,7 +175,7 @@ function W(u, c, r) {
|
|
|
175
175
|
]
|
|
176
176
|
);
|
|
177
177
|
}
|
|
178
|
-
function
|
|
178
|
+
function W(u, c) {
|
|
179
179
|
if (c.length === 0) return;
|
|
180
180
|
const r = c[0];
|
|
181
181
|
if (e.isObjectPattern(r)) {
|
|
@@ -201,7 +201,7 @@ function $(u, c) {
|
|
|
201
201
|
)), u.params = [t];
|
|
202
202
|
}
|
|
203
203
|
}
|
|
204
|
-
function
|
|
204
|
+
function $(u) {
|
|
205
205
|
const c = v(u, {
|
|
206
206
|
sourceType: "module",
|
|
207
207
|
plugins: ["typescript", "jsx"]
|
|
@@ -258,7 +258,7 @@ function _(u) {
|
|
|
258
258
|
ExportDefaultDeclaration(t) {
|
|
259
259
|
const n = t.node.declaration;
|
|
260
260
|
let s = null;
|
|
261
|
-
e.isArrayExpression(n) ? s = n : e.isTSSatisfiesExpression(n) && e.isArrayExpression(n.expression) && (s = n.expression), s &&
|
|
261
|
+
e.isArrayExpression(n) ? s = n : e.isTSSatisfiesExpression(n) && e.isArrayExpression(n.expression) && (s = n.expression), s && A(s.elements, "", l);
|
|
262
262
|
}
|
|
263
263
|
});
|
|
264
264
|
const i = /* @__PURE__ */ new Map();
|
|
@@ -271,14 +271,14 @@ function _(u) {
|
|
|
271
271
|
}
|
|
272
272
|
return i;
|
|
273
273
|
}
|
|
274
|
-
function
|
|
274
|
+
function A(u, c, r) {
|
|
275
275
|
for (const l of u) {
|
|
276
276
|
if (!e.isObjectExpression(l)) continue;
|
|
277
277
|
let i = "", t = c, n = null, s = null;
|
|
278
278
|
for (const o of l.properties) {
|
|
279
279
|
if (!e.isObjectProperty(o)) continue;
|
|
280
|
-
const a = o.key,
|
|
281
|
-
|
|
280
|
+
const a = o.key, p = e.isIdentifier(a) ? a.name : null;
|
|
281
|
+
p === "path" && e.isStringLiteral(o.value) && (i = o.value.value, i && !i.startsWith("/") ? t = c + "/" + i : t = c + i), p === "module" && e.isIdentifier(o.value) && (n = o.value.name), p === "children" && e.isArrayExpression(o.value) && (s = o.value);
|
|
282
282
|
}
|
|
283
283
|
if (n) {
|
|
284
284
|
const a = !s && i === "/" ? c || "/" : t;
|
|
@@ -287,7 +287,7 @@ function N(u, c, r) {
|
|
|
287
287
|
path: i
|
|
288
288
|
});
|
|
289
289
|
}
|
|
290
|
-
s &&
|
|
290
|
+
s && A(s.elements, t, r);
|
|
291
291
|
}
|
|
292
292
|
}
|
|
293
293
|
const g = "virtual:velo/server-entry", x = "virtual:velo/client-entry", T = "\0" + g, P = "\0" + x;
|
|
@@ -302,8 +302,8 @@ function J(u, c) {
|
|
|
302
302
|
},
|
|
303
303
|
buildStart() {
|
|
304
304
|
const t = d.join(r, l);
|
|
305
|
-
if (
|
|
306
|
-
const n =
|
|
305
|
+
if (L.existsSync(t)) {
|
|
306
|
+
const n = L.readFileSync(t, "utf-8"), s = _(n);
|
|
307
307
|
i.clear();
|
|
308
308
|
for (const [o, a] of s)
|
|
309
309
|
i.set(o, a);
|
|
@@ -312,10 +312,10 @@ function J(u, c) {
|
|
|
312
312
|
handleHotUpdate({ file: t, server: n }) {
|
|
313
313
|
const s = d.join(r, l);
|
|
314
314
|
if (t === s) {
|
|
315
|
-
const o =
|
|
315
|
+
const o = L.readFileSync(s, "utf-8"), a = _(o);
|
|
316
316
|
i.clear();
|
|
317
|
-
for (const [
|
|
318
|
-
i.set(
|
|
317
|
+
for (const [p, f] of a)
|
|
318
|
+
i.set(p, f);
|
|
319
319
|
return n.ws.send({ type: "full-reload" }), [];
|
|
320
320
|
}
|
|
321
321
|
},
|
|
@@ -323,16 +323,16 @@ function J(u, c) {
|
|
|
323
323
|
return t === g || t.endsWith(g) ? T : t === x || t.endsWith(x) || t === "/__velo_client.js" ? P : null;
|
|
324
324
|
},
|
|
325
325
|
load(t) {
|
|
326
|
-
const n = u.routesFile ?? "routes.tsx", s = u.serverInit ?? "server.tsx", o = u.clientInit ?? "client.tsx", a = d.join(r, n).replace(/\.tsx?$/, ".js"),
|
|
326
|
+
const n = u.routesFile ?? "routes.tsx", s = u.serverInit ?? "server.tsx", o = u.clientInit ?? "client.tsx", a = d.join(r, n).replace(/\.tsx?$/, ".js"), p = d.join(r, s).replace(/\.tsx?$/, ".js"), f = d.join(r, o).replace(/\.tsx?$/, ".js");
|
|
327
327
|
return t === T ? `
|
|
328
|
-
import "${
|
|
328
|
+
import "${p}";
|
|
329
329
|
import routes from "${a}";
|
|
330
330
|
import { startServer } from "@mauroandre/velojs/server";
|
|
331
331
|
|
|
332
332
|
export { routes };
|
|
333
333
|
export default await startServer({ routes });
|
|
334
334
|
` : t === P ? `
|
|
335
|
-
import "${
|
|
335
|
+
import "${f}";
|
|
336
336
|
import routes from "${a}";
|
|
337
337
|
import { startClient } from "@mauroandre/velojs/client";
|
|
338
338
|
|
|
@@ -342,18 +342,18 @@ startClient({ routes });
|
|
|
342
342
|
transform(t, n, s) {
|
|
343
343
|
const o = s?.ssr === !0;
|
|
344
344
|
if (n.startsWith("\0") || n.includes("/.velojs/") || !n.endsWith(".tsx") && !n.endsWith(".ts") || !n.startsWith(r)) return null;
|
|
345
|
-
let a = t,
|
|
346
|
-
const
|
|
345
|
+
let a = t, p = !1;
|
|
346
|
+
const f = /middlewares:\s*\[/.test(t), h = /export\s+(const|function)\s+Component/.test(
|
|
347
347
|
t
|
|
348
|
-
), y = /export\s+(const|function)\s+loader/.test(t),
|
|
349
|
-
if (!o &&
|
|
348
|
+
), y = /export\s+(const|function)\s+loader/.test(t), N = /export\s+const\s+action_\w+/.test(t), O = /\bLoader\s*</.test(t) || /\bLoader\s*\(/.test(t), D = /\buseLoader\s*</.test(t) || /\buseLoader\s*\(/.test(t);
|
|
349
|
+
if (!o && f && (a = k(a), p = !0), h || y || N || O || D) {
|
|
350
350
|
const E = d.relative(r, n).replace(/\.(tsx?|jsx?)$/, "").replace(/\\/g, "/"), I = i.get(E);
|
|
351
351
|
a = w(a, E, I?.fullPath, I?.path), a = R(a, E), o || (a = V(
|
|
352
352
|
a,
|
|
353
353
|
E
|
|
354
|
-
)), o || (a =
|
|
354
|
+
)), o || (a = $(a)), p = !0;
|
|
355
355
|
}
|
|
356
|
-
return
|
|
356
|
+
return p ? {
|
|
357
357
|
code: a,
|
|
358
358
|
map: null
|
|
359
359
|
} : null;
|
|
@@ -368,8 +368,8 @@ function M() {
|
|
|
368
368
|
let t = "client.js", n = "client.css";
|
|
369
369
|
if (r)
|
|
370
370
|
try {
|
|
371
|
-
const o = d.resolve(process.cwd(), "dist/client/.vite/manifest.json"),
|
|
372
|
-
|
|
371
|
+
const o = d.resolve(process.cwd(), "dist/client/.vite/manifest.json"), p = JSON.parse(L.readFileSync(o, "utf-8"))[x];
|
|
372
|
+
p && (t = p.file || t, p.css?.[0] && (n = p.css[0]));
|
|
373
373
|
} catch {
|
|
374
374
|
}
|
|
375
375
|
const s = {
|
|
@@ -377,7 +377,7 @@ function M() {
|
|
|
377
377
|
"process.env.NODE_ENV": JSON.stringify(l ? "development" : "production"),
|
|
378
378
|
"process.env.STATIC_BASE_URL": JSON.stringify(process.env.STATIC_BASE_URL || (i ? "/client" : "")),
|
|
379
379
|
__VELO_STATIC__: JSON.stringify(i),
|
|
380
|
-
__VELO_BUILD_HASH__: JSON.stringify(Date.now().toString(36)),
|
|
380
|
+
__VELO_BUILD_HASH__: JSON.stringify(process.env.VELO_BUILD_HASH || Date.now().toString(36)),
|
|
381
381
|
__VELO_CLIENT_JS__: JSON.stringify(t),
|
|
382
382
|
__VELO_CLIENT_CSS__: JSON.stringify(n)
|
|
383
383
|
},
|
|
@@ -451,9 +451,9 @@ function H() {
|
|
|
451
451
|
}
|
|
452
452
|
export {
|
|
453
453
|
_ as buildFullPathMap,
|
|
454
|
-
|
|
454
|
+
A as collectFullPaths,
|
|
455
455
|
w as injectMetadata,
|
|
456
|
-
|
|
456
|
+
$ as removeLoaders,
|
|
457
457
|
k as removeMiddlewares,
|
|
458
458
|
V as transformActionsForClient,
|
|
459
459
|
R as transformLoaderFunctions,
|