@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.
- package/LICENSE +21 -0
- package/README.md +24 -0
- package/dist/action.js +10 -0
- package/dist/action.js.map +1 -0
- package/dist/client-D67hK4Yy.js +9 -0
- package/dist/client-D67hK4Yy.js.map +1 -0
- package/dist/entry-server-Ckh6zfgm.js +258 -0
- package/dist/entry-server-Ckh6zfgm.js.map +1 -0
- package/dist/entry-server.js +12 -0
- package/dist/entry-server.js.map +1 -0
- package/dist/generateMetadata-C5QsMS-H.js +144 -0
- package/dist/generateMetadata-C5QsMS-H.js.map +1 -0
- package/dist/index-BIt7MJT9.js +163 -0
- package/dist/index-BIt7MJT9.js.map +1 -0
- package/dist/index.js +49 -0
- package/dist/index.js.map +1 -0
- package/dist/island/client.js +5 -0
- package/dist/island/client.js.map +1 -0
- package/dist/island/runtime.js +98 -0
- package/dist/island/runtime.js.map +1 -0
- package/dist/island.js +39 -0
- package/dist/island.js.map +1 -0
- package/dist/jsx-runtime-C2Vw67N2.js +256 -0
- package/dist/jsx-runtime-C2Vw67N2.js.map +1 -0
- package/dist/jsx-runtime.js +26 -0
- package/dist/jsx-runtime.js.map +1 -0
- package/dist/middleware.js +9 -0
- package/dist/middleware.js.map +1 -0
- package/dist/seo.js +7 -0
- package/dist/seo.js.map +1 -0
- package/dist/server.js +489 -0
- package/dist/server.js.map +1 -0
- package/dist/swap/server.js +15 -0
- package/dist/swap/server.js.map +1 -0
- package/dist/swap.js +121 -0
- package/dist/swap.js.map +1 -0
- package/dist/tooltip.js +129 -0
- package/dist/tooltip.js.map +1 -0
- package/dist/vite-plugin.js +381 -0
- package/dist/vite-plugin.js.map +1 -0
- package/index.ts +1 -0
- package/package.json +129 -0
- package/src/action/define-action.ts +8 -0
- package/src/action/index.ts +2 -0
- package/src/action/types.ts +21 -0
- package/src/core/bundler.ts +275 -0
- package/src/core/const.ts +2 -0
- package/src/core/entry-server.d.ts +1 -0
- package/src/core/entry-server.ts +381 -0
- package/src/core/exceptions.ts +80 -0
- package/src/core/head-priority.ts +15 -0
- package/src/core/index.ts +40 -0
- package/src/core/jsx-runtime.ts +325 -0
- package/src/core/jsx-types.d.ts +548 -0
- package/src/core/render.ts +181 -0
- package/src/core/request.ts +31 -0
- package/src/core/server.ts +740 -0
- package/src/core/vite-plugin.ts +779 -0
- package/src/island/ClientIsland.ts +71 -0
- package/src/island/client.ts +3 -0
- package/src/island/index.ts +3 -0
- package/src/island/runtime.ts +149 -0
- package/src/island/strategy-registry.ts +10 -0
- package/src/island/types.ts +28 -0
- package/src/middleware/defineMiddleware.ts +5 -0
- package/src/middleware/index.ts +133 -0
- package/src/middleware/sequence.ts +105 -0
- package/src/middleware/types.ts +28 -0
- package/src/seo/generateMetadata.tsx +559 -0
- package/src/seo/index.ts +10 -0
- package/src/seo/mergeMetadata.ts +200 -0
- package/src/seo/types.ts +316 -0
- package/src/swap/SwapResponse.tsx +16 -0
- package/src/swap/create-swap.ts +121 -0
- package/src/swap/index.ts +8 -0
- package/src/swap/parse.ts +12 -0
- package/src/swap/server.ts +1 -0
- package/src/swap/swap.ts +57 -0
- package/src/swap/types.ts +47 -0
- package/src/swap/utils.ts +7 -0
- package/src/tooltip/index.ts +2 -0
- package/src/tooltip/tooltip-loader.ts +108 -0
- package/src/tooltip/tooltip-runtime.ts +173 -0
- package/types.d.ts +14 -0
package/dist/server.js
ADDED
|
@@ -0,0 +1,489 @@
|
|
|
1
|
+
import { existsSync as V } from "fs";
|
|
2
|
+
import M from "node:fs/promises";
|
|
3
|
+
import u from "node:path";
|
|
4
|
+
import { pathToFileURL as I } from "node:url";
|
|
5
|
+
import W from "request-ip";
|
|
6
|
+
import { p as K, c as X, a as Y } from "./index-BIt7MJT9.js";
|
|
7
|
+
import { createHash as Z } from "node:crypto";
|
|
8
|
+
import { rollup as Q } from "rollup";
|
|
9
|
+
const N = /* @__PURE__ */ new Map(), J = /* @__PURE__ */ new Map(), B = /* @__PURE__ */ new Map();
|
|
10
|
+
function U(e) {
|
|
11
|
+
return Z("sha256").update(e).digest("hex").substring(0, 16);
|
|
12
|
+
}
|
|
13
|
+
async function q(e, t, n) {
|
|
14
|
+
if (e.length === 0)
|
|
15
|
+
return { hash: "", filename: "", content: "" };
|
|
16
|
+
const o = [...new Set(e)], f = `scripts:${o.sort().join(",")}`, h = J.get(f);
|
|
17
|
+
if (h) {
|
|
18
|
+
const a = N.get(h);
|
|
19
|
+
if (a)
|
|
20
|
+
return {
|
|
21
|
+
hash: a.hash,
|
|
22
|
+
filename: a.filename,
|
|
23
|
+
content: a.content
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
let c = null;
|
|
27
|
+
try {
|
|
28
|
+
const a = U(o.join(`
|
|
29
|
+
`)), g = u.join(t, ".temp-bundle");
|
|
30
|
+
await M.mkdir(g, { recursive: !0 }).catch(() => {
|
|
31
|
+
}), c = u.join(g, `entry-${a}.js`);
|
|
32
|
+
const v = o.map((s, l) => {
|
|
33
|
+
const d = s.startsWith("/") ? u.join(n, s.substring(1)) : u.join(n, s);
|
|
34
|
+
return `import ${JSON.stringify(d)};`;
|
|
35
|
+
}).join(`
|
|
36
|
+
`);
|
|
37
|
+
await M.writeFile(c, v, "utf-8"), console.log(`[bundler] Wrote entry file to ${c}`), console.log(`[bundler] Entry content: ${v}`);
|
|
38
|
+
const C = {
|
|
39
|
+
input: c,
|
|
40
|
+
plugins: [
|
|
41
|
+
{
|
|
42
|
+
name: "vendor-path-rewriter",
|
|
43
|
+
resolveId(s, l, d) {
|
|
44
|
+
if (s.includes("vendor-") || s.includes("chunk-") || s.includes(".global")) {
|
|
45
|
+
if (console.log(`[bundler] Resolving source: ${s}`), u.isAbsolute(s))
|
|
46
|
+
return console.log(`[bundler] Resolving absolute path: ${s}`), { id: "/" + u.relative(n, s).replace(/\\/g, "/"), external: !0 };
|
|
47
|
+
if (l && s.startsWith(".")) {
|
|
48
|
+
console.log(
|
|
49
|
+
`[bundler] Resolving relative path: ${s} from importer: ${l}`
|
|
50
|
+
);
|
|
51
|
+
const y = u.resolve(u.dirname(l), s);
|
|
52
|
+
return { id: "/" + u.relative(n, y).replace(/\\/g, "/"), external: !0 };
|
|
53
|
+
} else
|
|
54
|
+
console.log(`[bundler] Resolving source: ${s}`);
|
|
55
|
+
}
|
|
56
|
+
return null;
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
],
|
|
60
|
+
external: (s) => !s.startsWith(".") && !u.isAbsolute(s) ? !0 : (s.includes("vendor-") || s.includes("chunk-") || s.includes(".global"), !1)
|
|
61
|
+
}, x = {
|
|
62
|
+
format: "es",
|
|
63
|
+
inlineDynamicImports: !1,
|
|
64
|
+
entryFileNames: "bundle-[hash].js",
|
|
65
|
+
chunkFileNames: "bundle-[hash].js"
|
|
66
|
+
}, F = await Q(C), { output: S } = await F.generate(x);
|
|
67
|
+
await F.close(), S.forEach((s) => {
|
|
68
|
+
if (s.type !== "chunk")
|
|
69
|
+
return;
|
|
70
|
+
const l = {
|
|
71
|
+
content: s.code || "",
|
|
72
|
+
hash: U(s.code || ""),
|
|
73
|
+
filename: s.fileName,
|
|
74
|
+
mimeType: "application/javascript"
|
|
75
|
+
};
|
|
76
|
+
N.set(s.fileName, l);
|
|
77
|
+
});
|
|
78
|
+
const i = S[0];
|
|
79
|
+
return i?.type === "chunk" && J.set(f, i.fileName), {
|
|
80
|
+
hash: U(S[0]?.code || ""),
|
|
81
|
+
filename: S[0]?.fileName || "",
|
|
82
|
+
content: S[0]?.code || ""
|
|
83
|
+
};
|
|
84
|
+
} catch (a) {
|
|
85
|
+
return console.error("[bundler] Error bundling scripts:", a), { hash: "", filename: "", content: "" };
|
|
86
|
+
} finally {
|
|
87
|
+
c && await M.unlink(c).catch(() => {
|
|
88
|
+
});
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
async function ee(e, t, n) {
|
|
92
|
+
if (e.length === 0)
|
|
93
|
+
return { hash: "", filename: "", content: "" };
|
|
94
|
+
const o = [...new Set(e)], f = `css:${o.sort().join(",")}`, h = B.get(f);
|
|
95
|
+
if (h) {
|
|
96
|
+
const c = N.get(h);
|
|
97
|
+
if (c)
|
|
98
|
+
return {
|
|
99
|
+
hash: c.hash,
|
|
100
|
+
filename: c.filename,
|
|
101
|
+
content: c.content
|
|
102
|
+
};
|
|
103
|
+
}
|
|
104
|
+
try {
|
|
105
|
+
const c = [];
|
|
106
|
+
for (const x of o) {
|
|
107
|
+
const F = x.startsWith("/") ? u.join(n, x.substring(1)) : u.join(n, x);
|
|
108
|
+
try {
|
|
109
|
+
const S = await M.readFile(F, "utf-8");
|
|
110
|
+
c.push(`/* ${x} */
|
|
111
|
+
${S}
|
|
112
|
+
`);
|
|
113
|
+
} catch (S) {
|
|
114
|
+
console.warn(`[bundler] Failed to read CSS file: ${x}`, S);
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
const a = c.join(`
|
|
118
|
+
|
|
119
|
+
`), g = U(a), v = `bundle-${g}.css`, C = {
|
|
120
|
+
content: a,
|
|
121
|
+
hash: g,
|
|
122
|
+
filename: v,
|
|
123
|
+
mimeType: "text/css"
|
|
124
|
+
};
|
|
125
|
+
return N.set(v, C), B.set(f, v), { hash: g, filename: v, content: a };
|
|
126
|
+
} catch (c) {
|
|
127
|
+
return console.error("[bundler] Error bundling CSS:", c), { hash: "", filename: "", content: "" };
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
function te(e) {
|
|
131
|
+
return N.get(e);
|
|
132
|
+
}
|
|
133
|
+
function ne(e, t) {
|
|
134
|
+
return e.replace(/<html\b([^>]*)>/i, (n, o) => /\blang\s*=/i.test(o) ? n.replace(/lang\s*=\s*"[^"]*"/i, `lang="${t}"`) : `<html lang="${t}"${o}>`);
|
|
135
|
+
}
|
|
136
|
+
function se(e) {
|
|
137
|
+
return new URL(`${e.protocol}://${e.get("host")}${e.originalUrl}`);
|
|
138
|
+
}
|
|
139
|
+
function z(e, t) {
|
|
140
|
+
return `${e.pathname}${e.search}`.replace(t, "") || "/";
|
|
141
|
+
}
|
|
142
|
+
function oe(e) {
|
|
143
|
+
const t = {
|
|
144
|
+
method: e.method,
|
|
145
|
+
headers: Y(e)
|
|
146
|
+
};
|
|
147
|
+
return e.method !== "GET" && e.method !== "HEAD" && (t.body = e, t.duplex = "half"), new globalThis.Request(se(e).href, t);
|
|
148
|
+
}
|
|
149
|
+
function D(e, t, n, o) {
|
|
150
|
+
const f = new URL(t.url), h = z(f, n), c = h.startsWith("/") ? h : `/${h}`, a = {};
|
|
151
|
+
return t.headers.forEach((g, v) => {
|
|
152
|
+
a[v] = g;
|
|
153
|
+
}), {
|
|
154
|
+
url: f,
|
|
155
|
+
path: c,
|
|
156
|
+
pathname: f.pathname,
|
|
157
|
+
method: t.method,
|
|
158
|
+
headers: a,
|
|
159
|
+
cookies: K(t.headers.get("cookie") ?? void 0),
|
|
160
|
+
query: Object.fromEntries(f.searchParams.entries()),
|
|
161
|
+
ip: W.getClientIp(e) ?? void 0,
|
|
162
|
+
locals: o
|
|
163
|
+
};
|
|
164
|
+
}
|
|
165
|
+
function re(e, t, n) {
|
|
166
|
+
return e ? e instanceof globalThis.Request ? e : e instanceof URL ? new globalThis.Request(e.href, t.clone()) : new globalThis.Request(new URL(e, n).href, t.clone()) : t;
|
|
167
|
+
}
|
|
168
|
+
async function ie(e, t, n) {
|
|
169
|
+
t.status(n.status);
|
|
170
|
+
const o = ae(n.headers);
|
|
171
|
+
if (n.headers.forEach((h, c) => {
|
|
172
|
+
c.toLowerCase() !== "set-cookie" && t.setHeader(c, h);
|
|
173
|
+
}), o.length > 0 && t.setHeader("Set-Cookie", o), e.method === "HEAD") {
|
|
174
|
+
t.end();
|
|
175
|
+
return;
|
|
176
|
+
}
|
|
177
|
+
const f = Buffer.from(await n.arrayBuffer());
|
|
178
|
+
t.send(f);
|
|
179
|
+
}
|
|
180
|
+
function ae(e) {
|
|
181
|
+
const t = e.getSetCookie;
|
|
182
|
+
if (typeof t == "function")
|
|
183
|
+
return t.call(e);
|
|
184
|
+
const n = e.raw?.();
|
|
185
|
+
if (n?.["set-cookie"])
|
|
186
|
+
return n["set-cookie"];
|
|
187
|
+
const o = e.get("set-cookie");
|
|
188
|
+
return o ? ce(o) : [];
|
|
189
|
+
}
|
|
190
|
+
function ce(e) {
|
|
191
|
+
const t = [];
|
|
192
|
+
let n = 0;
|
|
193
|
+
for (let o = 0; o < e.length; o++) {
|
|
194
|
+
if (e[o] !== ",") continue;
|
|
195
|
+
const f = e.slice(o + 1);
|
|
196
|
+
/^\s*[^=;,]+=/.test(f) && (t.push(e.slice(n, o).trim()), n = o + 1);
|
|
197
|
+
}
|
|
198
|
+
return t.push(e.slice(n).trim()), t.filter(Boolean);
|
|
199
|
+
}
|
|
200
|
+
function le(e) {
|
|
201
|
+
if (!e.rawResponse)
|
|
202
|
+
return null;
|
|
203
|
+
const { body: t, contentType: n, statusCode: o, headers: f } = e.rawResponse, h = new Headers(f);
|
|
204
|
+
return h.set("Content-Type", n), new globalThis.Response(t, {
|
|
205
|
+
status: o || 200,
|
|
206
|
+
headers: h
|
|
207
|
+
});
|
|
208
|
+
}
|
|
209
|
+
async function ue({
|
|
210
|
+
rendered: e,
|
|
211
|
+
template: t,
|
|
212
|
+
manifest: n,
|
|
213
|
+
root: o,
|
|
214
|
+
distClientDir: f,
|
|
215
|
+
isProduction: h
|
|
216
|
+
}) {
|
|
217
|
+
const c = le(e);
|
|
218
|
+
if (c)
|
|
219
|
+
return c;
|
|
220
|
+
if (e.redirect)
|
|
221
|
+
return new globalThis.Response(null, {
|
|
222
|
+
status: e.redirect.statusCode,
|
|
223
|
+
headers: {
|
|
224
|
+
Location: e.redirect.url
|
|
225
|
+
}
|
|
226
|
+
});
|
|
227
|
+
let a = e.scripts || [], g = e.styles || [];
|
|
228
|
+
const v = e.islands || [];
|
|
229
|
+
let C = e.cacheTags || [];
|
|
230
|
+
const x = e.maxAge, F = e.sMaxAge, S = e.swr;
|
|
231
|
+
let i = "", s = [], l = "";
|
|
232
|
+
if (h && n) {
|
|
233
|
+
let k = function(r) {
|
|
234
|
+
const m = n[r];
|
|
235
|
+
return m ? (m.css && m.css.forEach(($) => w.add($)), m.imports && m.imports.forEach(($) => {
|
|
236
|
+
const _ = n[$];
|
|
237
|
+
_?.file && E.add(_.file), _?.css && _.css.forEach((O) => w.add(O)), _?.imports && _.imports.forEach((O) => {
|
|
238
|
+
const H = n[O];
|
|
239
|
+
H?.file && E.add(H.file), H?.css && H.css.forEach((G) => w.add(G));
|
|
240
|
+
});
|
|
241
|
+
}), { file: m.file }) : { file: null };
|
|
242
|
+
};
|
|
243
|
+
a = a.filter((r) => !r.includes(".global.")), g = g.filter((r) => !r.includes(".global."));
|
|
244
|
+
const w = /* @__PURE__ */ new Set(), E = /* @__PURE__ */ new Set(), L = [];
|
|
245
|
+
for (const r of a) {
|
|
246
|
+
const m = r.replace(/^\//, ""), { file: $ } = k(m);
|
|
247
|
+
$ && L.push(`/${$}`);
|
|
248
|
+
}
|
|
249
|
+
const P = [];
|
|
250
|
+
for (const r of g) {
|
|
251
|
+
const m = r.replace(/^\//, ""), { file: $ } = k(m);
|
|
252
|
+
$ && (P.push(`/${$}`), w.add($));
|
|
253
|
+
}
|
|
254
|
+
if (L.length > 0) {
|
|
255
|
+
const r = await q(L, o, f);
|
|
256
|
+
a = r.filename ? [`/${r.filename}`] : L;
|
|
257
|
+
}
|
|
258
|
+
if (P.length > 0) {
|
|
259
|
+
const r = await ee(P, o, f);
|
|
260
|
+
r.filename && (g = [`/${r.filename}`]);
|
|
261
|
+
}
|
|
262
|
+
const p = n["src/client.global.ts"];
|
|
263
|
+
if (p && (p.css && p.css.length > 0 && p.css.forEach((r) => {
|
|
264
|
+
i += `<link rel="stylesheet" crossorigin href="/${r}">`;
|
|
265
|
+
}), p.file && s.push(`/${p.file}`)), v.length > 0) {
|
|
266
|
+
const r = {};
|
|
267
|
+
for (const m of v) {
|
|
268
|
+
const $ = n[m.src];
|
|
269
|
+
$?.file && (r[m.key] = `/${$.file}`);
|
|
270
|
+
}
|
|
271
|
+
Object.keys(r).length > 0 && (l = `<script>window.__L5E_ISLANDS__=${JSON.stringify(r)}<\/script>`);
|
|
272
|
+
}
|
|
273
|
+
g.length > 0 && (i += g.map((r) => `<link rel="stylesheet" crossorigin href="${r}">`).join(""));
|
|
274
|
+
}
|
|
275
|
+
let d = "";
|
|
276
|
+
h || (d = g.map((k) => `<link rel="stylesheet" href="${k}">`).join(""));
|
|
277
|
+
let y = [...s, ...a];
|
|
278
|
+
if (!h) {
|
|
279
|
+
const k = u.join(o, "src", "client.global.ts");
|
|
280
|
+
if (V(k) && (y = ["/src/client.global.ts", ...y]), v.length > 0) {
|
|
281
|
+
const w = {};
|
|
282
|
+
for (const E of v)
|
|
283
|
+
w[E.key] = `/${E.src}`;
|
|
284
|
+
l = `<script>window.__L5E_ISLANDS__=${JSON.stringify(w)}<\/script>`;
|
|
285
|
+
}
|
|
286
|
+
}
|
|
287
|
+
const b = l + y.map((k) => `<script type="module" src="${k}"><\/script>`).join(""), A = e.lang ? ne(t, e.lang) : t, j = e.rawHtml ? e.html || "" : A.replace("<!--app-head-->", (e.head ?? "") + i + d).replace("<!--app-html-->", e.html ?? "").replace("<!--app-scripts-->", b), T = new Headers({
|
|
288
|
+
"Content-Type": "text/html"
|
|
289
|
+
}), R = ["public"];
|
|
290
|
+
return x !== void 0 && R.push(`max-age=${x}`), F !== void 0 && R.push(`s-maxage=${F}`), S !== void 0 && R.push(`stale-while-revalidate=${S}`), R.length > 1 && h && T.set("Cache-Control", R.join(", ")), process.env.NODE_ENV === "production" && (C = pe(C)), T.set("Cache-Tag", ["global", ...C].join(",")), new globalThis.Response(j, {
|
|
291
|
+
status: e.statusCode || 200,
|
|
292
|
+
headers: T
|
|
293
|
+
});
|
|
294
|
+
}
|
|
295
|
+
async function fe(e = {}) {
|
|
296
|
+
const t = e.root || process.cwd(), n = e.base || "/", o = process.env.NODE_ENV === "production", f = o ? await M.readFile(u.join(t, "./index.html"), "utf-8") : "", h = (await import("express")).default, c = e.app || h();
|
|
297
|
+
if (e.publicDir) {
|
|
298
|
+
const i = u.isAbsolute(e.publicDir) ? e.publicDir : u.join(t, e.publicDir);
|
|
299
|
+
V(i) && c.use(h.static(i));
|
|
300
|
+
}
|
|
301
|
+
let a;
|
|
302
|
+
const g = u.join(t, "./dist/client");
|
|
303
|
+
if (o) {
|
|
304
|
+
const i = (await import("compression")).default, s = (await import("sirv")).default;
|
|
305
|
+
c.use(i()), c.use(n, s(g, { extensions: [] })), c.get(
|
|
306
|
+
`${n === "/" ? "" : n}/bundle-:hash.:ext`,
|
|
307
|
+
async (l, d) => {
|
|
308
|
+
try {
|
|
309
|
+
const { hash: y, ext: b } = l.params, A = `bundle-${y}.${b}`, j = te(A);
|
|
310
|
+
if (!j)
|
|
311
|
+
return d.status(404).send("Bundled file not found");
|
|
312
|
+
d.set({
|
|
313
|
+
"Content-Type": j.mimeType,
|
|
314
|
+
"Cache-Control": "public, max-age=31536000, immutable"
|
|
315
|
+
}), d.send(j.content);
|
|
316
|
+
} catch (y) {
|
|
317
|
+
console.error("[server] Error serving bundled file:", y), d.status(500).end(y.message);
|
|
318
|
+
}
|
|
319
|
+
}
|
|
320
|
+
);
|
|
321
|
+
} else {
|
|
322
|
+
const { createServer: i } = await import("vite"), s = u.join(t, "vite.config.js");
|
|
323
|
+
a = await i({
|
|
324
|
+
root: t,
|
|
325
|
+
configFile: s,
|
|
326
|
+
server: { middlewareMode: !0 },
|
|
327
|
+
appType: "custom",
|
|
328
|
+
base: n,
|
|
329
|
+
optimizeDeps: {
|
|
330
|
+
exclude: ["@withl5e/l5e", "file-type"]
|
|
331
|
+
},
|
|
332
|
+
ssr: {
|
|
333
|
+
resolve: {
|
|
334
|
+
conditions: ["development", "default"]
|
|
335
|
+
}
|
|
336
|
+
},
|
|
337
|
+
resolve: {
|
|
338
|
+
conditions: ["development", "default"]
|
|
339
|
+
}
|
|
340
|
+
}), c.use(a.middlewares);
|
|
341
|
+
}
|
|
342
|
+
c.use("/_l5e/action", h.json({ limit: "100kb" }));
|
|
343
|
+
const v = /^[a-zA-Z]\w+_[0-9a-f]{1,4}$/;
|
|
344
|
+
let C = null, x = null;
|
|
345
|
+
async function F() {
|
|
346
|
+
if (!o)
|
|
347
|
+
return (await a.ssrLoadModule("virtual:l5e-actions")).actionRegistry || {};
|
|
348
|
+
if (!C) {
|
|
349
|
+
const i = u.join(t, "./dist/server/action-registry.json"), s = await M.readFile(i, "utf-8");
|
|
350
|
+
C = JSON.parse(s);
|
|
351
|
+
}
|
|
352
|
+
return C;
|
|
353
|
+
}
|
|
354
|
+
async function S() {
|
|
355
|
+
if (!o)
|
|
356
|
+
return (await a.ssrLoadModule("virtual:l5e-actions")).viewActions || {};
|
|
357
|
+
if (!x) {
|
|
358
|
+
const i = u.join(t, "./dist/server/entry-server.js");
|
|
359
|
+
x = (await import(I(i).href)).viewActions || {};
|
|
360
|
+
}
|
|
361
|
+
return x;
|
|
362
|
+
}
|
|
363
|
+
return c.all("/_l5e/action/:actionKey", async (i, s) => {
|
|
364
|
+
try {
|
|
365
|
+
const { actionKey: l } = i.params;
|
|
366
|
+
if (!v.test(l))
|
|
367
|
+
return s.status(400).send("Invalid action key");
|
|
368
|
+
const y = (await F())[l];
|
|
369
|
+
if (!y)
|
|
370
|
+
return s.status(404).send("Action not found");
|
|
371
|
+
const { modulePath: b, actionName: A } = y;
|
|
372
|
+
let j;
|
|
373
|
+
if (o) {
|
|
374
|
+
const r = await S(), m = r[`/src/${b}/actions.tsx`] ? `/src/${b}/actions.tsx` : r[`/src/${b}/actions.ts`] ? `/src/${b}/actions.ts` : null;
|
|
375
|
+
if (!m)
|
|
376
|
+
return s.status(404).send("Action module not found");
|
|
377
|
+
j = await r[m]();
|
|
378
|
+
} else
|
|
379
|
+
try {
|
|
380
|
+
j = await a.ssrLoadModule(`/src/${b}/actions.tsx`);
|
|
381
|
+
} catch {
|
|
382
|
+
j = await a.ssrLoadModule(`/src/${b}/actions.ts`);
|
|
383
|
+
}
|
|
384
|
+
if (!Object.prototype.hasOwnProperty.call(j, A))
|
|
385
|
+
return s.status(404).send("Action not found");
|
|
386
|
+
const T = j[A];
|
|
387
|
+
if (!T || !T.handler)
|
|
388
|
+
return s.status(404).send("Action not found");
|
|
389
|
+
const R = `${i.protocol}://${i.get("host")}${i.originalUrl}`, k = new URL(R), w = {
|
|
390
|
+
url: k,
|
|
391
|
+
path: i.originalUrl,
|
|
392
|
+
pathname: k.pathname,
|
|
393
|
+
method: i.method,
|
|
394
|
+
headers: i.headers,
|
|
395
|
+
cookies: K(i.headers.cookie),
|
|
396
|
+
query: i.query || {},
|
|
397
|
+
body: i.body,
|
|
398
|
+
ip: W.getClientIp(i)
|
|
399
|
+
}, E = u.join(t, "./dist/server/entry-server.js"), { runInRenderContext: L } = await (o ? import(I(E).href) : a.ssrLoadModule("@withl5e/l5e/jsx-runtime")), { renderJsxToHtmlString: P } = await (o ? import(I(E).href) : a.ssrLoadModule("@withl5e/l5e")), p = await L(
|
|
400
|
+
async () => {
|
|
401
|
+
const r = await T.handler(w);
|
|
402
|
+
return P(r);
|
|
403
|
+
},
|
|
404
|
+
w,
|
|
405
|
+
b
|
|
406
|
+
);
|
|
407
|
+
s.set("Content-Type", "text/html").send(p);
|
|
408
|
+
} catch (l) {
|
|
409
|
+
a?.ssrFixStacktrace?.(l), console.error("[l5e] Action error:", l.stack || l), s.status(500).send("Internal server error");
|
|
410
|
+
}
|
|
411
|
+
}), c.use(async (i, s) => {
|
|
412
|
+
try {
|
|
413
|
+
const l = i.originalUrl.replace(n, "");
|
|
414
|
+
let d, y, b, A;
|
|
415
|
+
if (o) {
|
|
416
|
+
d = f;
|
|
417
|
+
const p = u.join(t, "./dist/server/entry-server.js"), r = await import(I(p).href);
|
|
418
|
+
y = r.render, b = r.loadMiddleware;
|
|
419
|
+
const m = await M.readFile(
|
|
420
|
+
u.join(t, "./dist/client/.vite/manifest.json"),
|
|
421
|
+
"utf-8"
|
|
422
|
+
);
|
|
423
|
+
A = JSON.parse(m);
|
|
424
|
+
} else {
|
|
425
|
+
d = await M.readFile(u.join(t, "./index.html"), "utf-8"), d = await a.transformIndexHtml(l, d), d.includes("@vite/client") || (d = d.replace(
|
|
426
|
+
"</head>",
|
|
427
|
+
'<script type="module" src="/@vite/client"><\/script></head>'
|
|
428
|
+
));
|
|
429
|
+
const p = await a.ssrLoadModule(
|
|
430
|
+
"@withl5e/l5e/entry-server"
|
|
431
|
+
);
|
|
432
|
+
y = p.render, b = p.loadMiddleware;
|
|
433
|
+
}
|
|
434
|
+
const j = await b?.(), T = typeof j == "function" ? j : (p, r) => r(), R = {}, k = oe(i), w = X({
|
|
435
|
+
request: k,
|
|
436
|
+
requestInfo: D(i, k, n, R),
|
|
437
|
+
locals: R,
|
|
438
|
+
clientAddress: W.getClientIp(i)
|
|
439
|
+
}), E = async (p) => {
|
|
440
|
+
const r = D(i, p, n, R), m = z(r.url, n), $ = await y(m, r);
|
|
441
|
+
return ue({
|
|
442
|
+
rendered: $,
|
|
443
|
+
template: d,
|
|
444
|
+
manifest: A,
|
|
445
|
+
root: t,
|
|
446
|
+
distClientDir: g,
|
|
447
|
+
isProduction: o
|
|
448
|
+
});
|
|
449
|
+
}, L = async (p) => {
|
|
450
|
+
const r = re(p, w.request, w.url);
|
|
451
|
+
return w.request = r, w.url = new URL(r.url), w.cookies = K(r.headers.get("cookie") ?? void 0), w.requestInfo = D(i, r, n, R), E(r);
|
|
452
|
+
};
|
|
453
|
+
w.rewrite = (p) => L(p);
|
|
454
|
+
const P = await T(w, L);
|
|
455
|
+
await ie(i, s, P);
|
|
456
|
+
} catch (l) {
|
|
457
|
+
a?.ssrFixStacktrace?.(l), console.log(l.stack), s.status(500).end(l.stack);
|
|
458
|
+
}
|
|
459
|
+
}), { app: c, vite: a };
|
|
460
|
+
}
|
|
461
|
+
async function Se(e = {}) {
|
|
462
|
+
const t = e.port || 5173, n = (await import("express")).default, o = n();
|
|
463
|
+
e.setupApp && (console.log("setupApp"), await e.setupApp(o));
|
|
464
|
+
const { app: f } = await fe({ ...e, app: o });
|
|
465
|
+
f.listen(t, () => {
|
|
466
|
+
console.log(`Server started at http://localhost:${t}`);
|
|
467
|
+
});
|
|
468
|
+
}
|
|
469
|
+
const he = 1e3;
|
|
470
|
+
function de(e) {
|
|
471
|
+
if (e === "global")
|
|
472
|
+
return "global";
|
|
473
|
+
let t = 0;
|
|
474
|
+
for (let n = 0; n < e.length; n++) {
|
|
475
|
+
const o = e.charCodeAt(n);
|
|
476
|
+
t = (t << 5) - t + o, t = t & t;
|
|
477
|
+
}
|
|
478
|
+
return Math.abs(t).toString(36).substring(0, 8);
|
|
479
|
+
}
|
|
480
|
+
function pe(e) {
|
|
481
|
+
return (Array.isArray(e) ? e : [...e]).slice(0, he).map(de);
|
|
482
|
+
}
|
|
483
|
+
export {
|
|
484
|
+
fe as createServer,
|
|
485
|
+
de as hashTag,
|
|
486
|
+
pe as optimizeCacheTags,
|
|
487
|
+
Se as startServer
|
|
488
|
+
};
|
|
489
|
+
//# sourceMappingURL=server.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"server.js","sources":["../src/core/bundler.ts","../src/core/server.ts"],"sourcesContent":["/// <reference path=\"./jsx-types.d.ts\" />\nimport { createHash } from 'node:crypto';\nimport fs from 'node:fs/promises';\nimport path from 'node:path';\nimport { rollup, type OutputOptions, type RollupOptions } from 'rollup';\n\ninterface BundledFile {\n content: string;\n hash: string;\n filename: string;\n mimeType: string;\n}\n\n// Memory map để lưu bundled files\nconst bundledFilesMap = new Map<string, BundledFile>();\n\n// Cache map để deduplicate bundling requests (cacheKey → entry chunk fileName)\nconst bundleCache = new Map<string, string>();\nconst cssCache = new Map<string, string>();\n\n/**\n * Generate hash từ content\n */\nfunction generateHash(content: string): string {\n return createHash('sha256').update(content).digest('hex').substring(0, 16);\n}\n\n/**\n * Bundle JavaScript files từ dist/client thành 1 file\n * Trong production, các file đã được build sẵn trong dist/client\n */\nexport async function bundleScripts(\n scriptPaths: string[],\n rootDir: string,\n distClientDir: string,\n): Promise<{ hash: string; filename: string; content: string }> {\n if (scriptPaths.length === 0) {\n return { hash: '', filename: '', content: '' };\n }\n\n // Dedupe paths (remove duplicates)\n const uniquePaths = [...new Set(scriptPaths)];\n\n // Tạo cache key từ sorted unique paths\n const cacheKey = `scripts:${uniquePaths.sort().join(',')}`;\n\n // Kiểm tra cache - return entry chunk info if already bundled\n const cachedEntryFileName = bundleCache.get(cacheKey);\n if (cachedEntryFileName) {\n const entryFile = bundledFilesMap.get(cachedEntryFileName);\n if (entryFile) {\n return {\n hash: entryFile.hash,\n filename: entryFile.filename,\n content: entryFile.content,\n };\n }\n }\n\n // Temp file path for cleanup\n let entryFile: string | null = null;\n\n try {\n // Sử dụng rollup để bundle nếu cần (resolve imports, etc)\n // Tạo temp entry file\n const hash = generateHash(uniquePaths.join('\\n'));\n const tempDir = path.join(rootDir, '.temp-bundle');\n await fs.mkdir(tempDir, { recursive: true }).catch(() => {});\n\n entryFile = path.join(tempDir, `entry-${hash}.js`);\n // Tạo entry file import tất cả scripts\n const entryContent = uniquePaths\n .map((p, i) => {\n const filePath = p.startsWith('/')\n ? path.join(distClientDir, p.substring(1))\n : path.join(distClientDir, p);\n return `import ${JSON.stringify(filePath)};`;\n })\n .join('\\n');\n\n await fs.writeFile(entryFile, entryContent, 'utf-8');\n console.log(`[bundler] Wrote entry file to ${entryFile}`);\n console.log(`[bundler] Entry content: ${entryContent}`);\n // Rollup config để bundle\n const rollupOptions: RollupOptions = {\n input: entryFile,\n plugins: [\n {\n name: 'vendor-path-rewriter',\n resolveId(source, importer, _options) {\n // Handle vendor/chunk/global files: convert absolute paths to web paths\n // Global files (*.global.*) are already loaded by client.global.ts —\n // re-bundling them would create duplicate module instances (e.g. nanostores)\n if (\n source.includes('vendor-') ||\n source.includes('chunk-') ||\n source.includes('.global')\n ) {\n console.log(`[bundler] Resolving source: ${source}`);\n if (path.isAbsolute(source)) {\n console.log(`[bundler] Resolving absolute path: ${source}`);\n // e.g., C:\\...\\dist\\client\\assets\\vendor-react-XXX.js -> /assets/vendor-react-XXX.js\n const relativePath = path.relative(distClientDir, source);\n const webPath = '/' + relativePath.replace(/\\\\/g, '/');\n return { id: webPath, external: true };\n } else if (importer && source.startsWith('.')) {\n console.log(\n `[bundler] Resolving relative path: ${source} from importer: ${importer}`,\n );\n // Relative path like ./auth.global-BOVr81Z5.js — resolve from importer\n const resolved = path.resolve(path.dirname(importer), source);\n const relativePath = path.relative(distClientDir, resolved);\n const webPath = '/' + relativePath.replace(/\\\\/g, '/');\n return { id: webPath, external: true };\n } else {\n console.log(`[bundler] Resolving source: ${source}`);\n }\n }\n return null; // Let other plugins/external handle\n },\n },\n ],\n external: (id) => {\n // External node_modules\n if (!id.startsWith('.') && !path.isAbsolute(id)) {\n return true;\n }\n\n // Let plugin handle vendor/chunk/global files (don't mark external here)\n if (id.includes('vendor-') || id.includes('chunk-') || id.includes('.global')) {\n return false; // Let plugin's resolveId handle path rewriting\n }\n\n return false;\n },\n };\n\n const outputOptions: OutputOptions = {\n format: 'es',\n inlineDynamicImports: false,\n entryFileNames: 'bundle-[hash].js',\n chunkFileNames: 'bundle-[hash].js',\n };\n\n const bundle = await rollup(rollupOptions);\n const { output } = await bundle.generate(outputOptions);\n await bundle.close();\n\n // Lấy bundled content từ rollup\n\n output.forEach((o) => {\n if (o.type !== 'chunk') {\n return;\n }\n // Lưu vào map với key = fileName\n const bundledFile: BundledFile = {\n content: o.code || '',\n hash: generateHash(o.code || ''),\n filename: o.fileName,\n mimeType: 'application/javascript',\n };\n bundledFilesMap.set(o.fileName, bundledFile);\n });\n\n // Cache entry chunk fileName for deduplication\n const entryChunk = output[0];\n if (entryChunk?.type === 'chunk') {\n bundleCache.set(cacheKey, entryChunk.fileName);\n }\n\n // Return entry chunk info\n return {\n hash: generateHash(output[0]?.code || ''),\n filename: output[0]?.fileName || '',\n content: output[0]?.code || '',\n };\n } catch (error) {\n console.error('[bundler] Error bundling scripts:', error);\n return { hash: '', filename: '', content: '' };\n } finally {\n // Cleanup temp entry file\n if (entryFile) {\n await fs.unlink(entryFile).catch(() => {\n // Ignore cleanup errors\n });\n }\n }\n}\n\n/**\n * Bundle CSS files từ dist/client thành 1 file\n * Trong production, các file đã được build sẵn trong dist/client\n */\nexport async function bundleCss(\n cssPaths: string[],\n rootDir: string,\n distClientDir: string,\n): Promise<{ hash: string; filename: string; content: string }> {\n if (cssPaths.length === 0) {\n return { hash: '', filename: '', content: '' };\n }\n\n // Dedupe paths (remove duplicates)\n const uniquePaths = [...new Set(cssPaths)];\n\n // Tạo cache key từ sorted unique paths\n const cacheKey = `css:${uniquePaths.sort().join(',')}`;\n\n // Kiểm tra cache - return cached file if already bundled\n const cachedFileName = cssCache.get(cacheKey);\n if (cachedFileName) {\n const cachedFile = bundledFilesMap.get(cachedFileName);\n if (cachedFile) {\n return {\n hash: cachedFile.hash,\n filename: cachedFile.filename,\n content: cachedFile.content,\n };\n }\n }\n\n try {\n // Đọc và gộp tất cả CSS files từ dist/client\n const cssContents: string[] = [];\n\n for (const cssPath of uniquePaths) {\n // cssPath có thể là \"/assets/xxx.css\" hoặc từ manifest\n const filePath = cssPath.startsWith('/')\n ? path.join(distClientDir, cssPath.substring(1))\n : path.join(distClientDir, cssPath);\n\n try {\n const content = await fs.readFile(filePath, 'utf-8');\n cssContents.push(`/* ${cssPath} */\\n${content}\\n`);\n } catch (err) {\n console.warn(`[bundler] Failed to read CSS file: ${cssPath}`, err);\n }\n }\n\n const bundledContent = cssContents.join('\\n\\n');\n const hash = generateHash(bundledContent);\n const filename = `bundle-${hash}.css`;\n\n // Lưu vào map với key = filename\n const bundledFile: BundledFile = {\n content: bundledContent,\n hash,\n filename,\n mimeType: 'text/css',\n };\n bundledFilesMap.set(filename, bundledFile);\n\n // Cache filename for deduplication\n cssCache.set(cacheKey, filename);\n\n return { hash, filename, content: bundledContent };\n } catch (error) {\n console.error('[bundler] Error bundling CSS:', error);\n return { hash: '', filename: '', content: '' };\n }\n}\n\n/**\n * Get bundled file từ map\n */\nexport function getBundledFile(filename: string): BundledFile | undefined {\n return bundledFilesMap.get(filename);\n}\n\n/**\n * Clear bundled files map (useful for testing)\n */\nexport function clearBundledFiles(): void {\n bundledFilesMap.clear();\n}\n","import type { Request as ExpressRequest, Response as ExpressResponse } from 'express';\nimport { existsSync } from 'fs';\nimport fs from 'node:fs/promises';\nimport path from 'node:path';\nimport { pathToFileURL } from 'node:url';\nimport requestIp from 'request-ip';\nimport type { ViteDevServer } from 'vite';\nimport { createContext, type MiddlewareHandler, type RewritePayload } from '../middleware';\nimport { bundleCss, bundleScripts, getBundledFile } from './bundler';\nimport type { RenderResult, RequestInfo } from './entry-server';\nimport { createHeadersFromExpressRequest, parseCookies } from './request';\n\nexport interface ServerOptions {\n root?: string;\n port?: number;\n base?: string;\n publicDir?: string;\n setupApp?: (app: any) => void | Promise<void>;\n app?: any; // Express\n}\n\nexport interface ServerContext {\n app: any; // Express app\n vite?: ViteDevServer;\n}\n\n/**\n * Apply or replace lang attribute on <html> tag\n */\nfunction applyHtmlLang(template: string, lang: string): string {\n return template.replace(/<html\\b([^>]*)>/i, (match, attrs) => {\n // Check if lang already exists\n if (/\\blang\\s*=/i.test(attrs)) {\n // Replace existing lang value\n return match.replace(/lang\\s*=\\s*\"[^\"]*\"/i, `lang=\"${lang}\"`);\n } else {\n // Add lang attribute\n return `<html lang=\"${lang}\"${attrs}>`;\n }\n });\n}\n\ntype EntryServerModule = {\n render: (url: string, requestInfo?: RequestInfo) => Promise<RenderResult>;\n loadMiddleware?: () => Promise<MiddlewareHandler | undefined>;\n};\n\nfunction getRequestUrl(req: ExpressRequest): URL {\n return new URL(`${req.protocol}://${req.get('host')}${req.originalUrl}`);\n}\n\nfunction getRenderUrl(urlObject: URL, base: string): string {\n const requestPath = `${urlObject.pathname}${urlObject.search}`;\n return requestPath.replace(base, '') || '/';\n}\n\nfunction createWebRequestFromExpress(req: ExpressRequest): globalThis.Request {\n const init: RequestInit & { duplex?: 'half' } = {\n method: req.method,\n headers: createHeadersFromExpressRequest(req),\n };\n\n if (req.method !== 'GET' && req.method !== 'HEAD') {\n init.body = req as unknown as BodyInit;\n init.duplex = 'half';\n }\n\n return new globalThis.Request(getRequestUrl(req).href, init);\n}\n\nfunction createRequestInfo(\n req: ExpressRequest,\n webRequest: globalThis.Request,\n base: string,\n locals: Record<string, unknown>,\n): RequestInfo {\n const urlObject = new URL(webRequest.url);\n const renderUrl = getRenderUrl(urlObject, base);\n const normalizedPath = renderUrl.startsWith('/') ? renderUrl : `/${renderUrl}`;\n const headers: Record<string, string> = {};\n webRequest.headers.forEach((value, key) => {\n headers[key] = value;\n });\n\n return {\n url: urlObject,\n path: normalizedPath,\n pathname: urlObject.pathname,\n method: webRequest.method,\n headers,\n cookies: parseCookies(webRequest.headers.get('cookie') ?? undefined),\n query: Object.fromEntries(urlObject.searchParams.entries()),\n ip: requestIp.getClientIp(req) ?? undefined,\n locals,\n };\n}\n\nfunction createRewriteRequest(\n payload: RewritePayload | undefined,\n currentRequest: globalThis.Request,\n currentUrl: URL,\n): globalThis.Request {\n if (!payload) {\n return currentRequest;\n }\n\n if (payload instanceof globalThis.Request) {\n return payload;\n }\n\n if (payload instanceof URL) {\n return new globalThis.Request(payload.href, currentRequest.clone());\n }\n\n return new globalThis.Request(new URL(payload, currentUrl).href, currentRequest.clone());\n}\n\nasync function sendWebResponse(\n req: ExpressRequest,\n res: ExpressResponse,\n response: globalThis.Response,\n): Promise<void> {\n res.status(response.status);\n const setCookieValues = getSetCookieHeaders(response.headers);\n response.headers.forEach((value, key) => {\n if (key.toLowerCase() === 'set-cookie') {\n return;\n }\n res.setHeader(key, value);\n });\n if (setCookieValues.length > 0) {\n res.setHeader('Set-Cookie', setCookieValues);\n }\n\n if (req.method === 'HEAD') {\n res.end();\n return;\n }\n\n const body = Buffer.from(await response.arrayBuffer());\n res.send(body);\n}\n\nfunction getSetCookieHeaders(headers: Headers): string[] {\n const getSetCookie = (headers as Headers & { getSetCookie?: () => string[] }).getSetCookie;\n if (typeof getSetCookie === 'function') {\n return getSetCookie.call(headers);\n }\n\n const raw = (headers as Headers & { raw?: () => Record<string, string[]> }).raw?.();\n if (raw?.['set-cookie']) {\n return raw['set-cookie'];\n }\n\n const value = headers.get('set-cookie');\n return value ? splitSetCookieHeader(value) : [];\n}\n\nfunction splitSetCookieHeader(value: string): string[] {\n const cookies: string[] = [];\n let start = 0;\n\n for (let i = 0; i < value.length; i++) {\n if (value[i] !== ',') continue;\n\n const rest = value.slice(i + 1);\n if (/^\\s*[^=;,]+=/.test(rest)) {\n cookies.push(value.slice(start, i).trim());\n start = i + 1;\n }\n }\n\n cookies.push(value.slice(start).trim());\n return cookies.filter(Boolean);\n}\n\nfunction createRawResponse(rendered: RenderResult): globalThis.Response | null {\n if (!rendered.rawResponse) {\n return null;\n }\n\n const { body, contentType, statusCode, headers } = rendered.rawResponse;\n const responseHeaders = new Headers(headers);\n responseHeaders.set('Content-Type', contentType);\n\n return new globalThis.Response(body as BodyInit, {\n status: statusCode || 200,\n headers: responseHeaders,\n });\n}\n\nasync function createPageResponse({\n rendered,\n template,\n manifest,\n root,\n distClientDir,\n isProduction,\n}: {\n rendered: RenderResult;\n template: string;\n manifest?: Record<string, any>;\n root: string;\n distClientDir: string;\n isProduction: boolean;\n}): Promise<globalThis.Response> {\n const rawResponse = createRawResponse(rendered);\n if (rawResponse) {\n return rawResponse;\n }\n\n if (rendered.redirect) {\n return new globalThis.Response(null, {\n status: rendered.redirect.statusCode,\n headers: {\n Location: rendered.redirect.url,\n },\n });\n }\n\n let scriptSrcList: string[] = rendered.scripts || [];\n let cssSrcList: string[] = rendered.styles || [];\n const islandEntries = rendered.islands || [];\n let cacheTags: string[] = rendered.cacheTags || [];\n const maxAge: number | undefined = rendered.maxAge;\n const sMaxAge: number | undefined = rendered.sMaxAge;\n const swr: number | undefined = rendered.swr;\n\n let extraHead = '';\n let globalScripts: string[] = [];\n let islandRegistryScript = '';\n\n if (isProduction && manifest) {\n scriptSrcList = scriptSrcList.filter((src) => !src.includes('.global.'));\n cssSrcList = cssSrcList.filter((src) => !src.includes('.global.'));\n\n const cssFiles = new Set<string>();\n const preloadFiles = new Set<string>();\n\n function collectFromEntry(entryKey: string): { file: string | null } {\n const entry = manifest![entryKey];\n if (!entry) return { file: null };\n\n if (entry.css) entry.css.forEach((css: string) => cssFiles.add(css));\n if (entry.imports) {\n entry.imports.forEach((importKey: string) => {\n const importedChunk = manifest![importKey];\n if (importedChunk?.file) preloadFiles.add(importedChunk.file);\n if (importedChunk?.css) {\n importedChunk.css.forEach((css: string) => cssFiles.add(css));\n }\n if (importedChunk?.imports) {\n importedChunk.imports.forEach((key: string) => {\n const chunk = manifest![key];\n if (chunk?.file) preloadFiles.add(chunk.file);\n if (chunk?.css) chunk.css.forEach((css: string) => cssFiles.add(css));\n });\n }\n });\n }\n\n return { file: entry.file };\n }\n\n const mappedScripts: string[] = [];\n for (const src of scriptSrcList) {\n const entryKey = src.replace(/^\\//, '');\n const { file } = collectFromEntry(entryKey);\n if (file) mappedScripts.push(`/${file}`);\n }\n\n const mappedCssFiles: string[] = [];\n for (const src of cssSrcList) {\n const entryKey = src.replace(/^\\//, '');\n const { file } = collectFromEntry(entryKey);\n if (file) {\n mappedCssFiles.push(`/${file}`);\n cssFiles.add(file);\n }\n }\n\n if (mappedScripts.length > 0) {\n const bundledScript = await bundleScripts(mappedScripts, root, distClientDir);\n scriptSrcList = bundledScript.filename ? [`/${bundledScript.filename}`] : mappedScripts;\n }\n\n if (mappedCssFiles.length > 0) {\n const bundledCss = await bundleCss(mappedCssFiles, root, distClientDir);\n if (bundledCss.filename) {\n cssSrcList = [`/${bundledCss.filename}`];\n }\n }\n\n const globalEntry = manifest['src/client.global.ts'];\n if (globalEntry) {\n if (globalEntry.css && globalEntry.css.length > 0) {\n globalEntry.css.forEach((cssFile: string) => {\n extraHead += `<link rel=\"stylesheet\" crossorigin href=\"/${cssFile}\">`;\n });\n }\n if (globalEntry.file) {\n globalScripts.push(`/${globalEntry.file}`);\n }\n }\n\n if (islandEntries.length > 0) {\n const islandMap: Record<string, string> = {};\n for (const island of islandEntries) {\n const entry = manifest[island.src];\n if (entry?.file) {\n islandMap[island.key] = `/${entry.file}`;\n }\n }\n if (Object.keys(islandMap).length > 0) {\n islandRegistryScript = `<script>window.__L5E_ISLANDS__=${JSON.stringify(islandMap)}</script>`;\n }\n }\n\n if (cssSrcList.length > 0) {\n extraHead += cssSrcList\n .map((file) => `<link rel=\"stylesheet\" crossorigin href=\"${file}\">`)\n .join('');\n }\n }\n\n let cssHtml = '';\n if (!isProduction) {\n cssHtml = cssSrcList.map((src) => `<link rel=\"stylesheet\" href=\"${src}\">`).join('');\n }\n\n let allScripts = [...globalScripts, ...scriptSrcList];\n\n if (!isProduction) {\n const globalTsPath = path.join(root, 'src', 'client.global.ts');\n if (existsSync(globalTsPath)) {\n allScripts = ['/src/client.global.ts', ...allScripts];\n }\n\n if (islandEntries.length > 0) {\n const islandMap: Record<string, string> = {};\n for (const island of islandEntries) {\n islandMap[island.key] = `/${island.src}`;\n }\n islandRegistryScript = `<script>window.__L5E_ISLANDS__=${JSON.stringify(islandMap)}</script>`;\n }\n }\n\n const scriptsHtml =\n islandRegistryScript +\n allScripts.map((src) => `<script type=\"module\" src=\"${src}\"></script>`).join('');\n\n const templateWithLang = rendered.lang ? applyHtmlLang(template, rendered.lang) : template;\n\n const html = rendered.rawHtml\n ? rendered.html || ''\n : templateWithLang\n .replace(`<!--app-head-->`, (rendered.head ?? '') + extraHead + cssHtml)\n .replace(`<!--app-html-->`, rendered.html ?? '')\n .replace(`<!--app-scripts-->`, scriptsHtml);\n\n const headers = new Headers({\n 'Content-Type': 'text/html',\n });\n\n const cacheControlParts: string[] = ['public'];\n if (maxAge !== undefined) cacheControlParts.push(`max-age=${maxAge}`);\n if (sMaxAge !== undefined) cacheControlParts.push(`s-maxage=${sMaxAge}`);\n if (swr !== undefined) cacheControlParts.push(`stale-while-revalidate=${swr}`);\n\n if (cacheControlParts.length > 1 && isProduction) {\n headers.set('Cache-Control', cacheControlParts.join(', '));\n }\n\n if (process.env.NODE_ENV === 'production') {\n cacheTags = optimizeCacheTags(cacheTags);\n }\n headers.set('Cache-Tag', ['global', ...cacheTags].join(','));\n\n return new globalThis.Response(html, {\n status: rendered.statusCode || 200,\n headers,\n });\n}\n\nexport async function createServer(options: ServerOptions = {}): Promise<ServerContext> {\n const root = options.root || process.cwd();\n const base = options.base || '/';\n const isProduction = process.env.NODE_ENV === 'production';\n\n // Cached production assets\n const templateHtml = isProduction\n ? await fs.readFile(path.join(root, './index.html'), 'utf-8')\n : '';\n\n // Create http server\n // @ts-ignore\n const express = (await import('express')).default;\n const app = options.app || express();\n\n // Serve static files from public directory\n if (options.publicDir) {\n const publicPath = path.isAbsolute(options.publicDir)\n ? options.publicDir\n : path.join(root, options.publicDir);\n\n if (existsSync(publicPath)) {\n app.use(express.static(publicPath));\n }\n }\n\n // Add Vite or respective production middlewares\n let vite: ViteDevServer | undefined;\n const distClientDir = path.join(root, './dist/client');\n\n if (!isProduction) {\n const { createServer } = await import('vite');\n const configFile = path.join(root, 'vite.config.js');\n vite = await createServer({\n root,\n configFile,\n server: { middlewareMode: true },\n appType: 'custom',\n base,\n optimizeDeps: {\n exclude: ['@withl5e/l5e', 'file-type'],\n },\n ssr: {\n resolve: {\n conditions: ['development', 'default'],\n },\n },\n resolve: {\n conditions: ['development', 'default'],\n },\n });\n app.use(vite.middlewares);\n } else {\n // @ts-ignore\n const compression = (await import('compression')).default;\n // @ts-ignore\n const sirv = (await import('sirv')).default;\n app.use(compression());\n app.use(base, sirv(distClientDir, { extensions: [] }));\n\n // Route để serve bundled files từ memory map\n // Äặt route nà y trước route HTML để catch request trước\n app.get(\n `${base === '/' ? '' : base}/bundle-:hash.:ext`,\n async (req: ExpressRequest, res: ExpressResponse) => {\n try {\n const { hash, ext } = req.params;\n const filename = `bundle-${hash}.${ext}`;\n const bundledFile = getBundledFile(filename);\n\n if (!bundledFile) {\n return res.status(404).send('Bundled file not found');\n }\n\n res.set({\n 'Content-Type': bundledFile.mimeType,\n 'Cache-Control': 'public, max-age=31536000, immutable',\n });\n res.send(bundledFile.content);\n } catch (e: any) {\n console.error('[server] Error serving bundled file:', e);\n res.status(500).end(e.message);\n }\n },\n );\n }\n\n // Action routes — JSON body parsing scoped to action endpoints only\n app.use('/_l5e/action', express.json({ limit: '100kb' }));\n\n // Validate action key format: actionName_hexHash\n const ACTION_KEY_RE = /^[a-zA-Z]\\w+_[0-9a-f]{1,4}$/;\n\n // Load action registry and viewActions glob from virtual module (dev) or built bundle (prod)\n let prodActionRegistry: Record<string, { modulePath: string; actionName: string }> | null = null;\n let prodViewActions: Record<string, () => Promise<any>> | null = null;\n\n async function getActionRegistry(): Promise<\n Record<string, { modulePath: string; actionName: string }>\n > {\n if (!isProduction) {\n const mod = await vite!.ssrLoadModule('virtual:l5e-actions');\n return mod.actionRegistry || {};\n }\n if (!prodActionRegistry) {\n const registryPath = path.join(root, './dist/server/action-registry.json');\n const json = await fs.readFile(registryPath, 'utf-8');\n prodActionRegistry = JSON.parse(json);\n }\n return prodActionRegistry!;\n }\n\n async function getViewActions(): Promise<Record<string, () => Promise<any>>> {\n if (!isProduction) {\n const mod = await vite!.ssrLoadModule('virtual:l5e-actions');\n return mod.viewActions || {};\n }\n if (!prodViewActions) {\n const entryServerPath = path.join(root, './dist/server/entry-server.js');\n const mod = await import(pathToFileURL(entryServerPath).href);\n prodViewActions = mod.viewActions || {};\n }\n return prodViewActions!;\n }\n\n // Action route handler — hashed action keys\n // URL: /_l5e/action/:actionKey (e.g., /_l5e/action/loadMoreComments_a1b2)\n app.all('/_l5e/action/:actionKey', async (req: ExpressRequest, res: ExpressResponse) => {\n try {\n const { actionKey } = req.params;\n\n // Validate action key format\n if (!ACTION_KEY_RE.test(actionKey)) {\n return res.status(400).send('Invalid action key');\n }\n\n // Look up action in registry\n const registry = await getActionRegistry();\n const entry = registry[actionKey];\n if (!entry) {\n return res.status(404).send('Action not found');\n }\n\n const { modulePath, actionName } = entry;\n\n // Import action module via viewActions glob (works in both dev and prod)\n let actionModule: any;\n if (!isProduction) {\n try {\n actionModule = await vite!.ssrLoadModule(`/src/${modulePath}/actions.tsx`);\n } catch {\n actionModule = await vite!.ssrLoadModule(`/src/${modulePath}/actions.ts`);\n }\n } else {\n const viewActions = await getViewActions();\n // Find matching glob entry by modulePath\n const globKey = viewActions[`/src/${modulePath}/actions.tsx`]\n ? `/src/${modulePath}/actions.tsx`\n : viewActions[`/src/${modulePath}/actions.ts`]\n ? `/src/${modulePath}/actions.ts`\n : null;\n if (!globKey) {\n return res.status(404).send('Action module not found');\n }\n actionModule = await viewActions[globKey]();\n }\n\n // Look up exported action — use hasOwnProperty to avoid prototype pollution\n if (!Object.prototype.hasOwnProperty.call(actionModule, actionName)) {\n return res.status(404).send('Action not found');\n }\n const action = actionModule[actionName];\n if (!action || !action.handler) {\n return res.status(404).send('Action not found');\n }\n\n // Build RequestInfo (same pattern as HTML handler)\n const fullUrl = `${req.protocol}://${req.get('host')}${req.originalUrl}`;\n const urlObject = new URL(fullUrl);\n\n const requestInfo = {\n url: urlObject,\n path: req.originalUrl,\n pathname: urlObject.pathname,\n method: req.method,\n headers: req.headers,\n cookies: parseCookies(req.headers.cookie as string),\n query: req.query || {},\n body: req.body,\n ip: requestIp.getClientIp(req),\n };\n\n // Import render utilities from entry-server (bundled in SSR build)\n const entryServerPath = path.join(root, './dist/server/entry-server.js');\n const { runInRenderContext } = await (isProduction\n ? import(pathToFileURL(entryServerPath).href)\n : vite!.ssrLoadModule('@withl5e/l5e/jsx-runtime'));\n const { renderJsxToHtmlString } = await (isProduction\n ? import(pathToFileURL(entryServerPath).href)\n : vite!.ssrLoadModule('@withl5e/l5e'));\n\n // Run action handler in render context (needed for JSX)\n const html = await runInRenderContext(\n async () => {\n const jsx = await action.handler(requestInfo);\n return renderJsxToHtmlString(jsx);\n },\n requestInfo,\n modulePath,\n );\n\n res.set('Content-Type', 'text/html').send(html);\n } catch (e: any) {\n vite?.ssrFixStacktrace?.(e);\n console.error('[l5e] Action error:', e.stack || e);\n res.status(500).send('Internal server error');\n }\n });\n\n // Serve HTML\n app.use(async (req: ExpressRequest, res: ExpressResponse) => {\n try {\n const url = req.originalUrl.replace(base, '');\n\n let template: string;\n let render: (url: string, requestInfo?: any) => Promise<any>;\n let loadMiddleware: EntryServerModule['loadMiddleware'];\n let manifest: Record<string, any> | undefined;\n\n if (!isProduction) {\n // Always read fresh template in development\n template = await fs.readFile(path.join(root, './index.html'), 'utf-8');\n template = await vite!.transformIndexHtml(url, template);\n\n // Inject Vite HMR client for hot reload\n if (!template.includes('@vite/client')) {\n template = template.replace(\n '</head>',\n '<script type=\"module\" src=\"/@vite/client\"></script></head>',\n );\n }\n\n const entryServer = (await vite!.ssrLoadModule(\n '@withl5e/l5e/entry-server',\n )) as EntryServerModule;\n render = entryServer.render;\n loadMiddleware = entryServer.loadMiddleware;\n } else {\n template = templateHtml;\n const entryServerPath = path.join(root, './dist/server/entry-server.js');\n const entryServer = (await import(\n pathToFileURL(entryServerPath).href\n )) as EntryServerModule;\n render = entryServer.render;\n loadMiddleware = entryServer.loadMiddleware;\n // Read manifest to map hashed assets\n const manifestJson = await fs.readFile(\n path.join(root, './dist/client/.vite/manifest.json'),\n 'utf-8',\n );\n manifest = JSON.parse(manifestJson);\n }\n\n const loadedMiddleware = await loadMiddleware?.();\n const handler: MiddlewareHandler =\n typeof loadedMiddleware === 'function' ? loadedMiddleware : (_ctx, next) => next();\n\n const locals: Record<string, unknown> = {};\n const initialRequest = createWebRequestFromExpress(req);\n const context = createContext({\n request: initialRequest,\n requestInfo: createRequestInfo(req, initialRequest, base, locals),\n locals,\n clientAddress: requestIp.getClientIp(req),\n });\n\n const renderResponse = async (webRequest: globalThis.Request) => {\n const nextRequestInfo = createRequestInfo(req, webRequest, base, locals);\n const nextUrl = getRenderUrl(nextRequestInfo.url!, base);\n const nextRendered = await render(nextUrl, nextRequestInfo);\n return createPageResponse({\n rendered: nextRendered,\n template,\n manifest,\n root,\n distClientDir,\n isProduction,\n });\n };\n\n const next = async (payload?: RewritePayload) => {\n const nextRequest = createRewriteRequest(payload, context.request, context.url);\n context.request = nextRequest;\n context.url = new URL(nextRequest.url);\n context.cookies = parseCookies(nextRequest.headers.get('cookie') ?? undefined);\n context.requestInfo = createRequestInfo(req, nextRequest, base, locals);\n return renderResponse(nextRequest);\n };\n\n context.rewrite = (payload: RewritePayload) => next(payload);\n\n const response = await handler(context, next);\n await sendWebResponse(req, res, response);\n } catch (e: any) {\n vite?.ssrFixStacktrace?.(e);\n console.log(e.stack);\n res.status(500).end(e.stack);\n }\n });\n\n return { app, vite };\n}\n\nexport async function startServer(options: ServerOptions = {}): Promise<void> {\n const port = options.port || 5173;\n\n // Create Express app first\n // @ts-ignore\n const express = (await import('express')).default;\n const app = express();\n\n // Call callback if provided to allow custom routes before setting up L5E server\n if (options.setupApp) {\n console.log('setupApp');\n await options.setupApp(app);\n }\n\n const { app: serverApp } = await createServer({ ...options, app });\n\n serverApp.listen(port, () => {\n console.log(`Server started at http://localhost:${port}`);\n });\n}\n\nconst MAX_TAGS = 1000;\n\nexport function hashTag(tag: string): string {\n // global tag is not hashed, better for ci/cd\n if (tag === 'global') {\n return 'global';\n }\n\n let hash = 0;\n for (let i = 0; i < tag.length; i++) {\n const char = tag.charCodeAt(i);\n hash = (hash << 5) - hash + char;\n hash = hash & hash; // Convert to 32bit integer\n }\n return Math.abs(hash).toString(36).substring(0, 8);\n}\n\nexport function optimizeCacheTags(tags: Set<string> | string[]): string[] {\n const _tags = Array.isArray(tags) ? tags : [...tags];\n const result = _tags.slice(0, MAX_TAGS).map(hashTag);\n return result;\n}\n"],"names":["bundledFilesMap","bundleCache","cssCache","generateHash","content","createHash","bundleScripts","scriptPaths","rootDir","distClientDir","uniquePaths","cacheKey","cachedEntryFileName","entryFile","hash","tempDir","path","fs","entryContent","p","i","filePath","rollupOptions","source","importer","_options","resolved","id","outputOptions","bundle","rollup","output","o","bundledFile","entryChunk","error","bundleCss","cssPaths","cachedFileName","cachedFile","cssContents","cssPath","err","bundledContent","filename","getBundledFile","applyHtmlLang","template","lang","match","attrs","getRequestUrl","req","getRenderUrl","urlObject","base","createWebRequestFromExpress","init","createHeadersFromExpressRequest","createRequestInfo","webRequest","locals","renderUrl","normalizedPath","headers","value","key","parseCookies","requestIp","createRewriteRequest","payload","currentRequest","currentUrl","sendWebResponse","res","response","setCookieValues","getSetCookieHeaders","body","getSetCookie","raw","splitSetCookieHeader","cookies","start","rest","createRawResponse","rendered","contentType","statusCode","responseHeaders","createPageResponse","manifest","root","isProduction","rawResponse","scriptSrcList","cssSrcList","islandEntries","cacheTags","maxAge","sMaxAge","swr","extraHead","globalScripts","islandRegistryScript","collectFromEntry","entryKey","entry","css","cssFiles","importKey","importedChunk","preloadFiles","chunk","src","mappedScripts","file","mappedCssFiles","bundledScript","bundledCss","globalEntry","cssFile","islandMap","island","cssHtml","allScripts","globalTsPath","existsSync","scriptsHtml","templateWithLang","html","cacheControlParts","optimizeCacheTags","createServer","options","templateHtml","express","app","publicPath","vite","compression","sirv","ext","e","configFile","ACTION_KEY_RE","prodActionRegistry","prodViewActions","getActionRegistry","registryPath","json","getViewActions","entryServerPath","pathToFileURL","actionKey","modulePath","actionName","actionModule","viewActions","globKey","action","fullUrl","requestInfo","runInRenderContext","renderJsxToHtmlString","jsx","url","render","loadMiddleware","entryServer","manifestJson","loadedMiddleware","handler","_ctx","next","initialRequest","context","createContext","renderResponse","nextRequestInfo","nextUrl","nextRendered","nextRequest","startServer","port","serverApp","MAX_TAGS","hashTag","tag","char","tags"],"mappings":";;;;;;;;AAcA,MAAMA,wBAAsB,IAAA,GAGtBC,wBAAkB,IAAA,GAClBC,wBAAe,IAAA;AAKrB,SAASC,EAAaC,GAAyB;AAC7C,SAAOC,EAAW,QAAQ,EAAE,OAAOD,CAAO,EAAE,OAAO,KAAK,EAA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M,EAAE,KAAKgD,MAAc,MAAMpD,GAAa,EAAE,GAAGC,GAAS,KAAAG,GAAK;AAEjE,EAAAgD,EAAU,OAAOD,GAAM,MAAM;AAC3B,YAAQ,IAAI,sCAAsCA,CAAI,EAAE;AAAA,EAC1D,CAAC;AACH;AAEA,MAAME,KAAW;AAEV,SAASC,GAAQC,GAAqB;AAE3C,MAAIA,MAAQ;AACV,WAAO;AAGT,MAAI9K,IAAO;AACX,WAASM,IAAI,GAAGA,IAAIwK,EAAI,QAAQxK,KAAK;AACnC,UAAMyK,IAAOD,EAAI,WAAWxK,CAAC;AAC7B,IAAAN,KAAQA,KAAQ,KAAKA,IAAO+K,GAC5B/K,IAAOA,IAAOA;AAAA,EAChB;AACA,SAAO,KAAK,IAAIA,CAAI,EAAE,SAAS,EAAE,EAAE,UAAU,GAAG,CAAC;AACnD;AAEO,SAASsH,GAAkB0D,GAAwC;AAGxE,UAFc,MAAM,QAAQA,CAAI,IAAIA,IAAO,CAAC,GAAGA,CAAI,GAC9B,MAAM,GAAGJ,EAAQ,EAAE,IAAIC,EAAO;AAErD;"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { jsxFactory as n } from "@withl5e/l5e/jsx-runtime";
|
|
2
|
+
function d({ children: o, hasMore: t, meta: r }) {
|
|
3
|
+
return /* @__PURE__ */ n(
|
|
4
|
+
"div",
|
|
5
|
+
{
|
|
6
|
+
"data-has-more": t !== void 0 ? String(t) : void 0,
|
|
7
|
+
...r && Object.fromEntries(Object.entries(r).map(([e, i]) => [`data-${e}`, i]))
|
|
8
|
+
},
|
|
9
|
+
o
|
|
10
|
+
);
|
|
11
|
+
}
|
|
12
|
+
export {
|
|
13
|
+
d as SwapResponse
|
|
14
|
+
};
|
|
15
|
+
//# sourceMappingURL=server.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"server.js","sources":["../../src/swap/SwapResponse.tsx"],"sourcesContent":["interface SwapResponseProps {\n children: JSX.Element | JSX.Element[];\n hasMore?: boolean;\n meta?: Record<string, string>;\n}\n\nexport function SwapResponse({ children, hasMore, meta }: SwapResponseProps) {\n return (\n <div\n data-has-more={hasMore !== undefined ? String(hasMore) : undefined}\n {...(meta && Object.fromEntries(Object.entries(meta).map(([k, v]) => [`data-${k}`, v])))}\n >\n {children}\n </div>\n );\n}\n"],"names":["SwapResponse","children","hasMore","meta","jsxFactory","k","v"],"mappings":";AAM6E,SAAAA,EAAA,EAAA,UAAAC,GAAA,SAAAC,GAAA,MAAAC,EAAA,GAAA;AAC3E,SACE,gBAAAC;AAAA,IAAC;AAAA,IAAA;AAAA,MACC,iBAAeF,MAAY,SAAY,OAAOA,CAAO,IAAI;AAAA,MACxD,GAAIC,KAAQ,OAAO,YAAY,OAAO,QAAQA,CAAI,EAAE,IAAI,CAAC,CAACE,GAAGC,CAAC,MAAM,CAAC,QAAQD,CAAC,IAAIC,CAAC,CAAC,CAAC;AAAA,IAAA;AAAA,IAErFL;AAAA,EAAA;AAGP;"}
|