@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.
Files changed (71) hide show
  1. package/README.md +1 -1
  2. package/dist/action.js +10 -9
  3. package/dist/action.js.map +1 -1
  4. package/dist/defineMiddleware-D017PWDc.js +8 -0
  5. package/dist/defineMiddleware-D017PWDc.js.map +1 -0
  6. package/dist/entry-server.js +161 -176
  7. package/dist/entry-server.js.map +1 -1
  8. package/dist/exceptions-D4OdiQjY.js +30 -0
  9. package/dist/exceptions-D4OdiQjY.js.map +1 -0
  10. package/dist/generateMetadata-DcdY-XC1.js +303 -0
  11. package/dist/generateMetadata-DcdY-XC1.js.map +1 -0
  12. package/dist/global-style-BhiGjxVU.js +21 -0
  13. package/dist/global-style-BhiGjxVU.js.map +1 -0
  14. package/dist/i18n.js +8 -11
  15. package/dist/i18n.js.map +1 -1
  16. package/dist/index.js +9 -55
  17. package/dist/island/client.js +2 -5
  18. package/dist/island/runtime.js +90 -107
  19. package/dist/island/runtime.js.map +1 -1
  20. package/dist/island.js +38 -56
  21. package/dist/island.js.map +1 -1
  22. package/dist/jsx-runtime-CI0Jmr-C.js +275 -0
  23. package/dist/jsx-runtime-CI0Jmr-C.js.map +1 -0
  24. package/dist/jsx-runtime.js +2 -31
  25. package/dist/middleware-CnDqZobD.js +217 -0
  26. package/dist/middleware-CnDqZobD.js.map +1 -0
  27. package/dist/middleware.js +3 -8
  28. package/dist/render-hUQUreah.js +152 -0
  29. package/dist/render-hUQUreah.js.map +1 -0
  30. package/dist/rolldown-runtime-B0aSnxlc.js +20 -0
  31. package/dist/router.js +72 -68
  32. package/dist/router.js.map +1 -1
  33. package/dist/seo.js +3 -7
  34. package/dist/server-5BEwGAL4.js +461 -0
  35. package/dist/server-5BEwGAL4.js.map +1 -0
  36. package/dist/server.js +2 -515
  37. package/dist/strategy-registry-wmHnsHQb.js +9 -0
  38. package/dist/strategy-registry-wmHnsHQb.js.map +1 -0
  39. package/dist/swap/server.js +11 -14
  40. package/dist/swap/server.js.map +1 -1
  41. package/dist/swap.js +109 -116
  42. package/dist/swap.js.map +1 -1
  43. package/dist/tooltip.js +145 -141
  44. package/dist/tooltip.js.map +1 -1
  45. package/dist/vite-plugin.js +315 -372
  46. package/dist/vite-plugin.js.map +1 -1
  47. package/package.json +8 -8
  48. package/src/core/bundler.ts +41 -25
  49. package/src/core/vite-plugin.ts +14 -15
  50. package/dist/client-D67hK4Yy.js +0 -9
  51. package/dist/client-D67hK4Yy.js.map +0 -1
  52. package/dist/defineMiddleware-VdHQuiUc.js +0 -7
  53. package/dist/defineMiddleware-VdHQuiUc.js.map +0 -1
  54. package/dist/exceptions-CHPz01DJ.js +0 -39
  55. package/dist/exceptions-CHPz01DJ.js.map +0 -1
  56. package/dist/generateMetadata-Cn8BIxq6.js +0 -144
  57. package/dist/generateMetadata-Cn8BIxq6.js.map +0 -1
  58. package/dist/global-style-DFvaBcuR.js +0 -27
  59. package/dist/global-style-DFvaBcuR.js.map +0 -1
  60. package/dist/index-CybB8Tdk.js +0 -315
  61. package/dist/index-CybB8Tdk.js.map +0 -1
  62. package/dist/index.js.map +0 -1
  63. package/dist/island/client.js.map +0 -1
  64. package/dist/jsx-runtime-DqAp8xlt.js +0 -296
  65. package/dist/jsx-runtime-DqAp8xlt.js.map +0 -1
  66. package/dist/jsx-runtime.js.map +0 -1
  67. package/dist/middleware.js.map +0 -1
  68. package/dist/render-CRag-5V7.js +0 -202
  69. package/dist/render-CRag-5V7.js.map +0 -1
  70. package/dist/seo.js.map +0 -1
  71. package/dist/server.js.map +0 -1
@@ -1,390 +1,333 @@
1
- import { transform as J } from "esbuild";
2
- import { existsSync as w, mkdirSync as D, writeFileSync as N, rmSync as G, statSync as O, readFileSync as T, readdirSync as H } from "fs";
3
- import { join as b, relative as S, resolve as y, dirname as K } from "path";
4
- import { f as B } from "./global-style-DFvaBcuR.js";
5
- const j = "virtual:l5e-views", v = "virtual:l5e-route", _ = "virtual:l5e-ssr-entry", E = "virtual:l5e-global-loader", R = "virtual:l5e-island-strategies", I = "virtual:l5e-islands", $ = "virtual:l5e-actions", P = "virtual:l5e-middleware", F = /* @__PURE__ */ new Set(["MODE", "BASE_URL", "PROD", "DEV", "SSR", "LEGACY"]);
6
- function k(s, o = []) {
7
- const a = H(s);
8
- for (const i of a) {
9
- const t = b(s, i);
10
- if (O(t).isDirectory()) {
11
- if (i === "node_modules" || i === "dist" || i === ".git")
12
- continue;
13
- k(t, o);
14
- } else (i.endsWith(".tsx") || i.endsWith(".ts")) && o.push(t);
15
- }
16
- return o;
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 A(s) {
19
- let o = 0;
20
- for (let a = 0; a < s.length; a++)
21
- o = (o << 5) - o + s.charCodeAt(a), o = o & o;
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 V(s) {
25
- const o = s.split("/");
26
- let a = o[o.length - 1];
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 q(s) {
30
- return `${V(s)}_${A(s)}`;
34
+ function T(e) {
35
+ return `${w(e)}_${C(e)}`;
31
36
  }
32
- function Y(s, o) {
33
- const a = s.replace(/^\//, ""), i = y(o, a);
34
- for (const t of [".tsx", ".ts", ".jsx", ".js"])
35
- if (w(i + t))
36
- return a + t;
37
- return w(i) ? a : null;
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 Z(s, o) {
40
- const a = T(s, "utf-8"), i = [], t = /<ClientIsland\s[^>]*?from\s*=\s*"([^"]+)"/g, n = /* @__PURE__ */ new Set();
41
- let c;
42
- for (; (c = t.exec(a)) !== null; ) {
43
- const l = c[1];
44
- let e;
45
- if (l.startsWith("~/"))
46
- e = "/src/" + l.substring(2);
47
- else if (l.startsWith("/src/"))
48
- e = l;
49
- else if (l.startsWith("./") || l.startsWith("../")) {
50
- const m = y(s, "..", l);
51
- e = "/" + S(o, m).replace(/\\/g, "/");
52
- } else
53
- e = l;
54
- const d = Y(e, o);
55
- if (!d) {
56
- console.warn(
57
- `[l5e] Island component not found: ${e} (from ${l} in ${s})`
58
- );
59
- continue;
60
- }
61
- const u = q(e);
62
- n.has(u) || (n.add(u), i.push({
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 X(s, o) {
73
- const a = T(s, "utf-8"), i = [], t = [], n = /useCss\s*\(\s*['"]([^'"]+)['"]\s*,?\s*\)/g, c = /useClientJs\s*\(\s*['"]([^'"]+)['"]\s*,?\s*\)/g;
74
- let l;
75
- for (; (l = n.exec(a)) !== null; ) {
76
- const e = l[1];
77
- if (e.startsWith("/src/"))
78
- i.push(e);
79
- else if (e.startsWith("./") || e.startsWith("../")) {
80
- const d = y(s, "..", e), u = "/" + S(o, d).replace(/\\/g, "/");
81
- i.push(u);
82
- } else
83
- i.push(e);
84
- }
85
- for (; (l = c.exec(a)) !== null; ) {
86
- const e = l[1];
87
- if (e.startsWith("/src/"))
88
- t.push(e);
89
- else if (e.startsWith("./") || e.startsWith("../")) {
90
- const d = y(s, "..", e), u = "/" + S(o, d).replace(/\\/g, "/");
91
- t.push(u);
92
- } else
93
- t.push(e);
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 C(s) {
98
- const o = {}, a = b(s, "src"), i = /* @__PURE__ */ new Map(), t = /* @__PURE__ */ new Map(), n = /* @__PURE__ */ new Map(), c = /* @__PURE__ */ new Map();
99
- try {
100
- if (!O(a).isDirectory())
101
- return { input: o, islandRegistry: i, pathToKey: t, keyToSrc: n, actionRegistry: c };
102
- const l = b(s, "src", "client.global.ts");
103
- w(l) && (o.global = l, console.log("[l5e] Detected src/client.global.ts and added as entry"));
104
- const e = B(s);
105
- e && (o["global-style"] = e, console.log("[l5e] Detected src/global.css and added as global stylesheet"));
106
- const d = k(a), u = /* @__PURE__ */ new Set(), m = /* @__PURE__ */ new Set();
107
- for (const r of d) {
108
- const { css: f, js: p } = X(r, s);
109
- f.forEach((h) => u.add(h)), p.forEach((h) => m.add(h));
110
- const g = Z(r, s);
111
- for (const h of g)
112
- i.set(h.key, h.resolvedPath), t.set(h.resolvedPath, h.key), n.set(h.key, h.src);
113
- const x = r.replace(/\\/g, "/");
114
- if (/\/actions\.(ts|tsx)$/.test(x)) {
115
- const h = T(r, "utf-8"), U = /export\s+const\s+(\w+)\s*=\s*defineAction\s*\(/g;
116
- let W;
117
- const L = S(a, K(r)).replace(/\\/g, "/") || ".";
118
- for (; (W = U.exec(h)) !== null; ) {
119
- const M = W[1], z = `${M}_${A(L)}`;
120
- c.set(z, { modulePath: L, actionName: M });
121
- }
122
- }
123
- }
124
- for (const r of u) {
125
- const f = r.startsWith("/src/") || r.startsWith("/") ? r.substring(1) : r, p = y(s, f);
126
- if (e && y(p) === y(e))
127
- continue;
128
- if (!w(p)) {
129
- console.warn(`[l5e] CSS file not found: ${p} (from ${r})`);
130
- continue;
131
- }
132
- const g = f.replace(/^src\//, "").replace(/\.css$/, "").replace(/\//g, "-").replace(/\\/g, "-");
133
- o[g] = p;
134
- }
135
- for (const r of m) {
136
- const f = r.startsWith("/src/") || r.startsWith("/") ? r.substring(1) : r, p = y(s, f);
137
- if (!w(p)) {
138
- console.warn(`[l5e] JS/TS file not found: ${p} (from ${r})`);
139
- continue;
140
- }
141
- const g = f.replace(/^src\//, "").replace(/\.(ts|tsx|js|jsx)$/, "").replace(/\//g, "-").replace(/\\/g, "-");
142
- o[g] = p;
143
- }
144
- for (const [r, f] of n) {
145
- const p = y(s, f);
146
- o[`island-${r}`] = p;
147
- }
148
- i.size > 0 && console.log(`[l5e] Detected ${i.size} island(s)`), c.size > 0 && console.log(`[l5e] Detected ${c.size} action(s)`);
149
- } catch (l) {
150
- console.warn("[l5e] Failed to discover rollup input:", l);
151
- }
152
- return { input: o, islandRegistry: i, pathToKey: t, keyToSrc: n, actionRegistry: c };
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 Q(s, o, a, i, t) {
155
- const n = [];
156
- let c = 0;
157
- const l = /ClientIsland\s*,\s*\{/g;
158
- let e;
159
- for (; (e = l.exec(s)) !== null; ) {
160
- const d = e.index + e[0].length, u = s.substring(d, d + 500), m = /from:\s*"([^"]+)"/.exec(u);
161
- if (!m) continue;
162
- const r = m[1];
163
- let f;
164
- if (r.startsWith("~/"))
165
- f = "/src/" + r.substring(2);
166
- else if (r.startsWith("/src/"))
167
- f = r;
168
- else if (r.startsWith("./") || r.startsWith("../")) {
169
- const h = y(o, "..", r);
170
- f = "/" + S(a, h).replace(/\\/g, "/");
171
- } else
172
- f = r;
173
- const p = i.get(f);
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 ot() {
183
- let s = process.cwd(), o = /* @__PURE__ */ new Map(), a = /* @__PURE__ */ new Map(), i = /* @__PURE__ */ new Map();
184
- return {
185
- name: "l5e-jsx-classic",
186
- enforce: "pre",
187
- configResolved(t) {
188
- s = t.root || process.cwd();
189
- },
190
- handleHotUpdate({ file: t, server: n }) {
191
- const c = S(s, t);
192
- if (/actions\.(ts|tsx)$/.test(t)) {
193
- i = C(s).actionRegistry;
194
- const e = n.moduleGraph.getModuleById("\0" + $);
195
- e && n.moduleGraph.invalidateModule(e), console.log(
196
- `[l5e] Action file changed: ${c} — re-scanned ${i.size} action(s)`
197
- );
198
- }
199
- if (t.endsWith(".css")) {
200
- console.log(`[l5e] CSS changed: ${c} - using Vite HMR`);
201
- return;
202
- }
203
- if (t.includes("client.ts")) {
204
- console.log(`[l5e] Client JS changed: ${c} - using Vite HMR`);
205
- return;
206
- }
207
- if (t.includes("/src/") || t.includes("\\src\\"))
208
- return console.log(`[l5e] SSR file changed: ${c} - triggering full reload`), n.ws.send({
209
- type: "full-reload",
210
- path: "*"
211
- }), [];
212
- },
213
- buildEnd() {
214
- const t = b(s, ".l5e-temp");
215
- if (w(t))
216
- try {
217
- G(t, { recursive: !0, force: !0 }), console.log("[l5e] Cleaned up temporary files");
218
- } catch (n) {
219
- console.warn("[l5e] Failed to cleanup temporary files:", n);
220
- }
221
- },
222
- writeBundle(t, n) {
223
- if (i.size > 0) {
224
- const c = b(s, "dist", "server");
225
- w(c) || D(c, { recursive: !0 });
226
- const l = Object.fromEntries(i);
227
- N(b(c, "action-registry.json"), JSON.stringify(l), "utf-8"), console.log(`[l5e] Wrote action-registry.json (${i.size} actions)`);
228
- }
229
- },
230
- config(t) {
231
- const n = t.root || process.cwd(), c = C(n);
232
- c.islandRegistry, o = c.pathToKey, a = c.keyToSrc, i = c.actionRegistry;
233
- const l = t.build?.rollupOptions?.input || {}, e = typeof l == "object" && !Array.isArray(l) ? { ...c.input, ...l } : c.input;
234
- return {
235
- build: {
236
- ...t.build,
237
- rollupOptions: {
238
- ...t.build?.rollupOptions,
239
- input: Object.keys(e).length > 0 ? e : void 0,
240
- // Preserve exports for island component entries — without this,
241
- // Rollup tree-shakes their exports since nothing in the bundle imports them
242
- // (they're loaded at runtime via dynamic import from the island runtime).
243
- preserveEntrySignatures: "exports-only"
244
- }
245
- }
246
- };
247
- },
248
- resolveId(t) {
249
- return t === j ? "\0" + j : t === v ? "\0" + v : t === _ ? "\0" + _ : t === E ? "\0" + E : t === R ? "\0" + R : t === I ? "\0" + I : t === $ ? "\0" + $ : t === P ? "\0" + P : null;
250
- },
251
- async transform(t, n, c) {
252
- if (n.replace(/\\/g, "/").endsWith("src/client.global.ts") && !c?.ssr)
253
- return {
254
- code: `import '@withl5e/l5e/island/runtime';
255
- ${t}`,
256
- map: null
257
- };
258
- if (!c?.ssr) {
259
- const d = n.replace(/\\/g, "/").match(/\/src\/(.+)\/actions\.(ts|tsx)$/);
260
- if (d) {
261
- const u = d[1], m = /export\s+const\s+(\w+)\s*=\s*defineAction\s*\(/g, r = [];
262
- let f;
263
- for (; (f = m.exec(t)) !== null; ) {
264
- const p = f[1], x = t.substring(f.index, f.index + 500).match(/method:\s*['"](\w+)['"]/), h = x ? x[1].toUpperCase() : "GET";
265
- r.push({ name: p, method: h });
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 ${g}(body) {
276
- const res = await fetch('/_l5e/action/${h}', {
277
- method: '${x}',
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
- }).join(`
285
-
286
- `),
287
- map: null
288
- };
289
- }
290
- }
291
- if (n.includes("node_modules") || n.includes("/react/") || n.includes("\\react\\"))
292
- return null;
293
- if (/\.(tsx|jsx)$/.test(n))
294
- try {
295
- const e = `import { Fragment as __Fragment, jsxFactory } from "@withl5e/l5e/jsx-runtime"
296
- ${t}`, d = await J(e, {
297
- loader: n.endsWith(".tsx") ? "tsx" : "jsx",
298
- jsx: "transform",
299
- jsxFactory: "jsxFactory",
300
- jsxFragment: "__Fragment",
301
- sourcemap: !0,
302
- sourcefile: n,
303
- target: "es2020"
304
- });
305
- let u = d.code;
306
- return u.includes("ClientIsland") && (u = Q(u, n, s, o, a)), {
307
- code: u,
308
- map: d.map || null
309
- };
310
- } catch (e) {
311
- throw console.error(`[l5e] Failed to transform JSX in ${n}:`, e), e;
312
- }
313
- if (c?.ssr) {
314
- let e = t, d = !1;
315
- if (e = e.replace(
316
- /import\.meta\.env\.([a-zA-Z_][a-zA-Z0-9_]*)/g,
317
- (u, m) => F.has(m) ? u : (d = !0, `process.env.${m}`)
318
- ), e = e.replace(
319
- /import\.meta\.env\[(['"`])([^'"`]+)\1\]/g,
320
- (u, m, r) => F.has(r) ? u : (d = !0, `process.env[${m}${r}${m}]`)
321
- ), d)
322
- return {
323
- code: e,
324
- map: null
325
- // Không cần source map cho env transform
326
- };
327
- }
328
- return null;
329
- },
330
- load(t) {
331
- if (t === "\0" + j)
332
- return `
333
- export const viewLoaders = import.meta.glob('/src/views/*/loader.{ts,tsx}');
334
- export const viewComponents = import.meta.glob('/src/views/*/index.tsx');
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
- if (t === "\0" + I)
377
- return "export const islandModules = import.meta.glob('/src/**/react/*.{tsx,jsx}');";
378
- if (t === "\0" + R) {
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