vue-ssr-lite 0.2.6 → 0.2.9
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 +5 -1
- package/dist/SsrConfigCompileRuntime.d.ts.map +1 -1
- package/dist/chunks/{SsrHtmlRuntime-DW8Os5kA.mjs → SsrHtmlRuntime-mGcv3_Vb.mjs} +145 -151
- package/dist/chunks/{SsrServerRuntime-Cheg50nG.mjs → SsrServerRuntime-Bay4EOOR.mjs} +1 -1
- package/dist/cli.mjs +2 -2
- package/dist/server.mjs +2 -2
- package/dist/vite.mjs +1 -1
- package/package.json +1 -1
|
@@ -63,8 +63,12 @@ export declare const extractSsrViteEntries: (config: SsrConfig) => SsrViteEntrie
|
|
|
63
63
|
export declare const loadSsrConfigFile: (root: string, configPath?: string) => Promise<SsrConfig>;
|
|
64
64
|
export declare const resolveSsrViteEntries: (root: string, configPath?: string) => Promise<SsrViteEntries>;
|
|
65
65
|
/**
|
|
66
|
-
* Generate a Vite-analyzable runtime module that imports each application
|
|
66
|
+
* Generate a Vite-analyzable runtime module that imports each SSR application
|
|
67
67
|
* module statically and merges it into the user `ssr.config` export.
|
|
68
|
+
*
|
|
69
|
+
* SPA modules are intentionally omitted: the Node server only needs host /
|
|
70
|
+
* template metadata for them. Eagerly importing SPA apps would execute their
|
|
71
|
+
* client-side module side effects (shared registries, etc.) in the SSR process.
|
|
68
72
|
*/
|
|
69
73
|
export declare const generateSsrRuntimeModule: (root: string, configPath: string, entries: SsrViteApplicationEntry[]) => string;
|
|
70
74
|
export declare const generateSsrClientModule: (root: string, entry: SsrViteApplicationEntry) => string;
|
|
@@ -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,aAA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A;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;;;;;;;GAOG;AACH,eAAO,MAAM,wBAAwB,GACnC,MAAM,MAAM,EACZ,YAAY,MAAM,EAClB,SAAS,uBAAuB,EAAE,KACjC,MA0CF,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
|
|
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
|
|
6
|
-
const O = (t) => String(Array.isArray(t) ? t[0] : t || "").split(",", 1)[0].trim(),
|
|
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
|
|
14
|
-
return !
|
|
15
|
-
},
|
|
16
|
-
const
|
|
17
|
-
if (!
|
|
18
|
-
if (
|
|
19
|
-
return { category: "catch-all", specificity: 0, pattern:
|
|
20
|
-
if (
|
|
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:
|
|
24
|
-
pattern:
|
|
23
|
+
specificity: o.slice(2).length,
|
|
24
|
+
pattern: o
|
|
25
25
|
};
|
|
26
|
-
const n = m(
|
|
26
|
+
const n = m(o);
|
|
27
27
|
return {
|
|
28
28
|
category: "exact",
|
|
29
|
-
specificity:
|
|
30
|
-
pattern:
|
|
29
|
+
specificity: B + n.length,
|
|
30
|
+
pattern: o
|
|
31
31
|
};
|
|
32
|
-
},
|
|
33
|
-
const e = /* @__PURE__ */ new Map(),
|
|
34
|
-
for (const
|
|
35
|
-
const n =
|
|
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 "${
|
|
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 "${
|
|
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 "${
|
|
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 "${
|
|
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 "${
|
|
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
|
-
|
|
62
|
+
i.push(o.id);
|
|
63
63
|
continue;
|
|
64
64
|
}
|
|
65
65
|
const d = e.get(a);
|
|
66
|
-
if (d && d !==
|
|
66
|
+
if (d && d !== o.id)
|
|
67
67
|
throw new p(
|
|
68
|
-
`Host pattern "${a}" is assigned to both "${d}" and "${
|
|
68
|
+
`Host pattern "${a}" is assigned to both "${d}" and "${o.id}".`
|
|
69
69
|
);
|
|
70
|
-
e.set(a,
|
|
70
|
+
e.set(a, o.id);
|
|
71
71
|
}
|
|
72
72
|
}
|
|
73
|
-
if (
|
|
73
|
+
if (i.length > 1)
|
|
74
74
|
throw new p(
|
|
75
|
-
`Multiple catch-all ("*") host applications are not allowed (applications: ${
|
|
75
|
+
`Multiple catch-all ("*") host applications are not allowed (applications: ${i.join(", ")}).`
|
|
76
76
|
);
|
|
77
|
-
},
|
|
78
|
-
const
|
|
79
|
-
if (!
|
|
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 =
|
|
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:
|
|
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 (!
|
|
99
|
+
if (!i) return null;
|
|
100
100
|
const c = t.find(
|
|
101
|
-
(s) => s.id ===
|
|
101
|
+
(s) => s.id === i
|
|
102
102
|
);
|
|
103
103
|
return c ? {
|
|
104
104
|
entry: c,
|
|
105
105
|
matchedPattern: null,
|
|
106
|
-
normalizedHostname:
|
|
106
|
+
normalizedHostname: o,
|
|
107
107
|
category: "default",
|
|
108
108
|
specificity: -1
|
|
109
109
|
} : null;
|
|
110
|
-
},
|
|
111
|
-
if (!
|
|
112
|
-
const
|
|
113
|
-
return
|
|
114
|
-
}, R = /^[!#$%&'*+.^_`|~0-9A-Za-z-]+$/,
|
|
115
|
-
const
|
|
116
|
-
if (!t ||
|
|
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
|
|
121
|
+
return o.has(a) && !n.has(a);
|
|
122
122
|
});
|
|
123
123
|
return c.length ? c.join("; ") : void 0;
|
|
124
|
-
},
|
|
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
|
-
],
|
|
130
|
-
const
|
|
131
|
-
if (!
|
|
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
|
|
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
|
|
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 ((
|
|
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 !==
|
|
149
|
-
for (const s of
|
|
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),
|
|
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 "${
|
|
162
|
+
`Application "${i}" ${o} module must export${e ? ` "${e}"` : " a default value"}.`
|
|
163
163
|
);
|
|
164
164
|
return n;
|
|
165
|
-
}, _ = async (t, e,
|
|
166
|
-
const
|
|
167
|
-
if (!
|
|
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}" ${
|
|
169
|
+
`Application "${e}" ${i} loader must return a valid SsrApplicationDefinition.`
|
|
170
170
|
);
|
|
171
|
-
return
|
|
172
|
-
},
|
|
171
|
+
return Z(o, e);
|
|
172
|
+
}, G = async (t, e, i, o) => {
|
|
173
173
|
if (b(t)) {
|
|
174
|
-
const n =
|
|
175
|
-
return _(l, e,
|
|
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,
|
|
178
|
-
},
|
|
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,
|
|
184
|
-
if (!String(
|
|
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
|
|
189
|
-
if (!String(
|
|
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
|
-
},
|
|
194
|
+
}, Q = async (t, e) => {
|
|
195
195
|
if (e) return S(t, e);
|
|
196
|
-
for (const
|
|
197
|
-
const
|
|
196
|
+
for (const i of C) {
|
|
197
|
+
const o = S(t, i);
|
|
198
198
|
try {
|
|
199
|
-
return await T(
|
|
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
|
-
},
|
|
206
|
+
}, tt = (t) => {
|
|
207
207
|
const e = [];
|
|
208
|
-
for (const [
|
|
209
|
-
if (!
|
|
208
|
+
for (const [i, o] of Object.entries(t.applications || {})) {
|
|
209
|
+
if (!o.render || !o.template)
|
|
210
210
|
throw new Error(
|
|
211
|
-
`Application "${
|
|
211
|
+
`Application "${i}" requires render and template in ssr.config.`
|
|
212
212
|
);
|
|
213
|
-
if (!b(
|
|
213
|
+
if (!b(o.application))
|
|
214
214
|
throw new Error(
|
|
215
|
-
`Application "${
|
|
215
|
+
`Application "${i}" must declare application: { module, exportName } so vueSsrLite() can generate the client entry.`
|
|
216
216
|
);
|
|
217
217
|
e.push({
|
|
218
|
-
id:
|
|
219
|
-
kind:
|
|
220
|
-
definition:
|
|
221
|
-
exportName:
|
|
222
|
-
template:
|
|
223
|
-
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
|
-
},
|
|
230
|
-
const
|
|
229
|
+
}, et = async (t, e) => {
|
|
230
|
+
const i = await Q(t, e), c = (await (await import("esbuild")).build({
|
|
231
231
|
absWorkingDir: t,
|
|
232
|
-
entryPoints: [
|
|
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: ${
|
|
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
|
-
},
|
|
261
|
-
const
|
|
262
|
-
return
|
|
263
|
-
},
|
|
264
|
-
const
|
|
265
|
-
`import __ssrUserConfig from ${JSON.stringify(
|
|
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
|
|
268
|
-
const a = `__ssrApp${l}`, r = A(t,
|
|
267
|
+
return i.filter((s) => s.kind === "ssr").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
|
-
},
|
|
295
|
-
const
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
},
|
|
334
|
-
const
|
|
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 ||
|
|
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
|
|
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 (
|
|
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-->",
|
|
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
|
-
},
|
|
429
|
-
let
|
|
430
|
-
if (
|
|
431
|
-
</head>`)),
|
|
432
|
-
const
|
|
433
|
-
`(<([A-Za-z][\\w-]*)\\b[^>]*\\bid=["']${
|
|
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(
|
|
430
|
+
if (!n.test(i))
|
|
437
431
|
throw new Error(`SSR template is missing mount element ${e}.`);
|
|
438
|
-
|
|
432
|
+
i = i.replace(n, `$1${$}$3`);
|
|
439
433
|
}
|
|
440
|
-
return
|
|
441
|
-
</body>`)),
|
|
442
|
-
},
|
|
443
|
-
let n =
|
|
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,
|
|
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
|
|
463
|
-
return
|
|
464
|
-
n.replace(g,
|
|
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
|
-
},
|
|
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
|
-
|
|
470
|
-
|
|
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
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
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
|
-
|
|
477
|
+
et as n,
|
|
484
478
|
J as o,
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
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-
|
|
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-mGcv3_Vb.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-
|
|
5
|
-
import { c as S } from "./chunks/SsrServerRuntime-
|
|
4
|
+
import { r as w, S as u } from "./chunks/SsrHtmlRuntime-mGcv3_Vb.mjs";
|
|
5
|
+
import { c as S } from "./chunks/SsrServerRuntime-Bay4EOOR.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-
|
|
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-
|
|
1
|
+
import { c as H, a as v, i as _, r as T, b as A, d as M } from "./chunks/SsrServerRuntime-Bay4EOOR.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-mGcv3_Vb.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-
|
|
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-mGcv3_Vb.mjs";
|
|
4
4
|
const $ = [
|
|
5
5
|
"@vue/server-renderer",
|
|
6
6
|
"vue",
|