@mauroandre/velojs 0.0.17 → 0.0.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/README.md +153 -3
- package/dist/components.js +15 -15
- package/dist/events.d.ts +91 -0
- package/dist/events.js +62 -0
- package/dist/hooks.d.ts +31 -0
- package/dist/hooks.js +73 -42
- package/dist/index.d.ts +2 -0
- package/dist/index.js +7 -5
- package/dist/server.js +124 -94
- package/dist/vite.d.ts +8 -0
- package/dist/vite.js +207 -174
- package/package.json +5 -1
package/dist/vite.js
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import d from "node:path";
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
import { parse as
|
|
2
|
+
import L from "node:fs";
|
|
3
|
+
import F from "@preact/preset-vite";
|
|
4
|
+
import w from "@hono/vite-dev-server";
|
|
5
|
+
import { parse as _ } from "@babel/parser";
|
|
6
6
|
import E from "@babel/traverse";
|
|
7
7
|
import b from "@babel/generator";
|
|
8
8
|
import * as e from "@babel/types";
|
|
9
|
-
const m = typeof E == "function" ? E : E.default,
|
|
10
|
-
function
|
|
11
|
-
const i =
|
|
9
|
+
const m = typeof E == "function" ? E : E.default, v = typeof b == "function" ? b : b.default;
|
|
10
|
+
function V(u, l, n, c) {
|
|
11
|
+
const i = _(u, {
|
|
12
12
|
sourceType: "module",
|
|
13
13
|
plugins: ["typescript", "jsx"]
|
|
14
14
|
});
|
|
@@ -16,28 +16,28 @@ function w(u, c, r, l) {
|
|
|
16
16
|
if (m(i, {
|
|
17
17
|
// Procura: export const metadata = { ... }
|
|
18
18
|
ExportNamedDeclaration(s) {
|
|
19
|
-
const
|
|
20
|
-
if (e.isVariableDeclaration(
|
|
21
|
-
const
|
|
22
|
-
if (
|
|
19
|
+
const a = s.node.declaration;
|
|
20
|
+
if (e.isVariableDeclaration(a) && a.declarations.length === 1) {
|
|
21
|
+
const o = a.declarations[0];
|
|
22
|
+
if (o && e.isIdentifier(o.id, { name: "metadata" }) && e.isObjectExpression(o.init)) {
|
|
23
23
|
t = !0;
|
|
24
|
-
const f =
|
|
24
|
+
const f = o.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
|
-
e.stringLiteral(
|
|
27
|
+
e.stringLiteral(l)
|
|
28
28
|
)
|
|
29
29
|
];
|
|
30
|
-
|
|
30
|
+
n !== void 0 && h.push(
|
|
31
31
|
e.objectProperty(
|
|
32
32
|
e.identifier("fullPath"),
|
|
33
|
-
e.stringLiteral(
|
|
33
|
+
e.stringLiteral(n)
|
|
34
34
|
)
|
|
35
|
-
),
|
|
35
|
+
), c !== void 0 && h.push(
|
|
36
36
|
e.objectProperty(
|
|
37
37
|
e.identifier("path"),
|
|
38
|
-
e.stringLiteral(
|
|
38
|
+
e.stringLiteral(c)
|
|
39
39
|
)
|
|
40
|
-
),
|
|
40
|
+
), o.init.properties = [...h, ...f];
|
|
41
41
|
}
|
|
42
42
|
}
|
|
43
43
|
}
|
|
@@ -45,21 +45,21 @@ function w(u, c, r, l) {
|
|
|
45
45
|
const s = [
|
|
46
46
|
e.objectProperty(
|
|
47
47
|
e.identifier("moduleId"),
|
|
48
|
-
e.stringLiteral(
|
|
48
|
+
e.stringLiteral(l)
|
|
49
49
|
)
|
|
50
50
|
];
|
|
51
|
-
|
|
51
|
+
n !== void 0 && s.push(
|
|
52
52
|
e.objectProperty(
|
|
53
53
|
e.identifier("fullPath"),
|
|
54
|
-
e.stringLiteral(
|
|
54
|
+
e.stringLiteral(n)
|
|
55
55
|
)
|
|
56
|
-
),
|
|
56
|
+
), c !== void 0 && s.push(
|
|
57
57
|
e.objectProperty(
|
|
58
58
|
e.identifier("path"),
|
|
59
|
-
e.stringLiteral(
|
|
59
|
+
e.stringLiteral(c)
|
|
60
60
|
)
|
|
61
61
|
);
|
|
62
|
-
const
|
|
62
|
+
const a = e.exportNamedDeclaration(
|
|
63
63
|
e.variableDeclaration("const", [
|
|
64
64
|
e.variableDeclarator(
|
|
65
65
|
e.identifier("metadata"),
|
|
@@ -67,50 +67,50 @@ function w(u, c, r, l) {
|
|
|
67
67
|
)
|
|
68
68
|
])
|
|
69
69
|
);
|
|
70
|
-
i.program.body.unshift(
|
|
70
|
+
i.program.body.unshift(a);
|
|
71
71
|
}
|
|
72
|
-
return
|
|
72
|
+
return v(i, { retainLines: !0 }).code;
|
|
73
73
|
}
|
|
74
|
-
function R(u,
|
|
75
|
-
const
|
|
74
|
+
function R(u, l) {
|
|
75
|
+
const n = _(u, {
|
|
76
76
|
sourceType: "module",
|
|
77
77
|
plugins: ["typescript", "jsx"]
|
|
78
78
|
});
|
|
79
|
-
return m(
|
|
79
|
+
return m(n, {
|
|
80
80
|
CallExpression(i) {
|
|
81
|
-
const t = i.node.callee,
|
|
82
|
-
if (!
|
|
83
|
-
const
|
|
84
|
-
e.isStringLiteral(p) && p.value.includes("/") || (i.node.arguments = [
|
|
81
|
+
const t = i.node.callee, r = 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
|
+
if (!r && !s) return;
|
|
83
|
+
const a = i.node.arguments, o = e.stringLiteral(l), p = a[0];
|
|
84
|
+
e.isStringLiteral(p) && p.value.includes("/") || (i.node.arguments = [o, ...a]);
|
|
85
85
|
}
|
|
86
|
-
}),
|
|
86
|
+
}), v(n, { retainLines: !0 }).code;
|
|
87
87
|
}
|
|
88
|
-
function
|
|
89
|
-
const
|
|
88
|
+
function $(u, l) {
|
|
89
|
+
const n = _(u, {
|
|
90
90
|
sourceType: "module",
|
|
91
91
|
plugins: ["typescript", "jsx"]
|
|
92
92
|
});
|
|
93
|
-
return m(
|
|
93
|
+
return m(n, {
|
|
94
94
|
ExportNamedDeclaration(i) {
|
|
95
95
|
const t = i.node.declaration;
|
|
96
96
|
if (!e.isVariableDeclaration(t)) return;
|
|
97
|
-
const
|
|
98
|
-
if (!
|
|
99
|
-
const s =
|
|
97
|
+
const r = t.declarations[0];
|
|
98
|
+
if (!r || !e.isIdentifier(r.id)) return;
|
|
99
|
+
const s = r.id.name;
|
|
100
100
|
if (!s.startsWith("action_")) return;
|
|
101
|
-
const
|
|
102
|
-
if (!e.isArrowFunctionExpression(
|
|
103
|
-
const p =
|
|
104
|
-
|
|
101
|
+
const a = s.replace("action_", ""), o = r.init;
|
|
102
|
+
if (!e.isArrowFunctionExpression(o) || !o.async) return;
|
|
103
|
+
const p = o.params, f = U(l, a, p);
|
|
104
|
+
o.body = e.blockStatement([e.returnStatement(f)]), W(o, p);
|
|
105
105
|
}
|
|
106
|
-
}),
|
|
106
|
+
}), v(n, { retainLines: !0 }).code;
|
|
107
107
|
}
|
|
108
|
-
function U(u,
|
|
109
|
-
const
|
|
110
|
-
return
|
|
108
|
+
function U(u, l, n) {
|
|
109
|
+
const c = `/_action/${u}/${l}`;
|
|
110
|
+
return n.length === 0 ? e.callExpression(
|
|
111
111
|
e.memberExpression(
|
|
112
112
|
e.callExpression(e.identifier("fetch"), [
|
|
113
|
-
e.stringLiteral(
|
|
113
|
+
e.stringLiteral(c),
|
|
114
114
|
e.objectExpression([
|
|
115
115
|
e.objectProperty(
|
|
116
116
|
e.identifier("method"),
|
|
@@ -135,7 +135,7 @@ function U(u, c, r) {
|
|
|
135
135
|
) : e.callExpression(
|
|
136
136
|
e.memberExpression(
|
|
137
137
|
e.callExpression(e.identifier("fetch"), [
|
|
138
|
-
e.stringLiteral(
|
|
138
|
+
e.stringLiteral(c),
|
|
139
139
|
e.objectExpression([
|
|
140
140
|
e.objectProperty(
|
|
141
141
|
e.identifier("method"),
|
|
@@ -175,14 +175,14 @@ function U(u, c, r) {
|
|
|
175
175
|
]
|
|
176
176
|
);
|
|
177
177
|
}
|
|
178
|
-
function W(u,
|
|
179
|
-
if (
|
|
180
|
-
const
|
|
181
|
-
if (e.isObjectPattern(
|
|
182
|
-
let
|
|
183
|
-
if (e.isTSTypeAnnotation(
|
|
184
|
-
const
|
|
185
|
-
e.isIdentifier(
|
|
178
|
+
function W(u, l) {
|
|
179
|
+
if (l.length === 0) return;
|
|
180
|
+
const n = l[0];
|
|
181
|
+
if (e.isObjectPattern(n)) {
|
|
182
|
+
let c = null;
|
|
183
|
+
if (e.isTSTypeAnnotation(n.typeAnnotation) && e.isTSTypeReference(n.typeAnnotation.typeAnnotation)) {
|
|
184
|
+
const r = n.typeAnnotation.typeAnnotation;
|
|
185
|
+
e.isIdentifier(r.typeName, { name: "ActionArgs" }) && r.typeParameters?.params[0] && (c = r.typeParameters.params[0]);
|
|
186
186
|
}
|
|
187
187
|
const i = e.objectProperty(
|
|
188
188
|
e.identifier("body"),
|
|
@@ -191,196 +191,228 @@ function W(u, c) {
|
|
|
191
191
|
!0
|
|
192
192
|
// shorthand
|
|
193
193
|
), t = e.objectPattern([i]);
|
|
194
|
-
|
|
194
|
+
c && (t.typeAnnotation = e.tsTypeAnnotation(
|
|
195
195
|
e.tsTypeLiteral([
|
|
196
196
|
e.tsPropertySignature(
|
|
197
197
|
e.identifier("body"),
|
|
198
|
-
e.tsTypeAnnotation(
|
|
198
|
+
e.tsTypeAnnotation(c)
|
|
199
199
|
)
|
|
200
200
|
])
|
|
201
201
|
)), u.params = [t];
|
|
202
202
|
}
|
|
203
203
|
}
|
|
204
|
-
function
|
|
205
|
-
const
|
|
204
|
+
function J(u, l) {
|
|
205
|
+
const n = _(u, {
|
|
206
206
|
sourceType: "module",
|
|
207
207
|
plugins: ["typescript", "jsx"]
|
|
208
208
|
});
|
|
209
|
-
return m(
|
|
210
|
-
ExportNamedDeclaration(
|
|
211
|
-
const
|
|
209
|
+
return m(n, {
|
|
210
|
+
ExportNamedDeclaration(i) {
|
|
211
|
+
const t = i.node.declaration;
|
|
212
|
+
if (!e.isVariableDeclaration(t)) return;
|
|
213
|
+
const r = t.declarations[0];
|
|
214
|
+
if (!r || !e.isIdentifier(r.id)) return;
|
|
215
|
+
const s = r.id.name;
|
|
216
|
+
if (!s.startsWith("stream_")) return;
|
|
217
|
+
const a = s.replace("stream_", ""), o = `/_event/${l}/${a}`;
|
|
218
|
+
r.init = e.objectExpression([
|
|
219
|
+
e.objectProperty(
|
|
220
|
+
e.identifier("__isVeloEventStream"),
|
|
221
|
+
e.booleanLiteral(!0)
|
|
222
|
+
),
|
|
223
|
+
e.objectProperty(
|
|
224
|
+
e.identifier("__path"),
|
|
225
|
+
e.stringLiteral(o)
|
|
226
|
+
)
|
|
227
|
+
]), r.id.typeAnnotation = null;
|
|
228
|
+
}
|
|
229
|
+
}), v(n, { retainLines: !0 }).code;
|
|
230
|
+
}
|
|
231
|
+
function k(u) {
|
|
232
|
+
const l = _(u, {
|
|
233
|
+
sourceType: "module",
|
|
234
|
+
plugins: ["typescript", "jsx"]
|
|
235
|
+
});
|
|
236
|
+
return m(l, {
|
|
237
|
+
ExportNamedDeclaration(c) {
|
|
238
|
+
const i = c.node.declaration;
|
|
212
239
|
if (!e.isVariableDeclaration(i)) return;
|
|
213
240
|
const t = i.declarations[0];
|
|
214
|
-
!t || !e.isIdentifier(t.id) || t.id.name === "loader" &&
|
|
241
|
+
!t || !e.isIdentifier(t.id) || t.id.name === "loader" && c.remove();
|
|
215
242
|
}
|
|
216
|
-
}),
|
|
243
|
+
}), v(l, { retainLines: !0 }).code;
|
|
217
244
|
}
|
|
218
|
-
function
|
|
219
|
-
const
|
|
245
|
+
function B(u) {
|
|
246
|
+
const l = _(u, {
|
|
220
247
|
sourceType: "module",
|
|
221
248
|
plugins: ["typescript", "jsx"]
|
|
222
|
-
}),
|
|
223
|
-
return m(
|
|
249
|
+
}), n = /* @__PURE__ */ new Set();
|
|
250
|
+
return m(l, {
|
|
224
251
|
ObjectProperty(i) {
|
|
225
252
|
if (e.isIdentifier(i.node.key, { name: "middlewares" }) && e.isArrayExpression(i.node.value)) {
|
|
226
253
|
for (const t of i.node.value.elements)
|
|
227
|
-
e.isIdentifier(t) &&
|
|
254
|
+
e.isIdentifier(t) && n.add(t.name);
|
|
228
255
|
i.remove();
|
|
229
256
|
}
|
|
230
257
|
}
|
|
231
|
-
}),
|
|
258
|
+
}), n.size === 0 ? u : (m(l, {
|
|
232
259
|
ImportDeclaration(i) {
|
|
233
|
-
const t = i.node.specifiers,
|
|
260
|
+
const t = i.node.specifiers, r = t.filter((s) => {
|
|
234
261
|
if (e.isImportSpecifier(s)) {
|
|
235
|
-
const
|
|
236
|
-
return !
|
|
262
|
+
const a = s.local.name;
|
|
263
|
+
return !n.has(a);
|
|
237
264
|
}
|
|
238
265
|
return !0;
|
|
239
266
|
});
|
|
240
|
-
|
|
267
|
+
r.length === 0 ? i.remove() : r.length !== t.length && (i.node.specifiers = r);
|
|
241
268
|
}
|
|
242
|
-
}),
|
|
269
|
+
}), v(l, { retainLines: !0 }).code);
|
|
243
270
|
}
|
|
244
|
-
function
|
|
245
|
-
const
|
|
271
|
+
function T(u) {
|
|
272
|
+
const l = _(u, {
|
|
246
273
|
sourceType: "module",
|
|
247
274
|
plugins: ["typescript", "jsx"]
|
|
248
|
-
}),
|
|
249
|
-
m(
|
|
275
|
+
}), n = /* @__PURE__ */ new Map();
|
|
276
|
+
m(l, {
|
|
250
277
|
ImportDeclaration(t) {
|
|
251
|
-
const
|
|
278
|
+
const r = t.node.source.value;
|
|
252
279
|
for (const s of t.node.specifiers)
|
|
253
|
-
e.isImportNamespaceSpecifier(s) &&
|
|
280
|
+
e.isImportNamespaceSpecifier(s) && n.set(s.local.name, r);
|
|
254
281
|
}
|
|
255
282
|
});
|
|
256
|
-
const
|
|
257
|
-
m(
|
|
283
|
+
const c = /* @__PURE__ */ new Map();
|
|
284
|
+
m(l, {
|
|
258
285
|
ExportDefaultDeclaration(t) {
|
|
259
|
-
const
|
|
286
|
+
const r = t.node.declaration;
|
|
260
287
|
let s = null;
|
|
261
|
-
e.isArrayExpression(
|
|
288
|
+
e.isArrayExpression(r) ? s = r : e.isTSSatisfiesExpression(r) && e.isArrayExpression(r.expression) && (s = r.expression), s && A(s.elements, "", c);
|
|
262
289
|
}
|
|
263
290
|
});
|
|
264
291
|
const i = /* @__PURE__ */ new Map();
|
|
265
|
-
for (const [t,
|
|
266
|
-
const s =
|
|
292
|
+
for (const [t, r] of c) {
|
|
293
|
+
const s = n.get(t);
|
|
267
294
|
if (s) {
|
|
268
|
-
const
|
|
269
|
-
i.set(
|
|
295
|
+
const a = s.replace(/^\.\//, "").replace(/\.(tsx?|jsx?|js)$/, "");
|
|
296
|
+
i.set(a, r);
|
|
270
297
|
}
|
|
271
298
|
}
|
|
272
299
|
return i;
|
|
273
300
|
}
|
|
274
|
-
function A(u,
|
|
275
|
-
for (const
|
|
276
|
-
if (!e.isObjectExpression(
|
|
277
|
-
let i = "", t =
|
|
278
|
-
for (const
|
|
279
|
-
if (!e.isObjectProperty(
|
|
280
|
-
const
|
|
281
|
-
p === "path" && e.isStringLiteral(
|
|
301
|
+
function A(u, l, n) {
|
|
302
|
+
for (const c of u) {
|
|
303
|
+
if (!e.isObjectExpression(c)) continue;
|
|
304
|
+
let i = "", t = l, r = null, s = null;
|
|
305
|
+
for (const a of c.properties) {
|
|
306
|
+
if (!e.isObjectProperty(a)) continue;
|
|
307
|
+
const o = a.key, p = e.isIdentifier(o) ? o.name : null;
|
|
308
|
+
p === "path" && e.isStringLiteral(a.value) && (i = a.value.value, i && !i.startsWith("/") ? t = l + "/" + i : t = l + i), p === "module" && e.isIdentifier(a.value) && (r = a.value.name), p === "children" && e.isArrayExpression(a.value) && (s = a.value);
|
|
282
309
|
}
|
|
283
|
-
if (
|
|
284
|
-
const
|
|
285
|
-
|
|
286
|
-
fullPath:
|
|
310
|
+
if (r) {
|
|
311
|
+
const o = !s && i === "/" ? l || "/" : t;
|
|
312
|
+
n.set(r, {
|
|
313
|
+
fullPath: o,
|
|
287
314
|
path: i
|
|
288
315
|
});
|
|
289
316
|
}
|
|
290
|
-
s && A(s.elements, t,
|
|
317
|
+
s && A(s.elements, t, n);
|
|
291
318
|
}
|
|
292
319
|
}
|
|
293
|
-
const
|
|
294
|
-
function
|
|
295
|
-
let
|
|
296
|
-
const
|
|
320
|
+
const x = "virtual:velo/server-entry", S = "virtual:velo/client-entry", N = "\0" + x, P = "\0" + S;
|
|
321
|
+
function M(u, l) {
|
|
322
|
+
let n = d.resolve(process.cwd(), l);
|
|
323
|
+
const c = u.routesFile ?? "routes.tsx", i = /* @__PURE__ */ new Map();
|
|
297
324
|
return {
|
|
298
325
|
name: "velo:transform",
|
|
299
326
|
enforce: "pre",
|
|
300
327
|
configResolved(t) {
|
|
301
|
-
|
|
328
|
+
n = d.resolve(t.root, l);
|
|
302
329
|
},
|
|
303
330
|
buildStart() {
|
|
304
|
-
const t = d.join(
|
|
305
|
-
if (
|
|
306
|
-
const
|
|
331
|
+
const t = d.join(n, c);
|
|
332
|
+
if (L.existsSync(t)) {
|
|
333
|
+
const r = L.readFileSync(t, "utf-8"), s = T(r);
|
|
307
334
|
i.clear();
|
|
308
|
-
for (const [
|
|
309
|
-
i.set(
|
|
335
|
+
for (const [a, o] of s)
|
|
336
|
+
i.set(a, o);
|
|
310
337
|
}
|
|
311
338
|
},
|
|
312
|
-
handleHotUpdate({ file: t, server:
|
|
313
|
-
const s = d.join(
|
|
339
|
+
handleHotUpdate({ file: t, server: r }) {
|
|
340
|
+
const s = d.join(n, c);
|
|
314
341
|
if (t === s) {
|
|
315
|
-
const
|
|
342
|
+
const a = L.readFileSync(s, "utf-8"), o = T(a);
|
|
316
343
|
i.clear();
|
|
317
|
-
for (const [p, f] of
|
|
344
|
+
for (const [p, f] of o)
|
|
318
345
|
i.set(p, f);
|
|
319
|
-
return
|
|
346
|
+
return r.ws.send({ type: "full-reload" }), [];
|
|
320
347
|
}
|
|
321
348
|
},
|
|
322
349
|
resolveId(t) {
|
|
323
|
-
return t ===
|
|
350
|
+
return t === x || t.endsWith(x) ? N : t === S || t.endsWith(S) || t === "/__velo_client.js" ? P : null;
|
|
324
351
|
},
|
|
325
352
|
load(t) {
|
|
326
|
-
const
|
|
327
|
-
return t ===
|
|
353
|
+
const r = u.routesFile ?? "routes.tsx", s = u.serverInit ?? "server.tsx", a = u.clientInit ?? "client.tsx", o = d.join(n, r).replace(/\.tsx?$/, ".js"), p = d.join(n, s).replace(/\.tsx?$/, ".js"), f = d.join(n, a).replace(/\.tsx?$/, ".js");
|
|
354
|
+
return t === N ? `
|
|
328
355
|
globalThis.__veloBuildHash = __VELO_BUILD_HASH__;
|
|
356
|
+
globalThis.__veloClientJs = __VELO_CLIENT_JS__;
|
|
357
|
+
globalThis.__veloClientCss = __VELO_CLIENT_CSS__;
|
|
329
358
|
import "${p}";
|
|
330
|
-
import routes from "${
|
|
359
|
+
import routes from "${o}";
|
|
331
360
|
import { startServer } from "@mauroandre/velojs/server";
|
|
332
361
|
|
|
333
362
|
export { routes };
|
|
334
363
|
export default await startServer({ routes });
|
|
335
364
|
` : t === P ? `
|
|
336
365
|
import "${f}";
|
|
337
|
-
import routes from "${
|
|
366
|
+
import routes from "${o}";
|
|
338
367
|
import { startClient } from "@mauroandre/velojs/client";
|
|
339
368
|
|
|
340
369
|
startClient({ routes });
|
|
341
370
|
` : null;
|
|
342
371
|
},
|
|
343
|
-
transform(t,
|
|
344
|
-
const
|
|
345
|
-
if (
|
|
346
|
-
let
|
|
372
|
+
transform(t, r, s) {
|
|
373
|
+
const a = s?.ssr === !0;
|
|
374
|
+
if (r.startsWith("\0") || r.includes("/.velojs/") || !r.endsWith(".tsx") && !r.endsWith(".ts") || !r.startsWith(n)) return null;
|
|
375
|
+
let o = t, p = !1;
|
|
347
376
|
const f = /middlewares:\s*\[/.test(t), h = /export\s+(const|function)\s+Component/.test(
|
|
348
377
|
t
|
|
349
|
-
), y = /export\s+(const|function)\s+loader/.test(t),
|
|
350
|
-
if (!
|
|
351
|
-
const
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
)),
|
|
378
|
+
), y = /export\s+(const|function)\s+loader/.test(t), C = /export\s+const\s+action_\w+/.test(t), j = /export\s+const\s+stream_\w+/.test(t), O = /\bLoader\s*</.test(t) || /\bLoader\s*\(/.test(t), D = /\buseLoader\s*</.test(t) || /\buseLoader\s*\(/.test(t);
|
|
379
|
+
if (!a && f && (o = B(o), p = !0), h || y || C || j || O || D) {
|
|
380
|
+
const g = d.relative(n, r).replace(/\.(tsx?|jsx?)$/, "").replace(/\\/g, "/"), I = i.get(g);
|
|
381
|
+
o = V(o, g, I?.fullPath, I?.path), o = R(o, g), a || (o = $(
|
|
382
|
+
o,
|
|
383
|
+
g
|
|
384
|
+
)), !a && j && (o = J(
|
|
385
|
+
o,
|
|
386
|
+
g
|
|
387
|
+
)), a || (o = k(o)), p = !0;
|
|
356
388
|
}
|
|
357
389
|
return p ? {
|
|
358
|
-
code:
|
|
390
|
+
code: o,
|
|
359
391
|
map: null
|
|
360
392
|
} : null;
|
|
361
393
|
}
|
|
362
394
|
};
|
|
363
395
|
}
|
|
364
|
-
function
|
|
396
|
+
function H() {
|
|
365
397
|
return {
|
|
366
398
|
name: "velo:config",
|
|
367
|
-
config(u, { mode:
|
|
368
|
-
const
|
|
369
|
-
let t = "client.js",
|
|
370
|
-
if (
|
|
399
|
+
config(u, { mode: l }) {
|
|
400
|
+
const n = l === "server", c = l === "development", i = !!process.env.VELO_STATIC;
|
|
401
|
+
let t = "client.js", r = "client.css";
|
|
402
|
+
if (n)
|
|
371
403
|
try {
|
|
372
|
-
const
|
|
373
|
-
p && (t = p.file || t, p.css?.[0] && (
|
|
404
|
+
const a = d.resolve(process.cwd(), "dist/client/.vite/manifest.json"), p = JSON.parse(L.readFileSync(a, "utf-8"))[S];
|
|
405
|
+
p && (t = p.file || t, p.css?.[0] && (r = p.css[0]));
|
|
374
406
|
} catch {
|
|
375
407
|
}
|
|
376
408
|
const s = {
|
|
377
409
|
define: {
|
|
378
|
-
"process.env.NODE_ENV": JSON.stringify(
|
|
410
|
+
"process.env.NODE_ENV": JSON.stringify(c ? "development" : "production"),
|
|
379
411
|
"process.env.STATIC_BASE_URL": JSON.stringify(process.env.STATIC_BASE_URL || (i ? "/client" : "")),
|
|
380
412
|
__VELO_STATIC__: JSON.stringify(i),
|
|
381
413
|
__VELO_BUILD_HASH__: JSON.stringify(process.env.VELO_BUILD_HASH || Date.now().toString(36)),
|
|
382
414
|
__VELO_CLIENT_JS__: JSON.stringify(t),
|
|
383
|
-
__VELO_CLIENT_CSS__: JSON.stringify(
|
|
415
|
+
__VELO_CLIENT_CSS__: JSON.stringify(r)
|
|
384
416
|
},
|
|
385
417
|
resolve: {
|
|
386
418
|
alias: {
|
|
@@ -389,8 +421,8 @@ function J() {
|
|
|
389
421
|
}
|
|
390
422
|
}
|
|
391
423
|
};
|
|
392
|
-
return
|
|
393
|
-
ssr:
|
|
424
|
+
return n ? s.build = {
|
|
425
|
+
ssr: x,
|
|
394
426
|
outDir: "dist",
|
|
395
427
|
emptyOutDir: !1,
|
|
396
428
|
copyPublicDir: !1,
|
|
@@ -399,50 +431,50 @@ function J() {
|
|
|
399
431
|
entryFileNames: "server.js"
|
|
400
432
|
}
|
|
401
433
|
}
|
|
402
|
-
} :
|
|
434
|
+
} : c || (s.build = {
|
|
403
435
|
manifest: !0,
|
|
404
436
|
outDir: "dist/client",
|
|
405
437
|
rollupOptions: {
|
|
406
|
-
input:
|
|
438
|
+
input: S,
|
|
407
439
|
output: {
|
|
408
440
|
entryFileNames: "client.[hash].js",
|
|
409
|
-
assetFileNames: (
|
|
441
|
+
assetFileNames: (a) => a.names?.[0]?.endsWith(".css") ? "client.[hash].css" : "[name].[hash][extname]"
|
|
410
442
|
}
|
|
411
443
|
}
|
|
412
444
|
}), s;
|
|
413
445
|
}
|
|
414
446
|
};
|
|
415
447
|
}
|
|
416
|
-
function
|
|
448
|
+
function Y() {
|
|
417
449
|
return {
|
|
418
450
|
name: "velo:static-url",
|
|
419
451
|
apply: "build",
|
|
420
452
|
enforce: "post",
|
|
421
|
-
generateBundle(u,
|
|
422
|
-
const
|
|
423
|
-
if (
|
|
424
|
-
for (const
|
|
425
|
-
|
|
453
|
+
generateBundle(u, l) {
|
|
454
|
+
const n = process.env.STATIC_BASE_URL || "";
|
|
455
|
+
if (n)
|
|
456
|
+
for (const c of Object.values(l))
|
|
457
|
+
c.type === "asset" && typeof c.source == "string" && c.fileName.endsWith(".css") && (c.source = c.source.replace(
|
|
426
458
|
/url\(\s*(['"]?)\/(?!\/)/g,
|
|
427
|
-
`url($1${
|
|
459
|
+
`url($1${n}/`
|
|
428
460
|
));
|
|
429
461
|
}
|
|
430
462
|
};
|
|
431
463
|
}
|
|
432
|
-
function
|
|
433
|
-
const
|
|
464
|
+
function te(u) {
|
|
465
|
+
const l = u ?? {}, n = l.appDirectory ?? "./app";
|
|
434
466
|
return [
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
entry:
|
|
467
|
+
H(),
|
|
468
|
+
M(l, n),
|
|
469
|
+
Y(),
|
|
470
|
+
F(),
|
|
471
|
+
w({
|
|
472
|
+
entry: x
|
|
441
473
|
}),
|
|
442
|
-
|
|
474
|
+
z()
|
|
443
475
|
];
|
|
444
476
|
}
|
|
445
|
-
function
|
|
477
|
+
function z() {
|
|
446
478
|
return {
|
|
447
479
|
name: "velo:ws-bridge",
|
|
448
480
|
configureServer(u) {
|
|
@@ -451,12 +483,13 @@ function H() {
|
|
|
451
483
|
};
|
|
452
484
|
}
|
|
453
485
|
export {
|
|
454
|
-
|
|
486
|
+
T as buildFullPathMap,
|
|
455
487
|
A as collectFullPaths,
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
488
|
+
V as injectMetadata,
|
|
489
|
+
k as removeLoaders,
|
|
490
|
+
B as removeMiddlewares,
|
|
491
|
+
$ as transformActionsForClient,
|
|
460
492
|
R as transformLoaderFunctions,
|
|
461
|
-
|
|
493
|
+
J as transformStreamsForClient,
|
|
494
|
+
te as veloPlugin
|
|
462
495
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mauroandre/velojs",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.19",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Fullstack web framework built on Hono + Preact with Vite-powered AST transforms",
|
|
6
6
|
"keywords": [
|
|
@@ -53,6 +53,10 @@
|
|
|
53
53
|
"types": "./dist/hooks.d.ts",
|
|
54
54
|
"import": "./dist/hooks.js"
|
|
55
55
|
},
|
|
56
|
+
"./events": {
|
|
57
|
+
"types": "./dist/events.d.ts",
|
|
58
|
+
"import": "./dist/events.js"
|
|
59
|
+
},
|
|
56
60
|
"./cookie": {
|
|
57
61
|
"types": "./dist/cookie.d.ts",
|
|
58
62
|
"import": "./dist/cookie.js"
|