@withl5e/l5e 0.2.3 → 0.2.5
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/entry-server.js +123 -90
- package/dist/entry-server.js.map +1 -1
- package/dist/{generateMetadata-DLMaI0EO.js → generateMetadata-CIFVlViV.js} +4 -4
- package/dist/{generateMetadata-DLMaI0EO.js.map → generateMetadata-CIFVlViV.js.map} +1 -1
- package/dist/index.js +39 -37
- package/dist/island/runtime.js +9 -8
- package/dist/island/runtime.js.map +1 -1
- package/dist/island.js +36 -23
- package/dist/island.js.map +1 -1
- package/dist/{jsx-runtime-DVQ9eOji.js → jsx-runtime-Bokflh8Q.js} +68 -55
- package/dist/jsx-runtime-Bokflh8Q.js.map +1 -0
- package/dist/jsx-runtime.js +12 -10
- package/dist/{render-BF7iTagJ.js → render-DTXfJu0d.js} +2 -2
- package/dist/{render-BF7iTagJ.js.map → render-DTXfJu0d.js.map} +1 -1
- package/dist/seo.js +2 -2
- package/dist/server.js +2 -2
- package/dist/server.js.map +1 -1
- package/dist/vite-plugin.js +69 -67
- package/dist/vite-plugin.js.map +1 -1
- package/package.json +22 -2
- package/src/core/entry-server.ts +67 -1
- package/src/core/jsx-runtime.ts +33 -0
- package/src/core/server.ts +6 -3
- package/src/core/vite-plugin.ts +12 -0
- package/src/island/ClientIsland.ts +36 -1
- package/src/island/runtime.ts +10 -3
- package/src/island/types.ts +1 -0
- package/dist/jsx-runtime-DVQ9eOji.js.map +0 -1
package/dist/vite-plugin.js
CHANGED
|
@@ -1,41 +1,41 @@
|
|
|
1
1
|
import { transform as z } from "esbuild";
|
|
2
|
-
import { existsSync as w, mkdirSync as
|
|
3
|
-
import { join as b, relative as S, resolve as y, dirname as
|
|
4
|
-
const j = "virtual:l5e-views", v = "virtual:l5e-route", _ = "virtual:l5e-ssr-entry", E = "virtual:l5e-global-loader", R = "virtual:l5e-island-strategies", $ = "virtual:l5e-actions",
|
|
5
|
-
function
|
|
6
|
-
const l =
|
|
2
|
+
import { existsSync as w, mkdirSync as J, writeFileSync as D, rmSync as N, statSync as O, readFileSync as T, readdirSync as G } from "fs";
|
|
3
|
+
import { join as b, relative as S, resolve as y, dirname as K } from "path";
|
|
4
|
+
const j = "virtual:l5e-views", v = "virtual:l5e-route", _ = "virtual:l5e-ssr-entry", E = "virtual:l5e-global-loader", R = "virtual:l5e-island-strategies", P = "virtual:l5e-islands", $ = "virtual:l5e-actions", I = "virtual:l5e-middleware", F = /* @__PURE__ */ new Set(["MODE", "BASE_URL", "PROD", "DEV", "SSR", "LEGACY"]);
|
|
5
|
+
function k(s, o = []) {
|
|
6
|
+
const l = G(s);
|
|
7
7
|
for (const i of l) {
|
|
8
8
|
const t = b(s, i);
|
|
9
|
-
if (
|
|
9
|
+
if (O(t).isDirectory()) {
|
|
10
10
|
if (i === "node_modules" || i === "dist" || i === ".git")
|
|
11
11
|
continue;
|
|
12
|
-
|
|
12
|
+
k(t, o);
|
|
13
13
|
} else (i.endsWith(".tsx") || i.endsWith(".ts")) && o.push(t);
|
|
14
14
|
}
|
|
15
15
|
return o;
|
|
16
16
|
}
|
|
17
|
-
function
|
|
17
|
+
function A(s) {
|
|
18
18
|
let o = 0;
|
|
19
19
|
for (let l = 0; l < s.length; l++)
|
|
20
20
|
o = (o << 5) - o + s.charCodeAt(l), o = o & o;
|
|
21
21
|
return Math.abs(o).toString(16).slice(0, 4);
|
|
22
22
|
}
|
|
23
|
-
function
|
|
23
|
+
function V(s) {
|
|
24
24
|
const o = s.split("/");
|
|
25
25
|
let l = o[o.length - 1];
|
|
26
26
|
return l = l.replace(/\.(tsx?|jsx?)$/, ""), l;
|
|
27
27
|
}
|
|
28
|
-
function
|
|
29
|
-
return `${
|
|
28
|
+
function H(s) {
|
|
29
|
+
return `${V(s)}_${A(s)}`;
|
|
30
30
|
}
|
|
31
|
-
function
|
|
31
|
+
function B(s, o) {
|
|
32
32
|
const l = s.replace(/^\//, ""), i = y(o, l);
|
|
33
33
|
for (const t of [".tsx", ".ts", ".jsx", ".js"])
|
|
34
34
|
if (w(i + t))
|
|
35
35
|
return l + t;
|
|
36
36
|
return w(i) ? l : null;
|
|
37
37
|
}
|
|
38
|
-
function
|
|
38
|
+
function Y(s, o) {
|
|
39
39
|
const l = T(s, "utf-8"), i = [], t = /<ClientIsland\s[^>]*?from\s*=\s*"([^"]+)"/g, n = /* @__PURE__ */ new Set();
|
|
40
40
|
let c;
|
|
41
41
|
for (; (c = t.exec(l)) !== null; ) {
|
|
@@ -50,16 +50,16 @@ function B(s, o) {
|
|
|
50
50
|
e = "/" + S(o, r).replace(/\\/g, "/");
|
|
51
51
|
} else
|
|
52
52
|
e = a;
|
|
53
|
-
const d =
|
|
53
|
+
const d = B(e, o);
|
|
54
54
|
if (!d) {
|
|
55
55
|
console.warn(
|
|
56
56
|
`[l5e] Island component not found: ${e} (from ${a} in ${s})`
|
|
57
57
|
);
|
|
58
58
|
continue;
|
|
59
59
|
}
|
|
60
|
-
const f =
|
|
60
|
+
const f = H(e);
|
|
61
61
|
n.has(f) || (n.add(f), i.push({
|
|
62
|
-
component:
|
|
62
|
+
component: V(e),
|
|
63
63
|
resolvedPath: e,
|
|
64
64
|
src: d,
|
|
65
65
|
// "src/views/.../Counter.tsx" — matches manifest key format
|
|
@@ -68,7 +68,7 @@ function B(s, o) {
|
|
|
68
68
|
}
|
|
69
69
|
return i;
|
|
70
70
|
}
|
|
71
|
-
function
|
|
71
|
+
function Z(s, o) {
|
|
72
72
|
const l = T(s, "utf-8"), i = [], t = [], n = /useCss\s*\(\s*['"]([^'"]+)['"]\s*,?\s*\)/g, c = /useClientJs\s*\(\s*['"]([^'"]+)['"]\s*,?\s*\)/g;
|
|
73
73
|
let a;
|
|
74
74
|
for (; (a = n.exec(l)) !== null; ) {
|
|
@@ -93,52 +93,52 @@ function Y(s, o) {
|
|
|
93
93
|
}
|
|
94
94
|
return { css: i, js: t };
|
|
95
95
|
}
|
|
96
|
-
function
|
|
96
|
+
function C(s) {
|
|
97
97
|
const o = {}, l = b(s, "src"), i = /* @__PURE__ */ new Map(), t = /* @__PURE__ */ new Map(), n = /* @__PURE__ */ new Map(), c = /* @__PURE__ */ new Map();
|
|
98
98
|
try {
|
|
99
|
-
if (!
|
|
99
|
+
if (!O(l).isDirectory())
|
|
100
100
|
return { input: o, islandRegistry: i, pathToKey: t, keyToSrc: n, actionRegistry: c };
|
|
101
101
|
const a = b(s, "src", "client.global.ts");
|
|
102
102
|
w(a) && (o.global = a, console.log("[l5e] Detected src/client.global.ts and added as entry"));
|
|
103
|
-
const e =
|
|
103
|
+
const e = k(l), d = /* @__PURE__ */ new Set(), f = /* @__PURE__ */ new Set();
|
|
104
104
|
for (const r of e) {
|
|
105
|
-
const { css: u, js:
|
|
106
|
-
u.forEach((
|
|
107
|
-
const m =
|
|
108
|
-
for (const
|
|
109
|
-
i.set(
|
|
105
|
+
const { css: u, js: p } = Z(r, s);
|
|
106
|
+
u.forEach((h) => d.add(h)), p.forEach((h) => f.add(h));
|
|
107
|
+
const m = Y(r, s);
|
|
108
|
+
for (const h of m)
|
|
109
|
+
i.set(h.key, h.resolvedPath), t.set(h.resolvedPath, h.key), n.set(h.key, h.src);
|
|
110
110
|
const g = r.replace(/\\/g, "/");
|
|
111
111
|
if (/\/actions\.(ts|tsx)$/.test(g)) {
|
|
112
|
-
const
|
|
112
|
+
const h = T(r, "utf-8"), x = /export\s+const\s+(\w+)\s*=\s*defineAction\s*\(/g;
|
|
113
113
|
let W;
|
|
114
|
-
const
|
|
115
|
-
for (; (W = x.exec(
|
|
116
|
-
const M = W[1],
|
|
117
|
-
c.set(
|
|
114
|
+
const L = S(l, K(r)).replace(/\\/g, "/") || ".";
|
|
115
|
+
for (; (W = x.exec(h)) !== null; ) {
|
|
116
|
+
const M = W[1], U = `${M}_${A(L)}`;
|
|
117
|
+
c.set(U, { modulePath: L, actionName: M });
|
|
118
118
|
}
|
|
119
119
|
}
|
|
120
120
|
}
|
|
121
121
|
for (const r of d) {
|
|
122
|
-
const u = r.startsWith("/src/") || r.startsWith("/") ? r.substring(1) : r,
|
|
123
|
-
if (!w(
|
|
124
|
-
console.warn(`[l5e] CSS file not found: ${
|
|
122
|
+
const u = r.startsWith("/src/") || r.startsWith("/") ? r.substring(1) : r, p = y(s, u);
|
|
123
|
+
if (!w(p)) {
|
|
124
|
+
console.warn(`[l5e] CSS file not found: ${p} (from ${r})`);
|
|
125
125
|
continue;
|
|
126
126
|
}
|
|
127
127
|
const m = u.replace(/^src\//, "").replace(/\.css$/, "").replace(/\//g, "-").replace(/\\/g, "-");
|
|
128
|
-
o[m] =
|
|
128
|
+
o[m] = p;
|
|
129
129
|
}
|
|
130
130
|
for (const r of f) {
|
|
131
|
-
const u = r.startsWith("/src/") || r.startsWith("/") ? r.substring(1) : r,
|
|
132
|
-
if (!w(
|
|
133
|
-
console.warn(`[l5e] JS/TS file not found: ${
|
|
131
|
+
const u = r.startsWith("/src/") || r.startsWith("/") ? r.substring(1) : r, p = y(s, u);
|
|
132
|
+
if (!w(p)) {
|
|
133
|
+
console.warn(`[l5e] JS/TS file not found: ${p} (from ${r})`);
|
|
134
134
|
continue;
|
|
135
135
|
}
|
|
136
136
|
const m = u.replace(/^src\//, "").replace(/\.(ts|tsx|js|jsx)$/, "").replace(/\//g, "-").replace(/\\/g, "-");
|
|
137
|
-
o[m] =
|
|
137
|
+
o[m] = p;
|
|
138
138
|
}
|
|
139
139
|
for (const [r, u] of n) {
|
|
140
|
-
const
|
|
141
|
-
o[`island-${r}`] =
|
|
140
|
+
const p = y(s, u);
|
|
141
|
+
o[`island-${r}`] = p;
|
|
142
142
|
}
|
|
143
143
|
i.size > 0 && console.log(`[l5e] Detected ${i.size} island(s)`), c.size > 0 && console.log(`[l5e] Detected ${c.size} action(s)`);
|
|
144
144
|
} catch (a) {
|
|
@@ -146,7 +146,7 @@ function L(s) {
|
|
|
146
146
|
}
|
|
147
147
|
return { input: o, islandRegistry: i, pathToKey: t, keyToSrc: n, actionRegistry: c };
|
|
148
148
|
}
|
|
149
|
-
function
|
|
149
|
+
function X(s, o, l, i, t) {
|
|
150
150
|
const n = [];
|
|
151
151
|
let c = 0;
|
|
152
152
|
const a = /ClientIsland\s*,\s*\{/g;
|
|
@@ -155,26 +155,26 @@ function Z(s, o, l, i, t) {
|
|
|
155
155
|
const d = e.index + e[0].length, f = s.substring(d, d + 500), r = /from:\s*"([^"]+)"/.exec(f);
|
|
156
156
|
if (!r) continue;
|
|
157
157
|
const u = r[1];
|
|
158
|
-
let
|
|
158
|
+
let p;
|
|
159
159
|
if (u.startsWith("~/"))
|
|
160
|
-
|
|
160
|
+
p = "/src/" + u.substring(2);
|
|
161
161
|
else if (u.startsWith("/src/"))
|
|
162
|
-
|
|
162
|
+
p = u;
|
|
163
163
|
else if (u.startsWith("./") || u.startsWith("../")) {
|
|
164
164
|
const x = y(o, "..", u);
|
|
165
|
-
|
|
165
|
+
p = "/" + S(l, x).replace(/\\/g, "/");
|
|
166
166
|
} else
|
|
167
|
-
|
|
168
|
-
const m = i.get(
|
|
167
|
+
p = u;
|
|
168
|
+
const m = i.get(p);
|
|
169
169
|
if (!m) continue;
|
|
170
170
|
const g = t.get(m);
|
|
171
171
|
if (!g) continue;
|
|
172
|
-
const
|
|
173
|
-
n.push(s.substring(c,
|
|
172
|
+
const h = d + r.index + r[0].length;
|
|
173
|
+
n.push(s.substring(c, h)), n.push(`, __key: "${m}", __src: "${g}"`), c = h;
|
|
174
174
|
}
|
|
175
175
|
return n.push(s.substring(c)), n.join("");
|
|
176
176
|
}
|
|
177
|
-
function
|
|
177
|
+
function st() {
|
|
178
178
|
let s = process.cwd(), o = /* @__PURE__ */ new Map(), l = /* @__PURE__ */ new Map(), i = /* @__PURE__ */ new Map();
|
|
179
179
|
return {
|
|
180
180
|
name: "l5e-jsx-classic",
|
|
@@ -185,7 +185,7 @@ function et() {
|
|
|
185
185
|
handleHotUpdate({ file: t, server: n }) {
|
|
186
186
|
const c = S(s, t);
|
|
187
187
|
if (/actions\.(ts|tsx)$/.test(t)) {
|
|
188
|
-
i =
|
|
188
|
+
i = C(s).actionRegistry;
|
|
189
189
|
const e = n.moduleGraph.getModuleById("\0" + $);
|
|
190
190
|
e && n.moduleGraph.invalidateModule(e), console.log(
|
|
191
191
|
`[l5e] Action file changed: ${c} — re-scanned ${i.size} action(s)`
|
|
@@ -209,7 +209,7 @@ function et() {
|
|
|
209
209
|
const t = b(s, ".l5e-temp");
|
|
210
210
|
if (w(t))
|
|
211
211
|
try {
|
|
212
|
-
|
|
212
|
+
N(t, { recursive: !0, force: !0 }), console.log("[l5e] Cleaned up temporary files");
|
|
213
213
|
} catch (n) {
|
|
214
214
|
console.warn("[l5e] Failed to cleanup temporary files:", n);
|
|
215
215
|
}
|
|
@@ -217,13 +217,13 @@ function et() {
|
|
|
217
217
|
writeBundle(t, n) {
|
|
218
218
|
if (i.size > 0) {
|
|
219
219
|
const c = b(s, "dist", "server");
|
|
220
|
-
w(c) ||
|
|
220
|
+
w(c) || J(c, { recursive: !0 });
|
|
221
221
|
const a = Object.fromEntries(i);
|
|
222
|
-
|
|
222
|
+
D(b(c, "action-registry.json"), JSON.stringify(a), "utf-8"), console.log(`[l5e] Wrote action-registry.json (${i.size} actions)`);
|
|
223
223
|
}
|
|
224
224
|
},
|
|
225
225
|
config(t) {
|
|
226
|
-
const n = t.root || process.cwd(), c =
|
|
226
|
+
const n = t.root || process.cwd(), c = C(n);
|
|
227
227
|
c.islandRegistry, o = c.pathToKey, l = c.keyToSrc, i = c.actionRegistry;
|
|
228
228
|
const a = t.build?.rollupOptions?.input || {}, e = typeof a == "object" && !Array.isArray(a) ? { ...c.input, ...a } : c.input;
|
|
229
229
|
return {
|
|
@@ -241,7 +241,7 @@ function et() {
|
|
|
241
241
|
};
|
|
242
242
|
},
|
|
243
243
|
resolveId(t) {
|
|
244
|
-
return t === j ? "\0" + j : t === v ? "\0" + v : t === _ ? "\0" + _ : t === E ? "\0" + E : t === R ? "\0" + R : t === $ ? "\0" + $ : t ===
|
|
244
|
+
return t === j ? "\0" + j : t === v ? "\0" + v : t === _ ? "\0" + _ : t === E ? "\0" + E : t === R ? "\0" + R : t === P ? "\0" + P : t === $ ? "\0" + $ : t === I ? "\0" + I : null;
|
|
245
245
|
},
|
|
246
246
|
async transform(t, n, c) {
|
|
247
247
|
if (n.replace(/\\/g, "/").endsWith("src/client.global.ts") && !c?.ssr)
|
|
@@ -254,22 +254,22 @@ ${t}`,
|
|
|
254
254
|
const d = n.replace(/\\/g, "/").match(/\/src\/(.+)\/actions\.(ts|tsx)$/);
|
|
255
255
|
if (d) {
|
|
256
256
|
const f = d[1], r = /export\s+const\s+(\w+)\s*=\s*defineAction\s*\(/g, u = [];
|
|
257
|
-
let
|
|
258
|
-
for (; (
|
|
259
|
-
const m =
|
|
257
|
+
let p;
|
|
258
|
+
for (; (p = r.exec(t)) !== null; ) {
|
|
259
|
+
const m = p[1], h = t.substring(p.index, p.index + 500).match(/method:\s*['"](\w+)['"]/), x = h ? h[1].toUpperCase() : "GET";
|
|
260
260
|
u.push({ name: m, method: x });
|
|
261
261
|
}
|
|
262
262
|
if (u.length > 0)
|
|
263
263
|
return {
|
|
264
|
-
code: u.map(({ name: g, method:
|
|
265
|
-
const x = `${g}_${
|
|
266
|
-
return
|
|
264
|
+
code: u.map(({ name: g, method: h }) => {
|
|
265
|
+
const x = `${g}_${A(f)}`;
|
|
266
|
+
return h === "GET" ? `export async function ${g}(params) {
|
|
267
267
|
const res = await fetch('/_l5e/action/${x}?' + new URLSearchParams(params));
|
|
268
268
|
if (!res.ok) throw Object.assign(new Error('HTTP ' + res.status), { status: res.status });
|
|
269
269
|
return res;
|
|
270
270
|
}` : `export async function ${g}(body) {
|
|
271
271
|
const res = await fetch('/_l5e/action/${x}', {
|
|
272
|
-
method: '${
|
|
272
|
+
method: '${h}',
|
|
273
273
|
headers: { 'Content-Type': 'application/json' },
|
|
274
274
|
body: JSON.stringify(body),
|
|
275
275
|
});
|
|
@@ -298,7 +298,7 @@ ${t}`, d = await z(e, {
|
|
|
298
298
|
target: "es2020"
|
|
299
299
|
});
|
|
300
300
|
let f = d.code;
|
|
301
|
-
return f.includes("ClientIsland") && (f =
|
|
301
|
+
return f.includes("ClientIsland") && (f = X(f, n, s, o, l)), {
|
|
302
302
|
code: f,
|
|
303
303
|
map: d.map || null
|
|
304
304
|
};
|
|
@@ -340,7 +340,7 @@ export { viewActions } from 'virtual:l5e-actions';`;
|
|
|
340
340
|
return `export const viewActions = import.meta.glob('/src/**/actions.{ts,tsx}');
|
|
341
341
|
export const actionRegistry = ${JSON.stringify(n)};`;
|
|
342
342
|
}
|
|
343
|
-
if (t === "\0" +
|
|
343
|
+
if (t === "\0" + I)
|
|
344
344
|
return `
|
|
345
345
|
const middlewareModules = import.meta.glob([
|
|
346
346
|
'/src/middleware.{ts,tsx,js,jsx}',
|
|
@@ -366,6 +366,8 @@ export async function loadMiddleware() {
|
|
|
366
366
|
return mod.onRequest;
|
|
367
367
|
}
|
|
368
368
|
`;
|
|
369
|
+
if (t === "\0" + P)
|
|
370
|
+
return "export const islandModules = import.meta.glob('/src/**/react/*.{tsx,jsx}');";
|
|
369
371
|
if (t === "\0" + R) {
|
|
370
372
|
const n = b(s, "src", "island-strategies.ts");
|
|
371
373
|
return w(n) ? "import '/src/island-strategies.ts';" : "/* no custom island strategies */";
|
|
@@ -375,7 +377,7 @@ export async function loadMiddleware() {
|
|
|
375
377
|
};
|
|
376
378
|
}
|
|
377
379
|
export {
|
|
378
|
-
|
|
379
|
-
|
|
380
|
+
st as coreVite,
|
|
381
|
+
st as default
|
|
380
382
|
};
|
|
381
383
|
//# sourceMappingURL=vite-plugin.js.map
|
package/dist/vite-plugin.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"vite-plugin.js","sources":["../src/core/vite-plugin.ts"],"sourcesContent":["import { transform } from 'esbuild';\nimport {\n existsSync,\n mkdirSync,\n readdirSync,\n readFileSync,\n rmSync,\n statSync,\n writeFileSync,\n} from 'fs';\nimport { dirname, join, relative, resolve } from 'path';\nimport type { Plugin, UserConfig } from 'vite';\n\nconst VIRTUAL_L5E_VIEWS = 'virtual:l5e-views';\nconst VIRTUAL_L5E_ROUTE = 'virtual:l5e-route';\nconst VIRTUAL_L5E_SSR_ENTRY = 'virtual:l5e-ssr-entry';\nconst VIRTUAL_L5E_GLOBAL_LOADER = 'virtual:l5e-global-loader';\nconst VIRTUAL_L5E_ISLAND_STRATEGIES = 'virtual:l5e-island-strategies';\nconst VIRTUAL_L5E_ACTIONS = 'virtual:l5e-actions';\nconst VIRTUAL_L5E_MIDDLEWARE = 'virtual:l5e-middleware';\n\n/**\n * Vite's built-in env vars on `import.meta.env`. These are statically replaced\n * by Vite itself (DEV/PROD/SSR are booleans, MODE/BASE_URL strings), so the SSR\n * `import.meta.env.* -> process.env.*` rewrite must skip them — otherwise it\n * clobbers Vite defaults (e.g. `import.meta.env.DEV` would become the undefined\n * `process.env.DEV`).\n */\nconst VITE_RESERVED_ENV = new Set(['MODE', 'BASE_URL', 'PROD', 'DEV', 'SSR', 'LEGACY']);\n\n/**\n * Recursively scan directory for .tsx and .ts files\n */\nfunction scanTsFiles(dir: string, fileList: string[] = []): string[] {\n const files = readdirSync(dir);\n\n for (const file of files) {\n const filePath = join(dir, file);\n const stat = statSync(filePath);\n\n if (stat.isDirectory()) {\n // Skip node_modules and dist directories\n if (file === 'node_modules' || file === 'dist' || file === '.git') {\n continue;\n }\n scanTsFiles(filePath, fileList);\n } else if (file.endsWith('.tsx') || file.endsWith('.ts')) {\n fileList.push(filePath);\n }\n }\n\n return fileList;\n}\n\n/**\n * Short hash function for island keys\n */\nfunction shortHash(str: string): string {\n let hash = 0;\n for (let i = 0; i < str.length; i++) {\n hash = (hash << 5) - hash + str.charCodeAt(i);\n hash = hash & hash;\n }\n return Math.abs(hash).toString(16).slice(0, 4);\n}\n\n/**\n * Derive component name from path: \"./react/Counter\" → \"Counter\"\n */\nfunction deriveComponentName(fromPath: string): string {\n const segments = fromPath.split('/');\n let filename = segments[segments.length - 1];\n // Remove extension if present\n filename = filename.replace(/\\.(tsx?|jsx?)$/, '');\n return filename;\n}\n\n/**\n * Create island registry key: \"/src/views/test-island/react/Counter\" → \"Counter_a3f2\"\n */\nfunction makeIslandKey(resolvedPath: string): string {\n const name = deriveComponentName(resolvedPath);\n return `${name}_${shortHash(resolvedPath)}`;\n}\n\n/**\n * Resolve file path with extension (.tsx, .ts, .jsx, .js)\n * Returns the relative path with extension (e.g., \"src/views/.../Counter.tsx\")\n * or null if file not found\n */\nfunction resolveWithExtension(resolvedPath: string, rootDir: string): string | null {\n // resolvedPath: \"/src/views/test-island/react/Counter\" (no extension, leading /)\n const relPath = resolvedPath.replace(/^\\//, ''); // \"src/views/.../Counter\"\n const absBase = resolve(rootDir, relPath);\n\n // Check with extensions\n for (const ext of ['.tsx', '.ts', '.jsx', '.js']) {\n if (existsSync(absBase + ext)) {\n return relPath + ext; // \"src/views/.../Counter.tsx\"\n }\n }\n // Check without extension (file might already have one)\n if (existsSync(absBase)) {\n return relPath;\n }\n return null;\n}\n\n/**\n * Extract island entries from file using regex on JSX source\n */\nfunction extractIslandEntries(\n filePath: string,\n rootDir: string,\n): Array<{ component: string; resolvedPath: string; src: string; key: string }> {\n const content = readFileSync(filePath, 'utf-8');\n const entries: Array<{ component: string; resolvedPath: string; src: string; key: string }> = [];\n\n // Regex scan JSX source (NOT post-transform code).\n // Just find <ClientIsland ... from=\"Y\" ...> — component name derived from path.\n const regex = /<ClientIsland\\s[^>]*?from\\s*=\\s*\"([^\"]+)\"/g;\n\n const seen = new Set<string>();\n let match;\n\n while ((match = regex.exec(content)) !== null) {\n const fromPath = match[1];\n\n // Resolve relative path → absolute\n let resolvedPath: string;\n if (fromPath.startsWith('~/')) {\n // Alias ~/ → /src/ (project convention)\n resolvedPath = '/src/' + fromPath.substring(2);\n } else if (fromPath.startsWith('/src/')) {\n resolvedPath = fromPath;\n } else if (fromPath.startsWith('./') || fromPath.startsWith('../')) {\n const abs = resolve(filePath, '..', fromPath);\n resolvedPath = '/' + relative(rootDir, abs).replace(/\\\\/g, '/');\n } else {\n resolvedPath = fromPath;\n }\n\n // Resolve file extension for manifest compatibility\n const src = resolveWithExtension(resolvedPath, rootDir);\n if (!src) {\n console.warn(\n `[l5e] Island component not found: ${resolvedPath} (from ${fromPath} in ${filePath})`,\n );\n continue;\n }\n\n const key = makeIslandKey(resolvedPath);\n if (!seen.has(key)) {\n seen.add(key);\n entries.push({\n component: deriveComponentName(resolvedPath),\n resolvedPath,\n src, // \"src/views/.../Counter.tsx\" — matches manifest key format\n key,\n });\n }\n }\n return entries;\n}\n\n/**\n * Extract paths from useCss and useClientJs calls using regex\n */\nfunction extractPathsFromFile(filePath: string, rootDir: string): { css: string[]; js: string[] } {\n const content = readFileSync(filePath, 'utf-8');\n const css: string[] = [];\n const js: string[] = [];\n\n // Regex patterns to match useCss('path') or useCss(\"path\")\n // Handles single and double quotes, and escaped quotes\n const useCssPattern = /useCss\\s*\\(\\s*['\"]([^'\"]+)['\"]\\s*,?\\s*\\)/g;\n const useClientJsPattern = /useClientJs\\s*\\(\\s*['\"]([^'\"]+)['\"]\\s*,?\\s*\\)/g;\n\n let match;\n\n // Extract CSS paths\n while ((match = useCssPattern.exec(content)) !== null) {\n const path = match[1];\n // Convert relative path to absolute if needed\n if (path.startsWith('/src/')) {\n css.push(path);\n } else if (path.startsWith('./') || path.startsWith('../')) {\n // Resolve relative path\n const absolutePath = resolve(filePath, '..', path);\n const relativePath = '/' + relative(rootDir, absolutePath).replace(/\\\\/g, '/');\n css.push(relativePath);\n } else {\n css.push(path);\n }\n }\n\n // Extract JS paths\n while ((match = useClientJsPattern.exec(content)) !== null) {\n const path = match[1];\n if (path.startsWith('/src/')) {\n js.push(path);\n } else if (path.startsWith('./') || path.startsWith('../')) {\n const absolutePath = resolve(filePath, '..', path);\n const relativePath = '/' + relative(rootDir, absolutePath).replace(/\\\\/g, '/');\n js.push(relativePath);\n } else {\n js.push(path);\n }\n }\n\n return { css, js };\n}\n\n/**\n * Auto-discover rollup input entries from useCss and useClientJs calls\n */\nfunction discoverRollupInput(rootDir: string): {\n input: Record<string, string>;\n islandRegistry: Map<string, string>;\n pathToKey: Map<string, string>;\n keyToSrc: Map<string, string>;\n actionRegistry: Map<string, { modulePath: string; actionName: string }>;\n} {\n const input: Record<string, string> = {};\n const srcDir = join(rootDir, 'src');\n\n // Island registries\n const islandRegistry = new Map<string, string>(); // key → resolvedPath\n const pathToKey = new Map<string, string>(); // resolvedPath → key\n const keyToSrc = new Map<string, string>(); // key → src (manifest-compatible path with extension)\n\n // Action registry: actionKey → { modulePath, actionName }\n const actionRegistry = new Map<string, { modulePath: string; actionName: string }>();\n\n try {\n // Check if src directory exists\n if (!statSync(srcDir).isDirectory()) {\n return { input, islandRegistry, pathToKey, keyToSrc, actionRegistry };\n }\n\n // Check if src/client.global.ts exists and add it as an entry\n const globalTsPath = join(rootDir, 'src', 'client.global.ts');\n if (existsSync(globalTsPath)) {\n input['global'] = globalTsPath;\n console.log('[l5e] Detected src/client.global.ts and added as entry');\n }\n\n // Scan all .tsx and .ts files\n const tsFiles = scanTsFiles(srcDir);\n\n // Extract all paths\n const allCssPaths = new Set<string>();\n const allJsPaths = new Set<string>();\n\n for (const file of tsFiles) {\n const { css, js } = extractPathsFromFile(file, rootDir);\n css.forEach((path) => allCssPaths.add(path));\n js.forEach((path) => allJsPaths.add(path));\n\n // Extract island entries\n const islandEntries = extractIslandEntries(file, rootDir);\n for (const entry of islandEntries) {\n islandRegistry.set(entry.key, entry.resolvedPath);\n pathToKey.set(entry.resolvedPath, entry.key);\n keyToSrc.set(entry.key, entry.src);\n }\n\n // Extract action entries from actions.ts/tsx files\n const normalizedFile = file.replace(/\\\\/g, '/');\n if (/\\/actions\\.(ts|tsx)$/.test(normalizedFile)) {\n const content = readFileSync(file, 'utf-8');\n const actionExportRegex = /export\\s+const\\s+(\\w+)\\s*=\\s*defineAction\\s*\\(/g;\n let actionMatch;\n\n // Compute modulePath: relative path from src/ to parent dir\n const relFromSrc = relative(srcDir, dirname(file)).replace(/\\\\/g, '/');\n const modulePath = relFromSrc || '.';\n\n while ((actionMatch = actionExportRegex.exec(content)) !== null) {\n const actionName = actionMatch[1];\n const actionKey = `${actionName}_${shortHash(modulePath)}`;\n actionRegistry.set(actionKey, { modulePath, actionName });\n }\n }\n }\n\n // Convert paths to rollup input entries\n // CSS files\n for (const cssPath of allCssPaths) {\n // Remove leading /src/ and convert to relative path\n const relativePath = cssPath.startsWith('/src/')\n ? cssPath.substring(1) // Remove leading /\n : cssPath.startsWith('/')\n ? cssPath.substring(1)\n : cssPath;\n\n const absolutePath = resolve(rootDir, relativePath);\n\n // Only add if file exists\n if (!existsSync(absolutePath)) {\n console.warn(`[l5e] CSS file not found: ${absolutePath} (from ${cssPath})`);\n continue;\n }\n\n // Generate entry name from path (e.g., /src/views/home/home.css -> views-home-home)\n const entryName = relativePath\n .replace(/^src\\//, '')\n .replace(/\\.css$/, '')\n .replace(/\\//g, '-')\n .replace(/\\\\/g, '-');\n\n input[entryName] = absolutePath;\n }\n\n // JS/TS files\n for (const jsPath of allJsPaths) {\n const relativePath = jsPath.startsWith('/src/')\n ? jsPath.substring(1)\n : jsPath.startsWith('/')\n ? jsPath.substring(1)\n : jsPath;\n\n const absolutePath = resolve(rootDir, relativePath);\n\n // Only add if file exists\n if (!existsSync(absolutePath)) {\n console.warn(`[l5e] JS/TS file not found: ${absolutePath} (from ${jsPath})`);\n continue;\n }\n\n // Generate entry name from path\n const entryName = relativePath\n .replace(/^src\\//, '')\n .replace(/\\.(ts|tsx|js|jsx)$/, '')\n .replace(/\\//g, '-')\n .replace(/\\\\/g, '-');\n\n input[entryName] = absolutePath;\n }\n\n // Add island component files to rollup input so they appear in manifest.\n // server.ts looks up manifest at runtime to resolve per-page island URLs.\n for (const [key, src] of keyToSrc) {\n const absolutePath = resolve(rootDir, src);\n input[`island-${key}`] = absolutePath;\n }\n\n if (islandRegistry.size > 0) {\n console.log(`[l5e] Detected ${islandRegistry.size} island(s)`);\n }\n if (actionRegistry.size > 0) {\n console.log(`[l5e] Detected ${actionRegistry.size} action(s)`);\n }\n } catch (error) {\n // Silently fail if directory doesn't exist or other errors\n console.warn('[l5e] Failed to discover rollup input:', error);\n }\n\n return { input, islandRegistry, pathToKey, keyToSrc, actionRegistry };\n}\n\n/**\n * Inject __key prop into ClientIsland calls\n * Use anchor-based approach to avoid fragile regex with nested objects\n */\nfunction injectIslandKeys(\n code: string,\n fileId: string,\n rootDir: string,\n pathToKey: Map<string, string>,\n keyToSrc: Map<string, string>,\n): string {\n // After esbuild, code has form:\n // jsxFactory(ClientIsland, { from: \"./react/Counter\", props: { n: 5 } })\n // ^anchor ^find from here\n\n const result: string[] = [];\n let lastIndex = 0;\n\n // Find each position \"ClientIsland,\" (anchor)\n const anchorRegex = /ClientIsland\\s*,\\s*\\{/g;\n let anchorMatch;\n\n while ((anchorMatch = anchorRegex.exec(code)) !== null) {\n const searchStart = anchorMatch.index + anchorMatch[0].length;\n\n // Scan for from: \"...\" in window ~500 chars after anchor\n const window = code.substring(searchStart, searchStart + 500);\n const fromMatch = /from:\\s*\"([^\"]+)\"/.exec(window);\n\n if (!fromMatch) continue;\n\n const fromPath = fromMatch[1];\n\n // Resolve path (handle ~/ alias)\n let resolved: string;\n if (fromPath.startsWith('~/')) {\n resolved = '/src/' + fromPath.substring(2);\n } else if (fromPath.startsWith('/src/')) {\n resolved = fromPath;\n } else if (fromPath.startsWith('./') || fromPath.startsWith('../')) {\n const abs = resolve(fileId, '..', fromPath);\n resolved = '/' + relative(rootDir, abs).replace(/\\\\/g, '/');\n } else {\n resolved = fromPath;\n }\n\n const key = pathToKey.get(resolved);\n if (!key) continue;\n\n const src = keyToSrc.get(key);\n if (!src) continue;\n\n // Inject __key and __src right after from: \"...\"\n const insertPos = searchStart + fromMatch.index + fromMatch[0].length;\n result.push(code.substring(lastIndex, insertPos));\n result.push(`, __key: \"${key}\", __src: \"${src}\"`);\n lastIndex = insertPos;\n }\n\n result.push(code.substring(lastIndex));\n return result.join('');\n}\n\nexport function coreVite(): Plugin {\n let rootDir: string = process.cwd();\n let islandRegistry = new Map<string, string>();\n let pathToKey = new Map<string, string>();\n let keyToSrc = new Map<string, string>();\n let actionRegistry = new Map<string, { modulePath: string; actionName: string }>();\n\n return {\n name: 'l5e-jsx-classic',\n enforce: 'pre',\n\n configResolved(resolvedConfig) {\n // Store root directory for later use\n rootDir = resolvedConfig.root || process.cwd();\n },\n\n handleHotUpdate({ file, server }) {\n const relPath = relative(rootDir, file);\n\n // Re-scan action registry when an actions file changes\n if (/actions\\.(ts|tsx)$/.test(file)) {\n const discovered = discoverRollupInput(rootDir);\n actionRegistry = discovered.actionRegistry;\n // Invalidate the virtual:l5e-actions module so server picks up new registry\n const mod = server.moduleGraph.getModuleById('\\0' + VIRTUAL_L5E_ACTIONS);\n if (mod) {\n server.moduleGraph.invalidateModule(mod);\n }\n console.log(\n `[l5e] Action file changed: ${relPath} — re-scanned ${actionRegistry.size} action(s)`,\n );\n }\n\n // Allow Vite's default HMR for CSS and client-side JS files\n if (file.endsWith('.css')) {\n console.log(`[l5e] CSS changed: ${relPath} - using Vite HMR`);\n return; // Let Vite handle CSS HMR\n }\n\n if (file.includes('client.ts')) {\n console.log(`[l5e] Client JS changed: ${relPath} - using Vite HMR`);\n return; // Let Vite handle client JS HMR\n }\n\n // Trigger full page reload for SSR-related file changes (components, loaders, routes)\n // This ensures that server-side rendered components update properly\n if (file.includes('/src/') || file.includes('\\\\src\\\\')) {\n console.log(`[l5e] SSR file changed: ${relPath} - triggering full reload`);\n server.ws.send({\n type: 'full-reload',\n path: '*',\n });\n return []; // Prevent Vite's default HMR behavior\n }\n },\n\n buildEnd() {\n // Cleanup temporary files after build\n const tempDir = join(rootDir, '.l5e-temp');\n if (existsSync(tempDir)) {\n try {\n rmSync(tempDir, { recursive: true, force: true });\n console.log('[l5e] Cleaned up temporary files');\n } catch (error) {\n console.warn('[l5e] Failed to cleanup temporary files:', error);\n }\n }\n },\n\n writeBundle(_options, _bundle) {\n // Emit action registry JSON for production server\n if (actionRegistry.size > 0) {\n const outDir = join(rootDir, 'dist', 'server');\n if (!existsSync(outDir)) {\n mkdirSync(outDir, { recursive: true });\n }\n const registryObj = Object.fromEntries(actionRegistry);\n writeFileSync(join(outDir, 'action-registry.json'), JSON.stringify(registryObj), 'utf-8');\n console.log(`[l5e] Wrote action-registry.json (${actionRegistry.size} actions)`);\n }\n },\n\n config(userConfig) {\n // Auto-discover rollup input from useCss and useClientJs\n const projectRoot = userConfig.root || process.cwd();\n const discovered = discoverRollupInput(projectRoot);\n\n // Store island registries for use in other hooks\n islandRegistry = discovered.islandRegistry;\n pathToKey = discovered.pathToKey;\n keyToSrc = discovered.keyToSrc;\n actionRegistry = discovered.actionRegistry;\n\n // Merge with existing rollupOptions.input if any\n const existingInput = userConfig.build?.rollupOptions?.input || {};\n const mergedInput =\n typeof existingInput === 'object' && !Array.isArray(existingInput)\n ? { ...discovered.input, ...existingInput }\n : discovered.input;\n\n return {\n build: {\n ...userConfig.build,\n rollupOptions: {\n ...userConfig.build?.rollupOptions,\n input: Object.keys(mergedInput).length > 0 ? mergedInput : undefined,\n // Preserve exports for island component entries — without this,\n // Rollup tree-shakes their exports since nothing in the bundle imports them\n // (they're loaded at runtime via dynamic import from the island runtime).\n preserveEntrySignatures: 'exports-only',\n },\n },\n } satisfies UserConfig;\n },\n\n resolveId(id) {\n if (id === VIRTUAL_L5E_VIEWS) {\n return '\\0' + VIRTUAL_L5E_VIEWS;\n }\n if (id === VIRTUAL_L5E_ROUTE) {\n return '\\0' + VIRTUAL_L5E_ROUTE;\n }\n if (id === VIRTUAL_L5E_SSR_ENTRY) {\n return '\\0' + VIRTUAL_L5E_SSR_ENTRY;\n }\n if (id === VIRTUAL_L5E_GLOBAL_LOADER) {\n return '\\0' + VIRTUAL_L5E_GLOBAL_LOADER;\n }\n if (id === VIRTUAL_L5E_ISLAND_STRATEGIES) {\n return '\\0' + VIRTUAL_L5E_ISLAND_STRATEGIES;\n }\n if (id === VIRTUAL_L5E_ACTIONS) {\n return '\\0' + VIRTUAL_L5E_ACTIONS;\n }\n if (id === VIRTUAL_L5E_MIDDLEWARE) {\n return '\\0' + VIRTUAL_L5E_MIDDLEWARE;\n }\n return null;\n },\n\n async transform(code, id, options) {\n // Auto-inject island runtime into client.global.ts so it's always loaded globally\n if (id.replace(/\\\\/g, '/').endsWith('src/client.global.ts') && !options?.ssr) {\n return {\n code: `import '@withl5e/l5e/island/runtime';\\n${code}`,\n map: null,\n };\n }\n\n // Client-side action transform: replace defineAction exports with fetch stubs\n // Supports actions anywhere under src/ (e.g., src/views/*, src/features/*, etc.)\n if (!options?.ssr) {\n const normalizedId = id.replace(/\\\\/g, '/');\n const actionMatch = normalizedId.match(/\\/src\\/(.+)\\/actions\\.(ts|tsx)$/);\n if (actionMatch) {\n const modulePath = actionMatch[1];\n\n // Parse exported action names\n const exportRegex = /export\\s+const\\s+(\\w+)\\s*=\\s*defineAction\\s*\\(/g;\n const actions: Array<{ name: string; method: string }> = [];\n let m;\n while ((m = exportRegex.exec(code)) !== null) {\n const name = m[1];\n // Find method for this action — scan from the defineAction( position\n const chunk = code.substring(m.index, m.index + 500);\n const methodMatch = chunk.match(/method:\\s*['\"](\\w+)['\"]/);\n const method = methodMatch ? methodMatch[1].toUpperCase() : 'GET';\n actions.push({ name, method });\n }\n\n if (actions.length > 0) {\n const stubs = actions.map(({ name, method }) => {\n const actionKey = `${name}_${shortHash(modulePath)}`;\n if (method === 'GET') {\n return `export async function ${name}(params) {\n const res = await fetch('/_l5e/action/${actionKey}?' + new URLSearchParams(params));\n if (!res.ok) throw Object.assign(new Error('HTTP ' + res.status), { status: res.status });\n return res;\n}`;\n }\n return `export async function ${name}(body) {\n const res = await fetch('/_l5e/action/${actionKey}', {\n method: '${method}',\n headers: { 'Content-Type': 'application/json' },\n body: JSON.stringify(body),\n });\n if (!res.ok) throw Object.assign(new Error('HTTP ' + res.status), { status: res.status });\n return res;\n}`;\n });\n\n return {\n code: stubs.join('\\n\\n'),\n map: null,\n };\n }\n }\n }\n\n // Skip node_modules\n if (id.includes('node_modules')) {\n return null;\n }\n\n // Skip files in /react/ directories\n if (id.includes('/react/') || id.includes('\\\\react\\\\')) {\n return null;\n }\n\n // Check if this is a JSX/TSX file that needs L5E JSX transformation\n const isJsxFile = /\\.(tsx|jsx)$/.test(id);\n\n if (isJsxFile) {\n try {\n const injected = `import { Fragment as __Fragment, jsxFactory } from \"@withl5e/l5e/jsx-runtime\"\\n${code}`;\n\n // Transform JSX using esbuild with L5E's JSX runtime (async)\n const result = await transform(injected, {\n loader: id.endsWith('.tsx') ? 'tsx' : 'jsx',\n jsx: 'transform',\n jsxFactory: 'jsxFactory',\n jsxFragment: '__Fragment',\n sourcemap: true,\n sourcefile: id,\n target: 'es2020',\n });\n\n let transformedCode = result.code;\n\n // Inject __key and __src for ALL ClientIsland calls\n if (transformedCode.includes('ClientIsland')) {\n transformedCode = injectIslandKeys(transformedCode, id, rootDir, pathToKey, keyToSrc);\n }\n\n return {\n code: transformedCode,\n map: result.map || null,\n };\n } catch (error) {\n // Log error but let Vite handle it\n console.error(`[l5e] Failed to transform JSX in ${id}:`, error);\n throw error;\n }\n }\n\n // Transform import.meta.env thà nh process.env ở server side\n // Server side có thể access tất cả env variables\n // Client side chỉ access được VITE_ env variables\n // Transform nà y chạy ở runtime khi module được load trong SSR context\n if (options?.ssr) {\n let transformedCode = code;\n let hasChanges = false;\n\n // Thay thế import.meta.env.VARIABLE_NAME thà nh process.env.VARIABLE_NAME\n // Match: import.meta.env.VITE_EVENT_CATEGORY_SLUG\n transformedCode = transformedCode.replace(\n /import\\.meta\\.env\\.([a-zA-Z_][a-zA-Z0-9_]*)/g,\n (match, varName) => {\n // Leave Vite's built-in env vars for Vite to handle.\n if (VITE_RESERVED_ENV.has(varName)) return match;\n hasChanges = true;\n return `process.env.${varName}`;\n },\n );\n\n // Thay thế import.meta.env['VARIABLE_NAME'] hoặc import.meta.env[\"VARIABLE_NAME\"]\n // thà nh process.env['VARIABLE_NAME'] hoặc process.env[\"VARIABLE_NAME\"]\n // Match: import.meta.env['VITE_EVENT_CATEGORY_SLUG'] hoặc import.meta.env[\"VITE_EVENT_CATEGORY_SLUG\"]\n transformedCode = transformedCode.replace(\n /import\\.meta\\.env\\[(['\"`])([^'\"`]+)\\1\\]/g,\n (match, quote, varName) => {\n // Leave Vite's built-in env vars for Vite to handle.\n if (VITE_RESERVED_ENV.has(varName)) return match;\n hasChanges = true;\n return `process.env[${quote}${varName}${quote}]`;\n },\n );\n\n if (hasChanges) {\n return {\n code: transformedCode,\n map: null, // Không cần source map cho env transform\n };\n }\n }\n return null;\n },\n\n load(id) {\n // Virtual module: l5e-views\n if (id === '\\0' + VIRTUAL_L5E_VIEWS) {\n return `\nexport const viewLoaders = import.meta.glob('/src/views/*/loader.{ts,tsx}');\nexport const viewComponents = import.meta.glob('/src/views/*/index.tsx');\n`;\n }\n\n // Virtual module: l5e-route\n if (id === '\\0' + VIRTUAL_L5E_ROUTE) {\n // Always use TypeScript\n return `export { default } from '/src/route.ts';`;\n }\n\n // Virtual module: l5e-ssr-entry\n if (id === '\\0' + VIRTUAL_L5E_SSR_ENTRY) {\n return `export { render } from '@withl5e/l5e/entry-server';\nexport { viewActions } from 'virtual:l5e-actions';`;\n }\n\n // Virtual module: l5e-global-loader\n if (id === '\\0' + VIRTUAL_L5E_GLOBAL_LOADER) {\n return `export const globalLoader = import.meta.glob('/src/global-loader.{ts,tsx}', { eager: false });`;\n }\n\n // Virtual module: l5e-actions\n if (id === '\\0' + VIRTUAL_L5E_ACTIONS) {\n const registryObj = Object.fromEntries(actionRegistry);\n return `export const viewActions = import.meta.glob('/src/**/actions.{ts,tsx}');\nexport const actionRegistry = ${JSON.stringify(registryObj)};`;\n }\n\n // Virtual module: l5e-middleware\n if (id === '\\0' + VIRTUAL_L5E_MIDDLEWARE) {\n 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`;\n }\n\n // Virtual module: l5e-island-strategies\n if (id === '\\0' + VIRTUAL_L5E_ISLAND_STRATEGIES) {\n // Check if src/island-strategies.ts exists\n const strategiesFile = join(rootDir, 'src', 'island-strategies.ts');\n if (existsSync(strategiesFile)) {\n // Re-export user's file → Vite will build this file\n return `import '/src/island-strategies.ts';`;\n }\n // No file → empty module, no error\n return `/* no custom island strategies */`;\n }\n\n return null;\n },\n };\n}\n\nexport default coreVite;\n"],"names":["VIRTUAL_L5E_VIEWS","VIRTUAL_L5E_ROUTE","VIRTUAL_L5E_SSR_ENTRY","VIRTUAL_L5E_GLOBAL_LOADER","VIRTUAL_L5E_ISLAND_STRATEGIES","VIRTUAL_L5E_ACTIONS","VIRTUAL_L5E_MIDDLEWARE","VITE_RESERVED_ENV","scanTsFiles","dir","fileList","files","readdirSync","file","filePath","join","statSync","shortHash","str","hash","i","deriveComponentName","fromPath","segments","filename","makeIslandKey","resolvedPath","resolveWithExtension","rootDir","relPath","absBase","resolve","ext","existsSync","extractIslandEntries","content","readFileSync","entries","regex","seen","match","abs","relative","src","key","extractPathsFromFile","css","js","useCssPattern","useClientJsPattern","path","absolutePath","relativePath","discoverRollupInput","input","srcDir","islandRegistry","pathToKey","keyToSrc","actionRegistry","globalTsPath","tsFiles","allCssPaths","allJsPaths","islandEntries","entry","normalizedFile","actionExportRegex","actionMatch","modulePath","dirname","actionName","actionKey","cssPath","entryName","jsPath","error","injectIslandKeys","code","fileId","result","lastIndex","anchorRegex","anchorMatch","searchStart","window","fromMatch","resolved","insertPos","coreVite","resolvedConfig","server","mod","tempDir","rmSync","_options","_bundle","outDir","mkdirSync","registryObj","writeFileSync","userConfig","projectRoot","discovered","existingInput","mergedInput","id","options","exportRegex","actions","m","name","methodMatch","method","injected","transform","transformedCode","hasChanges","varName","quote","strategiesFile"],"mappings":";;;AAaA,MAAMA,IAAoB,qBACpBC,IAAoB,qBACpBC,IAAwB,yBACxBC,IAA4B,6BAC5BC,IAAgC,iCAChCC,IAAsB,uBACtBC,IAAyB,0BASzBC,IAAoB,oBAAI,IAAI,CAAC,QAAQ,YAAY,QAAQ,OAAO,OAAO,QAAQ,CAAC;AAKtF,SAASC,EAAYC,GAAaC,IAAqB,IAAc;AACnE,QAAMC,IAAQC,EAAYH,CAAG;AAE7B,aAAWI,KAAQF,GAAO;AACxB,UAAMG,IAAWC,EAAKN,GAAKI,CAAI;AAG/B,QAFaG,EAASF,CAAQ,EAErB,eAAe;AAEtB,UAAID,MAAS,kBAAkBA,MAAS,UAAUA,MAAS;AACzD;AAEF,MAAAL,EAAYM,GAAUJ,CAAQ;AAAA,IAChC,MAAA,EAAWG,EAAK,SAAS,MAAM,KAAKA,EAAK,SAAS,KAAK,MACrDH,EAAS,KAAKI,CAAQ;AAAA,EAE1B;AAEA,SAAOJ;AACT;AAKA,SAASO,EAAUC,GAAqB;AACtC,MAAIC,IAAO;AACX,WAASC,IAAI,GAAGA,IAAIF,EAAI,QAAQE;AAC9B,IAAAD,KAAQA,KAAQ,KAAKA,IAAOD,EAAI,WAAWE,CAAC,GAC5CD,IAAOA,IAAOA;AAEhB,SAAO,KAAK,IAAIA,CAAI,EAAE,SAAS,EAAE,EAAE,MAAM,GAAG,CAAC;AAC/C;AAKA,SAASE,EAAoBC,GAA0B;AACrD,QAAMC,IAAWD,EAAS,MAAM,GAAG;AACnC,MAAIE,IAAWD,EAASA,EAAS,SAAS,CAAC;AAE3C,SAAAC,IAAWA,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E,IAAa,IACN,eAAeC,CAAO;AAAA,QAC/B,GAMFF,IAAkBA,EAAgB;AAAA,UAChC;AAAA,UACA,CAAC5E,GAAO+E,GAAOD,MAET/G,EAAkB,IAAI+G,CAAO,IAAU9E,KAC3C6E,IAAa,IACN,eAAeE,CAAK,GAAGD,CAAO,GAAGC,CAAK;AAAA,QAC/C,GAGEF;AACF,iBAAO;AAAA,YACL,MAAMD;AAAA,YACN,KAAK;AAAA;AAAA,UAAA;AAAA,MAGX;AACA,aAAO;AAAA,IACT;AAAA,IAEA,KAAKV,GAAI;AAEP,UAAIA,MAAO,OAAO1G;AAChB,eAAO;AAAA;AAAA;AAAA;AAOT,UAAI0G,MAAO,OAAOzG;AAEhB,eAAO;AAIT,UAAIyG,MAAO,OAAOxG;AAChB,eAAO;AAAA;AAKT,UAAIwG,MAAO,OAAOvG;AAChB,eAAO;AAIT,UAAIuG,MAAO,OAAOrG,GAAqB;AACrC,cAAM8F,IAAc,OAAO,YAAYxC,CAAc;AACrD,eAAO;AAAA,gCACiB,KAAK,UAAUwC,CAAW,CAAC;AAAA,MACrD;AAGA,UAAIO,MAAO,OAAOpG;AAChB,eAAO;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AA4BT,UAAIoG,MAAO,OAAOtG,GAA+B;AAE/C,cAAMoH,IAAiBzG,EAAKa,GAAS,OAAO,sBAAsB;AAClE,eAAIK,EAAWuF,CAAc,IAEpB,wCAGF;AAAA,MACT;AAEA,aAAO;AAAA,IACT;AAAA,EAAA;AAEJ;"}
|
|
1
|
+
{"version":3,"file":"vite-plugin.js","sources":["../src/core/vite-plugin.ts"],"sourcesContent":["import { transform } from 'esbuild';\nimport {\n existsSync,\n mkdirSync,\n readdirSync,\n readFileSync,\n rmSync,\n statSync,\n writeFileSync,\n} from 'fs';\nimport { dirname, join, relative, resolve } from 'path';\nimport type { Plugin, UserConfig } from 'vite';\n\nconst VIRTUAL_L5E_VIEWS = 'virtual:l5e-views';\nconst VIRTUAL_L5E_ROUTE = 'virtual:l5e-route';\nconst VIRTUAL_L5E_SSR_ENTRY = 'virtual:l5e-ssr-entry';\nconst VIRTUAL_L5E_GLOBAL_LOADER = 'virtual:l5e-global-loader';\nconst VIRTUAL_L5E_ISLAND_STRATEGIES = 'virtual:l5e-island-strategies';\nconst VIRTUAL_L5E_ISLANDS = 'virtual:l5e-islands';\nconst VIRTUAL_L5E_ACTIONS = 'virtual:l5e-actions';\nconst VIRTUAL_L5E_MIDDLEWARE = 'virtual:l5e-middleware';\n\n/**\n * Vite's built-in env vars on `import.meta.env`. These are statically replaced\n * by Vite itself (DEV/PROD/SSR are booleans, MODE/BASE_URL strings), so the SSR\n * `import.meta.env.* -> process.env.*` rewrite must skip them — otherwise it\n * clobbers Vite defaults (e.g. `import.meta.env.DEV` would become the undefined\n * `process.env.DEV`).\n */\nconst VITE_RESERVED_ENV = new Set(['MODE', 'BASE_URL', 'PROD', 'DEV', 'SSR', 'LEGACY']);\n\n/**\n * Recursively scan directory for .tsx and .ts files\n */\nfunction scanTsFiles(dir: string, fileList: string[] = []): string[] {\n const files = readdirSync(dir);\n\n for (const file of files) {\n const filePath = join(dir, file);\n const stat = statSync(filePath);\n\n if (stat.isDirectory()) {\n // Skip node_modules and dist directories\n if (file === 'node_modules' || file === 'dist' || file === '.git') {\n continue;\n }\n scanTsFiles(filePath, fileList);\n } else if (file.endsWith('.tsx') || file.endsWith('.ts')) {\n fileList.push(filePath);\n }\n }\n\n return fileList;\n}\n\n/**\n * Short hash function for island keys\n */\nfunction shortHash(str: string): string {\n let hash = 0;\n for (let i = 0; i < str.length; i++) {\n hash = (hash << 5) - hash + str.charCodeAt(i);\n hash = hash & hash;\n }\n return Math.abs(hash).toString(16).slice(0, 4);\n}\n\n/**\n * Derive component name from path: \"./react/Counter\" → \"Counter\"\n */\nfunction deriveComponentName(fromPath: string): string {\n const segments = fromPath.split('/');\n let filename = segments[segments.length - 1];\n // Remove extension if present\n filename = filename.replace(/\\.(tsx?|jsx?)$/, '');\n return filename;\n}\n\n/**\n * Create island registry key: \"/src/views/test-island/react/Counter\" → \"Counter_a3f2\"\n */\nfunction makeIslandKey(resolvedPath: string): string {\n const name = deriveComponentName(resolvedPath);\n return `${name}_${shortHash(resolvedPath)}`;\n}\n\n/**\n * Resolve file path with extension (.tsx, .ts, .jsx, .js)\n * Returns the relative path with extension (e.g., \"src/views/.../Counter.tsx\")\n * or null if file not found\n */\nfunction resolveWithExtension(resolvedPath: string, rootDir: string): string | null {\n // resolvedPath: \"/src/views/test-island/react/Counter\" (no extension, leading /)\n const relPath = resolvedPath.replace(/^\\//, ''); // \"src/views/.../Counter\"\n const absBase = resolve(rootDir, relPath);\n\n // Check with extensions\n for (const ext of ['.tsx', '.ts', '.jsx', '.js']) {\n if (existsSync(absBase + ext)) {\n return relPath + ext; // \"src/views/.../Counter.tsx\"\n }\n }\n // Check without extension (file might already have one)\n if (existsSync(absBase)) {\n return relPath;\n }\n return null;\n}\n\n/**\n * Extract island entries from file using regex on JSX source\n */\nfunction extractIslandEntries(\n filePath: string,\n rootDir: string,\n): Array<{ component: string; resolvedPath: string; src: string; key: string }> {\n const content = readFileSync(filePath, 'utf-8');\n const entries: Array<{ component: string; resolvedPath: string; src: string; key: string }> = [];\n\n // Regex scan JSX source (NOT post-transform code).\n // Just find <ClientIsland ... from=\"Y\" ...> — component name derived from path.\n const regex = /<ClientIsland\\s[^>]*?from\\s*=\\s*\"([^\"]+)\"/g;\n\n const seen = new Set<string>();\n let match;\n\n while ((match = regex.exec(content)) !== null) {\n const fromPath = match[1];\n\n // Resolve relative path → absolute\n let resolvedPath: string;\n if (fromPath.startsWith('~/')) {\n // Alias ~/ → /src/ (project convention)\n resolvedPath = '/src/' + fromPath.substring(2);\n } else if (fromPath.startsWith('/src/')) {\n resolvedPath = fromPath;\n } else if (fromPath.startsWith('./') || fromPath.startsWith('../')) {\n const abs = resolve(filePath, '..', fromPath);\n resolvedPath = '/' + relative(rootDir, abs).replace(/\\\\/g, '/');\n } else {\n resolvedPath = fromPath;\n }\n\n // Resolve file extension for manifest compatibility\n const src = resolveWithExtension(resolvedPath, rootDir);\n if (!src) {\n console.warn(\n `[l5e] Island component not found: ${resolvedPath} (from ${fromPath} in ${filePath})`,\n );\n continue;\n }\n\n const key = makeIslandKey(resolvedPath);\n if (!seen.has(key)) {\n seen.add(key);\n entries.push({\n component: deriveComponentName(resolvedPath),\n resolvedPath,\n src, // \"src/views/.../Counter.tsx\" — matches manifest key format\n key,\n });\n }\n }\n return entries;\n}\n\n/**\n * Extract paths from useCss and useClientJs calls using regex\n */\nfunction extractPathsFromFile(filePath: string, rootDir: string): { css: string[]; js: string[] } {\n const content = readFileSync(filePath, 'utf-8');\n const css: string[] = [];\n const js: string[] = [];\n\n // Regex patterns to match useCss('path') or useCss(\"path\")\n // Handles single and double quotes, and escaped quotes\n const useCssPattern = /useCss\\s*\\(\\s*['\"]([^'\"]+)['\"]\\s*,?\\s*\\)/g;\n const useClientJsPattern = /useClientJs\\s*\\(\\s*['\"]([^'\"]+)['\"]\\s*,?\\s*\\)/g;\n\n let match;\n\n // Extract CSS paths\n while ((match = useCssPattern.exec(content)) !== null) {\n const path = match[1];\n // Convert relative path to absolute if needed\n if (path.startsWith('/src/')) {\n css.push(path);\n } else if (path.startsWith('./') || path.startsWith('../')) {\n // Resolve relative path\n const absolutePath = resolve(filePath, '..', path);\n const relativePath = '/' + relative(rootDir, absolutePath).replace(/\\\\/g, '/');\n css.push(relativePath);\n } else {\n css.push(path);\n }\n }\n\n // Extract JS paths\n while ((match = useClientJsPattern.exec(content)) !== null) {\n const path = match[1];\n if (path.startsWith('/src/')) {\n js.push(path);\n } else if (path.startsWith('./') || path.startsWith('../')) {\n const absolutePath = resolve(filePath, '..', path);\n const relativePath = '/' + relative(rootDir, absolutePath).replace(/\\\\/g, '/');\n js.push(relativePath);\n } else {\n js.push(path);\n }\n }\n\n return { css, js };\n}\n\n/**\n * Auto-discover rollup input entries from useCss and useClientJs calls\n */\nfunction discoverRollupInput(rootDir: string): {\n input: Record<string, string>;\n islandRegistry: Map<string, string>;\n pathToKey: Map<string, string>;\n keyToSrc: Map<string, string>;\n actionRegistry: Map<string, { modulePath: string; actionName: string }>;\n} {\n const input: Record<string, string> = {};\n const srcDir = join(rootDir, 'src');\n\n // Island registries\n const islandRegistry = new Map<string, string>(); // key → resolvedPath\n const pathToKey = new Map<string, string>(); // resolvedPath → key\n const keyToSrc = new Map<string, string>(); // key → src (manifest-compatible path with extension)\n\n // Action registry: actionKey → { modulePath, actionName }\n const actionRegistry = new Map<string, { modulePath: string; actionName: string }>();\n\n try {\n // Check if src directory exists\n if (!statSync(srcDir).isDirectory()) {\n return { input, islandRegistry, pathToKey, keyToSrc, actionRegistry };\n }\n\n // Check if src/client.global.ts exists and add it as an entry\n const globalTsPath = join(rootDir, 'src', 'client.global.ts');\n if (existsSync(globalTsPath)) {\n input['global'] = globalTsPath;\n console.log('[l5e] Detected src/client.global.ts and added as entry');\n }\n\n // Scan all .tsx and .ts files\n const tsFiles = scanTsFiles(srcDir);\n\n // Extract all paths\n const allCssPaths = new Set<string>();\n const allJsPaths = new Set<string>();\n\n for (const file of tsFiles) {\n const { css, js } = extractPathsFromFile(file, rootDir);\n css.forEach((path) => allCssPaths.add(path));\n js.forEach((path) => allJsPaths.add(path));\n\n // Extract island entries\n const islandEntries = extractIslandEntries(file, rootDir);\n for (const entry of islandEntries) {\n islandRegistry.set(entry.key, entry.resolvedPath);\n pathToKey.set(entry.resolvedPath, entry.key);\n keyToSrc.set(entry.key, entry.src);\n }\n\n // Extract action entries from actions.ts/tsx files\n const normalizedFile = file.replace(/\\\\/g, '/');\n if (/\\/actions\\.(ts|tsx)$/.test(normalizedFile)) {\n const content = readFileSync(file, 'utf-8');\n const actionExportRegex = /export\\s+const\\s+(\\w+)\\s*=\\s*defineAction\\s*\\(/g;\n let actionMatch;\n\n // Compute modulePath: relative path from src/ to parent dir\n const relFromSrc = relative(srcDir, dirname(file)).replace(/\\\\/g, '/');\n const modulePath = relFromSrc || '.';\n\n while ((actionMatch = actionExportRegex.exec(content)) !== null) {\n const actionName = actionMatch[1];\n const actionKey = `${actionName}_${shortHash(modulePath)}`;\n actionRegistry.set(actionKey, { modulePath, actionName });\n }\n }\n }\n\n // Convert paths to rollup input entries\n // CSS files\n for (const cssPath of allCssPaths) {\n // Remove leading /src/ and convert to relative path\n const relativePath = cssPath.startsWith('/src/')\n ? cssPath.substring(1) // Remove leading /\n : cssPath.startsWith('/')\n ? cssPath.substring(1)\n : cssPath;\n\n const absolutePath = resolve(rootDir, relativePath);\n\n // Only add if file exists\n if (!existsSync(absolutePath)) {\n console.warn(`[l5e] CSS file not found: ${absolutePath} (from ${cssPath})`);\n continue;\n }\n\n // Generate entry name from path (e.g., /src/views/home/home.css -> views-home-home)\n const entryName = relativePath\n .replace(/^src\\//, '')\n .replace(/\\.css$/, '')\n .replace(/\\//g, '-')\n .replace(/\\\\/g, '-');\n\n input[entryName] = absolutePath;\n }\n\n // JS/TS files\n for (const jsPath of allJsPaths) {\n const relativePath = jsPath.startsWith('/src/')\n ? jsPath.substring(1)\n : jsPath.startsWith('/')\n ? jsPath.substring(1)\n : jsPath;\n\n const absolutePath = resolve(rootDir, relativePath);\n\n // Only add if file exists\n if (!existsSync(absolutePath)) {\n console.warn(`[l5e] JS/TS file not found: ${absolutePath} (from ${jsPath})`);\n continue;\n }\n\n // Generate entry name from path\n const entryName = relativePath\n .replace(/^src\\//, '')\n .replace(/\\.(ts|tsx|js|jsx)$/, '')\n .replace(/\\//g, '-')\n .replace(/\\\\/g, '-');\n\n input[entryName] = absolutePath;\n }\n\n // Add island component files to rollup input so they appear in manifest.\n // server.ts looks up manifest at runtime to resolve per-page island URLs.\n for (const [key, src] of keyToSrc) {\n const absolutePath = resolve(rootDir, src);\n input[`island-${key}`] = absolutePath;\n }\n\n if (islandRegistry.size > 0) {\n console.log(`[l5e] Detected ${islandRegistry.size} island(s)`);\n }\n if (actionRegistry.size > 0) {\n console.log(`[l5e] Detected ${actionRegistry.size} action(s)`);\n }\n } catch (error) {\n // Silently fail if directory doesn't exist or other errors\n console.warn('[l5e] Failed to discover rollup input:', error);\n }\n\n return { input, islandRegistry, pathToKey, keyToSrc, actionRegistry };\n}\n\n/**\n * Inject __key prop into ClientIsland calls\n * Use anchor-based approach to avoid fragile regex with nested objects\n */\nfunction injectIslandKeys(\n code: string,\n fileId: string,\n rootDir: string,\n pathToKey: Map<string, string>,\n keyToSrc: Map<string, string>,\n): string {\n // After esbuild, code has form:\n // jsxFactory(ClientIsland, { from: \"./react/Counter\", props: { n: 5 } })\n // ^anchor ^find from here\n\n const result: string[] = [];\n let lastIndex = 0;\n\n // Find each position \"ClientIsland,\" (anchor)\n const anchorRegex = /ClientIsland\\s*,\\s*\\{/g;\n let anchorMatch;\n\n while ((anchorMatch = anchorRegex.exec(code)) !== null) {\n const searchStart = anchorMatch.index + anchorMatch[0].length;\n\n // Scan for from: \"...\" in window ~500 chars after anchor\n const window = code.substring(searchStart, searchStart + 500);\n const fromMatch = /from:\\s*\"([^\"]+)\"/.exec(window);\n\n if (!fromMatch) continue;\n\n const fromPath = fromMatch[1];\n\n // Resolve path (handle ~/ alias)\n let resolved: string;\n if (fromPath.startsWith('~/')) {\n resolved = '/src/' + fromPath.substring(2);\n } else if (fromPath.startsWith('/src/')) {\n resolved = fromPath;\n } else if (fromPath.startsWith('./') || fromPath.startsWith('../')) {\n const abs = resolve(fileId, '..', fromPath);\n resolved = '/' + relative(rootDir, abs).replace(/\\\\/g, '/');\n } else {\n resolved = fromPath;\n }\n\n const key = pathToKey.get(resolved);\n if (!key) continue;\n\n const src = keyToSrc.get(key);\n if (!src) continue;\n\n // Inject __key and __src right after from: \"...\"\n const insertPos = searchStart + fromMatch.index + fromMatch[0].length;\n result.push(code.substring(lastIndex, insertPos));\n result.push(`, __key: \"${key}\", __src: \"${src}\"`);\n lastIndex = insertPos;\n }\n\n result.push(code.substring(lastIndex));\n return result.join('');\n}\n\nexport function coreVite(): Plugin {\n let rootDir: string = process.cwd();\n let islandRegistry = new Map<string, string>();\n let pathToKey = new Map<string, string>();\n let keyToSrc = new Map<string, string>();\n let actionRegistry = new Map<string, { modulePath: string; actionName: string }>();\n\n return {\n name: 'l5e-jsx-classic',\n enforce: 'pre',\n\n configResolved(resolvedConfig) {\n // Store root directory for later use\n rootDir = resolvedConfig.root || process.cwd();\n },\n\n handleHotUpdate({ file, server }) {\n const relPath = relative(rootDir, file);\n\n // Re-scan action registry when an actions file changes\n if (/actions\\.(ts|tsx)$/.test(file)) {\n const discovered = discoverRollupInput(rootDir);\n actionRegistry = discovered.actionRegistry;\n // Invalidate the virtual:l5e-actions module so server picks up new registry\n const mod = server.moduleGraph.getModuleById('\\0' + VIRTUAL_L5E_ACTIONS);\n if (mod) {\n server.moduleGraph.invalidateModule(mod);\n }\n console.log(\n `[l5e] Action file changed: ${relPath} — re-scanned ${actionRegistry.size} action(s)`,\n );\n }\n\n // Allow Vite's default HMR for CSS and client-side JS files\n if (file.endsWith('.css')) {\n console.log(`[l5e] CSS changed: ${relPath} - using Vite HMR`);\n return; // Let Vite handle CSS HMR\n }\n\n if (file.includes('client.ts')) {\n console.log(`[l5e] Client JS changed: ${relPath} - using Vite HMR`);\n return; // Let Vite handle client JS HMR\n }\n\n // Trigger full page reload for SSR-related file changes (components, loaders, routes)\n // This ensures that server-side rendered components update properly\n if (file.includes('/src/') || file.includes('\\\\src\\\\')) {\n console.log(`[l5e] SSR file changed: ${relPath} - triggering full reload`);\n server.ws.send({\n type: 'full-reload',\n path: '*',\n });\n return []; // Prevent Vite's default HMR behavior\n }\n },\n\n buildEnd() {\n // Cleanup temporary files after build\n const tempDir = join(rootDir, '.l5e-temp');\n if (existsSync(tempDir)) {\n try {\n rmSync(tempDir, { recursive: true, force: true });\n console.log('[l5e] Cleaned up temporary files');\n } catch (error) {\n console.warn('[l5e] Failed to cleanup temporary files:', error);\n }\n }\n },\n\n writeBundle(_options, _bundle) {\n // Emit action registry JSON for production server\n if (actionRegistry.size > 0) {\n const outDir = join(rootDir, 'dist', 'server');\n if (!existsSync(outDir)) {\n mkdirSync(outDir, { recursive: true });\n }\n const registryObj = Object.fromEntries(actionRegistry);\n writeFileSync(join(outDir, 'action-registry.json'), JSON.stringify(registryObj), 'utf-8');\n console.log(`[l5e] Wrote action-registry.json (${actionRegistry.size} actions)`);\n }\n },\n\n config(userConfig) {\n // Auto-discover rollup input from useCss and useClientJs\n const projectRoot = userConfig.root || process.cwd();\n const discovered = discoverRollupInput(projectRoot);\n\n // Store island registries for use in other hooks\n islandRegistry = discovered.islandRegistry;\n pathToKey = discovered.pathToKey;\n keyToSrc = discovered.keyToSrc;\n actionRegistry = discovered.actionRegistry;\n\n // Merge with existing rollupOptions.input if any\n const existingInput = userConfig.build?.rollupOptions?.input || {};\n const mergedInput =\n typeof existingInput === 'object' && !Array.isArray(existingInput)\n ? { ...discovered.input, ...existingInput }\n : discovered.input;\n\n return {\n build: {\n ...userConfig.build,\n rollupOptions: {\n ...userConfig.build?.rollupOptions,\n input: Object.keys(mergedInput).length > 0 ? mergedInput : undefined,\n // Preserve exports for island component entries — without this,\n // Rollup tree-shakes their exports since nothing in the bundle imports them\n // (they're loaded at runtime via dynamic import from the island runtime).\n preserveEntrySignatures: 'exports-only',\n },\n },\n } satisfies UserConfig;\n },\n\n resolveId(id) {\n if (id === VIRTUAL_L5E_VIEWS) {\n return '\\0' + VIRTUAL_L5E_VIEWS;\n }\n if (id === VIRTUAL_L5E_ROUTE) {\n return '\\0' + VIRTUAL_L5E_ROUTE;\n }\n if (id === VIRTUAL_L5E_SSR_ENTRY) {\n return '\\0' + VIRTUAL_L5E_SSR_ENTRY;\n }\n if (id === VIRTUAL_L5E_GLOBAL_LOADER) {\n return '\\0' + VIRTUAL_L5E_GLOBAL_LOADER;\n }\n if (id === VIRTUAL_L5E_ISLAND_STRATEGIES) {\n return '\\0' + VIRTUAL_L5E_ISLAND_STRATEGIES;\n }\n if (id === VIRTUAL_L5E_ISLANDS) {\n return '\\0' + VIRTUAL_L5E_ISLANDS;\n }\n if (id === VIRTUAL_L5E_ACTIONS) {\n return '\\0' + VIRTUAL_L5E_ACTIONS;\n }\n if (id === VIRTUAL_L5E_MIDDLEWARE) {\n return '\\0' + VIRTUAL_L5E_MIDDLEWARE;\n }\n return null;\n },\n\n async transform(code, id, options) {\n // Auto-inject island runtime into client.global.ts so it's always loaded globally\n if (id.replace(/\\\\/g, '/').endsWith('src/client.global.ts') && !options?.ssr) {\n return {\n code: `import '@withl5e/l5e/island/runtime';\\n${code}`,\n map: null,\n };\n }\n\n // Client-side action transform: replace defineAction exports with fetch stubs\n // Supports actions anywhere under src/ (e.g., src/views/*, src/features/*, etc.)\n if (!options?.ssr) {\n const normalizedId = id.replace(/\\\\/g, '/');\n const actionMatch = normalizedId.match(/\\/src\\/(.+)\\/actions\\.(ts|tsx)$/);\n if (actionMatch) {\n const modulePath = actionMatch[1];\n\n // Parse exported action names\n const exportRegex = /export\\s+const\\s+(\\w+)\\s*=\\s*defineAction\\s*\\(/g;\n const actions: Array<{ name: string; method: string }> = [];\n let m;\n while ((m = exportRegex.exec(code)) !== null) {\n const name = m[1];\n // Find method for this action — scan from the defineAction( position\n const chunk = code.substring(m.index, m.index + 500);\n const methodMatch = chunk.match(/method:\\s*['\"](\\w+)['\"]/);\n const method = methodMatch ? methodMatch[1].toUpperCase() : 'GET';\n actions.push({ name, method });\n }\n\n if (actions.length > 0) {\n const stubs = actions.map(({ name, method }) => {\n const actionKey = `${name}_${shortHash(modulePath)}`;\n if (method === 'GET') {\n return `export async function ${name}(params) {\n const res = await fetch('/_l5e/action/${actionKey}?' + new URLSearchParams(params));\n if (!res.ok) throw Object.assign(new Error('HTTP ' + res.status), { status: res.status });\n return res;\n}`;\n }\n return `export async function ${name}(body) {\n const res = await fetch('/_l5e/action/${actionKey}', {\n method: '${method}',\n headers: { 'Content-Type': 'application/json' },\n body: JSON.stringify(body),\n });\n if (!res.ok) throw Object.assign(new Error('HTTP ' + res.status), { status: res.status });\n return res;\n}`;\n });\n\n return {\n code: stubs.join('\\n\\n'),\n map: null,\n };\n }\n }\n }\n\n // Skip node_modules\n if (id.includes('node_modules')) {\n return null;\n }\n\n // Skip files in /react/ directories\n if (id.includes('/react/') || id.includes('\\\\react\\\\')) {\n return null;\n }\n\n // Check if this is a JSX/TSX file that needs L5E JSX transformation\n const isJsxFile = /\\.(tsx|jsx)$/.test(id);\n\n if (isJsxFile) {\n try {\n const injected = `import { Fragment as __Fragment, jsxFactory } from \"@withl5e/l5e/jsx-runtime\"\\n${code}`;\n\n // Transform JSX using esbuild with L5E's JSX runtime (async)\n const result = await transform(injected, {\n loader: id.endsWith('.tsx') ? 'tsx' : 'jsx',\n jsx: 'transform',\n jsxFactory: 'jsxFactory',\n jsxFragment: '__Fragment',\n sourcemap: true,\n sourcefile: id,\n target: 'es2020',\n });\n\n let transformedCode = result.code;\n\n // Inject __key and __src for ALL ClientIsland calls\n if (transformedCode.includes('ClientIsland')) {\n transformedCode = injectIslandKeys(transformedCode, id, rootDir, pathToKey, keyToSrc);\n }\n\n return {\n code: transformedCode,\n map: result.map || null,\n };\n } catch (error) {\n // Log error but let Vite handle it\n console.error(`[l5e] Failed to transform JSX in ${id}:`, error);\n throw error;\n }\n }\n\n // Transform import.meta.env thà nh process.env ở server side\n // Server side có thể access tất cả env variables\n // Client side chỉ access được VITE_ env variables\n // Transform nà y chạy ở runtime khi module được load trong SSR context\n if (options?.ssr) {\n let transformedCode = code;\n let hasChanges = false;\n\n // Thay thế import.meta.env.VARIABLE_NAME thà nh process.env.VARIABLE_NAME\n // Match: import.meta.env.VITE_EVENT_CATEGORY_SLUG\n transformedCode = transformedCode.replace(\n /import\\.meta\\.env\\.([a-zA-Z_][a-zA-Z0-9_]*)/g,\n (match, varName) => {\n // Leave Vite's built-in env vars for Vite to handle.\n if (VITE_RESERVED_ENV.has(varName)) return match;\n hasChanges = true;\n return `process.env.${varName}`;\n },\n );\n\n // Thay thế import.meta.env['VARIABLE_NAME'] hoặc import.meta.env[\"VARIABLE_NAME\"]\n // thà nh process.env['VARIABLE_NAME'] hoặc process.env[\"VARIABLE_NAME\"]\n // Match: import.meta.env['VITE_EVENT_CATEGORY_SLUG'] hoặc import.meta.env[\"VITE_EVENT_CATEGORY_SLUG\"]\n transformedCode = transformedCode.replace(\n /import\\.meta\\.env\\[(['\"`])([^'\"`]+)\\1\\]/g,\n (match, quote, varName) => {\n // Leave Vite's built-in env vars for Vite to handle.\n if (VITE_RESERVED_ENV.has(varName)) return match;\n hasChanges = true;\n return `process.env[${quote}${varName}${quote}]`;\n },\n );\n\n if (hasChanges) {\n return {\n code: transformedCode,\n map: null, // Không cần source map cho env transform\n };\n }\n }\n return null;\n },\n\n load(id) {\n // Virtual module: l5e-views\n if (id === '\\0' + VIRTUAL_L5E_VIEWS) {\n return `\nexport const viewLoaders = import.meta.glob('/src/views/*/loader.{ts,tsx}');\nexport const viewComponents = import.meta.glob('/src/views/*/index.tsx');\n`;\n }\n\n // Virtual module: l5e-route\n if (id === '\\0' + VIRTUAL_L5E_ROUTE) {\n // Always use TypeScript\n return `export { default } from '/src/route.ts';`;\n }\n\n // Virtual module: l5e-ssr-entry\n if (id === '\\0' + VIRTUAL_L5E_SSR_ENTRY) {\n return `export { render } from '@withl5e/l5e/entry-server';\nexport { viewActions } from 'virtual:l5e-actions';`;\n }\n\n // Virtual module: l5e-global-loader\n if (id === '\\0' + VIRTUAL_L5E_GLOBAL_LOADER) {\n return `export const globalLoader = import.meta.glob('/src/global-loader.{ts,tsx}', { eager: false });`;\n }\n\n // Virtual module: l5e-actions\n if (id === '\\0' + VIRTUAL_L5E_ACTIONS) {\n const registryObj = Object.fromEntries(actionRegistry);\n return `export const viewActions = import.meta.glob('/src/**/actions.{ts,tsx}');\nexport const actionRegistry = ${JSON.stringify(registryObj)};`;\n }\n\n // Virtual module: l5e-middleware\n if (id === '\\0' + VIRTUAL_L5E_MIDDLEWARE) {\n 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`;\n }\n\n // Virtual module: l5e-islands\n // Lazy glob of all React island components so the SSR entry can import a\n // component by its __src path and renderToString() it. Non-eager → only\n // islands actually present on a page (with ssr) get imported at runtime.\n if (id === '\\0' + VIRTUAL_L5E_ISLANDS) {\n return `export const islandModules = import.meta.glob('/src/**/react/*.{tsx,jsx}');`;\n }\n\n // Virtual module: l5e-island-strategies\n if (id === '\\0' + VIRTUAL_L5E_ISLAND_STRATEGIES) {\n // Check if src/island-strategies.ts exists\n const strategiesFile = join(rootDir, 'src', 'island-strategies.ts');\n if (existsSync(strategiesFile)) {\n // Re-export user's file → Vite will build this file\n return `import '/src/island-strategies.ts';`;\n }\n // No file → empty module, no error\n return `/* no custom island strategies */`;\n }\n\n return null;\n },\n };\n}\n\nexport default coreVite;\n"],"names":["VIRTUAL_L5E_VIEWS","VIRTUAL_L5E_ROUTE","VIRTUAL_L5E_SSR_ENTRY","VIRTUAL_L5E_GLOBAL_LOADER","VIRTUAL_L5E_ISLAND_STRATEGIES","VIRTUAL_L5E_ISLANDS","VIRTUAL_L5E_ACTIONS","VIRTUAL_L5E_MIDDLEWARE","VITE_RESERVED_ENV","scanTsFiles","dir","fileList","files","readdirSync","file","filePath","join","statSync","shortHash","str","hash","i","deriveComponentName","fromPath","segments","filename","makeIslandKey","resolvedPath","resolveWithExtension","rootDir","relPath","absBase","resolve","ext","existsSync","extractIslandEntries","content","readFileSync","entries","regex","seen","match","abs","relative","src","key","extractPathsFromFile","css","js","useCssPattern","useClientJsPattern","path","absolutePath","relativePath","discoverRollupInput","input","srcDir","islandRegistry","pathToKey","keyToSrc","actionRegistry","globalTsPath","tsFiles","allCssPaths","allJsPaths","islandEntries","entry","normalizedFile","actionExportRegex","actionMatch","modulePath","dirname","actionName","actionKey","cssPath","entryName","jsPath","error","injectIslandKeys","code","fileId","result","lastIndex","anchorRegex","anchorMatch","searchStart","window","fromMatch","resolved","insertPos","coreVite","resolvedConfig","server","mod","tempDir","rmSync","_options","_bundle","outDir","mkdirSync","registryObj","writeFileSync","userConfig","projectRoot","discovered","existingInput","mergedInput","id","options","exportRegex","actions","m","name","methodMatch","method","injected","transform","transformedCode","hasChanges","varName","quote","strategiesFile"],"mappings":";;;AAaA,MAAMA,IAAoB,qBACpBC,IAAoB,qBACpBC,IAAwB,yBACxBC,IAA4B,6BAC5BC,IAAgC,iCAChCC,IAAsB,uBACtBC,IAAsB,uBACtBC,IAAyB,0BASzBC,IAAoB,oBAAI,IAAI,CAAC,QAAQ,YAAY,QAAQ,OAAO,OAAO,QAAQ,CAAC;AAKtF,SAASC,EAAYC,GAAaC,IAAqB,IAAc;AACnE,QAAMC,IAAQC,EAAYH,CAAG;AAE7B,aAAWI,KAAQF,GAAO;AACxB,UAAMG,IAAWC,EAAKN,GAAKI,CAAI;AAG/B,QAFaG,EAASF,CAAQ,EAErB,eAAe;AAEtB,UAAID,MAAS,kBAAkBA,MAAS,UAAUA,MAAS;AACzD;AAEF,MAAAL,EAAYM,GAAUJ,CAAQ;AAAA,IAChC,MAAA,EAAWG,EAAK,SAAS,MAAM,KAAKA,EAAK,SAAS,KAAK,MACrDH,EAAS,KAAKI,CAAQ;AAAA,EAE1B;AAEA,SAAOJ;AACT;AAKA,SAASO,EAAUC,GAAqB;AACtC,MAAIC,IAAO;AACX,WAASC,I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,UAAIoG,MAAO,OAAOtG;AAChB,eAAO;AAIT,UAAIsG,MAAO,OAAOvG,GAA+B;AAE/C,cAAMqH,IAAiBzG,EAAKa,GAAS,OAAO,sBAAsB;AAClE,eAAIK,EAAWuF,CAAc,IAEpB,wCAGF;AAAA,MACT;AAEA,aAAO;AAAA,IACT;AAAA,EAAA;AAEJ;"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@withl5e/l5e",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.5",
|
|
4
4
|
"description": "HTML-first SSR MPA framework with loaders, middleware, islands, actions, swap, SEO and cache controls.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -13,69 +13,89 @@
|
|
|
13
13
|
"types.d.ts",
|
|
14
14
|
"README.md"
|
|
15
15
|
],
|
|
16
|
-
"sideEffects":
|
|
16
|
+
"sideEffects": [
|
|
17
|
+
"**/island/runtime.ts",
|
|
18
|
+
"**/island/runtime.js",
|
|
19
|
+
"**/*.css"
|
|
20
|
+
],
|
|
17
21
|
"exports": {
|
|
18
22
|
".": {
|
|
23
|
+
"development": "./src/core/index.ts",
|
|
19
24
|
"types": "./src/core/index.ts",
|
|
20
25
|
"default": "./dist/index.js"
|
|
21
26
|
},
|
|
22
27
|
"./jsx-runtime": {
|
|
28
|
+
"development": "./src/core/jsx-runtime.ts",
|
|
23
29
|
"types": "./src/core/jsx-runtime.ts",
|
|
24
30
|
"default": "./dist/jsx-runtime.js"
|
|
25
31
|
},
|
|
26
32
|
"./vite-plugin": {
|
|
33
|
+
"development": "./src/core/vite-plugin.ts",
|
|
27
34
|
"types": "./src/core/vite-plugin.ts",
|
|
28
35
|
"default": "./dist/vite-plugin.js"
|
|
29
36
|
},
|
|
30
37
|
"./server": {
|
|
38
|
+
"development": "./src/core/server.ts",
|
|
31
39
|
"types": "./src/core/server.ts",
|
|
32
40
|
"default": "./dist/server.js"
|
|
33
41
|
},
|
|
34
42
|
"./entry-server": {
|
|
43
|
+
"development": "./src/core/entry-server.ts",
|
|
35
44
|
"types": "./src/core/entry-server.d.ts",
|
|
36
45
|
"default": "./dist/entry-server.js"
|
|
37
46
|
},
|
|
38
47
|
"./middleware": {
|
|
48
|
+
"development": "./src/middleware/index.ts",
|
|
39
49
|
"types": "./src/middleware/index.ts",
|
|
40
50
|
"default": "./dist/middleware.js"
|
|
41
51
|
},
|
|
42
52
|
"./tooltip": {
|
|
53
|
+
"development": "./src/tooltip/index.ts",
|
|
43
54
|
"types": "./src/tooltip/index.ts",
|
|
44
55
|
"default": "./dist/tooltip.js"
|
|
45
56
|
},
|
|
46
57
|
"./jsx-types": {
|
|
58
|
+
"development": "./src/core/jsx-types.d.ts",
|
|
47
59
|
"types": "./src/core/jsx-types.d.ts",
|
|
48
60
|
"default": "./src/core/jsx-types.d.ts"
|
|
49
61
|
},
|
|
50
62
|
"./seo": {
|
|
63
|
+
"development": "./src/seo/index.ts",
|
|
51
64
|
"types": "./src/seo/index.ts",
|
|
52
65
|
"default": "./dist/seo.js"
|
|
53
66
|
},
|
|
54
67
|
"./swap": {
|
|
68
|
+
"development": "./src/swap/index.ts",
|
|
55
69
|
"types": "./src/swap/index.ts",
|
|
56
70
|
"default": "./dist/swap.js"
|
|
57
71
|
},
|
|
58
72
|
"./swap/server": {
|
|
73
|
+
"development": "./src/swap/server.ts",
|
|
59
74
|
"types": "./src/swap/server.ts",
|
|
60
75
|
"default": "./dist/swap/server.js"
|
|
61
76
|
},
|
|
62
77
|
"./action": {
|
|
78
|
+
"development": "./src/action/index.ts",
|
|
63
79
|
"types": "./src/action/index.ts",
|
|
64
80
|
"default": "./dist/action.js"
|
|
65
81
|
},
|
|
66
82
|
"./island": {
|
|
83
|
+
"development": "./src/island/index.ts",
|
|
67
84
|
"types": "./src/island/index.ts",
|
|
68
85
|
"default": "./dist/island.js"
|
|
69
86
|
},
|
|
70
87
|
"./island/client": {
|
|
88
|
+
"development": "./src/island/client.ts",
|
|
71
89
|
"types": "./src/island/client.ts",
|
|
72
90
|
"default": "./dist/island/client.js"
|
|
73
91
|
},
|
|
74
92
|
"./island/runtime": {
|
|
93
|
+
"development": "./src/island/runtime.ts",
|
|
75
94
|
"types": "./src/island/runtime.ts",
|
|
76
95
|
"default": "./dist/island/runtime.js"
|
|
77
96
|
},
|
|
78
97
|
"./router": {
|
|
98
|
+
"development": "./src/router/index.ts",
|
|
79
99
|
"types": "./src/router/index.ts",
|
|
80
100
|
"default": "./dist/router.js"
|
|
81
101
|
}
|