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