vue-ssr-lite 0.1.13 → 0.2.2

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.
Files changed (42) hide show
  1. package/README.md +169 -159
  2. package/dist/SsrApplicationRuntime.d.ts.map +1 -1
  3. package/dist/SsrBrowserRuntime.d.ts +7 -6
  4. package/dist/SsrBrowserRuntime.d.ts.map +1 -1
  5. package/dist/SsrConfigCompileRuntime.d.ts +40 -0
  6. package/dist/SsrConfigCompileRuntime.d.ts.map +1 -0
  7. package/dist/SsrConfigRuntime.d.ts +4 -0
  8. package/dist/SsrConfigRuntime.d.ts.map +1 -0
  9. package/dist/SsrConfigTypes.d.ts +106 -0
  10. package/dist/SsrConfigTypes.d.ts.map +1 -0
  11. package/dist/SsrDomainRuntime.d.ts +38 -0
  12. package/dist/SsrDomainRuntime.d.ts.map +1 -0
  13. package/dist/SsrReactivityRuntime.d.ts +8 -1
  14. package/dist/SsrReactivityRuntime.d.ts.map +1 -1
  15. package/dist/SsrRenderRuntime.d.ts.map +1 -1
  16. package/dist/SsrRequestResolution.d.ts +3 -1
  17. package/dist/SsrRequestResolution.d.ts.map +1 -1
  18. package/dist/SsrRuntimeTypes.d.ts +6 -21
  19. package/dist/SsrRuntimeTypes.d.ts.map +1 -1
  20. package/dist/SsrTestFixtures.d.ts +8 -0
  21. package/dist/SsrTestFixtures.d.ts.map +1 -0
  22. package/dist/chunks/SsrApplicationRuntime-D4arUtsy.mjs +238 -0
  23. package/dist/chunks/SsrConfigRuntime-D0DkOrVQ.mjs +4 -0
  24. package/dist/chunks/SsrReactivityRuntime-CroM1WJG.mjs +28 -0
  25. package/dist/chunks/SsrServerRuntime-D7cDSFNm.mjs +1004 -0
  26. package/dist/cli.mjs +34 -34
  27. package/dist/client.d.ts +1 -0
  28. package/dist/client.d.ts.map +1 -1
  29. package/dist/client.mjs +79 -56
  30. package/dist/index.d.ts +4 -2
  31. package/dist/index.d.ts.map +1 -1
  32. package/dist/index.mjs +25 -19
  33. package/dist/server/SsrHostRuntime.d.ts +52 -2
  34. package/dist/server/SsrHostRuntime.d.ts.map +1 -1
  35. package/dist/server/SsrServerRuntime.d.ts.map +1 -1
  36. package/dist/server.d.ts +3 -0
  37. package/dist/server.d.ts.map +1 -1
  38. package/dist/server.mjs +73 -60
  39. package/package.json +1 -1
  40. package/dist/chunks/SsrApplicationRuntime-lMR_sMdk.mjs +0 -155
  41. package/dist/chunks/SsrReactivityRuntime-CUbPx7ew.mjs +0 -9
  42. package/dist/chunks/SsrServerRuntime-nBan8KxD.mjs +0 -731
package/dist/server.mjs CHANGED
@@ -1,39 +1,41 @@
1
- import { n as S } from "./chunks/SsrServerRuntime-nBan8KxD.mjs";
2
- import { c as v, a as C, f as $, i as T, m as _, b as A, r as F, d as P, e as M, g as K, h as L, j as I, s as U } from "./chunks/SsrServerRuntime-nBan8KxD.mjs";
3
- import { S as j, a as z, b as B, c as D, i as N, p as k, r as O } from "./chunks/SsrHtmlRuntime-cTFsMSAZ.mjs";
4
- const h = /* @__PURE__ */ new Set(["1", "true", "yes", "on"]), w = (r) => h.has(String(r ?? "").trim().toLowerCase()), f = (r, o) => {
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) => {
5
7
  const t = Number(r);
6
- return Number.isFinite(t) && t > 0 ? t : o;
7
- }, y = (r) => String(r ?? "").split(",").map((o) => o.trim()).filter(Boolean), p = (r, o, t = { production: !0 }) => {
8
- const a = String(o ?? "").trim();
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();
9
11
  if (!a && t.production)
10
12
  throw new Error(t.message ?? `${r} is required in production.`);
11
13
  return a;
12
- }, b = (r, o, t) => {
13
- const a = p(r, o, { production: t.production }) || t.fallback || "", e = S(a);
14
+ }, g = (r, s, t) => {
15
+ const a = h(r, s, { production: t.production }) || t.fallback || "", e = S(a);
14
16
  if (!e || e.includes(":"))
15
17
  throw new Error(`${r} must be a valid hostname without a port.`);
16
18
  return e;
17
- }, g = (r, o, t, a) => {
18
- const e = String(o ?? "").trim() || a;
19
+ }, x = (r, s, t, a) => {
20
+ const e = String(s ?? "").trim() || a;
19
21
  if (!t.includes(e))
20
22
  throw new Error(`${r} must be one of: ${t.join(", ")}.`);
21
23
  return e;
22
- }, x = (r) => ({
23
- info: (o, t) => console.info(`[${r}] ${o}`, t ?? ""),
24
- warn: (o, t) => console.warn(`[${r}] ${o}`, t ?? ""),
25
- error: (o, t) => console.error(`[${r}] ${o}`, t ?? "")
26
- }), i = `User-agent: *
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 ?? "")
28
+ }), c = `User-agent: *
27
29
  Disallow: /
28
30
  `, d = `<?xml version="1.0" encoding="UTF-8"?>
29
31
  <urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"></urlset>
30
32
  `, l = (r) => r === "robots.txt" ? "text/plain; charset=utf-8" : "application/xml; charset=utf-8", E = (r) => {
31
- const o = r.cacheControl ?? "no-store", t = r.id ?? `${r.entryId ?? "ssr"}-seo-resources`, a = (e, c) => ({
33
+ const s = r.cacheControl ?? "no-store", t = r.id ?? `${r.entryId ?? "ssr"}-seo-resources`, a = (e, i) => ({
32
34
  statusCode: 200,
33
- body: c,
35
+ body: i,
34
36
  headers: {
35
37
  "content-type": l(e),
36
- "cache-control": o,
38
+ "cache-control": s,
37
39
  vary: "Host, X-Forwarded-Host, X-Forwarded-Proto"
38
40
  }
39
41
  });
@@ -41,22 +43,22 @@ Disallow: /
41
43
  {
42
44
  id: t,
43
45
  match: (e) => (!r.entryId || e.entryId === r.entryId) && (e.pathname === "/robots.txt" || e.pathname === "/sitemap.xml"),
44
- async handle(e, c) {
45
- const s = e.pathname === "/robots.txt" ? "robots.txt" : "sitemap.xml";
46
+ async handle(e, i) {
47
+ const o = e.pathname === "/robots.txt" ? "robots.txt" : "sitemap.xml";
46
48
  if (r.mode === "disallow")
47
49
  return a(
48
- s,
49
- s === "robots.txt" ? i : d
50
+ o,
51
+ o === "robots.txt" ? c : d
50
52
  );
51
53
  if (r.mode === "inline") {
52
- const n = s === "robots.txt" ? await r.robots?.(e) : await r.sitemap?.(e);
54
+ const n = o === "robots.txt" ? await r.robots?.(e) : await r.sitemap?.(e);
53
55
  return a(
54
- s,
55
- n ?? (s === "robots.txt" ? i : d)
56
+ o,
57
+ n ?? (o === "robots.txt" ? c : d)
56
58
  );
57
59
  }
58
- const m = r.upstream?.(e, s);
59
- if (!m) return a(s, s === "robots.txt" ? i : d);
60
+ const m = r.upstream?.(e, o);
61
+ if (!m) return a(o, o === "robots.txt" ? c : d);
60
62
  try {
61
63
  const n = await fetch(m, {
62
64
  headers: {
@@ -64,26 +66,26 @@ Disallow: /
64
66
  "x-forwarded-host": e.host,
65
67
  "x-forwarded-proto": e.protocol
66
68
  },
67
- signal: c.signal
69
+ signal: i.signal
68
70
  });
69
71
  return {
70
72
  statusCode: n.status,
71
73
  body: new Uint8Array(await n.arrayBuffer()),
72
74
  headers: {
73
- "content-type": n.headers.get("content-type") || l(s),
74
- "cache-control": n.headers.get("cache-control") || o,
75
+ "content-type": n.headers.get("content-type") || l(o),
76
+ "cache-control": n.headers.get("cache-control") || s,
75
77
  vary: "Host, X-Forwarded-Host, X-Forwarded-Proto"
76
78
  }
77
79
  };
78
80
  } catch (n) {
79
- return c.logger?.warn?.("ssr.seo_proxy_failed", {
80
- resource: s,
81
+ return i.logger?.warn?.("ssr.seo_proxy_failed", {
82
+ resource: o,
81
83
  message: n instanceof Error ? n.message : String(n)
82
84
  }), {
83
85
  statusCode: 502,
84
- body: s === "robots.txt" ? i : d,
86
+ body: o === "robots.txt" ? c : d,
85
87
  headers: {
86
- "content-type": l(s),
88
+ "content-type": l(o),
87
89
  "cache-control": "no-store"
88
90
  }
89
91
  };
@@ -93,33 +95,44 @@ Disallow: /
93
95
  ];
94
96
  };
95
97
  export {
96
- j as SSR_HEAD_MARKER,
97
- z as SSR_HTML_MARKER,
98
- B as SSR_STATE_MARKER,
99
- D as SSR_TELEPORT_MARKER,
100
- x as createSsrConsoleLogger,
101
- v as createSsrManagedServer,
102
- C as createSsrMemoryResponseCache,
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,
103
109
  E as createSsrSeoEndpoints,
110
+ or as defineSsrConfig,
104
111
  $ as filterSsrCookieHeader,
105
- N as injectSsrHtml,
106
- T as isSsrResponseCacheable,
107
- _ as matchesSsrHostPattern,
112
+ J as injectSsrHtml,
113
+ rr as installSsrDomainContext,
114
+ A as isSsrResponseCacheable,
115
+ F as matchesSsrHostPattern,
108
116
  S as normalizeSsrHost,
109
- A as normalizeSsrHostPattern,
110
- k as prepareSsrHtmlTemplate,
111
- F as renderSsrApplication,
112
- O as renderSsrErrorDocument,
113
- g as requireSsrEnum,
114
- p as requireSsrEnv,
115
- b as requireSsrHostname,
116
- P as resolveSsrEntry,
117
- M as resolveSsrForwardedHost,
117
+ M as normalizeSsrHostPattern,
118
+ Q as prepareSsrHtmlTemplate,
119
+ P as renderSsrApplication,
120
+ 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,
118
127
  K as resolveSsrForwardedProtocol,
119
- L as resolveSsrProductionAsset,
120
- I as resolveSsrResponseCacheKey,
121
- w as ssrEnvBoolean,
122
- y as ssrEnvList,
123
- f as ssrEnvNumber,
124
- U as stripSsrHostPort
128
+ L as resolveSsrHostEntry,
129
+ N as resolveSsrProductionAsset,
130
+ U as resolveSsrResponseCacheKey,
131
+ X as scoreSsrHostMatch,
132
+ f as ssrEnvBoolean,
133
+ b as ssrEnvList,
134
+ w as ssrEnvNumber,
135
+ j as stripSsrHostPort,
136
+ er as useSsrDomain,
137
+ k as validateSsrHostEntries
125
138
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vue-ssr-lite",
3
- "version": "0.1.13",
3
+ "version": "0.2.2",
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,155 +0,0 @@
1
- import { inject as h, ref as m, createApp as b, createSSRApp as w } from "vue";
2
- import { createRouter as R, createMemoryHistory as E, createWebHistory as q } from "vue-router";
3
- const S = /* @__PURE__ */ Symbol.for(
4
- "vue-ssr:request-context"
5
- ), H = () => {
6
- const e = h(S);
7
- if (!e) throw new Error("vue-ssr-lite request context is not installed.");
8
- return e;
9
- }, C = /* @__PURE__ */ Symbol.for(
10
- "vue-ssr:hydration-context"
11
- ), v = (e) => {
12
- console.error("[vue-ssr-lite] hydration dispose failed", e);
13
- }, g = (e, r = typeof window > "u") => {
14
- const a = /* @__PURE__ */ new Map(), n = [], l = e ?? null;
15
- return {
16
- server: r,
17
- read: (t) => l ? l[t] : void 0,
18
- contribute: (t, s) => {
19
- r && a.set(t, s);
20
- },
21
- onDispose: (t) => {
22
- n.push(t);
23
- },
24
- collect: () => {
25
- if (a.size === 0) return;
26
- const t = {};
27
- for (const [s, c] of a)
28
- t[s] = c();
29
- return t;
30
- },
31
- dispose: () => {
32
- for (; n.length > 0; ) {
33
- const t = n.pop();
34
- try {
35
- t?.();
36
- } catch (s) {
37
- v(s);
38
- }
39
- }
40
- }
41
- };
42
- }, y = /* @__PURE__ */ Symbol.for(
43
- "vue-ssr:request-resolution"
44
- ), I = () => h(y, null), x = (e) => !!e && (typeof e == "object" || typeof e == "function") && typeof e.then == "function", T = (e = typeof window > "u") => {
45
- const r = /* @__PURE__ */ new Set();
46
- let a = 0, n = !1;
47
- const l = {
48
- server: e,
49
- get pass() {
50
- return a;
51
- },
52
- track: (t) => {
53
- if (!e || !x(t)) return t;
54
- const s = { promise: t, settled: !1 };
55
- return r.add(s), t.then(
56
- () => {
57
- s.settled = !0;
58
- },
59
- () => {
60
- s.settled = !0;
61
- }
62
- ), t;
63
- },
64
- requestAdditionalPass: () => {
65
- e && (n = !0);
66
- },
67
- beginPass: (t) => {
68
- a = t, n = !1;
69
- },
70
- pendingWork: () => [...r].filter((t) => !t.settled).map((t) => t.promise),
71
- additionalPassRequested: () => n,
72
- drain: async (t, s) => {
73
- const c = async () => {
74
- for (; ; ) {
75
- const o = l.pendingWork();
76
- if (o.length === 0) return !0;
77
- await Promise.allSettled(o);
78
- }
79
- };
80
- if (!Number.isFinite(t) || t <= 0)
81
- return s?.aborted ? l.pendingWork().length === 0 : c();
82
- let u, i;
83
- const p = new Promise((o) => {
84
- u = setTimeout(() => o(!1), t), s && (i = () => o(!1), s.aborted ? o(!1) : s.addEventListener("abort", i, { once: !0 }));
85
- });
86
- try {
87
- return await Promise.race([c(), p]);
88
- } finally {
89
- u && clearTimeout(u), s && i && s.removeEventListener("abort", i);
90
- }
91
- },
92
- dispose: () => {
93
- r.clear(), n = !1, a = 0;
94
- }
95
- };
96
- return l;
97
- }, N = async (e, r) => {
98
- if (!e?.id || !e.rootComponent)
99
- throw new Error("An SSR application requires an id and rootComponent.");
100
- if (r.hydrationState && r.hydrationState.applicationId !== e.id)
101
- throw new Error("Hydration state belongs to a different SSR application.");
102
- const a = typeof e.routes == "function" ? e.routes() : e.routes, n = a ? R({
103
- history: r.server ? E() : q(),
104
- routes: a,
105
- scrollBehavior: e.scrollBehavior ?? ((o, d, f) => {
106
- if (f) return f;
107
- if (o.hash) return { el: o.hash, top: 24 };
108
- if (o.fullPath !== d.fullPath)
109
- return { left: 0, top: 0 };
110
- })
111
- }) : null, l = r.hydrationState?.application ?? e.createInitialState?.() ?? {}, t = {
112
- statusCode: 200,
113
- headers: {},
114
- redirect: null
115
- }, s = g(
116
- r.hydrationState?.plugins ?? r.resumeState,
117
- r.server
118
- ), c = r.resolution ?? T(r.server), u = {
119
- applicationId: e.id,
120
- request: r.request,
121
- url: new URL(r.request.url),
122
- host: r.request.host,
123
- publicConfig: r.request.publicConfig,
124
- state: l,
125
- head: m(null),
126
- response: t,
127
- hydration: s,
128
- resolution: c
129
- }, i = e.createExtension ? await e.createExtension(u) : void 0, p = { ...u, extension: i };
130
- try {
131
- const o = r.spa ? b(e.rootComponent) : w(e.rootComponent);
132
- n && o.use(n), o.provide(C, s), o.provide(y, c), o.provide(S, p);
133
- for (const d of e.plugins ?? []) o.use(d);
134
- return await e.install?.({
135
- app: o,
136
- router: n,
137
- context: p,
138
- hydration: s,
139
- resolution: c,
140
- server: r.server
141
- }), { app: o, router: n, context: p, hydration: s, resolution: c };
142
- } catch (o) {
143
- throw s.dispose(), o;
144
- }
145
- };
146
- export {
147
- y as S,
148
- C as a,
149
- S as b,
150
- N as c,
151
- g as d,
152
- T as e,
153
- H as f,
154
- I as u
155
- };
@@ -1,9 +0,0 @@
1
- import { watch as f, watchEffect as a } from "vue";
2
- function h(s, t, c) {
3
- return f(s, t, { ...c, flush: "sync" });
4
- }
5
- const n = (s, t) => a(s, { ...t, flush: "sync" });
6
- export {
7
- n as a,
8
- h as s
9
- };