vue-ssr-lite 0.2.2 → 0.2.3
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/SsrConfigCompileRuntime.d.ts.map +1 -1
- package/dist/SsrConfigTypes.d.ts +3 -2
- package/dist/SsrConfigTypes.d.ts.map +1 -1
- package/dist/chunks/{SsrServerRuntime-D7cDSFNm.mjs → SsrServerRuntime-DqUVv06J.mjs} +225 -225
- package/dist/cli.mjs +1 -1
- package/dist/server.mjs +2 -2
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SsrConfigCompileRuntime.d.ts","sourceRoot":"","sources":["../src/SsrConfigCompileRuntime.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAEV,0BAA0B,EAI1B,aAAa,EACd,MAAM,kBAAkB,CAAA;AACzB,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAA;AACpD,OAAO,KAAK,EACV,wBAAwB,EACxB,qBAAqB,EACrB,YAAY,EACZ,iBAAiB,EACjB,wBAAwB,EACxB,gBAAgB,EACjB,MAAM,mBAAmB,CAAA;AAQ1B,OAAO,EAAE,eAAe,EAAE,CAAA;AAU1B,MAAM,WAAW,sBAAsB;IACrC,EAAE,EAAE,MAAM,CAAA;IACV,IAAI,EAAE,YAAY,CAAA;IAClB,QAAQ,EAAE,MAAM,CAAA;IAChB,KAAK,EAAE,MAAM,EAAE,CAAA;IACf,KAAK,CAAC,EAAE,MAAM,EAAE,CAAA;IAChB,WAAW,CAAC,EAAE,wBAAwB,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,CAAA;IACrD,aAAa,CAAC,EAAE,MAAM,CAAA;IACtB,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB,aAAa,CAAC,EAAE,wBAAwB,CAAC,GAAG,CAAC,CAAA;IAC7C,SAAS,EAAE,qBAAqB,CAAC,GAAG,CAAC,EAAE,CAAA;IACvC,eAAe,EAA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OAAO,CAAC,MAAM,CAchB,CAAA;AAED,eAAO,MAAM,gBAAgB,GAC3B,QAAQ,OAAO,EACf,UAAS;IAAE,WAAW,CAAC,EAAE,OAAO,CAAA;CAAO,KACtC,OAAO,CAAC,iBAAiB,CA8H3B,CAAA"}
|
package/dist/SsrConfigTypes.d.ts
CHANGED
|
@@ -41,8 +41,9 @@ export type SsrApplicationLoader = SsrApplicationDefinition<any, any, any> | (()
|
|
|
41
41
|
*/
|
|
42
42
|
export interface SsrApplicationConfig {
|
|
43
43
|
/**
|
|
44
|
-
* SPA
|
|
45
|
-
*
|
|
44
|
+
* SPA HTML shell. Use `true` (recommended) or a client-only loader reference.
|
|
45
|
+
* The Node server never executes SPA loaders — mount with
|
|
46
|
+
* `mountSpaApplication()` from a browser entry instead.
|
|
46
47
|
*/
|
|
47
48
|
spa?: true | SsrApplicationLoader;
|
|
48
49
|
/** Server-rendered Vue application. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SsrConfigTypes.d.ts","sourceRoot":"","sources":["../src/SsrConfigTypes.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,mBAAmB,CAAA;AACjE,OAAO,KAAK,EACV,qBAAqB,EACrB,SAAS,EACT,iBAAiB,EACjB,wBAAwB,EACzB,MAAM,mBAAmB,CAAA;AAE1B,gEAAgE;AAChE,MAAM,MAAM,aAAa,GAAG,MAAM,GAAG,YAAY,GAAG,qBAAqB,CAAA;AAEzE,MAAM,WAAW,0BAA0B;IACzC,2EAA2E;IAC3E,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB;;;OAGG;IACH,qBAAqB,CAAC,EAAE,MAAM,CAAA;CAC/B;AAED,MAAM,WAAW,0BAA0B;IACzC,mDAAmD;IACnD,WAAW,EAAE,MAAM,CAAA;IACnB,+BAA+B;IAC/B,UAAU,EAAE,MAAM,CAAA;IAClB,yCAAyC;IACzC,IAAI,CAAC,EAAE,aAAa,CAAA;IACpB,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AA+B;IAC/B,KAAK,EAAE,MAAM,CAAA;IACb,QAAQ,EAAE,MAAM,CAAA;IAChB,4DAA4D;IAC5D,UAAU,EAAE,MAAM,CAAA;IAClB,8EAA8E;IAC9E,SAAS,EAAE,MAAM,GAAG,IAAI,CAAA;IACxB,cAAc,EAAE,OAAO,CAAA;IACvB,WAAW,EAAE,OAAO,CAAA;IACpB,2CAA2C;IAC3C,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;CAC/B"}
|
|
@@ -20,8 +20,8 @@ const V = (t) => {
|
|
|
20
20
|
const o = e.includes(":") && e.split(":").length > 2 && !e.startsWith("[") ? `[${e}]` : e, r = new URL(`http://${o}`);
|
|
21
21
|
if (r.username || r.password || r.pathname !== "/" || r.search || r.hash)
|
|
22
22
|
return "";
|
|
23
|
-
const
|
|
24
|
-
return
|
|
23
|
+
const s = r.hostname.toLowerCase().replace(/\.$/, "");
|
|
24
|
+
return s ? `${s.includes(":") && !s.startsWith("[") ? `[${s}]` : s}${r.port ? `:${r.port}` : ""}` : "";
|
|
25
25
|
} catch {
|
|
26
26
|
return "";
|
|
27
27
|
}
|
|
@@ -55,22 +55,22 @@ const V = (t) => {
|
|
|
55
55
|
specificity: r.slice(2).length,
|
|
56
56
|
pattern: r
|
|
57
57
|
};
|
|
58
|
-
const
|
|
58
|
+
const s = z(r);
|
|
59
59
|
return {
|
|
60
60
|
category: "exact",
|
|
61
|
-
specificity: Et +
|
|
61
|
+
specificity: Et + s.length,
|
|
62
62
|
pattern: r
|
|
63
63
|
};
|
|
64
64
|
}, At = (t) => {
|
|
65
65
|
const e = /* @__PURE__ */ new Map(), o = [];
|
|
66
66
|
for (const r of t) {
|
|
67
|
-
const
|
|
68
|
-
if (!
|
|
67
|
+
const s = r.hosts ?? [];
|
|
68
|
+
if (!s.length)
|
|
69
69
|
throw new C(
|
|
70
70
|
`SSR application "${r.id}" requires at least one host pattern.`
|
|
71
71
|
);
|
|
72
72
|
const c = /* @__PURE__ */ new Set();
|
|
73
|
-
for (const l of
|
|
73
|
+
for (const l of s) {
|
|
74
74
|
const h = String(l ?? "").trim();
|
|
75
75
|
if (!h)
|
|
76
76
|
throw new C(
|
|
@@ -80,26 +80,26 @@ const V = (t) => {
|
|
|
80
80
|
throw new C(
|
|
81
81
|
`SSR application "${r.id}" host pattern "${l}" must not include a protocol, path, or query.`
|
|
82
82
|
);
|
|
83
|
-
const
|
|
84
|
-
if (!
|
|
83
|
+
const d = Q(h);
|
|
84
|
+
if (!d)
|
|
85
85
|
throw new C(
|
|
86
86
|
`SSR application "${r.id}" has an invalid host pattern "${l}". Use an exact hostname, *.example.com, or *.`
|
|
87
87
|
);
|
|
88
|
-
if (
|
|
88
|
+
if (d !== "*" && (d.startsWith("[") ? /\]:\d+$/.test(d) : /:\d+$/.test(d)))
|
|
89
89
|
throw new C(
|
|
90
90
|
`SSR application "${r.id}" host pattern "${l}" must not include a port.`
|
|
91
91
|
);
|
|
92
|
-
if (c.has(
|
|
93
|
-
if (c.add(
|
|
92
|
+
if (c.has(d)) continue;
|
|
93
|
+
if (c.add(d), d === "*") {
|
|
94
94
|
o.push(r.id);
|
|
95
95
|
continue;
|
|
96
96
|
}
|
|
97
|
-
const m = e.get(
|
|
97
|
+
const m = e.get(d);
|
|
98
98
|
if (m && m !== r.id)
|
|
99
99
|
throw new C(
|
|
100
|
-
`Host pattern "${
|
|
100
|
+
`Host pattern "${d}" is assigned to both "${m}" and "${r.id}".`
|
|
101
101
|
);
|
|
102
|
-
e.set(
|
|
102
|
+
e.set(d, r.id);
|
|
103
103
|
}
|
|
104
104
|
}
|
|
105
105
|
if (o.length > 1)
|
|
@@ -109,25 +109,25 @@ const V = (t) => {
|
|
|
109
109
|
}, It = (t, e, o) => {
|
|
110
110
|
const r = z(e);
|
|
111
111
|
if (!r) return null;
|
|
112
|
-
let
|
|
112
|
+
let s = null;
|
|
113
113
|
for (const l of t)
|
|
114
114
|
for (const h of l.hosts ?? []) {
|
|
115
|
-
const
|
|
116
|
-
if (!
|
|
115
|
+
const d = Pt(e, h);
|
|
116
|
+
if (!d) continue;
|
|
117
117
|
const a = {
|
|
118
118
|
entry: l,
|
|
119
|
-
matchedPattern:
|
|
119
|
+
matchedPattern: d.pattern,
|
|
120
120
|
normalizedHostname: r,
|
|
121
|
-
category:
|
|
122
|
-
specificity:
|
|
121
|
+
category: d.category,
|
|
122
|
+
specificity: d.specificity
|
|
123
123
|
};
|
|
124
|
-
if (!
|
|
125
|
-
|
|
124
|
+
if (!s || a.specificity > s.specificity) {
|
|
125
|
+
s = a;
|
|
126
126
|
continue;
|
|
127
127
|
}
|
|
128
|
-
a.specificity <
|
|
128
|
+
a.specificity < s.specificity || a.entry.id < s.entry.id && (s = a);
|
|
129
129
|
}
|
|
130
|
-
if (
|
|
130
|
+
if (s) return s;
|
|
131
131
|
if (!o) return null;
|
|
132
132
|
const c = t.find(
|
|
133
133
|
(l) => l.id === o
|
|
@@ -144,13 +144,13 @@ const V = (t) => {
|
|
|
144
144
|
const r = Z(t).toLowerCase();
|
|
145
145
|
return r === "http" || r === "https" ? r : e;
|
|
146
146
|
}, et = /^[!#$%&'*+.^_`|~0-9A-Za-z-]+$/, Dt = (t, e = [], o = []) => {
|
|
147
|
-
const r = new Set(e.filter((l) => et.test(l))),
|
|
147
|
+
const r = new Set(e.filter((l) => et.test(l))), s = new Set(o.filter((l) => et.test(l)));
|
|
148
148
|
if (!t || r.size === 0) return;
|
|
149
149
|
const c = String(t).split(";").map((l) => l.trim()).filter(Boolean).filter((l) => {
|
|
150
150
|
const h = l.indexOf("=");
|
|
151
151
|
if (h <= 0) return !1;
|
|
152
|
-
const
|
|
153
|
-
return r.has(
|
|
152
|
+
const d = l.slice(0, h).trim();
|
|
153
|
+
return r.has(d) && !s.has(d);
|
|
154
154
|
});
|
|
155
155
|
return c.length ? c.join("; ") : void 0;
|
|
156
156
|
}, Tt = ["localhost", "127.0.0.1", "0.0.0.0", "::1"], rt = [
|
|
@@ -171,22 +171,22 @@ const V = (t) => {
|
|
|
171
171
|
const o = t.mode ?? "root-and-subdomains", r = W(
|
|
172
172
|
e ? t.development : t.production,
|
|
173
173
|
e ? "domain.development" : "domain.production"
|
|
174
|
-
),
|
|
175
|
-
if ((o === "root" || o === "root-and-subdomains") && T(
|
|
174
|
+
), s = [];
|
|
175
|
+
if ((o === "root" || o === "root-and-subdomains") && T(s, r), (o === "subdomains" || o === "root-and-subdomains") && T(s, `*.${r}`), e) {
|
|
176
176
|
const c = W(
|
|
177
177
|
t.production,
|
|
178
178
|
"domain.production"
|
|
179
179
|
);
|
|
180
|
-
if (c !== r && ((o === "root" || o === "root-and-subdomains") && T(
|
|
181
|
-
for (const l of Tt) T(
|
|
180
|
+
if (c !== r && ((o === "root" || o === "root-and-subdomains") && T(s, c), (o === "subdomains" || o === "root-and-subdomains") && T(s, `*.${c}`)), t.localAliases)
|
|
181
|
+
for (const l of Tt) T(s, l);
|
|
182
182
|
}
|
|
183
183
|
for (const c of t.additionalHosts ?? [])
|
|
184
|
-
T(
|
|
185
|
-
if (t.customDomains && T(
|
|
184
|
+
T(s, W(c, "domain.additionalHosts"));
|
|
185
|
+
if (t.customDomains && T(s, "*"), !s.length)
|
|
186
186
|
throw new C(
|
|
187
187
|
"Application domain configuration produced an empty host list."
|
|
188
188
|
);
|
|
189
|
-
return
|
|
189
|
+
return s;
|
|
190
190
|
}, ot = (t) => t == null ? [] : Array.isArray(t) ? t.map((e) => String(e).trim()).filter(Boolean) : String(t).split(",").map((e) => e.trim()).filter(Boolean), jt = async (t, e, o) => {
|
|
191
191
|
if (!t) return;
|
|
192
192
|
const r = typeof t == "function" ? await t() : t;
|
|
@@ -195,7 +195,7 @@ const V = (t) => {
|
|
|
195
195
|
`Application "${e}" ${o} loader must return a valid SsrApplicationDefinition.`
|
|
196
196
|
);
|
|
197
197
|
return r;
|
|
198
|
-
},
|
|
198
|
+
}, ne = async (t, e) => {
|
|
199
199
|
if (e) return j(t, e);
|
|
200
200
|
for (const o of rt) {
|
|
201
201
|
const r = j(t, o);
|
|
@@ -208,58 +208,58 @@ const V = (t) => {
|
|
|
208
208
|
`vue-ssr-lite could not find an SSR config in ${t}. Expected one of: ${rt.join(", ")}`
|
|
209
209
|
);
|
|
210
210
|
}, zt = async (t, e = {}) => {
|
|
211
|
-
const r = t?.default ?? t,
|
|
212
|
-
if (!
|
|
211
|
+
const r = t?.default ?? t, s = typeof r == "function" ? await r() : r;
|
|
212
|
+
if (!s?.name || !s.applications || typeof s.applications != "object")
|
|
213
213
|
throw new Error(
|
|
214
214
|
"The SSR config module must export defineSsrConfig({ name, applications })."
|
|
215
215
|
);
|
|
216
|
-
const c = e.development ?? (typeof process < "u" ? process.env.NODE_ENV !== "production" : !0), l = Object.keys(
|
|
216
|
+
const c = e.development ?? (typeof process < "u" ? process.env.NODE_ENV !== "production" : !0), l = Object.keys(s.applications);
|
|
217
217
|
if (!l.length)
|
|
218
218
|
throw new Error("SSR config requires at least one application.");
|
|
219
219
|
const h = [];
|
|
220
|
-
for (const
|
|
221
|
-
const a =
|
|
220
|
+
for (const d of l) {
|
|
221
|
+
const a = s.applications[d];
|
|
222
222
|
if (!a?.template || !a.domain)
|
|
223
223
|
throw new C(
|
|
224
|
-
`Application "${
|
|
224
|
+
`Application "${d}" requires template and domain configuration.`
|
|
225
225
|
);
|
|
226
226
|
const m = a.spa !== void 0, v = a.ssr !== void 0;
|
|
227
227
|
if (!m && !v)
|
|
228
228
|
throw new C(
|
|
229
|
-
`Application "${
|
|
229
|
+
`Application "${d}" requires spa or ssr.`
|
|
230
230
|
);
|
|
231
231
|
if (m && v)
|
|
232
232
|
throw new C(
|
|
233
|
-
`Application "${
|
|
233
|
+
`Application "${d}" cannot declare both spa and ssr.`
|
|
234
234
|
);
|
|
235
|
-
const
|
|
235
|
+
const n = v ? "ssr" : "spa", i = v ? await jt(a.ssr, d, n) : void 0, w = {
|
|
236
236
|
...a.publicConfig || {}
|
|
237
237
|
};
|
|
238
|
-
a.graphql && (
|
|
238
|
+
a.graphql && (w.graphql = {
|
|
239
239
|
endpoint: a.graphql.endpoint,
|
|
240
240
|
timeout: a.graphql.timeout ?? 8e3
|
|
241
241
|
}), h.push({
|
|
242
|
-
id:
|
|
243
|
-
kind:
|
|
242
|
+
id: d,
|
|
243
|
+
kind: n,
|
|
244
244
|
template: a.template,
|
|
245
245
|
hosts: kt(a.domain, c),
|
|
246
246
|
roles: a.roles ? [...a.roles] : void 0,
|
|
247
|
-
application:
|
|
247
|
+
application: i,
|
|
248
248
|
mountSelector: a.mountSelector,
|
|
249
249
|
cacheControl: a.cacheControl,
|
|
250
250
|
responseCache: a.responseCache,
|
|
251
251
|
endpoints: a.endpoints ? [...a.endpoints] : [],
|
|
252
252
|
cookieAllowlist: ot(a.cookies?.allow),
|
|
253
253
|
cookieDenylist: ot(a.cookies?.deny),
|
|
254
|
-
publicConfig:
|
|
254
|
+
publicConfig: w,
|
|
255
255
|
domain: {
|
|
256
256
|
development: W(
|
|
257
257
|
a.domain.development,
|
|
258
|
-
`${
|
|
258
|
+
`${d}.domain.development`
|
|
259
259
|
),
|
|
260
260
|
production: W(
|
|
261
261
|
a.domain.production,
|
|
262
|
-
`${
|
|
262
|
+
`${d}.domain.production`
|
|
263
263
|
),
|
|
264
264
|
mode: a.domain.mode ?? "root-and-subdomains",
|
|
265
265
|
localAliases: !!a.domain.localAliases,
|
|
@@ -268,46 +268,46 @@ const V = (t) => {
|
|
|
268
268
|
}
|
|
269
269
|
});
|
|
270
270
|
}
|
|
271
|
-
if (At(h),
|
|
271
|
+
if (At(h), s.defaultApplicationId && !h.some((d) => d.id === s.defaultApplicationId))
|
|
272
272
|
throw new Error(
|
|
273
|
-
`defaultApplicationId "${
|
|
273
|
+
`defaultApplicationId "${s.defaultApplicationId}" does not match an application.`
|
|
274
274
|
);
|
|
275
275
|
return {
|
|
276
|
-
name:
|
|
276
|
+
name: s.name,
|
|
277
277
|
applications: h,
|
|
278
|
-
defaultApplicationId:
|
|
278
|
+
defaultApplicationId: s.defaultApplicationId,
|
|
279
279
|
development: c,
|
|
280
|
-
readiness:
|
|
280
|
+
readiness: s.readiness,
|
|
281
281
|
server: {
|
|
282
|
-
root:
|
|
283
|
-
host:
|
|
284
|
-
port:
|
|
285
|
-
role:
|
|
286
|
-
trustProxy:
|
|
287
|
-
clientOutDir:
|
|
288
|
-
requestTimeoutMs:
|
|
289
|
-
shutdownTimeoutMs:
|
|
290
|
-
healthPath:
|
|
291
|
-
readinessPath:
|
|
292
|
-
maxResolutionPasses:
|
|
293
|
-
resolutionDeadlineMs:
|
|
294
|
-
diagnostics:
|
|
295
|
-
logger:
|
|
282
|
+
root: s.server?.root,
|
|
283
|
+
host: s.server?.host,
|
|
284
|
+
port: s.server?.port,
|
|
285
|
+
role: s.runtime,
|
|
286
|
+
trustProxy: s.server?.trustProxy,
|
|
287
|
+
clientOutDir: s.server?.clientOutDir,
|
|
288
|
+
requestTimeoutMs: s.server?.requestTimeoutMs,
|
|
289
|
+
shutdownTimeoutMs: s.server?.shutdownTimeoutMs,
|
|
290
|
+
healthPath: s.server?.healthPath,
|
|
291
|
+
readinessPath: s.server?.readinessPath,
|
|
292
|
+
maxResolutionPasses: s.server?.maxResolutionPasses,
|
|
293
|
+
resolutionDeadlineMs: s.server?.resolutionDeadlineMs,
|
|
294
|
+
diagnostics: s.server?.diagnostics,
|
|
295
|
+
logger: s.server?.logger,
|
|
296
296
|
publicConfig: {}
|
|
297
297
|
}
|
|
298
298
|
};
|
|
299
|
-
}, _ = () => globalThis.performance?.now?.() ?? Date.now(),
|
|
300
|
-
for (const
|
|
301
|
-
const c = { requestId: e, applicationId: o, code:
|
|
302
|
-
t?.warn ? t.warn(`ssr.diagnostic.${
|
|
299
|
+
}, _ = () => globalThis.performance?.now?.() ?? Date.now(), nt = (t) => new TextEncoder().encode(t).byteLength, st = (t, e, o, r) => {
|
|
300
|
+
for (const s of r) {
|
|
301
|
+
const c = { requestId: e, applicationId: o, code: s.code };
|
|
302
|
+
t?.warn ? t.warn(`ssr.diagnostic.${s.code}`, c) : console.warn(`[vue-ssr-lite] ${s.message}`, c);
|
|
303
303
|
}
|
|
304
304
|
}, Nt = async (t, e, o = {}) => {
|
|
305
|
-
const r = _(),
|
|
306
|
-
let
|
|
305
|
+
const r = _(), s = Math.max(1, Math.floor(o.maxResolutionPasses ?? 4)), c = o.resolutionDeadlineMs ?? 0, l = o.diagnostics ?? process.env.NODE_ENV !== "production", h = vt(!0);
|
|
306
|
+
let d = r, a = r, m = r, v, n, i = "", w = "", u = 0, x;
|
|
307
307
|
const N = async () => {
|
|
308
|
-
if (!
|
|
309
|
-
const S =
|
|
310
|
-
|
|
308
|
+
if (!n) return;
|
|
309
|
+
const S = n;
|
|
310
|
+
n = void 0;
|
|
311
311
|
try {
|
|
312
312
|
await t.cleanup?.(S.context);
|
|
313
313
|
} catch (p) {
|
|
@@ -321,40 +321,40 @@ const V = (t) => {
|
|
|
321
321
|
};
|
|
322
322
|
try {
|
|
323
323
|
let S = !1;
|
|
324
|
-
for (let b = 0; b <
|
|
325
|
-
if (
|
|
324
|
+
for (let b = 0; b < s && !S; b += 1) {
|
|
325
|
+
if (u = b + 1, h.beginPass(b), n = await yt(t, {
|
|
326
326
|
server: !0,
|
|
327
327
|
request: e,
|
|
328
328
|
resumeState: b === 0 ? void 0 : v,
|
|
329
329
|
resolution: h
|
|
330
|
-
}), b === 0 && (
|
|
330
|
+
}), b === 0 && (d = _()), n.router) {
|
|
331
331
|
const O = new URL(e.url);
|
|
332
|
-
await
|
|
332
|
+
await n.router.push(`${O.pathname}${O.search}${O.hash}`), await n.router.isReady(), n.router.currentRoute.value.matched.length === 0 && (n.context.response.statusCode = 404);
|
|
333
333
|
}
|
|
334
334
|
b === 0 && (a = _());
|
|
335
335
|
const H = {};
|
|
336
|
-
i = await bt(
|
|
337
|
-
const A = h.pendingWork(), g = h.additionalPassRequested(), U = b ===
|
|
336
|
+
i = await bt(n.app, H), w = H.teleports?.body ?? "", m = _();
|
|
337
|
+
const A = h.pendingWork(), g = h.additionalPassRequested(), U = b === s - 1;
|
|
338
338
|
if (A.length === 0 && !g || U) {
|
|
339
|
-
S = !0, U && (A.length > 0 || g) &&
|
|
339
|
+
S = !0, U && (A.length > 0 || g) && st(o.logger, e.requestId, t.id, [
|
|
340
340
|
{
|
|
341
341
|
code: "resolution-pass-limit",
|
|
342
|
-
message: `Resolution did not settle within ${
|
|
342
|
+
message: `Resolution did not settle within ${s} render passes; serializing the last render.`
|
|
343
343
|
}
|
|
344
344
|
]);
|
|
345
345
|
break;
|
|
346
346
|
}
|
|
347
|
-
await h.drain(c, e.signal), v =
|
|
347
|
+
await h.drain(c, e.signal), v = n.hydration.collect(), await N();
|
|
348
348
|
}
|
|
349
|
-
if (!
|
|
350
|
-
const p = await t.resolveHead?.(
|
|
351
|
-
l &&
|
|
349
|
+
if (!n) throw new Error("SSR render produced no application instance.");
|
|
350
|
+
const p = await t.resolveHead?.(n.context) ?? n.context.head.value;
|
|
351
|
+
l && st(
|
|
352
352
|
o.logger,
|
|
353
353
|
e.requestId,
|
|
354
354
|
t.id,
|
|
355
355
|
xt({
|
|
356
356
|
html: i,
|
|
357
|
-
route:
|
|
357
|
+
route: n.router?.currentRoute.value ?? null,
|
|
358
358
|
requestUrl: e.url,
|
|
359
359
|
applicationId: t.id
|
|
360
360
|
})
|
|
@@ -364,39 +364,39 @@ const V = (t) => {
|
|
|
364
364
|
applicationId: t.id,
|
|
365
365
|
publicConfig: e.publicConfig,
|
|
366
366
|
domain: e.domain,
|
|
367
|
-
application:
|
|
368
|
-
plugins:
|
|
369
|
-
}, P =
|
|
367
|
+
application: n.context.state,
|
|
368
|
+
plugins: n.hydration.collect()
|
|
369
|
+
}, P = nt(ut(f)), D = _();
|
|
370
370
|
return {
|
|
371
371
|
html: i,
|
|
372
|
-
teleports:
|
|
372
|
+
teleports: w,
|
|
373
373
|
head: p,
|
|
374
|
-
response:
|
|
374
|
+
response: n.context.response,
|
|
375
375
|
hydrationState: f,
|
|
376
376
|
metrics: {
|
|
377
377
|
requestId: e.requestId,
|
|
378
378
|
applicationId: t.id,
|
|
379
|
-
contextDurationMs:
|
|
380
|
-
routeDurationMs: a -
|
|
379
|
+
contextDurationMs: d - r,
|
|
380
|
+
routeDurationMs: a - d,
|
|
381
381
|
renderDurationMs: m - a,
|
|
382
382
|
totalDurationMs: D - r,
|
|
383
|
-
htmlBytes:
|
|
383
|
+
htmlBytes: nt(i),
|
|
384
384
|
stateBytes: P,
|
|
385
|
-
renderPasses:
|
|
385
|
+
renderPasses: u
|
|
386
386
|
}
|
|
387
387
|
};
|
|
388
388
|
} catch (S) {
|
|
389
389
|
throw x = S, S;
|
|
390
390
|
} finally {
|
|
391
391
|
let S;
|
|
392
|
-
if (
|
|
392
|
+
if (n) {
|
|
393
393
|
try {
|
|
394
|
-
await t.cleanup?.(
|
|
394
|
+
await t.cleanup?.(n.context);
|
|
395
395
|
} catch (p) {
|
|
396
396
|
S = p, console.error("[vue-ssr-lite] application cleanup failed", p);
|
|
397
397
|
}
|
|
398
398
|
try {
|
|
399
|
-
|
|
399
|
+
n.hydration.dispose();
|
|
400
400
|
} catch (p) {
|
|
401
401
|
console.error("[vue-ssr-lite] hydration cleanup failed", p), S || (S = p);
|
|
402
402
|
}
|
|
@@ -424,12 +424,12 @@ const V = (t) => {
|
|
|
424
424
|
try {
|
|
425
425
|
const r = decodeURIComponent(e).replace(/^\/+/, "");
|
|
426
426
|
if (!r || o.includes(r)) return null;
|
|
427
|
-
const
|
|
428
|
-
return !
|
|
427
|
+
const s = j(t, r), c = t.endsWith(tt) ? t : `${t}${tt}`;
|
|
428
|
+
return !s.startsWith(c) || !(await Y(s)).isFile() ? null : {
|
|
429
429
|
statusCode: 200,
|
|
430
|
-
body: await lt(
|
|
430
|
+
body: await lt(s),
|
|
431
431
|
headers: {
|
|
432
|
-
"content-type": Ot[dt(
|
|
432
|
+
"content-type": Ot[dt(s)] || "application/octet-stream",
|
|
433
433
|
"cache-control": e.startsWith("/assets/") ? "public, max-age=31536000, immutable" : "public, max-age=3600"
|
|
434
434
|
}
|
|
435
435
|
};
|
|
@@ -440,17 +440,17 @@ const V = (t) => {
|
|
|
440
440
|
statusCode: t.statusCode,
|
|
441
441
|
body: t.body instanceof Uint8Array ? t.body.slice() : t.body,
|
|
442
442
|
headers: t.headers ? { ...t.headers } : void 0
|
|
443
|
-
}),
|
|
444
|
-
const e = Number(t.maxEntries ?? 500), o = Number(t.maxBytes ?? 32 * 1024 * 1024), r = Number.isFinite(e) ? Math.max(1, Math.floor(e)) : 500,
|
|
443
|
+
}), se = (t = {}) => {
|
|
444
|
+
const e = Number(t.maxEntries ?? 500), o = Number(t.maxBytes ?? 32 * 1024 * 1024), r = Number.isFinite(e) ? Math.max(1, Math.floor(e)) : 500, s = Number.isFinite(o) ? Math.max(1, Math.floor(o)) : 32 * 1024 * 1024, c = /* @__PURE__ */ new Map();
|
|
445
445
|
let l = 0;
|
|
446
446
|
const h = (a) => {
|
|
447
447
|
const m = c.get(a);
|
|
448
448
|
return m ? (c.delete(a), l -= m.size, !0) : !1;
|
|
449
|
-
},
|
|
449
|
+
}, d = () => {
|
|
450
450
|
const a = Date.now();
|
|
451
451
|
for (const [m, v] of c)
|
|
452
452
|
v.expiresAt <= a && h(m);
|
|
453
|
-
for (; c.size > r || l >
|
|
453
|
+
for (; c.size > r || l > s; ) {
|
|
454
454
|
const m = c.keys().next().value;
|
|
455
455
|
if (!m) break;
|
|
456
456
|
h(m);
|
|
@@ -462,23 +462,23 @@ const V = (t) => {
|
|
|
462
462
|
return m ? m.expiresAt <= Date.now() ? (h(a), null) : (c.delete(a), c.set(a, m), at(m.response)) : null;
|
|
463
463
|
},
|
|
464
464
|
set(a, m, v) {
|
|
465
|
-
const
|
|
466
|
-
if (!Number.isFinite(
|
|
465
|
+
const n = Number(v.ttlMs);
|
|
466
|
+
if (!Number.isFinite(n) || n <= 0) return;
|
|
467
467
|
h(a);
|
|
468
|
-
const i = at(m),
|
|
469
|
-
|
|
468
|
+
const i = at(m), w = Ft(i.body);
|
|
469
|
+
w > s || (c.set(a, {
|
|
470
470
|
response: i,
|
|
471
|
-
expiresAt: Date.now() +
|
|
472
|
-
size:
|
|
471
|
+
expiresAt: Date.now() + n,
|
|
472
|
+
size: w,
|
|
473
473
|
tags: new Set(v.tags ?? [])
|
|
474
|
-
}), l +=
|
|
474
|
+
}), l += w, d());
|
|
475
475
|
},
|
|
476
476
|
invalidate(a = {}) {
|
|
477
477
|
const m = new Set(a.keys ?? []), v = new Set(a.tags ?? []);
|
|
478
|
-
let
|
|
479
|
-
for (const [i,
|
|
480
|
-
(!m.size && !v.size || m.has(i) || [...v].some((x) =>
|
|
481
|
-
return
|
|
478
|
+
let n = 0;
|
|
479
|
+
for (const [i, w] of c)
|
|
480
|
+
(!m.size && !v.size || m.has(i) || [...v].some((x) => w.tags.has(x))) && h(i) && (n += 1);
|
|
481
|
+
return n;
|
|
482
482
|
}
|
|
483
483
|
};
|
|
484
484
|
}, Ut = async (t, e, o) => {
|
|
@@ -494,10 +494,10 @@ const V = (t) => {
|
|
|
494
494
|
r
|
|
495
495
|
]);
|
|
496
496
|
}, Bt = (t, e, o) => {
|
|
497
|
-
const r = Object.entries(t.headers ?? {}),
|
|
497
|
+
const r = Object.entries(t.headers ?? {}), s = String(
|
|
498
498
|
r.find(([l]) => l.toLowerCase() === "cache-control")?.[1] || ""
|
|
499
499
|
).toLowerCase();
|
|
500
|
-
return t.statusCode === 200 && typeof t.body == "string" && !r.some(([l]) => l.toLowerCase() === "set-cookie") && !
|
|
500
|
+
return t.statusCode === 200 && typeof t.body == "string" && !r.some(([l]) => l.toLowerCase() === "set-cookie") && !s.includes("private") && !s.includes("no-store") && (o.shouldCache?.(t, e) ?? !0);
|
|
501
501
|
};
|
|
502
502
|
class pt extends Error {
|
|
503
503
|
constructor() {
|
|
@@ -565,96 +565,96 @@ ${c}`;
|
|
|
565
565
|
}), ct = async (t, e, o) => {
|
|
566
566
|
if (!Number.isFinite(e) || e <= 0) return t;
|
|
567
567
|
let r;
|
|
568
|
-
const
|
|
568
|
+
const s = new Promise((c, l) => {
|
|
569
569
|
r = setTimeout(() => {
|
|
570
570
|
o.abort(), l(new pt());
|
|
571
571
|
}, e);
|
|
572
572
|
});
|
|
573
573
|
try {
|
|
574
|
-
return await Promise.race([t,
|
|
574
|
+
return await Promise.race([t, s]);
|
|
575
575
|
} finally {
|
|
576
576
|
r && clearTimeout(r);
|
|
577
577
|
}
|
|
578
|
-
}, Kt = (t) => t.headers, Xt = (t, e, o) => new Promise((r,
|
|
578
|
+
}, Kt = (t) => t.headers, Xt = (t, e, o) => new Promise((r, s) => {
|
|
579
579
|
t.middlewares(e, o, (c) => {
|
|
580
|
-
c ?
|
|
580
|
+
c ? s(c) : r();
|
|
581
581
|
});
|
|
582
582
|
}), ae = async (t) => {
|
|
583
583
|
let e = !1;
|
|
584
|
-
const o = await it(await t.loadRuntime()), r = o.server,
|
|
584
|
+
const o = await it(await t.loadRuntime()), r = o.server, s = r.host || "0.0.0.0", c = _t(r.port), l = j(
|
|
585
585
|
r.root || t.root,
|
|
586
586
|
r.clientOutDir || "dist/client"
|
|
587
|
-
), h = async () => t.production ? o : it(await t.loadRuntime()),
|
|
588
|
-
const
|
|
589
|
-
j(t.production ? l :
|
|
587
|
+
), h = async () => t.production ? o : it(await t.loadRuntime()), d = async (n, i, w) => {
|
|
588
|
+
const u = n.server.root || t.root, x = await lt(
|
|
589
|
+
j(t.production ? l : u, i),
|
|
590
590
|
"utf8"
|
|
591
591
|
);
|
|
592
592
|
if (t.production || !t.vite) return x;
|
|
593
593
|
const N = `/${i.replaceAll("\\", "/").replace(/^\/+/, "")}`;
|
|
594
|
-
return t.vite.transformIndexHtml(N, x,
|
|
595
|
-
}, a = async (
|
|
596
|
-
const i =
|
|
597
|
-
(
|
|
594
|
+
return t.vite.transformIndexHtml(N, x, w);
|
|
595
|
+
}, a = async (n) => {
|
|
596
|
+
const i = n.server.root || t.root, w = n.applications.filter(
|
|
597
|
+
(u) => !u.roles?.length || !n.server.role || u.roles.includes(n.server.role)
|
|
598
598
|
);
|
|
599
599
|
await Promise.all(
|
|
600
|
-
|
|
600
|
+
w.map(async (u) => {
|
|
601
601
|
if (!(await Y(
|
|
602
602
|
j(
|
|
603
603
|
t.production ? l : i,
|
|
604
|
-
|
|
604
|
+
u.template
|
|
605
605
|
)
|
|
606
606
|
)).isFile())
|
|
607
|
-
throw new Error(`SSR client entry is missing: ${
|
|
607
|
+
throw new Error(`SSR client entry is missing: ${u.template}`);
|
|
608
608
|
})
|
|
609
|
-
), await Promise.all((
|
|
609
|
+
), await Promise.all((n.readiness ?? []).map((u) => u.run()));
|
|
610
610
|
}, m = o.applications.filter(
|
|
611
|
-
(
|
|
611
|
+
(n) => !n.roles?.length || !o.server.role || n.roles.includes(o.server.role)
|
|
612
612
|
);
|
|
613
613
|
await Promise.all(
|
|
614
|
-
m.map(async (
|
|
614
|
+
m.map(async (n) => {
|
|
615
615
|
const i = o.server.root || t.root;
|
|
616
616
|
if (!(await Y(
|
|
617
617
|
j(
|
|
618
618
|
t.production ? l : i,
|
|
619
|
-
|
|
619
|
+
n.template
|
|
620
620
|
)
|
|
621
621
|
)).isFile())
|
|
622
|
-
throw new Error(`Missing client entry: ${
|
|
622
|
+
throw new Error(`Missing client entry: ${n.template}`);
|
|
623
623
|
})
|
|
624
624
|
);
|
|
625
|
-
const v = gt(async (
|
|
626
|
-
const
|
|
627
|
-
let
|
|
625
|
+
const v = gt(async (n, i) => {
|
|
626
|
+
const w = Date.now();
|
|
627
|
+
let u = "/", x = "unknown", N;
|
|
628
628
|
const S = new AbortController();
|
|
629
|
-
|
|
629
|
+
n.once("aborted", () => S.abort()), i.once("close", () => {
|
|
630
630
|
i.writableEnded || S.abort();
|
|
631
631
|
});
|
|
632
632
|
try {
|
|
633
|
-
const p = await h(), f = p.server, P = new URL(
|
|
634
|
-
|
|
633
|
+
const p = await h(), f = p.server, P = new URL(n.url || "/", "http://internal");
|
|
634
|
+
u = P.pathname;
|
|
635
635
|
const D = f.healthPath || "/healthz", b = f.readinessPath || "/readyz";
|
|
636
|
-
if (
|
|
637
|
-
return k(
|
|
636
|
+
if (u === D)
|
|
637
|
+
return k(n, i, 200, {
|
|
638
638
|
status: "ok",
|
|
639
639
|
service: p.name,
|
|
640
640
|
role: f.role || "default",
|
|
641
|
-
timestamp: new Date(
|
|
641
|
+
timestamp: new Date(w).toISOString()
|
|
642
642
|
});
|
|
643
|
-
if (
|
|
643
|
+
if (u === b) {
|
|
644
644
|
if (e)
|
|
645
|
-
return k(
|
|
645
|
+
return k(n, i, 503, {
|
|
646
646
|
status: "error",
|
|
647
647
|
service: p.name,
|
|
648
648
|
message: "Server is shutting down."
|
|
649
649
|
});
|
|
650
650
|
try {
|
|
651
|
-
return await a(p), k(
|
|
651
|
+
return await a(p), k(n, i, 200, {
|
|
652
652
|
status: "ok",
|
|
653
653
|
service: p.name,
|
|
654
654
|
role: f.role || "default"
|
|
655
655
|
});
|
|
656
656
|
} catch {
|
|
657
|
-
return k(
|
|
657
|
+
return k(n, i, 503, {
|
|
658
658
|
status: "error",
|
|
659
659
|
service: p.name,
|
|
660
660
|
message: "A required dependency is unavailable."
|
|
@@ -662,16 +662,16 @@ ${c}`;
|
|
|
662
662
|
}
|
|
663
663
|
}
|
|
664
664
|
const H = Ht(
|
|
665
|
-
|
|
666
|
-
|
|
665
|
+
n.headers["x-forwarded-host"],
|
|
666
|
+
n.headers.host,
|
|
667
667
|
f.trustProxy
|
|
668
668
|
);
|
|
669
669
|
if (!H)
|
|
670
|
-
return R(
|
|
670
|
+
return R(n, i, {
|
|
671
671
|
statusCode: 400,
|
|
672
|
-
body: F(
|
|
672
|
+
body: F(n, u) ? X("Invalid request", "The Host header is invalid.") : JSON.stringify({ status: "error", message: "Invalid Host header." }),
|
|
673
673
|
headers: {
|
|
674
|
-
"content-type": F(
|
|
674
|
+
"content-type": F(n, u) ? "text/html; charset=utf-8" : "application/json; charset=utf-8",
|
|
675
675
|
"cache-control": "no-store",
|
|
676
676
|
...L
|
|
677
677
|
}
|
|
@@ -682,7 +682,7 @@ ${c}`;
|
|
|
682
682
|
p.defaultApplicationId
|
|
683
683
|
);
|
|
684
684
|
if (!A)
|
|
685
|
-
return k(
|
|
685
|
+
return k(n, i, 421, {
|
|
686
686
|
status: "error",
|
|
687
687
|
service: p.name,
|
|
688
688
|
message: "No application serves this host."
|
|
@@ -696,44 +696,44 @@ ${c}`;
|
|
|
696
696
|
hostname: A.normalizedHostname,
|
|
697
697
|
role: f.role || "default"
|
|
698
698
|
}), g.roles?.length && f.role && !g.roles.includes(f.role)) {
|
|
699
|
-
const
|
|
700
|
-
return R(
|
|
699
|
+
const y = `Runtime role does not serve application "${g.id}".`;
|
|
700
|
+
return R(n, i, {
|
|
701
701
|
statusCode: 421,
|
|
702
|
-
body: F(
|
|
702
|
+
body: F(n, u) ? X("Misdirected request", y) : JSON.stringify({ status: "error", message: y }),
|
|
703
703
|
headers: {
|
|
704
|
-
"content-type": F(
|
|
704
|
+
"content-type": F(n, u) ? "text/html; charset=utf-8" : "application/json; charset=utf-8",
|
|
705
705
|
"cache-control": "no-store",
|
|
706
706
|
...L
|
|
707
707
|
}
|
|
708
708
|
});
|
|
709
709
|
}
|
|
710
710
|
const U = Mt(
|
|
711
|
-
|
|
712
|
-
|
|
711
|
+
n.headers["x-forwarded-proto"],
|
|
712
|
+
n.socket.encrypted ? "https" : "http",
|
|
713
713
|
f.trustProxy
|
|
714
714
|
), O = St(
|
|
715
715
|
H,
|
|
716
716
|
g,
|
|
717
717
|
p.development
|
|
718
718
|
), ft = Dt(
|
|
719
|
-
|
|
719
|
+
n.headers.cookie,
|
|
720
720
|
g.cookieAllowlist,
|
|
721
721
|
g.cookieDenylist
|
|
722
722
|
), E = {
|
|
723
|
-
requestId: String(
|
|
723
|
+
requestId: String(n.headers["x-request-id"] || "").trim() || `${w.toString(36)}-${Math.random().toString(36).slice(2, 10)}`,
|
|
724
724
|
url: new URL(
|
|
725
725
|
`${P.pathname}${P.search}`,
|
|
726
726
|
`${U}://${H}`
|
|
727
727
|
).href,
|
|
728
728
|
host: H,
|
|
729
729
|
protocol: U,
|
|
730
|
-
method:
|
|
731
|
-
headers: Kt(
|
|
730
|
+
method: n.method || "GET",
|
|
731
|
+
headers: Kt(n),
|
|
732
732
|
cookie: ft,
|
|
733
733
|
publicConfig: g.publicConfig,
|
|
734
734
|
domain: O,
|
|
735
735
|
signal: S.signal,
|
|
736
|
-
pathname:
|
|
736
|
+
pathname: u,
|
|
737
737
|
search: P.search,
|
|
738
738
|
entryId: g.id
|
|
739
739
|
};
|
|
@@ -742,26 +742,26 @@ ${c}`;
|
|
|
742
742
|
signal: S.signal,
|
|
743
743
|
logger: f.logger
|
|
744
744
|
};
|
|
745
|
-
for (const
|
|
746
|
-
if (!
|
|
745
|
+
for (const y of g.endpoints) {
|
|
746
|
+
if (!y.match(E)) continue;
|
|
747
747
|
const I = await ct(
|
|
748
|
-
Promise.resolve(
|
|
748
|
+
Promise.resolve(y.handle(E, ht)),
|
|
749
749
|
f.requestTimeoutMs ?? 15e3,
|
|
750
750
|
S
|
|
751
751
|
);
|
|
752
|
-
if (I) return R(
|
|
752
|
+
if (I) return R(n, i, I);
|
|
753
753
|
}
|
|
754
754
|
if (t.production) {
|
|
755
|
-
const
|
|
755
|
+
const y = await Lt(
|
|
756
756
|
l,
|
|
757
|
-
|
|
757
|
+
u,
|
|
758
758
|
p.applications.map(({ template: I }) => I)
|
|
759
759
|
);
|
|
760
|
-
if (
|
|
761
|
-
} else if (t.vite && (
|
|
760
|
+
if (y) return R(n, i, y);
|
|
761
|
+
} else if (t.vite && (u.startsWith("/src/") || u.startsWith("/@") || u.includes(".") || u === "/__vite_ping") && (await Xt(t.vite, n, i), i.writableEnded))
|
|
762
762
|
return;
|
|
763
|
-
if (!F(
|
|
764
|
-
return k(
|
|
763
|
+
if (!F(n, u))
|
|
764
|
+
return k(n, i, 404, {
|
|
765
765
|
status: "error",
|
|
766
766
|
service: p.name,
|
|
767
767
|
message: "Resource not found."
|
|
@@ -774,34 +774,34 @@ ${c}`;
|
|
|
774
774
|
E,
|
|
775
775
|
M
|
|
776
776
|
);
|
|
777
|
-
} catch (
|
|
777
|
+
} catch (y) {
|
|
778
778
|
f.logger?.warn?.("ssr.cache.key.failed", {
|
|
779
779
|
entryId: g.id,
|
|
780
780
|
requestId: E.requestId,
|
|
781
|
-
error:
|
|
781
|
+
error: y instanceof Error ? y.message : "Unknown cache error"
|
|
782
782
|
});
|
|
783
783
|
}
|
|
784
784
|
if (M && B)
|
|
785
785
|
try {
|
|
786
|
-
const
|
|
787
|
-
if (
|
|
788
|
-
return R(
|
|
789
|
-
...
|
|
786
|
+
const y = await M.store.get(B);
|
|
787
|
+
if (y)
|
|
788
|
+
return R(n, i, {
|
|
789
|
+
...y,
|
|
790
790
|
headers: {
|
|
791
|
-
...
|
|
791
|
+
...y.headers,
|
|
792
792
|
"server-timing": 'cache;desc="hit"'
|
|
793
793
|
}
|
|
794
794
|
});
|
|
795
|
-
} catch (
|
|
795
|
+
} catch (y) {
|
|
796
796
|
f.logger?.warn?.("ssr.cache.read.failed", {
|
|
797
797
|
entryId: g.id,
|
|
798
798
|
requestId: E.requestId,
|
|
799
|
-
error:
|
|
799
|
+
error: y instanceof Error ? y.message : "Unknown cache error"
|
|
800
800
|
});
|
|
801
801
|
}
|
|
802
|
-
let G = await
|
|
802
|
+
let G = await d(p, g.template, n.url || "/");
|
|
803
803
|
if (g.kind === "spa")
|
|
804
|
-
return R(
|
|
804
|
+
return R(n, i, {
|
|
805
805
|
statusCode: 200,
|
|
806
806
|
body: Gt(
|
|
807
807
|
G,
|
|
@@ -832,13 +832,13 @@ ${c}`;
|
|
|
832
832
|
S
|
|
833
833
|
);
|
|
834
834
|
if ($.response.redirect) {
|
|
835
|
-
const
|
|
835
|
+
const y = $.response.redirect, I = new URL(y.location, E.url);
|
|
836
836
|
if (I.protocol !== "http:" && I.protocol !== "https:")
|
|
837
837
|
throw new Error("SSR redirects must use HTTP or HTTPS.");
|
|
838
|
-
if (!
|
|
838
|
+
if (!y.allowExternal && I.origin !== new URL(E.url).origin)
|
|
839
839
|
throw new Error("Cross-origin redirect requires allowExternal: true.");
|
|
840
|
-
return R(
|
|
841
|
-
statusCode:
|
|
840
|
+
return R(n, i, {
|
|
841
|
+
statusCode: y.statusCode ?? 302,
|
|
842
842
|
headers: {
|
|
843
843
|
location: I.href,
|
|
844
844
|
"cache-control": "no-store"
|
|
@@ -875,20 +875,20 @@ ${c}`;
|
|
|
875
875
|
ttlMs: M.ttlMs,
|
|
876
876
|
tags: await M.tags?.(E)
|
|
877
877
|
});
|
|
878
|
-
} catch (
|
|
878
|
+
} catch (y) {
|
|
879
879
|
f.logger?.warn?.("ssr.cache.write.failed", {
|
|
880
880
|
entryId: g.id,
|
|
881
881
|
requestId: E.requestId,
|
|
882
|
-
error:
|
|
882
|
+
error: y instanceof Error ? y.message : "Unknown cache error"
|
|
883
883
|
});
|
|
884
884
|
}
|
|
885
|
-
return R(
|
|
885
|
+
return R(n, i, K);
|
|
886
886
|
} catch (p) {
|
|
887
887
|
t.vite?.ssrFixStacktrace(p);
|
|
888
888
|
const f = await h().catch(() => o);
|
|
889
889
|
if (f.server.logger?.error?.("ssr.request.failed", {
|
|
890
890
|
entryId: x,
|
|
891
|
-
pathname:
|
|
891
|
+
pathname: u,
|
|
892
892
|
error: p instanceof Error ? p.message : "Unknown error"
|
|
893
893
|
}), i.writableEnded) return;
|
|
894
894
|
if (i.headersSent) return i.destroy();
|
|
@@ -903,7 +903,7 @@ ${c}`;
|
|
|
903
903
|
entryId: x === "unknown" ? void 0 : x
|
|
904
904
|
});
|
|
905
905
|
if (b)
|
|
906
|
-
return R(
|
|
906
|
+
return R(n, i, {
|
|
907
907
|
...b,
|
|
908
908
|
statusCode: b.statusCode >= 400 ? b.statusCode : D,
|
|
909
909
|
headers: {
|
|
@@ -918,7 +918,7 @@ ${c}`;
|
|
|
918
918
|
error: b instanceof Error ? b.message : "Unknown error renderer failure"
|
|
919
919
|
});
|
|
920
920
|
}
|
|
921
|
-
return F(
|
|
921
|
+
return F(n, u) ? R(n, i, {
|
|
922
922
|
statusCode: D,
|
|
923
923
|
body: X(
|
|
924
924
|
P ? "Request timed out" : "Application unavailable",
|
|
@@ -929,7 +929,7 @@ ${c}`;
|
|
|
929
929
|
"cache-control": "no-store",
|
|
930
930
|
...L
|
|
931
931
|
}
|
|
932
|
-
}) : k(
|
|
932
|
+
}) : k(n, i, D, {
|
|
933
933
|
status: "error",
|
|
934
934
|
service: f.name
|
|
935
935
|
});
|
|
@@ -938,41 +938,41 @@ ${c}`;
|
|
|
938
938
|
return {
|
|
939
939
|
nodeServer: v,
|
|
940
940
|
address: () => {
|
|
941
|
-
const
|
|
941
|
+
const n = v.address();
|
|
942
942
|
return {
|
|
943
|
-
host: typeof
|
|
944
|
-
port: typeof
|
|
943
|
+
host: typeof n == "object" && n ? n.address : s,
|
|
944
|
+
port: typeof n == "object" && n ? n.port : c
|
|
945
945
|
};
|
|
946
946
|
},
|
|
947
|
-
listen: () => new Promise((
|
|
948
|
-
const
|
|
949
|
-
v.once("error",
|
|
950
|
-
v.off("error",
|
|
951
|
-
|
|
947
|
+
listen: () => new Promise((n, i) => {
|
|
948
|
+
const w = (u) => i(u);
|
|
949
|
+
v.once("error", w), v.listen(c, s, () => {
|
|
950
|
+
v.off("error", w), Vt(
|
|
951
|
+
s,
|
|
952
952
|
c,
|
|
953
953
|
r.role || "default"
|
|
954
|
-
),
|
|
954
|
+
), n();
|
|
955
955
|
});
|
|
956
956
|
}),
|
|
957
957
|
close: async () => {
|
|
958
958
|
if (e) return;
|
|
959
959
|
e = !0;
|
|
960
|
-
const
|
|
960
|
+
const n = r.shutdownTimeoutMs ?? 1e4;
|
|
961
961
|
let i;
|
|
962
962
|
try {
|
|
963
963
|
await Promise.race([
|
|
964
964
|
Promise.all([
|
|
965
|
-
new Promise((
|
|
965
|
+
new Promise((w, u) => {
|
|
966
966
|
v.close(
|
|
967
|
-
(x) => x ?
|
|
967
|
+
(x) => x ? u(x) : w()
|
|
968
968
|
);
|
|
969
969
|
}),
|
|
970
970
|
t.vite?.close()
|
|
971
971
|
]),
|
|
972
|
-
new Promise((
|
|
972
|
+
new Promise((w, u) => {
|
|
973
973
|
i = setTimeout(() => {
|
|
974
|
-
v.closeAllConnections?.(),
|
|
975
|
-
},
|
|
974
|
+
v.closeAllConnections?.(), u(new Error("SSR server graceful shutdown timed out."));
|
|
975
|
+
}, n);
|
|
976
976
|
})
|
|
977
977
|
]);
|
|
978
978
|
} finally {
|
|
@@ -984,7 +984,7 @@ ${c}`;
|
|
|
984
984
|
export {
|
|
985
985
|
C as S,
|
|
986
986
|
zt as a,
|
|
987
|
-
|
|
987
|
+
se as b,
|
|
988
988
|
ae as c,
|
|
989
989
|
Q as d,
|
|
990
990
|
Nt as e,
|
|
@@ -998,7 +998,7 @@ export {
|
|
|
998
998
|
Rt as m,
|
|
999
999
|
V as n,
|
|
1000
1000
|
z as o,
|
|
1001
|
-
|
|
1001
|
+
ne as r,
|
|
1002
1002
|
Pt as s,
|
|
1003
1003
|
At as v
|
|
1004
1004
|
};
|
package/dist/cli.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import { resolve as c, relative as f } from "node:path";
|
|
3
3
|
import { pathToFileURL as w } from "node:url";
|
|
4
|
-
import { r as S, c as b } from "./chunks/SsrServerRuntime-
|
|
4
|
+
import { r as S, c as b } from "./chunks/SsrServerRuntime-DqUVv06J.mjs";
|
|
5
5
|
import { createServer as g } from "node:net";
|
|
6
6
|
const i = 1, a = 65535, h = (r) => {
|
|
7
7
|
const e = r?.trim();
|
package/dist/server.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { n as S } from "./chunks/SsrServerRuntime-
|
|
2
|
-
import { S as v, a as C, c as T, b as _, f as $, i as A, m as F, d as M, e as P, r as D, g as I, h as K, j as L, k as N, l as U, s as X, o as j, v as k } from "./chunks/SsrServerRuntime-
|
|
1
|
+
import { n as S } from "./chunks/SsrServerRuntime-DqUVv06J.mjs";
|
|
2
|
+
import { S as v, a as C, c as T, b as _, f as $, i as A, m as F, d as M, e as P, r as D, g as I, h as K, j as L, k as N, l as U, s as X, o as j, v as k } from "./chunks/SsrServerRuntime-DqUVv06J.mjs";
|
|
3
3
|
import { S as B, a as O, b as Y, c as G, i as J, p as Q, r as V } from "./chunks/SsrHtmlRuntime-cTFsMSAZ.mjs";
|
|
4
4
|
import { S as Z, b as q, i as rr, r as tr, u as er } from "./chunks/SsrApplicationRuntime-D4arUtsy.mjs";
|
|
5
5
|
import { d as or } from "./chunks/SsrConfigRuntime-D0DkOrVQ.mjs";
|