gemi 0.4.9 → 0.4.11

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -6030,6 +6030,37 @@ async function imageHandler(req) {
6030
6030
  });
6031
6031
  }
6032
6032
 
6033
+ // server/renderErrorPage.ts
6034
+ function renderErrorPage(err) {
6035
+ return `
6036
+ <!DOCTYPE html>
6037
+ <html lang="en">
6038
+ <head>
6039
+ <meta charset="UTF-8" />
6040
+ <meta
6041
+ name="viewport"
6042
+ content="width=device-width, initial-scale=1.0"
6043
+ />
6044
+ <title>Error</title>
6045
+ <style>
6046
+ body {
6047
+ font-family: Arial, sans-serif;
6048
+ padding: 20px;
6049
+ }
6050
+ h1 {
6051
+ color: red;
6052
+ }
6053
+ </style>
6054
+ </head>
6055
+ <body>
6056
+ <h1>Error</h1>
6057
+ <pre>${JSON.stringify(err, null, 2)}</pre>
6058
+ <script type="module" src="/refresh.js"></script>
6059
+ </body>
6060
+ </html>
6061
+ `;
6062
+ }
6063
+
6033
6064
  // server/dev.ts
6034
6065
  async function startDevServer() {
6035
6066
  const root = process.cwd();
@@ -6080,7 +6111,15 @@ async function startDevServer() {
6080
6111
  } catch (err) {
6081
6112
  console.log(err);
6082
6113
  }
6083
- const { app } = await vite.ssrLoadModule(path.join(appDir, "bootstrap.ts"));
6114
+ let app = null;
6115
+ try {
6116
+ app = (await vite.ssrLoadModule(path.join(appDir, "bootstrap.ts"))).app;
6117
+ } catch (err) {
6118
+ return new Response(renderErrorPage(err), {
6119
+ status: 500,
6120
+ headers: { "Content-Type": "text/html" }
6121
+ });
6122
+ }
6084
6123
  const { default: css } = await vite.ssrLoadModule(`${appDir}/app.css`);
6085
6124
  const styles2 = [];
6086
6125
  styles2.push({
@@ -6102,7 +6141,9 @@ async function startDevServer() {
6102
6141
  try {
6103
6142
  return await handler(req);
6104
6143
  } catch (err) {
6105
- return new Response(err.stack, { status: 500 });
6144
+ return new Response(renderErrorPage(err), {
6145
+ headers: { "Content-Type": "text/html" }
6146
+ });
6106
6147
  }
6107
6148
  }
6108
6149
  await vite.listen(5174);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gemi",
3
- "version": "0.4.9",
3
+ "version": "0.4.11",
4
4
  "devDependencies": {
5
5
  "@happy-dom/global-registrator": "^14.12.3",
6
6
  "@repo/eslint-config": "*",