vue-ssr-lite 0.2.2 → 0.2.4
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/README.md +29 -45
- package/dist/SsrConfigCompileRuntime.d.ts +40 -4
- package/dist/SsrConfigCompileRuntime.d.ts.map +1 -1
- package/dist/SsrConfigTypes.d.ts +20 -4
- package/dist/SsrConfigTypes.d.ts.map +1 -1
- package/dist/chunks/SsrHtmlRuntime-BiQCklqA.mjs +446 -0
- package/dist/chunks/SsrServerRuntime-CkEnx8IY.mjs +703 -0
- package/dist/cli.mjs +10 -9
- package/dist/server/SsrServerRuntime.d.ts.map +1 -1
- package/dist/server.mjs +78 -73
- package/dist/vite/SsrVitePlugin.d.ts +11 -9
- package/dist/vite/SsrVitePlugin.d.ts.map +1 -1
- package/dist/vite.mjs +63 -48
- package/package.json +1 -1
- package/dist/chunks/SsrHtmlRuntime-cTFsMSAZ.mjs +0 -54
- package/dist/chunks/SsrServerRuntime-D7cDSFNm.mjs +0 -1004
|
@@ -0,0 +1,446 @@
|
|
|
1
|
+
import { access as D, mkdtemp as I, writeFile as k, rm as q } from "node:fs/promises";
|
|
2
|
+
import { tmpdir as L } from "node:os";
|
|
3
|
+
import { resolve as A, join as H } from "node:path";
|
|
4
|
+
import { pathToFileURL as z } from "node:url";
|
|
5
|
+
import { e as m, g as j, a as B, r as W } from "./SsrSerialization-k-3aCFYt.mjs";
|
|
6
|
+
const b = (t) => String(Array.isArray(t) ? t[0] : t || "").split(",", 1)[0].trim(), F = 1e6;
|
|
7
|
+
class p extends Error {
|
|
8
|
+
constructor(e) {
|
|
9
|
+
super(e), this.name = "SsrHostConfigurationError";
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
const w = (t) => {
|
|
13
|
+
const e = b(t);
|
|
14
|
+
if (!e || e.length > 512 || /[\u0000-\u0020\u007f]/.test(e) || /[\\/@?#]/.test(e))
|
|
15
|
+
return "";
|
|
16
|
+
try {
|
|
17
|
+
const o = e.includes(":") && e.split(":").length > 2 && !e.startsWith("[") ? `[${e}]` : e, n = new URL(`http://${o}`);
|
|
18
|
+
if (n.username || n.password || n.pathname !== "/" || n.search || n.hash)
|
|
19
|
+
return "";
|
|
20
|
+
const s = n.hostname.toLowerCase().replace(/\.$/, "");
|
|
21
|
+
return s ? `${s.includes(":") && !s.startsWith("[") ? `[${s}]` : s}${n.port ? `:${n.port}` : ""}` : "";
|
|
22
|
+
} catch {
|
|
23
|
+
return "";
|
|
24
|
+
}
|
|
25
|
+
}, f = (t) => {
|
|
26
|
+
const e = w(t);
|
|
27
|
+
if (!e) return "";
|
|
28
|
+
if (e.startsWith("[")) {
|
|
29
|
+
const o = e.indexOf("]");
|
|
30
|
+
return o > 0 ? e.slice(1, o) : "";
|
|
31
|
+
}
|
|
32
|
+
return e.replace(/:\d+$/, "");
|
|
33
|
+
}, E = (t) => {
|
|
34
|
+
const e = t.trim().toLowerCase();
|
|
35
|
+
if (e === "*") return "*";
|
|
36
|
+
if (e.startsWith("*.")) {
|
|
37
|
+
const o = f(e.slice(2));
|
|
38
|
+
return o && !o.includes(":") && !o.includes("*") ? `*.${o}` : "";
|
|
39
|
+
}
|
|
40
|
+
return w(e);
|
|
41
|
+
}, N = (t, e) => {
|
|
42
|
+
const o = f(t), n = E(e);
|
|
43
|
+
return !o || !n ? !1 : n === "*" ? !0 : n.startsWith("*.") ? o.endsWith(`.${n.slice(2)}`) : w(t) === n || o === f(n);
|
|
44
|
+
}, V = (t, e) => {
|
|
45
|
+
const o = f(t), n = E(e);
|
|
46
|
+
if (!o || !n || !N(t, n)) return null;
|
|
47
|
+
if (n === "*")
|
|
48
|
+
return { category: "catch-all", specificity: 0, pattern: n };
|
|
49
|
+
if (n.startsWith("*."))
|
|
50
|
+
return {
|
|
51
|
+
category: "wildcard",
|
|
52
|
+
specificity: n.slice(2).length,
|
|
53
|
+
pattern: n
|
|
54
|
+
};
|
|
55
|
+
const s = f(n);
|
|
56
|
+
return {
|
|
57
|
+
category: "exact",
|
|
58
|
+
specificity: F + s.length,
|
|
59
|
+
pattern: n
|
|
60
|
+
};
|
|
61
|
+
}, K = (t) => {
|
|
62
|
+
const e = /* @__PURE__ */ new Map(), o = [];
|
|
63
|
+
for (const n of t) {
|
|
64
|
+
const s = n.hosts ?? [];
|
|
65
|
+
if (!s.length)
|
|
66
|
+
throw new p(
|
|
67
|
+
`SSR application "${n.id}" requires at least one host pattern.`
|
|
68
|
+
);
|
|
69
|
+
const a = /* @__PURE__ */ new Set();
|
|
70
|
+
for (const c of s) {
|
|
71
|
+
const l = String(c ?? "").trim();
|
|
72
|
+
if (!l)
|
|
73
|
+
throw new p(
|
|
74
|
+
`SSR application "${n.id}" contains an empty host pattern.`
|
|
75
|
+
);
|
|
76
|
+
if (/^[a-z][a-z0-9+.-]*:\/\//i.test(l) || /[/?#]/.test(l))
|
|
77
|
+
throw new p(
|
|
78
|
+
`SSR application "${n.id}" host pattern "${c}" must not include a protocol, path, or query.`
|
|
79
|
+
);
|
|
80
|
+
const i = E(l);
|
|
81
|
+
if (!i)
|
|
82
|
+
throw new p(
|
|
83
|
+
`SSR application "${n.id}" has an invalid host pattern "${c}". Use an exact hostname, *.example.com, or *.`
|
|
84
|
+
);
|
|
85
|
+
if (i !== "*" && (i.startsWith("[") ? /\]:\d+$/.test(i) : /:\d+$/.test(i)))
|
|
86
|
+
throw new p(
|
|
87
|
+
`SSR application "${n.id}" host pattern "${c}" must not include a port.`
|
|
88
|
+
);
|
|
89
|
+
if (a.has(i)) continue;
|
|
90
|
+
if (a.add(i), i === "*") {
|
|
91
|
+
o.push(n.id);
|
|
92
|
+
continue;
|
|
93
|
+
}
|
|
94
|
+
const d = e.get(i);
|
|
95
|
+
if (d && d !== n.id)
|
|
96
|
+
throw new p(
|
|
97
|
+
`Host pattern "${i}" is assigned to both "${d}" and "${n.id}".`
|
|
98
|
+
);
|
|
99
|
+
e.set(i, n.id);
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
if (o.length > 1)
|
|
103
|
+
throw new p(
|
|
104
|
+
`Multiple catch-all ("*") host applications are not allowed (applications: ${o.join(", ")}).`
|
|
105
|
+
);
|
|
106
|
+
}, ct = (t, e, o) => {
|
|
107
|
+
const n = f(e);
|
|
108
|
+
if (!n) return null;
|
|
109
|
+
let s = null;
|
|
110
|
+
for (const c of t)
|
|
111
|
+
for (const l of c.hosts ?? []) {
|
|
112
|
+
const i = V(e, l);
|
|
113
|
+
if (!i) continue;
|
|
114
|
+
const r = {
|
|
115
|
+
entry: c,
|
|
116
|
+
matchedPattern: i.pattern,
|
|
117
|
+
normalizedHostname: n,
|
|
118
|
+
category: i.category,
|
|
119
|
+
specificity: i.specificity
|
|
120
|
+
};
|
|
121
|
+
if (!s || r.specificity > s.specificity) {
|
|
122
|
+
s = r;
|
|
123
|
+
continue;
|
|
124
|
+
}
|
|
125
|
+
r.specificity < s.specificity || r.entry.id < s.entry.id && (s = r);
|
|
126
|
+
}
|
|
127
|
+
if (s) return s;
|
|
128
|
+
if (!o) return null;
|
|
129
|
+
const a = t.find(
|
|
130
|
+
(c) => c.id === o
|
|
131
|
+
);
|
|
132
|
+
return a ? {
|
|
133
|
+
entry: a,
|
|
134
|
+
matchedPattern: null,
|
|
135
|
+
normalizedHostname: n,
|
|
136
|
+
category: "default",
|
|
137
|
+
specificity: -1
|
|
138
|
+
} : null;
|
|
139
|
+
}, lt = (t, e, o = !1) => w(o && b(t) || e), pt = (t, e, o = !1) => {
|
|
140
|
+
if (!o) return e;
|
|
141
|
+
const n = b(t).toLowerCase();
|
|
142
|
+
return n === "http" || n === "https" ? n : e;
|
|
143
|
+
}, P = /^[!#$%&'*+.^_`|~0-9A-Za-z-]+$/, dt = (t, e = [], o = []) => {
|
|
144
|
+
const n = new Set(e.filter((c) => P.test(c))), s = new Set(o.filter((c) => P.test(c)));
|
|
145
|
+
if (!t || n.size === 0) return;
|
|
146
|
+
const a = String(t).split(";").map((c) => c.trim()).filter(Boolean).filter((c) => {
|
|
147
|
+
const l = c.indexOf("=");
|
|
148
|
+
if (l <= 0) return !1;
|
|
149
|
+
const i = c.slice(0, l).trim();
|
|
150
|
+
return n.has(i) && !s.has(i);
|
|
151
|
+
});
|
|
152
|
+
return a.length ? a.join("; ") : void 0;
|
|
153
|
+
}, Z = ["localhost", "127.0.0.1", "0.0.0.0", "::1"], _ = [
|
|
154
|
+
"ssr.config.ts",
|
|
155
|
+
"ssr.config.mts",
|
|
156
|
+
"ssr.config.js",
|
|
157
|
+
"ssr.config.mjs"
|
|
158
|
+
], x = (t) => !!(t && typeof t == "object" && "module" in t && typeof t.module == "string" && !("id" in t && "rootComponent" in t)), h = (t, e) => {
|
|
159
|
+
const o = f(w(t) || t);
|
|
160
|
+
if (!o || o.includes("/") || o.includes("?"))
|
|
161
|
+
throw new p(
|
|
162
|
+
`${e} must be a valid hostname without a protocol, path, or port.`
|
|
163
|
+
);
|
|
164
|
+
return o.replace(/^\[|\]$/g, "");
|
|
165
|
+
}, u = (t, e) => {
|
|
166
|
+
t.includes(e) || t.push(e);
|
|
167
|
+
}, U = (t, e) => {
|
|
168
|
+
const o = t.mode ?? "root-and-subdomains", n = h(
|
|
169
|
+
e ? t.development : t.production,
|
|
170
|
+
e ? "domain.development" : "domain.production"
|
|
171
|
+
), s = [];
|
|
172
|
+
if ((o === "root" || o === "root-and-subdomains") && u(s, n), (o === "subdomains" || o === "root-and-subdomains") && u(s, `*.${n}`), e) {
|
|
173
|
+
const a = h(
|
|
174
|
+
t.production,
|
|
175
|
+
"domain.production"
|
|
176
|
+
);
|
|
177
|
+
if (a !== n && ((o === "root" || o === "root-and-subdomains") && u(s, a), (o === "subdomains" || o === "root-and-subdomains") && u(s, `*.${a}`)), t.localAliases)
|
|
178
|
+
for (const c of Z) u(s, c);
|
|
179
|
+
}
|
|
180
|
+
for (const a of t.additionalHosts ?? [])
|
|
181
|
+
u(s, h(a, "domain.additionalHosts"));
|
|
182
|
+
if (t.customDomains && u(s, "*"), !s.length)
|
|
183
|
+
throw new p(
|
|
184
|
+
"Application domain configuration produced an empty host list."
|
|
185
|
+
);
|
|
186
|
+
return s;
|
|
187
|
+
}, M = (t) => t == null ? [] : Array.isArray(t) ? t.map((e) => String(e).trim()).filter(Boolean) : String(t).split(",").map((e) => e.trim()).filter(Boolean), J = (t, e, o, n) => {
|
|
188
|
+
const s = e ? t[e] : t.default;
|
|
189
|
+
if (!s?.id || !s.rootComponent)
|
|
190
|
+
throw new p(
|
|
191
|
+
`Application "${o}" ${n} module must export a valid SsrApplicationDefinition${e ? ` as "${e}"` : " (default)"}.`
|
|
192
|
+
);
|
|
193
|
+
return s;
|
|
194
|
+
}, G = async (t, e, o) => {
|
|
195
|
+
if (!t) return;
|
|
196
|
+
const n = typeof t == "function" ? await t() : t;
|
|
197
|
+
if (!n?.id || !n.rootComponent)
|
|
198
|
+
throw new p(
|
|
199
|
+
`Application "${e}" ${o} loader must return a valid SsrApplicationDefinition.`
|
|
200
|
+
);
|
|
201
|
+
return n;
|
|
202
|
+
}, X = async (t, e, o, n) => {
|
|
203
|
+
if (t) {
|
|
204
|
+
if (x(t)) {
|
|
205
|
+
const s = n.root || process.cwd(), a = t.module.startsWith(".") ? A(s, t.module) : t.module, c = n.importModule ? await n.importModule(t.module) : await import(z(a).href);
|
|
206
|
+
return J(c, t.exportName, e, o);
|
|
207
|
+
}
|
|
208
|
+
return G(t, e, o);
|
|
209
|
+
}
|
|
210
|
+
}, Y = async (t, e) => {
|
|
211
|
+
if (e) return A(t, e);
|
|
212
|
+
for (const o of _) {
|
|
213
|
+
const n = A(t, o);
|
|
214
|
+
try {
|
|
215
|
+
return await D(n), n;
|
|
216
|
+
} catch {
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
throw new Error(
|
|
220
|
+
`vue-ssr-lite could not find an SSR config in ${t}. Expected one of: ${_.join(", ")}`
|
|
221
|
+
);
|
|
222
|
+
}, Q = (t) => {
|
|
223
|
+
const e = [], o = {};
|
|
224
|
+
for (const [n, s] of Object.entries(t.applications || {})) {
|
|
225
|
+
if (s.ssr !== void 0) {
|
|
226
|
+
if (!x(s.ssr))
|
|
227
|
+
throw new Error(
|
|
228
|
+
`Application "${n}" must declare ssr: { module, exportName } so vueSsrLite() can derive the client entry from ssr.config.`
|
|
229
|
+
);
|
|
230
|
+
e.push({
|
|
231
|
+
id: n,
|
|
232
|
+
definition: s.ssr.module,
|
|
233
|
+
exportName: s.ssr.exportName,
|
|
234
|
+
template: s.template,
|
|
235
|
+
mountSelector: s.mountSelector
|
|
236
|
+
});
|
|
237
|
+
continue;
|
|
238
|
+
}
|
|
239
|
+
s.spa !== void 0 && (o[n] = s.template);
|
|
240
|
+
}
|
|
241
|
+
if (!e.length && !Object.keys(o).length)
|
|
242
|
+
throw new Error(
|
|
243
|
+
"ssr.config must declare at least one spa or ssr application for Vite."
|
|
244
|
+
);
|
|
245
|
+
return { applications: e, spaEntries: o };
|
|
246
|
+
}, tt = async (t, e) => {
|
|
247
|
+
const o = await Y(t, e), a = (await (await import("esbuild")).build({
|
|
248
|
+
absWorkingDir: t,
|
|
249
|
+
entryPoints: [o],
|
|
250
|
+
bundle: !0,
|
|
251
|
+
write: !1,
|
|
252
|
+
platform: "node",
|
|
253
|
+
format: "esm",
|
|
254
|
+
target: "node20",
|
|
255
|
+
packages: "external",
|
|
256
|
+
logLevel: "silent"
|
|
257
|
+
})).outputFiles?.[0]?.text;
|
|
258
|
+
if (!a)
|
|
259
|
+
throw new Error(`Failed to bundle SSR config: ${o}`);
|
|
260
|
+
const c = await I(H(L(), "vue-ssr-lite-config-")), l = H(c, "ssr.config.mjs");
|
|
261
|
+
try {
|
|
262
|
+
await k(l, a, "utf8");
|
|
263
|
+
const i = await import(z(l).href), r = i.default ?? i, d = typeof r == "function" ? await r() : r;
|
|
264
|
+
if (!d?.name || !d.applications)
|
|
265
|
+
throw new Error(
|
|
266
|
+
"The SSR config module must export defineSsrConfig({ name, applications })."
|
|
267
|
+
);
|
|
268
|
+
return d;
|
|
269
|
+
} finally {
|
|
270
|
+
await q(c, { recursive: !0, force: !0 });
|
|
271
|
+
}
|
|
272
|
+
}, ut = async (t, e) => {
|
|
273
|
+
const o = await tt(t, e);
|
|
274
|
+
return Q(o);
|
|
275
|
+
}, ft = (t, e) => {
|
|
276
|
+
if (!/ssr\.config\.(m?ts|m?js)$/.test(e.replaceAll("\\", "/")) || !/\bssr\s*:\s*\{/.test(t) || !/\bmodule\s*:/.test(t))
|
|
277
|
+
return null;
|
|
278
|
+
const o = t.replace(
|
|
279
|
+
/ssr\s*:\s*\{\s*module\s*:\s*(['"])(.+?)\1\s*(?:,\s*exportName\s*:\s*(['"])(.+?)\3\s*)?,?\s*\}/g,
|
|
280
|
+
(n, s, a, c, l) => {
|
|
281
|
+
const i = l ? `m[${JSON.stringify(l)}]` : "m.default";
|
|
282
|
+
return `ssr: () => import(${JSON.stringify(a)}).then((m) => ${i})`;
|
|
283
|
+
}
|
|
284
|
+
);
|
|
285
|
+
return o === t ? null : o;
|
|
286
|
+
}, mt = async (t, e = {}) => {
|
|
287
|
+
const n = t?.default ?? t, s = typeof n == "function" ? await n() : n;
|
|
288
|
+
if (!s?.name || !s.applications || typeof s.applications != "object")
|
|
289
|
+
throw new Error(
|
|
290
|
+
"The SSR config module must export defineSsrConfig({ name, applications })."
|
|
291
|
+
);
|
|
292
|
+
const a = e.development ?? (typeof process < "u" ? process.env.NODE_ENV !== "production" : !0), c = Object.keys(s.applications);
|
|
293
|
+
if (!c.length)
|
|
294
|
+
throw new Error("SSR config requires at least one application.");
|
|
295
|
+
const l = [];
|
|
296
|
+
for (const i of c) {
|
|
297
|
+
const r = s.applications[i];
|
|
298
|
+
if (!r?.template || !r.domain)
|
|
299
|
+
throw new p(
|
|
300
|
+
`Application "${i}" requires template and domain configuration.`
|
|
301
|
+
);
|
|
302
|
+
const d = r.spa !== void 0, S = r.ssr !== void 0;
|
|
303
|
+
if (!d && !S)
|
|
304
|
+
throw new p(
|
|
305
|
+
`Application "${i}" requires spa or ssr.`
|
|
306
|
+
);
|
|
307
|
+
if (d && S)
|
|
308
|
+
throw new p(
|
|
309
|
+
`Application "${i}" cannot declare both spa and ssr.`
|
|
310
|
+
);
|
|
311
|
+
const R = S ? "ssr" : "spa", O = x(r.ssr) ? r.ssr : void 0, T = S ? await X(r.ssr, i, R, e) : void 0, C = {
|
|
312
|
+
...r.publicConfig || {}
|
|
313
|
+
};
|
|
314
|
+
r.graphql && (C.graphql = {
|
|
315
|
+
endpoint: r.graphql.endpoint,
|
|
316
|
+
timeout: r.graphql.timeout ?? 8e3
|
|
317
|
+
}), l.push({
|
|
318
|
+
id: i,
|
|
319
|
+
kind: R,
|
|
320
|
+
template: r.template,
|
|
321
|
+
hosts: U(r.domain, a),
|
|
322
|
+
roles: r.roles ? [...r.roles] : void 0,
|
|
323
|
+
application: T,
|
|
324
|
+
mountSelector: r.mountSelector,
|
|
325
|
+
cacheControl: r.cacheControl,
|
|
326
|
+
responseCache: r.responseCache,
|
|
327
|
+
endpoints: r.endpoints ? [...r.endpoints] : [],
|
|
328
|
+
cookieAllowlist: M(r.cookies?.allow),
|
|
329
|
+
cookieDenylist: M(r.cookies?.deny),
|
|
330
|
+
publicConfig: C,
|
|
331
|
+
ssrModule: O,
|
|
332
|
+
domain: {
|
|
333
|
+
development: h(
|
|
334
|
+
r.domain.development,
|
|
335
|
+
`${i}.domain.development`
|
|
336
|
+
),
|
|
337
|
+
production: h(
|
|
338
|
+
r.domain.production,
|
|
339
|
+
`${i}.domain.production`
|
|
340
|
+
),
|
|
341
|
+
mode: r.domain.mode ?? "root-and-subdomains",
|
|
342
|
+
localAliases: !!r.domain.localAliases,
|
|
343
|
+
customDomains: !!r.domain.customDomains,
|
|
344
|
+
expose: r.domain.expose
|
|
345
|
+
}
|
|
346
|
+
});
|
|
347
|
+
}
|
|
348
|
+
if (K(l), s.defaultApplicationId && !l.some((i) => i.id === s.defaultApplicationId))
|
|
349
|
+
throw new Error(
|
|
350
|
+
`defaultApplicationId "${s.defaultApplicationId}" does not match an application.`
|
|
351
|
+
);
|
|
352
|
+
return {
|
|
353
|
+
name: s.name,
|
|
354
|
+
applications: l,
|
|
355
|
+
defaultApplicationId: s.defaultApplicationId,
|
|
356
|
+
development: a,
|
|
357
|
+
readiness: s.readiness,
|
|
358
|
+
server: {
|
|
359
|
+
root: s.server?.root ?? e.root,
|
|
360
|
+
host: s.server?.host,
|
|
361
|
+
port: s.server?.port,
|
|
362
|
+
role: s.runtime,
|
|
363
|
+
trustProxy: s.server?.trustProxy,
|
|
364
|
+
clientOutDir: s.server?.clientOutDir,
|
|
365
|
+
requestTimeoutMs: s.server?.requestTimeoutMs,
|
|
366
|
+
shutdownTimeoutMs: s.server?.shutdownTimeoutMs,
|
|
367
|
+
healthPath: s.server?.healthPath,
|
|
368
|
+
readinessPath: s.server?.readinessPath,
|
|
369
|
+
maxResolutionPasses: s.server?.maxResolutionPasses,
|
|
370
|
+
resolutionDeadlineMs: s.server?.resolutionDeadlineMs,
|
|
371
|
+
diagnostics: s.server?.diagnostics,
|
|
372
|
+
logger: s.server?.logger,
|
|
373
|
+
publicConfig: {}
|
|
374
|
+
}
|
|
375
|
+
};
|
|
376
|
+
}, g = "<!--vue-ssr-lite:head-->", y = "<!--vue-ssr-lite:teleports-->", $ = "<!--vue-ssr-lite:html-->", v = "<!--vue-ssr-lite:state-->", et = (t) => {
|
|
377
|
+
if (!/^#[A-Za-z][A-Za-z0-9_-]*$/.test(t))
|
|
378
|
+
throw new Error("vue-ssr-lite mountSelector must be a simple element id selector.");
|
|
379
|
+
return t.slice(1);
|
|
380
|
+
}, ht = (t, e = "#app") => {
|
|
381
|
+
let o = t;
|
|
382
|
+
if (o.includes(g) || (o = o.replace(/<\/head>/i, ` ${g}
|
|
383
|
+
</head>`)), o.includes(y) || (o = o.replace(/<body([^>]*)>/i, `<body$1>${y}`)), !o.includes($)) {
|
|
384
|
+
const n = et(e), s = new RegExp(
|
|
385
|
+
`(<([A-Za-z][\\w-]*)\\b[^>]*\\bid=["']${n}["'][^>]*>)[\\s\\S]*?(<\\/\\2>)`,
|
|
386
|
+
"i"
|
|
387
|
+
);
|
|
388
|
+
if (!s.test(o))
|
|
389
|
+
throw new Error(`SSR template is missing mount element ${e}.`);
|
|
390
|
+
o = o.replace(s, `$1${$}$3`);
|
|
391
|
+
}
|
|
392
|
+
return o.includes(v) || (o = o.replace(/<\/body>/i, ` ${v}
|
|
393
|
+
</body>`)), o;
|
|
394
|
+
}, ot = (t, e) => e ? t.replace(/<html\b([^>]*)>/i, (o, n) => {
|
|
395
|
+
let s = n;
|
|
396
|
+
for (const [a, c] of Object.entries(e)) {
|
|
397
|
+
if (!/^[A-Za-z_:][A-Za-z0-9:._-]*$/.test(a)) continue;
|
|
398
|
+
const l = new RegExp(
|
|
399
|
+
`\\s${a.replace(/[.:_-]/g, "\\$&")}(?:\\s*=\\s*(?:"[^"]*"|'[^']*'|[^\\s>]+))?`,
|
|
400
|
+
"i"
|
|
401
|
+
);
|
|
402
|
+
s = s.replace(l, ""), c != null && (s += ` ${a}="${m(c)}"`);
|
|
403
|
+
}
|
|
404
|
+
return `<html${s}>`;
|
|
405
|
+
}) : t, wt = (t, e) => {
|
|
406
|
+
for (const a of [
|
|
407
|
+
g,
|
|
408
|
+
y,
|
|
409
|
+
$,
|
|
410
|
+
v
|
|
411
|
+
])
|
|
412
|
+
if (!t.includes(a))
|
|
413
|
+
throw new Error(`Transformed SSR template is missing marker ${a}.`);
|
|
414
|
+
const o = j(e.applicationId), n = `<script id="${m(o)}" type="application/json">${B(e.state)}<\/script>`, s = e.head?.title ? t.replace(/<title\b[^>]*>[\s\S]*?<\/title>/i, "") : t;
|
|
415
|
+
return ot(
|
|
416
|
+
s.replace(g, W(e.head)).replace(y, e.teleports).replace($, e.html).replace(v, n),
|
|
417
|
+
e.head?.htmlAttributes
|
|
418
|
+
);
|
|
419
|
+
}, St = (t, e, o = "en") => `<!doctype html><html lang="${m(o)}"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1"><meta name="robots" content="noindex,nofollow"><title>${m(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>${m(t)}</h1><p>${m(e)}</p><p><a href="/">Return home</a></p></div></main></body></html>`;
|
|
420
|
+
export {
|
|
421
|
+
g as S,
|
|
422
|
+
$ as a,
|
|
423
|
+
v as b,
|
|
424
|
+
y as c,
|
|
425
|
+
p as d,
|
|
426
|
+
mt as e,
|
|
427
|
+
Q as f,
|
|
428
|
+
dt as g,
|
|
429
|
+
x as h,
|
|
430
|
+
wt as i,
|
|
431
|
+
E as j,
|
|
432
|
+
St as k,
|
|
433
|
+
tt as l,
|
|
434
|
+
N as m,
|
|
435
|
+
w as n,
|
|
436
|
+
lt as o,
|
|
437
|
+
ht as p,
|
|
438
|
+
pt as q,
|
|
439
|
+
Y as r,
|
|
440
|
+
ct as s,
|
|
441
|
+
ut as t,
|
|
442
|
+
V as u,
|
|
443
|
+
f as v,
|
|
444
|
+
ft as w,
|
|
445
|
+
K as x
|
|
446
|
+
};
|