@withl5e/l5e 0.1.0-alpha.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 (84) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +24 -0
  3. package/dist/action.js +10 -0
  4. package/dist/action.js.map +1 -0
  5. package/dist/client-D67hK4Yy.js +9 -0
  6. package/dist/client-D67hK4Yy.js.map +1 -0
  7. package/dist/entry-server-Ckh6zfgm.js +258 -0
  8. package/dist/entry-server-Ckh6zfgm.js.map +1 -0
  9. package/dist/entry-server.js +12 -0
  10. package/dist/entry-server.js.map +1 -0
  11. package/dist/generateMetadata-C5QsMS-H.js +144 -0
  12. package/dist/generateMetadata-C5QsMS-H.js.map +1 -0
  13. package/dist/index-BIt7MJT9.js +163 -0
  14. package/dist/index-BIt7MJT9.js.map +1 -0
  15. package/dist/index.js +49 -0
  16. package/dist/index.js.map +1 -0
  17. package/dist/island/client.js +5 -0
  18. package/dist/island/client.js.map +1 -0
  19. package/dist/island/runtime.js +98 -0
  20. package/dist/island/runtime.js.map +1 -0
  21. package/dist/island.js +39 -0
  22. package/dist/island.js.map +1 -0
  23. package/dist/jsx-runtime-C2Vw67N2.js +256 -0
  24. package/dist/jsx-runtime-C2Vw67N2.js.map +1 -0
  25. package/dist/jsx-runtime.js +26 -0
  26. package/dist/jsx-runtime.js.map +1 -0
  27. package/dist/middleware.js +9 -0
  28. package/dist/middleware.js.map +1 -0
  29. package/dist/seo.js +7 -0
  30. package/dist/seo.js.map +1 -0
  31. package/dist/server.js +489 -0
  32. package/dist/server.js.map +1 -0
  33. package/dist/swap/server.js +15 -0
  34. package/dist/swap/server.js.map +1 -0
  35. package/dist/swap.js +121 -0
  36. package/dist/swap.js.map +1 -0
  37. package/dist/tooltip.js +129 -0
  38. package/dist/tooltip.js.map +1 -0
  39. package/dist/vite-plugin.js +381 -0
  40. package/dist/vite-plugin.js.map +1 -0
  41. package/index.ts +1 -0
  42. package/package.json +129 -0
  43. package/src/action/define-action.ts +8 -0
  44. package/src/action/index.ts +2 -0
  45. package/src/action/types.ts +21 -0
  46. package/src/core/bundler.ts +275 -0
  47. package/src/core/const.ts +2 -0
  48. package/src/core/entry-server.d.ts +1 -0
  49. package/src/core/entry-server.ts +381 -0
  50. package/src/core/exceptions.ts +80 -0
  51. package/src/core/head-priority.ts +15 -0
  52. package/src/core/index.ts +40 -0
  53. package/src/core/jsx-runtime.ts +325 -0
  54. package/src/core/jsx-types.d.ts +548 -0
  55. package/src/core/render.ts +181 -0
  56. package/src/core/request.ts +31 -0
  57. package/src/core/server.ts +740 -0
  58. package/src/core/vite-plugin.ts +779 -0
  59. package/src/island/ClientIsland.ts +71 -0
  60. package/src/island/client.ts +3 -0
  61. package/src/island/index.ts +3 -0
  62. package/src/island/runtime.ts +149 -0
  63. package/src/island/strategy-registry.ts +10 -0
  64. package/src/island/types.ts +28 -0
  65. package/src/middleware/defineMiddleware.ts +5 -0
  66. package/src/middleware/index.ts +133 -0
  67. package/src/middleware/sequence.ts +105 -0
  68. package/src/middleware/types.ts +28 -0
  69. package/src/seo/generateMetadata.tsx +559 -0
  70. package/src/seo/index.ts +10 -0
  71. package/src/seo/mergeMetadata.ts +200 -0
  72. package/src/seo/types.ts +316 -0
  73. package/src/swap/SwapResponse.tsx +16 -0
  74. package/src/swap/create-swap.ts +121 -0
  75. package/src/swap/index.ts +8 -0
  76. package/src/swap/parse.ts +12 -0
  77. package/src/swap/server.ts +1 -0
  78. package/src/swap/swap.ts +57 -0
  79. package/src/swap/types.ts +47 -0
  80. package/src/swap/utils.ts +7 -0
  81. package/src/tooltip/index.ts +2 -0
  82. package/src/tooltip/tooltip-loader.ts +108 -0
  83. package/src/tooltip/tooltip-runtime.ts +173 -0
  84. package/types.d.ts +14 -0
@@ -0,0 +1,381 @@
1
+ import { transform as z } from "esbuild";
2
+ import { existsSync as w, mkdirSync as J, writeFileSync as U, rmSync as V, statSync as L, readFileSync as T, readdirSync as N } from "fs";
3
+ import { join as b, relative as $, resolve as y, dirname as K } from "path";
4
+ const v = "virtual:l5e-views", S = "virtual:l5e-route", _ = "virtual:l5e-ssr-entry", P = "virtual:l5e-global-loader", R = "virtual:l5e-island-strategies", j = "virtual:l5e-actions", E = "virtual:l5e-middleware";
5
+ function C(s, r = []) {
6
+ const l = N(s);
7
+ for (const i of l) {
8
+ const t = b(s, i);
9
+ if (L(t).isDirectory()) {
10
+ if (i === "node_modules" || i === "dist" || i === ".git")
11
+ continue;
12
+ C(t, r);
13
+ } else (i.endsWith(".tsx") || i.endsWith(".ts")) && r.push(t);
14
+ }
15
+ return r;
16
+ }
17
+ function I(s) {
18
+ let r = 0;
19
+ for (let l = 0; l < s.length; l++)
20
+ r = (r << 5) - r + s.charCodeAt(l), r = r & r;
21
+ return Math.abs(r).toString(16).slice(0, 4);
22
+ }
23
+ function k(s) {
24
+ const r = s.split("/");
25
+ let l = r[r.length - 1];
26
+ return l = l.replace(/\.(tsx?|jsx?)$/, ""), l;
27
+ }
28
+ function G(s) {
29
+ return `${k(s)}_${I(s)}`;
30
+ }
31
+ function H(s, r) {
32
+ const l = s.replace(/^\//, ""), i = y(r, l);
33
+ for (const t of [".tsx", ".ts", ".jsx", ".js"])
34
+ if (w(i + t))
35
+ return l + t;
36
+ return w(i) ? l : null;
37
+ }
38
+ function D(s, r) {
39
+ const l = T(s, "utf-8"), i = [], t = /<ClientIsland\s[^>]*?from\s*=\s*"([^"]+)"/g, n = /* @__PURE__ */ new Set();
40
+ let c;
41
+ for (; (c = t.exec(l)) !== null; ) {
42
+ const a = c[1];
43
+ let e;
44
+ if (a.startsWith("~/"))
45
+ e = "/src/" + a.substring(2);
46
+ else if (a.startsWith("/src/"))
47
+ e = a;
48
+ else if (a.startsWith("./") || a.startsWith("../")) {
49
+ const o = y(s, "..", a);
50
+ e = "/" + $(r, o).replace(/\\/g, "/");
51
+ } else
52
+ e = a;
53
+ const d = H(e, r);
54
+ if (!d) {
55
+ console.warn(
56
+ `[l5e] Island component not found: ${e} (from ${a} in ${s})`
57
+ );
58
+ continue;
59
+ }
60
+ const h = G(e);
61
+ n.has(h) || (n.add(h), i.push({
62
+ component: k(e),
63
+ resolvedPath: e,
64
+ src: d,
65
+ // "src/views/.../Counter.tsx" — matches manifest key format
66
+ key: h
67
+ }));
68
+ }
69
+ return i;
70
+ }
71
+ function B(s, r) {
72
+ const l = T(s, "utf-8"), i = [], t = [], n = /useCss\s*\(\s*['"]([^'"]+)['"]\s*,?\s*\)/g, c = /useClientJs\s*\(\s*['"]([^'"]+)['"]\s*,?\s*\)/g;
73
+ let a;
74
+ for (; (a = n.exec(l)) !== null; ) {
75
+ const e = a[1];
76
+ if (e.startsWith("/src/"))
77
+ i.push(e);
78
+ else if (e.startsWith("./") || e.startsWith("../")) {
79
+ const d = y(s, "..", e), h = "/" + $(r, d).replace(/\\/g, "/");
80
+ i.push(h);
81
+ } else
82
+ i.push(e);
83
+ }
84
+ for (; (a = c.exec(l)) !== null; ) {
85
+ const e = a[1];
86
+ if (e.startsWith("/src/"))
87
+ t.push(e);
88
+ else if (e.startsWith("./") || e.startsWith("../")) {
89
+ const d = y(s, "..", e), h = "/" + $(r, d).replace(/\\/g, "/");
90
+ t.push(h);
91
+ } else
92
+ t.push(e);
93
+ }
94
+ return { css: i, js: t };
95
+ }
96
+ function M(s) {
97
+ const r = {}, l = b(s, "src"), i = /* @__PURE__ */ new Map(), t = /* @__PURE__ */ new Map(), n = /* @__PURE__ */ new Map(), c = /* @__PURE__ */ new Map();
98
+ try {
99
+ if (!L(l).isDirectory())
100
+ return { input: r, islandRegistry: i, pathToKey: t, keyToSrc: n, actionRegistry: c };
101
+ const a = b(s, "src", "client.global.ts");
102
+ w(a) && (r.global = a, console.log("[l5e] Detected src/client.global.ts and added as entry"));
103
+ const e = C(l), d = /* @__PURE__ */ new Set(), h = /* @__PURE__ */ new Set();
104
+ for (const o of e) {
105
+ const { css: u, js: f } = B(o, s);
106
+ u.forEach((p) => d.add(p)), f.forEach((p) => h.add(p));
107
+ const m = D(o, s);
108
+ for (const p of m)
109
+ i.set(p.key, p.resolvedPath), t.set(p.resolvedPath, p.key), n.set(p.key, p.src);
110
+ const g = o.replace(/\\/g, "/");
111
+ if (/\/actions\.(ts|tsx)$/.test(g)) {
112
+ const p = T(o, "utf-8"), x = /export\s+const\s+(\w+)\s*=\s*defineAction\s*\(/g;
113
+ let W;
114
+ const A = $(l, K(o)).replace(/\\/g, "/") || ".";
115
+ for (; (W = x.exec(p)) !== null; ) {
116
+ const F = W[1], O = `${F}_${I(A)}`;
117
+ c.set(O, { modulePath: A, actionName: F });
118
+ }
119
+ }
120
+ }
121
+ for (const o of d) {
122
+ const u = o.startsWith("/src/") || o.startsWith("/") ? o.substring(1) : o, f = y(s, u);
123
+ if (!w(f)) {
124
+ console.warn(`[l5e] CSS file not found: ${f} (from ${o})`);
125
+ continue;
126
+ }
127
+ const m = u.replace(/^src\//, "").replace(/\.css$/, "").replace(/\//g, "-").replace(/\\/g, "-");
128
+ r[m] = f;
129
+ }
130
+ for (const o of h) {
131
+ const u = o.startsWith("/src/") || o.startsWith("/") ? o.substring(1) : o, f = y(s, u);
132
+ if (!w(f)) {
133
+ console.warn(`[l5e] JS/TS file not found: ${f} (from ${o})`);
134
+ continue;
135
+ }
136
+ const m = u.replace(/^src\//, "").replace(/\.(ts|tsx|js|jsx)$/, "").replace(/\//g, "-").replace(/\\/g, "-");
137
+ r[m] = f;
138
+ }
139
+ for (const [o, u] of n) {
140
+ const f = y(s, u);
141
+ r[`island-${o}`] = f;
142
+ }
143
+ i.size > 0 && console.log(`[l5e] Detected ${i.size} island(s)`), c.size > 0 && console.log(`[l5e] Detected ${c.size} action(s)`);
144
+ } catch (a) {
145
+ console.warn("[l5e] Failed to discover rollup input:", a);
146
+ }
147
+ return { input: r, islandRegistry: i, pathToKey: t, keyToSrc: n, actionRegistry: c };
148
+ }
149
+ function Z(s, r, l, i, t) {
150
+ const n = [];
151
+ let c = 0;
152
+ const a = /ClientIsland\s*,\s*\{/g;
153
+ let e;
154
+ for (; (e = a.exec(s)) !== null; ) {
155
+ const d = e.index + e[0].length, h = s.substring(d, d + 500), o = /from:\s*"([^"]+)"/.exec(h);
156
+ if (!o) continue;
157
+ const u = o[1];
158
+ let f;
159
+ if (u.startsWith("~/"))
160
+ f = "/src/" + u.substring(2);
161
+ else if (u.startsWith("/src/"))
162
+ f = u;
163
+ else if (u.startsWith("./") || u.startsWith("../")) {
164
+ const x = y(r, "..", u);
165
+ f = "/" + $(l, x).replace(/\\/g, "/");
166
+ } else
167
+ f = u;
168
+ const m = i.get(f);
169
+ if (!m) continue;
170
+ const g = t.get(m);
171
+ if (!g) continue;
172
+ const p = d + o.index + o[0].length;
173
+ n.push(s.substring(c, p)), n.push(`, __key: "${m}", __src: "${g}"`), c = p;
174
+ }
175
+ return n.push(s.substring(c)), n.join("");
176
+ }
177
+ function tt() {
178
+ let s = process.cwd(), r = /* @__PURE__ */ new Map(), l = /* @__PURE__ */ new Map(), i = /* @__PURE__ */ new Map();
179
+ return {
180
+ name: "l5e-jsx-classic",
181
+ enforce: "pre",
182
+ configResolved(t) {
183
+ s = t.root || process.cwd();
184
+ },
185
+ handleHotUpdate({ file: t, server: n }) {
186
+ const c = $(s, t);
187
+ if (/actions\.(ts|tsx)$/.test(t)) {
188
+ i = M(s).actionRegistry;
189
+ const e = n.moduleGraph.getModuleById("\0" + j);
190
+ e && n.moduleGraph.invalidateModule(e), console.log(
191
+ `[l5e] Action file changed: ${c} — re-scanned ${i.size} action(s)`
192
+ );
193
+ }
194
+ if (t.endsWith(".css")) {
195
+ console.log(`[l5e] CSS changed: ${c} - using Vite HMR`);
196
+ return;
197
+ }
198
+ if (t.includes("client.ts")) {
199
+ console.log(`[l5e] Client JS changed: ${c} - using Vite HMR`);
200
+ return;
201
+ }
202
+ if (t.includes("/src/") || t.includes("\\src\\"))
203
+ return console.log(`[l5e] SSR file changed: ${c} - triggering full reload`), n.ws.send({
204
+ type: "full-reload",
205
+ path: "*"
206
+ }), [];
207
+ },
208
+ buildEnd() {
209
+ const t = b(s, ".l5e-temp");
210
+ if (w(t))
211
+ try {
212
+ V(t, { recursive: !0, force: !0 }), console.log("[l5e] Cleaned up temporary files");
213
+ } catch (n) {
214
+ console.warn("[l5e] Failed to cleanup temporary files:", n);
215
+ }
216
+ },
217
+ writeBundle(t, n) {
218
+ if (i.size > 0) {
219
+ const c = b(s, "dist", "server");
220
+ w(c) || J(c, { recursive: !0 });
221
+ const a = Object.fromEntries(i);
222
+ U(b(c, "action-registry.json"), JSON.stringify(a), "utf-8"), console.log(`[l5e] Wrote action-registry.json (${i.size} actions)`);
223
+ }
224
+ },
225
+ config(t) {
226
+ const n = t.root || process.cwd(), c = M(n);
227
+ c.islandRegistry, r = c.pathToKey, l = c.keyToSrc, i = c.actionRegistry;
228
+ const a = t.build?.rollupOptions?.input || {}, e = typeof a == "object" && !Array.isArray(a) ? { ...c.input, ...a } : c.input;
229
+ return {
230
+ build: {
231
+ ...t.build,
232
+ rollupOptions: {
233
+ ...t.build?.rollupOptions,
234
+ input: Object.keys(e).length > 0 ? e : void 0,
235
+ // Preserve exports for island component entries — without this,
236
+ // Rollup tree-shakes their exports since nothing in the bundle imports them
237
+ // (they're loaded at runtime via dynamic import from the island runtime).
238
+ preserveEntrySignatures: "exports-only"
239
+ }
240
+ }
241
+ };
242
+ },
243
+ resolveId(t) {
244
+ return t === v ? "\0" + v : t === S ? "\0" + S : t === _ ? "\0" + _ : t === P ? "\0" + P : t === R ? "\0" + R : t === j ? "\0" + j : t === E ? "\0" + E : null;
245
+ },
246
+ async transform(t, n, c) {
247
+ if (n.replace(/\\/g, "/").endsWith("src/client.global.ts") && !c?.ssr)
248
+ return {
249
+ code: `import '@withl5e/l5e/island/runtime';
250
+ ${t}`,
251
+ map: null
252
+ };
253
+ if (!c?.ssr) {
254
+ const d = n.replace(/\\/g, "/").match(/\/src\/(.+)\/actions\.(ts|tsx)$/);
255
+ if (d) {
256
+ const h = d[1], o = /export\s+const\s+(\w+)\s*=\s*defineAction\s*\(/g, u = [];
257
+ let f;
258
+ for (; (f = o.exec(t)) !== null; ) {
259
+ const m = f[1], p = t.substring(f.index, f.index + 500).match(/method:\s*['"](\w+)['"]/), x = p ? p[1].toUpperCase() : "GET";
260
+ u.push({ name: m, method: x });
261
+ }
262
+ if (u.length > 0)
263
+ return {
264
+ code: u.map(({ name: g, method: p }) => {
265
+ const x = `${g}_${I(h)}`;
266
+ return p === "GET" ? `export async function ${g}(params) {
267
+ const res = await fetch('/_l5e/action/${x}?' + new URLSearchParams(params));
268
+ if (!res.ok) throw Object.assign(new Error('HTTP ' + res.status), { status: res.status });
269
+ return res;
270
+ }` : `export async function ${g}(body) {
271
+ const res = await fetch('/_l5e/action/${x}', {
272
+ method: '${p}',
273
+ headers: { 'Content-Type': 'application/json' },
274
+ body: JSON.stringify(body),
275
+ });
276
+ if (!res.ok) throw Object.assign(new Error('HTTP ' + res.status), { status: res.status });
277
+ return res;
278
+ }`;
279
+ }).join(`
280
+
281
+ `),
282
+ map: null
283
+ };
284
+ }
285
+ }
286
+ if (n.includes("node_modules") || n.includes("/react/") || n.includes("\\react\\"))
287
+ return null;
288
+ if (/\.(tsx|jsx)$/.test(n))
289
+ try {
290
+ const e = `import { Fragment as __Fragment, jsxFactory } from "@withl5e/l5e/jsx-runtime"
291
+ ${t}`, d = await z(e, {
292
+ loader: n.endsWith(".tsx") ? "tsx" : "jsx",
293
+ jsx: "transform",
294
+ jsxFactory: "jsxFactory",
295
+ jsxFragment: "__Fragment",
296
+ sourcemap: !0,
297
+ sourcefile: n,
298
+ target: "es2020"
299
+ });
300
+ let h = d.code;
301
+ return h.includes("ClientIsland") && (h = Z(h, n, s, r, l)), {
302
+ code: h,
303
+ map: d.map || null
304
+ };
305
+ } catch (e) {
306
+ throw console.error(`[l5e] Failed to transform JSX in ${n}:`, e), e;
307
+ }
308
+ if (c?.ssr) {
309
+ let e = t, d = !1;
310
+ if (e = e.replace(
311
+ /import\.meta\.env\.([a-zA-Z_][a-zA-Z0-9_]*)/g,
312
+ (h, o) => (d = !0, `process.env.${o}`)
313
+ ), e = e.replace(
314
+ /import\.meta\.env\[(['"`])([^'"`]+)\1\]/g,
315
+ (h, o, u) => (d = !0, `process.env[${o}${u}${o}]`)
316
+ ), d)
317
+ return {
318
+ code: e,
319
+ map: null
320
+ // Không cần source map cho env transform
321
+ };
322
+ }
323
+ return null;
324
+ },
325
+ load(t) {
326
+ if (t === "\0" + v)
327
+ return `
328
+ export const viewLoaders = import.meta.glob('/src/views/*/loader.{ts,tsx}');
329
+ export const viewComponents = import.meta.glob('/src/views/*/index.tsx');
330
+ `;
331
+ if (t === "\0" + S)
332
+ return "export { default } from '/src/route.ts';";
333
+ if (t === "\0" + _)
334
+ return `export { render } from '@withl5e/l5e/entry-server';
335
+ export { viewActions } from 'virtual:l5e-actions';`;
336
+ if (t === "\0" + P)
337
+ return "export const globalLoader = import.meta.glob('/src/global-loader.{ts,tsx}', { eager: false });";
338
+ if (t === "\0" + j) {
339
+ const n = Object.fromEntries(i);
340
+ return `export const viewActions = import.meta.glob('/src/**/actions.{ts,tsx}');
341
+ export const actionRegistry = ${JSON.stringify(n)};`;
342
+ }
343
+ if (t === "\0" + E)
344
+ return `
345
+ const middlewareModules = import.meta.glob([
346
+ '/src/middleware.{ts,tsx,js,jsx}',
347
+ '/src/middleware/index.{ts,tsx,js,jsx}',
348
+ ]);
349
+
350
+ const middlewarePaths = [
351
+ '/src/middleware.ts',
352
+ '/src/middleware.tsx',
353
+ '/src/middleware.js',
354
+ '/src/middleware.jsx',
355
+ '/src/middleware/index.ts',
356
+ '/src/middleware/index.tsx',
357
+ '/src/middleware/index.js',
358
+ '/src/middleware/index.jsx',
359
+ ];
360
+
361
+ export async function loadMiddleware() {
362
+ const middlewarePath = middlewarePaths.find((path) => middlewareModules[path]);
363
+ if (!middlewarePath) return undefined;
364
+
365
+ const mod = await middlewareModules[middlewarePath]();
366
+ return mod.onRequest;
367
+ }
368
+ `;
369
+ if (t === "\0" + R) {
370
+ const n = b(s, "src", "island-strategies.ts");
371
+ return w(n) ? "import '/src/island-strategies.ts';" : "/* no custom island strategies */";
372
+ }
373
+ return null;
374
+ }
375
+ };
376
+ }
377
+ export {
378
+ tt as coreVite,
379
+ tt as default
380
+ };
381
+ //# sourceMappingURL=vite-plugin.js.map
@@ -0,0 +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 * 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 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 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","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;AAK/B,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,EAAS,QAAQ,kBAAkB,EAAE,GACzCA;AACT;AAKA,SAASC,EAAcC,GAA8B;AAEnD,SAAO,GADML,EAAoBK,CAAY,CAC/B,IAAIT,EAAUS,CAAY,CAAC;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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,OAAOzG;AAChB,eAAO;AAAA;AAAA;AAAA;AAOT,UAAIyG,MAAO,OAAOxG;AAEhB,eAAO;AAIT,UAAIwG,MAAO,OAAOvG;AAChB,eAAO;AAAA;AAKT,UAAIuG,MAAO,OAAOtG;AAChB,eAAO;AAIT,UAAIsG,MAAO,OAAOpG,GAAqB;AACrC,cAAM6F,IAAc,OAAO,YAAYxC,CAAc;AACrD,eAAO;AAAA,gCACiB,KAAK,UAAUwC,CAAW,CAAC;AAAA,MACrD;AAGA,UAAIO,MAAO,OAAOnG;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,UAAImG,MAAO,OAAOrG,GAA+B;AAE/C,cAAMmH,IAAiBzG,EAAKa,GAAS,OAAO,sBAAsB;AAClE,eAAIK,EAAWuF,CAAc,IAEpB,wCAGF;AAAA,MACT;AAEA,aAAO;AAAA,IACT;AAAA,EAAA;AAEJ;"}
package/index.ts ADDED
@@ -0,0 +1 @@
1
+ export * from './src/core';
package/package.json ADDED
@@ -0,0 +1,129 @@
1
+ {
2
+ "name": "@withl5e/l5e",
3
+ "version": "0.1.0-alpha.0",
4
+ "description": "HTML-first SSR MPA framework with loaders, middleware, islands, actions, swap, SEO and cache controls.",
5
+ "type": "module",
6
+ "license": "MIT",
7
+ "main": "./dist/index.js",
8
+ "types": "./src/core/index.ts",
9
+ "files": [
10
+ "dist",
11
+ "src",
12
+ "index.ts",
13
+ "types.d.ts",
14
+ "README.md"
15
+ ],
16
+ "sideEffects": false,
17
+ "exports": {
18
+ ".": {
19
+ "types": "./src/core/index.ts",
20
+ "development": "./index.ts",
21
+ "default": "./dist/index.js"
22
+ },
23
+ "./jsx-runtime": {
24
+ "types": "./src/core/jsx-runtime.ts",
25
+ "development": "./src/core/jsx-runtime.ts",
26
+ "default": "./dist/jsx-runtime.js"
27
+ },
28
+ "./vite-plugin": {
29
+ "types": "./src/core/vite-plugin.ts",
30
+ "development": "./src/core/vite-plugin.ts",
31
+ "default": "./dist/vite-plugin.js"
32
+ },
33
+ "./server": {
34
+ "types": "./src/core/server.ts",
35
+ "development": "./src/core/server.ts",
36
+ "default": "./dist/server.js"
37
+ },
38
+ "./entry-server": {
39
+ "types": "./src/core/entry-server.d.ts",
40
+ "development": "./src/core/entry-server.ts",
41
+ "default": "./dist/entry-server.js"
42
+ },
43
+ "./middleware": {
44
+ "types": "./src/middleware/index.ts",
45
+ "development": "./src/middleware/index.ts",
46
+ "default": "./dist/middleware.js"
47
+ },
48
+ "./tooltip": {
49
+ "types": "./src/tooltip/index.ts",
50
+ "development": "./src/tooltip/index.ts",
51
+ "default": "./dist/tooltip.js"
52
+ },
53
+ "./jsx-types": {
54
+ "types": "./src/core/jsx-types.d.ts",
55
+ "development": "./src/core/jsx-types.d.ts",
56
+ "default": "./src/core/jsx-types.d.ts"
57
+ },
58
+ "./seo": {
59
+ "types": "./src/seo/index.ts",
60
+ "development": "./src/seo/index.ts",
61
+ "default": "./dist/seo.js"
62
+ },
63
+ "./swap": {
64
+ "types": "./src/swap/index.ts",
65
+ "development": "./src/swap/index.ts",
66
+ "default": "./dist/swap.js"
67
+ },
68
+ "./swap/server": {
69
+ "types": "./src/swap/server.ts",
70
+ "development": "./src/swap/server.ts",
71
+ "default": "./dist/swap/server.js"
72
+ },
73
+ "./action": {
74
+ "types": "./src/action/index.ts",
75
+ "development": "./src/action/index.ts",
76
+ "default": "./dist/action.js"
77
+ },
78
+ "./island": {
79
+ "types": "./src/island/index.ts",
80
+ "development": "./src/island/index.ts",
81
+ "default": "./dist/island.js"
82
+ },
83
+ "./island/client": {
84
+ "types": "./src/island/client.ts",
85
+ "development": "./src/island/client.ts",
86
+ "default": "./dist/island/client.js"
87
+ },
88
+ "./island/runtime": {
89
+ "types": "./src/island/runtime.ts",
90
+ "development": "./src/island/runtime.ts",
91
+ "default": "./dist/island/runtime.js"
92
+ }
93
+ },
94
+ "dependencies": {
95
+ "@floating-ui/dom": "1.7.4",
96
+ "compression": "^1.7.4",
97
+ "esbuild": "^0.24.2",
98
+ "express": "^4.18.2",
99
+ "request-ip": "^3.3.0",
100
+ "rollup": "^4.0.0",
101
+ "sirv": "^2.0.3"
102
+ },
103
+ "peerDependencies": {
104
+ "react": "^19.0.0",
105
+ "react-dom": "^19.0.0",
106
+ "vite": "^7.0.0"
107
+ },
108
+ "devDependencies": {
109
+ "@types/express": "^4.17.25",
110
+ "@types/react": "^19.0.0",
111
+ "@types/react-dom": "^19.0.0",
112
+ "@types/request-ip": "0.0.41",
113
+ "react": "^19.0.0",
114
+ "react-dom": "^19.0.0",
115
+ "typescript": "^5.6.3",
116
+ "vite": "^7.1.5",
117
+ "vitest": "^2.1.3"
118
+ },
119
+ "publishConfig": {
120
+ "access": "public"
121
+ },
122
+ "scripts": {
123
+ "build": "vite build",
124
+ "typecheck": "tsc --noEmit",
125
+ "test": "vitest run",
126
+ "test:watch": "vitest",
127
+ "test:coverage": "vitest run --coverage"
128
+ }
129
+ }
@@ -0,0 +1,8 @@
1
+ import type { ActionOptions, Action } from './types';
2
+
3
+ export function defineAction(opts: ActionOptions): Action {
4
+ return {
5
+ handler: opts.handler,
6
+ method: opts.method ?? 'GET',
7
+ } as Action;
8
+ }
@@ -0,0 +1,2 @@
1
+ export { defineAction } from './define-action';
2
+ export type { ActionOptions, Action } from './types';
@@ -0,0 +1,21 @@
1
+ import type { RequestInfo } from '../core/entry-server';
2
+ import type { JSXChild, RenderedNode } from '../core/jsx-runtime';
3
+
4
+ type ActionReturn = JSXChild | RenderedNode;
5
+
6
+ export interface ActionOptions {
7
+ method?: 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE';
8
+ handler: (req: RequestInfo) => ActionReturn | Promise<ActionReturn>;
9
+ }
10
+
11
+ /**
12
+ * Action is both a server-side object (with handler/method) and
13
+ * a callable function on the client (after Vite transform replaces it with a fetch stub).
14
+ * The call signature matches what the client sees after transform.
15
+ */
16
+ export interface Action {
17
+ handler: (req: RequestInfo) => ActionReturn | Promise<ActionReturn>;
18
+ method: string;
19
+ // Client-side call signature (Vite transform replaces Action with an async function)
20
+ (params?: Record<string, any>): Promise<Response>;
21
+ }