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/cli.mjs CHANGED
@@ -1,19 +1,19 @@
1
1
  #!/usr/bin/env node
2
- import { resolve as i, relative as w } from "node:path";
3
- import { pathToFileURL as f } from "node:url";
4
- import { c as S } from "./chunks/SsrServerRuntime-nBan8KxD.mjs";
5
- import { createServer as b } from "node:net";
6
- const a = 1, c = 65535, R = (r) => {
2
+ import { resolve as c, relative as f } from "node:path";
3
+ import { pathToFileURL as w } from "node:url";
4
+ import { r as S, c as b } from "./chunks/SsrServerRuntime-D7cDSFNm.mjs";
5
+ import { createServer as g } from "node:net";
6
+ const i = 1, a = 65535, h = (r) => {
7
7
  const e = r?.trim();
8
8
  if (!e) return;
9
9
  if (!/^\d+$/.test(e))
10
- throw new Error(`HMR port must be an integer between ${a} and ${c}.`);
10
+ throw new Error(`HMR port must be an integer between ${i} and ${a}.`);
11
11
  const t = Number(e);
12
- if (!Number.isInteger(t) || t < a || t > c)
13
- throw new Error(`HMR port must be an integer between ${a} and ${c}.`);
12
+ if (!Number.isInteger(t) || t < i || t > a)
13
+ throw new Error(`HMR port must be an integer between ${i} and ${a}.`);
14
14
  return t;
15
- }, h = () => new Promise((r, e) => {
16
- const t = b();
15
+ }, P = () => new Promise((r, e) => {
16
+ const t = g();
17
17
  t.once("error", e), t.listen({ port: 0, exclusive: !0 }, () => {
18
18
  const o = t.address();
19
19
  if (!o || typeof o == "string") {
@@ -24,64 +24,64 @@ const a = 1, c = 65535, R = (r) => {
24
24
  s ? e(s) : r(o.port);
25
25
  });
26
26
  });
27
- }), P = async (r) => R(r) ?? h(), n = (r, e) => {
27
+ }), R = async (r) => h(r) ?? P(), n = (r, e) => {
28
28
  const t = r.indexOf(e);
29
29
  return t >= 0 ? r[t + 1] : void 0;
30
- }, T = (r) => {
30
+ }, T = async (r) => {
31
31
  const e = r[0];
32
32
  if (!["dev", "build", "start"].includes(e))
33
33
  throw new Error(
34
- "Usage: vue-ssr-lite <dev|build|start> [--root .] [--runtime src/SsrRuntime.ts] [--hmr-port 31001]"
34
+ "Usage: vue-ssr-lite <dev|build|start> [--root .] [--config ssr.config.ts] [--hmr-port 31001]"
35
35
  );
36
- const t = i(n(r, "--root") || process.cwd());
36
+ const t = c(n(r, "--root") || process.cwd()), o = await S(t, n(r, "--config"));
37
37
  return {
38
38
  command: e,
39
39
  root: t,
40
- runtime: i(t, n(r, "--runtime") || "src/SsrRuntime.ts"),
41
- serverOutput: i(
40
+ config: o,
41
+ serverOutput: c(
42
42
  t,
43
43
  n(r, "--server-output") || "dist/server/SsrRuntime.js"
44
44
  ),
45
45
  hmrPort: n(r, "--hmr-port") || process.env.VUE_SSR_LITE_HMR_PORT
46
46
  };
47
- }, M = async (r, e) => {
48
- const t = e ? void 0 : await P(r.hmrPort), o = e ? void 0 : (await import("vite")).createServer, s = e ? void 0 : await o({
47
+ }, y = async (r, e) => {
48
+ const t = e ? void 0 : await R(r.hmrPort), o = e ? void 0 : (await import("vite")).createServer, s = e ? void 0 : await o({
49
49
  root: r.root,
50
50
  server: {
51
51
  middlewareMode: !0,
52
52
  hmr: { port: t, clientPort: t }
53
53
  },
54
54
  appType: "custom"
55
- }), d = `/${w(r.root, r.runtime).replaceAll("\\", "/")}`, l = await S({
55
+ }), m = `/${f(r.root, r.config).replaceAll("\\", "/")}`, l = await b({
56
56
  production: e,
57
57
  root: r.root,
58
58
  vite: s,
59
- loadRuntime: e ? () => import(f(r.serverOutput).href) : () => s.ssrLoadModule(d)
59
+ loadRuntime: e ? () => import(w(r.serverOutput).href) : () => s.ssrLoadModule(m)
60
60
  });
61
61
  await l.listen();
62
- let u = !1;
63
- const m = async (p) => {
64
- if (!u) {
65
- u = !0;
62
+ let d = !1;
63
+ const u = async (v) => {
64
+ if (!d) {
65
+ d = !0;
66
66
  try {
67
- await l.close(), console.log(`stopped after ${p}`), process.exitCode = 0;
68
- } catch (v) {
69
- console.error("graceful shutdown failed", v), process.exitCode = 1;
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;
70
70
  }
71
71
  }
72
72
  };
73
73
  process.once("SIGINT", () => {
74
- m("SIGINT");
74
+ u("SIGINT");
75
75
  }), process.once("SIGTERM", () => {
76
- m("SIGTERM");
76
+ u("SIGTERM");
77
77
  });
78
- }, y = async (r) => {
78
+ }, M = async (r) => {
79
79
  const { build: e } = await import("vite");
80
80
  await e({ root: r.root }), await e({
81
81
  root: r.root,
82
82
  build: {
83
- ssr: r.runtime,
84
- outDir: i(r.root, "dist/server"),
83
+ ssr: r.config,
84
+ outDir: c(r.root, "dist/server"),
85
85
  emptyOutDir: !0,
86
86
  rollupOptions: {
87
87
  output: { entryFileNames: "SsrRuntime.js" }
@@ -89,8 +89,8 @@ const a = 1, c = 65535, R = (r) => {
89
89
  }
90
90
  });
91
91
  }, I = async () => {
92
- const r = T(process.argv.slice(2));
93
- return r.command === "build" ? y(r) : M(r, r.command === "start");
92
+ const r = await T(process.argv.slice(2));
93
+ return r.command === "build" ? M(r) : y(r, r.command === "start");
94
94
  };
95
95
  I().catch((r) => {
96
96
  console.error("fatal error", r), process.exitCode = 1;
package/dist/client.d.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  export * from './SsrBrowserRuntime';
2
+ export * from './SsrDomainRuntime';
2
3
  export * from './SsrReactivityRuntime';
3
4
  export { SSR_REQUEST_RESOLUTION, useSsrResolution, type SsrRequestResolution, } from './SsrRequestResolution';
4
5
  export type * from './SsrRuntimeTypes';
@@ -1 +1 @@
1
- {"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA,cAAc,qBAAqB,CAAA;AACnC,cAAc,wBAAwB,CAAA;AACtC,OAAO,EACL,sBAAsB,EACtB,gBAAgB,EAChB,KAAK,oBAAoB,GAC1B,MAAM,wBAAwB,CAAA;AAC/B,mBAAmB,mBAAmB,CAAA"}
1
+ {"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA,cAAc,qBAAqB,CAAA;AACnC,cAAc,oBAAoB,CAAA;AAClC,cAAc,wBAAwB,CAAA;AACtC,OAAO,EACL,sBAAsB,EACtB,gBAAgB,EAChB,KAAK,oBAAoB,GAC1B,MAAM,wBAAwB,CAAA;AAC/B,mBAAmB,mBAAmB,CAAA"}
package/dist/client.mjs CHANGED
@@ -1,94 +1,117 @@
1
- import { c as i } from "./chunks/SsrApplicationRuntime-lMR_sMdk.mjs";
2
- import { S as E, u as v } from "./chunks/SsrApplicationRuntime-lMR_sMdk.mjs";
3
- import { g as d } from "./chunks/SsrSerialization-k-3aCFYt.mjs";
4
- import { s as g, a as R } from "./chunks/SsrReactivityRuntime-CUbPx7ew.mjs";
5
- const u = (r, e, o, s) => ({
6
- requestId: `${o}-${Date.now().toString(36)}`,
7
- url: e,
1
+ import { c as u } from "./chunks/SsrApplicationRuntime-D4arUtsy.mjs";
2
+ import { S as g, a as b, b as C, i as x, r as R, u as A, d as I } from "./chunks/SsrApplicationRuntime-D4arUtsy.mjs";
3
+ import { g as h } from "./chunks/SsrSerialization-k-3aCFYt.mjs";
4
+ import { s as q, a as D } from "./chunks/SsrReactivityRuntime-CroM1WJG.mjs";
5
+ const d = (e, o, s, a, r) => ({
6
+ requestId: `${a}-${Date.now().toString(36)}`,
7
+ url: s,
8
8
  host: window.location.host,
9
9
  protocol: window.location.protocol === "https:" ? "https" : "http",
10
10
  method: "GET",
11
11
  headers: {},
12
- publicConfig: r,
13
- signal: s
14
- }), m = async (r, e = {}) => {
15
- const o = e.stateElementId ?? d(r.id), s = document.getElementById(o);
16
- if (!s?.textContent)
17
- throw new Error(`SSR hydration state element "${o}" is missing.`);
18
- const t = JSON.parse(
19
- s.textContent
12
+ publicConfig: e,
13
+ domain: o,
14
+ signal: r
15
+ }), p = () => {
16
+ const e = document.getElementById("vue-ssr-lite-domain");
17
+ if (!e?.textContent) return null;
18
+ try {
19
+ return JSON.parse(e.textContent);
20
+ } catch {
21
+ return null;
22
+ }
23
+ }, y = async (e, o = {}) => {
24
+ const s = o.stateElementId ?? h(e.id), a = document.getElementById(s);
25
+ if (!a?.textContent)
26
+ throw new Error(`SSR hydration state element "${s}" is missing.`);
27
+ const r = JSON.parse(
28
+ a.textContent
20
29
  );
21
- if (t.version !== 1)
30
+ if (r.version !== 1)
22
31
  throw new Error("Unsupported SSR hydration state version.");
23
- const a = new AbortController(), c = u(
24
- t.publicConfig,
32
+ if (!r.domain)
33
+ throw new Error("SSR hydration state is missing domain context.");
34
+ const i = new AbortController(), l = d(
35
+ r.publicConfig,
36
+ r.domain,
25
37
  window.location.href,
26
38
  "browser",
27
- a.signal
39
+ i.signal
28
40
  );
29
- let n;
41
+ let t;
30
42
  try {
31
- n = await i(r, {
43
+ t = await u(e, {
32
44
  server: !1,
33
- request: c,
34
- hydrationState: t
35
- }), n.router && (await n.router.push(
45
+ request: l,
46
+ hydrationState: r
47
+ }), t.router && (await t.router.push(
36
48
  `${window.location.pathname}${window.location.search}${window.location.hash}`
37
- ), await n.router.isReady()), n.app.mount(e.mountSelector ?? r.mountSelector ?? "#app"), document.head.querySelectorAll(
38
- e.removeHeadSelector ?? "[data-vue-ssr-lite-head]"
39
- ).forEach((l) => l.remove()), s.remove();
40
- } catch (l) {
41
- a.abort();
49
+ ), await t.router.isReady()), t.app.mount(o.mountSelector ?? e.mountSelector ?? "#app"), document.head.querySelectorAll(
50
+ o.removeHeadSelector ?? "[data-vue-ssr-lite-head]"
51
+ ).forEach((n) => n.remove()), a.remove();
52
+ } catch (n) {
53
+ i.abort();
42
54
  try {
43
- n?.hydration.dispose();
44
- } catch (p) {
45
- console.error("[vue-ssr-lite] hydration cleanup failed", p);
55
+ t?.hydration.dispose();
56
+ } catch (c) {
57
+ console.error("[vue-ssr-lite] hydration cleanup failed", c);
46
58
  }
47
- throw l;
59
+ throw n;
48
60
  }
49
- }, S = async (r, e = {}) => {
50
- const o = new AbortController(), s = u(
51
- e.publicConfig ?? {},
52
- e.url ?? window.location.href,
61
+ }, f = async (e, o = {}) => {
62
+ const s = p(), a = o.domain ?? s?.domain;
63
+ if (!a)
64
+ throw new Error(
65
+ "vue-ssr-lite SPA mount requires domain context. Ensure the managed server injected #vue-ssr-lite-domain."
66
+ );
67
+ const r = o.publicConfig ?? s?.publicConfig ?? {}, i = new AbortController(), l = d(
68
+ r,
69
+ a,
70
+ o.url ?? window.location.href,
53
71
  "spa",
54
- o.signal
72
+ i.signal
55
73
  );
56
74
  let t;
57
75
  try {
58
- t = await i(r, {
76
+ t = await u(e, {
59
77
  server: !1,
60
78
  spa: !0,
61
- request: s
79
+ request: l
62
80
  }), t.router && (await t.router.push(
63
- e.url ?? `${window.location.pathname}${window.location.search}${window.location.hash}`
81
+ o.url ?? `${window.location.pathname}${window.location.search}${window.location.hash}`
64
82
  ), await t.router.isReady());
65
- const a = t.app, c = t;
66
- return a.mount(e.mountSelector ?? r.mountSelector ?? "#app"), {
67
- app: a,
83
+ const n = t.app, c = t;
84
+ return n.mount(o.mountSelector ?? e.mountSelector ?? "#app"), document.getElementById("vue-ssr-lite-domain")?.remove(), {
85
+ app: n,
68
86
  unmount: () => {
69
- o.abort(), a.unmount();
87
+ i.abort(), n.unmount();
70
88
  try {
71
89
  c.hydration.dispose();
72
- } catch (n) {
73
- console.error("[vue-ssr-lite] SPA cleanup failed", n);
90
+ } catch (m) {
91
+ console.error("[vue-ssr-lite] SPA cleanup failed", m);
74
92
  }
75
93
  }
76
94
  };
77
- } catch (a) {
78
- o.abort();
95
+ } catch (n) {
96
+ i.abort();
79
97
  try {
80
98
  t?.hydration.dispose();
81
99
  } catch (c) {
82
100
  console.error("[vue-ssr-lite] SPA cleanup failed", c);
83
101
  }
84
- throw a;
102
+ throw n;
85
103
  }
86
104
  };
87
105
  export {
88
- E as SSR_REQUEST_RESOLUTION,
89
- m as hydrateSsrApplication,
90
- S as mountSpaApplication,
91
- g as ssrWatch,
92
- R as ssrWatchEffect,
93
- v as useSsrResolution
106
+ g as SSR_DOMAIN_CONTEXT,
107
+ b as SSR_REQUEST_RESOLUTION,
108
+ C as buildSsrSubdomainUrl,
109
+ y as hydrateSsrApplication,
110
+ x as installSsrDomainContext,
111
+ f as mountSpaApplication,
112
+ R as resolveSsrDomainContext,
113
+ q as ssrWatch,
114
+ D as ssrWatchEffect,
115
+ A as useSsrDomain,
116
+ I as useSsrResolution
94
117
  };
package/dist/index.d.ts CHANGED
@@ -1,5 +1,8 @@
1
- import { SsrApplicationDefinition, SsrRuntimeDefinition } from './SsrRuntimeTypes';
1
+ import { SsrApplicationDefinition } from './SsrRuntimeTypes';
2
2
  export * from './SsrApplicationRuntime';
3
+ export * from './SsrConfigRuntime';
4
+ export * from './SsrConfigTypes';
5
+ export * from './SsrDomainRuntime';
3
6
  export * from './SsrHydrationRuntime';
4
7
  export * from './SsrReactivityRuntime';
5
8
  export * from './SsrRequestContext';
@@ -8,5 +11,4 @@ export * from './SsrRuntimeTypes';
8
11
  export * from './SsrSerialization';
9
12
  export * from './SsrDiagnosticsRuntime';
10
13
  export declare const defineSsrApplication: <T extends SsrApplicationDefinition<any, any, any>>(definition: T) => T;
11
- export declare const defineSsrRuntime: <T extends SsrRuntimeDefinition<any>>(definition: T) => T;
12
14
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,yBAAyB,CAAA;AACvC,cAAc,uBAAuB,CAAA;AACrC,cAAc,wBAAwB,CAAA;AACtC,cAAc,qBAAqB,CAAA;AACnC,cAAc,wBAAwB,CAAA;AACtC,cAAc,mBAAmB,CAAA;AACjC,cAAc,oBAAoB,CAAA;AAClC,cAAc,yBAAyB,CAAA;AAEvC,OAAO,KAAK,EACV,wBAAwB,EACxB,oBAAoB,EACrB,MAAM,mBAAmB,CAAA;AAE1B,eAAO,MAAM,oBAAoB,GAAI,CAAC,SAAS,wBAAwB,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,EACpF,YAAY,CAAC,KACZ,CAAe,CAAA;AAElB,eAAO,MAAM,gBAAgB,GAAI,CAAC,SAAS,oBAAoB,CAAC,GAAG,CAAC,EAClE,YAAY,CAAC,KACZ,CAAe,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,yBAAyB,CAAA;AACvC,cAAc,oBAAoB,CAAA;AAClC,cAAc,kBAAkB,CAAA;AAChC,cAAc,oBAAoB,CAAA;AAClC,cAAc,uBAAuB,CAAA;AACrC,cAAc,wBAAwB,CAAA;AACtC,cAAc,qBAAqB,CAAA;AACnC,cAAc,wBAAwB,CAAA;AACtC,cAAc,mBAAmB,CAAA;AACjC,cAAc,oBAAoB,CAAA;AAClC,cAAc,yBAAyB,CAAA;AAEvC,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,mBAAmB,CAAA;AAEjE,eAAO,MAAM,oBAAoB,GAAI,CAAC,SAAS,wBAAwB,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,EACpF,YAAY,CAAC,KACZ,CAAe,CAAA"}
package/dist/index.mjs CHANGED
@@ -1,25 +1,31 @@
1
- import { a as o, b as S, S as n, c as i, d as c, e as l, f as R, u as f } from "./chunks/SsrApplicationRuntime-lMR_sMdk.mjs";
2
- import { s as d, a as E } from "./chunks/SsrReactivityRuntime-CUbPx7ew.mjs";
3
- import { e as m, g as u, r as x, s as _, a as C } from "./chunks/SsrSerialization-k-3aCFYt.mjs";
4
- import { c as H } from "./chunks/SsrDiagnosticsRuntime-B5VbSgsA.mjs";
5
- const e = (s) => s, r = (s) => s;
1
+ import { S as t, e as o, f as S, a as i, b as n, c as l, g as c, h as d, i as f, r as R, u as m, j as p, d as E } from "./chunks/SsrApplicationRuntime-D4arUtsy.mjs";
2
+ import { d as u } from "./chunks/SsrConfigRuntime-D0DkOrVQ.mjs";
3
+ import { s as C, a as _ } from "./chunks/SsrReactivityRuntime-CroM1WJG.mjs";
4
+ import { e as D, g as N, r as g, s as I, a as A } from "./chunks/SsrSerialization-k-3aCFYt.mjs";
5
+ import { c as U } from "./chunks/SsrDiagnosticsRuntime-B5VbSgsA.mjs";
6
+ const e = (s) => s;
6
7
  export {
8
+ t as SSR_DOMAIN_CONTEXT,
7
9
  o as SSR_HYDRATION_CONTEXT,
8
10
  S as SSR_REQUEST_CONTEXT,
9
- n as SSR_REQUEST_RESOLUTION,
10
- H as collectSsrRenderDiagnostics,
11
- i as createSsrApplication,
11
+ i as SSR_REQUEST_RESOLUTION,
12
+ n as buildSsrSubdomainUrl,
13
+ U as collectSsrRenderDiagnostics,
14
+ l as createSsrApplication,
12
15
  c as createSsrHydrationController,
13
- l as createSsrResolutionController,
16
+ d as createSsrResolutionController,
14
17
  e as defineSsrApplication,
15
- r as defineSsrRuntime,
16
- m as escapeSsrHtml,
17
- u as getSsrStateElementId,
18
- x as renderSsrHead,
19
- _ as sanitizeSsrIdentifier,
20
- C as serializeSsrState,
21
- d as ssrWatch,
22
- E as ssrWatchEffect,
23
- R as useSsrRequestContext,
24
- f as useSsrResolution
18
+ u as defineSsrConfig,
19
+ D as escapeSsrHtml,
20
+ N as getSsrStateElementId,
21
+ f as installSsrDomainContext,
22
+ g as renderSsrHead,
23
+ R as resolveSsrDomainContext,
24
+ I as sanitizeSsrIdentifier,
25
+ A as serializeSsrState,
26
+ C as ssrWatch,
27
+ _ as ssrWatchEffect,
28
+ m as useSsrDomain,
29
+ p as useSsrRequestContext,
30
+ E as useSsrResolution
25
31
  };
@@ -1,10 +1,60 @@
1
- import { SsrHeaderValue, SsrRuntimeEntry } from '../SsrRuntimeTypes';
1
+ import { SsrHeaderValue } from '../SsrRuntimeTypes';
2
+ /** Minimal host-owning application shape used by the matcher. */
3
+ export interface SsrHostApplication {
4
+ id: string;
5
+ hosts: string[];
6
+ }
7
+ export type SsrHostMatchCategory = 'exact' | 'wildcard' | 'catch-all' | 'default';
8
+ export interface SsrHostMatchScore {
9
+ category: SsrHostMatchCategory;
10
+ /** Higher wins. Exact > longer wildcard suffix > shorter wildcard > catch-all. */
11
+ specificity: number;
12
+ pattern: string;
13
+ }
14
+ export interface SsrHostResolution<T extends SsrHostApplication = SsrHostApplication> {
15
+ entry: T;
16
+ matchedPattern: string | null;
17
+ normalizedHostname: string;
18
+ category: SsrHostMatchCategory;
19
+ specificity: number;
20
+ }
21
+ export declare class SsrHostConfigurationError extends Error {
22
+ constructor(message: string);
23
+ }
2
24
  export declare const normalizeSsrHost: (host: SsrHeaderValue) => string;
3
25
  export declare const stripSsrHostPort: (host: SsrHeaderValue) => string;
4
26
  export declare const normalizeSsrHostPattern: (pattern: string) => string;
5
27
  export declare const matchesSsrHostPattern: (host: string, pattern: string) => boolean;
28
+ /**
29
+ * Score a single host pattern against a request host.
30
+ * Returns null when the pattern is invalid or does not match.
31
+ *
32
+ * Precedence (higher specificity wins):
33
+ * exact hostname > longer wildcard suffix > shorter wildcard suffix > `*`
34
+ */
35
+ export declare const scoreSsrHostMatch: (host: string, pattern: string) => SsrHostMatchScore | null;
36
+ /**
37
+ * Validate host patterns across compiled applications at startup.
38
+ *
39
+ * Rejects duplicate exact/wildcard ownership, invalid syntax, patterns that
40
+ * carry protocols/paths/ports, and multiple catch-all applications. Overlapping
41
+ * patterns with different specificity are allowed; the more specific pattern
42
+ * wins at request time.
43
+ */
44
+ export declare const validateSsrHostEntries: (applications: readonly SsrHostApplication[]) => void;
45
+ /**
46
+ * Resolve the application entry for a request host using specificity, not
47
+ * declaration order.
48
+ *
49
+ * Precedence:
50
+ * exact hostname >
51
+ * longest matching wildcard suffix >
52
+ * shorter matching wildcard suffix >
53
+ * catch-all `*` >
54
+ * `defaultEntryId`
55
+ */
56
+ export declare const resolveSsrHostEntry: <T extends SsrHostApplication>(applications: readonly T[], host: string, defaultApplicationId?: string) => SsrHostResolution<T> | null;
6
57
  export declare const resolveSsrForwardedHost: (forwardedHost: SsrHeaderValue, host: SsrHeaderValue, trustProxy?: boolean) => string;
7
58
  export declare const resolveSsrForwardedProtocol: (forwardedProtocol: SsrHeaderValue, fallback: "http" | "https", trustProxy?: boolean) => "http" | "https";
8
- export declare const resolveSsrEntry: (entries: SsrRuntimeEntry[], host: string, defaultEntryId?: string) => SsrRuntimeEntry | null;
9
59
  export declare const filterSsrCookieHeader: (cookieHeader: SsrHeaderValue, allowlist?: readonly string[], denylist?: readonly string[]) => string | undefined;
10
60
  //# sourceMappingURL=SsrHostRuntime.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"SsrHostRuntime.d.ts","sourceRoot":"","sources":["../../src/server/SsrHostRuntime.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAA;AAOzE,eAAO,MAAM,gBAAgB,GAAI,MAAM,cAAc,KAAG,MAmCvD,CAAA;AAED,eAAO,MAAM,gBAAgB,GAAI,MAAM,cAAc,KAAG,MAQvD,CAAA;AAED,eAAO,MAAM,uBAAuB,GAAI,SAAS,MAAM,KAAG,MAYzD,CAAA;AAED,eAAO,MAAM,qBAAqB,GAAI,MAAM,MAAM,EAAE,SAAS,MAAM,KAAG,OAYrE,CAAA;AAED,eAAO,MAAM,uBAAuB,GAClC,eAAe,cAAc,EAC7B,MAAM,cAAc,EACpB,oBAAkB,KACjB,MAC4E,CAAA;AAE/E,eAAO,MAAM,2BAA2B,GACtC,mBAAmB,cAAc,EACjC,UAA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package/dist/server.d.ts CHANGED
@@ -4,6 +4,9 @@ export * from './server/SsrHtmlRuntime';
4
4
  export * from './server/SsrResponseCacheRuntime';
5
5
  export * from './server/SsrRuntimeConfigRuntime';
6
6
  export * from './server/SsrServerRuntime';
7
+ export * from './SsrConfigCompileRuntime';
8
+ export * from './SsrDomainRuntime';
7
9
  export * from './SsrRenderRuntime';
8
10
  export type * from './SsrRuntimeTypes';
11
+ export type * from './SsrConfigTypes';
9
12
  //# sourceMappingURL=server.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../src/server.ts"],"names":[],"mappings":"AAAA,cAAc,0BAA0B,CAAA;AACxC,cAAc,yBAAyB,CAAA;AACvC,cAAc,yBAAyB,CAAA;AACvC,cAAc,kCAAkC,CAAA;AAChD,cAAc,kCAAkC,CAAA;AAChD,cAAc,2BAA2B,CAAA;AACzC,cAAc,oBAAoB,CAAA;AAClC,mBAAmB,mBAAmB,CAAA"}
1
+ {"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../src/server.ts"],"names":[],"mappings":"AAAA,cAAc,0BAA0B,CAAA;AACxC,cAAc,yBAAyB,CAAA;AACvC,cAAc,yBAAyB,CAAA;AACvC,cAAc,kCAAkC,CAAA;AAChD,cAAc,kCAAkC,CAAA;AAChD,cAAc,2BAA2B,CAAA;AACzC,cAAc,2BAA2B,CAAA;AACzC,cAAc,oBAAoB,CAAA;AAClC,cAAc,oBAAoB,CAAA;AAClC,mBAAmB,mBAAmB,CAAA;AACtC,mBAAmB,kBAAkB,CAAA"}