@withl5e/l5e 0.3.3-alpha.4 → 1.0.0
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 +1 -1
- package/dist/action.js +10 -9
- package/dist/action.js.map +1 -1
- package/dist/defineMiddleware-D017PWDc.js +8 -0
- package/dist/defineMiddleware-D017PWDc.js.map +1 -0
- package/dist/entry-server.js +161 -176
- package/dist/entry-server.js.map +1 -1
- package/dist/exceptions-D4OdiQjY.js +30 -0
- package/dist/exceptions-D4OdiQjY.js.map +1 -0
- package/dist/generateMetadata-DcdY-XC1.js +303 -0
- package/dist/generateMetadata-DcdY-XC1.js.map +1 -0
- package/dist/global-style-BhiGjxVU.js +21 -0
- package/dist/global-style-BhiGjxVU.js.map +1 -0
- package/dist/i18n.js +8 -11
- package/dist/i18n.js.map +1 -1
- package/dist/index.js +9 -55
- package/dist/island/client.js +2 -5
- package/dist/island/runtime.js +90 -107
- package/dist/island/runtime.js.map +1 -1
- package/dist/island.js +38 -56
- package/dist/island.js.map +1 -1
- package/dist/jsx-runtime-CI0Jmr-C.js +275 -0
- package/dist/jsx-runtime-CI0Jmr-C.js.map +1 -0
- package/dist/jsx-runtime.js +2 -31
- package/dist/middleware-CnDqZobD.js +217 -0
- package/dist/middleware-CnDqZobD.js.map +1 -0
- package/dist/middleware.js +3 -8
- package/dist/render-hUQUreah.js +152 -0
- package/dist/render-hUQUreah.js.map +1 -0
- package/dist/rolldown-runtime-B0aSnxlc.js +20 -0
- package/dist/router.js +72 -68
- package/dist/router.js.map +1 -1
- package/dist/seo.js +3 -7
- package/dist/server-5BEwGAL4.js +461 -0
- package/dist/server-5BEwGAL4.js.map +1 -0
- package/dist/server.js +2 -515
- package/dist/strategy-registry-wmHnsHQb.js +9 -0
- package/dist/strategy-registry-wmHnsHQb.js.map +1 -0
- package/dist/swap/server.js +11 -14
- package/dist/swap/server.js.map +1 -1
- package/dist/swap.js +109 -116
- package/dist/swap.js.map +1 -1
- package/dist/tooltip.js +145 -141
- package/dist/tooltip.js.map +1 -1
- package/dist/vite-plugin.js +315 -372
- package/dist/vite-plugin.js.map +1 -1
- package/package.json +8 -8
- package/src/core/bundler.ts +41 -25
- package/src/core/vite-plugin.ts +14 -15
- package/dist/client-D67hK4Yy.js +0 -9
- package/dist/client-D67hK4Yy.js.map +0 -1
- package/dist/defineMiddleware-VdHQuiUc.js +0 -7
- package/dist/defineMiddleware-VdHQuiUc.js.map +0 -1
- package/dist/exceptions-CHPz01DJ.js +0 -39
- package/dist/exceptions-CHPz01DJ.js.map +0 -1
- package/dist/generateMetadata-Cn8BIxq6.js +0 -144
- package/dist/generateMetadata-Cn8BIxq6.js.map +0 -1
- package/dist/global-style-DFvaBcuR.js +0 -27
- package/dist/global-style-DFvaBcuR.js.map +0 -1
- package/dist/index-CybB8Tdk.js +0 -315
- package/dist/index-CybB8Tdk.js.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/island/client.js.map +0 -1
- package/dist/jsx-runtime-DqAp8xlt.js +0 -296
- package/dist/jsx-runtime-DqAp8xlt.js.map +0 -1
- package/dist/jsx-runtime.js.map +0 -1
- package/dist/middleware.js.map +0 -1
- package/dist/render-CRag-5V7.js +0 -202
- package/dist/render-CRag-5V7.js.map +0 -1
- package/dist/seo.js.map +0 -1
- package/dist/server.js.map +0 -1
package/dist/vite-plugin.js
CHANGED
|
@@ -1,390 +1,333 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { existsSync as
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
1
|
+
import { t as e } from "./global-style-BhiGjxVU.js";
|
|
2
|
+
import { existsSync as t, mkdirSync as n, readFileSync as r, readdirSync as i, rmSync as a, statSync as o, writeFileSync as s } from "fs";
|
|
3
|
+
import { transform as c } from "esbuild";
|
|
4
|
+
import { dirname as l, join as u, relative as d, resolve as f } from "path";
|
|
5
|
+
//#region src/core/vite-plugin.ts
|
|
6
|
+
var p = "virtual:l5e-views", m = "virtual:l5e-route", h = "virtual:l5e-ssr-entry", g = "virtual:l5e-global-loader", _ = "virtual:l5e-island-strategies", v = "virtual:l5e-islands", y = "virtual:l5e-actions", b = "virtual:l5e-middleware", x = /* @__PURE__ */ new Set([
|
|
7
|
+
"MODE",
|
|
8
|
+
"BASE_URL",
|
|
9
|
+
"PROD",
|
|
10
|
+
"DEV",
|
|
11
|
+
"SSR",
|
|
12
|
+
"LEGACY"
|
|
13
|
+
]);
|
|
14
|
+
function S(e, t = []) {
|
|
15
|
+
let n = i(e);
|
|
16
|
+
for (let r of n) {
|
|
17
|
+
let n = u(e, r);
|
|
18
|
+
if (o(n).isDirectory()) {
|
|
19
|
+
if (r === "node_modules" || r === "dist" || r === ".git") continue;
|
|
20
|
+
S(n, t);
|
|
21
|
+
} else (r.endsWith(".tsx") || r.endsWith(".ts")) && t.push(n);
|
|
22
|
+
}
|
|
23
|
+
return t;
|
|
17
24
|
}
|
|
18
|
-
function
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
return Math.abs(o).toString(16).slice(0, 4);
|
|
25
|
+
function C(e) {
|
|
26
|
+
let t = 0;
|
|
27
|
+
for (let n = 0; n < e.length; n++) t = (t << 5) - t + e.charCodeAt(n), t &= t;
|
|
28
|
+
return Math.abs(t).toString(16).slice(0, 4);
|
|
23
29
|
}
|
|
24
|
-
function
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
return a = a.replace(/\.(tsx?|jsx?)$/, ""), a;
|
|
30
|
+
function w(e) {
|
|
31
|
+
let t = e.split("/"), n = t[t.length - 1];
|
|
32
|
+
return n = n.replace(/\.(tsx?|jsx?)$/, ""), n;
|
|
28
33
|
}
|
|
29
|
-
function
|
|
30
|
-
|
|
34
|
+
function T(e) {
|
|
35
|
+
return `${w(e)}_${C(e)}`;
|
|
31
36
|
}
|
|
32
|
-
function
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
37
|
+
function E(e, n) {
|
|
38
|
+
let r = e.replace(/^\//, ""), i = f(n, r);
|
|
39
|
+
for (let e of [
|
|
40
|
+
".tsx",
|
|
41
|
+
".ts",
|
|
42
|
+
".jsx",
|
|
43
|
+
".js"
|
|
44
|
+
]) if (t(i + e)) return r + e;
|
|
45
|
+
return t(i) ? r : null;
|
|
38
46
|
}
|
|
39
|
-
function
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
component: V(e),
|
|
64
|
-
resolvedPath: e,
|
|
65
|
-
src: d,
|
|
66
|
-
// "src/views/.../Counter.tsx" — matches manifest key format
|
|
67
|
-
key: u
|
|
68
|
-
}));
|
|
69
|
-
}
|
|
70
|
-
return i;
|
|
47
|
+
function D(e, t) {
|
|
48
|
+
let n = r(e, "utf-8"), i = [], a = /<ClientIsland\s[^>]*?from\s*=\s*"([^"]+)"/g, o = /* @__PURE__ */ new Set(), s;
|
|
49
|
+
for (; (s = a.exec(n)) !== null;) {
|
|
50
|
+
let n = s[1], r;
|
|
51
|
+
if (n.startsWith("~/")) r = "/src/" + n.substring(2);
|
|
52
|
+
else if (n.startsWith("/src/")) r = n;
|
|
53
|
+
else if (n.startsWith("./") || n.startsWith("../")) {
|
|
54
|
+
let i = f(e, "..", n);
|
|
55
|
+
r = "/" + d(t, i).replace(/\\/g, "/");
|
|
56
|
+
} else r = n;
|
|
57
|
+
let a = E(r, t);
|
|
58
|
+
if (!a) {
|
|
59
|
+
console.warn(`[l5e] Island component not found: ${r} (from ${n} in ${e})`);
|
|
60
|
+
continue;
|
|
61
|
+
}
|
|
62
|
+
let c = T(r);
|
|
63
|
+
o.has(c) || (o.add(c), i.push({
|
|
64
|
+
component: w(r),
|
|
65
|
+
resolvedPath: r,
|
|
66
|
+
src: a,
|
|
67
|
+
key: c
|
|
68
|
+
}));
|
|
69
|
+
}
|
|
70
|
+
return i;
|
|
71
71
|
}
|
|
72
|
-
function
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
}
|
|
95
|
-
return { css: i, js: t };
|
|
72
|
+
function O(e, t) {
|
|
73
|
+
let n = r(e, "utf-8"), i = [], a = [], o = /useCss\s*\(\s*['"]([^'"]+)['"]\s*,?\s*\)/g, s = /useClientJs\s*\(\s*['"]([^'"]+)['"]\s*,?\s*\)/g, c;
|
|
74
|
+
for (; (c = o.exec(n)) !== null;) {
|
|
75
|
+
let n = c[1];
|
|
76
|
+
if (n.startsWith("/src/")) i.push(n);
|
|
77
|
+
else if (n.startsWith("./") || n.startsWith("../")) {
|
|
78
|
+
let r = f(e, "..", n), a = "/" + d(t, r).replace(/\\/g, "/");
|
|
79
|
+
i.push(a);
|
|
80
|
+
} else i.push(n);
|
|
81
|
+
}
|
|
82
|
+
for (; (c = s.exec(n)) !== null;) {
|
|
83
|
+
let n = c[1];
|
|
84
|
+
if (n.startsWith("/src/")) a.push(n);
|
|
85
|
+
else if (n.startsWith("./") || n.startsWith("../")) {
|
|
86
|
+
let r = f(e, "..", n), i = "/" + d(t, r).replace(/\\/g, "/");
|
|
87
|
+
a.push(i);
|
|
88
|
+
} else a.push(n);
|
|
89
|
+
}
|
|
90
|
+
return {
|
|
91
|
+
css: i,
|
|
92
|
+
js: a
|
|
93
|
+
};
|
|
96
94
|
}
|
|
97
|
-
function
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
95
|
+
function k(n) {
|
|
96
|
+
let i = {}, a = u(n, "src"), s = /* @__PURE__ */ new Map(), c = /* @__PURE__ */ new Map(), p = /* @__PURE__ */ new Map(), m = /* @__PURE__ */ new Map();
|
|
97
|
+
try {
|
|
98
|
+
if (!o(a).isDirectory()) return {
|
|
99
|
+
input: i,
|
|
100
|
+
islandRegistry: s,
|
|
101
|
+
pathToKey: c,
|
|
102
|
+
keyToSrc: p,
|
|
103
|
+
actionRegistry: m
|
|
104
|
+
};
|
|
105
|
+
let h = u(n, "src", "client.global.ts");
|
|
106
|
+
t(h) && (i.global = h, console.log("[l5e] Detected src/client.global.ts and added as entry"));
|
|
107
|
+
let g = e(n);
|
|
108
|
+
g && (i["global-style"] = g, console.log("[l5e] Detected src/global.css and added as global stylesheet"));
|
|
109
|
+
let _ = S(a), v = /* @__PURE__ */ new Set(), y = /* @__PURE__ */ new Set();
|
|
110
|
+
for (let e of _) {
|
|
111
|
+
let { css: t, js: i } = O(e, n);
|
|
112
|
+
t.forEach((e) => v.add(e)), i.forEach((e) => y.add(e));
|
|
113
|
+
let o = D(e, n);
|
|
114
|
+
for (let e of o) s.set(e.key, e.resolvedPath), c.set(e.resolvedPath, e.key), p.set(e.key, e.src);
|
|
115
|
+
let u = e.replace(/\\/g, "/");
|
|
116
|
+
if (/\/actions\.(ts|tsx)$/.test(u)) {
|
|
117
|
+
let t = r(e, "utf-8"), n = /export\s+const\s+(\w+)\s*=\s*defineAction\s*\(/g, i, o = d(a, l(e)).replace(/\\/g, "/") || ".";
|
|
118
|
+
for (; (i = n.exec(t)) !== null;) {
|
|
119
|
+
let e = i[1], t = `${e}_${C(o)}`;
|
|
120
|
+
m.set(t, {
|
|
121
|
+
modulePath: o,
|
|
122
|
+
actionName: e
|
|
123
|
+
});
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
for (let e of v) {
|
|
128
|
+
let r = e.startsWith("/src/") || e.startsWith("/") ? e.substring(1) : e, a = f(n, r);
|
|
129
|
+
if (g && f(a) === f(g)) continue;
|
|
130
|
+
if (!t(a)) {
|
|
131
|
+
console.warn(`[l5e] CSS file not found: ${a} (from ${e})`);
|
|
132
|
+
continue;
|
|
133
|
+
}
|
|
134
|
+
let o = r.replace(/^src\//, "").replace(/\.css$/, "").replace(/\//g, "-").replace(/\\/g, "-");
|
|
135
|
+
i[o] = a;
|
|
136
|
+
}
|
|
137
|
+
for (let e of y) {
|
|
138
|
+
let r = e.startsWith("/src/") || e.startsWith("/") ? e.substring(1) : e, a = f(n, r);
|
|
139
|
+
if (!t(a)) {
|
|
140
|
+
console.warn(`[l5e] JS/TS file not found: ${a} (from ${e})`);
|
|
141
|
+
continue;
|
|
142
|
+
}
|
|
143
|
+
let o = r.replace(/^src\//, "").replace(/\.(ts|tsx|js|jsx)$/, "").replace(/\//g, "-").replace(/\\/g, "-");
|
|
144
|
+
i[o] = a;
|
|
145
|
+
}
|
|
146
|
+
for (let [e, t] of p) {
|
|
147
|
+
let r = f(n, t);
|
|
148
|
+
i[`island-${e}`] = r;
|
|
149
|
+
}
|
|
150
|
+
s.size > 0 && console.log(`[l5e] Detected ${s.size} island(s)`), m.size > 0 && console.log(`[l5e] Detected ${m.size} action(s)`);
|
|
151
|
+
} catch (e) {
|
|
152
|
+
console.warn("[l5e] Failed to discover bundler input:", e);
|
|
153
|
+
}
|
|
154
|
+
return {
|
|
155
|
+
input: i,
|
|
156
|
+
islandRegistry: s,
|
|
157
|
+
pathToKey: c,
|
|
158
|
+
keyToSrc: p,
|
|
159
|
+
actionRegistry: m
|
|
160
|
+
};
|
|
153
161
|
}
|
|
154
|
-
function
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
if (!p) continue;
|
|
175
|
-
const g = t.get(p);
|
|
176
|
-
if (!g) continue;
|
|
177
|
-
const x = d + m.index + m[0].length;
|
|
178
|
-
n.push(s.substring(c, x)), n.push(`, __key: "${p}", __src: "${g}"`), c = x;
|
|
179
|
-
}
|
|
180
|
-
return n.push(s.substring(c)), n.join("");
|
|
162
|
+
function A(e, t, n, r, i) {
|
|
163
|
+
let a = [], o = 0, s = /ClientIsland\s*,\s*\{/g, c;
|
|
164
|
+
for (; (c = s.exec(e)) !== null;) {
|
|
165
|
+
let s = c.index + c[0].length, l = e.substring(s, s + 500), u = /from:\s*"([^"]+)"/.exec(l);
|
|
166
|
+
if (!u) continue;
|
|
167
|
+
let p = u[1], m;
|
|
168
|
+
if (p.startsWith("~/")) m = "/src/" + p.substring(2);
|
|
169
|
+
else if (p.startsWith("/src/")) m = p;
|
|
170
|
+
else if (p.startsWith("./") || p.startsWith("../")) {
|
|
171
|
+
let e = f(t, "..", p);
|
|
172
|
+
m = "/" + d(n, e).replace(/\\/g, "/");
|
|
173
|
+
} else m = p;
|
|
174
|
+
let h = r.get(m);
|
|
175
|
+
if (!h) continue;
|
|
176
|
+
let g = i.get(h);
|
|
177
|
+
if (!g) continue;
|
|
178
|
+
let _ = s + u.index + u[0].length;
|
|
179
|
+
a.push(e.substring(o, _)), a.push(`, __key: "${h}", __src: "${g}"`), o = _;
|
|
180
|
+
}
|
|
181
|
+
return a.push(e.substring(o)), a.join("");
|
|
181
182
|
}
|
|
182
|
-
function
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
}
|
|
267
|
-
if (r.length > 0)
|
|
268
|
-
return {
|
|
269
|
-
code: r.map(({ name: g, method: x }) => {
|
|
270
|
-
const h = `${g}_${A(u)}`;
|
|
271
|
-
return x === "GET" ? `export async function ${g}(params) {
|
|
272
|
-
const res = await fetch('/_l5e/action/${h}?' + new URLSearchParams(params));
|
|
183
|
+
function j() {
|
|
184
|
+
let e = process.cwd(), r = /* @__PURE__ */ new Map(), i = /* @__PURE__ */ new Map(), o = /* @__PURE__ */ new Map();
|
|
185
|
+
return {
|
|
186
|
+
name: "l5e-jsx-classic",
|
|
187
|
+
enforce: "pre",
|
|
188
|
+
configResolved(t) {
|
|
189
|
+
e = t.root || process.cwd();
|
|
190
|
+
},
|
|
191
|
+
handleHotUpdate({ file: t, server: n }) {
|
|
192
|
+
let r = d(e, t);
|
|
193
|
+
if (/actions\.(ts|tsx)$/.test(t)) {
|
|
194
|
+
o = k(e).actionRegistry;
|
|
195
|
+
let t = n.moduleGraph.getModuleById("\0virtual:l5e-actions");
|
|
196
|
+
t && n.moduleGraph.invalidateModule(t), console.log(`[l5e] Action file changed: ${r} — re-scanned ${o.size} action(s)`);
|
|
197
|
+
}
|
|
198
|
+
if (t.endsWith(".css")) {
|
|
199
|
+
console.log(`[l5e] CSS changed: ${r} - using Vite HMR`);
|
|
200
|
+
return;
|
|
201
|
+
}
|
|
202
|
+
if (t.includes("client.ts")) {
|
|
203
|
+
console.log(`[l5e] Client JS changed: ${r} - using Vite HMR`);
|
|
204
|
+
return;
|
|
205
|
+
}
|
|
206
|
+
if (t.includes("/src/") || t.includes("\\src\\")) return console.log(`[l5e] SSR file changed: ${r} - triggering full reload`), n.ws.send({
|
|
207
|
+
type: "full-reload",
|
|
208
|
+
path: "*"
|
|
209
|
+
}), [];
|
|
210
|
+
},
|
|
211
|
+
buildEnd() {
|
|
212
|
+
let n = u(e, ".l5e-temp");
|
|
213
|
+
if (t(n)) try {
|
|
214
|
+
a(n, {
|
|
215
|
+
recursive: !0,
|
|
216
|
+
force: !0
|
|
217
|
+
}), console.log("[l5e] Cleaned up temporary files");
|
|
218
|
+
} catch (e) {
|
|
219
|
+
console.warn("[l5e] Failed to cleanup temporary files:", e);
|
|
220
|
+
}
|
|
221
|
+
},
|
|
222
|
+
writeBundle(r, i) {
|
|
223
|
+
if (o.size > 0) {
|
|
224
|
+
let r = u(e, "dist", "server");
|
|
225
|
+
t(r) || n(r, { recursive: !0 });
|
|
226
|
+
let i = Object.fromEntries(o);
|
|
227
|
+
s(u(r, "action-registry.json"), JSON.stringify(i), "utf-8"), console.log(`[l5e] Wrote action-registry.json (${o.size} actions)`);
|
|
228
|
+
}
|
|
229
|
+
},
|
|
230
|
+
config(e) {
|
|
231
|
+
let t = k(e.root || process.cwd());
|
|
232
|
+
t.islandRegistry, r = t.pathToKey, i = t.keyToSrc, o = t.actionRegistry;
|
|
233
|
+
let n = e.build?.rolldownOptions?.input || {}, a = typeof n == "object" && !Array.isArray(n) ? {
|
|
234
|
+
...t.input,
|
|
235
|
+
...n
|
|
236
|
+
} : t.input;
|
|
237
|
+
return { build: { rolldownOptions: {
|
|
238
|
+
...e.build?.rolldownOptions,
|
|
239
|
+
input: Object.keys(a).length > 0 ? a : void 0,
|
|
240
|
+
preserveEntrySignatures: "exports-only"
|
|
241
|
+
} } };
|
|
242
|
+
},
|
|
243
|
+
resolveId(e) {
|
|
244
|
+
return e === p ? "\0virtual:l5e-views" : e === m ? "\0virtual:l5e-route" : e === h ? "\0virtual:l5e-ssr-entry" : e === g ? "\0virtual:l5e-global-loader" : e === _ ? "\0virtual:l5e-island-strategies" : e === v ? "\0virtual:l5e-islands" : e === y ? "\0virtual:l5e-actions" : e === b ? "\0virtual:l5e-middleware" : null;
|
|
245
|
+
},
|
|
246
|
+
async transform(t, n, a) {
|
|
247
|
+
if (n.replace(/\\/g, "/").endsWith("src/client.global.ts") && !a?.ssr) return {
|
|
248
|
+
code: `import '@withl5e/l5e/island/runtime';\n${t}`,
|
|
249
|
+
map: null
|
|
250
|
+
};
|
|
251
|
+
if (!a?.ssr) {
|
|
252
|
+
let e = n.replace(/\\/g, "/").match(/\/src\/(.+)\/actions\.(ts|tsx)$/);
|
|
253
|
+
if (e) {
|
|
254
|
+
let n = e[1], r = /export\s+const\s+(\w+)\s*=\s*defineAction\s*\(/g, i = [], a;
|
|
255
|
+
for (; (a = r.exec(t)) !== null;) {
|
|
256
|
+
let e = a[1], n = t.substring(a.index, a.index + 500).match(/method:\s*['"](\w+)['"]/), r = n ? n[1].toUpperCase() : "GET";
|
|
257
|
+
i.push({
|
|
258
|
+
name: e,
|
|
259
|
+
method: r
|
|
260
|
+
});
|
|
261
|
+
}
|
|
262
|
+
if (i.length > 0) return {
|
|
263
|
+
code: i.map(({ name: e, method: t }) => {
|
|
264
|
+
let r = `${e}_${C(n)}`;
|
|
265
|
+
return t === "GET" ? `export async function ${e}(params) {
|
|
266
|
+
const res = await fetch('/_l5e/action/${r}?' + new URLSearchParams(params));
|
|
273
267
|
if (!res.ok) throw Object.assign(new Error('HTTP ' + res.status), { status: res.status });
|
|
274
268
|
return res;
|
|
275
|
-
}` : `export async function ${
|
|
276
|
-
const res = await fetch('/_l5e/action/${
|
|
277
|
-
method: '${
|
|
269
|
+
}` : `export async function ${e}(body) {
|
|
270
|
+
const res = await fetch('/_l5e/action/${r}', {
|
|
271
|
+
method: '${t}',
|
|
278
272
|
headers: { 'Content-Type': 'application/json' },
|
|
279
273
|
body: JSON.stringify(body),
|
|
280
274
|
});
|
|
281
275
|
if (!res.ok) throw Object.assign(new Error('HTTP ' + res.status), { status: res.status });
|
|
282
276
|
return res;
|
|
283
277
|
}`;
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
`;
|
|
336
|
-
if (t === "\0" + v)
|
|
337
|
-
return `export default function routeHandler(requestInfo) {
|
|
338
|
-
return import('/src/route.ts').then((mod) => mod.default(requestInfo));
|
|
339
|
-
}`;
|
|
340
|
-
if (t === "\0" + _)
|
|
341
|
-
return `export { render } from '@withl5e/l5e/entry-server';
|
|
342
|
-
export { viewActions } from 'virtual:l5e-actions';`;
|
|
343
|
-
if (t === "\0" + E)
|
|
344
|
-
return "export const globalLoader = import.meta.glob('/src/global-loader.{ts,tsx}', { eager: false });";
|
|
345
|
-
if (t === "\0" + $) {
|
|
346
|
-
const n = Object.fromEntries(i);
|
|
347
|
-
return `export const viewActions = import.meta.glob('/src/**/actions.{ts,tsx}');
|
|
348
|
-
export const actionRegistry = ${JSON.stringify(n)};`;
|
|
349
|
-
}
|
|
350
|
-
if (t === "\0" + P)
|
|
351
|
-
return `
|
|
352
|
-
const middlewareModules = import.meta.glob([
|
|
353
|
-
'/src/middleware.{ts,tsx,js,jsx}',
|
|
354
|
-
'/src/middleware/index.{ts,tsx,js,jsx}',
|
|
355
|
-
]);
|
|
356
|
-
|
|
357
|
-
const middlewarePaths = [
|
|
358
|
-
'/src/middleware.ts',
|
|
359
|
-
'/src/middleware.tsx',
|
|
360
|
-
'/src/middleware.js',
|
|
361
|
-
'/src/middleware.jsx',
|
|
362
|
-
'/src/middleware/index.ts',
|
|
363
|
-
'/src/middleware/index.tsx',
|
|
364
|
-
'/src/middleware/index.js',
|
|
365
|
-
'/src/middleware/index.jsx',
|
|
366
|
-
];
|
|
367
|
-
|
|
368
|
-
export async function loadMiddleware() {
|
|
369
|
-
const middlewarePath = middlewarePaths.find((path) => middlewareModules[path]);
|
|
370
|
-
if (!middlewarePath) return undefined;
|
|
371
|
-
|
|
372
|
-
const mod = await middlewareModules[middlewarePath]();
|
|
373
|
-
return mod.onRequest;
|
|
278
|
+
}).join("\n\n"),
|
|
279
|
+
map: null
|
|
280
|
+
};
|
|
281
|
+
}
|
|
282
|
+
}
|
|
283
|
+
if (n.includes("node_modules") || n.includes("/react/") || n.includes("\\react\\")) return null;
|
|
284
|
+
if (/\.(tsx|jsx)$/.test(n)) try {
|
|
285
|
+
let a = `import { Fragment as __Fragment, jsxFactory } from "@withl5e/l5e/jsx-runtime"\n${t}`, o = await c(a, {
|
|
286
|
+
loader: n.endsWith(".tsx") ? "tsx" : "jsx",
|
|
287
|
+
jsx: "transform",
|
|
288
|
+
jsxFactory: "jsxFactory",
|
|
289
|
+
jsxFragment: "__Fragment",
|
|
290
|
+
sourcemap: !0,
|
|
291
|
+
sourcefile: n,
|
|
292
|
+
target: "es2020"
|
|
293
|
+
}), s = o.code;
|
|
294
|
+
return s.includes("ClientIsland") && (s = A(s, n, e, r, i)), {
|
|
295
|
+
code: s,
|
|
296
|
+
map: o.map || null
|
|
297
|
+
};
|
|
298
|
+
} catch (e) {
|
|
299
|
+
throw console.error(`[l5e] Failed to transform JSX in ${n}:`, e), e;
|
|
300
|
+
}
|
|
301
|
+
if (a?.ssr) {
|
|
302
|
+
let e = t, n = !1;
|
|
303
|
+
if (e = e.replace(/import\.meta\.env\.([a-zA-Z_][a-zA-Z0-9_]*)/g, (e, t) => x.has(t) ? e : (n = !0, `process.env.${t}`)), e = e.replace(/import\.meta\.env\[(['"`])([^'"`]+)\1\]/g, (e, t, r) => x.has(r) ? e : (n = !0, `process.env[${t}${r}${t}]`)), n) return {
|
|
304
|
+
code: e,
|
|
305
|
+
map: null
|
|
306
|
+
};
|
|
307
|
+
}
|
|
308
|
+
return null;
|
|
309
|
+
},
|
|
310
|
+
load(n) {
|
|
311
|
+
if (n === "\0virtual:l5e-views") return "\nexport const viewLoaders = import.meta.glob('/src/views/*/loader.{ts,tsx}');\nexport const viewComponents = import.meta.glob('/src/views/*/index.tsx');\n";
|
|
312
|
+
if (n === "\0virtual:l5e-route") return "export default function routeHandler(requestInfo) {\n return import('/src/route.ts').then((mod) => mod.default(requestInfo));\n}";
|
|
313
|
+
if (n === "\0virtual:l5e-ssr-entry") return "export { render } from '@withl5e/l5e/entry-server';\nexport { viewActions } from 'virtual:l5e-actions';";
|
|
314
|
+
if (n === "\0virtual:l5e-global-loader") return "export const globalLoader = import.meta.glob('/src/global-loader.{ts,tsx}', { eager: false });";
|
|
315
|
+
if (n === "\0virtual:l5e-actions") {
|
|
316
|
+
let e = Object.fromEntries(o);
|
|
317
|
+
return `export const viewActions = import.meta.glob('/src/**/actions.{ts,tsx}');
|
|
318
|
+
export const actionRegistry = ${JSON.stringify(e)};`;
|
|
319
|
+
}
|
|
320
|
+
if (n === "\0virtual:l5e-middleware") return "\nconst middlewareModules = import.meta.glob([\n '/src/middleware.{ts,tsx,js,jsx}',\n '/src/middleware/index.{ts,tsx,js,jsx}',\n]);\n\nconst middlewarePaths = [\n '/src/middleware.ts',\n '/src/middleware.tsx',\n '/src/middleware.js',\n '/src/middleware.jsx',\n '/src/middleware/index.ts',\n '/src/middleware/index.tsx',\n '/src/middleware/index.js',\n '/src/middleware/index.jsx',\n];\n\nexport async function loadMiddleware() {\n const middlewarePath = middlewarePaths.find((path) => middlewareModules[path]);\n if (!middlewarePath) return undefined;\n\n const mod = await middlewareModules[middlewarePath]();\n return mod.onRequest;\n}\n";
|
|
321
|
+
if (n === "\0virtual:l5e-islands") return "export const islandModules = import.meta.glob('/src/**/react/*.{tsx,jsx}');";
|
|
322
|
+
if (n === "\0virtual:l5e-island-strategies") {
|
|
323
|
+
let n = u(e, "src", "island-strategies.ts");
|
|
324
|
+
return t(n) ? "import '/src/island-strategies.ts';" : "/* no custom island strategies */";
|
|
325
|
+
}
|
|
326
|
+
return null;
|
|
327
|
+
}
|
|
328
|
+
};
|
|
374
329
|
}
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
const n = b(s, "src", "island-strategies.ts");
|
|
380
|
-
return w(n) ? "import '/src/island-strategies.ts';" : "/* no custom island strategies */";
|
|
381
|
-
}
|
|
382
|
-
return null;
|
|
383
|
-
}
|
|
384
|
-
};
|
|
385
|
-
}
|
|
386
|
-
export {
|
|
387
|
-
ot as coreVite,
|
|
388
|
-
ot as default
|
|
389
|
-
};
|
|
390
|
-
//# sourceMappingURL=vite-plugin.js.map
|
|
330
|
+
//#endregion
|
|
331
|
+
export { j as coreVite, j as default };
|
|
332
|
+
|
|
333
|
+
//# sourceMappingURL=vite-plugin.js.map
|