@absolutejs/absolute 0.19.0-beta.766 → 0.19.0-beta.768

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.
@@ -3183,13 +3183,31 @@ var derivePageName = (pagePath) => {
3183
3183
  const name = dotIndex > 0 ? base.slice(0, dotIndex) : base;
3184
3184
  return toPascal(name);
3185
3185
  };
3186
+ var normalizeConventionPageName = (name) => toPascal(name).replace(/\d+$/, "");
3186
3187
  var resolveErrorConventionPath = (framework, pageName) => {
3187
3188
  const conventions = getMap()[framework];
3188
3189
  if (!conventions)
3189
3190
  return;
3190
- return conventions.pages?.[pageName]?.error ?? conventions.defaults?.error;
3191
+ const exact = conventions.pages?.[pageName]?.error;
3192
+ if (exact)
3193
+ return exact;
3194
+ const normalizedPageName = normalizeConventionPageName(pageName);
3195
+ for (const [candidate, page] of Object.entries(conventions.pages ?? {})) {
3196
+ if (normalizeConventionPageName(candidate) === normalizedPageName) {
3197
+ return page.error ?? conventions.defaults?.error;
3198
+ }
3199
+ }
3200
+ return conventions.defaults?.error;
3191
3201
  };
3192
3202
  var resolveNotFoundConventionPath = (framework) => getMap()[framework]?.defaults?.notFound;
3203
+ var hasErrorConvention = (framework) => {
3204
+ const conventions = getMap()[framework];
3205
+ if (!conventions)
3206
+ return false;
3207
+ if (conventions.defaults?.error)
3208
+ return true;
3209
+ return Object.values(conventions.pages ?? {}).some((page) => Boolean(page.error));
3210
+ };
3193
3211
  var setConventions = (map) => {
3194
3212
  Reflect.set(globalThis, CONVENTIONS_KEY, map);
3195
3213
  };
@@ -3275,7 +3293,17 @@ var ERROR_RENDERERS = {
3275
3293
  vue: renderVueError
3276
3294
  };
3277
3295
  var renderConventionError = async (framework, pageName, error) => {
3278
- const conventionPath = resolveErrorConventionPath(framework, pageName);
3296
+ let conventionPath = resolveErrorConventionPath(framework, pageName);
3297
+ if (!conventionPath && error instanceof Error && error.stack) {
3298
+ for (const match of error.stack.matchAll(/^\s*at\s+([A-Za-z_$][\w$]*)/gm)) {
3299
+ const candidate = match[1];
3300
+ if (!candidate)
3301
+ continue;
3302
+ conventionPath = resolveErrorConventionPath(framework, candidate);
3303
+ if (conventionPath)
3304
+ break;
3305
+ }
3306
+ }
3279
3307
  if (!conventionPath)
3280
3308
  return null;
3281
3309
  const errorProps = buildErrorProps(error);
@@ -3404,6 +3432,7 @@ var handleReactPageRequest = async (input) => {
3404
3432
  const resolvedIndex = input.index;
3405
3433
  const options = input;
3406
3434
  const maybeProps = input.props;
3435
+ const pageName = Page.name || Page.displayName || "";
3407
3436
  if (isSsrCacheDirty("react")) {
3408
3437
  return buildDirtyResponse(resolvedIndex, maybeProps);
3409
3438
  }
@@ -3423,14 +3452,19 @@ var handleReactPageRequest = async (input) => {
3423
3452
  }
3424
3453
  });
3425
3454
  const htmlStream = injectIslandPageContextStream(stream);
3455
+ if (resolveErrorConventionPath("react", pageName) || hasErrorConvention("react")) {
3456
+ const html = await new Response(htmlStream).text();
3457
+ return new Response(html, {
3458
+ headers: { "Content-Type": "text/html" }
3459
+ });
3460
+ }
3426
3461
  return new Response(htmlStream, {
3427
3462
  headers: { "Content-Type": "text/html" }
3428
3463
  });
3429
3464
  };
3430
- return runWithStreamingSlotWarningScope(() => options?.collectStreamingSlots === true ? withRegisteredStreamingSlots(renderPageResponse, options) : renderPageResponse(), { handlerCallsite });
3465
+ return await runWithStreamingSlotWarningScope(() => options?.collectStreamingSlots === true ? withRegisteredStreamingSlots(renderPageResponse, options) : renderPageResponse(), { handlerCallsite });
3431
3466
  } catch (error) {
3432
3467
  console.error("[SSR] React render error:", error);
3433
- const pageName = Page.name || Page.displayName || "";
3434
3468
  const conventionResponse = await renderConventionError("react", pageName, error);
3435
3469
  if (conventionResponse)
3436
3470
  return conventionResponse;
@@ -3604,5 +3638,5 @@ export {
3604
3638
  Island
3605
3639
  };
3606
3640
 
3607
- //# debugId=6DB9A702F811A8FF64756E2164756E21
3641
+ //# debugId=798CBDC2502C88F264756E2164756E21
3608
3642
  //# sourceMappingURL=index.js.map