vue-ssr-lite 0.2.6 → 0.2.7

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 +1 @@
1
- {"version":3,"file":"SsrConfigCompileRuntime.d.ts","sourceRoot":"","sources":["../src/SsrConfigCompileRuntime.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAEV,0BAA0B,EAE1B,uBAAuB,EAEvB,SAAS,EAET,aAAa,EACb,aAAa,EACd,MAAM,kBAAkB,CAAA;AACzB,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAA;AAEpD,OAAO,KAAK,EACV,wBAAwB,EACxB,qBAAqB,EACrB,YAAY,EACZ,iBAAiB,EACjB,wBAAwB,EACxB,gBAAgB,EACjB,MAAM,mBAAmB,CAAA;AAM1B,OAAO,EAAE,eAAe,EAAE,CAAA;AAU1B,eAAO,MAAM,sBAAsB,iCAAiC,CAAA;AACpE,eAAO,MAAM,yBAAyB,iCAAiC,CAAA;AAEvE,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,EAAE,MAAM,EAAE,CAAA;IACzB,cAAc,EAAE,MAAM,EAAE,CAAA;IACxB,YAAY,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;IACrC,iBAA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,MAAM,CAAA;IAChB,aAAa,CAAC,EAAE,MAAM,CAAA;CACvB;AAED,MAAM,WAAW,cAAc;IAC7B,YAAY,EAAE,uBAAuB,EAAE,CAAA;CACxC;AAED,eAAO,MAAM,yBAAyB,GACpC,OAAO,OAAO,KACb,KAAK,IAAI,uBAOT,CAAA;AA8HH,MAAM,WAAW,uBAAuB;IACtC,WAAW,CAAC,EAAE,OAAO,CAAA;IACrB,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,YAAY,CAAC,EAAE,CAAC,SAAS,EAAE,MAAM,KAAK,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAA;CACvE;AA4CD,eAAO,MAAM,oBAAoB,GAC/B,MAAM,MAAM,EACZ,WAAW,MAAM,KAChB,OAAO,CAAC,MAAM,CAchB,CAAA;AAED,mEAAmE;AACnE,eAAO,MAAM,qBAAqB,GAAI,QAAQ,SAAS,KAAG,cA0BzD,CAAA;AAED;;;GAGG;AACH,eAAO,MAAM,iBAAiB,GAC5B,MAAM,MAAM,EACZ,aAAa,MAAM,KAClB,OAAO,CAAC,SAAS,CAwCnB,CAAA;AAED,eAAO,MAAM,qBAAqB,GAChC,MAAM,MAAM,EACZ,aAAa,MAAM,KAClB,OAAO,CAAC,cAAc,CAGxB,CAAA;AAUD;;;GAGG;AACH,eAAO,MAAM,wBAAwB,GACnC,MAAM,MAAM,EACZ,YAAY,MAAM,EAClB,SAAS,uBAAuB,EAAE,KACjC,MAwCF,CAAA;AAED,eAAO,MAAM,uBAAuB,GAClC,MAAM,MAAM,EACZ,OAAO,uBAAuB,KAC7B,MAsCF,CAAA;AAED,eAAO,MAAM,gBAAgB,GAC3B,QAAQ,OAAO,EACf,UAAS,uBAA4B,KACpC,OAAO,CAAC,iBAAiB,CAgI3B,CAAA"}
@@ -1,91 +1,91 @@
1
1
  import { access as T, mkdir as I, writeFile as z, rm as D } from "node:fs/promises";
2
2
  import { randomBytes as k } from "node:crypto";
3
- import { resolve as S, join as x, relative as j } from "node:path";
3
+ import { resolve as S, join as x } from "node:path";
4
4
  import { pathToFileURL as H } from "node:url";
5
- import { n as v, d as m, a as E, e as u, g as L, c as q, r as B } from "./SsrSerialization-DeKozeIm.mjs";
6
- const O = (t) => String(Array.isArray(t) ? t[0] : t || "").split(",", 1)[0].trim(), F = 1e6;
5
+ import { n as v, d as m, a as E, e as u, g as j, c as L, r as q } from "./SsrSerialization-DeKozeIm.mjs";
6
+ const O = (t) => String(Array.isArray(t) ? t[0] : t || "").split(",", 1)[0].trim(), B = 1e6;
7
7
  class p extends Error {
8
8
  constructor(e) {
9
9
  super(e), this.name = "SsrHostConfigurationError";
10
10
  }
11
11
  }
12
12
  const J = (t, e) => {
13
- const o = m(t), i = E(e);
14
- return !o || !i ? !1 : i === "*" ? !0 : i.startsWith("*.") ? o.endsWith(`.${i.slice(2)}`) : v(t) === i || o === m(i);
15
- }, U = (t, e) => {
16
- const o = m(t), i = E(e);
17
- if (!o || !i || !J(t, i)) return null;
18
- if (i === "*")
19
- return { category: "catch-all", specificity: 0, pattern: i };
20
- if (i.startsWith("*."))
13
+ const i = m(t), o = E(e);
14
+ return !i || !o ? !1 : o === "*" ? !0 : o.startsWith("*.") ? i.endsWith(`.${o.slice(2)}`) : v(t) === o || i === m(o);
15
+ }, F = (t, e) => {
16
+ const i = m(t), o = E(e);
17
+ if (!i || !o || !J(t, o)) return null;
18
+ if (o === "*")
19
+ return { category: "catch-all", specificity: 0, pattern: o };
20
+ if (o.startsWith("*."))
21
21
  return {
22
22
  category: "wildcard",
23
- specificity: i.slice(2).length,
24
- pattern: i
23
+ specificity: o.slice(2).length,
24
+ pattern: o
25
25
  };
26
- const n = m(i);
26
+ const n = m(o);
27
27
  return {
28
28
  category: "exact",
29
- specificity: F + n.length,
30
- pattern: i
29
+ specificity: B + n.length,
30
+ pattern: o
31
31
  };
32
- }, V = (t) => {
33
- const e = /* @__PURE__ */ new Map(), o = [];
34
- for (const i of t) {
35
- const n = i.hosts ?? [];
32
+ }, U = (t) => {
33
+ const e = /* @__PURE__ */ new Map(), i = [];
34
+ for (const o of t) {
35
+ const n = o.hosts ?? [];
36
36
  if (!n.length)
37
37
  throw new p(
38
- `SSR application "${i.id}" requires at least one host pattern.`
38
+ `SSR application "${o.id}" requires at least one host pattern.`
39
39
  );
40
40
  const c = /* @__PURE__ */ new Set();
41
41
  for (const s of n) {
42
42
  const l = String(s ?? "").trim();
43
43
  if (!l)
44
44
  throw new p(
45
- `SSR application "${i.id}" contains an empty host pattern.`
45
+ `SSR application "${o.id}" contains an empty host pattern.`
46
46
  );
47
47
  if (/^[a-z][a-z0-9+.-]*:\/\//i.test(l) || /[/?#]/.test(l))
48
48
  throw new p(
49
- `SSR application "${i.id}" host pattern "${s}" must not include a protocol, path, or query.`
49
+ `SSR application "${o.id}" host pattern "${s}" must not include a protocol, path, or query.`
50
50
  );
51
51
  const a = E(l);
52
52
  if (!a)
53
53
  throw new p(
54
- `SSR application "${i.id}" has an invalid host pattern "${s}". Use an exact hostname, *.example.com, or *.`
54
+ `SSR application "${o.id}" has an invalid host pattern "${s}". Use an exact hostname, *.example.com, or *.`
55
55
  );
56
56
  if (a !== "*" && (a.startsWith("[") ? /\]:\d+$/.test(a) : /:\d+$/.test(a)))
57
57
  throw new p(
58
- `SSR application "${i.id}" host pattern "${s}" must not include a port.`
58
+ `SSR application "${o.id}" host pattern "${s}" must not include a port.`
59
59
  );
60
60
  if (c.has(a)) continue;
61
61
  if (c.add(a), a === "*") {
62
- o.push(i.id);
62
+ i.push(o.id);
63
63
  continue;
64
64
  }
65
65
  const d = e.get(a);
66
- if (d && d !== i.id)
66
+ if (d && d !== o.id)
67
67
  throw new p(
68
- `Host pattern "${a}" is assigned to both "${d}" and "${i.id}".`
68
+ `Host pattern "${a}" is assigned to both "${d}" and "${o.id}".`
69
69
  );
70
- e.set(a, i.id);
70
+ e.set(a, o.id);
71
71
  }
72
72
  }
73
- if (o.length > 1)
73
+ if (i.length > 1)
74
74
  throw new p(
75
- `Multiple catch-all ("*") host applications are not allowed (applications: ${o.join(", ")}).`
75
+ `Multiple catch-all ("*") host applications are not allowed (applications: ${i.join(", ")}).`
76
76
  );
77
- }, pt = (t, e, o) => {
78
- const i = m(e);
79
- if (!i) return null;
77
+ }, lt = (t, e, i) => {
78
+ const o = m(e);
79
+ if (!o) return null;
80
80
  let n = null;
81
81
  for (const s of t)
82
82
  for (const l of s.hosts ?? []) {
83
- const a = U(e, l);
83
+ const a = F(e, l);
84
84
  if (!a) continue;
85
85
  const r = {
86
86
  entry: s,
87
87
  matchedPattern: a.pattern,
88
- normalizedHostname: i,
88
+ normalizedHostname: o,
89
89
  category: a.category,
90
90
  specificity: a.specificity
91
91
  };
@@ -96,57 +96,57 @@ const J = (t, e) => {
96
96
  r.specificity < n.specificity || r.entry.id < n.entry.id && (n = r);
97
97
  }
98
98
  if (n) return n;
99
- if (!o) return null;
99
+ if (!i) return null;
100
100
  const c = t.find(
101
- (s) => s.id === o
101
+ (s) => s.id === i
102
102
  );
103
103
  return c ? {
104
104
  entry: c,
105
105
  matchedPattern: null,
106
- normalizedHostname: i,
106
+ normalizedHostname: o,
107
107
  category: "default",
108
108
  specificity: -1
109
109
  } : null;
110
- }, dt = (t, e, o = !1) => v(o && O(t) || e), ft = (t, e, o = !1) => {
111
- if (!o) return e;
112
- const i = O(t).toLowerCase();
113
- return i === "http" || i === "https" ? i : e;
114
- }, R = /^[!#$%&'*+.^_`|~0-9A-Za-z-]+$/, ut = (t, e = [], o = []) => {
115
- const i = new Set(e.filter((s) => R.test(s))), n = new Set(o.filter((s) => R.test(s)));
116
- if (!t || i.size === 0) return;
110
+ }, pt = (t, e, i = !1) => v(i && O(t) || e), dt = (t, e, i = !1) => {
111
+ if (!i) return e;
112
+ const o = O(t).toLowerCase();
113
+ return o === "http" || o === "https" ? o : e;
114
+ }, R = /^[!#$%&'*+.^_`|~0-9A-Za-z-]+$/, ft = (t, e = [], i = []) => {
115
+ const o = new Set(e.filter((s) => R.test(s))), n = new Set(i.filter((s) => R.test(s)));
116
+ if (!t || o.size === 0) return;
117
117
  const c = String(t).split(";").map((s) => s.trim()).filter(Boolean).filter((s) => {
118
118
  const l = s.indexOf("=");
119
119
  if (l <= 0) return !1;
120
120
  const a = s.slice(0, l).trim();
121
- return i.has(a) && !n.has(a);
121
+ return o.has(a) && !n.has(a);
122
122
  });
123
123
  return c.length ? c.join("; ") : void 0;
124
- }, W = ["localhost", "127.0.0.1", "0.0.0.0", "::1"], C = [
124
+ }, V = ["localhost", "127.0.0.1", "0.0.0.0", "::1"], C = [
125
125
  "ssr.config.ts",
126
126
  "ssr.config.mts",
127
127
  "ssr.config.js",
128
128
  "ssr.config.mjs"
129
- ], mt = "virtual:vue-ssr-lite/runtime", ht = "virtual:vue-ssr-lite/client/", b = (t) => !!(t && typeof t == "object" && "module" in t && typeof t.module == "string" && !("id" in t && "rootComponent" in t)), h = (t, e) => {
130
- const o = m(v(t) || t);
131
- if (!o || o.includes("/") || o.includes("?"))
129
+ ], ut = "virtual:vue-ssr-lite/runtime", mt = "virtual:vue-ssr-lite/client/", b = (t) => !!(t && typeof t == "object" && "module" in t && typeof t.module == "string" && !("id" in t && "rootComponent" in t)), h = (t, e) => {
130
+ const i = m(v(t) || t);
131
+ if (!i || i.includes("/") || i.includes("?"))
132
132
  throw new p(
133
133
  `${e} must be a valid hostname without a protocol, path, or port.`
134
134
  );
135
- return o.replace(/^\[|\]$/g, "");
135
+ return i.replace(/^\[|\]$/g, "");
136
136
  }, f = (t, e) => {
137
137
  t.includes(e) || t.push(e);
138
138
  }, K = (t, e) => {
139
- const o = t.mode ?? "root-and-subdomains", i = h(
139
+ const i = t.mode ?? "root-and-subdomains", o = h(
140
140
  e ? t.development : t.production,
141
141
  e ? "domain.development" : "domain.production"
142
142
  ), n = [];
143
- if ((o === "root" || o === "root-and-subdomains") && f(n, i), (o === "subdomains" || o === "root-and-subdomains") && f(n, `*.${i}`), e) {
143
+ if ((i === "root" || i === "root-and-subdomains") && f(n, o), (i === "subdomains" || i === "root-and-subdomains") && f(n, `*.${o}`), e) {
144
144
  const c = h(
145
145
  t.production,
146
146
  "domain.production"
147
147
  );
148
- if (c !== i && ((o === "root" || o === "root-and-subdomains") && f(n, c), (o === "subdomains" || o === "root-and-subdomains") && f(n, `*.${c}`)), t.localAliases)
149
- for (const s of W) f(n, s);
148
+ if (c !== o && ((i === "root" || i === "root-and-subdomains") && f(n, c), (i === "subdomains" || i === "root-and-subdomains") && f(n, `*.${c}`)), t.localAliases)
149
+ for (const s of V) f(n, s);
150
150
  }
151
151
  for (const c of t.additionalHosts ?? [])
152
152
  f(n, h(c, "domain.additionalHosts"));
@@ -155,81 +155,81 @@ const J = (t, e) => {
155
155
  "Application domain configuration produced an empty host list."
156
156
  );
157
157
  return n;
158
- }, P = (t) => t == null ? [] : Array.isArray(t) ? t.map((e) => String(e).trim()).filter(Boolean) : String(t).split(",").map((e) => e.trim()).filter(Boolean), Z = (t) => !!(t && typeof t == "object" && typeof t.id == "string" && t.rootComponent), X = (t, e) => t.id === e ? t : { ...t, id: e }, G = (t, e, o, i) => {
158
+ }, P = (t) => t == null ? [] : Array.isArray(t) ? t.map((e) => String(e).trim()).filter(Boolean) : String(t).split(",").map((e) => e.trim()).filter(Boolean), W = (t) => !!(t && typeof t == "object" && typeof t.id == "string" && t.rootComponent), Z = (t, e) => t.id === e ? t : { ...t, id: e }, X = (t, e, i, o) => {
159
159
  const n = e ? t[e] : t.default;
160
160
  if (n == null)
161
161
  throw new p(
162
- `Application "${o}" ${i} module must export${e ? ` "${e}"` : " a default value"}.`
162
+ `Application "${i}" ${o} module must export${e ? ` "${e}"` : " a default value"}.`
163
163
  );
164
164
  return n;
165
- }, _ = async (t, e, o) => {
166
- const i = typeof t == "function" ? await t() : t;
167
- if (!Z(i))
165
+ }, _ = async (t, e, i) => {
166
+ const o = typeof t == "function" ? await t() : t;
167
+ if (!W(o))
168
168
  throw new p(
169
- `Application "${e}" ${o} loader must return a valid SsrApplicationDefinition.`
169
+ `Application "${e}" ${i} loader must return a valid SsrApplicationDefinition.`
170
170
  );
171
- return X(i, e);
172
- }, Y = async (t, e, o, i) => {
171
+ return Z(o, e);
172
+ }, G = async (t, e, i, o) => {
173
173
  if (b(t)) {
174
- const n = i.root || process.cwd(), c = t.module.startsWith(".") ? S(n, t.module) : t.module, s = i.importModule ? await i.importModule(t.module) : await import(H(c).href), l = G(s, t.exportName, e, o);
175
- return _(l, e, o);
174
+ const n = o.root || process.cwd(), c = t.module.startsWith(".") ? S(n, t.module) : t.module, s = o.importModule ? await o.importModule(t.module) : await import(H(c).href), l = X(s, t.exportName, e, i);
175
+ return _(l, e, i);
176
176
  }
177
- return _(t, e, o);
178
- }, Q = (t) => {
177
+ return _(t, e, i);
178
+ }, Y = (t) => {
179
179
  if (!String(t.runtime || "").trim())
180
180
  throw new Error(
181
181
  'Production SSR config requires `runtime` (e.g. APP_RUNTIME). Refusing to default to "unified".'
182
182
  );
183
- for (const [e, o] of Object.entries(t.applications)) {
184
- if (!String(o.domain?.production || "").trim())
183
+ for (const [e, i] of Object.entries(t.applications)) {
184
+ if (!String(i.domain?.production || "").trim())
185
185
  throw new Error(
186
186
  `Application "${e}" requires domain.production in production.`
187
187
  );
188
- const i = o.publicConfig?.api;
189
- if (!String(i?.endpoint || "").trim())
188
+ const o = i.publicConfig?.api;
189
+ if (!String(o?.endpoint || "").trim())
190
190
  throw new Error(
191
191
  `Application "${e}" requires publicConfig.api.endpoint in production.`
192
192
  );
193
193
  }
194
- }, tt = async (t, e) => {
194
+ }, Q = async (t, e) => {
195
195
  if (e) return S(t, e);
196
- for (const o of C) {
197
- const i = S(t, o);
196
+ for (const i of C) {
197
+ const o = S(t, i);
198
198
  try {
199
- return await T(i), i;
199
+ return await T(o), o;
200
200
  } catch {
201
201
  }
202
202
  }
203
203
  throw new Error(
204
204
  `vue-ssr-lite could not find an SSR config in ${t}. Expected one of: ${C.join(", ")}`
205
205
  );
206
- }, et = (t) => {
206
+ }, tt = (t) => {
207
207
  const e = [];
208
- for (const [o, i] of Object.entries(t.applications || {})) {
209
- if (!i.render || !i.template)
208
+ for (const [i, o] of Object.entries(t.applications || {})) {
209
+ if (!o.render || !o.template)
210
210
  throw new Error(
211
- `Application "${o}" requires render and template in ssr.config.`
211
+ `Application "${i}" requires render and template in ssr.config.`
212
212
  );
213
- if (!b(i.application))
213
+ if (!b(o.application))
214
214
  throw new Error(
215
- `Application "${o}" must declare application: { module, exportName } so vueSsrLite() can generate the client entry.`
215
+ `Application "${i}" must declare application: { module, exportName } so vueSsrLite() can generate the client entry.`
216
216
  );
217
217
  e.push({
218
- id: o,
219
- kind: i.render,
220
- definition: i.application.module,
221
- exportName: i.application.exportName,
222
- template: i.template,
223
- mountSelector: i.mountSelector
218
+ id: i,
219
+ kind: o.render,
220
+ definition: o.application.module,
221
+ exportName: o.application.exportName,
222
+ template: o.template,
223
+ mountSelector: o.mountSelector
224
224
  });
225
225
  }
226
226
  if (!e.length)
227
227
  throw new Error("ssr.config must declare at least one application for Vite.");
228
228
  return { applications: e };
229
- }, ot = async (t, e) => {
230
- const o = await tt(t, e), c = (await (await import("esbuild")).build({
229
+ }, et = async (t, e) => {
230
+ const i = await Q(t, e), c = (await (await import("esbuild")).build({
231
231
  absWorkingDir: t,
232
- entryPoints: [o],
232
+ entryPoints: [i],
233
233
  bundle: !0,
234
234
  write: !1,
235
235
  platform: "node",
@@ -239,7 +239,7 @@ const J = (t, e) => {
239
239
  logLevel: "silent"
240
240
  })).outputFiles?.[0]?.text;
241
241
  if (!c)
242
- throw new Error(`Failed to bundle SSR config: ${o}`);
242
+ throw new Error(`Failed to bundle SSR config: ${i}`);
243
243
  const s = x(t, "node_modules", ".cache", "vue-ssr-lite");
244
244
  await I(s, { recursive: !0 });
245
245
  const l = x(
@@ -257,15 +257,15 @@ const J = (t, e) => {
257
257
  } finally {
258
258
  await D(l, { force: !0 });
259
259
  }
260
- }, St = async (t, e) => {
261
- const o = await ot(t, e);
262
- return et(o);
263
- }, gt = (t, e, o) => {
264
- const i = A(t, e), n = [
265
- `import __ssrUserConfig from ${JSON.stringify(i)}`
260
+ }, ht = async (t, e) => {
261
+ const i = await et(t, e);
262
+ return tt(i);
263
+ }, A = (t, e) => S(t, e).replaceAll("\\", "/"), St = (t, e, i) => {
264
+ const o = A(t, e), n = [
265
+ `import __ssrUserConfig from ${JSON.stringify(o)}`
266
266
  ], c = [];
267
- return o.forEach((s, l) => {
268
- const a = `__ssrApp${l}`, r = A(t, S(t, s.definition));
267
+ return i.forEach((s, l) => {
268
+ const a = `__ssrApp${l}`, r = A(t, s.definition);
269
269
  s.exportName ? n.push(
270
270
  `import { ${s.exportName} as ${a} } from ${JSON.stringify(r)}`
271
271
  ) : n.push(
@@ -291,16 +291,10 @@ const J = (t, e) => {
291
291
  ""
292
292
  ].join(`
293
293
  `);
294
- }, A = (t, e) => {
295
- const o = j(t, e).replaceAll("\\", "/");
296
- return o.startsWith(".") ? o : `./${o}`;
297
- }, wt = (t, e) => {
298
- const o = A(
299
- t,
300
- S(t, e.definition)
301
- ), i = e.exportName ? `import { ${e.exportName} as loadApplication } from ${JSON.stringify(o)}` : `import loadApplication from ${JSON.stringify(o)}`, n = e.mountSelector || "#app";
294
+ }, gt = (t, e) => {
295
+ const i = A(t, e.definition), o = e.exportName ? `import { ${e.exportName} as loadApplication } from ${JSON.stringify(i)}` : `import loadApplication from ${JSON.stringify(i)}`, n = e.mountSelector || "#app";
302
296
  return e.kind === "spa" ? [
303
- i,
297
+ o,
304
298
  "import { mountSpaApplication } from 'vue-ssr-lite/client'",
305
299
  "const definition = typeof loadApplication === 'function'",
306
300
  " ? await loadApplication()",
@@ -315,7 +309,7 @@ const J = (t, e) => {
315
309
  ""
316
310
  ].join(`
317
311
  `) : [
318
- i,
312
+ o,
319
313
  "import { hydrateSsrApplication } from 'vue-ssr-lite/client'",
320
314
  "const definition = typeof loadApplication === 'function'",
321
315
  " ? await loadApplication()",
@@ -330,14 +324,14 @@ const J = (t, e) => {
330
324
  ""
331
325
  ].join(`
332
326
  `);
333
- }, $t = async (t, e = {}) => {
334
- const i = t?.default ?? t, n = typeof i == "function" ? await i() : i;
327
+ }, wt = async (t, e = {}) => {
328
+ const o = t?.default ?? t, n = typeof o == "function" ? await o() : o;
335
329
  if (!n?.name || !n.applications || typeof n.applications != "object")
336
330
  throw new Error(
337
331
  "The SSR config module must export defineSsrConfig({ name, applications })."
338
332
  );
339
333
  const c = e.development ?? (typeof process < "u" ? process.env.NODE_ENV !== "production" : !0);
340
- c || Q(n);
334
+ c || Y(n);
341
335
  const s = Object.keys(n.applications);
342
336
  if (!s.length)
343
337
  throw new Error("SSR config requires at least one application.");
@@ -356,7 +350,7 @@ const J = (t, e) => {
356
350
  throw new p(
357
351
  `Application "${a}" render must be "spa" or "ssr".`
358
352
  );
359
- const d = r.render, M = b(r.application) ? r.application : void 0, N = d === "ssr" ? await Y(
353
+ const d = r.render, M = b(r.application) ? r.application : void 0, N = d === "ssr" ? await G(
360
354
  r.application,
361
355
  a,
362
356
  d,
@@ -393,7 +387,7 @@ const J = (t, e) => {
393
387
  }
394
388
  });
395
389
  }
396
- if (V(l), n.defaultApplicationId && !l.some((a) => a.id === n.defaultApplicationId))
390
+ if (U(l), n.defaultApplicationId && !l.some((a) => a.id === n.defaultApplicationId))
397
391
  throw new Error(
398
392
  `defaultApplicationId "${n.defaultApplicationId}" does not match an application.`
399
393
  );
@@ -421,26 +415,26 @@ const J = (t, e) => {
421
415
  publicConfig: {}
422
416
  }
423
417
  };
424
- }, g = "<!--vue-ssr-lite:head-->", w = "<!--vue-ssr-lite:teleports-->", $ = "<!--vue-ssr-lite:html-->", y = "<!--vue-ssr-lite:state-->", it = (t) => {
418
+ }, g = "<!--vue-ssr-lite:head-->", w = "<!--vue-ssr-lite:teleports-->", $ = "<!--vue-ssr-lite:html-->", y = "<!--vue-ssr-lite:state-->", ot = (t) => {
425
419
  if (!/^#[A-Za-z][A-Za-z0-9_-]*$/.test(t))
426
420
  throw new Error("vue-ssr-lite mountSelector must be a simple element id selector.");
427
421
  return t.slice(1);
428
- }, yt = (t, e = "#app") => {
429
- let o = t;
430
- if (o.includes(g) || (o = o.replace(/<\/head>/i, ` ${g}
431
- </head>`)), o.includes(w) || (o = o.replace(/<body([^>]*)>/i, `<body$1>${w}`)), !o.includes($)) {
432
- const i = it(e), n = new RegExp(
433
- `(<([A-Za-z][\\w-]*)\\b[^>]*\\bid=["']${i}["'][^>]*>)[\\s\\S]*?(<\\/\\2>)`,
422
+ }, $t = (t, e = "#app") => {
423
+ let i = t;
424
+ if (i.includes(g) || (i = i.replace(/<\/head>/i, ` ${g}
425
+ </head>`)), i.includes(w) || (i = i.replace(/<body([^>]*)>/i, `<body$1>${w}`)), !i.includes($)) {
426
+ const o = ot(e), n = new RegExp(
427
+ `(<([A-Za-z][\\w-]*)\\b[^>]*\\bid=["']${o}["'][^>]*>)[\\s\\S]*?(<\\/\\2>)`,
434
428
  "i"
435
429
  );
436
- if (!n.test(o))
430
+ if (!n.test(i))
437
431
  throw new Error(`SSR template is missing mount element ${e}.`);
438
- o = o.replace(n, `$1${$}$3`);
432
+ i = i.replace(n, `$1${$}$3`);
439
433
  }
440
- return o.includes(y) || (o = o.replace(/<\/body>/i, ` ${y}
441
- </body>`)), o;
442
- }, nt = (t, e) => e ? t.replace(/<html\b([^>]*)>/i, (o, i) => {
443
- let n = i;
434
+ return i.includes(y) || (i = i.replace(/<\/body>/i, ` ${y}
435
+ </body>`)), i;
436
+ }, it = (t, e) => e ? t.replace(/<html\b([^>]*)>/i, (i, o) => {
437
+ let n = o;
444
438
  for (const [c, s] of Object.entries(e)) {
445
439
  if (!/^[A-Za-z_:][A-Za-z0-9:._-]*$/.test(c)) continue;
446
440
  const l = new RegExp(
@@ -450,7 +444,7 @@ const J = (t, e) => {
450
444
  n = n.replace(l, ""), s != null && (n += ` ${c}="${u(s)}"`);
451
445
  }
452
446
  return `<html${n}>`;
453
- }) : t, At = (t, e) => {
447
+ }) : t, yt = (t, e) => {
454
448
  for (const c of [
455
449
  g,
456
450
  w,
@@ -459,36 +453,36 @@ const J = (t, e) => {
459
453
  ])
460
454
  if (!t.includes(c))
461
455
  throw new Error(`Transformed SSR template is missing marker ${c}.`);
462
- const o = L(e.applicationId), i = `<script id="${u(o)}" type="application/json">${q(e.state)}<\/script>`, n = e.head?.title ? t.replace(/<title\b[^>]*>[\s\S]*?<\/title>/i, "") : t;
463
- return nt(
464
- n.replace(g, B(e.head)).replace(w, e.teleports).replace($, e.html).replace(y, i),
456
+ const i = j(e.applicationId), o = `<script id="${u(i)}" type="application/json">${L(e.state)}<\/script>`, n = e.head?.title ? t.replace(/<title\b[^>]*>[\s\S]*?<\/title>/i, "") : t;
457
+ return it(
458
+ n.replace(g, q(e.head)).replace(w, e.teleports).replace($, e.html).replace(y, o),
465
459
  e.head?.htmlAttributes
466
460
  );
467
- }, vt = (t, e, o = "en") => `<!doctype html><html lang="${u(o)}"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1"><meta name="robots" content="noindex,nofollow"><title>${u(t)}</title></head><body><main id="main-content" style="min-height:70vh;display:grid;place-items:center;padding:2rem;text-align:center;font-family:system-ui,sans-serif" tabindex="-1"><div><h1>${u(t)}</h1><p>${u(e)}</p><p><a href="/">Return home</a></p></div></main></body></html>`;
461
+ }, At = (t, e, i = "en") => `<!doctype html><html lang="${u(i)}"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1"><meta name="robots" content="noindex,nofollow"><title>${u(t)}</title></head><body><main id="main-content" style="min-height:70vh;display:grid;place-items:center;padding:2rem;text-align:center;font-family:system-ui,sans-serif" tabindex="-1"><div><h1>${u(t)}</h1><p>${u(e)}</p><p><a href="/">Return home</a></p></div></main></body></html>`;
468
462
  export {
469
- mt as S,
470
- ht as a,
463
+ ut as S,
464
+ mt as a,
471
465
  g as b,
472
466
  $ as c,
473
467
  y as d,
474
468
  w as e,
475
469
  p as f,
476
- $t as g,
477
- et as h,
478
- ut as i,
479
- wt as j,
480
- gt as k,
481
- At as l,
470
+ wt as g,
471
+ tt as h,
472
+ ft as i,
473
+ gt as j,
474
+ St as k,
475
+ yt as l,
482
476
  b as m,
483
- ot as n,
477
+ et as n,
484
478
  J as o,
485
- yt as p,
486
- vt as q,
487
- tt as r,
488
- dt as s,
489
- ft as t,
490
- pt as u,
491
- St as v,
492
- U as w,
493
- V as x
479
+ $t as p,
480
+ At as q,
481
+ Q as r,
482
+ pt as s,
483
+ dt as t,
484
+ lt as u,
485
+ ht as v,
486
+ F as w,
487
+ U as x
494
488
  };
@@ -1,7 +1,7 @@
1
1
  import { createServer as ae } from "node:http";
2
2
  import { stat as J, readFile as q } from "node:fs/promises";
3
3
  import { resolve as z, sep as K, extname as ee } from "node:path";
4
- import { s as ie, q as W, u as ce, t as le, i as de, p as ue, l as he, g as me } from "./SsrHtmlRuntime-DW8Os5kA.mjs";
4
+ import { s as ie, q as W, u as ce, t as le, i as de, p as ue, l as he, g as me } from "./SsrHtmlRuntime-5FJMZjxW.mjs";
5
5
  import { c as fe, j as pe, r as ge } from "./SsrApplicationRuntime-CKjoPpvD.mjs";
6
6
  import { renderToString as ye } from "@vue/server-renderer";
7
7
  import { c as we } from "./SsrDiagnosticsRuntime-B5VbSgsA.mjs";
package/dist/cli.mjs CHANGED
@@ -1,8 +1,8 @@
1
1
  #!/usr/bin/env node
2
2
  import { resolve as c } from "node:path";
3
3
  import { pathToFileURL as f } from "node:url";
4
- import { r as w, S as u } from "./chunks/SsrHtmlRuntime-DW8Os5kA.mjs";
5
- import { c as S } from "./chunks/SsrServerRuntime-Cheg50nG.mjs";
4
+ import { r as w, S as u } from "./chunks/SsrHtmlRuntime-5FJMZjxW.mjs";
5
+ import { c as S } from "./chunks/SsrServerRuntime-BJ2NQFEl.mjs";
6
6
  import { createServer as R } from "node:net";
7
7
  const i = 1, a = 65535, b = (r) => {
8
8
  const e = r?.trim();
package/dist/server.mjs CHANGED
@@ -1,5 +1,5 @@
1
- import { c as H, a as v, i as _, r as T, b as A, d as M } from "./chunks/SsrServerRuntime-Cheg50nG.mjs";
2
- import { a as I, b as $, c as P, S as D, d as U, e as L, f as N, g as X, h as K, i as V, j, k, l as z, m as B, n as O, o as Y, p as G, q as J, r as Q, s as W, t as Z, u as q, v as rr, w as er, x as tr } from "./chunks/SsrHtmlRuntime-DW8Os5kA.mjs";
1
+ import { c as H, a as v, i as _, r as T, b as A, d as M } from "./chunks/SsrServerRuntime-BJ2NQFEl.mjs";
2
+ import { a as I, b as $, c as P, S as D, d as U, e as L, f as N, g as X, h as K, i as V, j, k, l as z, m as B, n as O, o as Y, p as G, q as J, r as Q, s as W, t as Z, u as q, v as rr, w as er, x as tr } from "./chunks/SsrHtmlRuntime-5FJMZjxW.mjs";
3
3
  import { n as m } from "./chunks/SsrSerialization-DeKozeIm.mjs";
4
4
  import { a as or, d as ar } from "./chunks/SsrSerialization-DeKozeIm.mjs";
5
5
  import { S as ir, b as cr, d as dr, i as lr, r as Sr, u as mr } from "./chunks/SsrApplicationRuntime-CKjoPpvD.mjs";
package/dist/vite.mjs CHANGED
@@ -1,6 +1,6 @@
1
1
  import { resolve as c } from "node:path";
2
2
  import { normalizePath as E } from "vite";
3
- import { r as S, k as w, a as p, S as R, v as y, p as h, j as _ } from "./chunks/SsrHtmlRuntime-DW8Os5kA.mjs";
3
+ import { r as S, k as w, a as p, S as R, v as y, p as h, j as _ } from "./chunks/SsrHtmlRuntime-5FJMZjxW.mjs";
4
4
  const $ = [
5
5
  "@vue/server-renderer",
6
6
  "vue",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vue-ssr-lite",
3
- "version": "0.2.6",
3
+ "version": "0.2.7",
4
4
  "description": "Vue 3 SSR runtime with routing, generic plugin hydration, Vite, and Node server lifecycle.",
5
5
  "license": "MIT",
6
6
  "type": "module",