@lomray/vite-ssr-boost 8.4.0-beta.4 → 8.4.1-beta.1

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 (91) hide show
  1. package/README.md +23 -0
  2. package/adapters/express/prepare-server.js +1 -1
  3. package/adapters/express/prepare-server.js.map +1 -1
  4. package/adapters/express/render.js +1 -1
  5. package/adapters/express/render.js.map +1 -1
  6. package/adapters/express/route-assets.d.ts +8 -0
  7. package/adapters/express/route-assets.js +2 -0
  8. package/adapters/express/route-assets.js.map +1 -0
  9. package/browser/entry.js.map +1 -1
  10. package/cli/commands.d.ts +1 -0
  11. package/cli/commands.js +2 -0
  12. package/cli/commands.js.map +1 -0
  13. package/cli/helpers/enable-shortcuts.d.ts +5 -0
  14. package/cli/helpers/enable-shortcuts.js +2 -0
  15. package/cli/helpers/enable-shortcuts.js.map +1 -0
  16. package/cli/run-prod.js +1 -1
  17. package/cli/run-prod.js.map +1 -1
  18. package/cli/start.d.ts +10 -0
  19. package/cli/start.js +2 -0
  20. package/cli/start.js.map +1 -0
  21. package/cli.js +1 -1
  22. package/cli.js.map +1 -1
  23. package/cloudflare.d.ts +5 -3
  24. package/cloudflare.js +1 -1
  25. package/cloudflare.js.map +1 -1
  26. package/core/cache-control.d.ts +4 -0
  27. package/core/cache-control.js +1 -1
  28. package/core/cache-control.js.map +1 -1
  29. package/core/conditional-request.d.ts +2 -1
  30. package/core/conditional-request.js +1 -1
  31. package/core/conditional-request.js.map +1 -1
  32. package/core/copy-loader-headers.d.ts +1 -1
  33. package/core/copy-loader-headers.js +1 -1
  34. package/core/copy-loader-headers.js.map +1 -1
  35. package/core/document-headers.js +1 -1
  36. package/core/document-headers.js.map +1 -1
  37. package/core/handler.js +1 -1
  38. package/core/handler.js.map +1 -1
  39. package/core/render.js +1 -1
  40. package/core/render.js.map +1 -1
  41. package/core/spa-html.js.map +1 -1
  42. package/core/spa-shell.js +1 -1
  43. package/core/spa-shell.js.map +1 -1
  44. package/core/ssr-policy.d.ts +37 -4
  45. package/core/ssr-policy.js +1 -1
  46. package/core/ssr-policy.js.map +1 -1
  47. package/helpers/print-server-info.js +1 -1
  48. package/helpers/print-server-info.js.map +1 -1
  49. package/http.d.ts +12 -0
  50. package/node/production.d.ts +3 -3
  51. package/package.json +5 -3
  52. package/services/build.d.ts +4 -0
  53. package/services/build.js +1 -1
  54. package/services/build.js.map +1 -1
  55. package/services/diagnostics.d.ts +18 -1
  56. package/services/diagnostics.js.map +1 -1
  57. package/services/production-config.d.ts +15 -0
  58. package/services/production-config.js +2 -0
  59. package/services/production-config.js.map +1 -0
  60. package/services/request-timeline.d.ts +31 -2
  61. package/services/request-timeline.js +1 -1
  62. package/services/request-timeline.js.map +1 -1
  63. package/services/route-asset-preparer.js.map +1 -1
  64. package/services/route-assets-memory.d.ts +20 -8
  65. package/services/route-assets-memory.js +1 -1
  66. package/services/route-assets-memory.js.map +1 -1
  67. package/services/server-config.d.ts +1 -0
  68. package/services/server-config.js +1 -1
  69. package/services/server-config.js.map +1 -1
  70. package/services/ssr-manifest.d.ts +4 -4
  71. package/services/ssr-manifest.js +1 -1
  72. package/services/ssr-manifest.js.map +1 -1
  73. package/testing/browser-observer.d.ts +13 -7
  74. package/testing/browser-observer.js +1 -1
  75. package/testing/browser-observer.js.map +1 -1
  76. package/testing/create-handler.d.ts +1 -0
  77. package/testing/create-handler.js.map +1 -1
  78. package/testing/deferred.js.map +1 -1
  79. package/testing/edge.d.ts +12 -0
  80. package/testing/edge.js.map +1 -1
  81. package/testing/parse-response.js.map +1 -1
  82. package/testing/playwright.d.ts +2 -0
  83. package/testing/playwright.js +1 -1
  84. package/testing/playwright.js.map +1 -1
  85. package/testing/requests.d.ts +3 -0
  86. package/testing/requests.js.map +1 -1
  87. package/testing/response.d.ts +49 -3
  88. package/testing/response.js +1 -1
  89. package/testing/response.js.map +1 -1
  90. package/testing.d.ts +12 -0
  91. package/testing.js.map +1 -1
package/README.md CHANGED
@@ -161,6 +161,29 @@ Test SSR routes without a server with `@lomray/vite-ssr-boost/testing`; see the
161
161
  - [Hydration order and streaming](./docs/reference/hydration-and-streaming.md).
162
162
  - API: [Plugin](./docs/api/plugin.md), [Browser entry](./docs/api/browser-entry.md), [Server entry](./docs/api/server-entry.md), [Node production](./docs/api/node-production.md), [Components and helpers](./docs/api/components-and-helpers.md) and [CLI](./docs/api/cli.md).
163
163
 
164
+ ## AI agents
165
+
166
+ The repository includes `ssr-boost-migrate` and `ssr-boost-new-app` in the [Agent Skills format](https://agentskills.io/specification).
167
+
168
+ Claude Code plugin:
169
+
170
+ ```sh
171
+ claude plugin marketplace add Lomray-Software/vite-ssr-boost
172
+ claude plugin install ssr-boost@lomray
173
+ ```
174
+
175
+ Codex CLI, from this checkout:
176
+
177
+ ```sh
178
+ mkdir -p ~/.codex/skills
179
+ cp -R skills/ssr-boost-migrate skills/ssr-boost-new-app ~/.codex/skills/
180
+ # Or use the target application's .codex/skills directory.
181
+ ```
182
+
183
+ Current Codex versions document `.agents/skills` for discovery; use that destination or the symlinks in [AI usage and installation](./docs/ai-usage.md#ai-agents). That page also covers local Claude plugin testing before the files reach the default branch.
184
+
185
+ For Cursor, copy the folders into the app's `skills/` directory and add a `.cursor/rules/ssr-boost.mdc` rule pointing to the relevant `SKILL.md`; see the [complete rule](./docs/ai-usage.md#ai-agents). Other agents can use [llms.txt](https://lomray-software.github.io/vite-ssr-boost/llms.txt) or [llms-full.txt](https://lomray-software.github.io/vite-ssr-boost/llms-full.txt).
186
+
164
187
  ## License
165
188
 
166
189
  Made with 💚
@@ -1,2 +1,2 @@
1
- import e from"node:fs";import t from"node:path";import r from"node:process";import{pathToFileURL as i}from"node:url";import o from"chalk";import{splitHtmlShell as s}from"../../services/diagnostics.js";import n from"../../services/server-api.js";class a{onServerStarted;config;serverApi;entrypoint;onServerCreated;html;middlewaresConfigs;constructor(e,t){this.config=e,this.serverApi=t??new n}static init(e,t){return new a(e,t)}async loadEntrypoint(e=!0){if(this.entrypoint&&this.config.isProd)return this.entrypoint;const{root:s,isProd:n,serverFile:a}=this.config.getParams(),d=t.resolve(`${s}/${a}`);let l;try{l=n?(await(import(i(d).toString()))).default:(await this.config.getVite().ssrLoadModule(d,{fixStacktrace:!0})).default}catch(e){if(e instanceof Error&&e.message.includes("Cannot find module")&&e.message.includes("/build/"))return this.config.getLogger().error(o.red(`Before starting the server, you need to create a build: ${o.yellow("ssr-boost build")} or provide path to build dir: ${o.yellow("ssr-boost start --build-dir build")}`)),r.exit(1);throw e}!e&&l.init&&delete l.init;const{render:c,init:g,routes:h,abortDelay:f,loggerProd:m,loggerDev:p,middlewares:u}=l;this.middlewaresConfigs=u,m&&n?this.config.setLogger(m):p&&!n&&this.config.setLogger(p);const{onServerCreated:v,onServerStarted:y,...w}=await(g?.({config:this.config}))??{};return this.entrypoint={render:c,routes:h,abortDelay:f,...w},this.onServerCreated=v,this.onServerStarted=y,this.entrypoint}async loadHtml(r){const{isProd:i,root:o,indexFile:n,clientFile:a}=this.config.getParams();this.html&&i||(this.html=e.readFileSync(t.resolve(`${o}/${n}`),"utf-8"));let d=this.html;if(!i){const e=t.posix.normalize(`${this.config.getVite()?.config.base}/${a}`);d=(await this.config.getVite().transformIndexHtml(r.originalUrl,this.html,n)).replace(new RegExp(String.raw`<script[^>]*?\bsrc=["']/?${e}([^"']*)["'][^>]*?\sasync\b`,"g"),e=>e.replace(/\sasync\b/,""))}return s(d,t.resolve(`${o}/${n}`))}async onAppCreated(){return await this.loadEntrypoint(),await(this.onServerCreated?.(this.config.getApp(),this.serverApi)),this}getMiddlewaresConfig(){const{compression:e,expressStatic:t}=this.middlewaresConfigs??{};return{compression:!1!==e&&{...e},expressStatic:!1!==t&&{...t,basename:t?.basename??"/"}}}}export{a as default};
1
+ import e from"node:fs";import t from"node:path";import r from"node:process";import{pathToFileURL as i}from"node:url";import s from"chalk";import{splitHtmlShell as o}from"../../services/diagnostics.js";import n from"../../services/server-api.js";class a{onServerStarted;config;serverApi;entrypoint;onServerCreated;html;middlewaresConfigs;constructor(e,t){this.config=e,this.serverApi=t??new n}static init(e,t){return new a(e,t)}async loadEntrypoint(e=!0){if(this.entrypoint&&this.config.isProd)return this.entrypoint;const{root:o,isProd:n,serverFile:a}=this.config.getParams(),l=t.resolve(`${o}/${a}`);let d;try{d=n?(await(import(i(l).toString()))).default:(await this.config.getVite().ssrLoadModule(l,{fixStacktrace:!0})).default}catch(e){if(e instanceof Error&&e.message.includes("Cannot find module")&&e.message.includes("/build/"))return this.config.getLogger().error(s.red(`Before starting the server, you need to create a build: ${s.yellow("ssr-boost build")} or provide path to build dir: ${s.yellow("ssr-boost start --build-dir build")}`)),r.exit(1);throw e}!e&&d.init&&delete d.init;const{render:c,init:g,routes:h,abortDelay:f,loggerProd:m,loggerDev:p,middlewares:u}=d;this.middlewaresConfigs=u,m&&n?this.config.setLogger(m):p&&!n&&this.config.setLogger(p);const{onServerCreated:v,onServerStarted:w,...y}=await(g?.({config:this.config}))??{};return this.entrypoint={render:c,routes:h,abortDelay:f,...y},this.onServerCreated=v,this.onServerStarted=w,this.entrypoint}async loadHtml(r){const{isProd:i,root:s,indexFile:n,clientFile:a}=this.config.getParams();this.html&&i||(this.html=e.readFileSync(t.resolve(`${s}/${n}`),"utf-8"));let l=this.html;if(!i){const e=t.posix.normalize(`${this.config.getVite()?.config.base}/${a}`);l=(await this.config.getVite().transformIndexHtml(r.originalUrl,this.html,n)).replace(new RegExp(String.raw`<script[^>]*?\bsrc=["']/?${e}([^"']*)["'][^>]*?\sasync\b`,"g"),e=>e.replace(/\sasync\b/,""))}return o(l,t.resolve(`${s}/${n}`))}async onAppCreated(){return await this.loadEntrypoint(),await(this.onServerCreated?.(this.config.getApp(),this.serverApi)),this}getMiddlewaresConfig(){const{compression:e,expressStatic:t}=this.middlewaresConfigs??{};return{compression:!1!==e&&{...e},expressStatic:!1!==t&&{...t,basename:t?.basename??new URL(this.config.getParams().base??"/","http://localhost").pathname}}}}export{a as default};
2
2
  //# sourceMappingURL=prepare-server.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"prepare-server.js","sources":["../../../src/adapters/express/prepare-server.ts"],"sourcesContent":[null],"names":["PrepareServer","onServerStarted","config","serverApi","entrypoint","onServerCreated","html","middlewaresConfigs","constructor","this","ServerApi","init","loadEntrypoint","shouldInit","isProd","root","serverFile","getParams","entrypointPath","path","resolve","resolvedEntrypoint","pathToFileURL","toString","default","getVite","ssrLoadModule","fixStacktrace","e","Error","message","includes","getLogger","error","chalk","red","yellow","process","exit","render","routes","abortDelay","loggerProd","loggerDev","middlewares","setLogger","renderParams","loadHtml","req","indexFile","clientFile","fs","readFileSync","modifiedHtml","clientFileEntry","posix","normalize","base","transformIndexHtml","originalUrl","replace","RegExp","String","raw","match","splitHtmlShell","onAppCreated","getApp","getMiddlewaresConfig","compression","expressStatic","basename"],"mappings":"qPA0BA,MAAMA,EAIGC,gBAKYC,OAKAC,UAKTC,WAKAC,gBAKAC,KAKAC,mBAKV,WAAAC,CAAsBN,EAAsBC,GAC1CM,KAAKP,OAASA,EACdO,KAAKN,UAAYA,GAAa,IAAIO,CACpC,CAKO,WAAOC,CAAKT,EAAsBC,GACvC,OAAO,IAAIH,EAAcE,EAAQC,EACnC,CAKO,oBAAMS,CAAeC,GAAa,GAIvC,GAAIJ,KAAKL,YAAcK,KAAKP,OAAOY,OACjC,OAAOL,KAAKL,WAGd,MAAMW,KAAEA,EAAID,OAAEA,EAAME,WAAEA,GAAeP,KAAKP,OAAOe,YAC3CC,EAAiBC,EAAKC,QAAQ,GAAGL,KAAQC,KAE/C,IAAIK,EAEJ,IAQIA,EAPGP,gBAQaQ,EAAcJ,GAAgBK,cAC5CC,eAPMf,KAAKP,OAAOuB,UAAWC,cAAcR,EAAgB,CACzDS,eAAe,KAEjBH,OAMN,CAAE,MAAOI,GACP,GACEA,aAAaC,OACbD,EAAEE,QAAQC,SAAS,uBACnBH,EAAEE,QAAQC,SAAS,WAcnB,OAZAtB,KAAKP,OACF8B,YACAC,MAC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BACLH,KAAKJ,kBAAkBI,KAAKP,OAAOiE,SAAoB1D,KAAKN,YAE3DM,IACT,CAKO,oBAAA2D,GACL,MAAMC,YAAEA,EAAWC,cAAEA,GAAkB7D,KAAKF,oBAAsB,CAAA,EAElE,MAAO,CACL8D,aACkB,IAAhBA,GACI,IACKA,GAGXC,eACoB,IAAlBA,GACI,IACKA,EACHC,SAAUD,GAAeC,UAAY,KAIjD"}
1
+ {"version":3,"file":"prepare-server.js","sources":["../../../src/adapters/express/prepare-server.ts"],"sourcesContent":[null],"names":["PrepareServer","onServerStarted","config","serverApi","entrypoint","onServerCreated","html","middlewaresConfigs","constructor","this","ServerApi","init","loadEntrypoint","shouldInit","isProd","root","serverFile","getParams","entrypointPath","path","resolve","resolvedEntrypoint","pathToFileURL","toString","default","getVite","ssrLoadModule","fixStacktrace","e","Error","message","includes","getLogger","error","chalk","red","yellow","process","exit","render","routes","abortDelay","loggerProd","loggerDev","middlewares","setLogger","renderParams","loadHtml","req","indexFile","clientFile","fs","readFileSync","modifiedHtml","clientFileEntry","posix","normalize","base","transformIndexHtml","originalUrl","replace","RegExp","String","raw","match","splitHtmlShell","onAppCreated","getApp","getMiddlewaresConfig","compression","expressStatic","basename","URL","pathname"],"mappings":"qPA0BA,MAAMA,EAIGC,gBAKYC,OAKAC,UAKTC,WAKAC,gBAKAC,KAKAC,mBAKV,WAAAC,CAAsBN,EAAsBC,GAC1CM,KAAKP,OAASA,EACdO,KAAKN,UAAYA,GAAa,IAAIO,CACpC,CAKO,WAAOC,CAAKT,EAAsBC,GACvC,OAAO,IAAIH,EAAcE,EAAQC,EACnC,CAKO,oBAAMS,CAAeC,GAAa,GAIvC,GAAIJ,KAAKL,YAAcK,KAAKP,OAAOY,OACjC,OAAOL,KAAKL,WAGd,MAAMW,KAAEA,EAAID,OAAEA,EAAME,WAAEA,GAAeP,KAAKP,OAAOe,YAC3CC,EAAiBC,EAAKC,QAAQ,GAAGL,KAAQC,KAE/C,IAAIK,EAEJ,IAQI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AAmBV,EAAIW,YAAalD,KAAKH,KAAM2C,IAC5EW,QACA,IAAIC,OACFC,OAAOC,GAAG,4BAA4BT,+BACtC,KAEDU,GAAUA,EAAMJ,QAAQ,YAAa,IAE1C,CAEA,OAAOK,EAAeZ,EAAclC,EAAKC,QAAQ,GAAGL,KAAQkC,KAC9D,CAKO,kBAAMiB,GAIX,aAHMzD,KAAKG,uBACLH,KAAKJ,kBAAkBI,KAAKP,OAAOiE,SAAoB1D,KAAKN,YAE3DM,IACT,CAKO,oBAAA2D,GACL,MAAMC,YAAEA,EAAWC,cAAEA,GAAkB7D,KAAKF,oBAAsB,CAAA,EAElE,MAAO,CACL8D,aACkB,IAAhBA,GACI,IACKA,GAGXC,eACoB,IAAlBA,GACI,IACKA,EACHC,SACED,GAAeC,UACf,IAAIC,IAAI/D,KAAKP,OAAOe,YAAYwC,MAAQ,IAAK,oBAAoBgB,UAI/E"}
@@ -1,2 +1,2 @@
1
- import e from"chalk";import t from"react";import s from"./create-request.js";import r from"../../constants/stream-error.js";import o from"../../core/early-hints.js";import{getSetCookieHeaders as n,getHeaderEntries as a}from"../../core/headers.js";import i from"../../core/render.js";import d from"../../node/render-to-stream.js";import c from"../../node/request-signal.js";import p from"../../node/write-early-hints.js";import m,{writeFetchHeaders as l}from"../../node/write-fetch-response.js";import h,{isDiagnosticsEnabled as u}from"../../services/diagnostics.js";import f from"../../services/ssr-manifest.js";const y=(e,t,r)=>{const o={signal:t};return r&&"GET"!==e.method&&"HEAD"!==e.method&&(o.body=r(e)??null),s(e,o)},g=(e,t,s)=>{if(!t.headersSent&&!t.writableEnded){e.response.status!==s.status&&t.status(e.response.status??200);const r=new Set([...s.headers.keys(),...e.response.headers.keys()]);for(const o of r)e.response.headers.get(o)!==s.headers.get(o)&&(e.response.headers.has(o)?t.setHeader(o,"set-cookie"===o?n(e.response.headers):e.response.headers.get(o)):t.removeHeader(o))}const r=new Headers(e.response.headers);r.delete("Set-Cookie");for(const[e,s]of Object.entries(t.getHeaders()))if("set-cookie"!==e.toLowerCase()&&void 0!==s)if(Array.isArray(s))for(const t of s)r.append(e,t);else r.set(e,"number"==typeof s?String(s):s);e.response.headers=r,e.response.status=t.statusCode};async function S({App:s,handler:S,policy:x,spaShell:w},v,E,{onRouterReady:b,onShellReady:C,onResponse:j,onShellError:R,onError:H,getBody:q,getState:k,hydration:A,nonce:P,bootstrapScriptContent:D,documentHeaders:L,sessionCookie:O,protectPrivate:T,abortDelay:B=15e3}){const{appProps:G,html:U,req:$,res:z}=E,F=v.getLogger(),I=c($,z);try{const c=Object.assign(E,{request:y($,I.signal,q),response:{headers:new Headers}}),J={appProps:G,diagnostics:u(!v.isProd)?new h(new URL(c.request.url).pathname,F):void 0,html:U,request:c.request,response:c.response};if(!v.isProd&&J.diagnostics){const{diagnostics:e}=J;for(const t of["req","res"]){let s=c[t];Object.defineProperty(c,t,{configurable:!0,enumerable:!0,get:()=>(e.deprecatedReqRes(),s),set:e=>{s=e}})}}g(J,z,{headers:new Headers(J.response.headers),status:J.response.status}),200===J.response.status&&(J.response.status=void 0);const K=e=>(c.request=e.request,c.response=e.response,c.didError=e.didError,c.html=e.html,c.isStream=e.isStream,c.isSpa=e.isSpa,c.matches=e.matches,c.routerContext=e.routerContext,c.serverContext=e.serverContext,c.timeline=e.timeline,c),M=await i({createApp:(e,r)=>t.createElement(s,{server:{...r.appProps,req:$}},e),handler:S,policy:x,spaShell:w,renderToStream:d},J,{abortDelay:B,hydration:A,nonce:P,bootstrapScriptContent:D,documentHeaders:L,sessionCookie:O,protectPrivate:T,getState:k?({context:e})=>k({context:K(e)}):void 0,onError:({context:t,error:s})=>{const{code:o,message:n}=s;if(H?.({context:K(t),error:s}),F.info(e.red(`Stream error. Code: ${o}`)),[r.RenderAborted,r.RenderTimeout,r.RenderCancel].includes(o))return void F.info(e.dim(n));const{original:a}=s;F.error(a)},onResponse:j?({context:e,html:t,isEnd:s})=>j({context:K(e),html:t,isEnd:s}):void 0,onRouterReady:b?({context:e})=>b({context:K(e)}):void 0,onShellError:R?({context:e,error:t})=>R({context:K(e),error:t}):void 0,onShellReady:({context:e})=>{const t=K(e);((e,t)=>{if(t.headersSent||t.writableEnded)return;t.status(e.response.status??200),a(e.response.headers).forEach(([e,s])=>t.setHeader(e,s));const s=n(e.response.headers);s.length&&t.setHeader("Set-Cookie",s)})(e,z);const s={headers:new Headers(e.response.headers),status:e.response.status},r=C?.({context:t});return g(e,z,s),r??{}},prepare:async({context:e,executionContext:t})=>{const s=K(e),r=f.get(v);await r.prepareDevAssets(e.matches,e.isSpa);const n=r.injectAssets(s);s.hasEarlyHints&&await o(t,n)},routerRequestContext:c},{onEarlyHints:e=>p(z,e)});K(J),await(async(e,t)=>{const s=t.headers.get("Location");if(s&&t.status>=300&&t.status<400&&!e.headersSent&&!e.writableEnded&&!e.destroyed)return l(e,t),await(t.body?.cancel()),void e.redirect(t.status,s);await m(e,t)})(z,M)}finally{I.dispose()}}export{S as default};
1
+ import e from"chalk";import t from"react";import r from"./create-request.js";import s from"./route-assets.js";import o from"../../constants/stream-error.js";import n from"../../core/early-hints.js";import{getSetCookieHeaders as a,getHeaderEntries as i}from"../../core/headers.js";import d from"../../core/render.js";import c from"../../node/render-to-stream.js";import p from"../../node/request-signal.js";import m from"../../node/write-early-hints.js";import l,{writeFetchHeaders as h}from"../../node/write-fetch-response.js";import u,{isDiagnosticsEnabled as f}from"../../services/diagnostics.js";const y=(e,t,s)=>{const o={signal:t};return s&&"GET"!==e.method&&"HEAD"!==e.method&&(o.body=s(e)??null),r(e,o)},g=(e,t,r)=>{if(!t.headersSent&&!t.writableEnded){e.response.status!==r.status&&t.status(e.response.status??200);const s=new Set([...r.headers.keys(),...e.response.headers.keys()]);for(const o of s)e.response.headers.get(o)!==r.headers.get(o)&&(e.response.headers.has(o)?t.setHeader(o,"set-cookie"===o?a(e.response.headers):e.response.headers.get(o)):t.removeHeader(o))}const s=new Headers(e.response.headers);s.delete("Set-Cookie");for(const[e,r]of Object.entries(t.getHeaders()))if("set-cookie"!==e.toLowerCase()&&void 0!==r)if(Array.isArray(r))for(const t of r)s.append(e,t);else s.set(e,"number"==typeof r?String(r):r);e.response.headers=s,e.response.status=t.statusCode};async function S({App:r,handler:S,policy:x,spaShell:w},E,b,{onRouterReady:v,onShellReady:C,onResponse:j,onShellError:R,onError:H,getBody:q,getState:k,hydration:P,nonce:A,bootstrapScriptContent:L,documentHeaders:D,sessionCookie:O,protectPrivate:T,abortDelay:B=15e3}){const{appProps:G,html:U,req:$,res:z}=b,F=E.getLogger(),I=p($,z);try{const p=Object.assign(b,{request:y($,I.signal,q),response:{headers:new Headers}}),J={appProps:G,diagnostics:f(!E.isProd)?new u(new URL(p.request.url).pathname,F):void 0,html:U,request:p.request,response:p.response};if(!E.isProd&&J.diagnostics){const{diagnostics:e}=J;for(const t of["req","res"]){let r=p[t];Object.defineProperty(p,t,{configurable:!0,enumerable:!0,get:()=>(e.deprecatedReqRes(),r),set:e=>{r=e}})}}const{response:K}=J;g(J,z,{headers:new Headers(K.headers),status:K.status}),200===K.status&&(K.status=void 0);const M=e=>(p.request=e.request,p.response=e.response,p.didError=e.didError,p.html=e.html,p.isStream=e.isStream,p.isSpa=e.isSpa,p.matches=e.matches,p.routerContext=e.routerContext,p.serverContext=e.serverContext,p.timeline=e.timeline,p),N=await d({createApp:(e,s)=>t.createElement(r,{server:{...s.appProps,req:$}},e),handler:S,policy:x,spaShell:w,renderToStream:c},J,{abortDelay:B,hydration:P,nonce:A,bootstrapScriptContent:L,documentHeaders:D,sessionCookie:O,protectPrivate:T,getState:k?({context:e})=>k({context:M(e)}):void 0,onError:({context:t,error:r})=>{const{code:s,message:n}=r;if(H?.({context:M(t),error:r}),F.info(e.red(`Stream error. Code: ${s}`)),[o.RenderAborted,o.RenderTimeout,o.RenderCancel].includes(s))return void F.info(e.dim(n));const{original:a}=r;F.error(a)},onResponse:j?({context:e,html:t,isEnd:r})=>j({context:M(e),html:t,isEnd:r}):void 0,onRouterReady:v?({context:e})=>v({context:M(e)}):void 0,onShellError:R?({context:e,error:t})=>R({context:M(e),error:t}):void 0,onShellReady:({context:e})=>{const t=M(e);((e,t)=>{if(t.headersSent||t.writableEnded)return;t.status(e.response.status??200),i(e.response.headers).forEach(([e,r])=>t.setHeader(e,r));const r=a(e.response.headers);r.length&&t.setHeader("Set-Cookie",r)})(e,z);const r={headers:new Headers(e.response.headers),status:e.response.status},s=C?.({context:t});return g(e,z,r),s??{}},prepare:async({context:e,executionContext:t})=>{const r=M(e),{matches:o,isSpa:a}=e,i=(await s(E,o,a)).injectAssets(r);r.hasEarlyHints&&await n(t,i)},routerRequestContext:p},{onEarlyHints:e=>m(z,e)});M(J),await(async(e,t)=>{const r=t.headers.get("Location");if(r&&t.status>=300&&t.status<400&&!e.headersSent&&!e.writableEnded&&!e.destroyed)return h(e,t),await(t.body?.cancel()),void e.redirect(t.status,r);await l(e,t)})(z,N)}finally{I.dispose()}}export{S as default};
2
2
  //# sourceMappingURL=render.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"render.js","sources":["../../../src/adapters/express/render.tsx"],"sourcesContent":[null],"names":["createRenderRequest","req","signal","getBody","options","method","body","createFetchRequest","syncResponse","context","res","previous","headersSent","writableEnded","response","status","names","Set","headers","keys","name","get","has","setHeader","getSetCookieHeaders","removeHeader","Headers","delete","value","Object","entries","getHeaders","toLowerCase","undefined","Array","isArray","item","append","set","String","statusCode","async","render","App","handler","policy","spaShell","config","initialContext","onRouterReady","onShellReady","onResponse","onShellError","onError","getState","hydration","nonce","bootstrapScriptContent","documentHeaders","sessionCookie","protectPrivate","abortDelay","appProps","html","shellHtml","Logger","getLogger","requestSignal","createRequestSignal","assign","request","coreContext","diagnostics","isDiagnosticsEnabled","isProd","Diagnostics","URL","url","pathname","defineProperty","configurable","enumerable","deprecatedReqRes","next","syncContext","updated","didError","isStream","isSpa","matches","routerContext","serverContext","timeline","coreRender","createApp","children","React","createElement","server","renderToStream","error","code","message","info","chalk","red","StreamError","RenderAborted","RenderTimeout","RenderCancel","includes","dim","original","isEnd","legacyContext","getHeaderEntries","forEach","cookies","length","prepareResponse","shell","prepare","executionContext","manifest","SsrManifest","prepareDevAssets","hints","injectAssets","hasEarlyHints","emitEarlyHints","routerRequestContext","onEarlyHints","writeEarlyHints","location","destroyed","writeFetchHeaders","cancel","redirect","writeFetchResponse","writeResponse","dispose"],"mappings":"omBA+FA,MAAMA,EAAsB,CAC1BC,EACAC,EACAC,KAEA,MAAMC,EAA2D,CAAEF,UAMnE,OAJIC,GAA0B,QAAfF,EAAII,QAAmC,SAAfJ,EAAII,SACzCD,EAAQE,KAAOH,EAAQF,IAAQ,MAG1BM,EAAmBN,EAAKG,IAwB3BI,EAAe,CACnBC,EACAC,EACAC,KAIA,IAAKD,EAAIE,cAAgBF,EAAIG,cAAe,CACtCJ,EAAQK,SAASC,SAAWJ,EAASI,QACvCL,EAAIK,OAAON,EAAQK,SAASC,QAAU,KAGxC,MAAMC,EAAQ,IAAIC,IAAI,IAAIN,EAASO,QAAQC,UAAWV,EAAQK,SAASI,QAAQC,SAE/E,IAAK,MAAMC,KAAQJ,EACbP,EAAQK,SAASI,QAAQG,IAAID,KAAUT,EAASO,QAAQG,IAAID,KAI3DX,EAAQK,SAASI,QAAQI,IAAIF,GAGhCV,EAAIa,UACFH,EACS,eAATA,EACII,EAAoBf,EAAQK,SAASI,SACrCT,EAAQK,SAASI,QAAQG,IAAID,IANnCV,EAAIe,aAAaL,GAUvB,CAEA,MAAMF,EAAU,IAAIQ,QAAQjB,EAAQK,SAASI,SAE7CA,EAAQS,OAAO,cAEf,IAAK,MAAOP,EAAMQ,KAAUC,OAAOC,QAAQpB,EAAIqB,cAC7C,GAA2B,eAAvBX,EAAKY,oBAA4CC,IAAVL,EAI3C,GAAIM,MAAMC,QAAQP,GAChB,IAAK,MAAMQ,KAAQR,EACjBV,EAAQmB,OAAOjB,EAAMgB,QAGvBlB,EAAQoB,IAAIlB,EAAuB,iBAAVQ,EAAqBW,OAAOX,GAASA,GAIlEnB,EAA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H,SAK1BK,EAAmBhI,EAAKI,IA2NtB6H,CAAcjI,EAAKI,EAC3B,SACEqD,EAAcyE,SAChB,CACF"}
1
+ {"version":3,"file":"render.js","sources":["../../../src/adapters/express/render.tsx"],"sourcesContent":[null],"names":["createRenderRequest","req","signal","getBody","options","method","body","createFetchRequest","syncResponse","context","res","previous","headersSent","writableEnded","response","status","names","Set","headers","keys","name","get","has","setHeader","getSetCookieHeaders","removeHeader","Headers","delete","value","Object","entries","getHeaders","toLowerCase","undefined","Array","isArray","item","append","set","String","statusCode","async","render","App","handler","policy","spaShell","config","initialContext","onRouterReady","onShellReady","onResponse","onShellError","onError","getState","hydration","nonce","bootstrapScriptContent","documentHeaders","sessionCookie","protectPrivate","abortDelay","appProps","html","shellHtml","Logger","getLogger","requestSignal","createRequestSignal","assign","request","coreContext","diagnostics","isDiagnosticsEnabled","isProd","Diagnostics","URL","url","pathname","defineProperty","configurable","enumerable","deprecatedReqRes","next","initialResponse","syncContext","updated","didError","isStream","isSpa","matches","routerContext","serverContext","timeline","coreRender","createApp","children","React","createElement","server","renderToStream","error","code","message","info","chalk","red","StreamError","RenderAborted","RenderTimeout","RenderCancel","includes","dim","original","isEnd","legacyContext","getHeaderEntries","forEach","cookies","length","prepareResponse","shell","prepare","executionContext","hints","getRouteAssets","injectAssets","hasEarlyHints","emitEarlyHints","routerRequestContext","onEarlyHints","writeEarlyHints","location","destroyed","writeFetchHeaders","cancel","redirect","writeFetchResponse","writeResponse","dispose"],"mappings":"ulBA+FA,MAAMA,EAAsB,CAC1BC,EACAC,EACAC,KAEA,MAAMC,EAA2D,CAAEF,UAMnE,OAJIC,GAA0B,QAAfF,EAAII,QAAmC,SAAfJ,EAAII,SACzCD,EAAQE,KAAOH,EAAQF,IAAQ,MAG1BM,EAAmBN,EAAKG,IAwB3BI,EAAe,CACnBC,EACAC,EACAC,KAIA,IAAKD,EAAIE,cAAgBF,EAAIG,cAAe,CACtCJ,EAAQK,SAASC,SAAWJ,EAASI,QACvCL,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,QAAQ4D,EAAQxE,SAASI,SACtCH,OAAQuE,EAAQxE,SAASC,QAGrB0G,EAAQvE,IAAe,CAAEzC,QAAS0G,IAIxC,OAFA3G,EAAa8E,EAAS5E,EAAKC,GAEpB8G,GAAS,CAAA,GAMlBC,QAASjF,OAAShC,QAAS6E,EAASqC,uBAClC,MAAMR,EAAgB9B,EAAYC,IAC5BI,QAAEA,EAAOD,MAAEA,GAAUH,EAErBsC,SADiBC,EAAe9E,EAAQ2C,EAASD,IAChCqC,aAAaX,GAEhCA,EAAcY,qBACVC,EAAeL,EAAkBC,IAG3CK,qBAAsBxH,GAExB,CAIEyH,aAAehH,GAAYiH,EAAgBzH,EAAKQ,KAIpDmE,EAAYd,QA3OM9B,OAAO/B,EAAsBI,KACjD,MAAMsH,EAAWtH,EAASI,QAAQG,IAAI,YAEtC,GACE+G,GACAtH,EAASC,QAAU,KACnBD,EAASC,OAAS,MACjBL,EAAIE,cACJF,EAAIG,gBACJH,EAAI2H,UAML,OAJAC,EAAkB5H,EAAKI,SACjBA,EAASR,MAAMiI,eACrB7H,EAAI8H,SAAS1H,EAASC,OAAQqH,SAK1BK,EAAmB/H,EAAKI,IA2NtB4H,CAAchI,EAAKI,EAC3B,SACEqD,EAAcwE,SAChB,CACF"}
@@ -0,0 +1,8 @@
1
+ import type { RouterState } from 'react-router';
2
+ import RouteAssets from '../../services/route-assets.js';
3
+ import type ServerConfig from '../../services/server-config.js';
4
+ /**
5
+ * Keep source analysis and Vite graph access confined to development requests.
6
+ */
7
+ declare const getRouteAssets: (config: ServerConfig, matches?: RouterState["matches"], isSpa?: boolean) => Promise<RouteAssets>;
8
+ export default getRouteAssets;
@@ -0,0 +1,2 @@
1
+ import e from"../../services/route-assets.js";const s=new WeakMap,t=async(t,r,a=!1)=>{if(!t.isProd){const{default:e}=await(import("../../services/ssr-manifest.js")),s=e.get(t);return await s.prepareDevAssets(r,a),s}let o=s.get(t);return o||(o=new e(t.getParams().root,t.isModulePreload),s.set(t,o)),o};export{t as default};
2
+ //# sourceMappingURL=route-assets.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"route-assets.js","sources":["../../../src/adapters/express/route-assets.ts"],"sourcesContent":[null],"names":["productionAssets","WeakMap","getRouteAssets","async","config","matches","isSpa","isProd","default","SsrManifest","manifest","get","prepareDevAssets","RouteAssets","getParams","root","isModulePreload","set"],"mappings":"8CAOA,MAAMA,EAAmB,IAAIC,QAKvBC,EAAiBC,MACrBC,EACAC,EACAC,GAAQ,KAER,IAAKF,EAAOG,OAAQ,CAClB,MAAQC,QAASC,gBAA6B,mCACxCC,EAAWD,EAAYE,IAAIP,GAIjC,aAFMM,EAASE,iBAAiBP,EAASC,GAElCI,CACT,CAEA,IAAIA,EAAWV,EAAiBW,IAAIP,GAOpC,OALKM,IACHA,EAAW,IAAIG,EAAYT,EAAOU,YAAYC,KAAMX,EAAOY,iBAC3DhB,EAAiBiB,IAAIb,EAAQM,IAGxBA"}
@@ -1 +1 @@
1
- {"version":3,"file":"entry.js","sources":["../../src/browser/entry.tsx"],"sourcesContent":[null],"names":["async","entry","App","routes","init","routerOptions","createRouter","createBrowserRouter","rootId","stream","IS_SSR_MODE","receiveStream","undefined","documentReady","hydrationKey","document","readyState","Reflect","get","window","Promise","resolve","onReady","deleteProperty","addEventListener","once","Object","defineProperty","configurable","enumerable","set","value","writable","removeEventListener","waitForDocument","lazyMatches","matchRoutes","location","basename","filter","m","route","lazy","length","all","map","lazyResult","assign","hydration","__ssrBoostStream","ready","router","root","getElementById","isSSRMode","dataset","documentElement","dispatchEvent","CustomEvent","detail","appProps","AppComponent","React","createElement","client","RouterProvider","ReactDOM","hydrateRoot","createRoot","render"],"mappings":"6NA0EAA,eAAeC,EACbC,EACAC,GACAC,KACEA,EAAIC,cACJA,EAAaC,aACbA,EAAeC,EAAmBC,OAClCA,EAAS,QACyB,CAAA,GAEpC,MAAMC,EAASC,EAAcC,SAAkBC,EACzCC,EAvDgB,MACtB,MAAMC,EAAe,8BAErB,KAC0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IACvBC,EAAAC,cAAC7D,EAAG,CAAC8D,OAAQJ,GACXE,EAAAC,cAACE,GAAed,OAAQA,KAI5B,OAAKG,EAIEY,EAASC,YAAYf,EAAMU,EAAAC,cAACF,EAAY,OAHtCK,EAASE,WAAWhB,GAAMiB,OAAOP,EAAAC,cAACF,EAAY,MAIzD"}
1
+ {"version":3,"file":"entry.js","sources":["../../src/browser/entry.tsx"],"sourcesContent":[null],"names":["async","entry","App","routes","init","routerOptions","createRouter","createBrowserRouter","rootId","stream","IS_SSR_MODE","receiveStream","undefined","documentReady","hydrationKey","document","readyState","Reflect","get","window","Promise","resolve","onReady","deleteProperty","addEventListener","once","Object","defineProperty","configurable","enumerable","set","value","writable","removeEventListener","waitForDocument","lazyMatches","matchRoutes","location","basename","filter","m","route","lazy","length","all","map","lazyResult","assign","hydration","__ssrBoostStream","ready","router","root","getElementById","isSSRMode","dataset","documentElement","dispatchEvent","CustomEvent","detail","appProps","AppComponent","React","createElement","client","RouterProvider","ReactDOM","hydrateRoot","createRoot","render"],"mappings":"6NA0EAA,eAAeC,EACbC,EACAC,GACAC,KACEA,EAAIC,cACJA,EAAaC,aACbA,EAAeC,EAAmBC,OAClCA,EAAS,QACyB,CAAA,GAEpC,MAAMC,EAASC,EAAcC,SAAkBC,EACzCC,EAvDgB,MACtB,MAAMC,EAAe,8BAErB,KAC0B,YAAxBC,SAASC,YACRN,QAAqDE,IAAtCK,QAAQC,IAAIC,OAAQL,IAKtC,OAAO,IAAIM,QAAeC,IACxB,MAAMC,EAAU,KACVZ,GACFO,QAAQM,eAAeJ,OAAQL,GAGjCO,KAGFN,SAASS,iBAAiB,mBAAoBF,EAAS,CAAEG,MAAM,IAE3Df,GACFgB,OAAOC,eAAeR,OAAQL,EAAc,CAC1Cc,cAAc,EACdC,YAAY,EACZX,IAAK,OACLY,IAAMC,IACJL,OAAOC,eAAeR,OAAQL,EAAc,CAC1Cc,cAAc,EACdC,YAAY,EACZG,UAAU,EACVD,UAEFhB,SAASkB,oBAAoB,mBAAoBX,GACjDD,UAqBca,GAChBC,EAAcC,EAClBjC,EACAgB,OAAOkB,SACPhC,GAAeiC,WACdC,OAAQC,GAAMA,EAAEC,MAAMC,OAIrB7B,GAAiBsB,GAAaQ,eAC1BvB,QAAQwB,IAAI,CAChB/B,MACIsB,GAAe,IAAIU,IAAI7C,MAAOwC,IAChC,MAAME,KAAEA,GAASF,EAAEC,MAEnB,GAAoB,mBAATC,EAAqB,CAC9B,MAAMI,QAAmBJ,IAErBI,GACFpB,OAAOqB,OAAOP,EAAEC,MAAO,IAClBK,EACHJ,UAAM9B,GAGZ,MAKN,MAAMoC,EAAY/B,QAAQC,IAAIC,OAAQ,+BAGlCV,GAAUuC,GAAWC,kBACvBhC,QAAQa,IAAIX,OAAQ,oCAAqCV,EAAOyC,OAGlE,MAAMC,EAAS7C,EAAaH,EAAyBE,GAC/C+C,EAAOrC,SAASsC,eAAe7C,GAK/B8C,EACJ5C,GAC6B,MAA7B0C,EAAKG,QAAkB,UAC0B,MAAjDxC,SAASyC,gBAAgBD,QAAkB,SAEzC7C,IACFO,QAAQM,eAAeJ,OAAQ,+BAE3BmC,GACFnC,OAAOsC,cAAc,IAAIC,YAAY,yBAA0B,CAAEC,OAAQ,CAAEnD,cAI/E,MAAMoD,QAAkBxD,IAAO,CAAEkD,YAAWH,YAEtCU,EAAmB,IACvBC,EAAAC,cAAC7D,EAAG,CAAC8D,OAAQJ,GACXE,EAAAC,cAACE,GAAed,OAAQA,KAI5B,OAAKG,EAIEY,EAASC,YAAYf,EAAMU,EAAAC,cAACF,EAAY,OAHtCK,EAASE,WAAWhB,GAAMiB,OAAOP,EAAAC,cAACF,EAAY,MAIzD"}
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,2 @@
1
+ import{readFileSync as e}from"node:fs";import o from"chalk";import{Command as i,Option as t}from"commander";import n from"./helpers/enable-shortcuts.js";import{runStart as r}from"./start.js";import a from"../constants/cli-actions.js";import d from"../constants/cli-context.js";import s from"../constants/cli-name.js";const{description:c,version:l}=JSON.parse(e(new URL("../package.json",import.meta.url),"utf8")),p=new i;p.name(s).description(c).version(l).hook("preAction",(e,o)=>{global.viteBoostAction=o.name()});const m=new t("--host","Ability to access the local instance on other devices under the same network.").default(!1),f=new t("--focus-only [focusOnly]","Build or Start only specified part of app.").default("app").choices(["all","app","client","server","entrypoint"]),u=new t("--port [port]","Server port.").default(3e3),w=new t("--mode [mode]","Env mode.").env("VITE_ENV_MODE").default("production"),O=new t("--build-dir [buildDir]","Build directory output.");p.command(a.dev).description("Run development server.").addOption(m).addOption(u).addOption(new t("--reset-cache","Clear vite cache before run.").default(!1)).addOption(new t("--mode [mode]","Env mode.").env("VITE_ENV_MODE").default("development")).addOption(new t("--entrypoint [entrypoint]","Run only entrypoint by name.")).action(async({host:e,port:i,resetCache:t,mode:r,entrypoint:a})=>{if(t){const{default:e}=await(import("./helpers/vite-reset-cache.js"));await e()}const s=async t=>{console.info(o.cyan("Starting the development server..."));const{default:n}=await(import("./run-dev.js")),{server:s,config:c}=await n({version:l,isHost:e,isPrintInfo:t,port:i,mode:r,entrypointName:a});d.server=s,d.config=c};return d.reboot=s,await n(),s()}),p.command(a.build).description("Create production build.").addOption(f).addOption(w).addOption(new t("--client-options [client-options]",'Pass vite build options for client. Example: --client-options="--ssrManifest"').env("VITE_BUILD_CLIENT_OPTIONS").default("")).addOption(new t("--server-options [server-options]","Pass vite build options for server.").env("VITE_BUILD_SERVER_OPTIONS").default("")).addOption(new t("--unlock-robots","Change general directive Disallow to Allow in robots.txt").default(!1)).addOption(new t("--eject","Produces entrypoint file to run app without cli").default(!1)).addOption(new t("--serverless","Produces entrypoint file to run app like serverless function").default(!1)).addOption(new t("--throw-warnings","The build will abort with an error if warnings occur in the process.").default(!1)).action(async({focusOnly:e,clientOptions:o,serverOptions:i,mode:t,unlockRobots:n,eject:r,serverless:a,throwWarnings:d})=>{await(await(import("./build.js"))).default({focusOnly:e,isUnlockRobots:n,isNoWarnings:d,isEject:r,isServerless:a,clientOptions:o,serverOptions:i,mode:t})}),p.command(a.start).description("Run production server.").addOption(m).addOption(u).addOption(f).addOption(O).addOption(new t("--module-preload","Add module preload scripts to server output.").default(!1)).action(r),p.command(a.preview).description("Build and preview production.").addOption(f).addOption(m).addOption(u).addOption(w).addOption(O).action(async({host:e,port:i,focusOnly:t,mode:r,buildDir:a})=>{global.viteBoostStartTime=performance.now();const s=async n=>{const{default:r}=await(import("./run-prod.js")),{server:s,config:c}=await r({version:l,isHost:e,isPrintInfo:n,port:i,focusOnly:t,buildDir:a});s.on("listening",()=>{setTimeout(()=>{c.getLogger().info(o.yellow("\n Running preview mode... \n"))},0)}),d.server=s,d.config=c};d.reboot=s,await n();await(await(import("./build.js"))).default({mode:r,isWatch:!0,focusOnly:t,clientOptions:"-w",serverOptions:"-w",onFinish:()=>{s()}})}),p.command(a.buildDocker).description("Create docker image with production build.").requiredOption("--image-name <image-name>","Docker image name.").addOption(new t("--docker-options [docker-options]","Extra docker options which pass to docker build command.")).addOption(new t("--docker-file [docker-file]","Name of the Dockerfile (Default is PLUGIN_PATH/workflow/Dockerfile).")).addOption(f).addOption(w).action(async({imageName:e,dockerOptions:o,dockerFile:i,focusOnly:t,mode:n})=>{await(await(import("./run-docker-build.js"))).default({imageName:e,dockerOptions:o,dockerFile:i,focusOnly:t,mode:n})}),p.command(a.buildAmplify).description("Create AWS Amplify production build.").addOption(new t("--manifest-file [manifest-file]","Path to the Amplify manifest file (Default is PLUGIN_PATH/workflow/amplify-manifest.json).")).addOption(new t("--is-optimize","Optimize node_modules folder.").default(!1)).addOption(w).action(async({manifestFile:e,mode:o,isOptimize:i})=>{await(await(import("./run-amplify-build.js"))).default({manifestFile:e,mode:o,isOptimize:i})}),p.command(a.buildVercel).description("Create Vercel serverless production build.").addOption(new t("--config-file [config-file]","Path to the Vercel config.json file (Default is PLUGIN_PATH/workflow/vercel.config.json).")).addOption(new t("--config-vc-file [config-vc-file]","Path to the Vercel vc-config.json file (Default is PLUGIN_PATH/workflow/vercel.vc-config.json).")).addOption(new t("--is-optimize","Optimize node_modules folder.").default(!1)).addOption(w).action(async({configFile:e,configVcFile:o,mode:i,isOptimize:t})=>{await(await(import("./run-vercel-build.js"))).default({configFile:e,configVcFile:o,mode:i,isOptimize:t})}),p.command("doctor").description("Inspect SSR setup and report actionable checks.").option("--json","Print machine-readable JSON.").option("--root <dir>","Project directory.").option("--bundle <file>","Write an allowlisted support bundle JSON.").action(async e=>(await(import("./doctor.js"))).default(e)),p.command("init").description("Add SSR to an existing Vite + React Router app (dry run by default).").option("--dry-run","Print every change without writing files.").option("--apply","Write the proposed changes.").option("--root <dir>","Project directory.").option("--entry <file>","Browser entry relative to the project directory.").option("--routes <file>","Module exporting the route array.").action(async e=>(await(import("./init.js"))).default(e)),await p.parseAsync();
2
+ //# sourceMappingURL=commands.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"commands.js","sources":["../../src/cli/commands.ts"],"sourcesContent":[null],"names":["description","version","JSON","parse","readFileSync","URL","url","program","Command","name","cliName","hook","_","actionCommand","global","viteBoostAction","hostOption","Option","default","focusOnlyOption","choices","portOption","envModeOption","env","buildDirOption","command","CliActions","dev","addOption","action","async","host","port","resetCache","mode","entrypoint","viteResetCache","isPrintInfo","console","info","chalk","cyan","runDev","server","config","isHost","entrypointName","cliContext","reboot","enableShortcuts","build","focusOnly","clientOptions","serverOptions","unlockRobots","eject","serverless","throwWarnings","isUnlockRobots","isNoWarnings","isEject","isServerless","start","runStart","preview","buildDir","viteBoostStartTime","performance","now","runProd","on","setTimeout","getLogger","yellow","isWatch","onFinish","buildDocker","requiredOption","imageName","dockerOptions","dockerFile","buildAmplify","manifestFile","isOptimize","buildVercel","configFile","configVcFile","option","options","parseAsync"],"mappings":"6TAsBA,MAAMA,YAAEA,EAAWC,QAAEA,GAAYC,KAAKC,MACpCC,EAAa,IAAIC,IAAI,8BAA+BC,KAAM,SAGtDC,EAAU,IAAIC,EAEpBD,EACGE,KAAKC,GACLV,YAAY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F,oCACA,6DAGHW,UACC,IAAIX,EACF,8BACA,yEAGHW,UAAUT,GACVS,UAAUN,GAGVO,OACCC,OAASgD,YAAWC,gBAAeC,aAAY7B,YAAWjB,8BAEzC,2BACbhB,QAAQ,CACR4D,YACAC,gBACAC,aACA7B,YACAjB,WAKR3B,EACGkB,QAAQC,EAAWuD,cACnBjF,YAAY,wCACZ4B,UACC,IAAIX,EACF,kCACA,+FAGHW,UAAU,IAAIX,EAAO,gBAAiB,iCAAiCC,SAAQ,IAC/EU,UAAUN,GAGVO,OAAOC,OAASoD,eAAchD,OAAMiD,oCAEpB,4BACbjE,QAAQ,CACRgE,eACAhD,OACAiD,iBAIN5E,EACGkB,QAAQC,EAAW0D,aACnBpF,YAAY,8CACZ4B,UACC,IAAIX,EACF,8BACA,8FAGHW,UACC,IAAIX,EACF,oCACA,oGAGHW,UAAU,IAAIX,EAAO,gBAAiB,iCAAiCC,SAAQ,IAC/EU,UAAUN,GAGVO,OAAOC,OAASuD,aAAYC,eAAcpD,OAAMiD,oCAEhC,2BACbjE,QAAQ,CACRmE,aACAC,eACApD,OACAiD,iBAIN5E,EACGkB,QAAQ,UACRzB,YAAY,mDACZuF,OAAO,SAAU,gCACjBA,OAAO,eAAgB,sBACvBA,OAAO,kBAAmB,6CAG1B1D,OAAOC,MAAO0D,iBAA0C,iBAAgBtE,QAAQsE,IAEnFjF,EACGkB,QAAQ,QACRzB,YAAY,wEACZuF,OAAO,YAAa,6CACpBA,OAAO,UAAW,+BAClBA,OAAO,eAAgB,sBACvBA,OAAO,iBAAkB,oDACzBA,OAAO,kBAAmB,qCAG1B1D,OAAOC,MAAO0D,iBAAwC,eAActE,QAAQsE,UAEzEjF,EAAQkF"}
@@ -0,0 +1,5 @@
1
+ /**
2
+ * Load keyboard handling only for interactive CLI sessions.
3
+ */
4
+ declare const enableShortcuts: () => Promise<void>;
5
+ export default enableShortcuts;
@@ -0,0 +1,2 @@
1
+ const s=async()=>{if(process.stdin.isTTY){const{default:s}=await(import("./keyboard-input.js"));process.stdin.setRawMode(!0),process.stdin.on("data",s).setEncoding("utf8").resume()}};export{s as default};
2
+ //# sourceMappingURL=enable-shortcuts.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"enable-shortcuts.js","sources":["../../../src/cli/helpers/enable-shortcuts.ts"],"sourcesContent":[null],"names":["enableShortcuts","async","process","stdin","isTTY","default","onKeyPress","setRawMode","on","setEncoding","resume"],"mappings":"AAGA,MAAMA,EAAkBC,UACtB,GAAIC,QAAQC,MAAMC,MAAO,CACvB,MAAQC,QAASC,gBAA4B,wBAE7CJ,QAAQC,MAAMI,YAAW,GACzBL,QAAQC,MAAMK,GAAG,OAAQF,GAAYG,YAAY,QAAQC,QAC3D"}
package/cli/run-prod.js CHANGED
@@ -1,2 +1,2 @@
1
- import{performance as o}from"node:perf_hooks";import r from"../adapters/express/server.js";import e from"../helpers/create-focus-only.js";import s from"../services/server-config.js";async function i({version:i,isHost:t,isPrintInfo:n,port:l,buildDir:a,focusOnly:f,modulePreload:m=!1}){global.viteBoostStartTime||(global.viteBoostStartTime=o.now());const p=s.init({isHost:t,isProd:!0,isOnlyClient:e(f).isOnlyClient(),isModulePreload:m},{port:l,root:a}),{run:c}=await r(p);return{server:c({version:i,isPrintInfo:n}),config:p}}export{i as default};
1
+ import{performance as o}from"node:perf_hooks";import e from"../adapters/express/server.js";import r from"../helpers/create-focus-only.js";import i from"../services/production-config.js";import s from"../services/server-config.js";async function t({version:t,isHost:n,isPrintInfo:l,port:a,buildDir:d,focusOnly:f,modulePreload:m=!1}){global.viteBoostStartTime||(global.viteBoostStartTime=o.now());const{root:p,base:c,publicDir:u,indexFile:v,serverFile:b,mode:g}=i(d)??{},y=s.init({isHost:n,isProd:!0,isOnlyClient:r(f).isOnlyClient(),isModulePreload:m,mode:g},{port:a,root:p??d,...void 0===c?{}:{base:c,publicDir:u,indexFile:v,serverFile:b}}),{run:P}=await e(y);return{server:P({version:t,isPrintInfo:l}),config:y}}export{t as default};
2
2
  //# sourceMappingURL=run-prod.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"run-prod.js","sources":["../../src/cli/run-prod.ts"],"sourcesContent":[null],"names":["async","runProd","version","isHost","isPrintInfo","port","buildDir","focusOnly","modulePreload","global","viteBoostStartTime","performance","now","config","ServerConfig","init","isProd","isOnlyClient","createFocusOnly","isModulePreload","root","run","createServer","server"],"mappings":"sLA0BAA,eAAeC,GAAQC,QACrBA,EAAOC,OACPA,EAAMC,YACNA,EAAWC,KACXA,EAAIC,SACJA,EAAQC,UACRA,EAASC,cACTA,GAAgB,IAEXC,OAAOC,qBACVD,OAAOC,mBAAqBC,EAAYC,OAG1C,MAAMC,EAASC,EAAaC,KAC1B,CACEZ,SACAa,QAAQ,EACRC,aAAcC,EAAgBX,GAAWU,eACzCE,gBAAiBX,GAEnB,CAAEH,OAAMe,KAAMd,KAEVe,IAAEA,SAAcC,EAAaT,GAEnC,MAAO,CACLU,OAAQF,EAAI,CAAEnB,UAASE,gBACvBS,SAEJ"}
1
+ {"version":3,"file":"run-prod.js","sources":["../../src/cli/run-prod.ts"],"sourcesContent":[null],"names":["async","runProd","version","isHost","isPrintInfo","port","buildDir","focusOnly","modulePreload","global","viteBoostStartTime","performance","now","root","base","publicDir","indexFile","serverFile","mode","loadProductionConfig","config","ServerConfig","init","isProd","isOnlyClient","createFocusOnly","isModulePreload","undefined","run","createServer","server"],"mappings":"sOA2BAA,eAAeC,GAAQC,QACrBA,EAAOC,OACPA,EAAMC,YACNA,EAAWC,KACXA,EAAIC,SACJA,EAAQC,UACRA,EAASC,cACTA,GAAgB,IAEXC,OAAOC,qBACVD,OAAOC,mBAAqBC,EAAYC,OAG1C,MAAMC,KAAEA,EAAIC,KAAEA,EAAIC,UAAEA,EAASC,UAAEA,EAASC,WAAEA,EAAUC,KAAEA,GACpDC,EAAqBb,IAAa,CAAA,EAC9Bc,EAASC,EAAaC,KAC1B,CACEnB,SACAoB,QAAQ,EACRC,aAAcC,EAAgBlB,GAAWiB,eACzCE,gBAAiBlB,EACjBU,QAEF,CACEb,OACAQ,KAAMA,GAAQP,UACDqB,IAATb,EAAqB,GAAK,CAAEA,OAAMC,YAAWC,YAAWC,iBAG1DW,IAAEA,SAAcC,EAAaT,GAEnC,MAAO,CACLU,OAAQF,EAAI,CAAE1B,UAASE,gBACvBgB,SAEJ"}
package/cli/start.d.ts ADDED
@@ -0,0 +1,10 @@
1
+ import type { IStartActionParams } from './interfaces/actions.js';
2
+ /**
3
+ * Parse ordinary start invocations; delegate help and ambiguous syntax to Commander.
4
+ */
5
+ declare const parseStartOptions: (args: string[]) => IStartActionParams | undefined;
6
+ /**
7
+ * Start and restart the existing managed server without importing other commands.
8
+ */
9
+ declare const runStart: ({ host, port, focusOnly, modulePreload, buildDir, }: IStartActionParams) => Promise<void>;
10
+ export { parseStartOptions, runStart };
package/cli/start.js ADDED
@@ -0,0 +1,2 @@
1
+ import{readFileSync as o}from"node:fs";import{parseArgs as t}from"node:util";import r from"./helpers/enable-shortcuts.js";import e from"../constants/cli-context.js";const s=o=>{try{const{values:r}=t({args:o,options:{host:{type:"boolean",default:!1},port:{type:"string",default:"3000"},"focus-only":{type:"string",default:"app"},"build-dir":{type:"string"},"module-preload":{type:"boolean",default:!1}},allowPositionals:!1}),{host:e,port:s,"focus-only":l,"build-dir":n,"module-preload":i}=r;if(!["all","app","client","server","entrypoint"].includes(l))return;return{host:e,port:Number(s),focusOnly:l,buildDir:n,modulePreload:i}}catch{return}},l=async({host:t,port:s,focusOnly:l,modulePreload:n,buildDir:i})=>{const{version:a}=JSON.parse(o(new URL("../package.json",import.meta.url),"utf8")),{default:u}=await(import("./run-prod.js")),p=async o=>{const{server:r,config:p}=await u({version:a,isHost:t,isPrintInfo:o,port:s,focusOnly:l,modulePreload:n,buildDir:i});e.server=r,e.config=p};e.reboot=p,await r(),await p()};export{s as parseStartOptions,l as runStart};
2
+ //# sourceMappingURL=start.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"start.js","sources":["../../src/cli/start.ts"],"sourcesContent":[null],"names":["parseStartOptions","args","values","parseArgs","options","host","type","default","port","allowPositionals","isHost","focusOnly","buildDir","isModulePreload","includes","Number","modulePreload","runStart","async","version","JSON","parse","readFileSync","URL","url","runProd","command","isPrintInfo","server","config","cliContext","reboot","enableShortcuts"],"mappings":"qKASA,MAAMA,EAAqBC,IACzB,IACE,MAAMC,OAAEA,GAAWC,EAAU,CAC3BF,OACAG,QAAS,CACPC,KAAM,CAAEC,KAAM,UAAWC,SAAS,GAClCC,KAAM,CAAEF,KAAM,SAAUC,QAAS,QACjC,aAAc,CAAED,KAAM,SAAUC,QAAS,OACzC,YAAa,CAAED,KAAM,UACrB,iBAAkB,CAAEA,KAAM,UAAWC,SAAS,IAEhDE,kBAAkB,KAGlBJ,KAAMK,EAAMF,KACZA,EACA,aAAcG,EACd,YAAaC,EACb,iBAAkBC,GAChBX,EAEJ,IAAK,CAAC,MAAO,MAAO,SAAU,SAAU,cAAcY,SAASH,GAC7D,OAGF,MAAO,CACLN,KAAMK,EACNF,KAAMO,OAAOP,GACbG,UAAWA,EACXC,WACAI,cAAeH,EAEnB,CAAE,MACA,MACF,GAMII,EAAWC,OACfb,OACAG,OACAG,YACAK,gBACAJ,eAEA,MAAMO,QAAEA,GAAYC,KAAKC,MACvBC,EAAa,IAAIC,IAAI,8BAA+BC,KAAM,UAEpDjB,QAASkB,gBAAyB,kBAKpCC,EAAUR,MAAOS,IACrB,MAAMC,OAAEA,EAAMC,OAAEA,SAAiBJ,EAAQ,CACvCN,UACAT,OAAQL,EACRsB,cACAnB,OACAG,YACAK,gBACAJ,aAGFkB,EAAWF,OAASA,EACpBE,EAAWD,OAASA,GAGtBC,EAAWC,OAASL,QACdM,UACAN"}
package/cli.js CHANGED
@@ -1,3 +1,3 @@
1
1
  #!/usr/bin/env node
2
- import{readFileSync as o}from"fs";import e from"chalk";import{Command as i,Option as t}from"commander";import n from"./cli/build.js";import r from"./cli/doctor.js";import d from"./cli/helpers/keyboard-input.js";import s from"./cli/helpers/vite-reset-cache.js";import a from"./cli/init.js";import c from"./cli/run-amplify-build.js";import l from"./cli/run-dev.js";import p from"./cli/run-docker-build.js";import m from"./cli/run-prod.js";import f from"./cli/run-vercel-build.js";import u from"./constants/cli-actions.js";import O from"./constants/cli-context.js";import w from"./constants/cli-name.js";const{description:v,version:y}=JSON.parse(o(new URL("./package.json",import.meta.url),"utf8")),g=()=>{process.stdin.isTTY&&(process.stdin.setRawMode(!0),process.stdin.on("data",d).setEncoding("utf8").resume())},h=new i;h.name(w).description(v).version(y).hook("preAction",(o,e)=>{global.viteBoostAction=e.name()});const b=new t("--host","Ability to access the local instance on other devices under the same network.").default(!1),k=new t("--focus-only [focusOnly]","Build or Start only specified part of app.").default("app").choices(["all","app","client","server","entrypoint"]),j=new t("--port [port]","Server port.").default(3e3),P=new t("--mode [mode]","Env mode.").env("VITE_ENV_MODE").default("production"),D=new t("--build-dir [buildDir]","Build directory output.");h.command(u.dev).description("Run development server.").addOption(b).addOption(j).addOption(new t("--reset-cache","Clear vite cache before run.").default(!1)).addOption(new t("--mode [mode]","Env mode.").env("VITE_ENV_MODE").default("development")).addOption(new t("--entrypoint [entrypoint]","Run only entrypoint by name.")).action(async({host:o,port:i,resetCache:t,mode:n,entrypoint:r})=>{t&&await s();const d=async t=>{console.info(e.cyan("Starting the development server..."));const{server:d,config:s}=await l({version:y,isHost:o,isPrintInfo:t,port:i,mode:n,entrypointName:r});O.server=d,O.config=s};return O.reboot=d,g(),d()}),h.command(u.build).description("Create production build.").addOption(k).addOption(P).addOption(new t("--client-options [client-options]",'Pass vite build options for client. Example: --client-options="--ssrManifest"').env("VITE_BUILD_CLIENT_OPTIONS").default("")).addOption(new t("--server-options [server-options]","Pass vite build options for server.").env("VITE_BUILD_SERVER_OPTIONS").default("")).addOption(new t("--unlock-robots","Change general directive Disallow to Allow in robots.txt").default(!1)).addOption(new t("--eject","Produces entrypoint file to run app without cli").default(!1)).addOption(new t("--serverless","Produces entrypoint file to run app like serverless function").default(!1)).addOption(new t("--throw-warnings","The build will abort with an error if warnings occur in the process.").default(!1)).action(async({focusOnly:o,clientOptions:e,serverOptions:i,mode:t,unlockRobots:r,eject:d,serverless:s,throwWarnings:a})=>{await n({focusOnly:o,isUnlockRobots:r,isNoWarnings:a,isEject:d,isServerless:s,clientOptions:e,serverOptions:i,mode:t})}),h.command(u.start).description("Run production server.").addOption(b).addOption(j).addOption(k).addOption(D).addOption(new t("--module-preload","Add module preload scripts to server output.").default(!1)).action(({host:o,port:e,focusOnly:i,modulePreload:t,buildDir:n})=>{const r=async r=>{const{server:d,config:s}=await m({version:y,isHost:o,isPrintInfo:r,port:e,focusOnly:i,modulePreload:t,buildDir:n});O.server=d,O.config=s};return O.reboot=r,g(),r()}),h.command(u.preview).description("Build and preview production.").addOption(k).addOption(b).addOption(j).addOption(P).addOption(D).action(async({host:o,port:i,focusOnly:t,mode:r,buildDir:d})=>{global.viteBoostStartTime=performance.now();const s=async n=>{const{server:r,config:s}=await m({version:y,isHost:o,isPrintInfo:n,port:i,focusOnly:t,buildDir:d});r.on("listening",()=>{setTimeout(()=>{s.getLogger().info(e.yellow("\n Running preview mode... \n"))},0)}),O.server=r,O.config=s};O.reboot=s,g();await n({mode:r,isWatch:!0,focusOnly:t,clientOptions:"-w",serverOptions:"-w",onFinish:()=>{s()}})}),h.command(u.buildDocker).description("Create docker image with production build.").requiredOption("--image-name <image-name>","Docker image name.").addOption(new t("--docker-options [docker-options]","Extra docker options which pass to docker build command.")).addOption(new t("--docker-file [docker-file]","Name of the Dockerfile (Default is PLUGIN_PATH/workflow/Dockerfile).")).addOption(k).addOption(P).action(async({imageName:o,dockerOptions:e,dockerFile:i,focusOnly:t,mode:n})=>{await p({imageName:o,dockerOptions:e,dockerFile:i,focusOnly:t,mode:n})}),h.command(u.buildAmplify).description("Create AWS Amplify production build.").addOption(new t("--manifest-file [manifest-file]","Path to the Amplify manifest file (Default is PLUGIN_PATH/workflow/amplify-manifest.json).")).addOption(new t("--is-optimize","Optimize node_modules folder.").default(!1)).addOption(P).action(async({manifestFile:o,mode:e,isOptimize:i})=>{await c({manifestFile:o,mode:e,isOptimize:i})}),h.command(u.buildVercel).description("Create Vercel serverless production build.").addOption(new t("--config-file [config-file]","Path to the Vercel config.json file (Default is PLUGIN_PATH/workflow/vercel.config.json).")).addOption(new t("--config-vc-file [config-vc-file]","Path to the Vercel vc-config.json file (Default is PLUGIN_PATH/workflow/vercel.vc-config.json).")).addOption(new t("--is-optimize","Optimize node_modules folder.").default(!1)).addOption(P).action(async({configFile:o,configVcFile:e,mode:i,isOptimize:t})=>{await f({configFile:o,configVcFile:e,mode:i,isOptimize:t})}),h.command("doctor").description("Inspect SSR setup and report actionable checks.").option("--json","Print machine-readable JSON.").option("--root <dir>","Project directory.").option("--bundle <file>","Write an allowlisted support bundle JSON.").action(r),h.command("init").description("Add SSR to an existing Vite + React Router app (dry run by default).").option("--dry-run","Print every change without writing files.").option("--apply","Write the proposed changes.").option("--root <dir>","Project directory.").option("--entry <file>","Browser entry relative to the project directory.").option("--routes <file>","Module exporting the route array.").action(a),h.parse();
2
+ import{parseStartOptions as t,runStart as o}from"./cli/start.js";const[s,...a]=process.argv.slice(2),i="start"===s?t(a):void 0;i?(global.viteBoostAction="start",await o(i)):await(import("./cli/commands.js"));
3
3
  //# sourceMappingURL=cli.js.map
package/cli.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"cli.js","sources":["../src/cli.ts"],"sourcesContent":[null],"names":["description","version","JSON","parse","readFileSync","URL","url","enableShortcuts","process","stdin","isTTY","setRawMode","on","onKeyPress","setEncoding","resume","program","Command","name","cliName","hook","_","actionCommand","global","viteBoostAction","hostOption","Option","default","focusOnlyOption","choices","portOption","envModeOption","env","buildDirOption","command","CliActions","dev","addOption","action","async","host","port","resetCache","mode","entrypoint","viteResetCache","isPrintInfo","console","info","chalk","cyan","server","config","runDev","isHost","entrypointName","cliContext","reboot","build","focusOnly","clientOptions","serverOptions","unlockRobots","eject","serverless","throwWarnings","runBuild","isUnlockRobots","isNoWarnings","isEject","isServerless","start","modulePreload","buildDir","runProd","preview","viteBoostStartTime","performance","now","setTimeout","getLogger","yellow","isWatch","onFinish","buildDocker","requiredOption","imageName","dockerOptions","dockerFile","runDockerBuild","buildAmplify","manifestFile","isOptimize","runAmplifyBuild","buildVercel","configFile","configVcFile","runVercelBuild","option","runDoctor","runInit"],"mappings":";ylBA+BA,MAAMA,YAAEA,EAAWC,QAAEA,GAAYC,KAAKC,MACpCC,EAAa,IAAIC,IAAI,6BAA8BC,KAAM,SAOrDC,EAAkB,KAClBC,QAAQC,MAAMC,QAChBF,QAAQC,MAAME,YAAW,GACzBH,QAAQC,MAAMG,GAAG,OAAQC,GAAYC,YAAY,QAAQC,WAIvDC,EAAU,IAAIC,EAEpBD,EACGE,KAAKC,GACLnB,YAAYA,GACZC,QAAQA,GACRmB,KAAK,YAAa,CAACC,EAAGC,KAErBC,OAAOC,gBAAkBF,EAAcJ,SAM3C,MAAMO,EAAa,IAAIC,EACrB,SACA,iFACAC,SAAQ,GACJC,EAAkB,IAAIF,EAC1B,2BACA,8CAECC,QAAQ,OACRE,QAAQ,CAAC,MAAO,MAAO,SAAU,SAAU,eACxCC,EAAa,IAAIJ,EAAO,gBAAiB,gBAAgBC,QAAQ,KACjEI,EAAgB,IAAIL,EAAO,gBAAiB,aAC/CM,IAAI,iBACJL,QAAQ,cACLM,EAAiB,IAAIP,EAAO,yBAA0B,2BAM5DV,EACGkB,QAAQC,EAAWC,KACnBpC,YAAY,2BACZqC,UAAUZ,GACVY,UAAUP,GACVO,UAAU,IAAIX,EAAO,gBAAiB,gCAAgCC,SAAQ,IAC9EU,UAAU,IAAIX,EAAO,gBAAiB,aAAaM,IAAI,iBAAiBL,QAAQ,gBAChFU,UAAU,IAAIX,EAAO,4BAA6B,iCAClDY,OAAOC,OAASC,OAAMC,OAAMC,aAAYC,OAAMC,iBACzCF,SACIG,IAGR,MAAMX,EAAUK,MAAOO,IACrBC,QAAQC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,GACVO,OAAOC,OAASwD,aAAYC,eAAcrD,OAAMiD,uBACzCK,EAAe,CACnBF,aACAC,eACArD,OACAiD,iBAIN5E,EACGkB,QAAQ,UACRlC,YAAY,mDACZkG,OAAO,SAAU,gCACjBA,OAAO,eAAgB,sBACvBA,OAAO,kBAAmB,6CAC1B5D,OAAO6D,GAEVnF,EACGkB,QAAQ,QACRlC,YAAY,wEACZkG,OAAO,YAAa,6CACpBA,OAAO,UAAW,+BAClBA,OAAO,eAAgB,sBACvBA,OAAO,iBAAkB,oDACzBA,OAAO,kBAAmB,qCAC1B5D,OAAO8D,GAEVpF,EAAQb"}
1
+ {"version":3,"file":"cli.js","sources":["../src/cli.ts"],"sourcesContent":[null],"names":["command","args","process","argv","slice","options","parseStartOptions","undefined","global","viteBoostAction","runStart"],"mappings":";iEAIA,MAAOA,KAAYC,GAAQC,QAAQC,KAAKC,MAAM,GACxCC,EAAsB,UAAZL,EAAsBM,EAAkBL,QAAQM,EAE5DF,GACFG,OAAOC,gBAAkB,cACnBC,EAASL,iBAEF"}
package/cloudflare.d.ts CHANGED
@@ -28,7 +28,7 @@ type TWorkerHtml<TEnv> = {
28
28
  indexHtml: string;
29
29
  getHtml?: never;
30
30
  };
31
- export type IWorkerHandlerOptions<TEnv = Record<string, unknown>, TAppProps = Record<string, any>> = Omit<ICreateHandlerOptions<TAppProps>, 'getHtml' | 'onRequest'> & TWorkerHtml<TEnv> & {
31
+ type TWorkerHandlerOptions<TEnv = Record<string, unknown>, TAppProps = Record<string, any>> = Omit<ICreateHandlerOptions<TAppProps>, 'getHtml' | 'onRequest'> & TWorkerHtml<TEnv> & {
32
32
  routes: TRouteObject[];
33
33
  App: FC<PropsWithChildren<{
34
34
  server: TAppProps;
@@ -36,7 +36,9 @@ export type IWorkerHandlerOptions<TEnv = Record<string, unknown>, TAppProps = Re
36
36
  manifest: TRouteAssetsManifest;
37
37
  /** Assets binding name, or false to delegate static delivery elsewhere. Default: ASSETS. */
38
38
  assets?: string | false;
39
+ /** Emit module preload hints when enabled; defaults to false. */
39
40
  modulePreload?: boolean;
41
+ /** HTML insertion marker; defaults to <!--ssr-outlet-->. */
40
42
  outlet?: string;
41
43
  routerOptions?: Parameters<typeof createStaticHandler>[1];
42
44
  onRequest?: (params: {
@@ -52,6 +54,6 @@ export declare const getHtmlFromAssets: (env: object, indexPath?: string, bindin
52
54
  /**
53
55
  * Create a Fetch Worker with in-memory route assets and the Web stream renderer.
54
56
  */
55
- export declare const createWorkerHandler: <TEnv extends object = Record<string, unknown>, TAppProps = Record<string, any>>({ routes, App, manifest, getHtml, indexHtml, assets, modulePreload, outlet, routerOptions, onRequest, onRouterReady, onShellReady, prepare, ...options }: IWorkerHandlerOptions<TEnv, TAppProps>) => TWorkerHandler<TEnv>;
57
+ export declare const createWorkerHandler: <TEnv extends object = Record<string, unknown>, TAppProps = Record<string, any>>({ routes, App, manifest, getHtml, indexHtml, routerOptions, onRequest, onRouterReady, onShellReady, prepare, assets, modulePreload, outlet, ...options }: TWorkerHandlerOptions<TEnv, TAppProps>) => TWorkerHandler<TEnv>;
56
58
  export { RouteAssets };
57
- export type { TRouteAssetsManifest, IHtmlShell };
59
+ export type { TWorkerHandlerOptions as IWorkerHandlerOptions, TRouteAssetsManifest, IHtmlShell };
package/cloudflare.js CHANGED
@@ -1,2 +1,2 @@
1
- import{createElement as e}from"react";import{createStaticHandler as t}from"react-router";import s from"./core/handler.js";import r from"./core/head-response.js";import o from"./edge/render-to-stream.js";import{splitHtmlShell as n}from"./services/diagnostics.js";import a from"./services/route-asset-preparer.js";import i from"./services/route-assets-memory.js";const c="Cache-Control",d=new WeakMap,p=(e,t)=>{const s=Reflect.get(e,t);if(!s||"function"!=typeof s.fetch)throw new Error(`[ssr-boost] Missing Workers assets binding "${t}".`);return s},m=async(e,t="/index.html",s="ASSETS",r="\x3c!--ssr-outlet--\x3e")=>{const o=p(e,s);let a=d.get(o);a||(a=new Map,d.set(o,a));const i=JSON.stringify([t,r]);let c=a.get(i);return c||(c=(async()=>{const e=await o.fetch(new Request(new URL(t,"https://assets.local")));if(!e.ok)throw await(e.body?.cancel()),new Error(`[ssr-boost] Failed to load "${t}" from assets: ${e.status}.`);const[s,a]=n(await e.text(),t,r);return()=>({header:s,footer:a})})(),a.set(i,c),c.catch(()=>a.delete(i))),c},u=({routes:d,App:m,manifest:u,getHtml:l,indexHtml:f,assets:h="ASSETS",modulePreload:w=!1,outlet:g="\x3c!--ssr-outlet--\x3e",routerOptions:x,onRequest:y,onRouterReady:R,onShellReady:S,prepare:b,...v})=>{const E=t(d,x),A=a(new i(u,w)),j=void 0===f?void 0:n(f,"indexHtml",g);return async(t,n,a)=>{const{pathname:i}=new URL(t.url);if(!1!==h&&["GET","HEAD"].includes(t.method)&&"/"!==i&&"/index.html"!==i){const e=await p(n,h).fetch(t);if(404!==e.status){if((e.ok||304===e.status)&&/\/assets\/[^/]+-[\w-]{8,}\.[^/]+$/.test(i)){const s=new Headers(e.headers);return s.set(c,"public, max-age=31536000, immutable"),r(t,new Response(e.body,{status:e.status,statusText:e.statusText,headers:s}))}return r(t,e)}await(e.body?.cancel())}const d={platform:{env:n,ctx:a},waitUntil:a.waitUntil.bind(a)};return s({handler:E,createApp:(t,s)=>e(m,{server:s.appProps},t),renderToStream:o},{diagnostics:!1,...v,getHtml:()=>l?l(t,n,a):{header:j[0],footer:j[1]},onRequest:y?()=>y({request:t,executionContext:d}):void 0,prepare:async e=>{await A(e),await(b?.(e))},onShellReady:e=>{const{context:t}=e;return t.isStream&&!t.response.headers.has("Content-Encoding")&&(t.response.headers.set("Content-Encoding","identity"),t.response.headers.get(c)?.includes("no-transform")||t.response.headers.append(c,"no-transform")),S?.(e)??{}},onRouterReady:async e=>({isStream:!/bot|crawler|spider|slurp|bingpreview/i.test(t.headers.get("User-Agent")??""),...await(R?.(e))})})(t,d)}};export{i as RouteAssets,u as createWorkerHandler,m as getHtmlFromAssets};
1
+ import{createElement as e}from"react";import{createStaticHandler as t}from"react-router";import s from"./core/handler.js";import r from"./core/head-response.js";import o from"./edge/render-to-stream.js";import{splitHtmlShell as n}from"./services/diagnostics.js";import a from"./services/route-asset-preparer.js";import i from"./services/route-assets-memory.js";const c="Cache-Control",d=new WeakMap,m=(e,t)=>{const s=Reflect.get(e,t);if(!s||"function"!=typeof s.fetch)throw new Error(`[ssr-boost] Missing Workers assets binding "${t}".`);return s},l=async(e,t="/index.html",s="ASSETS",r="\x3c!--ssr-outlet--\x3e")=>{const o=m(e,s);let a=d.get(o);a||(a=new Map,d.set(o,a));const i=JSON.stringify([t,r]);let c=a.get(i);return c||(c=(async()=>{const e=await o.fetch(new Request(new URL(t,"https://assets.local"))),{ok:s,body:a,status:i}=e;if(!s)throw await(a?.cancel()),new Error(`[ssr-boost] Failed to load "${t}" from assets: ${i}.`);const[c,d]=n(await e.text(),t,r);return()=>({header:c,footer:d})})(),a.set(i,c),c.catch(()=>a.delete(i))),c},p=({routes:d,App:l,manifest:p,getHtml:u,indexHtml:f,routerOptions:w,onRequest:h,onRouterReady:g,onShellReady:x,prepare:y,assets:R="ASSETS",modulePreload:S=!1,outlet:b="\x3c!--ssr-outlet--\x3e",...v})=>{const E=t(d,w),A=a(new i(p,S)),j=void 0===f?void 0:n(f,"indexHtml",b);return async(t,n,a)=>{const{url:i,method:d,headers:p}=t,{pathname:f}=new URL(i);if(!1!==R&&["GET","HEAD"].includes(d)&&"/"!==f&&"/index.html"!==f){const e=await m(n,R).fetch(t),{status:s,ok:o,headers:a,body:i,statusText:d}=e;if(404!==s){if((o||304===s)&&/\/assets\/[^/]+-[\w-]{8,}\.[^/]+$/.test(f)){const e=new Headers(a);return e.set(c,"public, max-age=31536000, immutable"),r(t,new Response(i,{status:s,statusText:d,headers:e}))}return r(t,e)}await(i?.cancel())}const w={platform:{env:n,ctx:a},waitUntil:a.waitUntil.bind(a)};return s({handler:E,createApp:(t,s)=>e(l,{server:s.appProps},t),renderToStream:o},{diagnostics:!1,...v,getHtml:()=>u?u(t,n,a):{header:j[0],footer:j[1]},onRequest:h?()=>h({request:t,executionContext:w}):void 0,prepare:async e=>{await A(e),await(y?.(e))},onShellReady:e=>{const{context:t}=e,{isStream:s,response:r}=t,{headers:o}=r;return s&&!o.has("Content-Encoding")&&(o.set("Content-Encoding","identity"),o.get(c)?.includes("no-transform")||o.append(c,"no-transform")),x?.(e)??{}},onRouterReady:async e=>({isStream:!/bot|crawler|spider|slurp|bingpreview/i.test(p.get("User-Agent")??""),...await(g?.(e))})})(t,w)}};export{i as RouteAssets,p as createWorkerHandler,l as getHtmlFromAssets};
2
2
  //# sourceMappingURL=cloudflare.js.map
package/cloudflare.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"cloudflare.js","sources":["../src/cloudflare.ts"],"sourcesContent":[null],"names":["CACHE_CONTROL","htmlCache","WeakMap","getAssetsBinding","env","name","binding","Reflect","get","fetch","Error","getHtmlFromAssets","async","indexPath","bindingName","outlet","cache","Map","set","key","JSON","stringify","pending","response","Request","URL","ok","body","cancel","status","header","footer","splitHtmlShell","text","catch","delete","createWorkerHandler","routes","App","manifest","getHtml","indexHtml","assets","modulePreload","routerOptions","onRequest","onRouterReady","onShellReady","prepare","options","handler","createStaticHandler","prepareAssets","createAssetPreparer","RouteAssets","shell","undefined","request","ctx","pathname","url","includes","method","test","headers","Headers","headResponse","Response","statusText","executionContext","platform","waitUntil","bind","createHandler","createApp","children","context","createElement","server","appProps","renderToStream","diagnostics","params","isStream","has","append","render"],"mappings":"yWAsEA,MAAMA,EAAgB,gBAEhBC,EAAY,IAAIC,QAKhBC,EAAmB,CAACC,EAAaC,KACrC,MAAMC,EAAUC,QAAQC,IAAIJ,EAAKC,GAEjC,IAAKC,GAAoC,mBAAlBA,EAAQG,MAC7B,MAAM,IAAIC,MAAM,+CAA+CL,OAGjE,OAAOC,GAOIK,EAAoBC,MAC/BR,EACAS,EAAY,cACZC,EAAc,SACdC,EAAS,6BAET,MAAMT,EAAUH,EAAiBC,EAAKU,GACtC,IAAIE,EAAQf,EAAUO,IA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,EACA,IAAIU,SAAS5C,EAASI,KAAM,CAC1BE,OAAQN,EAASM,OACjBuC,WAAY7C,EAAS6C,WACrBJ,YAGN,CAEA,OAAOE,EAAaT,EAASlC,EAC/B,OAEMA,EAASI,MAAMC,SACvB,CAEA,MAAMyC,EAAkD,CACtDC,SAAU,CAAElE,MAAKsD,OACjBa,UAAWb,EAAIa,UAAUC,KAAKd,IA0ChC,OAxCee,EACb,CACEvB,UACAwB,UAAW,CAACC,EAAUC,IACpBC,EAAcvC,EAAK,CAAEwC,OAAQF,EAAQG,UAAYJ,GACnDK,kBAEF,CACEC,aAAa,KACVhC,EACHT,QAAS,IACPA,EAAUA,EAAQiB,EAASrD,EAAKsD,GAAO,CAAE5B,OAAQyB,EAAO,GAAIxB,OAAQwB,EAAO,IAC7EV,UAAWA,EAAY,IAAMA,EAAU,CAAEY,UAASY,0BAAsBb,EACxER,QAASpC,MAAOsE,UACR9B,EAAc8B,SACdlC,IAAUkC,KAElBnC,aAAemC,IACb,MAAMN,QAAEA,GAAYM,EAWpB,OARIN,EAAQO,WAAaP,EAAQrD,SAASyC,QAAQoB,IAAI,sBACpDR,EAAQrD,SAASyC,QAAQ9C,IAAI,mBAAoB,YAE5C0D,EAAQrD,SAASyC,QAAQxD,IAAIR,IAAgB6D,SAAS,iBACzDe,EAAQrD,SAASyC,QAAQqB,OAAOrF,EAAe,iBAI5C+C,IAAemC,IAAW,CAAA,GAEnCpC,cAAelC,MAAOsE,IAAM,CAC1BC,UAAW,wCAAwCpB,KACjDN,EAAQO,QAAQxD,IAAI,eAAiB,aAE7BsC,IAAgBoC,OAKzBI,CAAO7B,EAASY"}
1
+ {"version":3,"file":"cloudflare.js","sources":["../src/cloudflare.ts"],"sourcesContent":[null],"names":["CACHE_CONTROL","htmlCache","WeakMap","getAssetsBinding","env","name","binding","Reflect","get","fetch","Error","getHtmlFromAssets","async","indexPath","bindingName","outlet","cache","Map","set","key","JSON","stringify","pending","response","Request","URL","ok","isOk","body","status","cancel","header","footer","splitHtmlShell","text","catch","delete","createWorkerHandler","routes","App","manifest","getHtml","indexHtml","routerOptions","onRequest","onRouterReady","onShellReady","prepare","assets","modulePreload","options","handler","createStaticHandler","prepareAssets","createAssetPreparer","RouteAssets","shell","undefined","request","ctx","url","method","headers","requestHeaders","pathname","includes","responseHeaders","statusText","test","Headers","headResponse","Response","executionContext","platform","waitUntil","bind","createHandler","createApp","children","context","createElement","server","appProps","renderToStream","diagnostics","params","isStream","has","append","render"],"mappings":"yWA8EA,MAAMA,EAAgB,gBAKhBC,EAAY,IAAIC,QAKhBC,EAAmB,CAACC,EAAaC,KACrC,MAAMC,EAAUC,QAAQC,IAAIJ,EAAKC,GAEjC,IAAKC,GAAoC,mBAAlBA,EAAQG,MAC7B,MAAM,IAAIC,MAAM,+CAA+CL,OAGjE,OAAOC,GAOIK,EAAoBC,MAC/BR,EACAS,EAAY,cACZC,EAAc,SACdC,EAAS,6BAET,MAAMT,EAAUH,EAAiBC,EAAKU,GACtC,IAAIE,EAAQf,EAAUO,IAAIF,GAErBU,IACHA,EAAQ,IAAIC,IACZhB,EAAUiB,IAAIZ,EAASU,IAGzB,MAAMG,EAAMC,KAAKC,UAAU,CAACR,EAAWE,IACvC,IAAIO,EAAUN,EAAMR,IAAIW,GA8BxB,OA5BKG,IAIHA,EAAU,WACR,MAAMC,QAAiBjB,EAAQG,MAAM,IAAIe,QAAQ,IAAIC,IAAIZ,EAAW,2BAC5Da,GAAIC,EAAIC,KAAEA,EAAIC,OAAEA,GAAWN,EAEnC,IAAKI,EAEH,YADMC,GAAME,UACN,IAAIpB,MAAM,+BAA+BG,mBAA2BgB,MAG5E,MAAOE,EAAQC,GAAUC,QAAqBV,EAASW,OAAQrB,EAAWE,GAK1E,MAAO,KAAA,CAASgB,SAAQC,UACzB,EAfS,GAgBVhB,EAAME,IAAIC,EAAKG,GAKVA,EAAQa,MAAM,IAAMnB,EAAMoB,OAAOjB,KAGjCG,GAMIe,EAAsB,EAIjCC,SACAC,MACAC,W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Y,IAAMA,EAAU,CAAEc,UAASc,0BAAsBf,EAKxEV,QAASnC,MAAOyE,UACRhC,EAAcgC,SACdtC,IAAUsC,KAMlBvC,aAAeuC,IACb,MAAMN,QAAEA,GAAYM,GACdC,SAAEA,EAAQ/D,SAAEA,GAAawD,GACzBjB,QAAEA,GAAYvC,EAWpB,OARI+D,IAAaxB,EAAQyB,IAAI,sBAC3BzB,EAAQ5C,IAAI,mBAAoB,YAE3B4C,EAAQtD,IAAIR,IAAgBiE,SAAS,iBACxCH,EAAQ0B,OAAOxF,EAAe,iBAI3B8C,IAAeuC,IAAW,CAAA,GAMnCxC,cAAejC,MAAOyE,IAAM,CAC1BC,UAAW,wCAAwClB,KACjDL,EAAevD,IAAI,eAAiB,aAE5BqC,IAAgBwC,OAKzBI,CAAO/B,EAASc"}
@@ -1,9 +1,13 @@
1
1
  export interface ICachePolicy {
2
2
  public?: boolean;
3
3
  private?: boolean;
4
+ /** Non-negative integer seconds of freshness in any cache. */
4
5
  maxAge?: number;
6
+ /** Non-negative integer seconds of freshness in shared caches. */
5
7
  sMaxAge?: number;
8
+ /** Non-negative integer seconds to serve stale content during revalidation. */
6
9
  staleWhileRevalidate?: number;
10
+ /** Non-negative integer seconds to serve stale content after an error. */
7
11
  staleIfError?: number;
8
12
  noStore?: boolean;
9
13
  noCache?: boolean;
@@ -1,2 +1,2 @@
1
- const e={public:"public",private:"private",maxAge:"max-age",sMaxAge:"s-maxage",staleWhileRevalidate:"stale-while-revalidate",staleIfError:"stale-if-error",noStore:"no-store",noCache:"no-cache",mustRevalidate:"must-revalidate",immutable:"immutable"},a=new Set(["maxAge","sMaxAge","staleWhileRevalidate","staleIfError"]),t=t=>{if(!t||"object"!=typeof t||Array.isArray(t))throw new TypeError("Cache policy must be an object.");for(const[r,i]of Object.entries(t)){if(!Object.hasOwn(e,r))throw new TypeError(`Unknown cache directive: ${r}.`);if(void 0!==i&&(a.has(r)?"number"!=typeof i||!Number.isSafeInteger(i)||i<0:"boolean"!=typeof i))throw new TypeError(`Invalid cache directive: ${r}.`)}if(t.public&&t.private)throw new TypeError("Cache policy cannot be both public and private.");if(t.noStore&&(t.public||t.immutable||[...a].some(e=>void 0!==t[e]))||t.private&&void 0!==t.sMaxAge||t.immutable&&(t.noCache||t.mustRevalidate)||(t.noCache||t.mustRevalidate)&&(void 0!==t.staleWhileRevalidate||void 0!==t.staleIfError))throw new TypeError("Cache policy contains conflicting directives.");return Object.entries(e).flatMap(([e,r])=>{const i=t[e];return void 0===i||!1===i?[]:[a.has(e)?`${r}=${i}`:r]}).join(", ")};export{t as default};
1
+ const e={public:"public",private:"private",maxAge:"max-age",sMaxAge:"s-maxage",staleWhileRevalidate:"stale-while-revalidate",staleIfError:"stale-if-error",noStore:"no-store",noCache:"no-cache",mustRevalidate:"must-revalidate",immutable:"immutable"},a=new Set(["maxAge","sMaxAge","staleWhileRevalidate","staleIfError"]),t=t=>{if(!t||"object"!=typeof t||Array.isArray(t))throw new TypeError("Cache policy must be an object.");for(const[r,o]of Object.entries(t)){if(!Object.hasOwn(e,r))throw new TypeError(`Unknown cache directive: ${r}.`);if(void 0!==o&&(a.has(r)?"number"!=typeof o||!Number.isSafeInteger(o)||o<0:"boolean"!=typeof o))throw new TypeError(`Invalid cache directive: ${r}.`)}const{public:r,private:o,noStore:i,immutable:n,sMaxAge:c,noCache:l,mustRevalidate:s,staleWhileRevalidate:h,staleIfError:p}=t;if(r&&o)throw new TypeError("Cache policy cannot be both public and private.");if(i&&(r||n||[...a].some(e=>void 0!==t[e]))||o&&void 0!==c||n&&(l||s)||(l||s)&&(void 0!==h||void 0!==p))throw new TypeError("Cache policy contains conflicting directives.");return Object.entries(e).flatMap(([e,r])=>{const o=t[e];return void 0===o||!1===o?[]:[a.has(e)?`${r}=${o}`:r]}).join(", ")};export{t as default};
2
2
  //# sourceMappingURL=cache-control.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"cache-control.js","sources":["../../src/core/cache-control.ts"],"sourcesContent":[null],"names":["directives","public","private","maxAge","sMaxAge","staleWhileRevalidate","staleIfError","noStore","noCache","mustRevalidate","immutable","seconds","Set","cacheControl","policy","Array","isArray","TypeError","name","value","Object","entries","hasOwn","undefined","has","Number","isSafeInteger","some","flatMap","directive","join"],"mappings":"AAaA,MAAMA,EAAa,CACjBC,OAAQ,SACRC,QAAS,UACTC,OAAQ,UACRC,QAAS,WACTC,qBAAsB,yBACtBC,aAAc,iBACdC,QAAS,WACTC,QAAS,WACTC,eAAgB,kBAChBC,UAAW,aAEPC,EAAU,IAAIC,IAAI,CAAC,SAAU,UAAW,uBAAwB,iBAGhEC,EAAgBC,IACpB,IAAKA,GAA4B,iBAAXA,GAAuBC,MAAMC,QAAQF,GACzD,MAAM,IAAIG,UAAU,mCAGtB,IAAK,MAAOC,EAAMC,KAAUC,OAAOC,QAAQP,GAAS,CAClD,IAAKM,OAAOE,OAAOtB,EAAYkB,GAC7B,MAAM,IAAID,UAAU,4BAA4BC,MAGlD,QAAcK,IAAVJ,IAKFR,EAAQa,IAAIN,GACS,iBAAVC,IAAuBM,OAAOC,cAAcP,IAAUA,EAAQ,EACpD,kBAAVA,GAEX,MAAM,IAAIF,UAAU,4BAA4BC,KAEpD,CAEA,GAAIJ,EAAOb,QAAUa,EAAOZ,QAC1B,MAAM,IAAIe,UAAU,mDAGtB,GACGH,EAAOP,UACLO,EAAOb,QACNa,EAAOJ,WACP,IAAIC,GAASgB,KAAMT,QAAgDK,IAAvCT,EAAOI,MACtCJ,EAAOZ,cAA8BqB,IAAnBT,EAAOV,SACzBU,EAAOJ,YAAcI,EAAON,SAAWM,EAAOL,kBAC7CK,EAAON,SAAWM,EAAOL,uBACQc,IAAhCT,EAAOT,2BAA8DkB,IAAxBT,EAAOR,cAEvD,MAAM,IAAIW,UAAU,iDAGtB,OAAOG,OAAOC,QAAQrB,GACnB4B,QAAQ,EAAEV,EAAMW,MACf,MAAMV,EAAQL,EAAOI,GAErB,YAAcK,IAAVJ,IAAiC,IAAVA,EAClB,GAGF,CAACR,EAAQa,IAAIN,GAAQ,GAAGW,KAAaV,IAAUU,KAEvDC,KAAK"}
1
+ {"version":3,"file":"cache-control.js","sources":["../../src/core/cache-control.ts"],"sourcesContent":[null],"names":["directives","public","private","maxAge","sMaxAge","staleWhileRevalidate","staleIfError","noStore","noCache","mustRevalidate","immutable","seconds","Set","cacheControl","policy","Array","isArray","TypeError","name","value","Object","entries","hasOwn","undefined","has","Number","isSafeInteger","isPublic","isPrivate","isNoStore","isImmutable","isNoCache","shouldRevalidate","some","flatMap","directive","join"],"mappings":"AAwBA,MAAMA,EAAa,CACjBC,OAAQ,SACRC,QAAS,UACTC,OAAQ,UACRC,QAAS,WACTC,qBAAsB,yBACtBC,aAAc,iBACdC,QAAS,WACTC,QAAS,WACTC,eAAgB,kBAChBC,UAAW,aAMPC,EAAU,IAAIC,IAAI,CAAC,SAAU,UAAW,uBAAwB,iBAGhEC,EAAgBC,IACpB,IAAKA,GAA4B,iBAAXA,GAAuBC,MAAMC,QAAQF,GACzD,MAAM,IAAIG,UAAU,mCAGtB,IAAK,MAAOC,EAAMC,KAAUC,OAAOC,QAAQP,GAAS,CAClD,IAAKM,OAAOE,OAAOtB,EAAYkB,GAC7B,MAAM,IAAID,UAAU,4BAA4BC,MAGlD,QAAcK,IAAVJ,IAKFR,EAAQa,IAAIN,GACS,iBAAVC,IAAuBM,OAAOC,cAAcP,IAAUA,EAAQ,EACpD,kBAAVA,GAEX,MAAM,IAAIF,UAAU,4BAA4BC,KAEpD,CAEA,MACEjB,OAAQ0B,EACRzB,QAAS0B,EACTrB,QAASsB,EACTnB,UAAWoB,EAAW1B,QACtBA,EACAI,QAASuB,EACTtB,eAAgBuB,EAAgB3B,qBAChCA,EAAoBC,aACpBA,GACEQ,EAEJ,GAAIa,GAAYC,EACd,MAAM,IAAIX,UAAU,mDAGtB,GACGY,IACEF,GACCG,GACA,IAAInB,GAASsB,KAAMf,QAAgDK,IAAvCT,EAAOI,MACtCU,QAAyBL,IAAZnB,GACb0B,IAAgBC,GAAaC,KAC5BD,GAAaC,UACaT,IAAzBlB,QAAuDkB,IAAjBjB,GAEzC,MAAM,IAAIW,UAAU,iDAMtB,OAAOG,OAAOC,QAAQrB,GACnBkC,QAAQ,EAAEhB,EAAMiB,MACf,MAAMhB,EAAQL,EAAOI,GAErB,YAAcK,IAAVJ,IAAiC,IAAVA,EAClB,GAGF,CAACR,EAAQa,IAAIN,GAAQ,GAAGiB,KAAahB,IAAUgB,KAEvDC,KAAK"}
@@ -1,6 +1,7 @@
1
1
  export interface IConditionalValidators {
2
2
  /** Quoted entity tag, optionally prefixed with W/. Must identify the selected representation. */
3
3
  etag?: string;
4
+ /** Modification time of the selected representation; must parse as a valid date. */
4
5
  lastModified?: string | Date;
5
6
  }
6
7
  /**
@@ -8,5 +9,5 @@ export interface IConditionalValidators {
8
9
  * If-None-Match takes precedence, uses weak comparison, and may contain a list.
9
10
  * Call before sending a buffered response; this helper never reads or hashes a stream.
10
11
  */
11
- declare const conditionalRequest: (request: Request, { etag, lastModified }: IConditionalValidators) => Response | undefined;
12
+ declare const conditionalRequest: ({ method, headers: requestHeaders }: Request, { etag, lastModified }: IConditionalValidators) => Response | undefined;
12
13
  export default conditionalRequest;
@@ -1,2 +1,2 @@
1
- const e=/^(?:W\/)?"[\x21\x23-\x7e\x80-\xff]*"$/,t=/^(?:[A-Za-z]{3}, \d{2} [A-Za-z]{3} \d{4} \d{2}:\d{2}:\d{2} GMT|[A-Za-z]+, \d{2}-[A-Za-z]{3}-\d{2} \d{2}:\d{2}:\d{2} GMT|[A-Za-z]{3} [A-Za-z]{3} [ \d]\d \d{2}:\d{2}:\d{2} \d{4})$/,d=(d,{etag:a,lastModified:i})=>{if(void 0!==a&&!e.test(a))throw new TypeError("ETag must be a quoted entity tag, optionally prefixed with W/.");const o=void 0===i?void 0:new Date(i).getTime();if(void 0!==o&&!Number.isFinite(o))throw new TypeError("Last-Modified must be a valid date.");if(!["GET","HEAD"].includes(d.method))return;const s=d.headers.get("If-None-Match");let r=!1;if(null!==s){const e=s.match(/(?:W\/)?"[\x21\x23-\x7e\x80-\xff]*"|\*/g)??[];r=/^(?:\*|(?:W\/)?"[\x21\x23-\x7e\x80-\xff]*"(?:\s*,\s*(?:W\/)?"[\x21\x23-\x7e\x80-\xff]*")*)$/.test(s)&&e.some(e=>"*"===e||a&&e.replace(/^W\//,"")===a.replace(/^W\//,""))}else if(void 0!==o){const e=d.headers.get("If-Modified-Since"),a=null!==e&&t.test(e)?Date.parse(e):NaN;r=Number.isFinite(a)&&Math.floor(o/1e3)<=Math.floor(a/1e3)}if(!r)return;const n=new Headers;return void 0!==a&&n.set("ETag",a),void 0!==o&&n.set("Last-Modified",new Date(o).toUTCString()),new Response(null,{status:304,headers:n})};export{d as default};
1
+ const e=/^(?:W\/)?"[\x21\x23-\x7e\x80-\xff]*"$/,t=/^(?:[A-Za-z]{3}, \d{2} [A-Za-z]{3} \d{4} \d{2}:\d{2}:\d{2} GMT|[A-Za-z]+, \d{2}-[A-Za-z]{3}-\d{2} \d{2}:\d{2}:\d{2} GMT|[A-Za-z]{3} [A-Za-z]{3} [ \d]\d \d{2}:\d{2}:\d{2} \d{4})$/,d=({method:d,headers:i},{etag:a,lastModified:o})=>{if(void 0!==a&&!e.test(a))throw new TypeError("ETag must be a quoted entity tag, optionally prefixed with W/.");const s=void 0===o?void 0:new Date(o).getTime();if(void 0!==s&&!Number.isFinite(s))throw new TypeError("Last-Modified must be a valid date.");if(!["GET","HEAD"].includes(d))return;const n=i.get("If-None-Match");let r=!1;if(null!==n){const e=n.match(/(?:W\/)?"[\x21\x23-\x7e\x80-\xff]*"|\*/g)??[];r=/^(?:\*|(?:W\/)?"[\x21\x23-\x7e\x80-\xff]*"(?:\s*,\s*(?:W\/)?"[\x21\x23-\x7e\x80-\xff]*")*)$/.test(n)&&e.some(e=>"*"===e||a&&e.replace(/^W\//,"")===a.replace(/^W\//,""))}else if(void 0!==s){const e=i.get("If-Modified-Since"),d=null!==e&&t.test(e)?Date.parse(e):NaN;r=Number.isFinite(d)&&Math.floor(s/1e3)<=Math.floor(d/1e3)}if(!r)return;const f=new Headers;return void 0!==a&&f.set("ETag",a),void 0!==s&&f.set("Last-Modified",new Date(s).toUTCString()),new Response(null,{status:304,headers:f})};export{d as default};
2
2
  //# sourceMappingURL=conditional-request.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"conditional-request.js","sources":["../../src/core/conditional-request.ts"],"sourcesContent":[null],"names":["entityTag","httpDate","conditionalRequest","request","etag","lastModified","undefined","test","TypeError","modified","Date","getTime","Number","isFinite","includes","method","noneMatch","headers","get","hasMatch","list","match","some","tag","replace","since","timestamp","parse","NaN","Math","floor","Headers","set","toUTCString","Response","status"],"mappings":"AAMA,MAAMA,EAAY,wCAEZC,EACJ,oLAOIC,EAAqB,CACzBC,GACEC,OAAMC,mBAER,QAAaC,IAATF,IAAuBJ,EAAUO,KAAKH,GACxC,MAAM,IAAII,UAAU,kEAGtB,MAAMC,OAA4BH,IAAjBD,OAA6BC,EAAY,IAAII,KAAKL,GAAcM,UAEjF,QAAiBL,IAAbG,IAA2BG,OAAOC,SAASJ,GAC7C,MAAM,IAAID,UAAU,uCAGtB,IAAK,CAAC,MAAO,QAAQM,SAASX,EAAQY,QACpC,OAGF,MAAMC,EAAYb,EAAQc,QAAQC,IAAI,iBACtC,IAAIC,GAAW,EAEf,GAAkB,OAAdH,EAAoB,CAEtB,MAAMI,EAAiBJ,EAAUK,MAAM,4CAA8C,GAMrFF,EAJE,8FAA8FZ,KAC5FS,IAKFI,EAAKE,KACFC,GAAgB,MAARA,GAAgBnB,GAAQmB,EAAIC,QAAQ,OAAQ,MAAQpB,EAAKoB,QAAQ,OAAQ,IAExF,MAAO,QAAiBlB,IAAbG,EAAwB,CACjC,MAAMgB,EAAQtB,EAAQc,QAAQC,IAAI,qBAC5BQ,EAAsB,OAAVD,GAAkBxB,EAASM,KAAKkB,GAASf,KAAKiB,MAAMF,GAASG,IAE/ET,EACEP,OAAOC,SAASa,IAAcG,KAAKC,MAAMrB,EAAW,MAASoB,KAAKC,MAAMJ,EAAY,IACxF,CAEA,IAAKP,EACH,OAGF,MAAMF,EAAU,IAAIc,QAUpB,YARazB,IAATF,GACFa,EAAQe,IAAI,OAAQ5B,QAGLE,IAAbG,GACFQ,EAAQe,IAAI,gBAAiB,IAAItB,KAAKD,GAAUwB,eAG3C,IAAIC,SAAS,KAAM,CAAEC,OAAQ,IAAKlB"}
1
+ {"version":3,"file":"conditional-request.js","sources":["../../src/core/conditional-request.ts"],"sourcesContent":[null],"names":["entityTag","httpDate","conditionalRequest","method","headers","requestHeaders","etag","lastModified","undefined","test","TypeError","modified","Date","getTime","Number","isFinite","includes","noneMatch","get","hasMatch","list","match","some","tag","replace","since","timestamp","parse","NaN","Math","floor","Headers","set","toUTCString","Response","status"],"mappings":"AAWA,MAAMA,EAAY,wCAKZC,EACJ,oLAOIC,EAAqB,EACvBC,SAAQC,QAASC,IACjBC,OAAMC,mBAER,QAAaC,IAATF,IAAuBN,EAAUS,KAAKH,GACxC,MAAM,IAAII,UAAU,kEAGtB,MAAMC,OAA4BH,IAAjBD,OAA6BC,EAAY,IAAII,KAAKL,GAAcM,UAEjF,QAAiBL,IAAbG,IAA2BG,OAAOC,SAASJ,GAC7C,MAAM,IAAID,UAAU,uCAGtB,IAAK,CAAC,MAAO,QAAQM,SAASb,GAC5B,OAGF,MAAMc,EAAYZ,EAAea,IAAI,iBACrC,IAAIC,GAAW,EAEf,GAAkB,OAAdF,EAAoB,CAItB,MAAMG,EAAiBH,EAAUI,MAAM,4CAA8C,GAMrFF,EAJE,8FAA8FV,KAC5FQ,IAKFG,EAAKE,KACFC,GAAgB,MAARA,GAAgBjB,GAAQiB,EAAIC,QAAQ,OAAQ,MAAQlB,EAAKkB,QAAQ,OAAQ,IAExF,MAAO,QAAiBhB,IAAbG,EAAwB,CACjC,MAAMc,EAAQpB,EAAea,IAAI,qBAC3BQ,EAAsB,OAAVD,GAAkBxB,EAASQ,KAAKgB,GAASb,KAAKe,MAAMF,GAASG,IAE/ET,EACEL,OAAOC,SAASW,IAAcG,KAAKC,MAAMnB,EAAW,MAASkB,KAAKC,MAAMJ,EAAY,IACxF,CAEA,IAAKP,EACH,OAGF,MAAMf,EAAU,IAAI2B,QAUpB,YARavB,IAATF,GACFF,EAAQ4B,IAAI,OAAQ1B,QAGLE,IAAbG,GACFP,EAAQ4B,IAAI,gBAAiB,IAAIpB,KAAKD,GAAUsB,eAG3C,IAAIC,SAAS,KAAM,CAAEC,OAAQ,IAAK/B"}
@@ -3,7 +3,7 @@ import type { StaticHandlerContext } from 'react-router';
3
3
  * Copy only named fields, visiting matched routes root to leaf, loader before action.
4
4
  * The first ordinary value wins (including Cache-Control); all cookies are appended.
5
5
  */
6
- declare const copyLoaderHeaders: (routerContext: Pick<StaticHandlerContext, "matches" | "loaderHeaders" | "actionHeaders">, { allow }: {
6
+ declare const copyLoaderHeaders: ({ matches, loaderHeaders, actionHeaders, }: Pick<StaticHandlerContext, "matches" | "loaderHeaders" | "actionHeaders">, { allow }: {
7
7
  allow: readonly string[];
8
8
  }) => Headers;
9
9
  export default copyLoaderHeaders;
@@ -1,2 +1,2 @@
1
- import{getHeaderEntries as e,getSetCookieHeaders as o}from"./headers.js";const t=(t,{allow:a})=>{const s=new Headers,r=new Set(a.map(e=>e.toLowerCase()));r.delete("content-type");for(const{route:a}of t.matches)for(const n of[t.loaderHeaders[a.id],t.actionHeaders[a.id]])n&&(e(n).forEach(([e,o])=>{r.has(e.toLowerCase())&&!s.has(e)&&s.set(e,o)}),r.has("set-cookie")&&o(n).forEach(e=>s.append("Set-Cookie",e)));return s};export{t as default};
1
+ import{getHeaderEntries as e,getSetCookieHeaders as o}from"./headers.js";const t=({matches:t,loaderHeaders:a,actionHeaders:s},{allow:r})=>{const n=new Headers,c=new Set(r.map(e=>e.toLowerCase()));c.delete("content-type");for(const{route:{id:r}}of t)for(const t of[a[r],s[r]])t&&(e(t).forEach(([e,o])=>{c.has(e.toLowerCase())&&!n.has(e)&&n.set(e,o)}),c.has("set-cookie")&&o(t).forEach(e=>n.append("Set-Cookie",e)));return n};export{t as default};
2
2
  //# sourceMappingURL=copy-loader-headers.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"copy-loader-headers.js","sources":["../../src/core/copy-loader-headers.ts"],"sourcesContent":[null],"names":["copyLoaderHeaders","routerContext","allow","headers","Headers","allowed","Set","map","name","toLowerCase","delete","route","matches","source","loaderHeaders","id","actionHeaders","getHeaderEntries","forEach","value","has","set","getSetCookieHeaders","cookie","append"],"mappings":"yEAOA,MAAMA,EAAoB,CACxBC,GACEC,YAEF,MAAMC,EAAU,IAAIC,QACdC,EAAU,IAAIC,IAAIJ,EAAMK,IAAKC,GAASA,EAAKC,gBAEjDJ,EAAQK,OAAO,gBAEf,IAAK,MAAMC,MAAEA,KAAWV,EAAcW,QACpC,IAAK,MAAMC,IAAU,CACnBZ,EAAca,cAAcH,EAAMI,IAClCd,EAAce,cAAcL,EAAMI,KAE7BF,IAILI,EAAiBJ,GAAQK,QAAQ,EAAEV,EAAMW,MACnCd,EAAQe,IAAIZ,EAAKC,iBAAmBN,EAAQiB,IAAIZ,IAClDL,EAAQkB,IAAIb,EAAMW,KAIlBd,EAAQe,IAAI,eACdE,EAAoBT,GAAQK,QAASK,GAAWpB,EAAQqB,OAAO,aAAcD,KAKnF,OAAOpB"}
1
+ {"version":3,"file":"copy-loader-headers.js","sources":["../../src/core/copy-loader-headers.ts"],"sourcesContent":[null],"names":["copyLoaderHeaders","matches","loaderHeaders","actionHeaders","allow","headers","Headers","allowed","Set","map","name","toLowerCase","delete","route","id","source","getHeaderEntries","forEach","value","has","set","getSetCookieHeaders","cookie","append"],"mappings":"yEAOA,MAAMA,EAAoB,EAEtBC,UACAC,gBACAC,kBAEAC,YAEF,MAAMC,EAAU,IAAIC,QACdC,EAAU,IAAIC,IAAIJ,EAAMK,IAAKC,GAASA,EAAKC,gBAEjDJ,EAAQK,OAAO,gBAEf,IAAK,MACHC,OAAOC,GAAEA,MACNb,EACH,IAAK,MAAMc,IAAU,CAACb,EAAcY,GAAKX,EAAcW,IAChDC,IAOLC,EAAiBD,GAAQE,QAAQ,EAAEP,EAAMQ,MACnCX,EAAQY,IAAIT,EAAKC,iBAAmBN,EAAQc,IAAIT,IAClDL,EAAQe,IAAIV,EAAMQ,KAIlBX,EAAQY,IAAI,eACdE,EAAoBN,GAAQE,QAASK,GAAWjB,EAAQkB,OAAO,aAAcD,KAKnF,OAAOjB"}
@@ -1,2 +1,2 @@
1
- import{getHeaderEntries as e,getSetCookieHeaders as t}from"./headers.js";const o=(e,t)=>(e.headers.get("Cookie")??"").split(";").some(e=>{const o=e.indexOf("=");return-1!==o&&e.slice(0,o).trim()===t}),r=(r,{sessionCookie:s,protectPrivate:n=!0}={})=>({request:a,routerContext:i,response:c})=>{const h=new Headers(c.headers),d={request:a,url:new URL(a.url),isBot:/bot|crawler|spider|crawling/i.test(a.headers.get("User-Agent")??""),hasCookie:e=>o(a,e),routerContext:i};for(const o of r){if(!o.when(d))continue;const r=new Headers(o.set);e(r).forEach(([e,t])=>h.set(e,t)),t(r).forEach(e=>h.append("Set-Cookie",e))}n&&(h.has("Set-Cookie")||a.headers.has("Authorization")||s&&o(a,s))&&h.set("Cache-Control","private, no-store");const l=(h.get("Vary")??"").split(",").map(e=>e.trim()).filter(e=>e&&"cookie"!==e.toLowerCase());return l.length?h.set("Vary",l.join(", ")):h.delete("Vary"),h};export{r as default,o as hasCookie};
1
+ import{getHeaderEntries as e,getSetCookieHeaders as t}from"./headers.js";const o=(e,t)=>(e.headers.get("Cookie")??"").split(";").some(e=>{const o=e.indexOf("=");return-1!==o&&e.slice(0,o).trim()===t}),r=(r,{sessionCookie:s,protectPrivate:n=!0}={})=>({request:i,routerContext:a,response:c})=>{const{url:h,headers:l}=i,d=new Headers(c.headers),p={request:i,url:new URL(h),isBot:/bot|crawler|spider|crawling/i.test(l.get("User-Agent")??""),hasCookie:e=>o(i,e),routerContext:a};for(const o of r){if(!o.when(p))continue;const r=new Headers(o.set);e(r).forEach(([e,t])=>d.set(e,t)),t(r).forEach(e=>d.append("Set-Cookie",e))}n&&(d.has("Set-Cookie")||l.has("Authorization")||s&&o(i,s))&&d.set("Cache-Control","private, no-store");const u=(d.get("Vary")??"").split(",").map(e=>e.trim()).filter(e=>e&&"cookie"!==e.toLowerCase());return u.length?d.set("Vary",u.join(", ")):d.delete("Vary"),d};export{r as default,o as hasCookie};
2
2
  //# sourceMappingURL=document-headers.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"document-headers.js","sources":["../../src/core/document-headers.ts"],"sourcesContent":[null],"names":["hasCookie","request","name","headers","get","split","some","cookie","separator","indexOf","slice","trim","documentHeaders","rules","sessionCookie","protectPrivate","routerContext","response","Headers","ruleContext","url","URL","isBot","test","rule","when","selected","set","getHeaderEntries","forEach","value","getSetCookieHeaders","append","has","vary","map","filter","toLowerCase","length","join","delete"],"mappings":"yEA+BO,MAAMA,EAAY,CAACC,EAAkBC,KACzCD,EAAQE,QAAQC,IAAI,WAAa,IAAIC,MAAM,KAAKC,KAAMC,IACrD,MAAMC,EAAYD,EAAOE,QAAQ,KAEjC,OAAqB,IAAdD,GAAoBD,EAAOG,MAAM,EAAGF,GAAWG,SAAWT,IAO/DU,EAAkB,CACtBC,GACEC,gBAAeC,kBAAiB,GAAkC,KAE7D,EAAGd,UAASe,gBAAeC,eAChC,MAAMd,EAAU,IAAIe,QAAQD,EAASd,SAC/BgB,EAAoC,CACxClB,UACAmB,IAAK,IAAIC,IAAIpB,EAAQmB,KACrBE,MAAO,+BAA+BC,KAAKtB,EAAQE,QAAQC,IAAI,eAAiB,IAChFJ,UAAYE,GAASF,EAAUC,EAASC,GACxCc,iBAGF,IAAK,MAAMQ,KAAQX,EAAO,CACxB,IAAKW,EAAKC,KAAKN,GACb,SAGF,MAAMO,EAAW,IAAIR,QAAQM,EAAKG,KAElCC,EAAiBF,GAAUG,QAAQ,EAAE3B,EAAM4B,KAAW3B,EAAQwB,IAAIzB,EAAM4B,IACxEC,EAAoBL,GAAUG,QAAStB,GAAWJ,EAAQ6B,OAAO,aAAczB,GACjF,CAGEQ,IACCZ,EAAQ8B,IAAI,eACXhC,EAAQE,QAAQ8B,IAAI,kBACnBnB,GAAiBd,EAAUC,EAASa,KAEvCX,EAAQwB,IAAI,gBAAiB,qBAK/B,MAAMO,GAAQ/B,EAAQC,IAAI,SAAW,IAClCC,MAAM,KACN8B,IAAKjC,GAASA,EAAKS,QACnByB,OAAQlC,GAASA,GAA+B,WAAvBA,EAAKmC,eAQjC,OANIH,EAAKI,OACPnC,EAAQwB,IAAI,OAAQO,EAAKK,KAAK,OAE9BpC,EAAQqC,OAAO,QAGVrC"}
1
+ {"version":3,"file":"document-headers.js","sources":["../../src/core/document-headers.ts"],"sourcesContent":[null],"names":["hasCookie","request","name","headers","get","split","some","cookie","separator","indexOf","slice","trim","documentHeaders","rules","sessionCookie","protectPrivate","routerContext","response","url","requestHeaders","Headers","ruleContext","URL","isBot","test","rule","when","selected","set","getHeaderEntries","forEach","value","getSetCookieHeaders","append","has","vary","map","filter","toLowerCase","length","join","delete"],"mappings":"yEAiCO,MAAMA,EAAY,CAACC,EAAkBC,KACzCD,EAAQE,QAAQC,IAAI,WAAa,IAAIC,MAAM,KAAKC,KAAMC,IACrD,MAAMC,EAAYD,EAAOE,QAAQ,KAEjC,OAAqB,IAAdD,GAAoBD,EAAOG,MAAM,EAAGF,GAAWG,SAAWT,IAO/DU,EAAkB,CACtBC,GACEC,gBAAeC,kBAAiB,GAAkC,KAK7D,EAAGd,UAASe,gBAAeC,eAChC,MAAMC,IAAEA,EAAKf,QAASgB,GAAmBlB,EACnCE,EAAU,IAAIiB,QAAQH,EAASd,SAC/BkB,EAAoC,CACxCpB,UACAiB,IAAK,IAAII,IAAIJ,GACbK,MAAO,+BAA+BC,KAAKL,EAAef,IAAI,eAAiB,IAK/EJ,UAAYE,GAASF,EAAUC,EAASC,GACxCc,iBAGF,IAAK,MAAMS,KAAQZ,EAAO,CACxB,IAAKY,EAAKC,KAAKL,GACb,SAGF,MAAMM,EAAW,IAAIP,QAAQK,EAAKG,KAElCC,EAAiBF,GAAUG,QAAQ,EAAE5B,EAAM6B,KAAW5B,EAAQyB,IAAI1B,EAAM6B,IACxEC,EAAoBL,GAAUG,QAASvB,GAAWJ,EAAQ8B,OAAO,aAAc1B,GACjF,CAGEQ,IACCZ,EAAQ+B,IAAI,eACXf,EAAee,IAAI,kBAClBpB,GAAiBd,EAAUC,EAASa,KAEvCX,EAAQyB,IAAI,gBAAiB,qBAO/B,MAAMO,GAAQhC,EAAQC,IAAI,SAAW,IAClCC,MAAM,KACN+B,IAAKlC,GAASA,EAAKS,QACnB0B,OAAQnC,GAASA,GAA+B,WAAvBA,EAAKoC,eAQjC,OANIH,EAAKI,OACPpC,EAAQyB,IAAI,OAAQO,EAAKK,KAAK,OAE9BrC,EAAQsC,OAAO,QAGVtC"}
package/core/handler.js CHANGED
@@ -1,2 +1,2 @@
1
- import{hasCookie as e}from"./document-headers.js";import s from"./head-response.js";import t from"./render.js";import o from"./spa-shell.js";import r from"./ssr-policy.js";import n,{isDiagnosticsEnabled as a}from"../services/diagnostics.js";import{createTimeline as i}from"../services/request-timeline.js";const c=(c,{diagnostics:p,getHtml:m,onContext:d,onRequest:l,ssr:u,basename:h,...f})=>{const w=new r(u,c.handler.dataRoutes,h),j=o();return async(o,r)=>{const u=a(p),h=i(o,u);try{const a=await(l?.({executionContext:r,request:o})),i=a instanceof Response,p=i?void 0:a,x={appProps:p?.appProps??{},diagnostics:u?new n(new URL(o.url).pathname):void 0,executionContext:r,html:i?{header:"",footer:""}:await m(o),request:o,response:{headers:new Headers(p?.headers),status:p?.status},...h?{timeline:h}:{}};if(d?.({context:x}),i){x.diagnostics?.inspectCachePolicy(a.headers,Boolean(f.sessionCookie&&e(o,f.sessionCookie)));const t=await s(o,a);return h?.response(t)??t}return await t({...c,policy:w,spaShell:j},x,f,r)}catch(e){throw h?.abort(e),h?.end(),e}}};export{c as default};
1
+ import{hasCookie as e}from"./document-headers.js";import s from"./head-response.js";import t from"./render.js";import o from"./spa-shell.js";import r from"./ssr-policy.js";import n,{isDiagnosticsEnabled as a}from"../services/diagnostics.js";import{createTimeline as i}from"../services/request-timeline.js";const c=(c,{diagnostics:p,getHtml:m,onContext:d,onRequest:l,ssr:u,basename:h,...f})=>{const w=new r(u,c.handler.dataRoutes,h),j=o();return async(o,r)=>{const u=a(p),h=i(o,u);try{const a=await(l?.({executionContext:r,request:o})),i=a instanceof Response,p=i?void 0:a,x={appProps:p?.appProps??{},diagnostics:u?new n(new URL(o.url).pathname):void 0,executionContext:r,html:i?{header:"",footer:""}:await m(o),request:o,response:{headers:new Headers(p?.headers),status:p?.status},...h?{timeline:h}:{}};if(d?.({context:x}),i){const{sessionCookie:t}=f;x.diagnostics?.inspectCachePolicy(a.headers,Boolean(t&&e(o,t)));const r=await s(o,a);return h?.response(r)??r}return await t({...c,policy:w,spaShell:j},x,f,r)}catch(e){throw h?.abort(e),h?.end(),e}}};export{c as default};
2
2
  //# sourceMappingURL=handler.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"handler.js","sources":["../../src/core/handler.ts"],"sourcesContent":[null],"names":["createHandler","params","diagnostics","getHtml","onContext","onRequest","ssr","basename","options","policy","SsrPolicy","handler","dataRoutes","spaShell","createSpaShell","async","request","executionContext","isEnabled","isDiagnosticsEnabled","timeline","createTimeline","requestInit","isBypass","Response","metadata","undefined","context","appProps","Diagnostics","URL","url","pathname","html","header","footer","response","headers","Headers","status","inspectCachePolicy","Boolean","sessionCookie","hasCookie","headResponse","render","error","abort","end"],"mappings":"kTAsDA,MAAMA,EAAgB,CACpBC,GAEEC,cACAC,UACAC,YACAC,YACAC,MACAC,cACGC,MAGL,MAAMC,EAAS,IAAIC,EAAUJ,EAAKL,EAAOU,QAAQC,WAAYL,GACvDM,EAAWC,IAKjB,OAAOC,MAAOC,EAASC,KACrB,MAAMC,EAAYC,EAAqBjB,GACjCkB,EAAWC,EAAeL,EAASE,GAEzC,IACE,MAAMI,QAAoBjB,IAAY,CAAEY,mBAAkBD,aACpDO,EAAWD,aAAuBE,SAClCC,EAAWF,OAAWG,EAAYJ,EAClCK,EAAyC,CAC7CC,SAAWH,GAAUG,UAAY,GACjC1B,YAAagB,EAAY,IAAIW,EAAY,IAAIC,IAAId,EAAQe,KAAKC,eAAYN,EAC1ET,mBACAgB,KAAMV,EAAW,CAAEW,OAAQ,GAAIC,OAAQ,UAAahC,EAAQa,GAC5DA,UACAoB,SAAU,CACRC,QAAS,IAAIC,QAAQb,GAAUY,SAC/BE,OAAQd,GAAUc,WAEhBnB,EAAW,CAAEA,YAAa,IAKhC,GAFAhB,IAAY,CAAEuB,YAEVJ,EAAU,CACZI,EAAQzB,aAAasC,mBACnBlB,EAAYe,QACZI,QAAQjC,EAAQkC,eAAiBC,EAAU3B,EAASR,EAAQkC,iBAG9D,MAAMN,QAAiBQ,EAAa5B,EAASM,GAE7C,OAAOF,GAAUgB,SAASA,IAAaA,CACzC,CAEA,aAAaS,EAAO,IAAK5C,EAAQQ,SAAQI,YAAYc,EAASnB,EAASS,EACzE,CAAE,MAAO6B,GAGP,MAFA1B,GAAU2B,MAAMD,GAChB1B,GAAU4B,MACJF,CACR"}
1
+ {"version":3,"file":"handler.js","sources":["../../src/core/handler.ts"],"sourcesContent":[null],"names":["createHandler","params","diagnostics","getHtml","onContext","onRequest","ssr","basename","options","policy","SsrPolicy","handler","dataRoutes","spaShell","createSpaShell","async","request","executionContext","isEnabled","isDiagnosticsEnabled","timeline","createTimeline","requestInit","isBypass","Response","metadata","undefined","context","appProps","Diagnostics","URL","url","pathname","html","header","footer","response","headers","Headers","status","sessionCookie","inspectCachePolicy","Boolean","hasCookie","headResponse","render","error","abort","end"],"mappings":"kTAsDA,MAAMA,EAAgB,CACpBC,GAEEC,cACAC,UACAC,YACAC,YACAC,MACAC,cACGC,MAGL,MAAMC,EAAS,IAAIC,EAAUJ,EAAKL,EAAOU,QAAQC,WAAYL,GACvDM,EAAWC,IAKjB,OAAOC,MAAOC,EAASC,KACrB,MAAMC,EAAYC,EAAqBjB,GACjCkB,EAAWC,EAAeL,EAASE,GAEzC,IACE,MAAMI,QAAoBjB,IAAY,CAAEY,mBAAkBD,aACpDO,EAAWD,aAAuBE,SAClCC,EAAWF,OAAWG,EAAYJ,EAClCK,EAAyC,CAC7CC,SAAWH,GAAUG,UAAY,GACjC1B,YAAagB,EAAY,IAAIW,EAAY,IAAIC,IAAId,EAAQe,KAAKC,eAAYN,EAC1ET,mBACAgB,KAAMV,EAAW,CAAEW,OAAQ,GAAIC,OAAQ,UAAahC,EAAQa,GAC5DA,UACAoB,SAAU,CACRC,QAAS,IAAIC,QAAQb,GAAUY,SAC/BE,OAAQd,GAAUc,WAEhBnB,EAAW,CAAEA,YAAa,IAKhC,GAFAhB,IAAY,CAAEuB,YAEVJ,EAAU,CACZ,MAAMiB,cAAEA,GAAkBhC,EAE1BmB,EAAQzB,aAAauC,mBACnBnB,EAAYe,QACZK,QAAQF,GAAiBG,EAAU3B,EAASwB,KAG9C,MAAMJ,QAAiBQ,EAAa5B,EAASM,GAE7C,OAAOF,GAAUgB,SAASA,IAAaA,CACzC,CAEA,aAAaS,EAAO,IAAK5C,EAAQQ,SAAQI,YAAYc,EAASnB,EAASS,EACzE,CAAE,MAAO6B,GAGP,MAFA1B,GAAU2B,MAAMD,GAChB1B,GAAU4B,MACJF,CACR"}