@absolutejs/absolute 0.19.0-beta.930 → 0.19.0-beta.932

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.
@@ -5087,16 +5087,22 @@ var setConventions = (map) => {
5087
5087
  };
5088
5088
  var isDev = () => true;
5089
5089
  var buildErrorProps = (error) => {
5090
- const message = error instanceof Error ? error.message : String(error);
5091
- const stack = isDev() && error instanceof Error ? error.stack : undefined;
5092
- return { error: { message, stack } };
5090
+ if (error instanceof Error) {
5091
+ return {
5092
+ name: error.name,
5093
+ message: error.message,
5094
+ ...isDev() && error.stack ? { stack: error.stack } : {}
5095
+ };
5096
+ }
5097
+ return { name: "Error", message: String(error) };
5093
5098
  };
5094
5099
  var renderReactError = async (conventionPath, errorProps) => {
5095
5100
  const { createElement } = await import("react");
5096
5101
  const { renderToReadableStream } = await import("react-dom/server");
5097
5102
  const mod = await import(conventionPath);
5098
- const [firstKey] = Object.keys(mod);
5099
- const ErrorComponent = mod.default ?? (firstKey ? mod[firstKey] : undefined);
5103
+ const ErrorComponent = mod.default;
5104
+ if (typeof ErrorComponent !== "function")
5105
+ return null;
5100
5106
  const element = createElement(ErrorComponent, errorProps);
5101
5107
  const stream = await renderToReadableStream(element);
5102
5108
  return new Response(stream, {
@@ -5108,6 +5114,8 @@ var renderSvelteError = async (conventionPath, errorProps) => {
5108
5114
  const { render } = await import("svelte/server");
5109
5115
  const mod = await import(conventionPath);
5110
5116
  const ErrorComponent = mod.default;
5117
+ if (!ErrorComponent)
5118
+ return null;
5111
5119
  const { head, body } = render(ErrorComponent, {
5112
5120
  props: errorProps
5113
5121
  });
@@ -5130,6 +5138,8 @@ var renderVueError = async (conventionPath, errorProps) => {
5130
5138
  const { renderToString } = await import("vue/server-renderer");
5131
5139
  const mod = await import(conventionPath);
5132
5140
  const ErrorComponent = mod.default;
5141
+ if (!ErrorComponent)
5142
+ return null;
5133
5143
  const app = createSSRApp({
5134
5144
  render: () => h(ErrorComponent, errorProps)
5135
5145
  });
@@ -5143,10 +5153,20 @@ var renderVueError = async (conventionPath, errorProps) => {
5143
5153
  };
5144
5154
  var renderAngularError = async (conventionPath, errorProps) => {
5145
5155
  const mod = await import(conventionPath);
5146
- const renderError = mod.default ?? mod.renderError;
5147
- if (typeof renderError !== "function")
5156
+ const renderFn = mod.default;
5157
+ if (typeof renderFn !== "function")
5148
5158
  return null;
5149
- const html = renderError(errorProps);
5159
+ const html = renderFn(errorProps);
5160
+ return new Response(html, {
5161
+ headers: { "Content-Type": "text/html" },
5162
+ status: 500
5163
+ });
5164
+ };
5165
+ var escapeHtml = (value) => value.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;").replace(/'/g, "&#39;");
5166
+ var replaceErrorTokens = (template, errorProps) => template.replace(/\{\{\s*name\s*\}\}/g, escapeHtml(errorProps.name)).replace(/\{\{\s*message\s*\}\}/g, escapeHtml(errorProps.message)).replace(/\{\{\s*stack\s*\}\}/g, errorProps.stack ? escapeHtml(errorProps.stack) : "");
5167
+ var renderHtmlError = async (conventionPath, errorProps) => {
5168
+ const template = await Bun.file(conventionPath).text();
5169
+ const html = replaceErrorTokens(template, errorProps);
5150
5170
  return new Response(html, {
5151
5171
  headers: { "Content-Type": "text/html" },
5152
5172
  status: 500
@@ -5165,11 +5185,12 @@ var renderEmberNotFound = async () => null;
5165
5185
  var ERROR_RENDERERS = {
5166
5186
  angular: renderAngularError,
5167
5187
  ember: renderEmberError,
5188
+ html: renderHtmlError,
5168
5189
  react: renderReactError,
5169
5190
  svelte: renderSvelteError,
5170
5191
  vue: renderVueError
5171
5192
  };
5172
- var renderConventionError = async (framework, pageName, error) => {
5193
+ var tryFrameworkErrorConvention = async (framework, pageName, errorProps, error) => {
5173
5194
  let conventionPath = resolveErrorConventionPath(framework, pageName);
5174
5195
  if (!conventionPath && error instanceof Error && error.stack) {
5175
5196
  for (const match of error.stack.matchAll(/^\s*at\s+([A-Za-z_$][\w$]*)/gm)) {
@@ -5183,7 +5204,6 @@ var renderConventionError = async (framework, pageName, error) => {
5183
5204
  }
5184
5205
  if (!conventionPath)
5185
5206
  return null;
5186
- const errorProps = buildErrorProps(error);
5187
5207
  const renderer = ERROR_RENDERERS[framework];
5188
5208
  if (!renderer)
5189
5209
  return null;
@@ -5194,12 +5214,25 @@ var renderConventionError = async (framework, pageName, error) => {
5194
5214
  }
5195
5215
  return null;
5196
5216
  };
5217
+ var renderConventionError = async (framework, pageName, error) => {
5218
+ const errorProps = buildErrorProps(error);
5219
+ const frameworkResponse = await tryFrameworkErrorConvention(framework, pageName, errorProps, error);
5220
+ if (frameworkResponse)
5221
+ return frameworkResponse;
5222
+ if (framework !== "html") {
5223
+ const htmlResponse = await tryFrameworkErrorConvention("html", pageName, errorProps, error);
5224
+ if (htmlResponse)
5225
+ return htmlResponse;
5226
+ }
5227
+ return null;
5228
+ };
5197
5229
  var renderReactNotFound = async (conventionPath) => {
5198
5230
  const { createElement } = await import("react");
5199
5231
  const { renderToReadableStream } = await import("react-dom/server");
5200
5232
  const mod = await import(conventionPath);
5201
- const [nfKey] = Object.keys(mod);
5202
- const NotFoundComponent = mod.default ?? (nfKey ? mod[nfKey] : undefined);
5233
+ const NotFoundComponent = mod.default;
5234
+ if (typeof NotFoundComponent !== "function")
5235
+ return null;
5203
5236
  const element = createElement(NotFoundComponent);
5204
5237
  const stream = await renderToReadableStream(element);
5205
5238
  return new Response(stream, {
@@ -5211,6 +5244,8 @@ var renderSvelteNotFound = async (conventionPath) => {
5211
5244
  const { render } = await import("svelte/server");
5212
5245
  const mod = await import(conventionPath);
5213
5246
  const NotFoundComponent = mod.default;
5247
+ if (!NotFoundComponent)
5248
+ return null;
5214
5249
  const { head, body } = render(NotFoundComponent);
5215
5250
  const html = `<!DOCTYPE html><html><head>${head}</head><body>${body}</body></html>`;
5216
5251
  return new Response(html, {
@@ -5223,6 +5258,8 @@ var renderVueNotFound = async (conventionPath) => {
5223
5258
  const { renderToString } = await import("vue/server-renderer");
5224
5259
  const mod = await import(conventionPath);
5225
5260
  const NotFoundComponent = mod.default;
5261
+ if (!NotFoundComponent)
5262
+ return null;
5226
5263
  const app = createSSRApp({
5227
5264
  render: () => h(NotFoundComponent)
5228
5265
  });
@@ -5236,10 +5273,17 @@ var renderVueNotFound = async (conventionPath) => {
5236
5273
  };
5237
5274
  var renderAngularNotFound = async (conventionPath) => {
5238
5275
  const mod = await import(conventionPath);
5239
- const renderNotFound = mod.default ?? mod.renderNotFound;
5240
- if (typeof renderNotFound !== "function")
5276
+ const renderFn = mod.default;
5277
+ if (typeof renderFn !== "function")
5241
5278
  return null;
5242
- const html = renderNotFound();
5279
+ const html = renderFn();
5280
+ return new Response(html, {
5281
+ headers: { "Content-Type": "text/html" },
5282
+ status: 404
5283
+ });
5284
+ };
5285
+ var renderHtmlNotFound = async (conventionPath) => {
5286
+ const html = await Bun.file(conventionPath).text();
5243
5287
  return new Response(html, {
5244
5288
  headers: { "Content-Type": "text/html" },
5245
5289
  status: 404
@@ -5248,6 +5292,7 @@ var renderAngularNotFound = async (conventionPath) => {
5248
5292
  var NOT_FOUND_RENDERERS = {
5249
5293
  angular: renderAngularNotFound,
5250
5294
  ember: renderEmberNotFound,
5295
+ html: renderHtmlNotFound,
5251
5296
  react: renderReactNotFound,
5252
5297
  svelte: renderSvelteNotFound,
5253
5298
  vue: renderVueNotFound
@@ -5270,7 +5315,8 @@ var NOT_FOUND_PRIORITY = [
5270
5315
  "react",
5271
5316
  "svelte",
5272
5317
  "vue",
5273
- "angular"
5318
+ "angular",
5319
+ "html"
5274
5320
  ];
5275
5321
  var renderFirstNotFound = async () => {
5276
5322
  const renderNext = async (frameworks) => {
@@ -5455,7 +5501,7 @@ var lowerAngularServerIslands = async (html) => {
5455
5501
  init_devRouteRegistrationCallsite();
5456
5502
 
5457
5503
  // src/angular/ssrSanitizer.ts
5458
- var escapeHtml = (str) => String(str).replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;");
5504
+ var escapeHtml2 = (str) => String(str).replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;");
5459
5505
  var bypassValue = (value) => ({
5460
5506
  changingThisBreaksApplicationSecurity: value
5461
5507
  });
@@ -5481,7 +5527,7 @@ var getSsrSanitizer = (deps) => {
5481
5527
  if (isTrustedHtml) {
5482
5528
  return strValue;
5483
5529
  }
5484
- return escapeHtml(strValue);
5530
+ return escapeHtml2(strValue);
5485
5531
  }
5486
5532
  return strValue;
5487
5533
  }
@@ -5820,5 +5866,5 @@ export {
5820
5866
  ABSOLUTE_HTTP_TRANSFER_CACHE_SKIP_HEADER
5821
5867
  };
5822
5868
 
5823
- //# debugId=9DA443ABFADD607864756E2164756E21
5869
+ //# debugId=73CF4660FF2BF51464756E2164756E21
5824
5870
  //# sourceMappingURL=server.js.map