@lomray/vite-ssr-boost 8.5.0 → 8.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/adapters/express/entry.d.ts +3 -1
- package/adapters/express/entry.js.map +1 -1
- package/adapters/express/server.js +1 -1
- package/adapters/express/server.js.map +1 -1
- package/adapters/express/static-files.d.ts +7 -2
- package/adapters/express/static-files.js +1 -1
- package/adapters/express/static-files.js.map +1 -1
- package/package.json +1 -1
|
@@ -32,7 +32,9 @@ export interface IPrepareRenderOut<TAppProps = Record<string, any>> {
|
|
|
32
32
|
middlewares?: {
|
|
33
33
|
compression?: CompressionOptions | false;
|
|
34
34
|
/**
|
|
35
|
-
* basename should be same as vite 'base' config
|
|
35
|
+
* basename should be same as vite 'base' config.
|
|
36
|
+
* Without an explicit `dotfiles` option `/.well-known/` is served (an extensionless request
|
|
37
|
+
* there also resolves the `.json` file) and other dot paths are ignored.
|
|
36
38
|
*/
|
|
37
39
|
expressStatic?: (ServeStaticOptions & {
|
|
38
40
|
basename?: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"entry.js","sources":["../../../src/adapters/express/entry.tsx"],"sourcesContent":[null],"names":["entry","App","routes","init","routerOptions","ssr","requestGuard","notFound","admission","rest","handler","createStaticHandler","runtime","HandlerRuntime","dataRoutes","basename","render","bind"],"mappings":"
|
|
1
|
+
{"version":3,"file":"entry.js","sources":["../../../src/adapters/express/entry.tsx"],"sourcesContent":[null],"names":["entry","App","routes","init","routerOptions","ssr","requestGuard","notFound","admission","rest","handler","createStaticHandler","runtime","HandlerRuntime","dataRoutes","basename","render","bind"],"mappings":"2HAuFA,SAASA,EACPC,EACAC,GACAC,KACEA,EAAIC,cACJA,EAAaC,IACbA,EAAGC,aACHA,EAAYC,SACZA,EAAQC,UACRA,KACGC,GAC+B,CAAA,GAEpC,MAAMC,EAAUC,EAAoBT,EAAyBE,GACvDQ,EAAU,IAAIC,EAAeH,EAAQI,WAAY,CACrDT,MACAC,eACAC,WACAC,YACAO,SAAUX,GAAeW,WAG3B,MAAO,CACLC,OAAQA,EAAOC,KAAK,KAAM,CAAEP,UAAST,MAAKW,YAC1CT,OACAD,YACGO,EAEP"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import e from"node:http";import r from"node:https";import t from"node:path";import o from"compression";import s from"express";import i from"./prepare-server.js";import n from"./static-files.js";import a from"../../helpers/print-server-info.js";import p from"../../services/server-api.js";async function
|
|
1
|
+
import e from"node:http";import r from"node:https";import t from"node:path";import o from"compression";import s from"express";import i from"./prepare-server.js";import n from"./static-files.js";import a from"../../helpers/print-server-info.js";import p from"../../services/server-api.js";async function d(d){const m=s().disable("x-powered-by");d.isProd&&m.set("env","production");const c=new p;d.setApp(m);const l=i.init(d,c);if(!d.isProd){const e=await(await(import("vite"))).createServer({server:{middlewareMode:!0,watch:{usePolling:!0,interval:100}},appType:"custom",mode:d.mode});m.use(e.middlewares),d.setVite(e)}const{isSPA:f}=d.getParams();if(f||await l.onAppCreated(),d.isProd){const{root:e,publicDir:r}=d.getParams(),{compression:s,expressStatic:i}=l.getMiddlewaresConfig();if(s&&m.use(o(s)),f||m.use((e,r,t)=>{"/index.html"!==e.url||c.hasAccessIndexHtml()||(e.url="/index-not-found.html"),t()}),i){const{basename:o,...s}=i;m.use(o,n(t.resolve(`${e}/${r}`),{...s,index:!!f&&void 0},f))}}return f?m.use(/(.*)/,(e,r,t)=>{(async()=>{try{const t=(await l.loadHtml(e)).join("");r.send(t)}catch(e){d.getLogger().error(`Failed to handle request: ${e?.message}`,{error:e}),t(e)}})()}):m.use(/(.*)/,(e,r,t)=>{(async()=>{try{const{render:o,onRequest:s,...i}=await l.loadEntrypoint(),n={req:e,res:r,appProps:{},html:{header:"",footer:""}};await o(d,n,{...i,onRequest:s,onSkip:t,getHtml:async()=>{const[r,t]=await l.loadHtml(e);return{header:r,footer:t}}})}catch(e){d.getLogger().error(`Failed to handle request: ${e?.message}`,{error:e}),t(e)}})()}),{run:({version:t,isPrintInfo:o=!0}={})=>{const{port:s,host:i}=d.getParams(),n=Boolean(d.getVite()?.config?.server?.https);d.isHost&&!d.isProd&&(d.getVite().config.server.host=i);const p=(n?r.createServer(d.getVite().config.server.https,m):e.createServer(m)).listen(s,i,()=>{l.onServerStarted?.(m,c,p),o&&a(d,{version:t,server:p})});return p},app:m}}export{d as default};
|
|
2
2
|
//# sourceMappingURL=server.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"server.js","sources":["../../../src/adapters/express/server.ts"],"sourcesContent":[null],"names":["async","createServer","config","app","express","disable","isProd","set","serverApi","ServerApi","setApp","prepareServer","PrepareServer","init","vite","server","middlewareMode","watch","usePolling","interval","appType","mode","use","middlewares","setVite","isSPA","getParams","onAppCreated","root","publicDir","compression","compressionConfig","expressStatic","getMiddlewaresConfig","req","_","next","url","hasAccessIndexHtml","basename","expressStaticOpts","
|
|
1
|
+
{"version":3,"file":"server.js","sources":["../../../src/adapters/express/server.ts"],"sourcesContent":[null],"names":["async","createServer","config","app","express","disable","isProd","set","serverApi","ServerApi","setApp","prepareServer","PrepareServer","init","vite","server","middlewareMode","watch","usePolling","interval","appType","mode","use","middlewares","setVite","isSPA","getParams","onAppCreated","root","publicDir","compression","compressionConfig","expressStatic","getMiddlewaresConfig","req","_","next","url","hasAccessIndexHtml","basename","expressStaticOpts","staticFiles","path","resolve","index","undefined","res","html","loadHtml","join","send","e","getLogger","error","message","render","onRequest","renderParams","loadEntrypoint","renderInput","appProps","header","footer","onSkip","getHtml","run","version","isPrintInfo","port","host","isHTTPS","Boolean","getVite","https","isHost","http","listen","onServerStarted","printServerInfo"],"mappings":"gSAsBAA,eAAeC,EAAaC,GAC1B,MAAMC,EAAMC,IAAUC,QAAQ,gBAE1BH,EAAOI,QACTH,EAAII,IAAI,MAAO,cAGjB,MAAMC,EAAY,IAAIC,EAEtBP,EAAOQ,OAAOP,GAEd,MAAMQ,EAAgBC,EAAcC,KAA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,OAAQ,WAGxBP,EAAOrD,EAAQyD,EAAa,IAC7BF,EACHD,YACAO,OAAQ3B,EAER4B,QAAShE,UACP,MAAO6D,EAAQC,SAAgBnD,EAAcqC,SAASd,GAEtD,MAAO,CAAE2B,SAAQC,YAGvB,CAAE,MAAOX,GACPjD,EACGkD,YACAC,MAAM,6BAA8BF,GAAaG,UAAW,CAAED,MAAOF,IACxEf,EAAKe,EACP,CACD,EA3BI,KAiDF,CAILc,IAAK,EAAGC,UAASC,eAAc,GAAS,CAAA,KACtC,MAAMC,KAAEA,EAAIC,KAAEA,GAASnE,EAAOwB,YACxB4C,EAAUC,QAAQrE,EAAOsE,WAAWtE,QAAQa,QAAQ0D,OAKtDvE,EAAOwE,SAAWxE,EAAOI,SAC3BJ,EAAOsE,UAAWtE,OAAOa,OAAOsD,KAAOA,GAGzC,MAAMtD,GACJuD,EACIG,EAAMxE,aAAaC,EAAOsE,UAAWtE,OAAOa,OAAO0D,MAAQtE,GAC3DwE,EAAK1E,aAAaE,IACtByE,OAAOR,EAAMC,EAAM,KACd1D,EAAckE,kBAAkB1E,EAAKK,EAAWO,GAEhDoD,GAIAW,EAAgB5E,EAAQ,CAAEgE,UAASnD,aAG1C,OAAOA,GAETZ,MAEJ"}
|
|
@@ -1,7 +1,12 @@
|
|
|
1
1
|
import type { RequestHandler } from 'express';
|
|
2
2
|
import type { ServeStaticOptions } from 'serve-static';
|
|
3
3
|
/**
|
|
4
|
-
*
|
|
4
|
+
* Serve the public directory.
|
|
5
|
+
* serve-static skips dotfiles unless told otherwise, but `/.well-known/` (app links,
|
|
6
|
+
* security.txt, ACME challenges) must reach the client: without an explicit `dotfiles`
|
|
7
|
+
* option that prefix alone is served, other dot paths stay hidden.
|
|
8
|
+
* Well-known files are requested without an extension (apple-app-site-association) while
|
|
9
|
+
* tooling keeps them as `.json` on disk, so that prefix also resolves `name` to `name.json`.
|
|
5
10
|
*/
|
|
6
|
-
declare const staticFiles: (root: string, options: ServeStaticOptions) => RequestHandler;
|
|
11
|
+
declare const staticFiles: (root: string, options: ServeStaticOptions, isSPA?: boolean) => RequestHandler;
|
|
7
12
|
export default staticFiles;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{readdirSync as t}from"node:fs";import e from"express";const
|
|
1
|
+
import{readdirSync as t}from"node:fs";import e from"node:path";import o from"express";const s=t=>{try{return decodeURIComponent(t.split("?",1)[0])}catch{return}},n=(n,r,i=!1)=>{const c=i?o.static(n,r):((e,n)=>{const r=o.static(e,n);if(!1===n.fallthrough||n.extensions)return r;let i;try{i=new Set(t(e).map(t=>t.toLowerCase()))}catch{return r}return(t,e,o)=>{const n=s(t.url);if(void 0===n)return void r(t,e,o);const c=n.indexOf("/",1),l=n.slice(1,c<0?void 0:c).toLowerCase();i.has(l)||n.includes("/.")||n.includes("\\")||n.includes("\0")||n.startsWith("//")?r(t,e,o):o()}})(n,r);if(void 0!==r.dotfiles)return c;const l=o.static(n,{...r,dotfiles:"allow",extensions:r.extensions??["json"]});return(t,o,n)=>{const r=s(t.url);(void 0!==r&&!r.includes("\\")&&e.posix.normalize(r).startsWith("/.well-known/")?l:c)(t,o,n)}};export{n as default};
|
|
2
2
|
//# sourceMappingURL=static-files.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"static-files.js","sources":["../../../src/adapters/express/static-files.ts"],"sourcesContent":[null],"names":["staticFiles","root","options","serve","express","static","fallthrough","extensions","prefixes","Set","readdirSync","map","name","toLowerCase","request","response","next","pathname","
|
|
1
|
+
{"version":3,"file":"static-files.js","sources":["../../../src/adapters/express/static-files.ts"],"sourcesContent":[null],"names":["getPathname","url","decodeURIComponent","split","staticFiles","root","options","isSPA","serve","express","static","fallthrough","extensions","prefixes","Set","readdirSync","map","name","toLowerCase","request","response","next","pathname","undefined","separator","indexOf","prefix","slice","has","includes","startsWith","ssrStaticFiles","dotfiles","serveWellKnown","path","posix","normalize"],"mappings":"sFAMA,MAKMA,EAAeC,IACnB,IACE,OAAOC,mBAAmBD,EAAIE,MAAM,IAAK,GAAG,GAC9C,CAAE,MACA,MACF,GA4DIC,EAAc,CAACC,EAAcC,EAA6BC,GAAQ,KACtE,MAAMC,EAAQD,EAAQE,EAAQC,OAAOL,EAAMC,GAvDtB,EAACD,EAAcC,KACpC,MAAME,EAAQC,EAAQC,OAAOL,EAAMC,GAEnC,IAA4B,IAAxBA,EAAQK,aAAyBL,EAAQM,WAC3C,OAAOJ,EAGT,IAAIK,EAEJ,IACEA,EAAW,IAAIC,IAAIC,EAAYV,GAAMW,IAAKC,GAASA,EAAKC,eAC1D,CAAE,MACA,OAAOV,CACT,CAKA,MAAO,CAACW,EAASC,EAAUC,KACzB,MAAMC,EAAWtB,EAAYmB,EAAQlB,KAErC,QAAiBsB,IAAbD,EAGF,YAFAd,EAAMW,EAASC,EAAUC,GAK3B,MAAMG,EAAYF,EAASG,QAAQ,IAAK,GAClCC,EAASJ,EAASK,MAAM,EAAGH,EAAY,OAAID,EAAYC,GAAWN,cAGtEL,EAASe,IAAIF,IACbJ,EAASO,SAAS,OAClBP,EAASO,SAAS,OAClBP,EAASO,SAAS,OAClBP,EAASQ,WAAW,MAEpBtB,EAAMW,EAASC,EAAUC,GAK3BA,MAaoDU,CAAe1B,EAAMC,GAE3E,QAAyBiB,IAArBjB,EAAQ0B,SACV,OAAOxB,EAGT,MAAMyB,EAAiBxB,EAAQC,OAAOL,EAAM,IACvCC,EACH0B,SAAU,QACVpB,WAAYN,EAAQM,YAAc,CAAC,UAGrC,MAAO,CAACO,EAASC,EAAUC,KACzB,MAAMC,EAAWtB,EAAYmB,EAAQlB,WAGtBsB,IAAbD,IACCA,EAASO,SAAS,OACnBK,EAAKC,MAAMC,UAAUd,GAAUQ,WAzFlB,iBA2FAG,EAAiBzB,GAAOW,EAASC,EAAUC"}
|