@withl5e/l5e 0.2.7 → 0.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/defineMiddleware-VdHQuiUc.js +7 -0
- package/dist/defineMiddleware-VdHQuiUc.js.map +1 -0
- package/dist/entry-server.js +1 -1
- package/dist/{generateMetadata-CIFVlViV.js → generateMetadata-Cn2uJjg_.js} +6 -6
- package/dist/generateMetadata-Cn2uJjg_.js.map +1 -0
- package/dist/i18n.js +12 -0
- package/dist/i18n.js.map +1 -0
- package/dist/{index-BlfNBupp.js → index-CybB8Tdk.js} +30 -33
- package/dist/index-CybB8Tdk.js.map +1 -0
- package/dist/index.js +24 -23
- package/dist/index.js.map +1 -1
- package/dist/middleware.js +5 -4
- package/dist/middleware.js.map +1 -1
- package/dist/seo.js +1 -1
- package/dist/server.js +374 -380
- package/dist/server.js.map +1 -1
- package/dist/tooltip.js +92 -74
- package/dist/tooltip.js.map +1 -1
- package/package.json +5 -1
- package/src/core/bundler.ts +201 -205
- package/src/core/jsx-types.d.ts +1 -0
- package/src/core/server.ts +52 -29
- package/src/i18n/index.ts +2 -0
- package/src/i18n/middleware.ts +50 -0
- package/src/i18n/types.ts +13 -0
- package/src/seo/generateMetadata.tsx +7 -2
- package/src/seo/types.ts +16 -0
- package/src/tooltip/index.ts +2 -1
- package/src/tooltip/tooltip-runtime.ts +71 -4
- package/dist/generateMetadata-CIFVlViV.js.map +0 -1
- package/dist/index-BlfNBupp.js.map +0 -1
package/dist/server.js
CHANGED
|
@@ -1,337 +1,330 @@
|
|
|
1
|
-
import { existsSync as
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import { pathToFileURL as
|
|
5
|
-
import
|
|
6
|
-
import { a as
|
|
7
|
-
import {
|
|
8
|
-
import { createHash as
|
|
9
|
-
import { createRequire as
|
|
10
|
-
let
|
|
11
|
-
function
|
|
12
|
-
return
|
|
13
|
-
const
|
|
14
|
-
return await import(
|
|
15
|
-
})()),
|
|
1
|
+
import { existsSync as Q } from "fs";
|
|
2
|
+
import H from "node:fs/promises";
|
|
3
|
+
import d from "node:path";
|
|
4
|
+
import { pathToFileURL as I } from "node:url";
|
|
5
|
+
import V from "request-ip";
|
|
6
|
+
import { a as ot, s as J } from "./render-DTXfJu0d.js";
|
|
7
|
+
import { c as G, p as tt, a as it } from "./index-CybB8Tdk.js";
|
|
8
|
+
import { createHash as at } from "node:crypto";
|
|
9
|
+
import { createRequire as ct } from "node:module";
|
|
10
|
+
let B = null;
|
|
11
|
+
function lt() {
|
|
12
|
+
return B || (B = (async () => {
|
|
13
|
+
const t = ct(import.meta.url), e = t.resolve("vite"), n = t.resolve("rollup", { paths: [d.dirname(e)] });
|
|
14
|
+
return await import(I(n).href);
|
|
15
|
+
})()), B;
|
|
16
16
|
}
|
|
17
|
-
const
|
|
18
|
-
function
|
|
19
|
-
|
|
17
|
+
const W = { hash: "", filename: "", content: "" }, z = /* @__PURE__ */ new Map(), K = /* @__PURE__ */ new Map();
|
|
18
|
+
function et(t, e) {
|
|
19
|
+
const n = K.get(t);
|
|
20
|
+
if (n)
|
|
21
|
+
return n;
|
|
22
|
+
const s = e().catch((i) => {
|
|
23
|
+
throw K.delete(t), i;
|
|
24
|
+
});
|
|
25
|
+
return K.set(t, s), s;
|
|
20
26
|
}
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
27
|
+
function q(t) {
|
|
28
|
+
return at("sha256").update(t).digest("hex").substring(0, 16);
|
|
29
|
+
}
|
|
30
|
+
const F = "\0l5e:bundle-entry";
|
|
31
|
+
function ut(t) {
|
|
32
|
+
return {
|
|
33
|
+
name: "l5e-virtual-entry",
|
|
34
|
+
resolveId(e) {
|
|
35
|
+
return e === F ? F : null;
|
|
36
|
+
},
|
|
37
|
+
load(e) {
|
|
38
|
+
return e === F ? t : null;
|
|
39
|
+
}
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
function dt(t) {
|
|
43
|
+
const e = (n) => "/" + d.relative(t, n).replace(/\\/g, "/");
|
|
44
|
+
return {
|
|
45
|
+
name: "vendor-path-rewriter",
|
|
46
|
+
resolveId(n, s) {
|
|
47
|
+
return !n.includes("vendor-") && !n.includes("chunk-") && !n.includes(".global") ? null : d.isAbsolute(n) ? { id: e(n), external: !0 } : s && n.startsWith(".") ? { id: e(d.resolve(d.dirname(s), n)), external: !0 } : null;
|
|
48
|
+
}
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
async function ft(t, e) {
|
|
52
|
+
const n = t.map((u) => {
|
|
53
|
+
const k = u.startsWith("/") ? d.join(e, u.substring(1)) : d.join(e, u);
|
|
54
|
+
return `import ${JSON.stringify(k)};`;
|
|
55
|
+
}).join(`
|
|
56
|
+
`), s = {
|
|
57
|
+
input: F,
|
|
58
|
+
plugins: [ut(n), dt(e)],
|
|
59
|
+
external: (u) => !u.startsWith(".") && !d.isAbsolute(u) && u !== F
|
|
60
|
+
}, i = {
|
|
61
|
+
format: "es",
|
|
62
|
+
inlineDynamicImports: !1,
|
|
63
|
+
entryFileNames: "bundle-[hash].js",
|
|
64
|
+
chunkFileNames: "bundle-[hash].js"
|
|
65
|
+
}, { rollup: l } = await lt(), c = await l(s);
|
|
66
|
+
let a;
|
|
35
67
|
try {
|
|
36
|
-
|
|
37
|
-
`)), g = u.join(t, ".temp-bundle");
|
|
38
|
-
await M.mkdir(g, { recursive: !0 }).catch(() => {
|
|
39
|
-
}), c = u.join(g, `entry-${a}.js`);
|
|
40
|
-
const $ = o.map((s, h) => {
|
|
41
|
-
const v = s.startsWith("/") ? u.join(n, s.substring(1)) : u.join(n, s);
|
|
42
|
-
return `import ${JSON.stringify(v)};`;
|
|
43
|
-
}).join(`
|
|
44
|
-
`);
|
|
45
|
-
await M.writeFile(c, $, "utf-8"), console.log(`[bundler] Wrote entry file to ${c}`), console.log(`[bundler] Entry content: ${$}`);
|
|
46
|
-
const R = {
|
|
47
|
-
input: c,
|
|
48
|
-
plugins: [
|
|
49
|
-
{
|
|
50
|
-
name: "vendor-path-rewriter",
|
|
51
|
-
resolveId(s, h, v) {
|
|
52
|
-
if (s.includes("vendor-") || s.includes("chunk-") || s.includes(".global")) {
|
|
53
|
-
if (console.log(`[bundler] Resolving source: ${s}`), u.isAbsolute(s))
|
|
54
|
-
return console.log(`[bundler] Resolving absolute path: ${s}`), { id: "/" + u.relative(n, s).replace(/\\/g, "/"), external: !0 };
|
|
55
|
-
if (h && s.startsWith(".")) {
|
|
56
|
-
console.log(
|
|
57
|
-
`[bundler] Resolving relative path: ${s} from importer: ${h}`
|
|
58
|
-
);
|
|
59
|
-
const y = u.resolve(u.dirname(h), s);
|
|
60
|
-
return { id: "/" + u.relative(n, y).replace(/\\/g, "/"), external: !0 };
|
|
61
|
-
} else
|
|
62
|
-
console.log(`[bundler] Resolving source: ${s}`);
|
|
63
|
-
}
|
|
64
|
-
return null;
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
],
|
|
68
|
-
external: (s) => !s.startsWith(".") && !u.isAbsolute(s) ? !0 : (s.includes("vendor-") || s.includes("chunk-") || s.includes(".global"), !1)
|
|
69
|
-
}, j = {
|
|
70
|
-
format: "es",
|
|
71
|
-
inlineDynamicImports: !1,
|
|
72
|
-
entryFileNames: "bundle-[hash].js",
|
|
73
|
-
chunkFileNames: "bundle-[hash].js"
|
|
74
|
-
}, { rollup: P } = await ne(), C = await P(R), { output: r } = await C.generate(j);
|
|
75
|
-
await C.close(), r.forEach((s) => {
|
|
76
|
-
if (s.type !== "chunk")
|
|
77
|
-
return;
|
|
78
|
-
const h = {
|
|
79
|
-
content: s.code || "",
|
|
80
|
-
hash: U(s.code || ""),
|
|
81
|
-
filename: s.fileName,
|
|
82
|
-
mimeType: "application/javascript"
|
|
83
|
-
};
|
|
84
|
-
I.set(s.fileName, h);
|
|
85
|
-
});
|
|
86
|
-
const f = r[0];
|
|
87
|
-
return f?.type === "chunk" && J.set(l, f.fileName), {
|
|
88
|
-
hash: U(r[0]?.code || ""),
|
|
89
|
-
filename: r[0]?.fileName || "",
|
|
90
|
-
content: r[0]?.code || ""
|
|
91
|
-
};
|
|
92
|
-
} catch (a) {
|
|
93
|
-
return console.error("[bundler] Error bundling scripts:", a), { hash: "", filename: "", content: "" };
|
|
68
|
+
({ output: a } = await c.generate(i));
|
|
94
69
|
} finally {
|
|
95
|
-
|
|
96
|
-
});
|
|
70
|
+
await c.close();
|
|
97
71
|
}
|
|
72
|
+
for (const u of a)
|
|
73
|
+
u.type === "chunk" && z.set(u.fileName, {
|
|
74
|
+
content: u.code || "",
|
|
75
|
+
hash: q(u.code || ""),
|
|
76
|
+
filename: u.fileName,
|
|
77
|
+
mimeType: "application/javascript"
|
|
78
|
+
});
|
|
79
|
+
const f = a[0];
|
|
80
|
+
if (f?.type !== "chunk")
|
|
81
|
+
throw new Error("[bundler] rollup produced no entry chunk");
|
|
82
|
+
return {
|
|
83
|
+
hash: q(f.code || ""),
|
|
84
|
+
filename: f.fileName,
|
|
85
|
+
content: f.code || ""
|
|
86
|
+
};
|
|
98
87
|
}
|
|
99
|
-
async function
|
|
100
|
-
if (
|
|
101
|
-
return
|
|
102
|
-
const
|
|
103
|
-
if (d) {
|
|
104
|
-
const c = I.get(d);
|
|
105
|
-
if (c)
|
|
106
|
-
return {
|
|
107
|
-
hash: c.hash,
|
|
108
|
-
filename: c.filename,
|
|
109
|
-
content: c.content
|
|
110
|
-
};
|
|
111
|
-
}
|
|
88
|
+
async function pt(t, e) {
|
|
89
|
+
if (t.length === 0)
|
|
90
|
+
return W;
|
|
91
|
+
const n = [...new Set(t)].sort(), s = `scripts:${n.join(",")}`;
|
|
112
92
|
try {
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
93
|
+
return await et(s, () => ft(n, e));
|
|
94
|
+
} catch (i) {
|
|
95
|
+
return console.error("[bundler] Error bundling scripts:", i), W;
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
async function ht(t, e) {
|
|
99
|
+
const n = [];
|
|
100
|
+
for (const c of t) {
|
|
101
|
+
const a = c.startsWith("/") ? d.join(e, c.substring(1)) : d.join(e, c);
|
|
102
|
+
try {
|
|
103
|
+
const f = await H.readFile(a, "utf-8");
|
|
104
|
+
n.push(`/* ${c} */
|
|
105
|
+
${f}
|
|
120
106
|
`);
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
}
|
|
107
|
+
} catch (f) {
|
|
108
|
+
console.warn(`[bundler] Failed to read CSS file: ${c}`, f);
|
|
124
109
|
}
|
|
125
|
-
|
|
110
|
+
}
|
|
111
|
+
const s = n.join(`
|
|
126
112
|
|
|
127
|
-
`),
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
113
|
+
`), i = q(s), l = `bundle-${i}.css`;
|
|
114
|
+
return z.set(l, {
|
|
115
|
+
content: s,
|
|
116
|
+
hash: i,
|
|
117
|
+
filename: l,
|
|
118
|
+
mimeType: "text/css"
|
|
119
|
+
}), { hash: i, filename: l, content: s };
|
|
120
|
+
}
|
|
121
|
+
async function mt(t, e) {
|
|
122
|
+
if (t.length === 0)
|
|
123
|
+
return W;
|
|
124
|
+
const n = [...new Set(t)].sort(), s = `css:${n.join(",")}`;
|
|
125
|
+
try {
|
|
126
|
+
return await et(s, () => ht(n, e));
|
|
127
|
+
} catch (i) {
|
|
128
|
+
return console.error("[bundler] Error bundling CSS:", i), W;
|
|
136
129
|
}
|
|
137
130
|
}
|
|
138
|
-
function
|
|
139
|
-
return
|
|
131
|
+
function wt(t) {
|
|
132
|
+
return z.get(t);
|
|
140
133
|
}
|
|
141
|
-
function
|
|
142
|
-
const n =
|
|
143
|
-
return
|
|
134
|
+
function gt(t, e) {
|
|
135
|
+
const n = ot(e);
|
|
136
|
+
return t.replace(/<html\b([^>]*)>/i, (s, i) => /\blang\s*=/i.test(i) ? s.replace(/lang\s*=\s*"[^"]*"/i, () => `lang="${n}"`) : `<html lang="${n}"${i}>`);
|
|
144
137
|
}
|
|
145
|
-
function
|
|
146
|
-
return new URL(`${
|
|
138
|
+
function yt(t) {
|
|
139
|
+
return new URL(`${t.protocol}://${t.get("host")}${t.originalUrl}`);
|
|
147
140
|
}
|
|
148
|
-
function
|
|
149
|
-
return `${
|
|
141
|
+
function nt(t, e) {
|
|
142
|
+
return `${t.pathname}${t.search}`.replace(e, "") || "/";
|
|
150
143
|
}
|
|
151
|
-
function
|
|
152
|
-
const
|
|
153
|
-
method:
|
|
154
|
-
headers:
|
|
144
|
+
function Y(t) {
|
|
145
|
+
const e = {
|
|
146
|
+
method: t.method,
|
|
147
|
+
headers: it(t)
|
|
155
148
|
};
|
|
156
|
-
return
|
|
149
|
+
return t.method !== "GET" && t.method !== "HEAD" && (e.body = t, e.duplex = "half"), new globalThis.Request(yt(t).href, e);
|
|
157
150
|
}
|
|
158
|
-
function
|
|
159
|
-
const
|
|
160
|
-
return
|
|
161
|
-
a[
|
|
151
|
+
function D(t, e, n, s) {
|
|
152
|
+
const i = new URL(e.url), l = nt(i, n), c = l.startsWith("/") ? l : `/${l}`, a = {};
|
|
153
|
+
return e.headers.forEach((f, u) => {
|
|
154
|
+
a[u] = f;
|
|
162
155
|
}), {
|
|
163
|
-
url:
|
|
156
|
+
url: i,
|
|
164
157
|
path: c,
|
|
165
|
-
pathname:
|
|
166
|
-
method:
|
|
158
|
+
pathname: i.pathname,
|
|
159
|
+
method: e.method,
|
|
167
160
|
headers: a,
|
|
168
|
-
cookies:
|
|
169
|
-
query: Object.fromEntries(
|
|
170
|
-
ip:
|
|
171
|
-
locals:
|
|
161
|
+
cookies: tt(e.headers.get("cookie") ?? void 0),
|
|
162
|
+
query: Object.fromEntries(i.searchParams.entries()),
|
|
163
|
+
ip: V.getClientIp(t) ?? void 0,
|
|
164
|
+
locals: s
|
|
172
165
|
};
|
|
173
166
|
}
|
|
174
|
-
function
|
|
175
|
-
return
|
|
167
|
+
function X(t, e, n) {
|
|
168
|
+
return t ? t instanceof globalThis.Request ? t : t instanceof URL ? new globalThis.Request(t.href, e.clone()) : new globalThis.Request(new URL(t, n).href, e.clone()) : e;
|
|
176
169
|
}
|
|
177
|
-
async function
|
|
178
|
-
|
|
179
|
-
const
|
|
180
|
-
if (n.headers.forEach((
|
|
181
|
-
c.toLowerCase() !== "set-cookie" &&
|
|
182
|
-
}),
|
|
183
|
-
|
|
170
|
+
async function Z(t, e, n) {
|
|
171
|
+
e.status(n.status);
|
|
172
|
+
const s = bt(n.headers);
|
|
173
|
+
if (n.headers.forEach((l, c) => {
|
|
174
|
+
c.toLowerCase() !== "set-cookie" && e.setHeader(c, l);
|
|
175
|
+
}), s.length > 0 && e.setHeader("Set-Cookie", s), t.method === "HEAD") {
|
|
176
|
+
e.end();
|
|
184
177
|
return;
|
|
185
178
|
}
|
|
186
|
-
const
|
|
187
|
-
|
|
179
|
+
const i = Buffer.from(await n.arrayBuffer());
|
|
180
|
+
e.send(i);
|
|
188
181
|
}
|
|
189
|
-
function
|
|
190
|
-
const
|
|
191
|
-
if (typeof
|
|
192
|
-
return
|
|
193
|
-
const n =
|
|
182
|
+
function bt(t) {
|
|
183
|
+
const e = t.getSetCookie;
|
|
184
|
+
if (typeof e == "function")
|
|
185
|
+
return e.call(t);
|
|
186
|
+
const n = t.raw?.();
|
|
194
187
|
if (n?.["set-cookie"])
|
|
195
188
|
return n["set-cookie"];
|
|
196
|
-
const
|
|
197
|
-
return
|
|
189
|
+
const s = t.get("set-cookie");
|
|
190
|
+
return s ? vt(s) : [];
|
|
198
191
|
}
|
|
199
|
-
function
|
|
200
|
-
const
|
|
192
|
+
function vt(t) {
|
|
193
|
+
const e = [];
|
|
201
194
|
let n = 0;
|
|
202
|
-
for (let
|
|
203
|
-
if (
|
|
204
|
-
const
|
|
205
|
-
/^\s*[^=;,]+=/.test(
|
|
195
|
+
for (let s = 0; s < t.length; s++) {
|
|
196
|
+
if (t[s] !== ",") continue;
|
|
197
|
+
const i = t.slice(s + 1);
|
|
198
|
+
/^\s*[^=;,]+=/.test(i) && (e.push(t.slice(n, s).trim()), n = s + 1);
|
|
206
199
|
}
|
|
207
|
-
return
|
|
200
|
+
return e.push(t.slice(n).trim()), e.filter(Boolean);
|
|
208
201
|
}
|
|
209
|
-
function
|
|
210
|
-
if (!
|
|
202
|
+
function xt(t) {
|
|
203
|
+
if (!t.rawResponse)
|
|
211
204
|
return null;
|
|
212
|
-
const { body:
|
|
213
|
-
return
|
|
214
|
-
status:
|
|
215
|
-
headers:
|
|
205
|
+
const { body: e, contentType: n, statusCode: s, headers: i } = t.rawResponse, l = new Headers(i);
|
|
206
|
+
return l.set("Content-Type", n), new globalThis.Response(e, {
|
|
207
|
+
status: s || 200,
|
|
208
|
+
headers: l
|
|
216
209
|
});
|
|
217
210
|
}
|
|
218
|
-
async function
|
|
219
|
-
rendered:
|
|
220
|
-
template:
|
|
211
|
+
async function St({
|
|
212
|
+
rendered: t,
|
|
213
|
+
template: e,
|
|
221
214
|
manifest: n,
|
|
222
|
-
root:
|
|
223
|
-
distClientDir:
|
|
224
|
-
isProduction:
|
|
215
|
+
root: s,
|
|
216
|
+
distClientDir: i,
|
|
217
|
+
isProduction: l
|
|
225
218
|
}) {
|
|
226
|
-
const c =
|
|
219
|
+
const c = xt(t);
|
|
227
220
|
if (c)
|
|
228
221
|
return c;
|
|
229
|
-
if (
|
|
222
|
+
if (t.redirect)
|
|
230
223
|
return new globalThis.Response(null, {
|
|
231
|
-
status:
|
|
224
|
+
status: t.redirect.statusCode,
|
|
232
225
|
headers: {
|
|
233
|
-
Location:
|
|
226
|
+
Location: t.redirect.url
|
|
234
227
|
}
|
|
235
228
|
});
|
|
236
|
-
let a =
|
|
237
|
-
const
|
|
238
|
-
let
|
|
239
|
-
const
|
|
240
|
-
let
|
|
241
|
-
if (
|
|
242
|
-
let
|
|
243
|
-
const
|
|
244
|
-
return
|
|
245
|
-
const
|
|
246
|
-
|
|
247
|
-
const
|
|
248
|
-
|
|
229
|
+
let a = t.scripts || [], f = t.styles || [];
|
|
230
|
+
const u = t.islands || [];
|
|
231
|
+
let k = t.cacheTags || [];
|
|
232
|
+
const _ = t.maxAge, N = t.sMaxAge, U = t.swr;
|
|
233
|
+
let o = "", p = [], w = "";
|
|
234
|
+
if (l && n) {
|
|
235
|
+
let x = function(r) {
|
|
236
|
+
const m = n[r];
|
|
237
|
+
return m ? (m.css && m.css.forEach((b) => g.add(b)), m.imports && m.imports.forEach((b) => {
|
|
238
|
+
const P = n[b];
|
|
239
|
+
P?.file && T.add(P.file), P?.css && P.css.forEach((A) => g.add(A)), P?.imports && P.imports.forEach((A) => {
|
|
240
|
+
const j = n[A];
|
|
241
|
+
j?.file && T.add(j.file), j?.css && j.css.forEach((O) => g.add(O));
|
|
249
242
|
});
|
|
250
|
-
}), { file:
|
|
243
|
+
}), { file: m.file }) : { file: null };
|
|
251
244
|
};
|
|
252
|
-
a = a.filter((
|
|
253
|
-
const
|
|
254
|
-
for (const
|
|
255
|
-
const
|
|
256
|
-
b &&
|
|
245
|
+
a = a.filter((r) => !r.includes(".global.")), f = f.filter((r) => !r.includes(".global."));
|
|
246
|
+
const g = /* @__PURE__ */ new Set(), T = /* @__PURE__ */ new Set(), M = [];
|
|
247
|
+
for (const r of a) {
|
|
248
|
+
const m = r.replace(/^\//, ""), { file: b } = x(m);
|
|
249
|
+
b && M.push(`/${b}`);
|
|
257
250
|
}
|
|
258
251
|
const L = [];
|
|
259
|
-
for (const
|
|
260
|
-
const
|
|
261
|
-
b && (L.push(`/${b}`),
|
|
252
|
+
for (const r of f) {
|
|
253
|
+
const m = r.replace(/^\//, ""), { file: b } = x(m);
|
|
254
|
+
b && (L.push(`/${b}`), g.add(b));
|
|
262
255
|
}
|
|
263
|
-
if (
|
|
264
|
-
const
|
|
265
|
-
a =
|
|
256
|
+
if (M.length > 0) {
|
|
257
|
+
const r = await pt(M, i);
|
|
258
|
+
a = r.filename ? [`/${r.filename}`] : M;
|
|
266
259
|
}
|
|
267
260
|
if (L.length > 0) {
|
|
268
|
-
const
|
|
269
|
-
|
|
261
|
+
const r = await mt(L, i);
|
|
262
|
+
r.filename && (f = [`/${r.filename}`]);
|
|
270
263
|
}
|
|
271
|
-
const
|
|
272
|
-
if (
|
|
273
|
-
|
|
274
|
-
}),
|
|
275
|
-
const
|
|
276
|
-
for (const
|
|
277
|
-
const b = n[
|
|
278
|
-
b?.file && (
|
|
264
|
+
const h = n["src/client.global.ts"];
|
|
265
|
+
if (h && (h.css && h.css.length > 0 && h.css.forEach((r) => {
|
|
266
|
+
o += `<link rel="stylesheet" crossorigin href="/${r}">`;
|
|
267
|
+
}), h.file && p.push(`/${h.file}`)), u.length > 0) {
|
|
268
|
+
const r = {};
|
|
269
|
+
for (const m of u) {
|
|
270
|
+
const b = n[m.src];
|
|
271
|
+
b?.file && (r[m.key] = `/${b.file}`);
|
|
279
272
|
}
|
|
280
|
-
Object.keys(
|
|
273
|
+
Object.keys(r).length > 0 && (w = `<script>window.__L5E_ISLANDS__=${J(r)}<\/script>`);
|
|
281
274
|
}
|
|
282
|
-
|
|
275
|
+
f.length > 0 && (o += f.map((r) => `<link rel="stylesheet" crossorigin href="${r}">`).join(""));
|
|
283
276
|
}
|
|
284
|
-
let
|
|
285
|
-
|
|
286
|
-
let
|
|
287
|
-
if (!
|
|
288
|
-
const
|
|
289
|
-
if (
|
|
290
|
-
const
|
|
291
|
-
for (const
|
|
292
|
-
|
|
293
|
-
|
|
277
|
+
let y = "";
|
|
278
|
+
l || (y = f.map((x) => `<link rel="stylesheet" href="${x}">`).join(""));
|
|
279
|
+
let S = [...p, ...a];
|
|
280
|
+
if (!l) {
|
|
281
|
+
const x = d.join(s, "src", "client.global.ts");
|
|
282
|
+
if (Q(x) && (S = ["/src/client.global.ts", ...S]), u.length > 0) {
|
|
283
|
+
const g = {};
|
|
284
|
+
for (const T of u)
|
|
285
|
+
g[T.key] = `/${T.src}`;
|
|
286
|
+
w = `<script>window.__L5E_ISLANDS__=${J(g)}<\/script>`;
|
|
294
287
|
}
|
|
295
288
|
}
|
|
296
|
-
const
|
|
289
|
+
const v = w + S.map((x) => `<script type="module" src="${x}"><\/script>`).join(""), E = t.lang ? gt(e, t.lang) : e, $ = t.rawHtml ? t.html || "" : E.replace("<!--app-head-->", () => (t.head ?? "") + o + y).replace("<!--app-html-->", () => t.html ?? "").replace("<!--app-scripts-->", () => v), C = new Headers({
|
|
297
290
|
"Content-Type": "text/html"
|
|
298
|
-
}),
|
|
299
|
-
return
|
|
300
|
-
status:
|
|
301
|
-
headers:
|
|
291
|
+
}), R = ["public"];
|
|
292
|
+
return _ !== void 0 && R.push(`max-age=${_}`), N !== void 0 && R.push(`s-maxage=${N}`), U !== void 0 && R.push(`stale-while-revalidate=${U}`), R.length > 1 && l && C.set("Cache-Control", R.join(", ")), process.env.NODE_ENV === "production" && (k = Ct(k)), C.set("Cache-Tag", ["global", ...k].join(",")), new globalThis.Response($, {
|
|
293
|
+
status: t.statusCode || 200,
|
|
294
|
+
headers: C
|
|
302
295
|
});
|
|
303
296
|
}
|
|
304
|
-
async function
|
|
305
|
-
const
|
|
306
|
-
if (
|
|
307
|
-
const
|
|
308
|
-
|
|
297
|
+
async function $t(t = {}) {
|
|
298
|
+
const e = t.root || process.cwd(), n = t.base || "/", s = process.env.NODE_ENV === "production", i = s ? await H.readFile(d.join(e, "./index.html"), "utf-8") : "", l = (await import("express")).default, c = t.app || l();
|
|
299
|
+
if (t.publicDir) {
|
|
300
|
+
const o = d.isAbsolute(t.publicDir) ? t.publicDir : d.join(e, t.publicDir);
|
|
301
|
+
Q(o) && c.use(l.static(o));
|
|
309
302
|
}
|
|
310
303
|
let a;
|
|
311
|
-
const
|
|
312
|
-
if (
|
|
313
|
-
const
|
|
314
|
-
c.use(
|
|
304
|
+
const f = d.join(e, "./dist/client");
|
|
305
|
+
if (s) {
|
|
306
|
+
const o = (await import("compression")).default, p = (await import("sirv")).default;
|
|
307
|
+
c.use(o()), c.use(n, p(f, { extensions: [] })), c.get(
|
|
315
308
|
`${n === "/" ? "" : n}/bundle-:hash.:ext`,
|
|
316
|
-
async (
|
|
309
|
+
async (w, y) => {
|
|
317
310
|
try {
|
|
318
|
-
const { hash:
|
|
319
|
-
if (
|
|
320
|
-
return
|
|
321
|
-
|
|
322
|
-
"Content-Type":
|
|
311
|
+
const { hash: S, ext: v } = w.params, E = `bundle-${S}.${v}`, $ = wt(E);
|
|
312
|
+
if (!$)
|
|
313
|
+
return y.status(404).send("Bundled file not found");
|
|
314
|
+
y.set({
|
|
315
|
+
"Content-Type": $.mimeType,
|
|
323
316
|
"Cache-Control": "public, max-age=31536000, immutable"
|
|
324
|
-
}),
|
|
325
|
-
} catch (
|
|
326
|
-
console.error("[server] Error serving bundled file:",
|
|
317
|
+
}), y.send($.content);
|
|
318
|
+
} catch (S) {
|
|
319
|
+
console.error("[server] Error serving bundled file:", S), y.status(500).end("Internal server error");
|
|
327
320
|
}
|
|
328
321
|
}
|
|
329
322
|
);
|
|
330
323
|
} else {
|
|
331
|
-
const { createServer:
|
|
332
|
-
a = await
|
|
333
|
-
root:
|
|
334
|
-
configFile:
|
|
324
|
+
const { createServer: o } = await import("vite"), p = d.join(e, "vite.config.js");
|
|
325
|
+
a = await o({
|
|
326
|
+
root: e,
|
|
327
|
+
configFile: p,
|
|
335
328
|
server: { middlewareMode: !0 },
|
|
336
329
|
appType: "custom",
|
|
337
330
|
base: n,
|
|
@@ -348,155 +341,156 @@ async function me(e = {}) {
|
|
|
348
341
|
}
|
|
349
342
|
}), c.use(a.middlewares);
|
|
350
343
|
}
|
|
351
|
-
c.use("/_l5e/action",
|
|
352
|
-
const
|
|
353
|
-
let
|
|
354
|
-
async function
|
|
355
|
-
if (!
|
|
344
|
+
c.use("/_l5e/action", l.json({ limit: "100kb" }));
|
|
345
|
+
const u = /^[a-zA-Z]\w+_[0-9a-f]{1,4}$/;
|
|
346
|
+
let k = null, _ = null;
|
|
347
|
+
async function N() {
|
|
348
|
+
if (!s)
|
|
356
349
|
return (await a.ssrLoadModule("virtual:l5e-actions")).actionRegistry || {};
|
|
357
|
-
if (!
|
|
358
|
-
const
|
|
359
|
-
|
|
350
|
+
if (!k) {
|
|
351
|
+
const o = d.join(e, "./dist/server/action-registry.json"), p = await H.readFile(o, "utf-8");
|
|
352
|
+
k = JSON.parse(p);
|
|
360
353
|
}
|
|
361
|
-
return
|
|
354
|
+
return k;
|
|
362
355
|
}
|
|
363
|
-
async function
|
|
364
|
-
if (!
|
|
356
|
+
async function U() {
|
|
357
|
+
if (!s)
|
|
365
358
|
return (await a.ssrLoadModule("virtual:l5e-actions")).viewActions || {};
|
|
366
|
-
if (!
|
|
367
|
-
const
|
|
368
|
-
|
|
359
|
+
if (!_) {
|
|
360
|
+
const o = d.join(e, "./dist/server/entry-server.js");
|
|
361
|
+
_ = (await import(I(o).href)).viewActions || {};
|
|
369
362
|
}
|
|
370
|
-
return
|
|
363
|
+
return _;
|
|
371
364
|
}
|
|
372
|
-
return c.all("/_l5e/action/:actionKey", async (
|
|
365
|
+
return c.all("/_l5e/action/:actionKey", async (o, p) => {
|
|
373
366
|
try {
|
|
374
|
-
const { actionKey:
|
|
375
|
-
if (
|
|
376
|
-
return
|
|
377
|
-
const
|
|
378
|
-
if (!
|
|
379
|
-
return
|
|
380
|
-
const { modulePath:
|
|
381
|
-
let
|
|
382
|
-
if (
|
|
383
|
-
const
|
|
384
|
-
if (!
|
|
385
|
-
return
|
|
386
|
-
|
|
367
|
+
const { actionKey: w } = o.params;
|
|
368
|
+
if (!u.test(w))
|
|
369
|
+
return p.status(400).send("Invalid action key");
|
|
370
|
+
const S = (await N())[w];
|
|
371
|
+
if (!S)
|
|
372
|
+
return p.status(404).send("Action not found");
|
|
373
|
+
const { modulePath: v, actionName: E } = S;
|
|
374
|
+
let $;
|
|
375
|
+
if (s) {
|
|
376
|
+
const A = await U(), j = A[`/src/${v}/actions.tsx`] ? `/src/${v}/actions.tsx` : A[`/src/${v}/actions.ts`] ? `/src/${v}/actions.ts` : null;
|
|
377
|
+
if (!j)
|
|
378
|
+
return p.status(404).send("Action module not found");
|
|
379
|
+
$ = await A[j]();
|
|
387
380
|
} else
|
|
388
381
|
try {
|
|
389
|
-
|
|
382
|
+
$ = await a.ssrLoadModule(`/src/${v}/actions.tsx`);
|
|
390
383
|
} catch {
|
|
391
|
-
|
|
384
|
+
$ = await a.ssrLoadModule(`/src/${v}/actions.ts`);
|
|
392
385
|
}
|
|
393
|
-
if (!Object.prototype.hasOwnProperty.call(
|
|
394
|
-
return
|
|
395
|
-
const
|
|
396
|
-
if (!
|
|
397
|
-
return
|
|
398
|
-
const
|
|
399
|
-
if (
|
|
400
|
-
return
|
|
401
|
-
const
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
386
|
+
if (!Object.prototype.hasOwnProperty.call($, E))
|
|
387
|
+
return p.status(404).send("Action not found");
|
|
388
|
+
const C = $[E];
|
|
389
|
+
if (!C || !C.handler)
|
|
390
|
+
return p.status(404).send("Action not found");
|
|
391
|
+
const R = (C.method || "GET").toUpperCase();
|
|
392
|
+
if (o.method.toUpperCase() !== R)
|
|
393
|
+
return p.status(405).set("Allow", R).send("Method Not Allowed");
|
|
394
|
+
const x = d.join(e, "./dist/server/entry-server.js"), g = s ? await import(I(x).href) : await a.ssrLoadModule("@withl5e/l5e/entry-server"), { runInRenderContext: T } = await (s ? import(I(x).href) : a.ssrLoadModule("@withl5e/l5e/jsx-runtime")), { renderJsxToHtmlString: M } = await (s ? import(I(x).href) : a.ssrLoadModule("@withl5e/l5e")), L = {}, h = Y(o), r = G({
|
|
395
|
+
request: h,
|
|
396
|
+
locals: L,
|
|
397
|
+
clientAddress: V.getClientIp(o) ?? void 0
|
|
398
|
+
}), m = await g.loadMiddleware?.(), P = await (typeof m == "function" ? m : (A, j) => j())(r, async (A) => {
|
|
399
|
+
const j = X(A, r.request, r.url), O = {
|
|
400
|
+
...D(o, j, n, L),
|
|
401
|
+
path: o.originalUrl,
|
|
402
|
+
body: o.body
|
|
403
|
+
}, st = await T(
|
|
404
|
+
async () => {
|
|
405
|
+
const rt = await C.handler(O);
|
|
406
|
+
return M(rt);
|
|
407
|
+
},
|
|
408
|
+
O,
|
|
409
|
+
v
|
|
410
|
+
);
|
|
411
|
+
return new Response(st, { headers: { "Content-Type": "text/html" } });
|
|
412
|
+
});
|
|
413
|
+
await Z(o, p, P);
|
|
414
|
+
} catch (w) {
|
|
415
|
+
a?.ssrFixStacktrace?.(w), console.error("[l5e] Action error:", w.stack || w), p.status(500).send("Internal server error");
|
|
422
416
|
}
|
|
423
|
-
}), c.use(async (
|
|
417
|
+
}), c.use(async (o, p) => {
|
|
424
418
|
try {
|
|
425
|
-
const
|
|
426
|
-
let
|
|
427
|
-
if (
|
|
428
|
-
|
|
429
|
-
const
|
|
430
|
-
|
|
431
|
-
const
|
|
432
|
-
|
|
419
|
+
const w = o.originalUrl.replace(n, "");
|
|
420
|
+
let y, S, v, E;
|
|
421
|
+
if (s) {
|
|
422
|
+
y = i;
|
|
423
|
+
const h = d.join(e, "./dist/server/entry-server.js"), r = await import(I(h).href);
|
|
424
|
+
S = r.render, v = r.loadMiddleware;
|
|
425
|
+
const m = await H.readFile(
|
|
426
|
+
d.join(e, "./dist/client/.vite/manifest.json"),
|
|
433
427
|
"utf-8"
|
|
434
428
|
);
|
|
435
|
-
|
|
429
|
+
E = JSON.parse(m);
|
|
436
430
|
} else {
|
|
437
|
-
|
|
431
|
+
y = await H.readFile(d.join(e, "./index.html"), "utf-8"), y = await a.transformIndexHtml(w, y), y.includes("@vite/client") || (y = y.replace(
|
|
438
432
|
"</head>",
|
|
439
433
|
'<script type="module" src="/@vite/client"><\/script></head>'
|
|
440
434
|
));
|
|
441
|
-
const
|
|
435
|
+
const h = await a.ssrLoadModule(
|
|
442
436
|
"@withl5e/l5e/entry-server"
|
|
443
437
|
);
|
|
444
|
-
|
|
438
|
+
S = h.render, v = h.loadMiddleware;
|
|
445
439
|
}
|
|
446
|
-
const
|
|
447
|
-
request:
|
|
448
|
-
requestInfo:
|
|
449
|
-
locals:
|
|
450
|
-
clientAddress:
|
|
451
|
-
}),
|
|
452
|
-
const
|
|
453
|
-
return
|
|
440
|
+
const $ = await v?.(), C = typeof $ == "function" ? $ : (h, r) => r(), R = {}, x = Y(o), g = G({
|
|
441
|
+
request: x,
|
|
442
|
+
requestInfo: D(o, x, n, R),
|
|
443
|
+
locals: R,
|
|
444
|
+
clientAddress: V.getClientIp(o)
|
|
445
|
+
}), T = async (h) => {
|
|
446
|
+
const r = D(o, h, n, R), m = nt(r.url, n), b = await S(m, r);
|
|
447
|
+
return St({
|
|
454
448
|
rendered: b,
|
|
455
|
-
template:
|
|
456
|
-
manifest:
|
|
457
|
-
root:
|
|
458
|
-
distClientDir:
|
|
459
|
-
isProduction:
|
|
449
|
+
template: y,
|
|
450
|
+
manifest: E,
|
|
451
|
+
root: e,
|
|
452
|
+
distClientDir: f,
|
|
453
|
+
isProduction: s
|
|
460
454
|
});
|
|
461
|
-
},
|
|
462
|
-
const
|
|
463
|
-
return
|
|
455
|
+
}, M = async (h) => {
|
|
456
|
+
const r = X(h, g.request, g.url);
|
|
457
|
+
return g.request = r, g.url = new URL(r.url), g.cookies = tt(r.headers.get("cookie") ?? void 0), g.requestInfo = D(o, r, n, R), T(r);
|
|
464
458
|
};
|
|
465
|
-
|
|
466
|
-
const L = await
|
|
467
|
-
await
|
|
468
|
-
} catch (
|
|
469
|
-
a?.ssrFixStacktrace?.(
|
|
459
|
+
g.rewrite = (h) => M(h);
|
|
460
|
+
const L = await C(g, M);
|
|
461
|
+
await Z(o, p, L);
|
|
462
|
+
} catch (w) {
|
|
463
|
+
a?.ssrFixStacktrace?.(w), console.error(w.stack), p.status(500).end(s ? "Internal Server Error" : w.stack);
|
|
470
464
|
}
|
|
471
465
|
}), { app: c, vite: a };
|
|
472
466
|
}
|
|
473
|
-
async function
|
|
474
|
-
const
|
|
475
|
-
|
|
476
|
-
const { app:
|
|
477
|
-
|
|
478
|
-
console.log(`Server started at http://localhost:${
|
|
467
|
+
async function Ht(t = {}) {
|
|
468
|
+
const e = t.port || 5173, n = (await import("express")).default, s = n();
|
|
469
|
+
t.setupApp && (console.log("setupApp"), await t.setupApp(s));
|
|
470
|
+
const { app: i } = await $t({ ...t, app: s });
|
|
471
|
+
i.listen(e, () => {
|
|
472
|
+
console.log(`Server started at http://localhost:${e}`);
|
|
479
473
|
});
|
|
480
474
|
}
|
|
481
|
-
const
|
|
482
|
-
function
|
|
483
|
-
if (
|
|
475
|
+
const Rt = 1e3;
|
|
476
|
+
function jt(t) {
|
|
477
|
+
if (t === "global")
|
|
484
478
|
return "global";
|
|
485
|
-
let
|
|
486
|
-
for (let n = 0; n <
|
|
487
|
-
const
|
|
488
|
-
|
|
479
|
+
let e = 0;
|
|
480
|
+
for (let n = 0; n < t.length; n++) {
|
|
481
|
+
const s = t.charCodeAt(n);
|
|
482
|
+
e = (e << 5) - e + s, e = e & e;
|
|
489
483
|
}
|
|
490
|
-
return Math.abs(
|
|
484
|
+
return Math.abs(e).toString(36).substring(0, 8);
|
|
491
485
|
}
|
|
492
|
-
function
|
|
493
|
-
return (Array.isArray(
|
|
486
|
+
function Ct(t) {
|
|
487
|
+
return (Array.isArray(t) ? t : [...t]).slice(0, Rt).map(jt);
|
|
494
488
|
}
|
|
495
489
|
export {
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
490
|
+
gt as applyHtmlLang,
|
|
491
|
+
$t as createServer,
|
|
492
|
+
jt as hashTag,
|
|
493
|
+
Ct as optimizeCacheTags,
|
|
494
|
+
Ht as startServer
|
|
501
495
|
};
|
|
502
496
|
//# sourceMappingURL=server.js.map
|