vue-ssr-lite 0.2.7 → 0.2.11
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 +79 -82
- package/dist/SsrConfigCompileRuntime.d.ts +5 -1
- package/dist/SsrConfigCompileRuntime.d.ts.map +1 -1
- package/dist/SsrConfigTypes.d.ts +3 -1
- package/dist/SsrConfigTypes.d.ts.map +1 -1
- package/dist/chunks/{SsrHtmlRuntime-5FJMZjxW.mjs → SsrHtmlRuntime-BJUxjM2F.mjs} +81 -85
- package/dist/chunks/{SsrServerRuntime-BJ2NQFEl.mjs → SsrServerRuntime-CiuWVKYb.mjs} +1 -1
- package/dist/cli.mjs +2 -2
- package/dist/server/SsrHostRuntime.d.ts +6 -0
- package/dist/server/SsrHostRuntime.d.ts.map +1 -1
- package/dist/server.mjs +2 -2
- package/dist/vite/SsrVitePlugin.d.ts.map +1 -1
- package/dist/vite.mjs +80 -53
- package/package.json +4 -1
package/README.md
CHANGED
|
@@ -28,7 +28,7 @@ It includes routing, browser hydration, production builds, a managed Node server
|
|
|
28
28
|
- Health and readiness checks
|
|
29
29
|
- Request timeouts
|
|
30
30
|
- Optional response caching
|
|
31
|
-
- Cookie
|
|
31
|
+
- Cookie allow / deny filtering (including deny-only)
|
|
32
32
|
- Proxy-aware host and protocol resolution
|
|
33
33
|
- Graceful shutdown
|
|
34
34
|
- TypeScript support
|
|
@@ -68,39 +68,50 @@ yarn add vue-ssr-lite vue vue-router @vue/server-renderer
|
|
|
68
68
|
yarn add --dev vite @vitejs/plugin-vue
|
|
69
69
|
```
|
|
70
70
|
|
|
71
|
-
##
|
|
71
|
+
## Clean consumer (canonical path)
|
|
72
72
|
|
|
73
|
-
|
|
73
|
+
Every project follows the same five pieces. `ssr.config` is the single source of
|
|
74
|
+
truth — there is no `spaEntries`, no `kind`, no manual `main.ts` mount, and no
|
|
75
|
+
`server.role`.
|
|
74
76
|
|
|
75
|
-
|
|
|
77
|
+
| Piece | Role |
|
|
76
78
|
| --- | --- |
|
|
77
|
-
| `
|
|
78
|
-
| `
|
|
79
|
+
| `ssr.config.ts` | Apps, domains, `runtime`, cookies, endpoints |
|
|
80
|
+
| `defineSsrApplication()` modules | One module per app (`application.module`) |
|
|
81
|
+
| HTML shells | Mount node only — **no** bootstrap `<script type="module" src>` |
|
|
82
|
+
| `vite.config.ts` | `vue()` + `vueSsrLite()` |
|
|
83
|
+
| CLI scripts | `vue-ssr-lite dev \| build \| start` |
|
|
79
84
|
|
|
80
|
-
|
|
81
|
-
`application: { module, exportName }` at that module. Do not maintain a separate
|
|
82
|
-
`main.ts` / `ErpClient.ts` bootstrap — `vueSsrLite()` injects the client entry
|
|
83
|
-
from `ssr.config`.
|
|
85
|
+
Render modes (declared as `render` on each application):
|
|
84
86
|
|
|
87
|
+
| `render` | Behavior |
|
|
88
|
+
| --- | --- |
|
|
89
|
+
| `spa` | Serves the HTML shell; the plugin generates the browser mount entry |
|
|
90
|
+
| `ssr` | Server-renders Vue and generates the hydration client entry |
|
|
85
91
|
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
92
|
+
`vueSsrLite()` defaults the client Vite `build.outDir` to `dist/client` so
|
|
93
|
+
`vue-ssr-lite start` finds assets without a consumer override. Set
|
|
94
|
+
`build.outDir` or `server.clientOutDir` only when you need a different path.
|
|
89
95
|
|
|
90
|
-
|
|
96
|
+
Production compile requires top-level `runtime` (typically `APP_RUNTIME`) and
|
|
97
|
+
each app’s `domain.production`. `publicConfig` is opaque — validating API URLs
|
|
98
|
+
is the consumer’s job.
|
|
91
99
|
|
|
92
|
-
|
|
100
|
+
For async config, export a factory that *returns* `defineSsrConfig(...)`:
|
|
93
101
|
|
|
94
|
-
|
|
102
|
+
```ts
|
|
103
|
+
export default async () =>
|
|
104
|
+
defineSsrConfig({
|
|
105
|
+
name: 'my-platform',
|
|
106
|
+
runtime: process.env.APP_RUNTIME,
|
|
107
|
+
applications: { /* ... */ },
|
|
108
|
+
})
|
|
109
|
+
```
|
|
95
110
|
|
|
96
|
-
|
|
97
|
-
- Storefront
|
|
98
|
-
- Blog
|
|
99
|
-
- Marketing website
|
|
100
|
-
- Documentation website
|
|
101
|
-
- SEO-focused application
|
|
111
|
+
`defineSsrConfig` itself is synchronous and accepts a plain object.
|
|
102
112
|
|
|
103
|
-
|
|
113
|
+
See `fixtures/clean-consumer` in this repo for a minimal SPA project that
|
|
114
|
+
matches this contract.
|
|
104
115
|
|
|
105
116
|
## Quick Start: SPA and SSR Together
|
|
106
117
|
|
|
@@ -111,17 +122,17 @@ The following example creates:
|
|
|
111
122
|
|
|
112
123
|
## 1. Create the SPA Application
|
|
113
124
|
|
|
114
|
-
Define the application once
|
|
115
|
-
|
|
116
|
-
|
|
125
|
+
Define the application once. The library owns router creation, plugin
|
|
126
|
+
installation, public-config delivery, and mounting via the generated virtual
|
|
127
|
+
client — do **not** add a `main.ts` bootstrap.
|
|
117
128
|
|
|
118
129
|
```ts
|
|
119
|
-
// src/
|
|
130
|
+
// src/dashboard/DashboardBootstrap.ts
|
|
120
131
|
import { defineSsrApplication } from 'vue-ssr-lite'
|
|
121
132
|
import App from './App.vue'
|
|
122
133
|
import routes from './routes'
|
|
123
134
|
|
|
124
|
-
export const
|
|
135
|
+
export const createDashboardApplication = defineSsrApplication({
|
|
125
136
|
id: 'dashboard',
|
|
126
137
|
rootComponent: App,
|
|
127
138
|
routes,
|
|
@@ -129,18 +140,10 @@ export const app = defineSsrApplication({
|
|
|
129
140
|
})
|
|
130
141
|
```
|
|
131
142
|
|
|
132
|
-
```ts
|
|
133
|
-
// src/spa/main.ts — thin entry
|
|
134
|
-
import { mountSpaApplication } from 'vue-ssr-lite/client'
|
|
135
|
-
import { app } from './app'
|
|
136
|
-
|
|
137
|
-
void mountSpaApplication(app)
|
|
138
|
-
```
|
|
139
|
-
|
|
140
143
|
Create the SPA root component:
|
|
141
144
|
|
|
142
145
|
```vue
|
|
143
|
-
<!-- src/
|
|
146
|
+
<!-- src/dashboard/App.vue -->
|
|
144
147
|
<script setup lang="ts">
|
|
145
148
|
import { RouterView } from 'vue-router'
|
|
146
149
|
</script>
|
|
@@ -150,7 +153,7 @@ import { RouterView } from 'vue-router'
|
|
|
150
153
|
</template>
|
|
151
154
|
```
|
|
152
155
|
|
|
153
|
-
Create the SPA HTML
|
|
156
|
+
Create the SPA HTML shell (no bootstrap script):
|
|
154
157
|
|
|
155
158
|
```html
|
|
156
159
|
<!-- index.html -->
|
|
@@ -166,16 +169,10 @@ Create the SPA HTML entry:
|
|
|
166
169
|
|
|
167
170
|
<body>
|
|
168
171
|
<div id="app"></div>
|
|
169
|
-
|
|
170
|
-
<script
|
|
171
|
-
type="module"
|
|
172
|
-
src="/src/spa/main.ts"></script>
|
|
173
172
|
</body>
|
|
174
173
|
</html>
|
|
175
174
|
```
|
|
176
175
|
|
|
177
|
-
The same definition backs the SSR entry, so the SPA and SSR paths cannot drift.
|
|
178
|
-
|
|
179
176
|
## 2. Create the SSR Application
|
|
180
177
|
|
|
181
178
|
Create the SSR root component:
|
|
@@ -369,11 +366,14 @@ export default defineConfig({
|
|
|
369
366
|
`vueSsrLite()` generates:
|
|
370
367
|
|
|
371
368
|
- HTML Rollup inputs from each `template`
|
|
369
|
+
- Client `build.outDir` defaulting to `dist/client` (aligned with the Node server)
|
|
372
370
|
- `virtual:vue-ssr-lite/client/<id>` SPA mount / SSR hydrate entries
|
|
373
|
-
- `virtual:vue-ssr-lite/runtime` for the Node server (
|
|
371
|
+
- `virtual:vue-ssr-lite/runtime` for the Node server (SSR apps only; SPA modules are omitted)
|
|
374
372
|
|
|
375
373
|
HTML templates should not include a manual `<script type="module" src="...">`
|
|
376
|
-
bootstrap — the plugin
|
|
374
|
+
bootstrap — the plugin strips those tags from matched templates and injects the
|
|
375
|
+
generated client entry. Editing `ssr.config.*` invalidates the cached config and
|
|
376
|
+
triggers a full reload in dev.
|
|
377
377
|
|
|
378
378
|
## 5. Add Commands
|
|
379
379
|
|
|
@@ -600,30 +600,31 @@ For reusable REST caching and hydration, register an SSR-compatible Vue plugin i
|
|
|
600
600
|
|
|
601
601
|
## Public Configuration
|
|
602
602
|
|
|
603
|
-
Pass
|
|
603
|
+
Pass opaque, browser-safe values per application in `ssr.config`:
|
|
604
604
|
|
|
605
605
|
```ts
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
'https://api.example.com/graphql',
|
|
606
|
+
applications: {
|
|
607
|
+
website: {
|
|
608
|
+
// ...
|
|
609
|
+
publicConfig: {
|
|
610
|
+
apiUrl: 'https://api.example.com',
|
|
611
|
+
graphqlEndpoint: 'https://api.example.com/graphql',
|
|
612
|
+
},
|
|
612
613
|
},
|
|
613
614
|
}
|
|
614
615
|
```
|
|
615
616
|
|
|
616
|
-
Access them in
|
|
617
|
+
Access them in a component:
|
|
617
618
|
|
|
618
619
|
```ts
|
|
619
620
|
import { useSsrRequestContext } from 'vue-ssr-lite'
|
|
620
621
|
|
|
621
622
|
const context = useSsrRequestContext()
|
|
622
|
-
|
|
623
623
|
const apiUrl = context.publicConfig.apiUrl
|
|
624
624
|
```
|
|
625
625
|
|
|
626
|
-
|
|
626
|
+
The library does not interpret `publicConfig` (no GraphQL/REST assumptions).
|
|
627
|
+
Validate transport URLs in your own plugins or env checks.
|
|
627
628
|
|
|
628
629
|
## SEO
|
|
629
630
|
|
|
@@ -755,6 +756,11 @@ catch-all (`*`) applications are rejected at startup.
|
|
|
755
756
|
|
|
756
757
|
Do not include protocols, paths, query strings, or ports in domain values.
|
|
757
758
|
|
|
759
|
+
`localAliases: true` adds bare loopback hosts (`localhost`, `127.0.0.1`, …) only
|
|
760
|
+
when the app’s development base is itself a loopback hostname. Subdomain bases
|
|
761
|
+
such as `shop.localhost` already expand to `*.shop.localhost` and do not claim
|
|
762
|
+
bare `localhost`, so multiple apps can enable `localAliases` safely.
|
|
763
|
+
|
|
758
764
|
Set `server.trustProxy` to `true` only when the Node process sits behind a trusted reverse proxy. Then `X-Forwarded-Host` and `X-Forwarded-Proto` are used for host matching and absolute URLs. Leave it `false` for direct local traffic.
|
|
759
765
|
|
|
760
766
|
## Runtime Roles
|
|
@@ -828,10 +834,12 @@ With that setup:
|
|
|
828
834
|
|
|
829
835
|
If a host matches an application that the current role does not allow, the server responds with `421`.
|
|
830
836
|
|
|
831
|
-
Development may
|
|
832
|
-
rejects a missing `runtime
|
|
837
|
+
Development may omit `runtime` (the compiler defaults the process role to
|
|
838
|
+
`unified`). Production compilation rejects a missing `runtime` or
|
|
839
|
+
`domain.production`. It does **not** validate `publicConfig` shape — pass
|
|
840
|
+
whatever your plugins need and validate API URLs in the consumer.
|
|
833
841
|
|
|
834
|
-
|
|
842
|
+
For async loading, export `async () => defineSsrConfig({ ... })`.
|
|
835
843
|
|
|
836
844
|
## Custom Endpoints
|
|
837
845
|
|
|
@@ -938,9 +946,9 @@ cookies: {
|
|
|
938
946
|
}
|
|
939
947
|
```
|
|
940
948
|
|
|
941
|
-
-
|
|
942
|
-
- `deny`
|
|
943
|
-
-
|
|
949
|
+
- Both empty → forward nothing (secure default when SSR needs no cookies).
|
|
950
|
+
- `allow` empty and `deny` non-empty → forward all cookies except `deny`.
|
|
951
|
+
- `allow` non-empty → forward `allow ∩ ¬deny`.
|
|
944
952
|
|
|
945
953
|
## Server Configuration
|
|
946
954
|
|
|
@@ -1050,28 +1058,17 @@ warnings; production render paths are untouched.
|
|
|
1050
1058
|
|
|
1051
1059
|
## Summary
|
|
1052
1060
|
|
|
1053
|
-
|
|
1054
|
-
|
|
1055
|
-
|
|
1056
|
-
|
|
1057
|
-
|
|
1058
|
-
|
|
1059
|
-
|
|
1060
|
-
For SSR:
|
|
1061
|
-
|
|
1062
|
-
1. Create the Vue root component and routes.
|
|
1063
|
-
2. Define it with `defineSsrApplication()`.
|
|
1064
|
-
3. Create an SSR HTML template.
|
|
1065
|
-
4. Register it in `applications`.
|
|
1066
|
-
5. Add a runtime entry with `kind: 'ssr'`.
|
|
1067
|
-
|
|
1068
|
-
Optional for multi-mode deployments:
|
|
1061
|
+
1. Add `ssr.config.ts` with `defineSsrConfig({ name, runtime, applications })`.
|
|
1062
|
+
2. For each app: `defineSsrApplication()` module, HTML shell (no bootstrap script),
|
|
1063
|
+
`render: 'spa' | 'ssr'`, and `application: { module, exportName }`.
|
|
1064
|
+
3. Wire Vite with `vue()` + `vueSsrLite()` (client assets land in `dist/client`).
|
|
1065
|
+
4. Run `vue-ssr-lite dev|build|start`.
|
|
1066
|
+
5. In production set `APP_RUNTIME` / `runtime` and every `domain.production`.
|
|
1069
1067
|
|
|
1070
|
-
|
|
1071
|
-
|
|
1072
|
-
3. Restrict each entry with `roles`.
|
|
1068
|
+
Optional: restrict apps with `roles`, filter cookies, add endpoints, or pass
|
|
1069
|
+
`server.onMetrics` / `server.renderError` through `ssr.config`.
|
|
1073
1070
|
|
|
1074
|
-
|
|
1071
|
+
SPA and SSR apps share one project, one build, and one production server.
|
|
1075
1072
|
|
|
1076
1073
|
## License
|
|
1077
1074
|
|
|
@@ -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,aAAa,EACb,aAAa,EACd,MAAM,kBAAkB,CAAA;AACzB,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAA;AAEpD,OAAO,KAAK,EACV,wBAAwB,EACxB,qBAAqB,EACrB,YAAY,EACZ,iBAAiB,EACjB,wBAAwB,EACxB,gBAAgB,EACjB,MAAM,mBAAmB,CAAA;AAM1B,OAAO,EAAE,eAAe,EAAE,CAAA;
|
|
1
|
+
{"version":3,"file":"SsrConfigCompileRuntime.d.ts","sourceRoot":"","sources":["../src/SsrConfigCompileRuntime.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAEV,0BAA0B,EAE1B,uBAAuB,EAEvB,SAAS,EAET,aAAa,EACb,aAAa,EACd,MAAM,kBAAkB,CAAA;AACzB,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAA;AAEpD,OAAO,KAAK,EACV,wBAAwB,EACxB,qBAAqB,EACrB,YAAY,EACZ,iBAAiB,EACjB,wBAAwB,EACxB,gBAAgB,EACjB,MAAM,mBAAmB,CAAA;AAM1B,OAAO,EAAE,eAAe,EAAE,CAAA;AAc1B,eAAO,MAAM,sBAAsB,iCAAiC,CAAA;AACpE,eAAO,MAAM,yBAAyB,iCAAiC,CAAA;AAEvE,MAAM,WAAW,sBAAsB;IACrC,EAAE,EAAE,MAAM,CAAA;IACV,IAAI,EAAE,YAAY,CAAA;IAClB,QAAQ,EAAE,MAAM,CAAA;IAChB,KAAK,EAAE,MAAM,EAAE,CAAA;IACf,KAAK,CAAC,EAAE,MAAM,EAAE,CAAA;IAChB,WAAW,CAAC,EAAE,wBAAwB,CAAC,GAAG,EAAE,GAAG,EAAE,G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C,OAAO,OAAO,KACb,KAAK,IAAI,uBAOT,CAAA;AAiIH,MAAM,WAAW,uBAAuB;IACtC,WAAW,CAAC,EAAE,OAAO,CAAA;IACrB,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,YAAY,CAAC,EAAE,CAAC,SAAS,EAAE,MAAM,KAAK,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAA;CACvE;AAqCD,eAAO,MAAM,oBAAoB,GAC/B,MAAM,MAAM,EACZ,WAAW,MAAM,KAChB,OAAO,CAAC,MAAM,CAchB,CAAA;AAED,mEAAmE;AACnE,eAAO,MAAM,qBAAqB,GAAI,QAAQ,SAAS,KAAG,cA0BzD,CAAA;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,CAkI3B,CAAA"}
|
package/dist/SsrConfigTypes.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { SsrApplicationDefinition, SsrEndpointDefinition, SsrLogger, SsrReadinessProbe, SsrResponseCacheStrategy } from './SsrRuntimeTypes';
|
|
1
|
+
import { SsrApplicationDefinition, SsrEndpointDefinition, SsrErrorRenderContext, SsrHttpResponse, SsrLogger, SsrReadinessProbe, SsrRenderMetrics, SsrResponseCacheStrategy } from './SsrRuntimeTypes';
|
|
2
2
|
/** How an application owns its apex hostname and subdomains. */
|
|
3
3
|
export type SsrDomainMode = 'root' | 'subdomains' | 'root-and-subdomains';
|
|
4
4
|
export type SsrRenderMode = 'spa' | 'ssr';
|
|
@@ -82,6 +82,8 @@ export interface SsrConfigServerOptions {
|
|
|
82
82
|
resolutionDeadlineMs?: number;
|
|
83
83
|
diagnostics?: boolean;
|
|
84
84
|
logger?: SsrLogger;
|
|
85
|
+
onMetrics?: (metrics: SsrRenderMetrics) => void;
|
|
86
|
+
renderError?: (context: SsrErrorRenderContext) => SsrHttpResponse | null | Promise<SsrHttpResponse | null>;
|
|
85
87
|
}
|
|
86
88
|
/**
|
|
87
89
|
* Flat Vite/Nuxt-style SSR configuration.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SsrConfigTypes.d.ts","sourceRoot":"","sources":["../src/SsrConfigTypes.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,mBAAmB,CAAA;AACjE,OAAO,KAAK,EACV,qBAAqB,EACrB,SAAS,EACT,iBAAiB,EACjB,wBAAwB,EACzB,MAAM,mBAAmB,CAAA;AAE1B,gEAAgE;AAChE,MAAM,MAAM,aAAa,GAAG,MAAM,GAAG,YAAY,GAAG,qBAAqB,CAAA;AAEzE,MAAM,MAAM,aAAa,GAAG,KAAK,GAAG,KAAK,CAAA;AAEzC,oEAAoE;AACpE,MAAM,MAAM,oBAAoB,GAC5B,sBAAsB,GACtB,uBAAuB,CAAA;AAE3B,MAAM,WAAW,wBAAwB;IACvC,MAAM,EAAE,oBAAoB,CAAA;CAC7B;AAED,MAAM,WAAW,0BAA0B;IACzC,mDAAmD;IACnD,WAAW,EAAE,MAAM,CAAA;IACnB,4EAA4E;IAC5E,UAAU,EAAE,MAAM,CAAA;IAClB,yCAAyC;IACzC,IAAI,CAAC,EAAE,aAAa,CAAA;IACpB,mEAAmE;IACnE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A;IAClD,0DAA0D;IAC1D,oBAAoB,CAAC,EAAE,MAAM,CAAA;IAC7B,SAAS,CAAC,EAAE,iBAAiB,EAAE,CAAA;CAChC;AAED,MAAM,MAAM,eAAe,GACvB,SAAS,GACT,CAAC,MAAM,SAAS,GAAG,OAAO,CAAC,SAAS,CAAC,CAAC,CAAA;AAE1C,kFAAkF;AAClF,MAAM,WAAW,gBAAgB;IAC/B,+DAA+D;IAC/D,KAAK,EAAE,MAAM,CAAA;IACb,QAAQ,EAAE,MAAM,CAAA;IAChB,4DAA4D;IAC5D,UAAU,EAAE,MAAM,CAAA;IAClB,8EAA8E;IAC9E,SAAS,EAAE,MAAM,GAAG,IAAI,CAAA;IACxB,cAAc,EAAE,OAAO,CAAA;IACvB,WAAW,EAAE,OAAO,CAAA;IACpB,2CAA2C;IAC3C,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;CAC/B"}
|
|
@@ -1,20 +1,20 @@
|
|
|
1
|
-
import { access as
|
|
2
|
-
import { randomBytes as
|
|
1
|
+
import { access as I, mkdir as z, writeFile as k, rm as D } from "node:fs/promises";
|
|
2
|
+
import { randomBytes as L } from "node:crypto";
|
|
3
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 j, c 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 B, r as q } from "./SsrSerialization-DeKozeIm.mjs";
|
|
6
|
+
const O = (t) => String(Array.isArray(t) ? t[0] : t || "").split(",", 1)[0].trim(), J = 1e6;
|
|
7
7
|
class p extends Error {
|
|
8
8
|
constructor(e) {
|
|
9
9
|
super(e), this.name = "SsrHostConfigurationError";
|
|
10
10
|
}
|
|
11
11
|
}
|
|
12
|
-
const
|
|
12
|
+
const F = (t, e) => {
|
|
13
13
|
const i = m(t), o = E(e);
|
|
14
14
|
return !i || !o ? !1 : o === "*" ? !0 : o.startsWith("*.") ? i.endsWith(`.${o.slice(2)}`) : v(t) === o || i === m(o);
|
|
15
|
-
},
|
|
15
|
+
}, U = (t, e) => {
|
|
16
16
|
const i = m(t), o = E(e);
|
|
17
|
-
if (!i || !o || !
|
|
17
|
+
if (!i || !o || !F(t, o)) return null;
|
|
18
18
|
if (o === "*")
|
|
19
19
|
return { category: "catch-all", specificity: 0, pattern: o };
|
|
20
20
|
if (o.startsWith("*."))
|
|
@@ -26,10 +26,10 @@ const J = (t, e) => {
|
|
|
26
26
|
const n = m(o);
|
|
27
27
|
return {
|
|
28
28
|
category: "exact",
|
|
29
|
-
specificity:
|
|
29
|
+
specificity: J + n.length,
|
|
30
30
|
pattern: o
|
|
31
31
|
};
|
|
32
|
-
},
|
|
32
|
+
}, V = (t) => {
|
|
33
33
|
const e = /* @__PURE__ */ new Map(), i = [];
|
|
34
34
|
for (const o of t) {
|
|
35
35
|
const n = o.hosts ?? [];
|
|
@@ -74,13 +74,13 @@ const J = (t, e) => {
|
|
|
74
74
|
throw new p(
|
|
75
75
|
`Multiple catch-all ("*") host applications are not allowed (applications: ${i.join(", ")}).`
|
|
76
76
|
);
|
|
77
|
-
},
|
|
77
|
+
}, dt = (t, e, i) => {
|
|
78
78
|
const o = m(e);
|
|
79
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 = U(e, l);
|
|
84
84
|
if (!a) continue;
|
|
85
85
|
const r = {
|
|
86
86
|
entry: s,
|
|
@@ -107,26 +107,26 @@ const J = (t, e) => {
|
|
|
107
107
|
category: "default",
|
|
108
108
|
specificity: -1
|
|
109
109
|
} : null;
|
|
110
|
-
},
|
|
110
|
+
}, ft = (t, e, i = !1) => v(i && O(t) || e), ut = (t, e, i = !1) => {
|
|
111
111
|
if (!i) return e;
|
|
112
112
|
const o = O(t).toLowerCase();
|
|
113
113
|
return o === "http" || o === "https" ? o : e;
|
|
114
|
-
}, R = /^[!#$%&'*+.^_`|~0-9A-Za-z-]+$/,
|
|
114
|
+
}, R = /^[!#$%&'*+.^_`|~0-9A-Za-z-]+$/, mt = (t, e = [], i = []) => {
|
|
115
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;
|
|
116
|
+
if (!t || o.size === 0 && n.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 n.has(a) ? !1 : o.size === 0 ? !0 : o.has(a);
|
|
122
122
|
});
|
|
123
123
|
return c.length ? c.join("; ") : void 0;
|
|
124
|
-
},
|
|
124
|
+
}, M = ["localhost", "127.0.0.1", "0.0.0.0", "::1"], K = new Set(M), C = [
|
|
125
125
|
"ssr.config.ts",
|
|
126
126
|
"ssr.config.mts",
|
|
127
127
|
"ssr.config.js",
|
|
128
128
|
"ssr.config.mjs"
|
|
129
|
-
],
|
|
129
|
+
], W = (t) => K.has(t), ht = "virtual:vue-ssr-lite/runtime", St = "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
130
|
const i = m(v(t) || t);
|
|
131
131
|
if (!i || i.includes("/") || i.includes("?"))
|
|
132
132
|
throw new p(
|
|
@@ -135,7 +135,7 @@ const J = (t, e) => {
|
|
|
135
135
|
return i.replace(/^\[|\]$/g, "");
|
|
136
136
|
}, f = (t, e) => {
|
|
137
137
|
t.includes(e) || t.push(e);
|
|
138
|
-
},
|
|
138
|
+
}, Z = (t, e) => {
|
|
139
139
|
const i = t.mode ?? "root-and-subdomains", o = h(
|
|
140
140
|
e ? t.development : t.production,
|
|
141
141
|
e ? "domain.development" : "domain.production"
|
|
@@ -145,8 +145,8 @@ const J = (t, e) => {
|
|
|
145
145
|
t.production,
|
|
146
146
|
"domain.production"
|
|
147
147
|
);
|
|
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
|
|
148
|
+
if (c !== o && ((i === "root" || i === "root-and-subdomains") && f(n, c), (i === "subdomains" || i === "root-and-subdomains") && f(n, `*.${c}`)), t.localAliases && W(o))
|
|
149
|
+
for (const s of M) f(n, s);
|
|
150
150
|
}
|
|
151
151
|
for (const c of t.additionalHosts ?? [])
|
|
152
152
|
f(n, h(c, "domain.additionalHosts"));
|
|
@@ -155,55 +155,49 @@ const J = (t, e) => {
|
|
|
155
155
|
"Application domain configuration produced an empty host list."
|
|
156
156
|
);
|
|
157
157
|
return n;
|
|
158
|
-
},
|
|
158
|
+
}, _ = (t) => t == null ? [] : Array.isArray(t) ? t.map((e) => String(e).trim()).filter(Boolean) : String(t).split(",").map((e) => e.trim()).filter(Boolean), X = (t) => !!(t && typeof t == "object" && typeof t.id == "string" && t.rootComponent), G = (t, e) => t.id === e ? t : { ...t, id: e }, Y = (t, e, i, o) => {
|
|
159
159
|
const n = e ? t[e] : t.default;
|
|
160
160
|
if (n == null)
|
|
161
161
|
throw new p(
|
|
162
162
|
`Application "${i}" ${o} module must export${e ? ` "${e}"` : " a default value"}.`
|
|
163
163
|
);
|
|
164
164
|
return n;
|
|
165
|
-
},
|
|
165
|
+
}, P = async (t, e, i) => {
|
|
166
166
|
const o = typeof t == "function" ? await t() : t;
|
|
167
|
-
if (!
|
|
167
|
+
if (!X(o))
|
|
168
168
|
throw new p(
|
|
169
169
|
`Application "${e}" ${i} loader must return a valid SsrApplicationDefinition.`
|
|
170
170
|
);
|
|
171
|
-
return
|
|
172
|
-
},
|
|
171
|
+
return G(o, e);
|
|
172
|
+
}, Q = async (t, e, i, o) => {
|
|
173
173
|
if (b(t)) {
|
|
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 =
|
|
175
|
-
return
|
|
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 = Y(s, t.exportName, e, i);
|
|
175
|
+
return P(l, e, i);
|
|
176
176
|
}
|
|
177
|
-
return
|
|
178
|
-
},
|
|
177
|
+
return P(t, e, i);
|
|
178
|
+
}, tt = (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, i] of Object.entries(t.applications))
|
|
183
|
+
for (const [e, i] of Object.entries(t.applications))
|
|
184
184
|
if (!String(i.domain?.production || "").trim())
|
|
185
185
|
throw new Error(
|
|
186
186
|
`Application "${e}" requires domain.production in production.`
|
|
187
187
|
);
|
|
188
|
-
|
|
189
|
-
if (!String(o?.endpoint || "").trim())
|
|
190
|
-
throw new Error(
|
|
191
|
-
`Application "${e}" requires publicConfig.api.endpoint in production.`
|
|
192
|
-
);
|
|
193
|
-
}
|
|
194
|
-
}, Q = async (t, e) => {
|
|
188
|
+
}, et = async (t, e) => {
|
|
195
189
|
if (e) return S(t, e);
|
|
196
190
|
for (const i of C) {
|
|
197
191
|
const o = S(t, i);
|
|
198
192
|
try {
|
|
199
|
-
return await
|
|
193
|
+
return await I(o), o;
|
|
200
194
|
} catch {
|
|
201
195
|
}
|
|
202
196
|
}
|
|
203
197
|
throw new Error(
|
|
204
198
|
`vue-ssr-lite could not find an SSR config in ${t}. Expected one of: ${C.join(", ")}`
|
|
205
199
|
);
|
|
206
|
-
},
|
|
200
|
+
}, ot = (t) => {
|
|
207
201
|
const e = [];
|
|
208
202
|
for (const [i, o] of Object.entries(t.applications || {})) {
|
|
209
203
|
if (!o.render || !o.template)
|
|
@@ -226,8 +220,8 @@ const J = (t, e) => {
|
|
|
226
220
|
if (!e.length)
|
|
227
221
|
throw new Error("ssr.config must declare at least one application for Vite.");
|
|
228
222
|
return { applications: e };
|
|
229
|
-
},
|
|
230
|
-
const i = await
|
|
223
|
+
}, it = async (t, e) => {
|
|
224
|
+
const i = await et(t, e), c = (await (await import("esbuild")).build({
|
|
231
225
|
absWorkingDir: t,
|
|
232
226
|
entryPoints: [i],
|
|
233
227
|
bundle: !0,
|
|
@@ -241,13 +235,13 @@ const J = (t, e) => {
|
|
|
241
235
|
if (!c)
|
|
242
236
|
throw new Error(`Failed to bundle SSR config: ${i}`);
|
|
243
237
|
const s = x(t, "node_modules", ".cache", "vue-ssr-lite");
|
|
244
|
-
await
|
|
238
|
+
await z(s, { recursive: !0 });
|
|
245
239
|
const l = x(
|
|
246
240
|
s,
|
|
247
|
-
`ssr.config.${
|
|
241
|
+
`ssr.config.${L(6).toString("hex")}.mjs`
|
|
248
242
|
);
|
|
249
243
|
try {
|
|
250
|
-
await
|
|
244
|
+
await k(l, c, "utf8");
|
|
251
245
|
const a = await import(H(l).href), r = a.default ?? a, d = typeof r == "function" ? await r() : r;
|
|
252
246
|
if (!d?.name || !d.applications)
|
|
253
247
|
throw new Error(
|
|
@@ -257,14 +251,14 @@ const J = (t, e) => {
|
|
|
257
251
|
} finally {
|
|
258
252
|
await D(l, { force: !0 });
|
|
259
253
|
}
|
|
260
|
-
},
|
|
261
|
-
const i = await
|
|
262
|
-
return
|
|
263
|
-
}, A = (t, e) => S(t, e).replaceAll("\\", "/"),
|
|
254
|
+
}, gt = async (t, e) => {
|
|
255
|
+
const i = await it(t, e);
|
|
256
|
+
return ot(i);
|
|
257
|
+
}, A = (t, e) => S(t, e).replaceAll("\\", "/"), wt = (t, e, i) => {
|
|
264
258
|
const o = A(t, e), n = [
|
|
265
259
|
`import __ssrUserConfig from ${JSON.stringify(o)}`
|
|
266
260
|
], c = [];
|
|
267
|
-
return i.forEach((s, l) => {
|
|
261
|
+
return i.filter((s) => s.kind === "ssr").forEach((s, l) => {
|
|
268
262
|
const a = `__ssrApp${l}`, r = A(t, s.definition);
|
|
269
263
|
s.exportName ? n.push(
|
|
270
264
|
`import { ${s.exportName} as ${a} } from ${JSON.stringify(r)}`
|
|
@@ -291,7 +285,7 @@ const J = (t, e) => {
|
|
|
291
285
|
""
|
|
292
286
|
].join(`
|
|
293
287
|
`);
|
|
294
|
-
},
|
|
288
|
+
}, $t = (t, e) => {
|
|
295
289
|
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";
|
|
296
290
|
return e.kind === "spa" ? [
|
|
297
291
|
o,
|
|
@@ -324,14 +318,14 @@ const J = (t, e) => {
|
|
|
324
318
|
""
|
|
325
319
|
].join(`
|
|
326
320
|
`);
|
|
327
|
-
},
|
|
321
|
+
}, yt = async (t, e = {}) => {
|
|
328
322
|
const o = t?.default ?? t, n = typeof o == "function" ? await o() : o;
|
|
329
323
|
if (!n?.name || !n.applications || typeof n.applications != "object")
|
|
330
324
|
throw new Error(
|
|
331
325
|
"The SSR config module must export defineSsrConfig({ name, applications })."
|
|
332
326
|
);
|
|
333
327
|
const c = e.development ?? (typeof process < "u" ? process.env.NODE_ENV !== "production" : !0);
|
|
334
|
-
c ||
|
|
328
|
+
c || tt(n);
|
|
335
329
|
const s = Object.keys(n.applications);
|
|
336
330
|
if (!s.length)
|
|
337
331
|
throw new Error("SSR config requires at least one application.");
|
|
@@ -350,7 +344,7 @@ const J = (t, e) => {
|
|
|
350
344
|
throw new p(
|
|
351
345
|
`Application "${a}" render must be "spa" or "ssr".`
|
|
352
346
|
);
|
|
353
|
-
const d = r.render,
|
|
347
|
+
const d = r.render, T = b(r.application) ? r.application : void 0, N = d === "ssr" ? await Q(
|
|
354
348
|
r.application,
|
|
355
349
|
a,
|
|
356
350
|
d,
|
|
@@ -360,17 +354,17 @@ const J = (t, e) => {
|
|
|
360
354
|
id: a,
|
|
361
355
|
kind: d,
|
|
362
356
|
template: r.template,
|
|
363
|
-
hosts:
|
|
357
|
+
hosts: Z(r.domain, c),
|
|
364
358
|
roles: r.roles ? [...r.roles] : void 0,
|
|
365
359
|
application: N,
|
|
366
360
|
mountSelector: r.mountSelector,
|
|
367
361
|
cacheControl: r.cacheControl,
|
|
368
362
|
responseCache: r.responseCache,
|
|
369
363
|
endpoints: r.endpoints ? [...r.endpoints] : [],
|
|
370
|
-
cookieAllowlist:
|
|
371
|
-
cookieDenylist:
|
|
364
|
+
cookieAllowlist: _(r.cookies?.allow),
|
|
365
|
+
cookieDenylist: _(r.cookies?.deny),
|
|
372
366
|
publicConfig: { ...r.publicConfig || {} },
|
|
373
|
-
applicationModule:
|
|
367
|
+
applicationModule: T,
|
|
374
368
|
domain: {
|
|
375
369
|
development: h(
|
|
376
370
|
r.domain.development,
|
|
@@ -387,7 +381,7 @@ const J = (t, e) => {
|
|
|
387
381
|
}
|
|
388
382
|
});
|
|
389
383
|
}
|
|
390
|
-
if (
|
|
384
|
+
if (V(l), n.defaultApplicationId && !l.some((a) => a.id === n.defaultApplicationId))
|
|
391
385
|
throw new Error(
|
|
392
386
|
`defaultApplicationId "${n.defaultApplicationId}" does not match an application.`
|
|
393
387
|
);
|
|
@@ -412,18 +406,20 @@ const J = (t, e) => {
|
|
|
412
406
|
resolutionDeadlineMs: n.server?.resolutionDeadlineMs,
|
|
413
407
|
diagnostics: n.server?.diagnostics,
|
|
414
408
|
logger: n.server?.logger,
|
|
409
|
+
onMetrics: n.server?.onMetrics,
|
|
410
|
+
renderError: n.server?.renderError,
|
|
415
411
|
publicConfig: {}
|
|
416
412
|
}
|
|
417
413
|
};
|
|
418
|
-
}, g = "<!--vue-ssr-lite:head-->", w = "<!--vue-ssr-lite:teleports-->", $ = "<!--vue-ssr-lite:html-->", y = "<!--vue-ssr-lite:state-->",
|
|
414
|
+
}, g = "<!--vue-ssr-lite:head-->", w = "<!--vue-ssr-lite:teleports-->", $ = "<!--vue-ssr-lite:html-->", y = "<!--vue-ssr-lite:state-->", nt = (t) => {
|
|
419
415
|
if (!/^#[A-Za-z][A-Za-z0-9_-]*$/.test(t))
|
|
420
416
|
throw new Error("vue-ssr-lite mountSelector must be a simple element id selector.");
|
|
421
417
|
return t.slice(1);
|
|
422
|
-
},
|
|
418
|
+
}, At = (t, e = "#app") => {
|
|
423
419
|
let i = t;
|
|
424
420
|
if (i.includes(g) || (i = i.replace(/<\/head>/i, ` ${g}
|
|
425
421
|
</head>`)), i.includes(w) || (i = i.replace(/<body([^>]*)>/i, `<body$1>${w}`)), !i.includes($)) {
|
|
426
|
-
const o =
|
|
422
|
+
const o = nt(e), n = new RegExp(
|
|
427
423
|
`(<([A-Za-z][\\w-]*)\\b[^>]*\\bid=["']${o}["'][^>]*>)[\\s\\S]*?(<\\/\\2>)`,
|
|
428
424
|
"i"
|
|
429
425
|
);
|
|
@@ -433,7 +429,7 @@ const J = (t, e) => {
|
|
|
433
429
|
}
|
|
434
430
|
return i.includes(y) || (i = i.replace(/<\/body>/i, ` ${y}
|
|
435
431
|
</body>`)), i;
|
|
436
|
-
},
|
|
432
|
+
}, rt = (t, e) => e ? t.replace(/<html\b([^>]*)>/i, (i, o) => {
|
|
437
433
|
let n = o;
|
|
438
434
|
for (const [c, s] of Object.entries(e)) {
|
|
439
435
|
if (!/^[A-Za-z_:][A-Za-z0-9:._-]*$/.test(c)) continue;
|
|
@@ -444,7 +440,7 @@ const J = (t, e) => {
|
|
|
444
440
|
n = n.replace(l, ""), s != null && (n += ` ${c}="${u(s)}"`);
|
|
445
441
|
}
|
|
446
442
|
return `<html${n}>`;
|
|
447
|
-
}) : t,
|
|
443
|
+
}) : t, vt = (t, e) => {
|
|
448
444
|
for (const c of [
|
|
449
445
|
g,
|
|
450
446
|
w,
|
|
@@ -453,36 +449,36 @@ const J = (t, e) => {
|
|
|
453
449
|
])
|
|
454
450
|
if (!t.includes(c))
|
|
455
451
|
throw new Error(`Transformed SSR template is missing marker ${c}.`);
|
|
456
|
-
const i = j(e.applicationId), o = `<script id="${u(i)}" type="application/json">${
|
|
457
|
-
return
|
|
452
|
+
const i = j(e.applicationId), o = `<script id="${u(i)}" type="application/json">${B(e.state)}<\/script>`, n = e.head?.title ? t.replace(/<title\b[^>]*>[\s\S]*?<\/title>/i, "") : t;
|
|
453
|
+
return rt(
|
|
458
454
|
n.replace(g, q(e.head)).replace(w, e.teleports).replace($, e.html).replace(y, o),
|
|
459
455
|
e.head?.htmlAttributes
|
|
460
456
|
);
|
|
461
|
-
},
|
|
457
|
+
}, Et = (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>`;
|
|
462
458
|
export {
|
|
463
|
-
|
|
464
|
-
|
|
459
|
+
ht as S,
|
|
460
|
+
St as a,
|
|
465
461
|
g as b,
|
|
466
462
|
$ as c,
|
|
467
463
|
y as d,
|
|
468
464
|
w as e,
|
|
469
465
|
p as f,
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
466
|
+
yt as g,
|
|
467
|
+
ot as h,
|
|
468
|
+
mt as i,
|
|
469
|
+
$t as j,
|
|
470
|
+
wt as k,
|
|
471
|
+
vt as l,
|
|
476
472
|
b as m,
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
473
|
+
it as n,
|
|
474
|
+
F as o,
|
|
475
|
+
At as p,
|
|
476
|
+
Et as q,
|
|
477
|
+
et as r,
|
|
478
|
+
ft as s,
|
|
479
|
+
ut as t,
|
|
480
|
+
dt as u,
|
|
481
|
+
gt as v,
|
|
482
|
+
U as w,
|
|
483
|
+
V as x
|
|
488
484
|
};
|
|
@@ -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-BJUxjM2F.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-BJUxjM2F.mjs";
|
|
5
|
+
import { c as S } from "./chunks/SsrServerRuntime-CiuWVKYb.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();
|
|
@@ -54,5 +54,11 @@ export declare const validateSsrHostEntries: (applications: readonly SsrHostAppl
|
|
|
54
54
|
export declare const resolveSsrHostEntry: <T extends SsrHostApplication>(applications: readonly T[], host: string, defaultApplicationId?: string) => SsrHostResolution<T> | null;
|
|
55
55
|
export declare const resolveSsrForwardedHost: (forwardedHost: SsrHeaderValue, host: SsrHeaderValue, trustProxy?: boolean) => string;
|
|
56
56
|
export declare const resolveSsrForwardedProtocol: (forwardedProtocol: SsrHeaderValue, fallback: "http" | "https", trustProxy?: boolean) => "http" | "https";
|
|
57
|
+
/**
|
|
58
|
+
* Cookie passthrough for SSR upstream/client fetches:
|
|
59
|
+
* - both empty → forward nothing (secure default)
|
|
60
|
+
* - allow empty + deny non-empty → forward all except deny
|
|
61
|
+
* - allow non-empty → allow ∩ ¬deny
|
|
62
|
+
*/
|
|
57
63
|
export declare const filterSsrCookieHeader: (cookieHeader: SsrHeaderValue, allowlist?: readonly string[], denylist?: readonly string[]) => string | undefined;
|
|
58
64
|
//# 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,MAAM,oBAAoB,CAAA;AAOxD,OAAO,EACL,gBAAgB,EAChB,uBAAuB,EACvB,gBAAgB,GACjB,MAAM,uBAAuB,CAAA;AAE9B,iEAAiE;AACjE,MAAM,WAAW,kBAAkB;IACjC,EAAE,EAAE,MAAM,CAAA;IACV,KAAK,EAAE,MAAM,EAAE,CAAA;CAChB;AAUD,MAAM,MAAM,oBAAoB,GAAG,OAAO,GAAG,UAAU,GAAG,WAAW,GAAG,SAAS,CAAA;AAEjF,MAAM,WAAW,iBAAiB;IAChC,QAAQ,EAAE,oBAAoB,CAAA;IAC9B,kFAAkF;IAClF,WAAW,EAAE,MAAM,CAAA;IACnB,OAAO,EAAE,MAAM,CAAA;CAChB;AAED,MAAM,WAAW,iBAAiB,CAAC,CAAC,SAAS,kBAAkB,GAAG,k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AAM,uBAAuB,GAClC,eAAe,cAAc,EAC7B,MAAM,cAAc,EACpB,oBAAkB,KACjB,MAC4E,CAAA;AAE/E,eAAO,MAAM,2BAA2B,GACtC,mBAAmB,cAAc,EACjC,UAAU,MAAM,GAAG,OAAO,EAC1B,oBAAkB,KACjB,MAAM,GAAG,OAIX,CAAA;AAID;;;;;GAKG;AACH,eAAO,MAAM,qBAAqB,GAChC,cAAc,cAAc,EAC5B,YAAW,SAAS,MAAM,EAAO,EACjC,WAAU,SAAS,MAAM,EAAO,KAC/B,MAAM,GAAG,SAkBX,CAAA"}
|
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-CiuWVKYb.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-BJUxjM2F.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";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SsrVitePlugin.d.ts","sourceRoot":"","sources":["../../src/vite/SsrVitePlugin.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"SsrVitePlugin.d.ts","sourceRoot":"","sources":["../../src/vite/SsrVitePlugin.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,MAAM,EAAiB,MAAM,MAAM,CAAA;AAEjD,OAAO,EAQL,KAAK,uBAAuB,EAE7B,MAAM,4BAA4B,CAAA;AAGnC,YAAY,EAAE,uBAAuB,EAAE,CAAA;AAEvC,MAAM,WAAW,oBAAoB;IACnC,sEAAsE;IACtE,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,IAAI,CAAC,EAAE,MAAM,CAAA;IACb;;;OAGG;IACH,MAAM,CAAC,EAAE,MAAM,EAAE,CAAA;IACjB;;OAEG;IACH,aAAa,CAAC,EAAE,CAAC,MAAM,GAAG,MAAM,CAAC,EAAE,CAAA;CACpC;AAuBD,eAAO,MAAM,UAAU,GAAI,UAAS,oBAAyB,KAAG,MAmJ/D,CAAA"}
|
package/dist/vite.mjs
CHANGED
|
@@ -1,84 +1,111 @@
|
|
|
1
|
-
import { resolve as
|
|
2
|
-
import { normalizePath as
|
|
3
|
-
import { r as
|
|
4
|
-
const
|
|
1
|
+
import { resolve as d } from "node:path";
|
|
2
|
+
import { normalizePath as S } from "vite";
|
|
3
|
+
import { r as R, k as C, a as m, S as _, n as D, h as $, p as O, j as T } from "./chunks/SsrHtmlRuntime-BJUxjM2F.mjs";
|
|
4
|
+
const L = [
|
|
5
5
|
"@vue/server-renderer",
|
|
6
6
|
"vue",
|
|
7
7
|
"vue-router",
|
|
8
8
|
"vue-ssr-lite"
|
|
9
|
-
],
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
9
|
+
], h = `\0${_}`, p = `\0${m}`, f = "dist/client", U = /<script\b(?=[^>]*\btype\s*=\s*["']module["'])(?=[^>]*\bsrc\s*=\s*["'][^"']+["'])[^>]*>\s*<\/script>/gi, b = (a, r) => {
|
|
10
|
+
const n = S(a);
|
|
11
|
+
return r && n === S(r) ? !0 : /\/ssr\.config\.(ts|mts|js|mjs)$/.test(n);
|
|
12
|
+
}, F = (a = {}) => {
|
|
13
|
+
let r = d(a.root || process.cwd()), n = "", o = null, E = f;
|
|
14
|
+
const c = /* @__PURE__ */ new Map(), w = () => {
|
|
15
|
+
c.clear();
|
|
16
|
+
for (const t of o?.applications ?? [])
|
|
17
|
+
c.set(
|
|
18
|
+
`${m}${t.id}`,
|
|
19
|
+
t
|
|
17
20
|
);
|
|
18
|
-
},
|
|
21
|
+
}, y = () => {
|
|
22
|
+
o = null, c.clear(), E = f;
|
|
23
|
+
}, u = async () => {
|
|
24
|
+
if (o) return o;
|
|
25
|
+
n = await R(r, a.config);
|
|
26
|
+
const t = await D(r, n);
|
|
27
|
+
return o = $(t), E = t.server?.clientOutDir || f, w(), o;
|
|
28
|
+
}, I = (t) => {
|
|
29
|
+
const e = t.moduleGraph.getModuleById(h);
|
|
30
|
+
e && t.moduleGraph.invalidateModule(e);
|
|
31
|
+
for (const l of o?.applications ?? []) {
|
|
32
|
+
const i = `${p}${l.id}`, s = t.moduleGraph.getModuleById(i);
|
|
33
|
+
s && t.moduleGraph.invalidateModule(s);
|
|
34
|
+
}
|
|
35
|
+
};
|
|
19
36
|
return {
|
|
20
37
|
name: "vue-ssr-lite",
|
|
21
38
|
enforce: "pre",
|
|
22
|
-
async config(
|
|
23
|
-
|
|
24
|
-
const
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
39
|
+
async config(t, e) {
|
|
40
|
+
r = d(a.root || t.root || process.cwd());
|
|
41
|
+
const l = await u(), i = Object.fromEntries(
|
|
42
|
+
l.applications.map((g) => [
|
|
43
|
+
g.id,
|
|
44
|
+
d(r, g.template)
|
|
28
45
|
])
|
|
29
|
-
);
|
|
46
|
+
), s = t.build?.outDir || E || f;
|
|
30
47
|
return {
|
|
31
48
|
resolve: {
|
|
32
|
-
dedupe: [.../* @__PURE__ */ new Set([
|
|
49
|
+
dedupe: [.../* @__PURE__ */ new Set([...L, ...a.dedupe ?? []])]
|
|
33
50
|
},
|
|
34
51
|
ssr: {
|
|
35
52
|
external: ["vue-ssr-lite"],
|
|
36
|
-
noExternal: [...new Set(
|
|
53
|
+
noExternal: [...new Set(a.ssrNoExternal ?? [])]
|
|
37
54
|
},
|
|
38
|
-
build:
|
|
55
|
+
build: e.isSsrBuild ? void 0 : {
|
|
56
|
+
manifest: !0,
|
|
57
|
+
outDir: s,
|
|
58
|
+
rollupOptions: { input: i }
|
|
59
|
+
}
|
|
39
60
|
};
|
|
40
61
|
},
|
|
41
|
-
configResolved(
|
|
42
|
-
|
|
62
|
+
configResolved(t) {
|
|
63
|
+
r = t.root;
|
|
43
64
|
},
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
65
|
+
configureServer(t) {
|
|
66
|
+
u().then(() => {
|
|
67
|
+
n && t.watcher.add(n);
|
|
68
|
+
});
|
|
48
69
|
},
|
|
49
|
-
async
|
|
50
|
-
if (
|
|
51
|
-
|
|
52
|
-
|
|
70
|
+
async handleHotUpdate({ file: t, server: e }) {
|
|
71
|
+
if (b(t, n))
|
|
72
|
+
return I(e), y(), await u(), n && e.watcher.add(n), I(e), e.ws.send({ type: "full-reload" }), [];
|
|
73
|
+
},
|
|
74
|
+
resolveId(t) {
|
|
75
|
+
if (t === _) return h;
|
|
76
|
+
if (c.has(t))
|
|
77
|
+
return `${p}${t.slice(m.length)}`;
|
|
78
|
+
},
|
|
79
|
+
async load(t) {
|
|
80
|
+
if (t === h) {
|
|
81
|
+
const i = await u(), s = n || await R(r, a.config);
|
|
82
|
+
return C(r, s, i.applications);
|
|
53
83
|
}
|
|
54
|
-
if (!
|
|
55
|
-
const
|
|
56
|
-
({ id:
|
|
84
|
+
if (!t.startsWith(p)) return;
|
|
85
|
+
const e = t.slice(p.length), l = o?.applications.find(
|
|
86
|
+
({ id: i }) => i === e
|
|
57
87
|
);
|
|
58
|
-
if (
|
|
59
|
-
return
|
|
88
|
+
if (l)
|
|
89
|
+
return T(r, l);
|
|
60
90
|
},
|
|
61
91
|
transformIndexHtml: {
|
|
62
92
|
order: "pre",
|
|
63
|
-
handler(
|
|
64
|
-
const
|
|
65
|
-
(
|
|
66
|
-
);
|
|
67
|
-
if (!r) return e;
|
|
68
|
-
const n = `${p}${r.id}`, f = h(
|
|
69
|
-
e,
|
|
70
|
-
r.mountSelector || "#app"
|
|
71
|
-
).replace(
|
|
72
|
-
/<script\b[^>]*\btype=["']module["'][^>]*\bsrc=["'][^"']+["'][^>]*>\s*<\/script>/gi,
|
|
73
|
-
(l) => /src=["'][^"']*ErpClient[^"']*["']/i.test(l) || /src=["'][^"']*main\.ts["']/i.test(l) ? "" : l
|
|
93
|
+
handler(t, e) {
|
|
94
|
+
const l = S(e.filename), i = o?.applications.find(
|
|
95
|
+
(M) => l === S(d(r, M.template))
|
|
74
96
|
);
|
|
75
|
-
|
|
76
|
-
|
|
97
|
+
if (!i) return t;
|
|
98
|
+
const s = `${m}${i.id}`, v = O(
|
|
99
|
+
t,
|
|
100
|
+
i.mountSelector || "#app"
|
|
101
|
+
).replace(U, "");
|
|
102
|
+
return v.includes(`import ${JSON.stringify(s)}`) ? v : {
|
|
103
|
+
html: v,
|
|
77
104
|
tags: [
|
|
78
105
|
{
|
|
79
106
|
tag: "script",
|
|
80
107
|
attrs: { type: "module" },
|
|
81
|
-
children: `import ${JSON.stringify(
|
|
108
|
+
children: `import ${JSON.stringify(s)}`,
|
|
82
109
|
injectTo: "body"
|
|
83
110
|
}
|
|
84
111
|
]
|
|
@@ -88,5 +115,5 @@ const $ = [
|
|
|
88
115
|
};
|
|
89
116
|
};
|
|
90
117
|
export {
|
|
91
|
-
|
|
118
|
+
F as vueSsrLite
|
|
92
119
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "vue-ssr-lite",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.11",
|
|
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",
|
|
@@ -45,6 +45,9 @@
|
|
|
45
45
|
"engines": {
|
|
46
46
|
"node": ">=20.0.0"
|
|
47
47
|
},
|
|
48
|
+
"dependencies": {
|
|
49
|
+
"esbuild": "^0.27.0 || ^0.28.0"
|
|
50
|
+
},
|
|
48
51
|
"peerDependencies": {
|
|
49
52
|
"@vue/server-renderer": "^3.3.0",
|
|
50
53
|
"vite": "^7.0.0",
|