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/dist/cli.mjs CHANGED
@@ -1,7 +1,8 @@
1
1
  #!/usr/bin/env node
2
2
  import { resolve as c, relative as f } from "node:path";
3
3
  import { pathToFileURL as w } from "node:url";
4
- import { r as S, c as b } from "./chunks/SsrServerRuntime-D7cDSFNm.mjs";
4
+ import { r as S } from "./chunks/SsrHtmlRuntime-BiQCklqA.mjs";
5
+ import { c as b } from "./chunks/SsrServerRuntime-CkEnx8IY.mjs";
5
6
  import { createServer as g } from "node:net";
6
7
  const i = 1, a = 65535, h = (r) => {
7
8
  const e = r?.trim();
@@ -52,28 +53,28 @@ const i = 1, a = 65535, h = (r) => {
52
53
  hmr: { port: t, clientPort: t }
53
54
  },
54
55
  appType: "custom"
55
- }), m = `/${f(r.root, r.config).replaceAll("\\", "/")}`, l = await b({
56
+ }), u = `/${f(r.root, r.config).replaceAll("\\", "/")}`, l = await b({
56
57
  production: e,
57
58
  root: r.root,
58
59
  vite: s,
59
- loadRuntime: e ? () => import(w(r.serverOutput).href) : () => s.ssrLoadModule(m)
60
+ loadRuntime: e ? () => import(w(r.serverOutput).href) : () => s.ssrLoadModule(u)
60
61
  });
61
62
  await l.listen();
62
63
  let d = !1;
63
- const u = async (v) => {
64
+ const m = async (p) => {
64
65
  if (!d) {
65
66
  d = !0;
66
67
  try {
67
- await l.close(), console.log(`stopped after ${v}`), process.exitCode = 0;
68
- } catch (p) {
69
- console.error("graceful shutdown failed", p), process.exitCode = 1;
68
+ await l.close(), console.log(`stopped after ${p}`), process.exitCode = 0;
69
+ } catch (v) {
70
+ console.error("graceful shutdown failed", v), process.exitCode = 1;
70
71
  }
71
72
  }
72
73
  };
73
74
  process.once("SIGINT", () => {
74
- u("SIGINT");
75
+ m("SIGINT");
75
76
  }), process.once("SIGTERM", () => {
76
- u("SIGTERM");
77
+ m("SIGTERM");
77
78
  });
78
79
  }, M = async (r) => {
79
80
  const { build: e } = await import("vite");
@@ -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;AA+BzC,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;AAwJD,eAAO,MAAM,sBAAsB,GACjC,SAAS,uBAAuB,KAC/B,OAAO,CAAC,gBAAgB,CA4gB1B,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;AA+BzC,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;AAmKD,eAAO,MAAM,sBAAsB,GACjC,SAAS,uBAAuB,KAC/B,OAAO,CAAC,gBAAgB,CA4gB1B,CAAA"}
package/dist/server.mjs CHANGED
@@ -1,70 +1,70 @@
1
- import { n as S } from "./chunks/SsrServerRuntime-D7cDSFNm.mjs";
2
- import { S as v, a as C, c as T, b as _, f as $, i as A, m as F, d as M, e as P, r as D, g as I, h as K, j as L, k as N, l as U, s as X, o as j, v as k } from "./chunks/SsrServerRuntime-D7cDSFNm.mjs";
3
- import { S as B, a as O, b as Y, c as G, i as J, p as Q, r as V } from "./chunks/SsrHtmlRuntime-cTFsMSAZ.mjs";
4
- import { S as Z, b as q, i as rr, r as tr, u as er } from "./chunks/SsrApplicationRuntime-D4arUtsy.mjs";
5
- import { d as or } from "./chunks/SsrConfigRuntime-D0DkOrVQ.mjs";
6
- const u = /* @__PURE__ */ new Set(["1", "true", "yes", "on"]), f = (r) => u.has(String(r ?? "").trim().toLowerCase()), w = (r, s) => {
1
+ import { c as v, a as C, i as T, r as _, b as A, d as M } from "./chunks/SsrServerRuntime-CkEnx8IY.mjs";
2
+ import { n as m } from "./chunks/SsrHtmlRuntime-BiQCklqA.mjs";
3
+ import { S as F, a as P, b as D, c as I, d as K, e as L, f as N, g as U, i as X, h as j, l as k, m as z, j as B, p as O, k as V, r as Y, o as G, q as J, s as Q, t as W, u as Z, v as q, w as rr, x as tr } from "./chunks/SsrHtmlRuntime-BiQCklqA.mjs";
4
+ import { S as er, b as or, i as ar, r as nr, u as ir } from "./chunks/SsrApplicationRuntime-D4arUtsy.mjs";
5
+ import { d as dr } from "./chunks/SsrConfigRuntime-D0DkOrVQ.mjs";
6
+ const u = /* @__PURE__ */ new Set(["1", "true", "yes", "on"]), f = (r) => u.has(String(r ?? "").trim().toLowerCase()), w = (r, e) => {
7
7
  const t = Number(r);
8
- return Number.isFinite(t) && t > 0 ? t : s;
9
- }, b = (r) => String(r ?? "").split(",").map((s) => s.trim()).filter(Boolean), h = (r, s, t = { production: !0 }) => {
10
- const a = String(s ?? "").trim();
8
+ return Number.isFinite(t) && t > 0 ? t : e;
9
+ }, g = (r) => String(r ?? "").split(",").map((e) => e.trim()).filter(Boolean), p = (r, e, t = { production: !0 }) => {
10
+ const a = String(e ?? "").trim();
11
11
  if (!a && t.production)
12
12
  throw new Error(t.message ?? `${r} is required in production.`);
13
13
  return a;
14
- }, g = (r, s, t) => {
15
- const a = h(r, s, { production: t.production }) || t.fallback || "", e = S(a);
16
- if (!e || e.includes(":"))
14
+ }, x = (r, e, t) => {
15
+ const a = p(r, e, { production: t.production }) || t.fallback || "", s = m(a);
16
+ if (!s || s.includes(":"))
17
17
  throw new Error(`${r} must be a valid hostname without a port.`);
18
- return e;
19
- }, x = (r, s, t, a) => {
20
- const e = String(s ?? "").trim() || a;
21
- if (!t.includes(e))
18
+ return s;
19
+ }, b = (r, e, t, a) => {
20
+ const s = String(e ?? "").trim() || a;
21
+ if (!t.includes(s))
22
22
  throw new Error(`${r} must be one of: ${t.join(", ")}.`);
23
- return e;
24
- }, y = (r) => ({
25
- info: (s, t) => console.info(`[${r}] ${s}`, t ?? ""),
26
- warn: (s, t) => console.warn(`[${r}] ${s}`, t ?? ""),
27
- error: (s, t) => console.error(`[${r}] ${s}`, t ?? "")
23
+ return s;
24
+ }, E = (r) => ({
25
+ info: (e, t) => console.info(`[${r}] ${e}`, t ?? ""),
26
+ warn: (e, t) => console.warn(`[${r}] ${e}`, t ?? ""),
27
+ error: (e, t) => console.error(`[${r}] ${e}`, t ?? "")
28
28
  }), c = `User-agent: *
29
29
  Disallow: /
30
30
  `, d = `<?xml version="1.0" encoding="UTF-8"?>
31
31
  <urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"></urlset>
32
- `, l = (r) => r === "robots.txt" ? "text/plain; charset=utf-8" : "application/xml; charset=utf-8", E = (r) => {
33
- const s = r.cacheControl ?? "no-store", t = r.id ?? `${r.entryId ?? "ssr"}-seo-resources`, a = (e, i) => ({
32
+ `, l = (r) => r === "robots.txt" ? "text/plain; charset=utf-8" : "application/xml; charset=utf-8", y = (r) => {
33
+ const e = r.cacheControl ?? "no-store", t = r.id ?? `${r.entryId ?? "ssr"}-seo-resources`, a = (s, i) => ({
34
34
  statusCode: 200,
35
35
  body: i,
36
36
  headers: {
37
- "content-type": l(e),
38
- "cache-control": s,
37
+ "content-type": l(s),
38
+ "cache-control": e,
39
39
  vary: "Host, X-Forwarded-Host, X-Forwarded-Proto"
40
40
  }
41
41
  });
42
42
  return [
43
43
  {
44
44
  id: t,
45
- match: (e) => (!r.entryId || e.entryId === r.entryId) && (e.pathname === "/robots.txt" || e.pathname === "/sitemap.xml"),
46
- async handle(e, i) {
47
- const o = e.pathname === "/robots.txt" ? "robots.txt" : "sitemap.xml";
45
+ match: (s) => (!r.entryId || s.entryId === r.entryId) && (s.pathname === "/robots.txt" || s.pathname === "/sitemap.xml"),
46
+ async handle(s, i) {
47
+ const o = s.pathname === "/robots.txt" ? "robots.txt" : "sitemap.xml";
48
48
  if (r.mode === "disallow")
49
49
  return a(
50
50
  o,
51
51
  o === "robots.txt" ? c : d
52
52
  );
53
53
  if (r.mode === "inline") {
54
- const n = o === "robots.txt" ? await r.robots?.(e) : await r.sitemap?.(e);
54
+ const n = o === "robots.txt" ? await r.robots?.(s) : await r.sitemap?.(s);
55
55
  return a(
56
56
  o,
57
57
  n ?? (o === "robots.txt" ? c : d)
58
58
  );
59
59
  }
60
- const m = r.upstream?.(e, o);
61
- if (!m) return a(o, o === "robots.txt" ? c : d);
60
+ const S = r.upstream?.(s, o);
61
+ if (!S) return a(o, o === "robots.txt" ? c : d);
62
62
  try {
63
- const n = await fetch(m, {
63
+ const n = await fetch(S, {
64
64
  headers: {
65
- host: e.host,
66
- "x-forwarded-host": e.host,
67
- "x-forwarded-proto": e.protocol
65
+ host: s.host,
66
+ "x-forwarded-host": s.host,
67
+ "x-forwarded-proto": s.protocol
68
68
  },
69
69
  signal: i.signal
70
70
  });
@@ -73,7 +73,7 @@ Disallow: /
73
73
  body: new Uint8Array(await n.arrayBuffer()),
74
74
  headers: {
75
75
  "content-type": n.headers.get("content-type") || l(o),
76
- "cache-control": n.headers.get("cache-control") || s,
76
+ "cache-control": n.headers.get("cache-control") || e,
77
77
  vary: "Host, X-Forwarded-Host, X-Forwarded-Proto"
78
78
  }
79
79
  };
@@ -95,44 +95,49 @@ Disallow: /
95
95
  ];
96
96
  };
97
97
  export {
98
- Z as SSR_DOMAIN_CONTEXT,
99
- B as SSR_HEAD_MARKER,
100
- O as SSR_HTML_MARKER,
101
- Y as SSR_STATE_MARKER,
102
- G as SSR_TELEPORT_MARKER,
103
- v as SsrHostConfigurationError,
104
- q as buildSsrSubdomainUrl,
105
- C as compileSsrConfig,
106
- y as createSsrConsoleLogger,
107
- T as createSsrManagedServer,
108
- _ as createSsrMemoryResponseCache,
109
- E as createSsrSeoEndpoints,
110
- or as defineSsrConfig,
111
- $ as filterSsrCookieHeader,
112
- J as injectSsrHtml,
113
- rr as installSsrDomainContext,
114
- A as isSsrResponseCacheable,
115
- F as matchesSsrHostPattern,
116
- S as normalizeSsrHost,
117
- M as normalizeSsrHostPattern,
118
- Q as prepareSsrHtmlTemplate,
119
- P as renderSsrApplication,
98
+ er as SSR_DOMAIN_CONTEXT,
99
+ F as SSR_HEAD_MARKER,
100
+ P as SSR_HTML_MARKER,
101
+ D as SSR_STATE_MARKER,
102
+ I as SSR_TELEPORT_MARKER,
103
+ K as SsrHostConfigurationError,
104
+ or as buildSsrSubdomainUrl,
105
+ L as compileSsrConfig,
106
+ E as createSsrConsoleLogger,
107
+ v as createSsrManagedServer,
108
+ C as createSsrMemoryResponseCache,
109
+ y as createSsrSeoEndpoints,
110
+ dr as defineSsrConfig,
111
+ N as extractSsrViteEntries,
112
+ U as filterSsrCookieHeader,
113
+ X as injectSsrHtml,
114
+ ar as installSsrDomainContext,
115
+ j as isSsrApplicationModuleRef,
116
+ T as isSsrResponseCacheable,
117
+ k as loadSsrConfigFile,
118
+ z as matchesSsrHostPattern,
119
+ m as normalizeSsrHost,
120
+ B as normalizeSsrHostPattern,
121
+ O as prepareSsrHtmlTemplate,
122
+ _ as renderSsrApplication,
120
123
  V as renderSsrErrorDocument,
121
- x as requireSsrEnum,
122
- h as requireSsrEnv,
123
- g as requireSsrHostname,
124
- D as resolveSsrConfigPath,
125
- tr as resolveSsrDomainContext,
126
- I as resolveSsrForwardedHost,
127
- K as resolveSsrForwardedProtocol,
128
- L as resolveSsrHostEntry,
129
- N as resolveSsrProductionAsset,
130
- U as resolveSsrResponseCacheKey,
131
- X as scoreSsrHostMatch,
124
+ b as requireSsrEnum,
125
+ p as requireSsrEnv,
126
+ x as requireSsrHostname,
127
+ Y as resolveSsrConfigPath,
128
+ nr as resolveSsrDomainContext,
129
+ G as resolveSsrForwardedHost,
130
+ J as resolveSsrForwardedProtocol,
131
+ Q as resolveSsrHostEntry,
132
+ A as resolveSsrProductionAsset,
133
+ M as resolveSsrResponseCacheKey,
134
+ W as resolveSsrViteEntries,
135
+ Z as scoreSsrHostMatch,
132
136
  f as ssrEnvBoolean,
133
- b as ssrEnvList,
137
+ g as ssrEnvList,
134
138
  w as ssrEnvNumber,
135
- j as stripSsrHostPort,
136
- er as useSsrDomain,
137
- k as validateSsrHostEntries
139
+ q as stripSsrHostPort,
140
+ rr as transformSsrModuleRefs,
141
+ ir as useSsrDomain,
142
+ tr as validateSsrHostEntries
138
143
  };
@@ -1,14 +1,16 @@
1
1
  import { Plugin } from 'vite';
2
- export interface SsrViteApplicationEntry {
3
- id: string;
4
- definition: string;
5
- exportName?: string;
6
- template: string;
7
- mountSelector?: string;
8
- }
2
+ import { SsrViteApplicationEntry } from '../SsrConfigCompileRuntime';
3
+ export type { SsrViteApplicationEntry };
9
4
  export interface SsrVitePluginOptions {
10
- applications: SsrViteApplicationEntry[];
5
+ /**
6
+ * Explicit SSR hydration entries. When omitted, entries are derived from
7
+ * `ssr.config.*` (`ssr: { module, exportName }` and `spa: true` templates).
8
+ */
9
+ applications?: SsrViteApplicationEntry[];
10
+ /** Explicit SPA HTML inputs. Derived from `ssr.config` when omitted. */
11
11
  spaEntries?: Record<string, string>;
12
+ /** Optional path to `ssr.config.*` when auto-discovering entries. */
13
+ config?: string;
12
14
  root?: string;
13
15
  /**
14
16
  * Additional packages to deduplicate. `vue-ssr-lite` always dedupes the Vue
@@ -24,5 +26,5 @@ export interface SsrVitePluginOptions {
24
26
  */
25
27
  ssrNoExternal?: (string | RegExp)[];
26
28
  }
27
- export declare const vueSsrLite: (options: SsrVitePluginOptions) => Plugin;
29
+ export declare const vueSsrLite: (options?: SsrVitePluginOptions) => Plugin;
28
30
  //# sourceMappingURL=SsrVitePlugin.d.ts.map
@@ -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;IACb;;;;OAIG;IACH,MAAM,CAAC,EAAE,MAAM,EAAE,CAAA;IACjB;;;;;OAKG;IACH,aAAa,CAAC,EAAE,CAAC,MAAM,GAAG,MAAM,CAAC,EAAE,CAAA;CACpC;AAcD,eAAO,MAAM,UAAU,GAAI,SAAS,oBAAoB,KAAG,MAwG1D,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;AAElC,OAAO,EAGL,KAAK,uBAAuB,EAE7B,MAAM,4BAA4B,CAAA;AAGnC,YAAY,EAAE,uBAAuB,EAAE,CAAA;AAEvC,MAAM,WAAW,oBAAoB;IACnC;;;OAGG;IACH,YAAY,CAAC,EAAE,uBAAuB,EAAE,CAAA;IACxC,wEAAwE;IACxE,UAAU,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;IACnC,qEAAqE;IACrE,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,IAAI,CAAC,EAAE,MAAM,CAAA;IACb;;;;OAIG;IACH,MAAM,CAAC,EAAE,MAAM,EAAE,CAAA;IACjB;;;;;OAKG;IACH,aAAa,CAAC,EAAE,CAAC,MAAM,GAAG,MAAM,CAAC,EAAE,CAAA;CACpC;AAgCD,eAAO,MAAM,UAAU,GAAI,UAAS,oBAAyB,KAAG,MAyH/D,CAAA"}
package/dist/vite.mjs CHANGED
@@ -1,42 +1,52 @@
1
- import { resolve as l } from "node:path";
2
- import { normalizePath as c } from "vite";
3
- import { p as f } from "./chunks/SsrHtmlRuntime-cTFsMSAZ.mjs";
4
- const v = [
1
+ import { resolve as a } from "node:path";
2
+ import { normalizePath as m } from "vite";
3
+ import { p as S, w as h, t as g } from "./chunks/SsrHtmlRuntime-BiQCklqA.mjs";
4
+ const y = [
5
5
  "@vue/server-renderer",
6
6
  "vue",
7
7
  "vue-router",
8
8
  "vue-ssr-lite"
9
- ], p = "virtual:vue-ssr-lite/client/", m = `\0${p}`, g = (t) => {
10
- if (!t.applications?.length)
11
- throw new Error("vueSsrLite requires at least one SSR application entry.");
12
- let n = l(t.root || process.cwd());
13
- const u = new Map(
14
- t.applications.map((e) => [
15
- `${p}${e.id}`,
16
- e
9
+ ], c = "virtual:vue-ssr-lite/client/", d = `\0${c}`, $ = (r, i) => ({
10
+ ...Object.fromEntries(
11
+ i.applications.map((t) => [
12
+ t.id,
13
+ a(r, t.template)
17
14
  ])
18
- );
15
+ ),
16
+ ...Object.fromEntries(
17
+ Object.entries(i.spaEntries).map(([t, l]) => [
18
+ t,
19
+ a(r, l)
20
+ ])
21
+ )
22
+ }), I = (r = {}) => {
23
+ let i = a(r.root || process.cwd()), t = r.applications?.length || r.spaEntries ? {
24
+ applications: r.applications ?? [],
25
+ spaEntries: r.spaEntries ?? {}
26
+ } : null;
27
+ const l = /* @__PURE__ */ new Map(), f = () => {
28
+ l.clear();
29
+ for (const e of t?.applications ?? [])
30
+ l.set(`${c}${e.id}`, e);
31
+ };
32
+ f();
33
+ const v = async () => {
34
+ if (t) return t;
35
+ if (t = await g(i, r.config), !t.applications.length && !Object.keys(t.spaEntries).length)
36
+ throw new Error(
37
+ "vueSsrLite() could not derive applications from ssr.config. Declare spa/ssr apps or pass applications explicitly."
38
+ );
39
+ return f(), t;
40
+ };
19
41
  return {
20
42
  name: "vue-ssr-lite",
21
43
  enforce: "pre",
22
- config(e, o) {
23
- const i = {
24
- ...Object.fromEntries(
25
- t.applications.map((r) => [
26
- r.id,
27
- l(n, r.template)
28
- ])
29
- ),
30
- ...Object.fromEntries(
31
- Object.entries(t.spaEntries ?? {}).map(([r, s]) => [
32
- r,
33
- l(n, s)
34
- ])
35
- )
36
- };
44
+ async config(e, o) {
45
+ i = a(r.root || e.root || process.cwd());
46
+ const n = await v(), s = $(i, n);
37
47
  return {
38
48
  resolve: {
39
- dedupe: [.../* @__PURE__ */ new Set([...v, ...t.dedupe ?? []])]
49
+ dedupe: [.../* @__PURE__ */ new Set([...y, ...r.dedupe ?? []])]
40
50
  },
41
51
  ssr: {
42
52
  // The managed server imports vue-ssr-lite through Node. Explicitly
@@ -46,27 +56,32 @@ const v = [
46
56
  // `noExternal` filter also happens to match this package.
47
57
  external: ["vue-ssr-lite"],
48
58
  // API-client and browser-oriented packages remain consumer-owned.
49
- noExternal: [...new Set(t.ssrNoExternal ?? [])]
59
+ noExternal: [...new Set(r.ssrNoExternal ?? [])]
50
60
  },
51
- build: o.isSsrBuild ? void 0 : { manifest: !0, rollupOptions: { input: i } }
61
+ build: o.isSsrBuild ? void 0 : { manifest: !0, rollupOptions: { input: s } }
52
62
  };
53
63
  },
54
64
  configResolved(e) {
55
- n = e.root;
65
+ i = e.root;
66
+ },
67
+ transform(e, o) {
68
+ return h(e, o);
56
69
  },
57
70
  resolveId(e) {
58
- return u.has(e) ? `${m}${e.slice(p.length)}` : void 0;
71
+ return l.has(e) ? `${d}${e.slice(c.length)}` : void 0;
59
72
  },
60
73
  load(e) {
61
- if (!e.startsWith(m)) return;
62
- const o = e.slice(m.length), i = t.applications.find(({ id: a }) => a === o);
63
- if (!i) return;
64
- const r = c(l(n, i.definition));
74
+ if (!e.startsWith(d)) return;
75
+ const o = e.slice(d.length), n = t?.applications.find(
76
+ ({ id: p }) => p === o
77
+ );
78
+ if (!n) return;
79
+ const s = m(a(i, n.definition));
65
80
  return [
66
- i.exportName ? `import { ${i.exportName} as application } from ${JSON.stringify(r)}` : `import application from ${JSON.stringify(r)}`,
81
+ n.exportName ? `import { ${n.exportName} as application } from ${JSON.stringify(s)}` : `import application from ${JSON.stringify(s)}`,
67
82
  "import { hydrateSsrApplication } from 'vue-ssr-lite/client'",
68
83
  `hydrateSsrApplication(application, ${JSON.stringify({
69
- mountSelector: i.mountSelector || "#app"
84
+ mountSelector: n.mountSelector || "#app"
70
85
  })}).catch((error) => {`,
71
86
  " console.error('[vue-ssr-lite] hydration failed', error)",
72
87
  " throw error",
@@ -77,21 +92,21 @@ const v = [
77
92
  transformIndexHtml: {
78
93
  order: "pre",
79
94
  handler(e, o) {
80
- const i = c(o.filename), r = t.applications.find(
81
- (d) => i === c(l(n, d.template))
95
+ const n = m(o.filename), s = t?.applications.find(
96
+ (E) => n === m(a(i, E.template))
82
97
  );
83
- if (!r) return e;
84
- const s = `${p}${r.id}`, a = f(
98
+ if (!s) return e;
99
+ const u = `${c}${s.id}`, p = S(
85
100
  e,
86
- r.mountSelector || "#app"
101
+ s.mountSelector || "#app"
87
102
  );
88
- return a.includes(`import ${JSON.stringify(s)}`) ? a : {
89
- html: a,
103
+ return p.includes(`import ${JSON.stringify(u)}`) ? p : {
104
+ html: p,
90
105
  tags: [
91
106
  {
92
107
  tag: "script",
93
108
  attrs: { type: "module" },
94
- children: `import ${JSON.stringify(s)}`,
109
+ children: `import ${JSON.stringify(u)}`,
95
110
  injectTo: "body"
96
111
  }
97
112
  ]
@@ -101,5 +116,5 @@ const v = [
101
116
  };
102
117
  };
103
118
  export {
104
- g as vueSsrLite
119
+ I as vueSsrLite
105
120
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vue-ssr-lite",
3
- "version": "0.2.2",
3
+ "version": "0.2.4",
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",
@@ -1,54 +0,0 @@
1
- import { e as i, g as h, a as u, r as S } from "./SsrSerialization-k-3aCFYt.mjs";
2
- const l = "<!--vue-ssr-lite:head-->", o = "<!--vue-ssr-lite:teleports-->", c = "<!--vue-ssr-lite:html-->", m = "<!--vue-ssr-lite:state-->", $ = (s) => {
3
- if (!/^#[A-Za-z][A-Za-z0-9_-]*$/.test(s))
4
- throw new Error("vue-ssr-lite mountSelector must be a simple element id selector.");
5
- return s.slice(1);
6
- }, b = (s, t = "#app") => {
7
- let e = s;
8
- if (e.includes(l) || (e = e.replace(/<\/head>/i, ` ${l}
9
- </head>`)), e.includes(o) || (e = e.replace(/<body([^>]*)>/i, `<body$1>${o}`)), !e.includes(c)) {
10
- const n = $(t), r = new RegExp(
11
- `(<([A-Za-z][\\w-]*)\\b[^>]*\\bid=["']${n}["'][^>]*>)[\\s\\S]*?(<\\/\\2>)`,
12
- "i"
13
- );
14
- if (!r.test(e))
15
- throw new Error(`SSR template is missing mount element ${t}.`);
16
- e = e.replace(r, `$1${c}$3`);
17
- }
18
- return e.includes(m) || (e = e.replace(/<\/body>/i, ` ${m}
19
- </body>`)), e;
20
- }, f = (s, t) => t ? s.replace(/<html\b([^>]*)>/i, (e, n) => {
21
- let r = n;
22
- for (const [a, d] of Object.entries(t)) {
23
- if (!/^[A-Za-z_:][A-Za-z0-9:._-]*$/.test(a)) continue;
24
- const p = new RegExp(
25
- `\\s${a.replace(/[.:_-]/g, "\\$&")}(?:\\s*=\\s*(?:"[^"]*"|'[^']*'|[^\\s>]+))?`,
26
- "i"
27
- );
28
- r = r.replace(p, ""), d != null && (r += ` ${a}="${i(d)}"`);
29
- }
30
- return `<html${r}>`;
31
- }) : s, E = (s, t) => {
32
- for (const a of [
33
- l,
34
- o,
35
- c,
36
- m
37
- ])
38
- if (!s.includes(a))
39
- throw new Error(`Transformed SSR template is missing marker ${a}.`);
40
- const e = h(t.applicationId), n = `<script id="${i(e)}" type="application/json">${u(t.state)}<\/script>`, r = t.head?.title ? s.replace(/<title\b[^>]*>[\s\S]*?<\/title>/i, "") : s;
41
- return f(
42
- r.replace(l, S(t.head)).replace(o, t.teleports).replace(c, t.html).replace(m, n),
43
- t.head?.htmlAttributes
44
- );
45
- }, g = (s, t, e = "en") => `<!doctype html><html lang="${i(e)}"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1"><meta name="robots" content="noindex,nofollow"><title>${i(s)}</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>${i(s)}</h1><p>${i(t)}</p><p><a href="/">Return home</a></p></div></main></body></html>`;
46
- export {
47
- l as S,
48
- c as a,
49
- m as b,
50
- o as c,
51
- E as i,
52
- b as p,
53
- g as r
54
- };