@ecopages/core 0.2.0-rc.9 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (211) hide show
  1. package/README.md +39 -38
  2. package/package.json +22 -152
  3. package/src/adapters/README.md +11 -3
  4. package/src/adapters/abstract/application-adapter.d.ts +32 -36
  5. package/src/adapters/abstract/application-adapter.js +61 -47
  6. package/src/adapters/abstract/server-adapter.d.ts +14 -0
  7. package/src/adapters/abstract/server-adapter.js +10 -0
  8. package/src/adapters/abstract/ws-pattern-matcher.d.ts +0 -5
  9. package/src/adapters/abstract/ws-pattern-matcher.js +0 -9
  10. package/src/adapters/bun/create-app.d.ts +12 -16
  11. package/src/adapters/bun/create-app.js +25 -55
  12. package/src/adapters/bun/hmr-manager.d.ts +0 -1
  13. package/src/adapters/bun/hmr-manager.js +2 -4
  14. package/src/adapters/bun/server-adapter.d.ts +15 -21
  15. package/src/adapters/bun/server-adapter.js +33 -67
  16. package/src/adapters/bun/static-preview-host.d.ts +1 -0
  17. package/src/adapters/bun/static-preview-host.js +1 -1
  18. package/src/adapters/create-app.d.ts +63 -8
  19. package/src/adapters/create-app.js +62 -5
  20. package/src/adapters/node/create-app.d.ts +8 -12
  21. package/src/adapters/node/create-app.js +22 -14
  22. package/src/adapters/node/runtime-host.d.ts +10 -10
  23. package/src/adapters/node/runtime-host.js +13 -8
  24. package/src/adapters/node/server-adapter-dependencies.d.ts +2 -10
  25. package/src/adapters/node/server-adapter-dependencies.js +8 -13
  26. package/src/adapters/node/server-adapter.d.ts +30 -32
  27. package/src/adapters/node/server-adapter.js +59 -65
  28. package/src/adapters/shared/hmr/shared-hmr-manager.d.ts +0 -4
  29. package/src/adapters/shared/hmr/shared-hmr-manager.js +0 -12
  30. package/src/adapters/shared/http/api-request-pipeline.d.ts +27 -1
  31. package/src/adapters/shared/http/api-request-pipeline.js +31 -16
  32. package/src/adapters/shared/http/explicit-static-route-matcher.js +5 -2
  33. package/src/adapters/shared/http/fs-server-response-factory.d.ts +2 -9
  34. package/src/adapters/shared/http/fs-server-response-factory.js +5 -33
  35. package/src/adapters/shared/http/fs-server-response-matcher.d.ts +24 -24
  36. package/src/adapters/shared/http/fs-server-response-matcher.js +59 -83
  37. package/src/adapters/shared/runtime/application-adapter.d.ts +1 -0
  38. package/src/adapters/shared/runtime/application-adapter.js +12 -0
  39. package/src/adapters/shared/runtime/bind-runtime-server.d.ts +17 -0
  40. package/src/adapters/shared/runtime/bind-runtime-server.js +50 -0
  41. package/src/adapters/shared/runtime/collect-dev-prewarm-plan.d.ts +1 -3
  42. package/src/adapters/shared/runtime/collect-dev-prewarm-plan.js +1 -4
  43. package/src/adapters/shared/runtime/port-manager-default-prompt.d.ts +6 -0
  44. package/src/adapters/shared/runtime/port-manager-default-prompt.js +41 -0
  45. package/src/adapters/shared/runtime/port-manager.d.ts +3 -3
  46. package/src/adapters/shared/runtime/port-manager.js +14 -45
  47. package/src/adapters/shared/runtime/runtime-app-bootstrap.d.ts +0 -10
  48. package/src/adapters/shared/runtime/runtime-app-bootstrap.js +0 -7
  49. package/src/adapters/shared/runtime/runtime-host.d.ts +5 -2
  50. package/src/adapters/shared/runtime/runtime-server-lifecycle.d.ts +1 -1
  51. package/src/adapters/shared/runtime/runtime-server-lifecycle.js +1 -1
  52. package/src/adapters/shared/runtime/server-adapter.d.ts +26 -5
  53. package/src/adapters/shared/runtime/server-adapter.js +35 -8
  54. package/src/adapters/shared/runtime/server-route-handler.js +11 -3
  55. package/src/adapters/shared/runtime/server-static-builder.d.ts +9 -3
  56. package/src/adapters/shared/runtime/server-static-builder.js +59 -37
  57. package/src/adapters/shared/ws/node-http-websocket-upgrades.d.ts +9 -1
  58. package/src/adapters/shared/ws/node-http-websocket-upgrades.js +8 -2
  59. package/src/build/README.md +12 -8
  60. package/src/build/cache/cache-constants.d.ts +0 -2
  61. package/src/build/cache/cache-constants.js +0 -2
  62. package/src/build/cache/cache-keys.d.ts +0 -2
  63. package/src/build/cache/cache-keys.js +0 -2
  64. package/src/build/cache/output-imports.d.ts +35 -0
  65. package/src/build/cache/output-imports.js +87 -0
  66. package/src/build/cache/pages-unified-graph-build.d.ts +15 -1
  67. package/src/build/cache/pages-unified-graph-build.js +73 -22
  68. package/src/build/cache/production-build-cache.d.ts +2 -2
  69. package/src/build/cache/production-build-cache.js +2 -2
  70. package/src/build/cache/server-entry-build-cache.d.ts +25 -3
  71. package/src/build/cache/server-entry-build-cache.js +129 -13
  72. package/src/build/contracts/build-contracts.d.ts +1 -13
  73. package/src/build/rolldown/runtime-build-output-normalizer.js +3 -6
  74. package/src/build/runtime/build-request-identity.d.ts +2 -6
  75. package/src/build/runtime/build-request-identity.js +2 -8
  76. package/src/build/runtime/build-request-policy.js +1 -1
  77. package/src/build/runtime/deduping-build-executor.d.ts +0 -1
  78. package/src/build/runtime/deduping-build-executor.js +0 -1
  79. package/src/build/server-bundle-publication.d.ts +14 -0
  80. package/src/build/server-bundle-publication.js +49 -0
  81. package/src/cache/index.d.ts +1 -1
  82. package/src/cache/index.js +1 -1
  83. package/src/cache/module-parse-cache.d.ts +2 -29
  84. package/src/cache/module-parse-cache.js +6 -39
  85. package/src/config/README.md +17 -2
  86. package/src/config/apply-user-config.d.ts +8 -0
  87. package/src/config/apply-user-config.js +68 -0
  88. package/src/config/config-builder.d.ts +11 -1
  89. package/src/config/config-builder.js +53 -12
  90. package/src/config/constants.d.ts +4 -4
  91. package/src/config/constants.js +4 -4
  92. package/src/config/define-config.d.ts +9 -0
  93. package/src/config/define-config.js +10 -0
  94. package/src/config/index.d.ts +5 -0
  95. package/src/config/index.js +4 -0
  96. package/src/config/is-finalized-app-config.d.ts +6 -0
  97. package/src/config/is-finalized-app-config.js +11 -0
  98. package/src/config/load-eco-config.d.ts +21 -0
  99. package/src/config/load-eco-config.js +107 -0
  100. package/src/config/resolve-eco-config-path.d.ts +32 -0
  101. package/src/config/resolve-eco-config-path.js +58 -0
  102. package/src/config/server-config-bundle.d.ts +25 -0
  103. package/src/config/server-config-bundle.js +148 -0
  104. package/src/config/user-config-types.d.ts +170 -0
  105. package/src/config/user-config-types.js +1 -0
  106. package/src/dev/README.md +4 -0
  107. package/src/dev/development-restart-watch-paths.d.ts +13 -0
  108. package/src/dev/development-restart-watch-paths.js +37 -0
  109. package/src/dev/development-restart.d.ts +13 -0
  110. package/src/dev/development-restart.js +21 -0
  111. package/src/dev/host-runtime.d.ts +0 -1
  112. package/src/dev/host-runtime.js +0 -3
  113. package/src/dev/sc-server.d.ts +4 -1
  114. package/src/dev/sc-server.js +11 -20
  115. package/src/dev/transform-server/dev-transform-import-rewriter.js +2 -2
  116. package/src/eco/eco.js +4 -0
  117. package/src/errors/http-error-page-contract.d.ts +77 -0
  118. package/src/errors/http-error-page-contract.js +106 -0
  119. package/src/hmr/hmr-file-change-prep.d.ts +0 -1
  120. package/src/hmr/hmr-file-change-prep.js +2 -5
  121. package/src/hmr/hmr-strategy.d.ts +3 -8
  122. package/src/hmr/hmr-strategy.js +3 -8
  123. package/src/index.browser.d.ts +1 -2
  124. package/src/index.browser.js +1 -2
  125. package/src/index.d.ts +5 -6
  126. package/src/index.js +5 -6
  127. package/src/islands/island-host.d.ts +0 -9
  128. package/src/islands/island-host.js +1 -13
  129. package/src/plugins/component-import-discovery.js +2 -2
  130. package/src/plugins/eco-component-meta-plugin.js +5 -5
  131. package/src/plugins/integration-plugin.d.ts +0 -1
  132. package/src/plugins/integration-plugin.js +0 -4
  133. package/src/plugins/processor.d.ts +6 -2
  134. package/src/route-renderer/README.md +4 -0
  135. package/src/{adapters/shared/http/explicit-static-render-preparation.d.ts → route-renderer/explicit-view-render-preparation.d.ts} +3 -3
  136. package/src/route-renderer/orchestration/document-shell/document-shell-render.service.js +1 -4
  137. package/src/route-renderer/orchestration/foreign-child/foreign-subtree-execution.service.d.ts +25 -24
  138. package/src/route-renderer/orchestration/foreign-child/foreign-subtree-execution.service.js +18 -20
  139. package/src/route-renderer/orchestration/integration-renderer.d.ts +24 -7
  140. package/src/route-renderer/orchestration/integration-renderer.js +44 -33
  141. package/src/route-renderer/orchestration/integration-renderer.test-fixtures.js +1 -1
  142. package/src/route-renderer/orchestration/page-browser-graph/page-browser-graph-session.d.ts +1 -1
  143. package/src/route-renderer/orchestration/page-browser-graph/page-browser-graph-session.js +1 -1
  144. package/src/route-renderer/route-renderer.d.ts +9 -0
  145. package/src/route-renderer/route-renderer.js +18 -0
  146. package/src/services/README.md +2 -1
  147. package/src/services/assets/browser-bundle.service.d.ts +1 -6
  148. package/src/services/error-pages/README.md +9 -0
  149. package/src/services/error-pages/default-error-pages.d.ts +39 -0
  150. package/src/services/error-pages/default-error-pages.js +199 -0
  151. package/src/services/error-pages/error-page-renderer.d.ts +58 -0
  152. package/src/services/error-pages/error-page-renderer.js +146 -0
  153. package/src/services/error-pages/semantic-error-page-exporter.d.ts +23 -0
  154. package/src/services/error-pages/semantic-error-page-exporter.js +35 -0
  155. package/src/services/html/html-rewriter.d.ts +77 -0
  156. package/src/services/html/html-rewriter.js +751 -0
  157. package/src/services/html/html-rewriter.parity.test.bun.d.ts +1 -0
  158. package/src/services/html/html-rewriter.parity.test.bun.js +74 -0
  159. package/src/services/html/html-transformer.service.d.ts +29 -42
  160. package/src/services/html/html-transformer.service.js +85 -157
  161. package/src/services/invalidation/development-invalidation.service.d.ts +9 -20
  162. package/src/services/invalidation/development-invalidation.service.js +26 -39
  163. package/src/services/module-loading/README.md +20 -15
  164. package/src/services/module-loading/app-module-loader.service.d.ts +0 -2
  165. package/src/services/module-loading/app-server-module-transpiler.service.d.ts +1 -1
  166. package/src/services/module-loading/app-server-module-transpiler.service.js +2 -10
  167. package/src/services/module-loading/collection-server-module-build.service.d.ts +0 -1
  168. package/src/services/module-loading/collection-server-module-build.service.js +0 -3
  169. package/src/services/module-loading/host-module-loader-registry.d.ts +0 -1
  170. package/src/services/module-loading/host-module-loader-registry.js +0 -3
  171. package/src/services/module-loading/route-module-build-cache-registry.d.ts +0 -4
  172. package/src/services/module-loading/route-module-build-cache-registry.js +0 -4
  173. package/src/services/module-loading/route-module-build-cache.store.d.ts +8 -0
  174. package/src/services/module-loading/route-module-build-cache.store.js +25 -7
  175. package/src/services/module-loading/route-module-build-manifest.d.ts +12 -1
  176. package/src/services/module-loading/route-module-build-manifest.js +7 -3
  177. package/src/services/module-loading/route-module-dependency-hasher.d.ts +3 -2
  178. package/src/services/module-loading/route-module-dependency-hasher.js +13 -1
  179. package/src/services/module-loading/server-module-transpiler.service.d.ts +1 -15
  180. package/src/services/module-loading/server-module-transpiler.service.js +0 -24
  181. package/src/services/module-loading/view-module-loader.d.ts +10 -0
  182. package/src/services/module-loading/view-module-loader.js +46 -0
  183. package/src/services/runtime-state/entrypoint-dependency-graph.service.js +0 -12
  184. package/src/services/runtime-state/server-invalidation-state.service.d.ts +4 -2
  185. package/src/services/runtime-state/server-invalidation-state.service.js +7 -14
  186. package/src/static-site-generator/README.md +12 -8
  187. package/src/static-site-generator/static-site-generator.d.ts +3 -2
  188. package/src/static-site-generator/static-site-generator.js +17 -3
  189. package/src/types/internal-types.d.ts +1 -38
  190. package/src/types/public-types.d.ts +28 -130
  191. package/src/watchers/project-watcher.d.ts +9 -16
  192. package/src/watchers/project-watcher.js +35 -28
  193. package/src/watchers/project-watcher.test-helpers.d.ts +10 -1
  194. package/src/watchers/project-watcher.test-helpers.js +12 -0
  195. package/src/adapters/abstract/router-adapter.d.ts +0 -26
  196. package/src/adapters/abstract/router-adapter.js +0 -13
  197. package/src/adapters/bun/index.d.ts +0 -2
  198. package/src/adapters/bun/index.js +0 -2
  199. package/src/adapters/index.d.ts +0 -2
  200. package/src/adapters/index.js +0 -2
  201. package/src/eco/eco.utils.d.ts +0 -1
  202. package/src/eco/eco.utils.js +0 -1
  203. package/src/services/cache/index.d.ts +0 -9
  204. package/src/services/cache/index.js +0 -8
  205. package/src/services/html/html-rewriter-provider.service.d.ts +0 -40
  206. package/src/services/html/html-rewriter-provider.service.js +0 -68
  207. package/src/services/module-loading/route-module-build-cache.d.ts +0 -4
  208. package/src/services/module-loading/route-module-build-cache.js +0 -3
  209. package/src/services/runtime-state/dev-graph.service.d.ts +0 -118
  210. package/src/services/runtime-state/dev-graph.service.js +0 -170
  211. /package/src/{adapters/shared/http/explicit-static-render-preparation.js → route-renderer/explicit-view-render-preparation.js} +0 -0
@@ -15,7 +15,7 @@ import { RouteRenderOrchestrator, type RouteRenderOrchestratorAdapter, type Rout
15
15
  import { type ResolvedPageDependencies } from '../page-loading/resolved-page-dependencies.js';
16
16
  import { type GroupedGraphBuildPlan } from './page-browser-graph/grouped-graph-build-plan.js';
17
17
  import type { ForeignChildRuntime } from './foreign-child/component-render-context.js';
18
- import { ForeignSubtreeExecutionService } from './foreign-child/foreign-subtree-execution.service.js';
18
+ import { ForeignSubtreeExecutionService, type ForeignSubtreeExecutionOwningRenderer, type QueuedForeignSubtreeResolutionContext, type RenderQueuedForeignSubtreeChildren } from './foreign-child/foreign-subtree-execution.service.js';
19
19
  import { type DocumentShellLayoutInput } from './document-shell/document-shell-render.service.js';
20
20
  /**
21
21
  * Controls how one route module is loaded outside the normal render path.
@@ -325,7 +325,6 @@ export declare abstract class IntegrationRenderer<C = EcoPagesElement> {
325
325
  * other runtime coordination markers without relying on script sniffing.
326
326
  */
327
327
  protected getDocumentAttributes(_renderOptions: IntegrationRendererRenderOptions<C>): Record<string, string> | undefined;
328
- protected applyAttributesToFirstBodyElement(html: string, attributes: Record<string, string>): string;
329
328
  protected applyAttributesToHtmlElement(html: string, attributes: Record<string, string>): string;
330
329
  /**
331
330
  * Returns declarative HTML fragments that core should inject into the final document.
@@ -354,6 +353,29 @@ export declare abstract class IntegrationRenderer<C = EcoPagesElement> {
354
353
  * renderer's nested foreign-child handoff.
355
354
  */
356
355
  renderComponentWithForeignChildren(input: InternalComponentRenderInput): Promise<ComponentRenderResult>;
356
+ /**
357
+ * Returns the renderer that owns `integrationName`, reusing `rendererCache`
358
+ * for the current render.
359
+ */
360
+ protected resolveOwningRenderer(integrationName: string, rendererCache: Map<string, ForeignSubtreeExecutionOwningRenderer>): Promise<ForeignSubtreeExecutionOwningRenderer>;
361
+ /**
362
+ * Returns the queued foreign-subtree state this renderer keeps on `input`, or
363
+ * `undefined` when nothing was queued for it.
364
+ */
365
+ protected getQueuedForeignSubtreeContext<TContext extends QueuedForeignSubtreeResolutionContext = QueuedForeignSubtreeResolutionContext>(input: ComponentRenderInput): TContext | undefined;
366
+ /**
367
+ * Replaces the foreign-subtree tokens queued while rendering `html` with the
368
+ * HTML each owning renderer produces.
369
+ *
370
+ * @remarks
371
+ * `renderQueuedChildren` renders a subtree's children inside this renderer
372
+ * before the owning renderer renders the subtree around them. The returned
373
+ * assets are the owning renderers' assets, deduplicated.
374
+ */
375
+ protected resolveQueuedForeignSubtrees<TContext extends QueuedForeignSubtreeResolutionContext>(html: string, runtimeContext: TContext | undefined, renderQueuedChildren: RenderQueuedForeignSubtreeChildren<TContext>): Promise<{
376
+ assets: ProcessedAsset[];
377
+ html: string;
378
+ }>;
357
379
  protected finalizeIslandComponentRender(input: ComponentRenderInput, result: ComponentRenderResult): ComponentRenderResult;
358
380
  private normalizeComponentRenderOutput;
359
381
  protected normalizeUnresolvedMarkerArtifactHtml(html: string): string;
@@ -424,9 +446,4 @@ export declare abstract class IntegrationRenderer<C = EcoPagesElement> {
424
446
  renderInput: ComponentRenderInput;
425
447
  rendererCache: Map<string, IntegrationRenderer<any>>;
426
448
  }): ForeignChildRuntime;
427
- /**
428
- * Creates an explicit fail-fast runtime for tests or renderers that do not
429
- * support cross-integration foreign-child execution.
430
- */
431
- protected createFailFastForeignChildRuntime(): ForeignChildRuntime;
432
449
  }
@@ -22,7 +22,7 @@ import { normalizeUnresolvedMarkerArtifactHtml } from './route-pipeline/marker-a
22
22
  import { isMarkupNodeLike } from './foreign-child/foreign-child-output.utils.js';
23
23
  import { getForeignSubtreeResolutionContextKey, getForeignSubtreeTokenPrefix, resolveOwningIntegrationRenderer, } from './foreign-child/owning-renderer-resolution.js';
24
24
  import { ensureIntegrationRuntimeReady } from '../../build/app-build-manifest-runtime.js';
25
- import { ForeignSubtreeExecutionService } from './foreign-child/foreign-subtree-execution.service.js';
25
+ import { ForeignSubtreeExecutionService, } from './foreign-child/foreign-subtree-execution.service.js';
26
26
  import { composeDocumentShell, finalizeDocumentShellHtml, renderPageDocumentShell, } from './document-shell/document-shell-render.service.js';
27
27
  import { resolveInnermostPageLayout, resolvePageLayoutComponents, } from './document-shell/layout-shell-props.service.js';
28
28
  import { finalizeIslandComponentRender } from '../../islands/island-host.js';
@@ -421,20 +421,9 @@ export class IntegrationRenderer {
421
421
  const componentRender = await this.renderStringComponentWithSerializedChildren(input, component);
422
422
  const queuedForeignSubtreeResolution = await this.foreignSubtreeExecutionService.resolveStringQueuedHtml({
423
423
  currentIntegrationName: this.name,
424
- renderInput: input,
425
424
  html: componentRender.html,
426
- runtimeContextKey: getForeignSubtreeResolutionContextKey(this.name),
427
- queueLabel: 'String',
428
- getOwningRenderer: (integrationName, rendererCache) => resolveOwningIntegrationRenderer({
429
- appConfig: this.appConfig,
430
- runtimeOrigin: this.runtimeOrigin,
431
- currentIntegrationName: this.name,
432
- currentRenderer: this,
433
- integrationName,
434
- cache: rendererCache,
435
- }),
436
- applyAttributesToFirstElement: (html, attributes) => this.htmlTransformer.applyAttributesToFirstElement(html, attributes),
437
- dedupeProcessedAssets: (assets) => this.htmlTransformer.dedupeProcessedAssets(assets),
425
+ runtimeContext: this.getQueuedForeignSubtreeContext(input),
426
+ getOwningRenderer: (integrationName, rendererCache) => this.resolveOwningRenderer(integrationName, rendererCache),
438
427
  });
439
428
  const mergedAssets = this.htmlTransformer.dedupeProcessedAssets([
440
429
  ...(componentRender.assets ?? []),
@@ -547,7 +536,7 @@ export class IntegrationRenderer {
547
536
  applyAttributesToHtmlElement: (html, attributes) => this.applyAttributesToHtmlElement(html, attributes),
548
537
  transformRouteResponse: async (response, htmlContributions, pagePackage) => {
549
538
  const resolvedPagePackage = this.htmlTransformer.getPagePackage() ?? pagePackage;
550
- const transformedResponse = await this.htmlTransformer.transform(response, htmlContributions, resolvedPagePackage);
539
+ const transformedResponse = this.htmlTransformer.transform(response, htmlContributions, resolvedPagePackage);
551
540
  return (transformedResponse.body ?? (await transformedResponse.text()));
552
541
  },
553
542
  });
@@ -670,9 +659,6 @@ export class IntegrationRenderer {
670
659
  getDocumentAttributes(_renderOptions) {
671
660
  return undefined;
672
661
  }
673
- applyAttributesToFirstBodyElement(html, attributes) {
674
- return this.htmlTransformer.applyAttributesToFirstBodyElement(html, attributes);
675
- }
676
662
  applyAttributesToHtmlElement(html, attributes) {
677
663
  return this.htmlTransformer.applyAttributesToHtmlElement(html, attributes);
678
664
  }
@@ -707,14 +693,46 @@ export class IntegrationRenderer {
707
693
  renderInput,
708
694
  rendererCache: rendererCache,
709
695
  }),
710
- getOwningRenderer: (integrationName, rendererCache) => resolveOwningIntegrationRenderer({
711
- appConfig: this.appConfig,
712
- runtimeOrigin: this.runtimeOrigin,
713
- currentIntegrationName: this.name,
714
- currentRenderer: this,
715
- integrationName,
716
- cache: rendererCache,
717
- }),
696
+ getOwningRenderer: (integrationName, rendererCache) => this.resolveOwningRenderer(integrationName, rendererCache),
697
+ });
698
+ }
699
+ /**
700
+ * Returns the renderer that owns `integrationName`, reusing `rendererCache`
701
+ * for the current render.
702
+ */
703
+ resolveOwningRenderer(integrationName, rendererCache) {
704
+ return resolveOwningIntegrationRenderer({
705
+ appConfig: this.appConfig,
706
+ runtimeOrigin: this.runtimeOrigin,
707
+ currentIntegrationName: this.name,
708
+ currentRenderer: this,
709
+ integrationName,
710
+ cache: rendererCache,
711
+ });
712
+ }
713
+ /**
714
+ * Returns the queued foreign-subtree state this renderer keeps on `input`, or
715
+ * `undefined` when nothing was queued for it.
716
+ */
717
+ getQueuedForeignSubtreeContext(input) {
718
+ return this.foreignSubtreeExecutionService.getQueuedRuntimeContext(input, getForeignSubtreeResolutionContextKey(this.name));
719
+ }
720
+ /**
721
+ * Replaces the foreign-subtree tokens queued while rendering `html` with the
722
+ * HTML each owning renderer produces.
723
+ *
724
+ * @remarks
725
+ * `renderQueuedChildren` renders a subtree's children inside this renderer
726
+ * before the owning renderer renders the subtree around them. The returned
727
+ * assets are the owning renderers' assets, deduplicated.
728
+ */
729
+ resolveQueuedForeignSubtrees(html, runtimeContext, renderQueuedChildren) {
730
+ return this.foreignSubtreeExecutionService.resolveQueuedHtml({
731
+ currentIntegrationName: this.name,
732
+ html,
733
+ runtimeContext,
734
+ renderQueuedChildren,
735
+ getOwningRenderer: (integrationName, rendererCache) => this.resolveOwningRenderer(integrationName, rendererCache),
718
736
  });
719
737
  }
720
738
  finalizeIslandComponentRender(input, result) {
@@ -809,11 +827,4 @@ export class IntegrationRenderer {
809
827
  tokenPrefix: getForeignSubtreeTokenPrefix(this.name),
810
828
  });
811
829
  }
812
- /**
813
- * Creates an explicit fail-fast runtime for tests or renderers that do not
814
- * support cross-integration foreign-child execution.
815
- */
816
- createFailFastForeignChildRuntime() {
817
- return this.foreignSubtreeExecutionService.createFailFastRuntime(this.name);
818
- }
819
830
  }
@@ -163,7 +163,7 @@ export class TestIntegrationRenderer extends IntegrationRenderer {
163
163
  createForeignChildRuntime(options) {
164
164
  this.ForeignChildRuntimeCreationCount += 1;
165
165
  if (this.UseFailFastForeignChildRuntime) {
166
- return this.createFailFastForeignChildRuntime();
166
+ return this.foreignSubtreeExecutionService.createFailFastRuntime(this.name);
167
167
  }
168
168
  return super.createForeignChildRuntime(options);
169
169
  }
@@ -110,7 +110,7 @@ export declare function getAppPageBrowserGraphSession(appConfig: EcoPagesAppConf
110
110
  /**
111
111
  * Invalidates graph records that depend on the changed file path.
112
112
  */
113
- export declare function invalidatePageBrowserGraphSession(appConfig: EcoPagesAppConfig, filePath: string): number;
113
+ export declare function invalidatePageBrowserGraphSession(appConfig: EcoPagesAppConfig, filePath: string): void;
114
114
  /**
115
115
  * Returns graph identities affected by a source file change.
116
116
  */
@@ -474,7 +474,7 @@ export function getAppPageBrowserGraphSession(appConfig) {
474
474
  * Invalidates graph records that depend on the changed file path.
475
475
  */
476
476
  export function invalidatePageBrowserGraphSession(appConfig, filePath) {
477
- return getAppPageBrowserGraphSession(appConfig).invalidateByFilePath(filePath);
477
+ getAppPageBrowserGraphSession(appConfig).invalidateByFilePath(filePath);
478
478
  }
479
479
  /**
480
480
  * Returns graph identities affected by a source file change.
@@ -49,6 +49,15 @@ export declare class RouteRendererFactory {
49
49
  rendererModules?: unknown;
50
50
  runtimeOrigin: string;
51
51
  });
52
+ /**
53
+ * Rebinds renderer creation to the actual listening origin.
54
+ *
55
+ * @remarks
56
+ * A development server may select a fallback port after this factory is
57
+ * constructed. Cached renderers retain their original page-module loader, so
58
+ * they must be discarded when the origin changes.
59
+ */
60
+ setRuntimeOrigin(runtimeOrigin: string): void;
52
61
  /**
53
62
  * Returns a route renderer for the supplied route file.
54
63
  */
@@ -21,6 +21,24 @@ export class RouteRendererFactory {
21
21
  this.rendererModules = rendererModules;
22
22
  this.runtimeOrigin = runtimeOrigin;
23
23
  }
24
+ /**
25
+ * Rebinds renderer creation to the actual listening origin.
26
+ *
27
+ * @remarks
28
+ * A development server may select a fallback port after this factory is
29
+ * constructed. Cached renderers retain their original page-module loader, so
30
+ * they must be discarded when the origin changes.
31
+ */
32
+ setRuntimeOrigin(runtimeOrigin) {
33
+ if (this.runtimeOrigin === runtimeOrigin) {
34
+ return;
35
+ }
36
+ this.runtimeOrigin = runtimeOrigin;
37
+ this.rendererCache.clear();
38
+ for (const integration of this.appConfig.integrations) {
39
+ integration.setRuntimeOrigin?.(runtimeOrigin);
40
+ }
41
+ }
24
42
  /**
25
43
  * Returns a route renderer for the supplied route file.
26
44
  */
@@ -22,7 +22,8 @@ Typical responsibilities include:
22
22
  - `invalidation/`: file-change classification and invalidation policy
23
23
  - `runtime-state/`: app-owned invalidation state and dependency graphs
24
24
  - `runtime-manifest/`: node runtime manifest derivation and persistence
25
- - `html/`: final HTML dependency injection and rewriter selection
25
+ - `html/`: final HTML dependency injection and attribute stamping through `HtmlRewriter`, an in-house streaming rewriter with a subset of Bun's `HTMLRewriter` API that matches lol-html output (tag-name selectors; `before`/`prepend`/`append`/`after`; attributes). It runs the same way on Bun and Node, and `html-rewriter.parity.test.bun.ts` checks it against the native rewriter.
26
+ - `error-pages/`: shared semantic 404/500 source precedence, rendering, built-in documents, and static export artifacts
26
27
 
27
28
  The asset-processing service caches emitted file assets by source identity in development as well as production.
28
29
  When a source file changes, its source hash or explicit invalidation removes the cached asset before the next render,
@@ -22,7 +22,6 @@ import type { EcoPagesAppConfig } from '../../types/internal-types.js';
22
22
  export type BrowserBundleOptions = {
23
23
  entrypoints: string[] | Record<string, string>;
24
24
  outdir?: string;
25
- outbase?: string;
26
25
  naming?: string;
27
26
  conditions?: string[];
28
27
  define?: Record<string, string>;
@@ -30,7 +29,6 @@ export type BrowserBundleOptions = {
30
29
  treeshaking?: boolean;
31
30
  splitting?: boolean;
32
31
  root?: string;
33
- bundle?: boolean;
34
32
  externalPackages?: boolean;
35
33
  external?: string[];
36
34
  plugins?: EcoBuildPlugin[];
@@ -39,9 +37,6 @@ export type BrowserBundleOptions = {
39
37
  excludeAppBuildPlugins?: string[];
40
38
  };
41
39
  type BrowserBundleGroupedOptions = Omit<BrowserBundleOptions, 'entrypoints'>;
42
- export interface BrowserBundleExecutor {
43
- bundle(options: BrowserBundleOptions): Promise<BuildResult>;
44
- }
45
40
  export type BrowserBundleGroupedEntry = {
46
41
  entrypoint: string;
47
42
  entryName: string;
@@ -54,7 +49,7 @@ export type BrowserBundleGroupedEntry = {
54
49
  * the app-owned executor rather than direct backend calls. Assembles a complete
55
50
  * request via {@link createBrowserBuildRequest} before scheduling.
56
51
  */
57
- export declare class BrowserBundleService implements BrowserBundleExecutor {
52
+ export declare class BrowserBundleService {
58
53
  private readonly appConfig;
59
54
  constructor(appConfig: EcoPagesAppConfig);
60
55
  /**
@@ -0,0 +1,9 @@
1
+ # Error pages
2
+
3
+ This directory owns semantic 404/500 page behavior shared by request-time rendering and static export.
4
+
5
+ - `error-page-renderer.ts` applies filesystem → registered-loader → built-in precedence. Registered views reuse `prepareExplicitStaticRender`. Callers that need a guaranteed built-in document after a custom-page failure use `renderBuiltIn()`. Static export asks `resolveSourceFile()` before rendering so unchanged sources can skip work.
6
+ - `default-error-pages.ts` renders self-contained fallback documents with development-only diagnostics.
7
+ - `semantic-error-page-exporter.ts` writes `/404.html` and `/500.html` exactly once during static export.
8
+
9
+ Runtime adapters only wrap the rendered body in an HTTP response; they do not decide error-page source precedence.
@@ -0,0 +1,39 @@
1
+ /** Stable class hooks exposed by the framework-owned error documents. */
2
+ export declare const DEFAULT_ERROR_PAGE_CLASS_NAMES: {
3
+ readonly root: "eco-error-page";
4
+ readonly notFoundModifier: "eco-error-page--not-found";
5
+ readonly serverErrorModifier: "eco-error-page--server-error";
6
+ readonly badRequestModifier: "eco-error-page--bad-request";
7
+ readonly unauthorizedModifier: "eco-error-page--unauthorized";
8
+ readonly forbiddenModifier: "eco-error-page--forbidden";
9
+ readonly conflictModifier: "eco-error-page--conflict";
10
+ readonly content: "eco-error-page__content";
11
+ readonly status: "eco-error-page__status";
12
+ readonly title: "eco-error-page__title";
13
+ readonly message: "eco-error-page__message";
14
+ readonly diagnostics: "eco-error-page__diagnostics";
15
+ readonly diagnosticsHeader: "eco-error-page__diagnostics-header";
16
+ readonly diagnosticsLabel: "eco-error-page__diagnostics-label";
17
+ readonly stack: "eco-error-page__stack";
18
+ readonly copyButton: "eco-error-page__copy";
19
+ readonly copyButtonCopied: "eco-error-page__copy--copied";
20
+ readonly copyButtonFailed: "eco-error-page__copy--failed";
21
+ readonly copyIcon: "eco-error-page__copy-icon";
22
+ readonly copyIconClipboard: "eco-error-page__copy-icon--clipboard";
23
+ readonly copyIconSuccess: "eco-error-page__copy-icon--success";
24
+ readonly copyLabel: "eco-error-page__copy-label";
25
+ };
26
+ export type DefaultErrorPageDetails = {
27
+ message?: string;
28
+ stack?: string;
29
+ };
30
+ /**
31
+ * Self-contained HTML for a framework default error response.
32
+ *
33
+ * @remarks
34
+ * Development 5xx pages may include escaped `message` / `stack` and a copy
35
+ * button. 4xx pages never serialize a stack.
36
+ */
37
+ export declare function buildDefaultErrorHtml(status: number, details?: DefaultErrorPageDetails): string;
38
+ export declare function getDefaultServerErrorDetails(error: unknown): DefaultErrorPageDetails | undefined;
39
+ export declare function getPublicErrorMessage(error: unknown): string | undefined;
@@ -0,0 +1,199 @@
1
+ import { isDevelopmentRuntime } from '../../utils/runtime.js';
2
+ import { ERROR_PAGE_COPY, isHttpErrorPageStatus, isHttpErrorStatus } from '../../errors/http-error-page-contract.js';
3
+ function escapeHtml(value) {
4
+ return value
5
+ .replaceAll('&', '&amp;')
6
+ .replaceAll('<', '&lt;')
7
+ .replaceAll('>', '&gt;')
8
+ .replaceAll('"', '&quot;')
9
+ .replaceAll("'", '&#39;');
10
+ }
11
+ /** Stable class hooks exposed by the framework-owned error documents. */
12
+ export const DEFAULT_ERROR_PAGE_CLASS_NAMES = {
13
+ root: 'eco-error-page',
14
+ notFoundModifier: 'eco-error-page--not-found',
15
+ serverErrorModifier: 'eco-error-page--server-error',
16
+ badRequestModifier: 'eco-error-page--bad-request',
17
+ unauthorizedModifier: 'eco-error-page--unauthorized',
18
+ forbiddenModifier: 'eco-error-page--forbidden',
19
+ conflictModifier: 'eco-error-page--conflict',
20
+ content: 'eco-error-page__content',
21
+ status: 'eco-error-page__status',
22
+ title: 'eco-error-page__title',
23
+ message: 'eco-error-page__message',
24
+ diagnostics: 'eco-error-page__diagnostics',
25
+ diagnosticsHeader: 'eco-error-page__diagnostics-header',
26
+ diagnosticsLabel: 'eco-error-page__diagnostics-label',
27
+ stack: 'eco-error-page__stack',
28
+ copyButton: 'eco-error-page__copy',
29
+ copyButtonCopied: 'eco-error-page__copy--copied',
30
+ copyButtonFailed: 'eco-error-page__copy--failed',
31
+ copyIcon: 'eco-error-page__copy-icon',
32
+ copyIconClipboard: 'eco-error-page__copy-icon--clipboard',
33
+ copyIconSuccess: 'eco-error-page__copy-icon--success',
34
+ copyLabel: 'eco-error-page__copy-label',
35
+ };
36
+ const sharedStyles = `
37
+ .eco-error-page { box-sizing: border-box; display: grid; place-items: center; margin: 0; padding: 2rem; color: #18181b; background: radial-gradient(circle at top, #f4f4f5, #fff 42rem); font-family: ui-sans-serif, system-ui, sans-serif; line-height: 1.5; }
38
+ .eco-error-page__content { width: min(100%, 42rem); padding: clamp(2rem, 8vw, 4.5rem); border: 1px solid #e4e4e7; border-radius: 1rem; background: #fff; }
39
+ .eco-error-page__status { margin: 0 0 1rem; color: #71717a; font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace; font-size: .75rem; font-weight: 700; letter-spacing: .12em; }
40
+ .eco-error-page__title { margin: 0; font-size: clamp(2rem, 6vw, 3.5rem); font-weight: 650; letter-spacing: -.05em; line-height: 1.05; }
41
+ .eco-error-page__message { max-width: 36rem; margin: 1rem 0 0; color: #52525b; font-size: 1rem; }
42
+ .eco-error-page__diagnostics { margin-top: 2rem; border: 1px solid #e4e4e7; border-radius: .75rem; overflow: hidden; background: #fafafa; }
43
+ .eco-error-page__diagnostics-header { display: flex; align-items: center; justify-content: space-between; gap: 1rem; min-height: 3rem; padding: 0 .75rem 0 1rem; border-bottom: 1px solid #e4e4e7; background: #fff; }
44
+ .eco-error-page__diagnostics-label { color: #52525b; font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace; font-size: .75rem; font-weight: 650; }
45
+ .eco-error-page__stack { max-height: 22rem; overflow: auto; box-sizing: border-box; margin: 0; padding: 1rem; color: #3f3f46; font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace; font-size: .8125rem; line-height: 1.65; white-space: pre-wrap; word-break: break-word; }
46
+ .eco-error-page__copy { font: inherit; cursor: pointer; display: inline-flex; align-items: center; gap: .5rem; min-height: 2rem; padding: .375rem .625rem; border: 1px solid #d4d4d8; border-radius: .4375rem; color: #3f3f46; background: #fff; font-size: .8125rem; font-weight: 600; transition: border-color .15s ease, background-color .15s ease, color .15s ease; }
47
+ .eco-error-page__copy:hover { border-color: #a1a1aa; background: #fafafa; }
48
+ .eco-error-page__copy--copied { border-color: #86efac; background: #f0fdf4; color: #166534; }
49
+ .eco-error-page__copy--failed { border-color: #fecaca; background: #fef2f2; color: #b91c1c; }
50
+ .eco-error-page__copy-icon { display: inline-flex; flex-shrink: 0; width: 1rem; height: 1rem; }
51
+ .eco-error-page__copy-icon svg { display: block; width: 100%; height: 100%; }
52
+ .eco-error-page__copy-icon--success { display: none; }
53
+ .eco-error-page__copy--copied .eco-error-page__copy-icon--clipboard { display: none; }
54
+ .eco-error-page__copy--copied .eco-error-page__copy-icon--success { display: inline-flex; }
55
+ .eco-error-page__copy:focus-visible { outline: 2px solid #2563eb; outline-offset: 2px; }
56
+ @media (max-width: 40rem) { .eco-error-page { padding: 1rem; } .eco-error-page__content { padding: 2rem 1.5rem; border-radius: .75rem; } }
57
+ @media (prefers-color-scheme: dark) { .eco-error-page { color: #f4f4f5; background: radial-gradient(circle at top, #27272a, #09090b 42rem); } .eco-error-page__content { border-color: #3f3f46; background: #18181b; } .eco-error-page__status, .eco-error-page__message { color: #a1a1aa; } .eco-error-page__diagnostics { border-color: #3f3f46; background: #18181b; } .eco-error-page__diagnostics-header { border-color: #3f3f46; background: #27272a; } .eco-error-page__diagnostics-label, .eco-error-page__stack { color: #d4d4d8; } .eco-error-page__copy { border-color: #52525b; color: #e4e4e7; background: #27272a; } .eco-error-page__copy:hover { border-color: #a1a1aa; background: #3f3f46; } .eco-error-page__copy--copied { border-color: #166534; background: #052e16; color: #bbf7d0; } .eco-error-page__copy--failed { border-color: #991b1b; background: #450a0a; color: #fecaca; } }
58
+ `.trim();
59
+ const clipboardIconSvg = '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><rect width="8" height="4" x="8" y="2" rx="1" ry="1"/><path d="M16 4h2a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2h2"/></svg>';
60
+ const checkIconSvg = '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M20 6 9 17l-5-5"/></svg>';
61
+ function buildDefaultCopyButtonMarkup(copyPayload) {
62
+ const names = DEFAULT_ERROR_PAGE_CLASS_NAMES;
63
+ return `<pre id="eco-copy-error-payload" hidden>${escapeHtml(copyPayload)}</pre>
64
+ <button type="button" class="${names.copyButton}" id="eco-copy-error" aria-label="Copy error details to clipboard">
65
+ <span class="${names.copyIcon} ${names.copyIconClipboard}" aria-hidden="true">${clipboardIconSvg}</span>
66
+ <span class="${names.copyIcon} ${names.copyIconSuccess}" aria-hidden="true">${checkIconSvg}</span>
67
+ <span class="${names.copyLabel}" aria-live="polite">Copy error</span>
68
+ </button>
69
+ <script>
70
+ (function () {
71
+ var button = document.getElementById('eco-copy-error');
72
+ var payload = document.getElementById('eco-copy-error-payload');
73
+ if (!button || !payload) return;
74
+ var label = button.querySelector('.${names.copyLabel}');
75
+ var text = payload.textContent || '';
76
+ var resetTimer;
77
+ function setState(state) {
78
+ button.classList.toggle('${names.copyButtonCopied}', state === 'copied');
79
+ button.classList.toggle('${names.copyButtonFailed}', state === 'failed');
80
+ if (label) label.textContent = state === 'copied' ? 'Copied' : state === 'failed' ? 'Copy failed' : 'Copy error';
81
+ button.setAttribute('aria-label', state === 'copied' ? 'Error details copied' : state === 'failed' ? 'Could not copy error details' : 'Copy error details to clipboard');
82
+ }
83
+ function fallbackCopy(value) {
84
+ var area = document.createElement('textarea');
85
+ area.value = value;
86
+ area.setAttribute('readonly', '');
87
+ area.style.position = 'absolute';
88
+ area.style.left = '-9999px';
89
+ document.body.appendChild(area);
90
+ area.select();
91
+ try {
92
+ if (!document.execCommand('copy')) throw new Error('Clipboard copy failed');
93
+ } finally { document.body.removeChild(area); }
94
+ }
95
+ function copyToClipboard(value) {
96
+ if (navigator.clipboard && navigator.clipboard.writeText) return navigator.clipboard.writeText(value);
97
+ return Promise.resolve().then(function () { fallbackCopy(value); });
98
+ }
99
+ button.addEventListener('click', function () {
100
+ copyToClipboard(text).then(function () {
101
+ setState('copied');
102
+ clearTimeout(resetTimer);
103
+ resetTimer = setTimeout(function () { setState('idle'); }, 2000);
104
+ }).catch(function () {
105
+ setState('failed');
106
+ clearTimeout(resetTimer);
107
+ resetTimer = setTimeout(function () { setState('idle'); }, 3000);
108
+ });
109
+ });
110
+ })();
111
+ </script>`;
112
+ }
113
+ function copyForStatus(status) {
114
+ if (isHttpErrorPageStatus(status)) {
115
+ return ERROR_PAGE_COPY[status];
116
+ }
117
+ if (isHttpErrorStatus(status) && status >= 500) {
118
+ return ERROR_PAGE_COPY[500];
119
+ }
120
+ return {
121
+ title: `Error ${status}`,
122
+ message: 'An error occurred while handling this request.',
123
+ modifier: `status-${status}`,
124
+ };
125
+ }
126
+ function normalizeDetail(value) {
127
+ const trimmed = value?.trim();
128
+ return trimmed ? trimmed : undefined;
129
+ }
130
+ function formatDiagnosticsCopyPayload(message, stack) {
131
+ const parts = [];
132
+ if (message)
133
+ parts.push(`Message: ${message}`);
134
+ if (stack)
135
+ parts.push(`Stack:\n${stack}`);
136
+ return parts.join('\n\n');
137
+ }
138
+ function createDefaultErrorPageViewModel(status, details) {
139
+ const copy = copyForStatus(status);
140
+ const isServerError = status >= 500;
141
+ const stack = isServerError ? normalizeDetail(details?.stack) : undefined;
142
+ const showDiagnostics = isServerError && isDevelopmentRuntime() && Boolean(details?.message || stack);
143
+ const diagnosticMessage = showDiagnostics ? normalizeDetail(details?.message) : undefined;
144
+ return {
145
+ status,
146
+ title: copy.title,
147
+ modifierClass: `eco-error-page--${copy.modifier}`,
148
+ bodyMessage: isServerError ? copy.message : normalizeDetail(details?.message) || copy.message,
149
+ diagnostics: showDiagnostics
150
+ ? {
151
+ message: diagnosticMessage,
152
+ stack,
153
+ copyPayload: formatDiagnosticsCopyPayload(diagnosticMessage, stack),
154
+ }
155
+ : undefined,
156
+ };
157
+ }
158
+ function renderDiagnosticsMarkup(diagnostics) {
159
+ const names = DEFAULT_ERROR_PAGE_CLASS_NAMES;
160
+ const copyMarkup = buildDefaultCopyButtonMarkup(diagnostics.copyPayload);
161
+ const messageMarkup = diagnostics.message
162
+ ? `<p class="${names.message}" role="alert">${escapeHtml(diagnostics.message)}</p>`
163
+ : '';
164
+ if (!diagnostics.stack) {
165
+ return `${messageMarkup}${copyMarkup}`;
166
+ }
167
+ return `${messageMarkup}<section class="${names.diagnostics}" aria-label="Error stack trace"><div class="${names.diagnosticsHeader}"><span class="${names.diagnosticsLabel}">Stack trace</span>${copyMarkup}</div><pre class="${names.stack}">${escapeHtml(diagnostics.stack)}</pre></section>`;
168
+ }
169
+ /**
170
+ * Self-contained HTML for a framework default error response.
171
+ *
172
+ * @remarks
173
+ * Development 5xx pages may include escaped `message` / `stack` and a copy
174
+ * button. 4xx pages never serialize a stack.
175
+ */
176
+ export function buildDefaultErrorHtml(status, details) {
177
+ const names = DEFAULT_ERROR_PAGE_CLASS_NAMES;
178
+ const view = createDefaultErrorPageViewModel(status, details);
179
+ const detailsBlock = view.diagnostics ? renderDiagnosticsMarkup(view.diagnostics) : '';
180
+ return `<!DOCTYPE html>
181
+ <html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width, initial-scale=1"><title>${escapeHtml(view.title)}</title><style>${sharedStyles}</style></head>
182
+ <body class="${names.root} ${view.modifierClass}"><main class="${names.content}"><p class="${names.status}" aria-hidden="true">ERROR ${view.status}</p><h1 class="${names.title}">${escapeHtml(view.title)}</h1><p class="${names.message}">${escapeHtml(view.bodyMessage)}</p>${detailsBlock}</main></body></html>`;
183
+ }
184
+ export function getDefaultServerErrorDetails(error) {
185
+ if (!isDevelopmentRuntime() || error === undefined) {
186
+ return undefined;
187
+ }
188
+ if (error instanceof Error) {
189
+ return { message: error.message, stack: error.stack };
190
+ }
191
+ return { message: String(error) };
192
+ }
193
+ export function getPublicErrorMessage(error) {
194
+ if (error instanceof Error) {
195
+ const message = error.message.trim();
196
+ return message.length > 0 ? message : undefined;
197
+ }
198
+ return undefined;
199
+ }
@@ -0,0 +1,58 @@
1
+ import type { EcoPagesAppConfig } from '../../types/internal-types.js';
2
+ import type { ErrorPageLoaders, RouteRendererBody } from '../../types/public-types.js';
3
+ import type { StaticGenerationRendererResolver } from '../../route-renderer/route-renderer.js';
4
+ import { type ErrorPageKind } from '../../errors/http-error-page-contract.js';
5
+ export type { ErrorPageKind };
6
+ export type ErrorPageRenderResult = {
7
+ body: RouteRendererBody;
8
+ sourceFile?: string;
9
+ };
10
+ export type ErrorPageRenderInput = {
11
+ kind?: ErrorPageKind;
12
+ status?: number;
13
+ error?: unknown;
14
+ };
15
+ /**
16
+ * Owns error-page source precedence and rendering for runtime and static paths.
17
+ *
18
+ * @remarks
19
+ * Filesystem semantic pages win over explicitly registered views. A missing
20
+ * custom source is the only case that uses a framework default; rendering
21
+ * failures are intentionally propagated so callers can apply their own retry
22
+ * or fallback policy without hiding the original failure.
23
+ */
24
+ export declare class ErrorPageRenderer {
25
+ private readonly appConfig;
26
+ private readonly routeRendererFactory?;
27
+ private readonly loaders;
28
+ constructor({ appConfig, routeRendererFactory, errorPageLoaders, }: {
29
+ appConfig: EcoPagesAppConfig;
30
+ routeRendererFactory?: StaticGenerationRendererResolver;
31
+ errorPageLoaders?: ErrorPageLoaders;
32
+ });
33
+ render(input: ErrorPageRenderInput): Promise<ErrorPageRenderResult>;
34
+ /**
35
+ * Renders the framework-owned document, ignoring custom filesystem pages and
36
+ * registered views.
37
+ *
38
+ * @remarks
39
+ * Request-time callers use this after a custom 500 page itself fails so the
40
+ * fallback cannot re-enter the custom source.
41
+ */
42
+ renderBuiltIn(input: ErrorPageRenderInput): ErrorPageRenderResult;
43
+ /**
44
+ * Returns the source file used for incremental static-export reuse, without
45
+ * rendering the page.
46
+ */
47
+ resolveSourceFile(kind: ErrorPageKind): Promise<string | undefined>;
48
+ private resolveCustomSource;
49
+ private renderFileSystemPage;
50
+ private renderRegisteredPage;
51
+ private getTemplatePath;
52
+ private getCustomPageProps;
53
+ private resolveViewSourceFile;
54
+ }
55
+ /**
56
+ * Logs a custom error-page failure without replacing the original request error.
57
+ */
58
+ export declare function logErrorPageFailure(kind: ErrorPageKind | undefined, error: unknown): void;