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