codeforlife 2.12.0 → 2.12.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,2 +1,2 @@
1
- "use strict";const A=require("react/jsx-runtime");require("react");const e=require("react-router"),o="data:image/x-icon;base64,iVBORw0KGgoAAAANSUhEUgAAABEAAAARCAYAAAA7bUf6AAAACXBIWXMAAAsSAAALEgHS3X78AAABk0lEQVQ4jaWUP0gCcRTHv0+UUMOzLSiwP4M01dhQSENDizQEjYJDQ0s1uKY0BRE51G7gWFDRfhYVtLlVg9TVYlOnqGeYXrzj7jrzzht8cPC73/v9Pr/v+733fqSqKgY1r7FfongYwLb+CTxHvk4zsF6iYPK5DCDjX1JzdueZSiSKFwHM2i3yTlcxcvQAGm7d6LCC1e/RARknANtPKYTG+RQPYwBERaScItJEF0QPoa81ziat7gSAoiJSRoPodyG4QdS67/8U70lblQxknoh6JQOouEEo2OqZk9rjoLxUMJRk3SCBtVdzXOmEkKrsYqZ8x78xE8JpdDL2BRMvmve4lkT08x4nteSfSqNOFJHU+mlUy4JxiRwCK2DA7fc8Nr4O8d4e6w3VCrETwnGn5DSum8uOSl2zE6YqIt6PvmuskB27LAmeKg6EPTyNLmBx6NEW0tXFikhceFyFW06nXigrjU15vyV3BLNAbZ8CRaQ5Pe3cK1a75BbxL6lvlJf4MK3j+74nikirOowLkjd3dS/lpTCA7C/fXpOUGDhYFAAAAABJRU5ErkJggg==",t=({faviconPath:i="/favicon.ico"})=>A.jsx(e.Routes,{children:A.jsx(e.Route,{path:i,element:A.jsx("img",{src:o,alt:"code for Life favicon"})})});module.exports=t;
1
+ "use strict";const e=require("react/jsx-runtime");require("react");const t=require("react-router"),o=({children:r,catchAll:s})=>e.jsxs(t.Routes,{children:[r,s&&e.jsx(t.Route,{path:"*",element:e.jsx(e.Fragment,{children:"TODO: Replace with Not Found Error Page"})})]});module.exports=o;
2
2
  //# sourceMappingURL=DefaultRoutes.cjs.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"DefaultRoutes.cjs.js","sources":["../../src/images/favicon.ico","../../src/server/DefaultRoutes.tsx"],"sourcesContent":["export default \"data:image/x-icon;base64,iVBORw0KGgoAAAANSUhEUgAAABEAAAARCAYAAAA7bUf6AAAACXBIWXMAAAsSAAALEgHS3X78AAABk0lEQVQ4jaWUP0gCcRTHv0+UUMOzLSiwP4M01dhQSENDizQEjYJDQ0s1uKY0BRE51G7gWFDRfhYVtLlVg9TVYlOnqGeYXrzj7jrzzht8cPC73/v9Pr/v+733fqSqKgY1r7FfongYwLb+CTxHvk4zsF6iYPK5DCDjX1JzdueZSiSKFwHM2i3yTlcxcvQAGm7d6LCC1e/RARknANtPKYTG+RQPYwBERaScItJEF0QPoa81ziat7gSAoiJSRoPodyG4QdS67/8U70lblQxknoh6JQOouEEo2OqZk9rjoLxUMJRk3SCBtVdzXOmEkKrsYqZ8x78xE8JpdDL2BRMvmve4lkT08x4nteSfSqNOFJHU+mlUy4JxiRwCK2DA7fc8Nr4O8d4e6w3VCrETwnGn5DSum8uOSl2zE6YqIt6PvmuskB27LAmeKg6EPTyNLmBx6NEW0tXFikhceFyFW06nXigrjU15vyV3BLNAbZ8CRaQ5Pe3cK1a75BbxL6lvlJf4MK3j+74nikirOowLkjd3dS/lpTCA7C/fXpOUGDhYFAAAAABJRU5ErkJggg==\"","import { type FC, type ReactNode } from \"react\"\nimport { Route, Routes } from \"react-router\"\n\nimport FaviconImage from \"../images/favicon.ico\"\n\nexport interface DefaultRoutesProps {\n children: ReactNode\n faviconPath?: string\n}\n\nconst DefaultRoutes: FC<DefaultRoutesProps> = ({\n faviconPath = \"/favicon.ico\",\n}) => (\n <Routes>\n <Route\n path={faviconPath}\n element={<img src={FaviconImage} alt=\"code for Life favicon\" />}\n />\n </Routes>\n)\n\nexport default DefaultRoutes\n"],"names":["FaviconImage","DefaultRoutes","faviconPath","Routes","jsx","Route"],"mappings":"mGAAAA,EAAe,gqBCUTC,EAAwC,CAAC,CAC7C,YAAAC,EAAc,cAChB,UACGC,EAAAA,OAAA,CACC,SAAAC,EAAAA,IAACC,EAAAA,MAAA,CACC,KAAMH,EACN,QAASE,EAAAA,IAAC,MAAA,CAAI,IAAKJ,EAAc,IAAI,uBAAA,CAAwB,CAAA,CAC/D,CAAA,CACF"}
1
+ {"version":3,"file":"DefaultRoutes.cjs.js","sources":["../../src/server/DefaultRoutes.tsx"],"sourcesContent":["import { type FC, type ReactNode } from \"react\"\nimport { Route, Routes } from \"react-router\"\n\nexport interface DefaultRoutesProps {\n children: ReactNode\n catchAll: boolean\n}\n\nconst DefaultRoutes: FC<DefaultRoutesProps> = ({ children, catchAll }) => (\n <Routes>\n {children}\n {catchAll && (\n <Route path=\"*\" element={<>TODO: Replace with Not Found Error Page</>} />\n )}\n </Routes>\n)\n\nexport default DefaultRoutes\n"],"names":["DefaultRoutes","children","catchAll","Routes","Route","jsx","Fragment"],"mappings":"mGAQMA,EAAwC,CAAC,CAAE,SAAAC,EAAU,SAAAC,CAAA,WACxDC,EAAAA,OAAA,CACE,SAAA,CAAAF,EACAC,SACEE,QAAA,CAAM,KAAK,IAAI,QAASC,EAAAA,IAAAC,EAAAA,SAAA,CAAE,mDAAuC,CAAA,CAAK,CAAA,CAAA,CAE3E"}
@@ -1,16 +1,11 @@
1
- import { jsx as A } from "react/jsx-runtime";
1
+ import { jsxs as r, jsx as e, Fragment as a } from "react/jsx-runtime";
2
2
  import "react";
3
- import { Routes as i, Route as e } from "react-router";
4
- const t = "data:image/x-icon;base64,iVBORw0KGgoAAAANSUhEUgAAABEAAAARCAYAAAA7bUf6AAAACXBIWXMAAAsSAAALEgHS3X78AAABk0lEQVQ4jaWUP0gCcRTHv0+UUMOzLSiwP4M01dhQSENDizQEjYJDQ0s1uKY0BRE51G7gWFDRfhYVtLlVg9TVYlOnqGeYXrzj7jrzzht8cPC73/v9Pr/v+733fqSqKgY1r7FfongYwLb+CTxHvk4zsF6iYPK5DCDjX1JzdueZSiSKFwHM2i3yTlcxcvQAGm7d6LCC1e/RARknANtPKYTG+RQPYwBERaScItJEF0QPoa81ziat7gSAoiJSRoPodyG4QdS67/8U70lblQxknoh6JQOouEEo2OqZk9rjoLxUMJRk3SCBtVdzXOmEkKrsYqZ8x78xE8JpdDL2BRMvmve4lkT08x4nteSfSqNOFJHU+mlUy4JxiRwCK2DA7fc8Nr4O8d4e6w3VCrETwnGn5DSum8uOSl2zE6YqIt6PvmuskB27LAmeKg6EPTyNLmBx6NEW0tXFikhceFyFW06nXigrjU15vyV3BLNAbZ8CRaQ5Pe3cK1a75BbxL6lvlJf4MK3j+74nikirOowLkjd3dS/lpTCA7C/fXpOUGDhYFAAAAABJRU5ErkJggg==", E = ({
5
- faviconPath: o = "/favicon.ico"
6
- }) => /* @__PURE__ */ A(i, { children: /* @__PURE__ */ A(
7
- e,
8
- {
9
- path: o,
10
- element: /* @__PURE__ */ A("img", { src: t, alt: "code for Life favicon" })
11
- }
12
- ) });
3
+ import { Routes as m, Route as s } from "react-router";
4
+ const p = ({ children: t, catchAll: o }) => /* @__PURE__ */ r(m, { children: [
5
+ t,
6
+ o && /* @__PURE__ */ e(s, { path: "*", element: /* @__PURE__ */ e(a, { children: "TODO: Replace with Not Found Error Page" }) })
7
+ ] });
13
8
  export {
14
- E as default
9
+ p as default
15
10
  };
16
11
  //# sourceMappingURL=DefaultRoutes.es.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"DefaultRoutes.es.js","sources":["../../src/images/favicon.ico","../../src/server/DefaultRoutes.tsx"],"sourcesContent":["export default \"data:image/x-icon;base64,iVBORw0KGgoAAAANSUhEUgAAABEAAAARCAYAAAA7bUf6AAAACXBIWXMAAAsSAAALEgHS3X78AAABk0lEQVQ4jaWUP0gCcRTHv0+UUMOzLSiwP4M01dhQSENDizQEjYJDQ0s1uKY0BRE51G7gWFDRfhYVtLlVg9TVYlOnqGeYXrzj7jrzzht8cPC73/v9Pr/v+733fqSqKgY1r7FfongYwLb+CTxHvk4zsF6iYPK5DCDjX1JzdueZSiSKFwHM2i3yTlcxcvQAGm7d6LCC1e/RARknANtPKYTG+RQPYwBERaScItJEF0QPoa81ziat7gSAoiJSRoPodyG4QdS67/8U70lblQxknoh6JQOouEEo2OqZk9rjoLxUMJRk3SCBtVdzXOmEkKrsYqZ8x78xE8JpdDL2BRMvmve4lkT08x4nteSfSqNOFJHU+mlUy4JxiRwCK2DA7fc8Nr4O8d4e6w3VCrETwnGn5DSum8uOSl2zE6YqIt6PvmuskB27LAmeKg6EPTyNLmBx6NEW0tXFikhceFyFW06nXigrjU15vyV3BLNAbZ8CRaQ5Pe3cK1a75BbxL6lvlJf4MK3j+74nikirOowLkjd3dS/lpTCA7C/fXpOUGDhYFAAAAABJRU5ErkJggg==\"","import { type FC, type ReactNode } from \"react\"\nimport { Route, Routes } from \"react-router\"\n\nimport FaviconImage from \"../images/favicon.ico\"\n\nexport interface DefaultRoutesProps {\n children: ReactNode\n faviconPath?: string\n}\n\nconst DefaultRoutes: FC<DefaultRoutesProps> = ({\n faviconPath = \"/favicon.ico\",\n}) => (\n <Routes>\n <Route\n path={faviconPath}\n element={<img src={FaviconImage} alt=\"code for Life favicon\" />}\n />\n </Routes>\n)\n\nexport default DefaultRoutes\n"],"names":["FaviconImage","DefaultRoutes","faviconPath","Routes","jsx","Route"],"mappings":";;;AAAA,MAAAA,IAAe,iqBCUTC,IAAwC,CAAC;AAAA,EAC7C,aAAAC,IAAc;AAChB,wBACGC,GAAA,EACC,UAAA,gBAAAC;AAAA,EAACC;AAAA,EAAA;AAAA,IACC,MAAMH;AAAA,IACN,SAAS,gBAAAE,EAAC,OAAA,EAAI,KAAKJ,GAAc,KAAI,wBAAA,CAAwB;AAAA,EAAA;AAC/D,EAAA,CACF;"}
1
+ {"version":3,"file":"DefaultRoutes.es.js","sources":["../../src/server/DefaultRoutes.tsx"],"sourcesContent":["import { type FC, type ReactNode } from \"react\"\nimport { Route, Routes } from \"react-router\"\n\nexport interface DefaultRoutesProps {\n children: ReactNode\n catchAll: boolean\n}\n\nconst DefaultRoutes: FC<DefaultRoutesProps> = ({ children, catchAll }) => (\n <Routes>\n {children}\n {catchAll && (\n <Route path=\"*\" element={<>TODO: Replace with Not Found Error Page</>} />\n )}\n </Routes>\n)\n\nexport default DefaultRoutes\n"],"names":["DefaultRoutes","children","catchAll","Routes","Route","jsx","Fragment"],"mappings":";;;AAQA,MAAMA,IAAwC,CAAC,EAAE,UAAAC,GAAU,UAAAC,EAAA,wBACxDC,GAAA,EACE,UAAA;AAAA,EAAAF;AAAA,EACAC,uBACEE,GAAA,EAAM,MAAK,KAAI,SAAS,gBAAAC,EAAAC,GAAA,EAAE,qDAAuC,EAAA,CAAK;AAAA,EAAA,CAE3E;"}
@@ -1,2 +1,2 @@
1
- "use strict";var g=Object.create;var m=Object.defineProperty;var p=Object.getOwnPropertyDescriptor;var v=Object.getOwnPropertyNames;var w=Object.getPrototypeOf,k=Object.prototype.hasOwnProperty;var M=(e,t,r,c)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of v(t))!k.call(e,o)&&o!==r&&m(e,o,{get:()=>t[o],enumerable:!(c=p(t,o))||c.enumerable});return e};var s=(e,t,r)=>(r=e!=null?g(w(e)):{},M(t||!e||!e.__esModule?m(r,"default",{value:e,enumerable:!0}):r,e));Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const n=require("react/jsx-runtime"),h=require("react-router"),f=require("react"),T=require("@emotion/cache"),y=require("./DefaultRoutes.cjs.js");require("@mui/material");require("@emotion/react");require("react-redux");;/* empty css */const E="codeforlife",$={name:E};function j({key:e="css",prepend:t=!0,...r}={}){return T({key:e,prepend:t,...r})}async function b({App:e,routes:t,createEmotionCacheOptions:r={},...c}){const{default:o}=await import("@emotion/server/create-instance"),{renderToString:i}=await import("react-dom/server"),{default:a}=await import("node:fs/promises"),x=await a.readFile(`./node_modules/${$.name}/dist/style.css`,"utf-8");function C(S){const u=j(r),l=o(u),d=i(n.jsx(f.StrictMode,{children:n.jsx(e,{emotionCache:u,...c,children:n.jsx(h.StaticRouter,{location:S,children:n.jsx(y,{children:t})})})})),q=l.extractCriticalToChunks(d),R=l.constructStyleTagsFromChunks(q);return{html:d,head:`${R}<style data-cfl>${x}</style>`}}return{render:C}}async function B({App:e,routes:t,createEmotionCacheOptions:r={},...c}){const o=await import("react-dom/client"),{hydrateRoot:i}=o.default||o,a=j(r);i(document.getElementById("root"),n.jsx(f.StrictMode,{children:n.jsx(e,{emotionCache:a,...c,children:n.jsx(h.BrowserRouter,{children:n.jsx(y,{children:t})})})}))}exports.client=B;exports.server=b;
1
+ "use strict";var v=Object.create;var h=Object.defineProperty;var w=Object.getOwnPropertyDescriptor;var T=Object.getOwnPropertyNames;var A=Object.getPrototypeOf,k=Object.prototype.hasOwnProperty;var E=(e,t,r,c)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of T(t))!k.call(e,o)&&o!==r&&h(e,o,{get:()=>t[o],enumerable:!(c=w(t,o))||c.enumerable});return e};var i=(e,t,r)=>(r=e!=null?v(A(e)):{},E(t||!e||!e.__esModule?h(r,"default",{value:e,enumerable:!0}):r,e));Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const n=require("react/jsx-runtime"),f=require("react-router"),C=require("react"),M=require("@emotion/cache"),y=require("./DefaultRoutes.cjs.js");require("@mui/material");require("@emotion/react");require("react-redux");;/* empty css */const _="codeforlife",D={name:_};function j({key:e="css",prepend:t=!0,...r}={}){return M({key:e,prepend:t,...r})}const x=!0;async function F({App:e,routes:t,catchAllRoute:r=x,createEmotionCacheOptions:c,...o}){const{default:s}=await import("@emotion/server/create-instance"),{renderToString:a}=await import("react-dom/server"),{default:u}=await import("node:fs/promises"),S=await u.readFile(`./node_modules/${D.name}/dist/style.css`,"utf-8");function q(R){const l=j(c),d=s(l),m=a(n.jsx(C.StrictMode,{children:n.jsx(e,{emotionCache:l,...o,children:n.jsx(f.StaticRouter,{location:R,children:n.jsx(y,{catchAll:r,children:t})})})})),g=d.extractCriticalToChunks(m),p=d.constructStyleTagsFromChunks(g);return{html:m,head:`${p}<style data-cfl>${S}</style>`}}return{render:q}}async function L({App:e,routes:t,catchAllRoute:r=x,createEmotionCacheOptions:c,...o}){const s=await import("react-dom/client"),{hydrateRoot:a}=s.default||s,u=j(c);a(document.getElementById("root"),n.jsx(C.StrictMode,{children:n.jsx(e,{emotionCache:u,...o,children:n.jsx(f.BrowserRouter,{children:n.jsx(y,{catchAll:r,children:t})})})}))}exports.client=L;exports.server=F;
2
2
  //# sourceMappingURL=entry.cjs.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"entry.cjs.js","sources":["../../src/server/entry.tsx"],"sourcesContent":["/**\n * © Ocado Group\n * Created on 20/10/2025 at 17:45:17(+01:00).\n *\n * The client and server entrypoints when doing server-side rendering.\n *\n * Helpful links:\n * https://mui.com/material-ui/guides/server-rendering/\n * https://github.com/remix-run/react-router/tree/main/examples/ssr\n */\n\nimport { BrowserRouter, StaticRouter } from \"react-router\"\nimport { type FC, StrictMode } from \"react\"\nimport createCache, {\n type Options as CreateEmotionCacheOptions,\n} from \"@emotion/cache\"\n\nimport DefaultRoutes, { type DefaultRoutesProps } from \"./DefaultRoutes\"\nimport { type AppProps } from \"./App\"\nimport packageJson from \"../../package.json\"\n\n/**\n * Creates a new Emotion cache instance.\n */\nfunction createEmotionCache(\n {\n key = \"css\", // ensures all styles are generated with this prefix\n prepend = true, // loads MUI-styles first so we can override them easily\n ...otherOptions\n } = {} as CreateEmotionCacheOptions,\n) {\n return createCache({ key, prepend, ...otherOptions })\n}\n\nexport type EntryAppProps = Pick<AppProps, \"emotionCache\" | \"children\">\n\nexport type EntryKwArgs = {\n App: FC<EntryAppProps>\n routes: DefaultRoutesProps[\"children\"]\n createEmotionCacheOptions?: CreateEmotionCacheOptions\n}\n\nexport async function server({\n App,\n routes,\n createEmotionCacheOptions = {} as CreateEmotionCacheOptions,\n ...appProps\n}: EntryKwArgs) {\n const { default: createEmotionServer } = await import(\n \"@emotion/server/create-instance\"\n )\n const { renderToString } = await import(\"react-dom/server\")\n const { default: fs } = await import(\"node:fs/promises\")\n\n const cflStyle = await fs.readFile(\n `./node_modules/${packageJson.name}/dist/style.css`,\n \"utf-8\",\n )\n\n function render(path: string) {\n const emotionCache = createEmotionCache(createEmotionCacheOptions)\n const emotionServer = createEmotionServer(emotionCache)\n\n const html = renderToString(\n <StrictMode>\n <App emotionCache={emotionCache} {...appProps}>\n <StaticRouter location={path}>\n <DefaultRoutes>{routes}</DefaultRoutes>\n </StaticRouter>\n </App>\n </StrictMode>,\n )\n\n const emotionChunks = emotionServer.extractCriticalToChunks(html)\n const emotionCss = emotionServer.constructStyleTagsFromChunks(emotionChunks)\n\n return {\n html,\n head: `${emotionCss}<style data-cfl>${cflStyle}</style>`,\n }\n }\n\n return { render }\n}\n\nexport async function client({\n App,\n routes,\n createEmotionCacheOptions = {} as CreateEmotionCacheOptions,\n ...appProps\n}: EntryKwArgs) {\n const reactDomClientModule = await import(\"react-dom/client\")\n\n // Check for the .default property to handle CJS/ESM interop.\n // 'hydrateRoot' will be on the module itself OR on the .default object.\n const { hydrateRoot } = reactDomClientModule.default || reactDomClientModule\n\n const emotionCache = createEmotionCache(createEmotionCacheOptions)\n\n hydrateRoot(\n document.getElementById(\"root\") as HTMLElement,\n <StrictMode>\n <App emotionCache={emotionCache} {...appProps}>\n <BrowserRouter>\n <DefaultRoutes>{routes}</DefaultRoutes>\n </BrowserRouter>\n </App>\n </StrictMode>,\n )\n}\n"],"names":["createEmotionCache","key","prepend","otherOptions","createCache","server","App","routes","createEmotionCacheOptions","appProps","createEmotionServer","renderToString","fs","cflStyle","packageJson","render","path","emotionCache","emotionServer","html","StrictMode","jsx","StaticRouter","DefaultRoutes","emotionChunks","emotionCss","client","reactDomClientModule","hydrateRoot","BrowserRouter"],"mappings":"uzBAwBA,SAASA,EACP,CACE,IAAAC,EAAM,MACN,QAAAC,EAAU,GACV,GAAGC,CACL,EAAI,GACJ,CACA,OAAOC,EAAY,CAAE,IAAAH,EAAK,QAAAC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AAAR,EAAAA,IAACE,EAAA,CAAe,SAAAhB,CAAA,CAAO,EACzB,EACF,CAAA,CACF,CAAA,CAEJ"}
1
+ {"version":3,"file":"entry.cjs.js","sources":["../../src/server/entry.tsx"],"sourcesContent":["/**\n * © Ocado Group\n * Created on 20/10/2025 at 17:45:17(+01:00).\n *\n * The client and server entrypoints when doing server-side rendering.\n *\n * Helpful links:\n * https://mui.com/material-ui/guides/server-rendering/\n * https://github.com/remix-run/react-router/tree/main/examples/ssr\n */\n\nimport { BrowserRouter, StaticRouter } from \"react-router\"\nimport { type FC, StrictMode } from \"react\"\nimport createCache, {\n type Options as CreateEmotionCacheOptions,\n} from \"@emotion/cache\"\n\nimport DefaultRoutes, { type DefaultRoutesProps } from \"./DefaultRoutes\"\nimport { type AppProps } from \"./App\"\nimport packageJson from \"../../package.json\"\n\n/**\n * Creates a new Emotion cache instance.\n */\nfunction createEmotionCache(\n {\n key = \"css\", // ensures all styles are generated with this prefix\n prepend = true, // loads MUI-styles first so we can override them easily\n ...otherOptions\n } = {} as CreateEmotionCacheOptions,\n) {\n return createCache({ key, prepend, ...otherOptions })\n}\n\nexport type EntryAppProps = Pick<AppProps, \"emotionCache\" | \"children\">\n\nexport type EntryKwArgs = {\n App: FC<EntryAppProps>\n routes: DefaultRoutesProps[\"children\"]\n catchAllRoute?: DefaultRoutesProps[\"catchAll\"]\n createEmotionCacheOptions?: CreateEmotionCacheOptions\n}\n\nconst DEFAULT_CATCH_ALL: DefaultRoutesProps[\"catchAll\"] = true\n\nexport async function server({\n App,\n routes,\n catchAllRoute = DEFAULT_CATCH_ALL,\n createEmotionCacheOptions,\n ...appProps\n}: EntryKwArgs) {\n const { default: createEmotionServer } = await import(\n \"@emotion/server/create-instance\"\n )\n const { renderToString } = await import(\"react-dom/server\")\n const { default: fs } = await import(\"node:fs/promises\")\n\n const cflStyle = await fs.readFile(\n `./node_modules/${packageJson.name}/dist/style.css`,\n \"utf-8\",\n )\n\n function render(path: string) {\n const emotionCache = createEmotionCache(createEmotionCacheOptions)\n const emotionServer = createEmotionServer(emotionCache)\n\n const html = renderToString(\n <StrictMode>\n <App emotionCache={emotionCache} {...appProps}>\n <StaticRouter location={path}>\n <DefaultRoutes catchAll={catchAllRoute}>{routes}</DefaultRoutes>\n </StaticRouter>\n </App>\n </StrictMode>,\n )\n\n const emotionChunks = emotionServer.extractCriticalToChunks(html)\n const emotionCss = emotionServer.constructStyleTagsFromChunks(emotionChunks)\n\n return {\n html,\n head: `${emotionCss}<style data-cfl>${cflStyle}</style>`,\n }\n }\n\n return { render }\n}\n\nexport async function client({\n App,\n routes,\n catchAllRoute = DEFAULT_CATCH_ALL,\n createEmotionCacheOptions,\n ...appProps\n}: EntryKwArgs) {\n const reactDomClientModule = await import(\"react-dom/client\")\n\n // Check for the .default property to handle CJS/ESM interop.\n // 'hydrateRoot' will be on the module itself OR on the .default object.\n const { hydrateRoot } = reactDomClientModule.default || reactDomClientModule\n\n const emotionCache = createEmotionCache(createEmotionCacheOptions)\n\n hydrateRoot(\n document.getElementById(\"root\") as HTMLElement,\n <StrictMode>\n <App emotionCache={emotionCache} {...appProps}>\n <BrowserRouter>\n <DefaultRoutes catchAll={catchAllRoute}>{routes}</DefaultRoutes>\n </BrowserRouter>\n </App>\n </StrictMode>,\n )\n}\n"],"names":["createEmotionCache","key","prepend","otherOptions","createCache","DEFAULT_CATCH_ALL","server","App","routes","catchAllRoute","createEmotionCacheOptions","appProps","createEmotionServer","renderToString","fs","cflStyle","packageJson","render","path","emotionCache","emotionServer","html","StrictMode","jsx","StaticRouter","DefaultRoutes","emotionChunks","emotionCss","client","reactDomClientModule","hydrateRoot","BrowserRouter"],"mappings":"uzBAwBA,SAASA,EACP,CACE,IAAAC,EAAM,MACN,QAAAC,EAAU,GACV,GAAGC,CACL,EAAI,GACJ,CACA,OAAOC,EAAY,CAAE,IAAAH,EAAK,QAAAC,EAAS,GAAGC,EAAc,CACtD,CAWA,MAAME,EAAoD,GAE1D,eAAsBC,EAAO,CAC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AAAD,CAAA,CAAO,EAClD,EACF,CAAA,CACF,CAAA,CAEJ"}
@@ -1,14 +1,14 @@
1
1
  import { jsx as t } from "react/jsx-runtime";
2
- import { BrowserRouter as w, StaticRouter as g } from "react-router";
3
- import { StrictMode as d } from "react";
2
+ import { BrowserRouter as T, StaticRouter as g } from "react-router";
3
+ import { StrictMode as u } from "react";
4
4
  import k from "@emotion/cache";
5
- import u from "./DefaultRoutes.es.js";
5
+ import h from "./DefaultRoutes.es.js";
6
6
  import "@mui/material";
7
7
  import "@emotion/react";
8
8
  import "react-redux";
9
9
  /* empty css */
10
- const R = "codeforlife", v = {
11
- name: R
10
+ const E = "codeforlife", R = {
11
+ name: E
12
12
  };
13
13
  function f({
14
14
  key: o = "css",
@@ -19,41 +19,44 @@ function f({
19
19
  } = {}) {
20
20
  return k({ key: o, prepend: e, ...r });
21
21
  }
22
- async function I({
22
+ const p = !0;
23
+ async function j({
23
24
  App: o,
24
25
  routes: e,
25
- createEmotionCacheOptions: r = {},
26
- ...c
26
+ catchAllRoute: r = p,
27
+ createEmotionCacheOptions: c,
28
+ ...i
27
29
  }) {
28
- const { default: n } = await import("@emotion/server/create-instance"), { renderToString: i } = await import("react-dom/server"), { default: a } = await import("node:fs/promises"), h = await a.readFile(
29
- `./node_modules/${v.name}/dist/style.css`,
30
+ const { default: n } = await import("@emotion/server/create-instance"), { renderToString: a } = await import("react-dom/server"), { default: s } = await import("node:fs/promises"), C = await s.readFile(
31
+ `./node_modules/${R.name}/dist/style.css`,
30
32
  "utf-8"
31
33
  );
32
- function p(C) {
33
- const s = f(r), m = n(s), l = i(
34
- /* @__PURE__ */ t(d, { children: /* @__PURE__ */ t(o, { emotionCache: s, ...c, children: /* @__PURE__ */ t(g, { location: C, children: /* @__PURE__ */ t(u, { children: e }) }) }) })
35
- ), y = m.extractCriticalToChunks(l), S = m.constructStyleTagsFromChunks(y);
34
+ function y(S) {
35
+ const l = f(c), m = n(l), d = a(
36
+ /* @__PURE__ */ t(u, { children: /* @__PURE__ */ t(o, { emotionCache: l, ...i, children: /* @__PURE__ */ t(g, { location: S, children: /* @__PURE__ */ t(h, { catchAll: r, children: e }) }) }) })
37
+ ), w = m.extractCriticalToChunks(d), A = m.constructStyleTagsFromChunks(w);
36
38
  return {
37
- html: l,
38
- head: `${S}<style data-cfl>${h}</style>`
39
+ html: d,
40
+ head: `${A}<style data-cfl>${C}</style>`
39
41
  };
40
42
  }
41
- return { render: p };
43
+ return { render: y };
42
44
  }
43
- async function J({
45
+ async function H({
44
46
  App: o,
45
47
  routes: e,
46
- createEmotionCacheOptions: r = {},
47
- ...c
48
+ catchAllRoute: r = p,
49
+ createEmotionCacheOptions: c,
50
+ ...i
48
51
  }) {
49
- const n = await import("react-dom/client"), { hydrateRoot: i } = n.default || n, a = f(r);
50
- i(
52
+ const n = await import("react-dom/client"), { hydrateRoot: a } = n.default || n, s = f(c);
53
+ a(
51
54
  document.getElementById("root"),
52
- /* @__PURE__ */ t(d, { children: /* @__PURE__ */ t(o, { emotionCache: a, ...c, children: /* @__PURE__ */ t(w, { children: /* @__PURE__ */ t(u, { children: e }) }) }) })
55
+ /* @__PURE__ */ t(u, { children: /* @__PURE__ */ t(o, { emotionCache: s, ...i, children: /* @__PURE__ */ t(T, { children: /* @__PURE__ */ t(h, { catchAll: r, children: e }) }) }) })
53
56
  );
54
57
  }
55
58
  export {
56
- J as client,
57
- I as server
59
+ H as client,
60
+ j as server
58
61
  };
59
62
  //# sourceMappingURL=entry.es.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"entry.es.js","sources":["../../src/server/entry.tsx"],"sourcesContent":["/**\n * © Ocado Group\n * Created on 20/10/2025 at 17:45:17(+01:00).\n *\n * The client and server entrypoints when doing server-side rendering.\n *\n * Helpful links:\n * https://mui.com/material-ui/guides/server-rendering/\n * https://github.com/remix-run/react-router/tree/main/examples/ssr\n */\n\nimport { BrowserRouter, StaticRouter } from \"react-router\"\nimport { type FC, StrictMode } from \"react\"\nimport createCache, {\n type Options as CreateEmotionCacheOptions,\n} from \"@emotion/cache\"\n\nimport DefaultRoutes, { type DefaultRoutesProps } from \"./DefaultRoutes\"\nimport { type AppProps } from \"./App\"\nimport packageJson from \"../../package.json\"\n\n/**\n * Creates a new Emotion cache instance.\n */\nfunction createEmotionCache(\n {\n key = \"css\", // ensures all styles are generated with this prefix\n prepend = true, // loads MUI-styles first so we can override them easily\n ...otherOptions\n } = {} as CreateEmotionCacheOptions,\n) {\n return createCache({ key, prepend, ...otherOptions })\n}\n\nexport type EntryAppProps = Pick<AppProps, \"emotionCache\" | \"children\">\n\nexport type EntryKwArgs = {\n App: FC<EntryAppProps>\n routes: DefaultRoutesProps[\"children\"]\n createEmotionCacheOptions?: CreateEmotionCacheOptions\n}\n\nexport async function server({\n App,\n routes,\n createEmotionCacheOptions = {} as CreateEmotionCacheOptions,\n ...appProps\n}: EntryKwArgs) {\n const { default: createEmotionServer } = await import(\n \"@emotion/server/create-instance\"\n )\n const { renderToString } = await import(\"react-dom/server\")\n const { default: fs } = await import(\"node:fs/promises\")\n\n const cflStyle = await fs.readFile(\n `./node_modules/${packageJson.name}/dist/style.css`,\n \"utf-8\",\n )\n\n function render(path: string) {\n const emotionCache = createEmotionCache(createEmotionCacheOptions)\n const emotionServer = createEmotionServer(emotionCache)\n\n const html = renderToString(\n <StrictMode>\n <App emotionCache={emotionCache} {...appProps}>\n <StaticRouter location={path}>\n <DefaultRoutes>{routes}</DefaultRoutes>\n </StaticRouter>\n </App>\n </StrictMode>,\n )\n\n const emotionChunks = emotionServer.extractCriticalToChunks(html)\n const emotionCss = emotionServer.constructStyleTagsFromChunks(emotionChunks)\n\n return {\n html,\n head: `${emotionCss}<style data-cfl>${cflStyle}</style>`,\n }\n }\n\n return { render }\n}\n\nexport async function client({\n App,\n routes,\n createEmotionCacheOptions = {} as CreateEmotionCacheOptions,\n ...appProps\n}: EntryKwArgs) {\n const reactDomClientModule = await import(\"react-dom/client\")\n\n // Check for the .default property to handle CJS/ESM interop.\n // 'hydrateRoot' will be on the module itself OR on the .default object.\n const { hydrateRoot } = reactDomClientModule.default || reactDomClientModule\n\n const emotionCache = createEmotionCache(createEmotionCacheOptions)\n\n hydrateRoot(\n document.getElementById(\"root\") as HTMLElement,\n <StrictMode>\n <App emotionCache={emotionCache} {...appProps}>\n <BrowserRouter>\n <DefaultRoutes>{routes}</DefaultRoutes>\n </BrowserRouter>\n </App>\n </StrictMode>,\n )\n}\n"],"names":["createEmotionCache","key","prepend","otherOptions","createCache","server","App","routes","createEmotionCacheOptions","appProps","createEmotionServer","renderToString","fs","cflStyle","packageJson","render","path","emotionCache","emotionServer","html","StrictMode","jsx","StaticRouter","DefaultRoutes","emotionChunks","emotionCss","client","reactDomClientModule","hydrateRoot","BrowserRouter"],"mappings":";;;;;;;;;;;;AAwBA,SAASA,EACP;AAAA,EACE,KAAAC,IAAM;AAAA;AAAA,EACN,SAAAC,IAAU;AAAA;AAAA,EACV,GAAGC;AACL,IAAI,IACJ;AACA,SAAOC,EAAY,EAAE,KAAAH,GAAK,SAAAC,GAAS,GAAGC,GAAc;AACtD;AAUA,eAAsBE,EAAO;AAAA,EAC3B,KAAAC;AAAA,EACA,QAAAC;AAAA,EACA,2BAAAC,IAA4B,CAAA;AAAA,EAC5B,GAAGC;AACL,GAAgB;AACd,QAAM,EAAE,SAASC,MAAwB,MAAM,OAC7C,iCACF,GACM,EAAE,gBAAAC,EAAA,IAAmB,MAAM,OAAO,kBAAkB,GACpD,EAAE,SAASC,MAAO,MAAM,OAAO,kBAAkB,GAEjDC,IAAW,MAAMD,EAAG;AAAA,IACxB,kBAAkBE,EAAY,IAAI;AAAA,IAClC;AAAA,EAAA;AAGF,WAASC,EAAOC,GAAc;AAC5B,UAAMC,IAAejB,EAAmBQ,CAAyB,GAC3DU,IAAgBR,EAAoBO,CAAY,GAEhDE,IAAOR;AAAA,wBACVS,GAAA,EACC,UAAA,gBAAAC,EAACf,GAAA,EAAI,cAAAW,GAA6B,GAAGR,GACnC,UAAA,gBAAAY,EAACC,GAAA,EAAa,UAAUN,GACtB,UAAA,gBAAAK,EAACE,GAAA,EAAe,UAAAhB,EAAA,CAAO,GACzB,GACF,EAAA,CACF;AAAA,IAAA,GAGIiB,IAAgBN,EAAc,wBAAwBC,CAAI,GAC1DM,IAAaP,EAAc,6BAA6BM,CAAa;AAE3E,WAAO;AAAA,MACL,MAAAL;AAAA,MACA,MAAM,GAAGM,CAAU,mBAAmBZ,CAAQ;AAAA,IAAA;AAAA,EAElD;AAEA,SAAO,EAAE,QAAAE,EAAA;AACX;AAEA,eAAsBW,EAAO;AAAA,EAC3B,KAAApB;AAAA,EACA,QAAAC;AAAA,EACA,2BAAAC,IAA4B,CAAA;AAAA,EAC5B,GAAGC;AACL,GAAgB;AACd,QAAMkB,IAAuB,MAAM,OAAO,kBAAkB,GAItD,EAAE,aAAAC,EAAA,IAAgBD,EAAqB,WAAWA,GAElDV,IAAejB,EAAmBQ,CAAyB;AAEjE,EAAAoB;AAAA,IACE,SAAS,eAAe,MAAM;AAAA,IAC9B,gBAAAP,EAACD,GAAA,EACC,UAAA,gBAAAC,EAACf,GAAA,EAAI,cAAAW,GAA6B,GAAGR,GACnC,UAAA,gBAAAY,EAACQ,GAAA,EACC,UAAA,gBAAAR,EAACE,GAAA,EAAe,UAAAhB,EAAA,CAAO,GACzB,GACF,EAAA,CACF;AAAA,EAAA;AAEJ;"}
1
+ {"version":3,"file":"entry.es.js","sources":["../../src/server/entry.tsx"],"sourcesContent":["/**\n * © Ocado Group\n * Created on 20/10/2025 at 17:45:17(+01:00).\n *\n * The client and server entrypoints when doing server-side rendering.\n *\n * Helpful links:\n * https://mui.com/material-ui/guides/server-rendering/\n * https://github.com/remix-run/react-router/tree/main/examples/ssr\n */\n\nimport { BrowserRouter, StaticRouter } from \"react-router\"\nimport { type FC, StrictMode } from \"react\"\nimport createCache, {\n type Options as CreateEmotionCacheOptions,\n} from \"@emotion/cache\"\n\nimport DefaultRoutes, { type DefaultRoutesProps } from \"./DefaultRoutes\"\nimport { type AppProps } from \"./App\"\nimport packageJson from \"../../package.json\"\n\n/**\n * Creates a new Emotion cache instance.\n */\nfunction createEmotionCache(\n {\n key = \"css\", // ensures all styles are generated with this prefix\n prepend = true, // loads MUI-styles first so we can override them easily\n ...otherOptions\n } = {} as CreateEmotionCacheOptions,\n) {\n return createCache({ key, prepend, ...otherOptions })\n}\n\nexport type EntryAppProps = Pick<AppProps, \"emotionCache\" | \"children\">\n\nexport type EntryKwArgs = {\n App: FC<EntryAppProps>\n routes: DefaultRoutesProps[\"children\"]\n catchAllRoute?: DefaultRoutesProps[\"catchAll\"]\n createEmotionCacheOptions?: CreateEmotionCacheOptions\n}\n\nconst DEFAULT_CATCH_ALL: DefaultRoutesProps[\"catchAll\"] = true\n\nexport async function server({\n App,\n routes,\n catchAllRoute = DEFAULT_CATCH_ALL,\n createEmotionCacheOptions,\n ...appProps\n}: EntryKwArgs) {\n const { default: createEmotionServer } = await import(\n \"@emotion/server/create-instance\"\n )\n const { renderToString } = await import(\"react-dom/server\")\n const { default: fs } = await import(\"node:fs/promises\")\n\n const cflStyle = await fs.readFile(\n `./node_modules/${packageJson.name}/dist/style.css`,\n \"utf-8\",\n )\n\n function render(path: string) {\n const emotionCache = createEmotionCache(createEmotionCacheOptions)\n const emotionServer = createEmotionServer(emotionCache)\n\n const html = renderToString(\n <StrictMode>\n <App emotionCache={emotionCache} {...appProps}>\n <StaticRouter location={path}>\n <DefaultRoutes catchAll={catchAllRoute}>{routes}</DefaultRoutes>\n </StaticRouter>\n </App>\n </StrictMode>,\n )\n\n const emotionChunks = emotionServer.extractCriticalToChunks(html)\n const emotionCss = emotionServer.constructStyleTagsFromChunks(emotionChunks)\n\n return {\n html,\n head: `${emotionCss}<style data-cfl>${cflStyle}</style>`,\n }\n }\n\n return { render }\n}\n\nexport async function client({\n App,\n routes,\n catchAllRoute = DEFAULT_CATCH_ALL,\n createEmotionCacheOptions,\n ...appProps\n}: EntryKwArgs) {\n const reactDomClientModule = await import(\"react-dom/client\")\n\n // Check for the .default property to handle CJS/ESM interop.\n // 'hydrateRoot' will be on the module itself OR on the .default object.\n const { hydrateRoot } = reactDomClientModule.default || reactDomClientModule\n\n const emotionCache = createEmotionCache(createEmotionCacheOptions)\n\n hydrateRoot(\n document.getElementById(\"root\") as HTMLElement,\n <StrictMode>\n <App emotionCache={emotionCache} {...appProps}>\n <BrowserRouter>\n <DefaultRoutes catchAll={catchAllRoute}>{routes}</DefaultRoutes>\n </BrowserRouter>\n </App>\n </StrictMode>,\n )\n}\n"],"names":["createEmotionCache","key","prepend","otherOptions","createCache","DEFAULT_CATCH_ALL","server","App","routes","catchAllRoute","createEmotionCacheOptions","appProps","createEmotionServer","renderToString","fs","cflStyle","packageJson","render","path","emotionCache","emotionServer","html","StrictMode","jsx","StaticRouter","DefaultRoutes","emotionChunks","emotionCss","client","reactDomClientModule","hydrateRoot","BrowserRouter"],"mappings":";;;;;;;;;;;;AAwBA,SAASA,EACP;AAAA,EACE,KAAAC,IAAM;AAAA;AAAA,EACN,SAAAC,IAAU;AAAA;AAAA,EACV,GAAGC;AACL,IAAI,IACJ;AACA,SAAOC,EAAY,EAAE,KAAAH,GAAK,SAAAC,GAAS,GAAGC,GAAc;AACtD;AAWA,MAAME,IAAoD;AAE1D,eAAsBC,EAAO;AAAA,EAC3B,KAAAC;AAAA,EACA,QAAAC;AAAA,EACA,eAAAC,IAAgBJ;AAAA,EAChB,2BAAAK;AAAA,EACA,GAAGC;AACL,GAAgB;AACd,QAAM,EAAE,SAASC,MAAwB,MAAM,OAC7C,iCACF,GACM,EAAE,gBAAAC,EAAA,IAAmB,MAAM,OAAO,kBAAkB,GACpD,EAAE,SAASC,MAAO,MAAM,OAAO,kBAAkB,GAEjDC,IAAW,MAAMD,EAAG;AAAA,IACxB,kBAAkBE,EAAY,IAAI;AAAA,IAClC;AAAA,EAAA;AAGF,WAASC,EAAOC,GAAc;AAC5B,UAAMC,IAAenB,EAAmBU,CAAyB,GAC3DU,IAAgBR,EAAoBO,CAAY,GAEhDE,IAAOR;AAAA,wBACVS,GAAA,EACC,UAAA,gBAAAC,EAAChB,KAAI,cAAAY,GAA6B,GAAGR,GACnC,UAAA,gBAAAY,EAACC,GAAA,EAAa,UAAUN,GACtB,4BAACO,GAAA,EAAc,UAAUhB,GAAgB,UAAAD,EAAA,CAAO,EAAA,CAClD,GACF,EAAA,CACF;AAAA,IAAA,GAGIkB,IAAgBN,EAAc,wBAAwBC,CAAI,GAC1DM,IAAaP,EAAc,6BAA6BM,CAAa;AAE3E,WAAO;AAAA,MACL,MAAAL;AAAA,MACA,MAAM,GAAGM,CAAU,mBAAmBZ,CAAQ;AAAA,IAAA;AAAA,EAElD;AAEA,SAAO,EAAE,QAAAE,EAAA;AACX;AAEA,eAAsBW,EAAO;AAAA,EAC3B,KAAArB;AAAA,EACA,QAAAC;AAAA,EACA,eAAAC,IAAgBJ;AAAA,EAChB,2BAAAK;AAAA,EACA,GAAGC;AACL,GAAgB;AACd,QAAMkB,IAAuB,MAAM,OAAO,kBAAkB,GAItD,EAAE,aAAAC,EAAA,IAAgBD,EAAqB,WAAWA,GAElDV,IAAenB,EAAmBU,CAAyB;AAEjE,EAAAoB;AAAA,IACE,SAAS,eAAe,MAAM;AAAA,sBAC7BR,GAAA,EACC,UAAA,gBAAAC,EAAChB,GAAA,EAAI,cAAAY,GAA6B,GAAGR,GACnC,UAAA,gBAAAY,EAACQ,GAAA,EACC,UAAA,gBAAAR,EAACE,KAAc,UAAUhB,GAAgB,UAAAD,EAAA,CAAO,GAClD,GACF,EAAA,CACF;AAAA,EAAA;AAEJ;"}
@@ -1,4 +1,4 @@
1
- "use strict";var u=Object.create;var c=Object.defineProperty;var m=Object.getOwnPropertyDescriptor;var v=Object.getOwnPropertyNames;var C=Object.getPrototypeOf,k=Object.prototype.hasOwnProperty;var w=(r,s,e,t)=>{if(s&&typeof s=="object"||typeof s=="function")for(let a of v(s))!k.call(r,a)&&a!==e&&c(r,a,{get:()=>s[a],enumerable:!(t=m(s,a))||t.enumerable});return r};var o=(r,s,e)=>(e=r!=null?u(C(r)):{},w(s||!r||!r.__esModule?c(e,"default",{value:r,enumerable:!0}):e,r));const y=require("memory-cache"),S=require("node:crypto"),f=require("express"),l=require("node:fs/promises"),I=require("node:http");class P{envIsProduction;templateHtml;hostname;mode;port;base;app;server;cache;healthCheckCacheKey;healthCheckCacheTimeout;healthCheckStatusCodes;devtoolsWorkspaceUUID;constructor({mode:s,port:e,base:t}={}){this.envIsProduction=process.env.NODE_ENV==="production",this.templateHtml="",this.hostname=this.envIsProduction?"0.0.0.0":"127.0.0.1",this.mode=s||process.env.MODE||"development",this.port=e||(process.env.PORT?Number(process.env.PORT):this.envIsProduction?8080:5173),this.base=t||process.env.BASE||"",this.app=f(),this.server=I.createServer(this.app),this.cache=new y.Cache,this.healthCheckCacheKey="health-check",this.healthCheckCacheTimeout=3e4,this.healthCheckStatusCodes={healthy:200,startingUp:503,shuttingDown:503,unhealthy:503,unknown:503},this.devtoolsWorkspaceUUID=S.randomUUID()}getHealthCheck(s){return{healthStatus:"healthy",additionalInfo:"All healthy."}}handleHealthCheck(s,e){let t=this.cache.get(this.healthCheckCacheKey);if(t===null){const a=this.getHealthCheck(s);a.healthStatus!=="healthy"&&console.warn(`health check: ${JSON.stringify(a)}`),t={appId:process.env.APP_ID||"REPLACE_ME",healthStatus:a.healthStatus,lastCheckedTimestamp:new Date().toISOString(),additionalInformation:a.additionalInfo,startupTimestamp:new Date().toISOString(),appVersion:process.env.APP_VERSION||"REPLACE_ME",details:a.details||[]},this.cache.put(this.healthCheckCacheKey,t,this.healthCheckCacheTimeout)}e.status(this.healthCheckStatusCodes[t.healthStatus]).json(t)}async handleServeHtml(s,e,{getRenderAndTemplate:t,onServeError:a}){try{const h=s.originalUrl.replace(this.base,""),[n,p]=await t(h),i=await n(h),d=p.replace("<!--app-head-->",i.head??"").replace("<!--app-html-->",i.html??"");e.status(200).set({"Content-Type":"text/html"}).send(d)}catch(h){if(h instanceof Error){console.error(h.stack);const n=a(h);e.status(500).end(n)}}}handleChromeDevTools(s,e){if(this.envIsProduction)e.status(404).json({});else{const t=process.env.LOCAL_WORKSPACE_PATH;let a,h;t?(a=200,h={workspace:{uuid:this.devtoolsWorkspaceUUID,root:t}}):(a=404,h={error:"Local workspace path not configured."}),e.status(a).json(h)}}async setUpProduction(){const s=(await import("compression")).default,e=(await import("sirv")).default;return this.templateHtml=await l.readFile("./dist/client/index.html","utf-8"),this.app.use(s()),this.app.use(this.base,e("./dist/client",{extensions:[]})),{getRenderAndTemplate:async()=>{const t=(await import("../../../dist/server/entry-server.js")).render,a=this.templateHtml;return[t,a]},onServeError:()=>{}}}async setUpDevelopment(){const{createServer:s}=await import("vite"),e=await s({configFile:"/workspace/frontend/vite.config.ts",server:{middlewareMode:!0,hmr:{server:this.server}},appType:"custom",base:this.base,mode:this.mode});return this.app.use(e.middlewares),{getRenderAndTemplate:async t=>{const a=(await e.ssrLoadModule("/src/entry-server.tsx")).render;let h=await l.readFile("./index.html","utf-8");return h=await e.transformIndexHtml(t,h),[a,h]},onServeError:t=>(e.ssrFixStacktrace(t),t.stack)}}async run(){const s=this.envIsProduction?await this.setUpProduction():await this.setUpDevelopment();this.app.get("/health-check",(e,t)=>{this.handleHealthCheck(e,t)}),this.app.get("/.well-known/appspecific/com.chrome.devtools.json",(e,t)=>{this.handleChromeDevTools(e,t)}),this.app.get("*",async(e,t)=>{await this.handleServeHtml(e,t,s)}),this.server.listen(this.port,this.hostname,()=>{let e=`Server started.
1
+ "use strict";var u=Object.create;var c=Object.defineProperty;var m=Object.getOwnPropertyDescriptor;var v=Object.getOwnPropertyNames;var C=Object.getPrototypeOf,k=Object.prototype.hasOwnProperty;var w=(r,s,e,t)=>{if(s&&typeof s=="object"||typeof s=="function")for(let a of v(s))!k.call(r,a)&&a!==e&&c(r,a,{get:()=>s[a],enumerable:!(t=m(s,a))||t.enumerable});return r};var o=(r,s,e)=>(e=r!=null?u(C(r)):{},w(s||!r||!r.__esModule?c(e,"default",{value:r,enumerable:!0}):e,r));const y=require("memory-cache"),S=require("node:crypto"),f=require("express"),l=require("node:fs/promises"),I=require("node:http");class P{envIsProduction;templateHtml;hostname;mode;port;base;app;server;cache;healthCheckCacheKey;healthCheckCacheTimeout;healthCheckStatusCodes;devtoolsWorkspaceUUID;constructor({mode:s,port:e,base:t}={}){this.envIsProduction=process.env.NODE_ENV==="production",this.templateHtml="",this.hostname=this.envIsProduction?"0.0.0.0":"127.0.0.1",this.mode=s||process.env.MODE||"development",this.port=e||(process.env.PORT?Number(process.env.PORT):this.envIsProduction?8080:5173),this.base=t||process.env.BASE||"",this.app=f(),this.server=I.createServer(this.app),this.cache=new y.Cache,this.healthCheckCacheKey="health-check",this.healthCheckCacheTimeout=3e4,this.healthCheckStatusCodes={healthy:200,startingUp:503,shuttingDown:503,unhealthy:503,unknown:503},this.devtoolsWorkspaceUUID=S.randomUUID()}getHealthCheck(s){return{healthStatus:"healthy",additionalInfo:"All healthy."}}handleHealthCheck(s,e){let t=this.cache.get(this.healthCheckCacheKey);if(t===null){const a=this.getHealthCheck(s);a.healthStatus!=="healthy"&&console.warn(`health check: ${JSON.stringify(a)}`),t={appId:process.env.APP_ID||"REPLACE_ME",healthStatus:a.healthStatus,lastCheckedTimestamp:new Date().toISOString(),additionalInformation:a.additionalInfo,startupTimestamp:new Date().toISOString(),appVersion:process.env.APP_VERSION||"REPLACE_ME",details:a.details||[]},this.cache.put(this.healthCheckCacheKey,t,this.healthCheckCacheTimeout)}e.status(this.healthCheckStatusCodes[t.healthStatus]).json(t)}async handleServeHtml(s,e,{getRenderAndTemplate:t,onServeError:a}){try{const h=s.originalUrl.replace(this.base,""),[n,p]=await t(h),i=await n(h),d=p.replace("<!--app-head-->",i.head??"").replace("<!--app-html-->",i.html??"");e.status(200).set({"Content-Type":"text/html"}).send(d)}catch(h){if(h instanceof Error){console.error(h.stack);const n=a(h);e.status(500).end(n)}}}handleChromeDevTools(s,e){if(this.envIsProduction)e.status(404).json({});else{const t=process.env.LOCAL_WORKSPACE_PATH;let a,h;t?(a=200,h={workspace:{uuid:this.devtoolsWorkspaceUUID,root:t}}):(a=404,h={error:"Local workspace path not configured."}),e.status(a).json(h)}}async setUpProduction(){const s=(await import("compression")).default,e=(await import("sirv")).default;return this.templateHtml=await l.readFile("./dist/client/index.html","utf-8"),this.app.use(s()),this.app.use(this.base,e("./dist/client",{extensions:[]})),{getRenderAndTemplate:async()=>{const t=(await import("../../../../dist/server/entry-server.js")).render,a=this.templateHtml;return[t,a]},onServeError:()=>{}}}async setUpDevelopment(){const{createServer:s}=await import("vite"),e=await s({configFile:"/workspace/frontend/vite.config.ts",server:{middlewareMode:!0,hmr:{server:this.server}},appType:"custom",base:this.base,mode:this.mode});return this.app.use(e.middlewares),{getRenderAndTemplate:async t=>{const a=(await e.ssrLoadModule("/src/entry-server.tsx")).render;let h=await l.readFile("./index.html","utf-8");return h=await e.transformIndexHtml(t,h),[a,h]},onServeError:t=>(e.ssrFixStacktrace(t),t.stack)}}async run(){const s=this.envIsProduction?await this.setUpProduction():await this.setUpDevelopment();this.app.get("/health-check",(e,t)=>{this.handleHealthCheck(e,t)}),this.app.get("/.well-known/appspecific/com.chrome.devtools.json",(e,t)=>{this.handleChromeDevTools(e,t)}),this.app.get("*",async(e,t)=>{await this.handleServeHtml(e,t,s)}),this.server.listen(this.port,this.hostname,()=>{let e=`Server started.
2
2
  url: http://${this.hostname}:${this.port}
3
3
  environment: ${process.env.NODE_ENV}
4
4
  `;this.envIsProduction||(e+=`mode: ${this.mode}
@@ -1 +1 @@
1
- {"version":3,"file":"server.cjs.js","sources":["../../src/server/server.ts"],"sourcesContent":["/**\n * © Ocado Group\n * Created on 13/12/2024 at 12:15:05(+00:00).\n *\n * A server for an app in a live environment.\n * Based off: https://github.com/bluwy/create-vite-extra/blob/master/template-ssr-react-ts/server.js\n */\n\nimport { Cache, type CacheClass } from \"memory-cache\"\nimport { type UUID, randomUUID } from \"node:crypto\"\nimport express, { type Express, type Request, type Response } from \"express\"\nimport fs from \"node:fs/promises\"\nimport http from \"node:http\"\n\ntype Mode = \"development\" | \"staging\" | \"production\"\ntype Options = Partial<{\n mode: Mode\n port: number\n base: string\n}>\n\ntype HealthStatus =\n | \"healthy\"\n | \"startingUp\"\n | \"shuttingDown\"\n | \"unhealthy\"\n | \"unknown\"\ntype HealthCheck = {\n healthStatus: HealthStatus\n additionalInfo: string\n details?: Array<{\n name: string\n description: string\n health: HealthStatus\n }>\n}\ntype HealthCheckResponse = {\n appId: string\n healthStatus: HealthStatus\n lastCheckedTimestamp: string\n additionalInformation: string\n startupTimestamp: string\n appVersion: string\n details: Array<{\n name: string\n description: string\n health: HealthStatus\n }>\n}\n\ntype Render = (path: string) => Promise<{ head?: string; html?: string }>\ntype EntryModule = { render: Render }\ntype RenderAndTemplate = [Render, string]\ntype GetRenderAndTemplate = (path: string) => Promise<RenderAndTemplate>\ntype OnServeError = (error: Error) => string | undefined\n\ntype Setup = {\n getRenderAndTemplate: GetRenderAndTemplate\n onServeError: OnServeError\n}\n\nexport default class Server {\n envIsProduction: boolean\n templateHtml: string\n hostname: string\n mode: Mode\n port: number\n base: string\n app: Express\n server: http.Server<typeof http.IncomingMessage, typeof http.ServerResponse>\n cache: CacheClass<string, any>\n healthCheckCacheKey: string\n healthCheckCacheTimeout: number\n healthCheckStatusCodes: Record<HealthStatus, number>\n devtoolsWorkspaceUUID: UUID\n\n constructor({ mode, port, base }: Options = {}) {\n this.envIsProduction = process.env.NODE_ENV === \"production\"\n this.templateHtml = \"\"\n this.hostname = this.envIsProduction ? \"0.0.0.0\" : \"127.0.0.1\"\n\n this.mode = mode || (process.env.MODE as Mode) || \"development\"\n this.port =\n port ||\n (process.env.PORT\n ? Number(process.env.PORT)\n : this.envIsProduction\n ? 8080\n : 5173)\n this.base = base || process.env.BASE || \"\"\n\n this.app = express()\n this.server = http.createServer(this.app)\n this.cache = new Cache()\n\n this.healthCheckCacheKey = \"health-check\"\n this.healthCheckCacheTimeout = 30000\n this.healthCheckStatusCodes = {\n // The app is running normally.\n healthy: 200,\n // The app is performing app-specific initialisation which must\n // complete before it will serve normal application requests\n // (perhaps the app is warming a cache or something similar). You\n // only need to use this status if your app will be in a start-up\n // mode for a prolonged period of time.\n startingUp: 503,\n // The app is shutting down. As with startingUp, you only need to\n // use this status if your app takes a prolonged amount of time\n // to shutdown, perhaps because it waits for a long-running\n // process to complete before shutting down.\n shuttingDown: 503,\n // The app is not running normally.\n unhealthy: 503,\n // The app is not able to report its own state.\n unknown: 503,\n }\n\n this.devtoolsWorkspaceUUID = randomUUID()\n }\n\n // @ts-expect-error unused var\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n getHealthCheck(request: Request): HealthCheck {\n return {\n healthStatus: \"healthy\",\n additionalInfo: \"All healthy.\",\n }\n }\n\n handleHealthCheck(request: Request, response: Response): void {\n let value: HealthCheckResponse = this.cache.get(\n this.healthCheckCacheKey,\n ) as HealthCheckResponse\n if (value === null) {\n const healthCheck = this.getHealthCheck(request)\n\n if (healthCheck.healthStatus !== \"healthy\") {\n console.warn(`health check: ${JSON.stringify(healthCheck)}`)\n }\n\n value = {\n appId: process.env.APP_ID || \"REPLACE_ME\",\n healthStatus: healthCheck.healthStatus,\n lastCheckedTimestamp: new Date().toISOString(),\n additionalInformation: healthCheck.additionalInfo,\n startupTimestamp: new Date().toISOString(),\n appVersion: process.env.APP_VERSION || \"REPLACE_ME\",\n details: healthCheck.details || [],\n }\n\n this.cache.put(\n this.healthCheckCacheKey,\n value,\n this.healthCheckCacheTimeout,\n )\n }\n\n response.status(this.healthCheckStatusCodes[value.healthStatus]).json(value)\n }\n\n async handleServeHtml(\n request: Request,\n response: Response,\n { getRenderAndTemplate, onServeError }: Setup,\n ): Promise<void> {\n try {\n const path = request.originalUrl.replace(this.base, \"\")\n\n const [render, template] = await getRenderAndTemplate(path)\n\n const rendered = await render(path)\n\n const html = template\n .replace(`<!--app-head-->`, rendered.head ?? \"\")\n .replace(`<!--app-html-->`, rendered.html ?? \"\")\n\n response.status(200).set({ \"Content-Type\": \"text/html\" }).send(html)\n } catch (error) {\n if (error instanceof Error) {\n console.error(error.stack)\n const body = onServeError(error)\n response.status(500).end(body)\n }\n }\n }\n\n // @ts-expect-error unused var\n handleChromeDevTools(request: Request, response: Response) {\n if (this.envIsProduction) {\n response.status(404).json({})\n } else {\n const localWorkspacePath = process.env.LOCAL_WORKSPACE_PATH\n\n let code: number\n let body: object\n if (localWorkspacePath) {\n code = 200\n body = {\n workspace: {\n uuid: this.devtoolsWorkspaceUUID,\n root: localWorkspacePath,\n },\n }\n } else {\n code = 404\n body = { error: \"Local workspace path not configured.\" }\n }\n\n response.status(code).json(body)\n }\n }\n\n async setUpProduction(): Promise<Setup> {\n const compression = (await import(\"compression\")).default\n const sirv = (await import(\"sirv\")).default\n\n this.templateHtml = await fs.readFile(\"./dist/client/index.html\", \"utf-8\")\n\n this.app.use(compression())\n this.app.use(this.base, sirv(\"./dist/client\", { extensions: [] }))\n\n return {\n getRenderAndTemplate: async () => {\n const render = (\n (await import(\n // @ts-expect-error only present after building installing app.\n \"../../../dist/server/entry-server.js\"\n )) as EntryModule\n ).render\n\n // Use cached template.\n const template = this.templateHtml\n\n return [render, template]\n },\n onServeError: () => undefined,\n }\n }\n\n async setUpDevelopment(): Promise<Setup> {\n const { createServer } = await import(\"vite\")\n\n const vite = await createServer({\n configFile: \"/workspace/frontend/vite.config.ts\",\n server: {\n middlewareMode: true,\n hmr: { server: this.server },\n },\n appType: \"custom\",\n base: this.base,\n mode: this.mode,\n })\n\n this.app.use(vite.middlewares)\n\n return {\n getRenderAndTemplate: async path => {\n const render = (\n (await vite.ssrLoadModule(\"/src/entry-server.tsx\")) as EntryModule\n ).render\n\n // Always read fresh template.\n let template = await fs.readFile(\"./index.html\", \"utf-8\")\n template = await vite.transformIndexHtml(path, template)\n\n return [render, template]\n },\n onServeError: error => {\n vite.ssrFixStacktrace(error)\n return error.stack\n },\n }\n }\n\n async run() {\n const setup = this.envIsProduction\n ? await this.setUpProduction()\n : await this.setUpDevelopment()\n\n this.app.get(\"/health-check\", (request, response) => {\n this.handleHealthCheck(request, response)\n })\n\n this.app.get(\n \"/.well-known/appspecific/com.chrome.devtools.json\",\n (request, response) => {\n this.handleChromeDevTools(request, response)\n },\n )\n\n this.app.get(\"*\", async (request, response) => {\n await this.handleServeHtml(request, response, setup)\n })\n\n this.server.listen(this.port, this.hostname, () => {\n let startMessage =\n \"Server started.\\n\" +\n `url: http://${this.hostname}:${this.port}\\n` +\n `environment: ${process.env.NODE_ENV}\\n`\n\n if (!this.envIsProduction) startMessage += `mode: ${this.mode}\\n`\n\n console.log(startMessage)\n })\n }\n}\n"],"names":["Server","mode","port","base","express","http","Cache","randomUUID","request","response","value","healthCheck","getRenderAndTemplate","onServeError","path","render","template","rendered","html","error","body","localWorkspacePath","code","compression","sirv","fs","createServer","vite","setup","startMessage"],"mappings":"2lBA6DA,MAAqBA,CAAO,CAC1B,gBACA,aACA,SACA,KACA,KACA,KACA,IACA,OACA,MACA,oBACA,wBACA,uBACA,sBAEA,YAAY,CAAE,KAAAC,EAAM,KAAAC,EAAM,KAAAC,CAAA,EAAkB,CAAA,EAAI,CAC9C,KAAK,gBAAkB,QAAQ,IAAI,WAAa,aAChD,KAAK,aAAe,GACpB,KAAK,SAAW,KAAK,gBAAkB,UAAY,YAEnD,KAAK,KAAOF,GAAS,QAAQ,IAAI,MAAiB,cAClD,KAAK,KACHC,IACC,QAAQ,IAAI,KACT,OAAO,QAAQ,IAAI,IAAI,EACvB,KAAK,gBACH,KACA,MACR,KAAK,KAAOC,GAAQ,QAAQ,IAAI,MAAQ,GAExC,KAAK,IAAMC,EAAA,EACX,KAAK,OAASC,EAAK,aAAa,KAAK,GAAG,EACxC,KAAK,MAAQ,IAAIC,QAEjB,KAAK,oBAAsB,eAC3B,KAAK,wBAA0B,IAC/B,KAAK,uBAAyB,CAE5B,QAAS,IAMT,WAAY,IAKZ,aAAc,IAEd,UAAW,IAEX,QAAS,GAAA,EAGX,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,SAAS,eAAgB,OAAO,EACxD,OAAAT,EAAW,MAAMW,EAAK,mBAAmBb,EAAME,CAAQ,EAEhD,CAACD,EAAQC,CAAQ,CAC1B,EACA,aAAcG,IACZQ,EAAK,iBAAiBR,CAAK,EACpBA,EAAM,MACf,CAEJ,CAEA,MAAM,KAAM,CACV,MAAMS,EAAQ,KAAK,gBACf,MAAM,KAAK,gBAAA,EACX,MAAM,KAAK,iBAAA,EAEf,KAAK,IAAI,IAAI,gBAAiB,CAACpB,EAASC,IAAa,CACnD,KAAK,kBAAkBD,EAASC,CAAQ,CAC1C,CAAC,EAED,KAAK,IAAI,IACP,oDACA,CAACD,EAASC,IAAa,CACrB,KAAK,qBAAqBD,EAASC,CAAQ,CAC7C,CAAA,EAGF,KAAK,IAAI,IAAI,IAAK,MAAOD,EAASC,IAAa,CAC7C,MAAM,KAAK,gBAAgBD,EAASC,EAAUmB,CAAK,CACrD,CAAC,EAED,KAAK,OAAO,OAAO,KAAK,KAAM,KAAK,SAAU,IAAM,CACjD,IAAIC,EACF;AAAA,cACe,KAAK,QAAQ,IAAI,KAAK,IAAI;AAAA,eACzB,QAAQ,IAAI,QAAQ;AAAA,EAEjC,KAAK,kBAAiBA,GAAgB,SAAS,KAAK,IAAI;AAAA,GAE7D,QAAQ,IAAIA,CAAY,CAC1B,CAAC,CACH,CACF"}
1
+ {"version":3,"file":"server.cjs.js","sources":["../../src/server/server.ts"],"sourcesContent":["/**\n * © Ocado Group\n * Created on 13/12/2024 at 12:15:05(+00:00).\n *\n * A server for an app in a live environment.\n * Based off: https://github.com/bluwy/create-vite-extra/blob/master/template-ssr-react-ts/server.js\n */\n\nimport { Cache, type CacheClass } from \"memory-cache\"\nimport { type UUID, randomUUID } from \"node:crypto\"\nimport express, { type Express, type Request, type Response } from \"express\"\nimport fs from \"node:fs/promises\"\nimport http from \"node:http\"\n\ntype Mode = \"development\" | \"staging\" | \"production\"\ntype Options = Partial<{\n mode: Mode\n port: number\n base: string\n}>\n\ntype HealthStatus =\n | \"healthy\"\n | \"startingUp\"\n | \"shuttingDown\"\n | \"unhealthy\"\n | \"unknown\"\ntype HealthCheck = {\n healthStatus: HealthStatus\n additionalInfo: string\n details?: Array<{\n name: string\n description: string\n health: HealthStatus\n }>\n}\ntype HealthCheckResponse = {\n appId: string\n healthStatus: HealthStatus\n lastCheckedTimestamp: string\n additionalInformation: string\n startupTimestamp: string\n appVersion: string\n details: Array<{\n name: string\n description: string\n health: HealthStatus\n }>\n}\n\ntype Render = (path: string) => Promise<{ head?: string; html?: string }>\ntype EntryModule = { render: Render }\ntype RenderAndTemplate = [Render, string]\ntype GetRenderAndTemplate = (path: string) => Promise<RenderAndTemplate>\ntype OnServeError = (error: Error) => string | undefined\n\ntype Setup = {\n getRenderAndTemplate: GetRenderAndTemplate\n onServeError: OnServeError\n}\n\nexport default class Server {\n envIsProduction: boolean\n templateHtml: string\n hostname: string\n mode: Mode\n port: number\n base: string\n app: Express\n server: http.Server<typeof http.IncomingMessage, typeof http.ServerResponse>\n cache: CacheClass<string, any>\n healthCheckCacheKey: string\n healthCheckCacheTimeout: number\n healthCheckStatusCodes: Record<HealthStatus, number>\n devtoolsWorkspaceUUID: UUID\n\n constructor({ mode, port, base }: Options = {}) {\n this.envIsProduction = process.env.NODE_ENV === \"production\"\n this.templateHtml = \"\"\n this.hostname = this.envIsProduction ? \"0.0.0.0\" : \"127.0.0.1\"\n\n this.mode = mode || (process.env.MODE as Mode) || \"development\"\n this.port =\n port ||\n (process.env.PORT\n ? Number(process.env.PORT)\n : this.envIsProduction\n ? 8080\n : 5173)\n this.base = base || process.env.BASE || \"\"\n\n this.app = express()\n this.server = http.createServer(this.app)\n this.cache = new Cache()\n\n this.healthCheckCacheKey = \"health-check\"\n this.healthCheckCacheTimeout = 30000\n this.healthCheckStatusCodes = {\n // The app is running normally.\n healthy: 200,\n // The app is performing app-specific initialisation which must\n // complete before it will serve normal application requests\n // (perhaps the app is warming a cache or something similar). You\n // only need to use this status if your app will be in a start-up\n // mode for a prolonged period of time.\n startingUp: 503,\n // The app is shutting down. As with startingUp, you only need to\n // use this status if your app takes a prolonged amount of time\n // to shutdown, perhaps because it waits for a long-running\n // process to complete before shutting down.\n shuttingDown: 503,\n // The app is not running normally.\n unhealthy: 503,\n // The app is not able to report its own state.\n unknown: 503,\n }\n\n this.devtoolsWorkspaceUUID = randomUUID()\n }\n\n // @ts-expect-error unused var\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n getHealthCheck(request: Request): HealthCheck {\n return {\n healthStatus: \"healthy\",\n additionalInfo: \"All healthy.\",\n }\n }\n\n handleHealthCheck(request: Request, response: Response): void {\n let value: HealthCheckResponse = this.cache.get(\n this.healthCheckCacheKey,\n ) as HealthCheckResponse\n if (value === null) {\n const healthCheck = this.getHealthCheck(request)\n\n if (healthCheck.healthStatus !== \"healthy\") {\n console.warn(`health check: ${JSON.stringify(healthCheck)}`)\n }\n\n value = {\n appId: process.env.APP_ID || \"REPLACE_ME\",\n healthStatus: healthCheck.healthStatus,\n lastCheckedTimestamp: new Date().toISOString(),\n additionalInformation: healthCheck.additionalInfo,\n startupTimestamp: new Date().toISOString(),\n appVersion: process.env.APP_VERSION || \"REPLACE_ME\",\n details: healthCheck.details || [],\n }\n\n this.cache.put(\n this.healthCheckCacheKey,\n value,\n this.healthCheckCacheTimeout,\n )\n }\n\n response.status(this.healthCheckStatusCodes[value.healthStatus]).json(value)\n }\n\n async handleServeHtml(\n request: Request,\n response: Response,\n { getRenderAndTemplate, onServeError }: Setup,\n ): Promise<void> {\n try {\n const path = request.originalUrl.replace(this.base, \"\")\n\n const [render, template] = await getRenderAndTemplate(path)\n\n const rendered = await render(path)\n\n const html = template\n .replace(`<!--app-head-->`, rendered.head ?? \"\")\n .replace(`<!--app-html-->`, rendered.html ?? \"\")\n\n response.status(200).set({ \"Content-Type\": \"text/html\" }).send(html)\n } catch (error) {\n if (error instanceof Error) {\n console.error(error.stack)\n const body = onServeError(error)\n response.status(500).end(body)\n }\n }\n }\n\n // @ts-expect-error unused var\n handleChromeDevTools(request: Request, response: Response) {\n if (this.envIsProduction) {\n response.status(404).json({})\n } else {\n const localWorkspacePath = process.env.LOCAL_WORKSPACE_PATH\n\n let code: number\n let body: object\n if (localWorkspacePath) {\n code = 200\n body = {\n workspace: {\n uuid: this.devtoolsWorkspaceUUID,\n root: localWorkspacePath,\n },\n }\n } else {\n code = 404\n body = { error: \"Local workspace path not configured.\" }\n }\n\n response.status(code).json(body)\n }\n }\n\n async setUpProduction(): Promise<Setup> {\n const compression = (await import(\"compression\")).default\n const sirv = (await import(\"sirv\")).default\n\n this.templateHtml = await fs.readFile(\"./dist/client/index.html\", \"utf-8\")\n\n this.app.use(compression())\n this.app.use(this.base, sirv(\"./dist/client\", { extensions: [] }))\n\n return {\n getRenderAndTemplate: async () => {\n const render = (\n (await import(\n // @ts-expect-error only present after building installing app.\n \"../../../../dist/server/entry-server.js\"\n )) as EntryModule\n ).render\n\n // Use cached template.\n const template = this.templateHtml\n\n return [render, template]\n },\n onServeError: () => undefined,\n }\n }\n\n async setUpDevelopment(): Promise<Setup> {\n const { createServer } = await import(\"vite\")\n\n const vite = await createServer({\n configFile: \"/workspace/frontend/vite.config.ts\",\n server: {\n middlewareMode: true,\n hmr: { server: this.server },\n },\n appType: \"custom\",\n base: this.base,\n mode: this.mode,\n })\n\n this.app.use(vite.middlewares)\n\n return {\n getRenderAndTemplate: async path => {\n const render = (\n (await vite.ssrLoadModule(\"/src/entry-server.tsx\")) as EntryModule\n ).render\n\n // Always read fresh template.\n let template = await fs.readFile(\"./index.html\", \"utf-8\")\n template = await vite.transformIndexHtml(path, template)\n\n return [render, template]\n },\n onServeError: error => {\n vite.ssrFixStacktrace(error)\n return error.stack\n },\n }\n }\n\n async run() {\n const setup = this.envIsProduction\n ? await this.setUpProduction()\n : await this.setUpDevelopment()\n\n this.app.get(\"/health-check\", (request, response) => {\n this.handleHealthCheck(request, response)\n })\n\n this.app.get(\n \"/.well-known/appspecific/com.chrome.devtools.json\",\n (request, response) => {\n this.handleChromeDevTools(request, response)\n },\n )\n\n this.app.get(\"*\", async (request, response) => {\n await this.handleServeHtml(request, response, setup)\n })\n\n this.server.listen(this.port, this.hostname, () => {\n let startMessage =\n \"Server started.\\n\" +\n `url: http://${this.hostname}:${this.port}\\n` +\n `environment: ${process.env.NODE_ENV}\\n`\n\n if (!this.envIsProduction) startMessage += `mode: ${this.mode}\\n`\n\n console.log(startMessage)\n })\n }\n}\n"],"names":["Server","mode","port","base","express","http","Cache","randomUUID","request","response","value","healthCheck","getRenderAndTemplate","onServeError","path","render","template","rendered","html","error","body","localWorkspacePath","code","compression","sirv","fs","createServer","vite","setup","startMessage"],"mappings":"2lBA6DA,MAAqBA,CAAO,CAC1B,gBACA,aACA,SACA,KACA,KACA,KACA,IACA,OACA,MACA,oBACA,wBACA,uBACA,sBAEA,YAAY,CAAE,KAAAC,EAAM,KAAAC,EAAM,KAAAC,CAAA,EAAkB,CAAA,EAAI,CAC9C,KAAK,gBAAkB,QAAQ,IAAI,WAAa,aAChD,KAAK,aAAe,GACpB,KAAK,SAAW,KAAK,gBAAkB,UAAY,YAEnD,KAAK,KAAOF,GAAS,QAAQ,IAAI,MAAiB,cAClD,KAAK,KACHC,IACC,QAAQ,IAAI,KACT,OAAO,QAAQ,IAAI,IAAI,EACvB,KAAK,gBACH,KACA,MACR,KAAK,KAAOC,GAAQ,QAAQ,IAAI,MAAQ,GAExC,KAAK,IAAMC,EAAA,EACX,KAAK,OAASC,EAAK,aAAa,KAAK,GAAG,EACxC,KAAK,MAAQ,IAAIC,QAEjB,KAAK,oBAAsB,eAC3B,KAAK,wBAA0B,IAC/B,KAAK,uBAAyB,CAE5B,QAAS,IAMT,WAAY,IAKZ,aAAc,IAEd,UAAW,IAEX,QAAS,GAAA,EAGX,KAAK,sBAAwBC,aAAA,CAC/B,CAIA,eAAeC,EAA+B,CAC5C,MAAO,CACL,aAAc,UACd,eAAgB,cAAA,CAEpB,CAEA,kBAAkBA,EAAkBC,EAA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Q,EAAK,iBAAiBR,CAAK,EACpBA,EAAM,MACf,CAEJ,CAEA,MAAM,KAAM,CACV,MAAMS,EAAQ,KAAK,gBACf,MAAM,KAAK,gBAAA,EACX,MAAM,KAAK,iBAAA,EAEf,KAAK,IAAI,IAAI,gBAAiB,CAACpB,EAASC,IAAa,CACnD,KAAK,kBAAkBD,EAASC,CAAQ,CAC1C,CAAC,EAED,KAAK,IAAI,IACP,oDACA,CAACD,EAASC,IAAa,CACrB,KAAK,qBAAqBD,EAASC,CAAQ,CAC7C,CAAA,EAGF,KAAK,IAAI,IAAI,IAAK,MAAOD,EAASC,IAAa,CAC7C,MAAM,KAAK,gBAAgBD,EAASC,EAAUmB,CAAK,CACrD,CAAC,EAED,KAAK,OAAO,OAAO,KAAK,KAAM,KAAK,SAAU,IAAM,CACjD,IAAIC,EACF;AAAA,cACe,KAAK,QAAQ,IAAI,KAAK,IAAI;AAAA,eACzB,QAAQ,IAAI,QAAQ;AAAA,EAEjC,KAAK,kBAAiBA,GAAgB,SAAS,KAAK,IAAI;AAAA,GAE7D,QAAQ,IAAIA,CAAY,CAC1B,CAAC,CACH,CACF"}
@@ -101,7 +101,7 @@ class S {
101
101
  getRenderAndTemplate: async () => {
102
102
  const t = (await import(
103
103
  // @ts-expect-error only present after building installing app.
104
- "../../../dist/server/entry-server.js"
104
+ "../../../../dist/server/entry-server.js"
105
105
  )).render, s = this.templateHtml;
106
106
  return [t, s];
107
107
  },
@@ -1 +1 @@
1
- {"version":3,"file":"server.es.js","sources":["../../src/server/server.ts"],"sourcesContent":["/**\n * © Ocado Group\n * Created on 13/12/2024 at 12:15:05(+00:00).\n *\n * A server for an app in a live environment.\n * Based off: https://github.com/bluwy/create-vite-extra/blob/master/template-ssr-react-ts/server.js\n */\n\nimport { Cache, type CacheClass } from \"memory-cache\"\nimport { type UUID, randomUUID } from \"node:crypto\"\nimport express, { type Express, type Request, type Response } from \"express\"\nimport fs from \"node:fs/promises\"\nimport http from \"node:http\"\n\ntype Mode = \"development\" | \"staging\" | \"production\"\ntype Options = Partial<{\n mode: Mode\n port: number\n base: string\n}>\n\ntype HealthStatus =\n | \"healthy\"\n | \"startingUp\"\n | \"shuttingDown\"\n | \"unhealthy\"\n | \"unknown\"\ntype HealthCheck = {\n healthStatus: HealthStatus\n additionalInfo: string\n details?: Array<{\n name: string\n description: string\n health: HealthStatus\n }>\n}\ntype HealthCheckResponse = {\n appId: string\n healthStatus: HealthStatus\n lastCheckedTimestamp: string\n additionalInformation: string\n startupTimestamp: string\n appVersion: string\n details: Array<{\n name: string\n description: string\n health: HealthStatus\n }>\n}\n\ntype Render = (path: string) => Promise<{ head?: string; html?: string }>\ntype EntryModule = { render: Render }\ntype RenderAndTemplate = [Render, string]\ntype GetRenderAndTemplate = (path: string) => Promise<RenderAndTemplate>\ntype OnServeError = (error: Error) => string | undefined\n\ntype Setup = {\n getRenderAndTemplate: GetRenderAndTemplate\n onServeError: OnServeError\n}\n\nexport default class Server {\n envIsProduction: boolean\n templateHtml: string\n hostname: string\n mode: Mode\n port: number\n base: string\n app: Express\n server: http.Server<typeof http.IncomingMessage, typeof http.ServerResponse>\n cache: CacheClass<string, any>\n healthCheckCacheKey: string\n healthCheckCacheTimeout: number\n healthCheckStatusCodes: Record<HealthStatus, number>\n devtoolsWorkspaceUUID: UUID\n\n constructor({ mode, port, base }: Options = {}) {\n this.envIsProduction = process.env.NODE_ENV === \"production\"\n this.templateHtml = \"\"\n this.hostname = this.envIsProduction ? \"0.0.0.0\" : \"127.0.0.1\"\n\n this.mode = mode || (process.env.MODE as Mode) || \"development\"\n this.port =\n port ||\n (process.env.PORT\n ? Number(process.env.PORT)\n : this.envIsProduction\n ? 8080\n : 5173)\n this.base = base || process.env.BASE || \"\"\n\n this.app = express()\n this.server = http.createServer(this.app)\n this.cache = new Cache()\n\n this.healthCheckCacheKey = \"health-check\"\n this.healthCheckCacheTimeout = 30000\n this.healthCheckStatusCodes = {\n // The app is running normally.\n healthy: 200,\n // The app is performing app-specific initialisation which must\n // complete before it will serve normal application requests\n // (perhaps the app is warming a cache or something similar). You\n // only need to use this status if your app will be in a start-up\n // mode for a prolonged period of time.\n startingUp: 503,\n // The app is shutting down. As with startingUp, you only need to\n // use this status if your app takes a prolonged amount of time\n // to shutdown, perhaps because it waits for a long-running\n // process to complete before shutting down.\n shuttingDown: 503,\n // The app is not running normally.\n unhealthy: 503,\n // The app is not able to report its own state.\n unknown: 503,\n }\n\n this.devtoolsWorkspaceUUID = randomUUID()\n }\n\n // @ts-expect-error unused var\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n getHealthCheck(request: Request): HealthCheck {\n return {\n healthStatus: \"healthy\",\n additionalInfo: \"All healthy.\",\n }\n }\n\n handleHealthCheck(request: Request, response: Response): void {\n let value: HealthCheckResponse = this.cache.get(\n this.healthCheckCacheKey,\n ) as HealthCheckResponse\n if (value === null) {\n const healthCheck = this.getHealthCheck(request)\n\n if (healthCheck.healthStatus !== \"healthy\") {\n console.warn(`health check: ${JSON.stringify(healthCheck)}`)\n }\n\n value = {\n appId: process.env.APP_ID || \"REPLACE_ME\",\n healthStatus: healthCheck.healthStatus,\n lastCheckedTimestamp: new Date().toISOString(),\n additionalInformation: healthCheck.additionalInfo,\n startupTimestamp: new Date().toISOString(),\n appVersion: process.env.APP_VERSION || \"REPLACE_ME\",\n details: healthCheck.details || [],\n }\n\n this.cache.put(\n this.healthCheckCacheKey,\n value,\n this.healthCheckCacheTimeout,\n )\n }\n\n response.status(this.healthCheckStatusCodes[value.healthStatus]).json(value)\n }\n\n async handleServeHtml(\n request: Request,\n response: Response,\n { getRenderAndTemplate, onServeError }: Setup,\n ): Promise<void> {\n try {\n const path = request.originalUrl.replace(this.base, \"\")\n\n const [render, template] = await getRenderAndTemplate(path)\n\n const rendered = await render(path)\n\n const html = template\n .replace(`<!--app-head-->`, rendered.head ?? \"\")\n .replace(`<!--app-html-->`, rendered.html ?? \"\")\n\n response.status(200).set({ \"Content-Type\": \"text/html\" }).send(html)\n } catch (error) {\n if (error instanceof Error) {\n console.error(error.stack)\n const body = onServeError(error)\n response.status(500).end(body)\n }\n }\n }\n\n // @ts-expect-error unused var\n handleChromeDevTools(request: Request, response: Response) {\n if (this.envIsProduction) {\n response.status(404).json({})\n } else {\n const localWorkspacePath = process.env.LOCAL_WORKSPACE_PATH\n\n let code: number\n let body: object\n if (localWorkspacePath) {\n code = 200\n body = {\n workspace: {\n uuid: this.devtoolsWorkspaceUUID,\n root: localWorkspacePath,\n },\n }\n } else {\n code = 404\n body = { error: \"Local workspace path not configured.\" }\n }\n\n response.status(code).json(body)\n }\n }\n\n async setUpProduction(): Promise<Setup> {\n const compression = (await import(\"compression\")).default\n const sirv = (await import(\"sirv\")).default\n\n this.templateHtml = await fs.readFile(\"./dist/client/index.html\", \"utf-8\")\n\n this.app.use(compression())\n this.app.use(this.base, sirv(\"./dist/client\", { extensions: [] }))\n\n return {\n getRenderAndTemplate: async () => {\n const render = (\n (await import(\n // @ts-expect-error only present after building installing app.\n \"../../../dist/server/entry-server.js\"\n )) as EntryModule\n ).render\n\n // Use cached template.\n const template = this.templateHtml\n\n return [render, template]\n },\n onServeError: () => undefined,\n }\n }\n\n async setUpDevelopment(): Promise<Setup> {\n const { createServer } = await import(\"vite\")\n\n const vite = await createServer({\n configFile: \"/workspace/frontend/vite.config.ts\",\n server: {\n middlewareMode: true,\n hmr: { server: this.server },\n },\n appType: \"custom\",\n base: this.base,\n mode: this.mode,\n })\n\n this.app.use(vite.middlewares)\n\n return {\n getRenderAndTemplate: async path => {\n const render = (\n (await vite.ssrLoadModule(\"/src/entry-server.tsx\")) as EntryModule\n ).render\n\n // Always read fresh template.\n let template = await fs.readFile(\"./index.html\", \"utf-8\")\n template = await vite.transformIndexHtml(path, template)\n\n return [render, template]\n },\n onServeError: error => {\n vite.ssrFixStacktrace(error)\n return error.stack\n },\n }\n }\n\n async run() {\n const setup = this.envIsProduction\n ? await this.setUpProduction()\n : await this.setUpDevelopment()\n\n this.app.get(\"/health-check\", (request, response) => {\n this.handleHealthCheck(request, response)\n })\n\n this.app.get(\n \"/.well-known/appspecific/com.chrome.devtools.json\",\n (request, response) => {\n this.handleChromeDevTools(request, response)\n },\n )\n\n this.app.get(\"*\", async (request, response) => {\n await this.handleServeHtml(request, response, setup)\n })\n\n this.server.listen(this.port, this.hostname, () => {\n let startMessage =\n \"Server started.\\n\" +\n `url: http://${this.hostname}:${this.port}\\n` +\n `environment: ${process.env.NODE_ENV}\\n`\n\n if (!this.envIsProduction) startMessage += `mode: ${this.mode}\\n`\n\n console.log(startMessage)\n })\n }\n}\n"],"names":["Server","mode","port","base","express","http","Cache","randomUUID","request","response","value","healthCheck","getRenderAndTemplate","onServeError","path","render","template","rendered","html","error","body","localWorkspacePath","code","compression","sirv","fs","createServer","vite","setup","startMessage"],"mappings":";;;;;AA6DA,MAAqBA,EAAO;AAAA,EAC1B;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EAEA,YAAY,EAAE,MAAAC,GAAM,MAAAC,GAAM,MAAAC,EAAA,IAAkB,CAAA,GAAI;AAC9C,SAAK,kBAAkB,QAAQ,IAAI,aAAa,cAChD,KAAK,eAAe,IACpB,KAAK,WAAW,KAAK,kBAAkB,YAAY,aAEnD,KAAK,OAAOF,KAAS,QAAQ,IAAI,QAAiB,eAClD,KAAK,OACHC,MACC,QAAQ,IAAI,OACT,OAAO,QAAQ,IAAI,IAAI,IACvB,KAAK,kBACH,OACA,OACR,KAAK,OAAOC,KAAQ,QAAQ,IAAI,QAAQ,IAExC,KAAK,MAAMC,EAAA,GACX,KAAK,SAASC,EAAK,aAAa,KAAK,GAAG,GACxC,KAAK,QAAQ,IAAIC,EAAA,GAEjB,KAAK,sBAAsB,gBAC3B,KAAK,0BAA0B,KAC/B,KAAK,yBAAyB;AAAA;AAAA,MAE5B,SAAS;AAAA;AAAA;AA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AK,UAAU,MAAM;AACjD,UAAIC,IACF;AAAA,cACe,KAAK,QAAQ,IAAI,KAAK,IAAI;AAAA,eACzB,QAAQ,IAAI,QAAQ;AAAA;AAEtC,MAAK,KAAK,oBAAiBA,KAAgB,SAAS,KAAK,IAAI;AAAA,IAE7D,QAAQ,IAAIA,CAAY;AAAA,IAC1B,CAAC;AAAA,EACH;AACF;"}
1
+ {"version":3,"file":"server.es.js","sources":["../../src/server/server.ts"],"sourcesContent":["/**\n * © Ocado Group\n * Created on 13/12/2024 at 12:15:05(+00:00).\n *\n * A server for an app in a live environment.\n * Based off: https://github.com/bluwy/create-vite-extra/blob/master/template-ssr-react-ts/server.js\n */\n\nimport { Cache, type CacheClass } from \"memory-cache\"\nimport { type UUID, randomUUID } from \"node:crypto\"\nimport express, { type Express, type Request, type Response } from \"express\"\nimport fs from \"node:fs/promises\"\nimport http from \"node:http\"\n\ntype Mode = \"development\" | \"staging\" | \"production\"\ntype Options = Partial<{\n mode: Mode\n port: number\n base: string\n}>\n\ntype HealthStatus =\n | \"healthy\"\n | \"startingUp\"\n | \"shuttingDown\"\n | \"unhealthy\"\n | \"unknown\"\ntype HealthCheck = {\n healthStatus: HealthStatus\n additionalInfo: string\n details?: Array<{\n name: string\n description: string\n health: HealthStatus\n }>\n}\ntype HealthCheckResponse = {\n appId: string\n healthStatus: HealthStatus\n lastCheckedTimestamp: string\n additionalInformation: string\n startupTimestamp: string\n appVersion: string\n details: Array<{\n name: string\n description: string\n health: HealthStatus\n }>\n}\n\ntype Render = (path: string) => Promise<{ head?: string; html?: string }>\ntype EntryModule = { render: Render }\ntype RenderAndTemplate = [Render, string]\ntype GetRenderAndTemplate = (path: string) => Promise<RenderAndTemplate>\ntype OnServeError = (error: Error) => string | undefined\n\ntype Setup = {\n getRenderAndTemplate: GetRenderAndTemplate\n onServeError: OnServeError\n}\n\nexport default class Server {\n envIsProduction: boolean\n templateHtml: string\n hostname: string\n mode: Mode\n port: number\n base: string\n app: Express\n server: http.Server<typeof http.IncomingMessage, typeof http.ServerResponse>\n cache: CacheClass<string, any>\n healthCheckCacheKey: string\n healthCheckCacheTimeout: number\n healthCheckStatusCodes: Record<HealthStatus, number>\n devtoolsWorkspaceUUID: UUID\n\n constructor({ mode, port, base }: Options = {}) {\n this.envIsProduction = process.env.NODE_ENV === \"production\"\n this.templateHtml = \"\"\n this.hostname = this.envIsProduction ? \"0.0.0.0\" : \"127.0.0.1\"\n\n this.mode = mode || (process.env.MODE as Mode) || \"development\"\n this.port =\n port ||\n (process.env.PORT\n ? Number(process.env.PORT)\n : this.envIsProduction\n ? 8080\n : 5173)\n this.base = base || process.env.BASE || \"\"\n\n this.app = express()\n this.server = http.createServer(this.app)\n this.cache = new Cache()\n\n this.healthCheckCacheKey = \"health-check\"\n this.healthCheckCacheTimeout = 30000\n this.healthCheckStatusCodes = {\n // The app is running normally.\n healthy: 200,\n // The app is performing app-specific initialisation which must\n // complete before it will serve normal application requests\n // (perhaps the app is warming a cache or something similar). You\n // only need to use this status if your app will be in a start-up\n // mode for a prolonged period of time.\n startingUp: 503,\n // The app is shutting down. As with startingUp, you only need to\n // use this status if your app takes a prolonged amount of time\n // to shutdown, perhaps because it waits for a long-running\n // process to complete before shutting down.\n shuttingDown: 503,\n // The app is not running normally.\n unhealthy: 503,\n // The app is not able to report its own state.\n unknown: 503,\n }\n\n this.devtoolsWorkspaceUUID = randomUUID()\n }\n\n // @ts-expect-error unused var\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n getHealthCheck(request: Request): HealthCheck {\n return {\n healthStatus: \"healthy\",\n additionalInfo: \"All healthy.\",\n }\n }\n\n handleHealthCheck(request: Request, response: Response): void {\n let value: HealthCheckResponse = this.cache.get(\n this.healthCheckCacheKey,\n ) as HealthCheckResponse\n if (value === null) {\n const healthCheck = this.getHealthCheck(request)\n\n if (healthCheck.healthStatus !== \"healthy\") {\n console.warn(`health check: ${JSON.stringify(healthCheck)}`)\n }\n\n value = {\n appId: process.env.APP_ID || \"REPLACE_ME\",\n healthStatus: healthCheck.healthStatus,\n lastCheckedTimestamp: new Date().toISOString(),\n additionalInformation: healthCheck.additionalInfo,\n startupTimestamp: new Date().toISOString(),\n appVersion: process.env.APP_VERSION || \"REPLACE_ME\",\n details: healthCheck.details || [],\n }\n\n this.cache.put(\n this.healthCheckCacheKey,\n value,\n this.healthCheckCacheTimeout,\n )\n }\n\n response.status(this.healthCheckStatusCodes[value.healthStatus]).json(value)\n }\n\n async handleServeHtml(\n request: Request,\n response: Response,\n { getRenderAndTemplate, onServeError }: Setup,\n ): Promise<void> {\n try {\n const path = request.originalUrl.replace(this.base, \"\")\n\n const [render, template] = await getRenderAndTemplate(path)\n\n const rendered = await render(path)\n\n const html = template\n .replace(`<!--app-head-->`, rendered.head ?? \"\")\n .replace(`<!--app-html-->`, rendered.html ?? \"\")\n\n response.status(200).set({ \"Content-Type\": \"text/html\" }).send(html)\n } catch (error) {\n if (error instanceof Error) {\n console.error(error.stack)\n const body = onServeError(error)\n response.status(500).end(body)\n }\n }\n }\n\n // @ts-expect-error unused var\n handleChromeDevTools(request: Request, response: Response) {\n if (this.envIsProduction) {\n response.status(404).json({})\n } else {\n const localWorkspacePath = process.env.LOCAL_WORKSPACE_PATH\n\n let code: number\n let body: object\n if (localWorkspacePath) {\n code = 200\n body = {\n workspace: {\n uuid: this.devtoolsWorkspaceUUID,\n root: localWorkspacePath,\n },\n }\n } else {\n code = 404\n body = { error: \"Local workspace path not configured.\" }\n }\n\n response.status(code).json(body)\n }\n }\n\n async setUpProduction(): Promise<Setup> {\n const compression = (await import(\"compression\")).default\n const sirv = (await import(\"sirv\")).default\n\n this.templateHtml = await fs.readFile(\"./dist/client/index.html\", \"utf-8\")\n\n this.app.use(compression())\n this.app.use(this.base, sirv(\"./dist/client\", { extensions: [] }))\n\n return {\n getRenderAndTemplate: async () => {\n const render = (\n (await import(\n // @ts-expect-error only present after building installing app.\n \"../../../../dist/server/entry-server.js\"\n )) as EntryModule\n ).render\n\n // Use cached template.\n const template = this.templateHtml\n\n return [render, template]\n },\n onServeError: () => undefined,\n }\n }\n\n async setUpDevelopment(): Promise<Setup> {\n const { createServer } = await import(\"vite\")\n\n const vite = await createServer({\n configFile: \"/workspace/frontend/vite.config.ts\",\n server: {\n middlewareMode: true,\n hmr: { server: this.server },\n },\n appType: \"custom\",\n base: this.base,\n mode: this.mode,\n })\n\n this.app.use(vite.middlewares)\n\n return {\n getRenderAndTemplate: async path => {\n const render = (\n (await vite.ssrLoadModule(\"/src/entry-server.tsx\")) as EntryModule\n ).render\n\n // Always read fresh template.\n let template = await fs.readFile(\"./index.html\", \"utf-8\")\n template = await vite.transformIndexHtml(path, template)\n\n return [render, template]\n },\n onServeError: error => {\n vite.ssrFixStacktrace(error)\n return error.stack\n },\n }\n }\n\n async run() {\n const setup = this.envIsProduction\n ? await this.setUpProduction()\n : await this.setUpDevelopment()\n\n this.app.get(\"/health-check\", (request, response) => {\n this.handleHealthCheck(request, response)\n })\n\n this.app.get(\n \"/.well-known/appspecific/com.chrome.devtools.json\",\n (request, response) => {\n this.handleChromeDevTools(request, response)\n },\n )\n\n this.app.get(\"*\", async (request, response) => {\n await this.handleServeHtml(request, response, setup)\n })\n\n this.server.listen(this.port, this.hostname, () => {\n let startMessage =\n \"Server started.\\n\" +\n `url: http://${this.hostname}:${this.port}\\n` +\n `environment: ${process.env.NODE_ENV}\\n`\n\n if (!this.envIsProduction) startMessage += `mode: ${this.mode}\\n`\n\n console.log(startMessage)\n })\n }\n}\n"],"names":["Server","mode","port","base","express","http","Cache","randomUUID","request","response","value","healthCheck","getRenderAndTemplate","onServeError","path","render","template","rendered","html","error","body","localWorkspacePath","code","compression","sirv","fs","createServer","vite","setup","startMessage"],"mappings":";;;;;AA6DA,MAAqBA,EAAO;AAAA,EAC1B;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AA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AAA,MACA,cAAc,CAAAG,OACZQ,EAAK,iBAAiBR,CAAK,GACpBA,EAAM;AAAA,IACf;AAAA,EAEJ;AAAA,EAEA,MAAM,MAAM;AACV,UAAMS,IAAQ,KAAK,kBACf,MAAM,KAAK,gBAAA,IACX,MAAM,KAAK,iBAAA;AAEf,SAAK,IAAI,IAAI,iBAAiB,CAACpB,GAASC,MAAa;AACnD,WAAK,kBAAkBD,GAASC,CAAQ;AAAA,IAC1C,CAAC,GAED,KAAK,IAAI;AAAA,MACP;AAAA,MACA,CAACD,GAASC,MAAa;AACrB,aAAK,qBAAqBD,GAASC,CAAQ;AAAA,MAC7C;AAAA,IAAA,GAGF,KAAK,IAAI,IAAI,KAAK,OAAOD,GAASC,MAAa;AAC7C,YAAM,KAAK,gBAAgBD,GAASC,GAAUmB,CAAK;AAAA,IACrD,CAAC,GAED,KAAK,OAAO,OAAO,KAAK,MAAM,KAAK,UAAU,MAAM;AACjD,UAAIC,IACF;AAAA,cACe,KAAK,QAAQ,IAAI,KAAK,IAAI;AAAA,eACzB,QAAQ,IAAI,QAAQ;AAAA;AAEtC,MAAK,KAAK,oBAAiBA,KAAgB,SAAS,KAAK,IAAI;AAAA,IAE7D,QAAQ,IAAIA,CAAY;AAAA,IAC1B,CAAC;AAAA,EACH;AACF;"}
@@ -1,7 +1,7 @@
1
1
  import { FC, ReactNode } from 'react';
2
2
  export interface DefaultRoutesProps {
3
3
  children: ReactNode;
4
- faviconPath?: string;
4
+ catchAll: boolean;
5
5
  }
6
6
  declare const DefaultRoutes: FC<DefaultRoutesProps>;
7
7
  export default DefaultRoutes;
@@ -6,12 +6,13 @@ export type EntryAppProps = Pick<AppProps, "emotionCache" | "children">;
6
6
  export type EntryKwArgs = {
7
7
  App: FC<EntryAppProps>;
8
8
  routes: DefaultRoutesProps["children"];
9
+ catchAllRoute?: DefaultRoutesProps["catchAll"];
9
10
  createEmotionCacheOptions?: CreateEmotionCacheOptions;
10
11
  };
11
- export declare function server({ App, routes, createEmotionCacheOptions, ...appProps }: EntryKwArgs): Promise<{
12
+ export declare function server({ App, routes, catchAllRoute, createEmotionCacheOptions, ...appProps }: EntryKwArgs): Promise<{
12
13
  render: (path: string) => {
13
14
  html: string;
14
15
  head: string;
15
16
  };
16
17
  }>;
17
- export declare function client({ App, routes, createEmotionCacheOptions, ...appProps }: EntryKwArgs): Promise<void>;
18
+ export declare function client({ App, routes, catchAllRoute, createEmotionCacheOptions, ...appProps }: EntryKwArgs): Promise<void>;
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "codeforlife",
3
3
  "description": "Common frontend code",
4
4
  "private": false,
5
- "version": "2.12.0",
5
+ "version": "2.12.2",
6
6
  "type": "module",
7
7
  "types": "dist/index.d.ts",
8
8
  "module": "dist/index.es.js",