vue-ssr-lite 0.1.1 → 0.1.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.
@@ -1,11 +1,11 @@
1
1
  import { createServer as ae } from "node:http";
2
- import { stat as B, readFile as te } from "node:fs/promises";
2
+ import { stat as _, readFile as te } from "node:fs/promises";
3
3
  import { resolve as j, sep as X, extname as re } from "node:path";
4
4
  import { createApollo as ie } from "vue-apollo-client";
5
5
  import { renderToString as ce } from "@vue/server-renderer";
6
6
  import { c as le } from "./SsrApplicationRuntime-B-6cXN5-.mjs";
7
7
  import { a as de } from "./SsrSerialization-k-3aCFYt.mjs";
8
- import { r as W, p as ue, i as he } from "./SsrHtmlRuntime-cTFsMSAZ.mjs";
8
+ import { r as B, p as ue, i as he } from "./SsrHtmlRuntime-cTFsMSAZ.mjs";
9
9
  const D = () => globalThis.performance?.now?.() ?? Date.now(), Z = (e) => new TextEncoder().encode(e).byteLength, me = async (e, t) => {
10
10
  const s = D(), r = await le(e, {
11
11
  server: !0,
@@ -13,10 +13,10 @@ const D = () => globalThis.performance?.now?.() ?? Date.now(), Z = (e) => new Te
13
13
  }), i = D();
14
14
  try {
15
15
  if (r.router) {
16
- const a = new URL(t.url);
17
- await r.router.push(`${a.pathname}${a.search}${a.hash}`), await r.router.isReady(), r.router.currentRoute.value.matched.length === 0 && (r.context.response.statusCode = 404);
16
+ const n = new URL(t.url);
17
+ await r.router.push(`${n.pathname}${n.search}${n.hash}`), await r.router.isReady(), r.router.currentRoute.value.matched.length === 0 && (r.context.response.statusCode = 404);
18
18
  }
19
- const n = D(), l = {}, v = await ce(r.app, l), C = D(), f = await e.resolveHead?.(r.context) ?? r.context.head.value, m = {
19
+ const a = D(), l = {}, v = await ce(r.app, l), C = D(), f = await e.resolveHead?.(r.context) ?? r.context.head.value, m = {
20
20
  version: 1,
21
21
  applicationId: e.id,
22
22
  publicConfig: t.publicConfig,
@@ -33,8 +33,8 @@ const D = () => globalThis.performance?.now?.() ?? Date.now(), Z = (e) => new Te
33
33
  requestId: t.requestId,
34
34
  applicationId: e.id,
35
35
  contextDurationMs: i - s,
36
- routeDurationMs: n - i,
37
- renderDurationMs: C - n,
36
+ routeDurationMs: a - i,
37
+ renderDurationMs: C - a,
38
38
  totalDurationMs: o - s,
39
39
  htmlBytes: Z(v),
40
40
  stateBytes: g
@@ -64,8 +64,8 @@ const D = () => globalThis.performance?.now?.() ?? Date.now(), Z = (e) => new Te
64
64
  try {
65
65
  const r = decodeURIComponent(t).replace(/^\/+/, "");
66
66
  if (!r || s.includes(r)) return null;
67
- const i = j(e, r), n = e.endsWith(X) ? e : `${e}${X}`;
68
- return !i.startsWith(n) || !(await B(i)).isFile() ? null : {
67
+ const i = j(e, r), a = e.endsWith(X) ? e : `${e}${X}`;
68
+ return !i.startsWith(a) || !(await _(i)).isFile() ? null : {
69
69
  statusCode: 200,
70
70
  body: await te(i),
71
71
  headers: {
@@ -76,8 +76,8 @@ const D = () => globalThis.performance?.now?.() ?? Date.now(), Z = (e) => new Te
76
76
  } catch {
77
77
  return null;
78
78
  }
79
- }, G = (e) => String(Array.isArray(e) ? e[0] : e || "").split(",", 1)[0].trim(), N = (e) => {
80
- const t = G(e);
79
+ }, J = (e) => String(Array.isArray(e) ? e[0] : e || "").split(",", 1)[0].trim(), U = (e) => {
80
+ const t = J(e);
81
81
  if (!t || t.length > 512 || /[\u0000-\u0020\u007f]/.test(t) || /[\\/@?#]/.test(t))
82
82
  return "";
83
83
  try {
@@ -89,8 +89,8 @@ const D = () => globalThis.performance?.now?.() ?? Date.now(), Z = (e) => new Te
89
89
  } catch {
90
90
  return "";
91
91
  }
92
- }, _ = (e) => {
93
- const t = N(e);
92
+ }, G = (e) => {
93
+ const t = U(e);
94
94
  if (!t) return "";
95
95
  if (t.startsWith("[")) {
96
96
  const s = t.indexOf("]");
@@ -101,68 +101,68 @@ const D = () => globalThis.performance?.now?.() ?? Date.now(), Z = (e) => new Te
101
101
  const t = e.trim().toLowerCase();
102
102
  if (t === "*") return "*";
103
103
  if (t.startsWith("*.")) {
104
- const s = _(t.slice(2));
104
+ const s = G(t.slice(2));
105
105
  return s && !s.includes(":") ? `*.${s}` : "";
106
106
  }
107
- return N(t);
107
+ return U(t);
108
108
  }, ge = (e, t) => {
109
- const s = _(e), r = we(t);
110
- return !s || !r ? !1 : r === "*" ? !0 : r.startsWith("*.") ? s.endsWith(`.${r.slice(2)}`) : N(e) === r || s === _(r);
111
- }, ye = (e, t, s = !1) => N(s && G(e) || t), ve = (e, t, s = !1) => {
109
+ const s = G(e), r = we(t);
110
+ return !s || !r ? !1 : r === "*" ? !0 : r.startsWith("*.") ? s.endsWith(`.${r.slice(2)}`) : U(e) === r || s === G(r);
111
+ }, ye = (e, t, s = !1) => U(s && J(e) || t), ve = (e, t, s = !1) => {
112
112
  if (!s) return t;
113
- const r = G(e).toLowerCase();
113
+ const r = J(e).toLowerCase();
114
114
  return r === "http" || r === "https" ? r : t;
115
115
  }, Se = (e, t, s) => {
116
116
  const r = e.find(
117
- (n) => n.hosts.some(
117
+ (a) => a.hosts.some(
118
118
  (l) => l !== "*" && ge(t, l)
119
119
  )
120
120
  );
121
121
  if (r) return r;
122
- const i = e.find((n) => n.hosts.includes("*"));
123
- return i || (e.find((n) => n.id === s) ?? null);
122
+ const i = e.find((a) => a.hosts.includes("*"));
123
+ return i || (e.find((a) => a.id === s) ?? null);
124
124
  }, Q = /^[!#$%&'*+.^_`|~0-9A-Za-z-]+$/, xe = (e, t = [], s = []) => {
125
125
  const r = new Set(t.filter((l) => Q.test(l))), i = new Set(s.filter((l) => Q.test(l)));
126
126
  if (!e || r.size === 0) return;
127
- const n = String(e).split(";").map((l) => l.trim()).filter(Boolean).filter((l) => {
127
+ const a = String(e).split(";").map((l) => l.trim()).filter(Boolean).filter((l) => {
128
128
  const v = l.indexOf("=");
129
129
  if (v <= 0) return !1;
130
130
  const C = l.slice(0, v).trim();
131
131
  return r.has(C) && !i.has(C);
132
132
  });
133
- return n.length ? n.join("; ") : void 0;
133
+ return a.length ? a.join("; ") : void 0;
134
134
  }, be = (e) => typeof e == "string" ? new TextEncoder().encode(e).byteLength : e?.byteLength ?? 0, Y = (e) => ({
135
135
  statusCode: e.statusCode,
136
136
  body: e.body instanceof Uint8Array ? e.body.slice() : e.body,
137
137
  headers: e.headers ? { ...e.headers } : void 0
138
138
  }), Le = (e = {}) => {
139
- const t = Number(e.maxEntries ?? 500), s = Number(e.maxBytes ?? 32 * 1024 * 1024), r = Number.isFinite(t) ? Math.max(1, Math.floor(t)) : 500, i = Number.isFinite(s) ? Math.max(1, Math.floor(s)) : 32 * 1024 * 1024, n = /* @__PURE__ */ new Map();
139
+ const t = Number(e.maxEntries ?? 500), s = Number(e.maxBytes ?? 32 * 1024 * 1024), r = Number.isFinite(t) ? Math.max(1, Math.floor(t)) : 500, i = Number.isFinite(s) ? Math.max(1, Math.floor(s)) : 32 * 1024 * 1024, a = /* @__PURE__ */ new Map();
140
140
  let l = 0;
141
141
  const v = (f) => {
142
- const m = n.get(f);
143
- return m ? (n.delete(f), l -= m.size, !0) : !1;
142
+ const m = a.get(f);
143
+ return m ? (a.delete(f), l -= m.size, !0) : !1;
144
144
  }, C = () => {
145
145
  const f = Date.now();
146
- for (const [m, g] of n)
146
+ for (const [m, g] of a)
147
147
  g.expiresAt <= f && v(m);
148
- for (; n.size > r || l > i; ) {
149
- const m = n.keys().next().value;
148
+ for (; a.size > r || l > i; ) {
149
+ const m = a.keys().next().value;
150
150
  if (!m) break;
151
151
  v(m);
152
152
  }
153
153
  };
154
154
  return {
155
155
  get(f) {
156
- const m = n.get(f);
157
- return m ? m.expiresAt <= Date.now() ? (v(f), null) : (n.delete(f), n.set(f, m), Y(m.response)) : null;
156
+ const m = a.get(f);
157
+ return m ? m.expiresAt <= Date.now() ? (v(f), null) : (a.delete(f), a.set(f, m), Y(m.response)) : null;
158
158
  },
159
159
  set(f, m, g) {
160
160
  const o = Number(g.ttlMs);
161
161
  if (!Number.isFinite(o) || o <= 0) return;
162
162
  v(f);
163
- const a = Y(m), p = be(a.body);
164
- p > i || (n.set(f, {
165
- response: a,
163
+ const n = Y(m), p = be(n.body);
164
+ p > i || (a.set(f, {
165
+ response: n,
166
166
  expiresAt: Date.now() + o,
167
167
  size: p,
168
168
  tags: new Set(g.tags ?? [])
@@ -171,8 +171,8 @@ const D = () => globalThis.performance?.now?.() ?? Date.now(), Z = (e) => new Te
171
171
  invalidate(f = {}) {
172
172
  const m = new Set(f.keys ?? []), g = new Set(f.tags ?? []);
173
173
  let o = 0;
174
- for (const [a, p] of n)
175
- (!m.size && !g.size || m.has(a) || [...g].some((S) => p.tags.has(S))) && v(a) && (o += 1);
174
+ for (const [n, p] of a)
175
+ (!m.size && !g.size || m.has(n) || [...g].some((S) => p.tags.has(S))) && v(n) && (o += 1);
176
176
  return o;
177
177
  }
178
178
  };
@@ -209,28 +209,28 @@ const Ce = (e) => {
209
209
  if (!r?.name || !Array.isArray(r.entries) || !r.server)
210
210
  throw new Error("The SSR runtime module does not export a valid runtime definition.");
211
211
  const i = /* @__PURE__ */ new Set();
212
- for (const n of r.entries) {
213
- if (!n.id || i.has(n.id))
212
+ for (const a of r.entries) {
213
+ if (!a.id || i.has(a.id))
214
214
  throw new Error("SSR runtime entry ids must be present and unique.");
215
- if (i.add(n.id), !n.template || !n.hosts?.length)
216
- throw new Error(`SSR runtime entry "${n.id}" requires a template and hosts.`);
217
- const l = !n.roles?.length || !r.server.role || n.roles.includes(r.server.role);
218
- if (n.kind === "ssr" && l && !n.application)
219
- throw new Error(`SSR entry "${n.id}" requires an application definition.`);
215
+ if (i.add(a.id), !a.template || !a.hosts?.length)
216
+ throw new Error(`SSR runtime entry "${a.id}" requires a template and hosts.`);
217
+ const l = !a.roles?.length || !r.server.role || a.roles.includes(r.server.role);
218
+ if (a.kind === "ssr" && l && !a.application)
219
+ throw new Error(`SSR entry "${a.id}" requires an application definition.`);
220
220
  }
221
221
  return r;
222
- }, $ = {
222
+ }, T = {
223
223
  "referrer-policy": "strict-origin-when-cross-origin",
224
224
  "x-content-type-options": "nosniff",
225
225
  "x-frame-options": "SAMEORIGIN"
226
- }, I = (e, t) => {
226
+ }, A = (e, t) => {
227
227
  if (e.method !== "GET" && e.method !== "HEAD") return !1;
228
228
  if (e.headers["sec-fetch-mode"] === "navigate") return !0;
229
229
  const s = String(e.headers.accept || "");
230
230
  return s.includes("text/html") ? !0 : (!s || s === "*/*") && !re(t);
231
231
  }, Me = (e, t, s = "") => t.end(e.method === "HEAD" ? "" : s), E = (e, t, s) => {
232
232
  t.writeHead(s.statusCode, s.headers ?? {}), Me(e, t, s.body ?? "");
233
- }, T = (e, t, s, r) => E(e, t, {
233
+ }, P = (e, t, s, r) => E(e, t, {
234
234
  statusCode: s,
235
235
  body: JSON.stringify(r),
236
236
  headers: {
@@ -240,7 +240,7 @@ const Ce = (e) => {
240
240
  }), ee = async (e, t, s) => {
241
241
  if (!Number.isFinite(t) || t <= 0) return e;
242
242
  let r;
243
- const i = new Promise((n, l) => {
243
+ const i = new Promise((a, l) => {
244
244
  r = setTimeout(() => {
245
245
  s.abort(), l(new oe());
246
246
  }, t);
@@ -250,29 +250,31 @@ const Ce = (e) => {
250
250
  } finally {
251
251
  r && clearTimeout(r);
252
252
  }
253
- }, Pe = (e) => e.headers, Te = (e, t, s) => new Promise((r, i) => {
254
- e.middlewares(t, s, (n) => {
255
- n ? i(n) : r();
253
+ }, $e = (e) => e.headers, Pe = (e, t, s) => new Promise((r, i) => {
254
+ e.middlewares(t, s, (a) => {
255
+ a ? i(a) : r();
256
256
  });
257
257
  }), Ne = async (e) => {
258
258
  let t = !1;
259
- const s = await q(await e.loadRuntime()), r = s.server, i = r.host || "0.0.0.0", n = Ce(r.port), l = j(
259
+ const s = await q(await e.loadRuntime()), r = s.server, i = r.host || "0.0.0.0", a = Ce(r.port), l = j(
260
260
  r.root || e.root,
261
261
  r.clientOutDir || "dist/client"
262
- ), v = async () => e.production ? s : q(await e.loadRuntime()), C = async (o, a, p) => {
262
+ ), v = async () => e.production ? s : q(await e.loadRuntime()), C = async (o, n, p) => {
263
263
  const c = o.server.root || e.root, S = await te(
264
- j(e.production ? l : c, a),
264
+ j(e.production ? l : c, n),
265
265
  "utf8"
266
266
  );
267
- return !e.production && e.vite ? e.vite.transformIndexHtml(p, S) : S;
267
+ if (e.production || !e.vite) return S;
268
+ const F = `/${n.replaceAll("\\", "/").replace(/^\/+/, "")}`;
269
+ return e.vite.transformIndexHtml(F, S, p);
268
270
  }, f = async (o) => {
269
- const a = o.server.root || e.root, p = o.entries.filter(
271
+ const n = o.server.root || e.root, p = o.entries.filter(
270
272
  (c) => !c.roles?.length || !o.server.role || c.roles.includes(o.server.role)
271
273
  );
272
274
  await Promise.all(
273
275
  p.map(async (c) => {
274
- if (!(await B(
275
- j(e.production ? l : a, c.template)
276
+ if (!(await _(
277
+ j(e.production ? l : n, c.template)
276
278
  )).isFile())
277
279
  throw new Error(`SSR client entry is missing: ${c.template}`);
278
280
  })
@@ -282,25 +284,25 @@ const Ce = (e) => {
282
284
  );
283
285
  await Promise.all(
284
286
  m.map(async (o) => {
285
- const a = s.server.root || e.root;
286
- if (!(await B(
287
- j(e.production ? l : a, o.template)
287
+ const n = s.server.root || e.root;
288
+ if (!(await _(
289
+ j(e.production ? l : n, o.template)
288
290
  )).isFile()) throw new Error(`Missing client entry: ${o.template}`);
289
291
  })
290
292
  );
291
- const g = ae(async (o, a) => {
293
+ const g = ae(async (o, n) => {
292
294
  const p = Date.now();
293
- let c = "/", S = "unknown", J;
294
- const A = new AbortController(), V = [];
295
- o.once("aborted", () => A.abort()), a.once("close", () => {
296
- a.writableEnded || A.abort();
295
+ let c = "/", S = "unknown", F;
296
+ const I = new AbortController(), V = [];
297
+ o.once("aborted", () => I.abort()), n.once("close", () => {
298
+ n.writableEnded || I.abort();
297
299
  });
298
300
  try {
299
301
  const h = await v(), u = h.server, M = new URL(o.url || "/", "http://internal");
300
302
  c = M.pathname;
301
303
  const H = u.healthPath || "/healthz", R = u.readinessPath || "/readyz";
302
304
  if (c === H)
303
- return T(o, a, 200, {
305
+ return P(o, n, 200, {
304
306
  status: "ok",
305
307
  service: h.name,
306
308
  role: u.role || "default",
@@ -308,60 +310,60 @@ const Ce = (e) => {
308
310
  });
309
311
  if (c === R) {
310
312
  if (t)
311
- return T(o, a, 503, {
313
+ return P(o, n, 503, {
312
314
  status: "error",
313
315
  service: h.name,
314
316
  message: "Server is shutting down."
315
317
  });
316
318
  try {
317
- return await f(h), T(o, a, 200, {
319
+ return await f(h), P(o, n, 200, {
318
320
  status: "ok",
319
321
  service: h.name,
320
322
  role: u.role || "default"
321
323
  });
322
324
  } catch {
323
- return T(o, a, 503, {
325
+ return P(o, n, 503, {
324
326
  status: "error",
325
327
  service: h.name,
326
328
  message: "A required dependency is unavailable."
327
329
  });
328
330
  }
329
331
  }
330
- const F = ye(
332
+ const L = ye(
331
333
  o.headers["x-forwarded-host"],
332
334
  o.headers.host,
333
335
  u.trustProxy
334
336
  );
335
- if (!F)
336
- return E(o, a, {
337
+ if (!L)
338
+ return E(o, n, {
337
339
  statusCode: 400,
338
- body: I(o, c) ? W("Invalid request", "The Host header is invalid.") : JSON.stringify({ status: "error", message: "Invalid Host header." }),
340
+ body: A(o, c) ? B("Invalid request", "The Host header is invalid.") : JSON.stringify({ status: "error", message: "Invalid Host header." }),
339
341
  headers: {
340
- "content-type": I(o, c) ? "text/html; charset=utf-8" : "application/json; charset=utf-8",
342
+ "content-type": A(o, c) ? "text/html; charset=utf-8" : "application/json; charset=utf-8",
341
343
  "cache-control": "no-store",
342
- ...$
344
+ ...T
343
345
  }
344
346
  });
345
347
  const w = Se(
346
348
  h.entries,
347
- F,
349
+ L,
348
350
  h.defaultEntryId
349
351
  );
350
352
  if (!w)
351
- return T(o, a, 421, {
353
+ return P(o, n, 421, {
352
354
  status: "error",
353
355
  service: h.name,
354
356
  message: "No application entry serves this host."
355
357
  });
356
358
  if (S = w.id, w.roles?.length && u.role && !w.roles.includes(u.role)) {
357
359
  const d = `Runtime role does not serve entry "${w.id}".`;
358
- return E(o, a, {
360
+ return E(o, n, {
359
361
  statusCode: 421,
360
- body: I(o, c) ? W("Misdirected request", d) : JSON.stringify({ status: "error", message: d }),
362
+ body: A(o, c) ? B("Misdirected request", d) : JSON.stringify({ status: "error", message: d }),
361
363
  headers: {
362
- "content-type": I(o, c) ? "text/html; charset=utf-8" : "application/json; charset=utf-8",
364
+ "content-type": A(o, c) ? "text/html; charset=utf-8" : "application/json; charset=utf-8",
363
365
  "cache-control": "no-store",
364
- ...$
366
+ ...T
365
367
  }
366
368
  });
367
369
  }
@@ -369,7 +371,7 @@ const Ce = (e) => {
369
371
  o.headers["x-forwarded-proto"],
370
372
  o.socket.encrypted ? "https" : "http",
371
373
  u.trustProxy
372
- ), U = xe(
374
+ ), z = xe(
373
375
  o.headers.cookie,
374
376
  u.cookieAllowlist,
375
377
  u.cookieDenylist
@@ -377,22 +379,22 @@ const Ce = (e) => {
377
379
  requestId: String(o.headers["x-request-id"] || "").trim() || `${p.toString(36)}-${Math.random().toString(36).slice(2, 10)}`,
378
380
  url: new URL(
379
381
  `${M.pathname}${M.search}`,
380
- `${K}://${F}`
382
+ `${K}://${L}`
381
383
  ).href,
382
- host: F,
384
+ host: L,
383
385
  protocol: K,
384
386
  method: o.method || "GET",
385
- headers: Pe(o),
386
- cookie: U,
387
- apolloHeaders: U ? { cookie: U } : void 0,
387
+ headers: $e(o),
388
+ cookie: z,
389
+ apolloHeaders: z ? { cookie: z } : void 0,
388
390
  apolloRequestTimeoutMs: u.apolloRequestTimeoutMs,
389
391
  publicConfig: u.publicConfig,
390
- signal: A.signal,
392
+ signal: I.signal,
391
393
  pathname: c,
392
394
  search: M.search,
393
395
  entryId: w.id
394
396
  };
395
- J = y;
397
+ F = y;
396
398
  const se = {
397
399
  createApolloClients: (d) => {
398
400
  const b = ie(d, {
@@ -410,9 +412,9 @@ const Ce = (e) => {
410
412
  const b = await ee(
411
413
  Promise.resolve(d.handle(y, se)),
412
414
  u.requestTimeoutMs ?? 15e3,
413
- A
415
+ I
414
416
  );
415
- if (b) return E(o, a, b);
417
+ if (b) return E(o, n, b);
416
418
  }
417
419
  if (e.production) {
418
420
  const d = await pe(
@@ -420,22 +422,22 @@ const Ce = (e) => {
420
422
  c,
421
423
  h.entries.map(({ template: b }) => b)
422
424
  );
423
- if (d) return E(o, a, d);
424
- } else if (e.vite && (c.startsWith("/src/") || c.startsWith("/@") || c.includes(".") || c === "/__vite_ping") && (await Te(e.vite, o, a), a.writableEnded))
425
+ if (d) return E(o, n, d);
426
+ } else if (e.vite && (c.startsWith("/src/") || c.startsWith("/@") || c.includes(".") || c === "/__vite_ping") && (await Pe(e.vite, o, n), n.writableEnded))
425
427
  return;
426
- if (!I(o, c))
427
- return T(o, a, 404, {
428
+ if (!A(o, c))
429
+ return P(o, n, 404, {
428
430
  status: "error",
429
431
  service: h.name,
430
432
  message: "Resource not found."
431
433
  });
432
- const P = w.kind === "ssr" ? w.responseCache : void 0;
434
+ const $ = w.kind === "ssr" ? w.responseCache : void 0;
433
435
  let k = null;
434
436
  try {
435
437
  k = await Ee(
436
438
  w.id,
437
439
  y,
438
- P
440
+ $
439
441
  );
440
442
  } catch (d) {
441
443
  u.logger?.warn?.("ssr.cache.key.failed", {
@@ -444,11 +446,11 @@ const Ce = (e) => {
444
446
  error: d instanceof Error ? d.message : "Unknown cache error"
445
447
  });
446
448
  }
447
- if (P && k)
449
+ if ($ && k)
448
450
  try {
449
- const d = await P.store.get(k);
451
+ const d = await $.store.get(k);
450
452
  if (d)
451
- return E(o, a, {
453
+ return E(o, n, {
452
454
  ...d,
453
455
  headers: {
454
456
  ...d.headers,
@@ -462,27 +464,27 @@ const Ce = (e) => {
462
464
  error: d instanceof Error ? d.message : "Unknown cache error"
463
465
  });
464
466
  }
465
- let L = await C(h, w.template, o.url || "/");
467
+ let N = await C(h, w.template, o.url || "/");
466
468
  if (w.kind === "spa")
467
- return E(o, a, {
469
+ return E(o, n, {
468
470
  statusCode: 200,
469
- body: L,
471
+ body: N,
470
472
  headers: {
471
473
  "content-type": "text/html; charset=utf-8",
472
474
  "cache-control": w.cacheControl || "private, no-store",
473
475
  vary: "Host, X-Forwarded-Host",
474
- ...$
476
+ ...T
475
477
  }
476
478
  });
477
- const z = w.application;
478
- L = ue(
479
- L,
480
- w.mountSelector || z.mountSelector || "#app"
479
+ const O = w.application;
480
+ N = ue(
481
+ N,
482
+ w.mountSelector || O.mountSelector || "#app"
481
483
  );
482
484
  const x = await ee(
483
- me(z, y),
485
+ me(O, y),
484
486
  u.requestTimeoutMs ?? 15e3,
485
- A
487
+ I
486
488
  );
487
489
  if (x.response.redirect) {
488
490
  const d = x.response.redirect, b = new URL(d.location, y.url);
@@ -490,7 +492,7 @@ const Ce = (e) => {
490
492
  throw new Error("SSR redirects must use HTTP or HTTPS.");
491
493
  if (!d.allowExternal && b.origin !== new URL(y.url).origin)
492
494
  throw new Error("Cross-origin redirect requires allowExternal: true.");
493
- return E(o, a, {
495
+ return E(o, n, {
494
496
  statusCode: d.statusCode ?? 302,
495
497
  headers: {
496
498
  location: b.href,
@@ -498,15 +500,15 @@ const Ce = (e) => {
498
500
  }
499
501
  });
500
502
  }
501
- const ne = he(L, {
502
- applicationId: z.id,
503
+ const ne = he(N, {
504
+ applicationId: O.id,
503
505
  html: x.html,
504
506
  teleports: x.teleports,
505
507
  head: x.head,
506
508
  state: x.hydrationState
507
509
  });
508
510
  u.onMetrics?.(x.metrics), u.logger?.info?.("ssr.render.complete", x.metrics);
509
- const O = {
511
+ const W = {
510
512
  statusCode: x.response.statusCode,
511
513
  body: ne,
512
514
  headers: {
@@ -519,14 +521,14 @@ const Ce = (e) => {
519
521
  `render;dur=${x.metrics.renderDurationMs.toFixed(1)}`
520
522
  ].join(", "),
521
523
  ...x.response.headers,
522
- ...$
524
+ ...T
523
525
  }
524
526
  };
525
- if (P && k && Re(O, y, P))
527
+ if ($ && k && Re(W, y, $))
526
528
  try {
527
- await P.store.set(k, O, {
528
- ttlMs: P.ttlMs,
529
- tags: await P.tags?.(y)
529
+ await $.store.set(k, W, {
530
+ ttlMs: $.ttlMs,
531
+ tags: await $.tags?.(y)
530
532
  });
531
533
  } catch (d) {
532
534
  u.logger?.warn?.("ssr.cache.write.failed", {
@@ -535,7 +537,7 @@ const Ce = (e) => {
535
537
  error: d instanceof Error ? d.message : "Unknown cache error"
536
538
  });
537
539
  }
538
- return E(o, a, O);
540
+ return E(o, n, W);
539
541
  } catch (h) {
540
542
  e.vite?.ssrFixStacktrace(h);
541
543
  const u = await v().catch(() => s);
@@ -543,8 +545,8 @@ const Ce = (e) => {
543
545
  entryId: S,
544
546
  pathname: c,
545
547
  error: h instanceof Error ? h.message : "Unknown error"
546
- }), a.writableEnded) return;
547
- if (a.headersSent) return a.destroy();
548
+ }), n.writableEnded) return;
549
+ if (n.headersSent) return n.destroy();
548
550
  const M = h instanceof oe, H = M ? 504 : 500;
549
551
  if (u.server.renderError)
550
552
  try {
@@ -552,17 +554,17 @@ const Ce = (e) => {
552
554
  error: h,
553
555
  kind: M ? "timeout" : "internal",
554
556
  production: e.production,
555
- request: J,
557
+ request: F,
556
558
  entryId: S === "unknown" ? void 0 : S
557
559
  });
558
560
  if (R)
559
- return E(o, a, {
561
+ return E(o, n, {
560
562
  ...R,
561
563
  statusCode: R.statusCode >= 400 ? R.statusCode : H,
562
564
  headers: {
563
565
  ...R.headers,
564
566
  "cache-control": "no-store",
565
- ...$
567
+ ...T
566
568
  }
567
569
  });
568
570
  } catch (R) {
@@ -571,18 +573,18 @@ const Ce = (e) => {
571
573
  error: R instanceof Error ? R.message : "Unknown error renderer failure"
572
574
  });
573
575
  }
574
- return I(o, c) ? E(o, a, {
576
+ return A(o, c) ? E(o, n, {
575
577
  statusCode: H,
576
- body: W(
578
+ body: B(
577
579
  M ? "Request timed out" : "Application unavailable",
578
580
  e.production ? "The application could not render this page. Please try again." : h instanceof Error ? h.message : "Unknown rendering failure."
579
581
  ),
580
582
  headers: {
581
583
  "content-type": "text/html; charset=utf-8",
582
584
  "cache-control": "no-store",
583
- ...$
585
+ ...T
584
586
  }
585
- }) : T(o, a, H, {
587
+ }) : P(o, n, H, {
586
588
  status: "error",
587
589
  service: u.name
588
590
  });
@@ -596,15 +598,15 @@ const Ce = (e) => {
596
598
  const o = g.address();
597
599
  return {
598
600
  host: typeof o == "object" && o ? o.address : i,
599
- port: typeof o == "object" && o ? o.port : n
601
+ port: typeof o == "object" && o ? o.port : a
600
602
  };
601
603
  },
602
- listen: () => new Promise((o, a) => {
603
- const p = (c) => a(c);
604
- g.once("error", p), g.listen(n, i, () => {
604
+ listen: () => new Promise((o, n) => {
605
+ const p = (c) => n(c);
606
+ g.once("error", p), g.listen(a, i, () => {
605
607
  g.off("error", p), r.logger?.info?.("ssr.server.listening", {
606
608
  host: i,
607
- port: n,
609
+ port: a,
608
610
  role: r.role || "default"
609
611
  }), o();
610
612
  });
@@ -613,7 +615,7 @@ const Ce = (e) => {
613
615
  if (t) return;
614
616
  t = !0;
615
617
  const o = r.shutdownTimeoutMs ?? 1e4;
616
- let a;
618
+ let n;
617
619
  try {
618
620
  await Promise.race([
619
621
  Promise.all([
@@ -625,13 +627,13 @@ const Ce = (e) => {
625
627
  e.vite?.close()
626
628
  ]),
627
629
  new Promise((p, c) => {
628
- a = setTimeout(() => {
630
+ n = setTimeout(() => {
629
631
  g.closeAllConnections?.(), c(new Error("SSR server graceful shutdown timed out."));
630
632
  }, o);
631
633
  })
632
634
  ]);
633
635
  } finally {
634
- a && clearTimeout(a);
636
+ n && clearTimeout(n);
635
637
  }
636
638
  }
637
639
  };
@@ -648,7 +650,7 @@ export {
648
650
  Re as i,
649
651
  Ee as j,
650
652
  ge as m,
651
- N as n,
653
+ U as n,
652
654
  me as r,
653
- _ as s
655
+ G as s
654
656
  };
package/dist/cli.mjs CHANGED
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env node
2
2
  import { resolve as o, relative as p } from "node:path";
3
3
  import { pathToFileURL as f } from "node:url";
4
- import { c as w } from "./chunks/SsrServerRuntime-Cboc9aUP.mjs";
4
+ import { c as w } from "./chunks/SsrServerRuntime-D9hwT6rl.mjs";
5
5
  const i = (e, r) => {
6
6
  const t = e.indexOf(r);
7
7
  return t >= 0 ? e[t + 1] : void 0;
@@ -1 +1 @@
1
- {"version":3,"file":"SsrServerRuntime.d.ts","sourceRoot":"","sources":["../../src/server/SsrServerRuntime.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAA6C,MAAM,WAAW,CAAA;AAGnF,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,MAAM,CAAA;AA4BzC,MAAM,WAAW,uBAAuB;IACtC,UAAU,EAAE,OAAO,CAAA;IACnB,IAAI,EAAE,MAAM,CAAA;IACZ,WAAW,EAAE,MAAM,OAAO,CAAC,OAAO,CAAC,CAAA;IACnC,IAAI,CAAC,EAAE,aAAa,CAAA;CACrB;AAED,MAAM,WAAW,gBAAgB;IAC/B,UAAU,EAAE,UAAU,CAAC,OAAO,YAAY,CAAC,CAAA;IAC3C,MAAM,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAA;IAC3B,KAAK,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAA;IAC1B,OAAO,EAAE,MAAM;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,CAAA;CAC9C;AAgID,eAAO,MAAM,sBAAsB,GACjC,SAAS,uBAAuB,KAC/B,OAAO,CAAC,gBAAgB,CAqf1B,CAAA"}
1
+ {"version":3,"file":"SsrServerRuntime.d.ts","sourceRoot":"","sources":["../../src/server/SsrServerRuntime.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAA6C,MAAM,WAAW,CAAA;AAGnF,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,MAAM,CAAA;AA4BzC,MAAM,WAAW,uBAAuB;IACtC,UAAU,EAAE,OAAO,CAAA;IACnB,IAAI,EAAE,MAAM,CAAA;IACZ,WAAW,EAAE,MAAM,OAAO,CAAC,OAAO,CAAC,CAAA;IACnC,IAAI,CAAC,EAAE,aAAa,CAAA;CACrB;AAED,MAAM,WAAW,gBAAgB;IAC/B,UAAU,EAAE,UAAU,CAAC,OAAO,YAAY,CAAC,CAAA;IAC3C,MAAM,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAA;IAC3B,KAAK,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAA;IAC1B,OAAO,EAAE,MAAM;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,CAAA;CAC9C;AAgID,eAAO,MAAM,sBAAsB,GACjC,SAAS,uBAAuB,KAC/B,OAAO,CAAC,gBAAgB,CAuf1B,CAAA"}
package/dist/server.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import { c as e, a, f as o, i as S, m as t, n, b as R, r as l, d as c, e as i, g as p, h as m, j as d, s as E } from "./chunks/SsrServerRuntime-Cboc9aUP.mjs";
1
+ import { c as e, a, f as o, i as S, m as t, n, b as R, r as l, d as c, e as i, g as p, h as m, j as d, s as E } from "./chunks/SsrServerRuntime-D9hwT6rl.mjs";
2
2
  import { S as A, a as _, b as M, c as v, i as P, p as T, r as h } from "./chunks/SsrHtmlRuntime-cTFsMSAZ.mjs";
3
3
  export {
4
4
  A as SSR_HEAD_MARKER,
@@ -1 +1 @@
1
- {"version":3,"file":"SsrVitePlugin.d.ts","sourceRoot":"","sources":["../../src/vite/SsrVitePlugin.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,MAAM,CAAA;AAIlC,MAAM,WAAW,uBAAuB;IACtC,EAAE,EAAE,MAAM,CAAA;IACV,UAAU,EAAE,MAAM,CAAA;IAClB,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,QAAQ,EAAE,MAAM,CAAA;IAChB,aAAa,CAAC,EAAE,MAAM,CAAA;CACvB;AAED,MAAM,WAAW,oBAAoB;IACnC,YAAY,EAAE,uBAAuB,EAAE,CAAA;IACvC,UAAU,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;IACnC,IAAI,CAAC,EAAE,MAAM,CAAA;CACd;AAKD,eAAO,MAAM,UAAU,GAAI,SAAS,oBAAoB,KAAG,MAmH1D,CAAA"}
1
+ {"version":3,"file":"SsrVitePlugin.d.ts","sourceRoot":"","sources":["../../src/vite/SsrVitePlugin.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,MAAM,CAAA;AAIlC,MAAM,WAAW,uBAAuB;IACtC,EAAE,EAAE,MAAM,CAAA;IACV,UAAU,EAAE,MAAM,CAAA;IAClB,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,QAAQ,EAAE,MAAM,CAAA;IAChB,aAAa,CAAC,EAAE,MAAM,CAAA;CACvB;AAED,MAAM,WAAW,oBAAoB;IACnC,YAAY,EAAE,uBAAuB,EAAE,CAAA;IACvC,UAAU,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;IACnC,IAAI,CAAC,EAAE,MAAM,CAAA;CACd;AAKD,eAAO,MAAM,UAAU,GAAI,SAAS,oBAAoB,KAAG,MAsH1D,CAAA"}
package/dist/vite.mjs CHANGED
@@ -37,10 +37,14 @@ const p = "virtual:vue-ssr-lite/client/", m = `\0${p}`, g = (i) => {
37
37
  "graphql",
38
38
  "vue",
39
39
  "vue-apollo-client",
40
+ "vue-ssr-lite",
40
41
  "vue-router"
41
42
  ]
42
43
  },
43
44
  ssr: {
45
+ // The managed server imports vue-ssr-lite through Node. Keep the
46
+ // consumer SSR module on that same package instance so InjectionKey
47
+ // symbols and other runtime identity-sensitive values stay shared.
44
48
  noExternal: [
45
49
  "@apollo/client",
46
50
  "@vue/apollo-composable",
@@ -50,7 +54,6 @@ const p = "virtual:vue-ssr-lite/client/", m = `\0${p}`, g = (i) => {
50
54
  "optimism",
51
55
  "ts-invariant",
52
56
  "vue-apollo-client",
53
- "vue-ssr-lite",
54
57
  /^@wry\//
55
58
  ]
56
59
  },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vue-ssr-lite",
3
- "version": "0.1.1",
3
+ "version": "0.1.3",
4
4
  "description": "Fully managed Vue 3 SSR runtime with routing, Apollo hydration, Vite, and Node server lifecycle.",
5
5
  "license": "MIT",
6
6
  "type": "module",