@ecopages/core 0.4.0 → 0.5.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 (54) hide show
  1. package/README.md +3 -3
  2. package/package.json +3 -3
  3. package/src/adapters/shared/http/api-request-pipeline.js +2 -2
  4. package/src/adapters/shared/runtime/server-request-pipeline.js +1 -0
  5. package/src/adapters/shared/runtime/server-route-handler.js +4 -4
  6. package/src/assets/app-browser-client-build.js +8 -21
  7. package/src/assets/app-browser-client-manifest.d.ts +0 -1
  8. package/src/assets/app-browser-client-manifest.js +1 -20
  9. package/src/build/contracts/content-virtual-modules.d.ts +9 -3
  10. package/src/build/contracts/content-virtual-modules.js +11 -5
  11. package/src/build/contracts.d.ts +1 -1
  12. package/src/build/contracts.js +1 -1
  13. package/src/build/rolldown/rolldown-plugin-bridge.js +2 -2
  14. package/src/build.d.ts +1 -1
  15. package/src/build.js +1 -1
  16. package/src/dev/transform-server/dev-transform-server.js +1 -1
  17. package/src/dev/transform-server/dev-transform-vendor-registry.d.ts +29 -6
  18. package/src/dev/transform-server/dev-transform-vendor-registry.js +101 -53
  19. package/src/errors/http-error.d.ts +9 -0
  20. package/src/errors/http-error.js +11 -0
  21. package/src/html/html-transformer.service.d.ts +0 -21
  22. package/src/html/html-transformer.service.js +0 -32
  23. package/src/html-pages/html-page-renderer.d.ts +2 -1
  24. package/src/html-pages/html-page-renderer.js +5 -3
  25. package/src/integration.d.ts +1 -2
  26. package/src/integration.js +0 -1
  27. package/src/islands/island-host.d.ts +1 -2
  28. package/src/islands/island-host.js +1 -2
  29. package/src/plugins/integration-plugin.d.ts +1 -1
  30. package/src/plugins/processor.d.ts +1 -1
  31. package/src/plugins/tsconfig-import-resolver.d.ts +3 -1
  32. package/src/plugins/tsconfig-import-resolver.js +4 -2
  33. package/src/processor.d.ts +1 -1
  34. package/src/route-renderer/orchestration/document-shell/document-shell-render.service.d.ts +2 -44
  35. package/src/route-renderer/orchestration/document-shell/document-shell-render.service.js +14 -89
  36. package/src/route-renderer/orchestration/foreign-child/foreign-subtree-execution.service.d.ts +4 -16
  37. package/src/route-renderer/orchestration/foreign-child/foreign-subtree-execution.service.js +2 -10
  38. package/src/route-renderer/orchestration/foreign-child/render-session.d.ts +3 -5
  39. package/src/route-renderer/orchestration/integration-renderer.d.ts +20 -44
  40. package/src/route-renderer/orchestration/integration-renderer.js +52 -115
  41. package/src/route-renderer/orchestration/ownership-graph/page-client-browser-assets.d.ts +3 -4
  42. package/src/route-renderer/orchestration/ownership-graph/page-client-browser-assets.js +4 -15
  43. package/src/route-renderer/orchestration/ownership-graph/prepared-graph-membership.d.ts +22 -0
  44. package/src/route-renderer/orchestration/ownership-graph/prepared-graph-membership.js +45 -0
  45. package/src/route-renderer/orchestration/page-browser-graph/grouped-graph-build-plan.d.ts +0 -1
  46. package/src/route-renderer/orchestration/route-pipeline/route-render-orchestrator.js +4 -3
  47. package/src/router/server/route-registry.d.ts +2 -0
  48. package/src/router/server/route-registry.js +3 -0
  49. package/src/static-site-generator/production-page-browser-graph-prebuild.js +0 -4
  50. package/src/types/build-types.d.ts +6 -0
  51. package/src/types/contracts.d.ts +6 -4
  52. package/src/types/eco-api-types.d.ts +1 -1
  53. package/src/route-renderer/orchestration/page-browser-graph/page-browser-graph-merge.utils.d.ts +0 -12
  54. package/src/route-renderer/orchestration/page-browser-graph/page-browser-graph-merge.utils.js +0 -32
@@ -73,6 +73,11 @@ export type IntegrationRendererHooks = {
73
73
  beforeRender?: <C>(options: IntegrationRendererRenderOptions<C>) => Promise<void>;
74
74
  beforeImportPageModule?: (file: string) => Promise<void>;
75
75
  transformDocumentHtml?: (html: string) => string;
76
+ /**
77
+ * Optional wrapper around the route render, for scoping such as HMR ownership.
78
+ * @remarks Core already wraps whatever this throws with `createRenderError('Error rendering page')`,
79
+ * keeping the original error as `cause` and passing an `HttpError` through. Do not catch and re-wrap.
80
+ */
76
81
  renderRoute?: <C>(renderOptions: IntegrationRendererRenderOptions<C>, render: () => Promise<RouteRendererBody>) => Promise<RouteRendererBody>;
77
82
  /** Reconciles integration-owned document markup after core transforms the response. */
78
83
  finalizeDocument?: <C>(body: RouteRendererBody, renderOptions: IntegrationRendererRenderOptions<C>) => Promise<RouteRendererBody> | RouteRendererBody;
@@ -93,10 +98,6 @@ export type IntegrationRendererHookFactoryOptions = Omit<IntegrationRendererOpti
93
98
  resolveDependencies: (components: (EcoComponent | Partial<EcoComponent>)[], options?: {
94
99
  preparedGraph?: true;
95
100
  }) => Promise<ProcessedAsset[]>;
96
- /** Resolves component-owned assets without prepending Integration-wide dependencies. */
97
- resolveComponentDependencies: (components: (EcoComponent | Partial<EcoComponent>)[], options?: {
98
- preparedGraph?: true;
99
- }) => Promise<ProcessedAsset[]>;
100
101
  /** Resolves a declared component asset relative to its owning component file. */
101
102
  resolveDependencyPath: (componentDir: string, pathUrl: string) => string;
102
103
  /** Resolves lazy client triggers from processed assets using the current render session. */
@@ -213,17 +214,6 @@ export declare abstract class IntegrationRenderer<C = EcoPagesElement> {
213
214
  protected createRenderError(message: string, cause?: unknown): HttpError;
214
215
  protected resolvePageBrowserGraphForFile(filePath: string): Promise<PageBrowserGraphResult | undefined>;
215
216
  protected resolvePageBrowserGraphForRoute(filePath: string, routeOptions?: Pick<RouteRendererOptions, 'params' | 'query' | 'skipStaticProps'>, groupedBuildPlan?: GroupedGraphBuildPlan): Promise<PageBrowserGraphResult | undefined>;
216
- /**
217
- * Merges component-scoped assets into the active render's page package.
218
- *
219
- * Explicit page, layout, and document shell composition can produce assets at
220
- * each foreign subtree. This helper deduplicates those groups and adds them to the
221
- * render session so downstream HTML finalization sees one canonical asset set.
222
- *
223
- * @param assetGroups - Optional groups of processed assets to merge.
224
- * @returns The deduplicated asset subset contributed by this merge operation.
225
- */
226
- protected appendProcessedDependencies(...assetGroups: Array<readonly ProcessedAsset[] | undefined>): ProcessedAsset[];
227
217
  /**
228
218
  * Renders a route page through optional layout and document shells.
229
219
  *
@@ -308,7 +298,7 @@ export declare abstract class IntegrationRenderer<C = EcoPagesElement> {
308
298
  preparedGraph?: true;
309
299
  }): Promise<ProcessedAsset[]>;
310
300
  getRouteHtmlFinalization(renderOptions: InternalIntegrationRendererRenderOptions<C>): RouteHtmlFinalization;
311
- transformRouteResponse(response: Response, htmlContributions: HtmlDocumentContribution[] | undefined, pagePackage: InternalIntegrationRendererRenderOptions<C>['pagePackage'], renderOptions: InternalIntegrationRendererRenderOptions<C>): Promise<RouteRendererBody>;
301
+ transformRouteResponse(response: Response, htmlContributions: HtmlDocumentContribution[] | undefined, renderOptions: InternalIntegrationRendererRenderOptions<C>): Promise<RouteRendererBody>;
312
302
  protected finalizeDocument(body: RouteRendererBody, renderOptions: IntegrationRendererRenderOptions<C>): Promise<RouteRendererBody> | RouteRendererBody;
313
303
  resolveRouteRenderInputs(routeOptions: RouteRendererOptions, options?: {
314
304
  skipMetadata?: boolean;
@@ -393,10 +383,18 @@ export declare abstract class IntegrationRenderer<C = EcoPagesElement> {
393
383
  */
394
384
  protected getHtmlDocumentContributions(context: HtmlDocumentContributionContext<C>): HtmlDocumentContribution[] | undefined;
395
385
  /**
396
- * Renders the route through the shared document shell.
386
+ * Renders the route, wrapping whatever it throws as `Error rendering page`.
397
387
  * Integrations can add preparation and final HTML hooks around core composition.
398
388
  */
399
389
  render(options: IntegrationRendererRenderOptions<C>): Promise<RouteRendererBody>;
390
+ /**
391
+ * Renders the route document through the shared document shell.
392
+ *
393
+ * @remarks
394
+ * A subclass with its own document model overrides this rather than `render()`,
395
+ * so its errors still go through core's wrap.
396
+ */
397
+ protected renderRouteDocument(options: IntegrationRendererRenderOptions<C>): Promise<RouteRendererBody>;
400
398
  protected beforeRender(options: IntegrationRendererRenderOptions<C>): Promise<void>;
401
399
  protected transformDocumentHtml(html: string): string;
402
400
  /**
@@ -424,30 +422,18 @@ export declare abstract class IntegrationRenderer<C = EcoPagesElement> {
424
422
  *
425
423
  * @remarks
426
424
  * `renderQueuedChildren` renders a subtree's children inside this renderer
427
- * before the owning renderer renders the subtree around them. The returned
428
- * assets are the owning renderers' assets, deduplicated.
425
+ * before the owning renderer renders the subtree around them.
429
426
  */
430
- protected resolveQueuedForeignSubtrees<TContext extends QueuedForeignSubtreeResolutionContext>(html: string, runtimeContext: TContext | undefined, renderQueuedChildren: RenderQueuedForeignSubtreeChildren<TContext>): Promise<{
431
- assets: ProcessedAsset[];
432
- html: string;
433
- }>;
427
+ protected resolveQueuedForeignSubtrees<TContext extends QueuedForeignSubtreeResolutionContext>(html: string, runtimeContext: TContext | undefined, renderQueuedChildren: RenderQueuedForeignSubtreeChildren<TContext>): Promise<string>;
434
428
  /**
435
429
  * Stamps `result` as an Island Host when the component itself declares a client script.
436
430
  *
437
- * @remarks Reads the component's own declarations, excluding Foreign Children, instead of `result.assets`,
438
- * which also carries the assets of Foreign Subtrees and of declared Foreign Children. Components without
439
- * `dependencies` emit no assets of their own, so they are never stamped.
431
+ * @remarks Reads the component's own declarations, excluding Foreign Children: a component without
432
+ * scripts that wraps an island is not an island itself. Components without `dependencies` are never stamped.
440
433
  */
441
434
  protected finalizeIslandComponentRender(input: ComponentRenderInput, result: ComponentRenderResult): ComponentRenderResult;
442
435
  private normalizeComponentRenderOutput;
443
436
  protected normalizeUnresolvedMarkerArtifactHtml(html: string): string;
444
- /**
445
- * Island assets for the active render.
446
- *
447
- * @remarks
448
- * The render context owns the map; outside a render there are none.
449
- */
450
- protected getActiveIslandRenderAssets(): ReadonlyMap<string, ProcessedAsset[]>;
451
437
  /**
452
438
  * @remarks
453
439
  * The active plan is the page owner's, but it answers for any renderer: a nested renderer of
@@ -455,15 +441,6 @@ export declare abstract class IntegrationRenderer<C = EcoPagesElement> {
455
441
  * foreign children. A component the plan did not walk gets a plan built for it.
456
442
  */
457
443
  protected hasForeignChildDescendants(component: EcoComponent, foreignChildRoots?: ReadonlyArray<EcoComponent | Partial<EcoComponent>>): boolean;
458
- /**
459
- * Builds island client assets from the page client plan before SSR.
460
- *
461
- * @remarks
462
- * Default is none. Integrations that hydrate islands override this so
463
- * {@link IntegrationRenderer.execute} never starts a browser build during SSR.
464
- * Page owners also call this on other hydrating integrations listed in the plan.
465
- */
466
- protected collectIslandRenderAssets(_plan: PageClientPlan): Promise<Map<string, ProcessedAsset[]>>;
467
444
  /**
468
445
  * Returns whether this renderer builds island and lazy-entry scripts in the
469
446
  * app-wide grouped browser build that other page owners should run for the plan.
@@ -474,8 +451,7 @@ export declare abstract class IntegrationRenderer<C = EcoPagesElement> {
474
451
  *
475
452
  * @remarks
476
453
  * The planning and merging live in `ownership-graph/page-client-browser-assets.ts`; this method
477
- * supplies what only the renderer has: its own island assets, the owning renderers of other
478
- * Integrations, and its asset service.
454
+ * supplies what only the renderer has: the owning renderers of other Integrations and its asset service.
479
455
  */
480
456
  buildPageClientBrowserAssets(plan: PageClientPlan, route?: Pick<RouteRendererOptions, 'file' | 'params' | 'query'>): Promise<PageClientBrowserAssets>;
481
457
  private buildPrebuiltPageClientBrowserAssets;
@@ -3,7 +3,7 @@
3
3
  * Every integration renderer should extend this class
4
4
  * @module
5
5
  */
6
- import { createPagePackage, } from '../../assets/asset-processing-service/index.js';
6
+ import {} from '../../assets/asset-processing-service/index.js';
7
7
  import { resolveAssetProcessingIntegration } from '../../assets/asset-processing-service/asset-processing-integration.js';
8
8
  import { createAppBrowserClientEntryKey } from '../../assets/app-browser-client-build.js';
9
9
  import { HtmlTransformerService } from '../../html/html-transformer.service.js';
@@ -15,6 +15,7 @@ import { getComponentIdentity } from '../../eco/component-identity.js';
15
15
  import { OwnershipValidationService } from './ownership-graph/ownership-validation.service.js';
16
16
  import {} from './ownership-graph/component-graph.js';
17
17
  import { collectComponentGraphWatchPaths } from './ownership-graph/component-graph-collectors.js';
18
+ import { assertComponentInPreparedGraph } from './ownership-graph/prepared-graph-membership.js';
18
19
  import { collectPageClientPlan, collectPageClientPlanFromGraph, planCoversComponents, planHasForeignChildDescendants, uniqueIslandIntegrationNames, } from './ownership-graph/page-client-plan.js';
19
20
  import { buildPageClientBrowserAssets } from './ownership-graph/page-client-browser-assets.js';
20
21
  import { finalizeComponentRender, getComponentRenderContext, runWithComponentRenderContext, } from '../../eco/component-render-context.js';
@@ -193,7 +194,6 @@ export class IntegrationRenderer {
193
194
  pageClientBuildEntries,
194
195
  prebuiltPageClientBrowserAssets: {
195
196
  processedAssets: [],
196
- islandRenderAssetsByFile: new Map(),
197
197
  fallbackDependencies: [],
198
198
  },
199
199
  };
@@ -331,36 +331,6 @@ export class IntegrationRenderer {
331
331
  collectContribution: async () => mergePageBrowserGraphContributions(await this.collectPageBrowserGraphContribution(graphContext), resolvedPageDependencies?.contribution),
332
332
  });
333
333
  }
334
- /**
335
- * Merges component-scoped assets into the active render's page package.
336
- *
337
- * Explicit page, layout, and document shell composition can produce assets at
338
- * each foreign subtree. This helper deduplicates those groups and adds them to the
339
- * render session so downstream HTML finalization sees one canonical asset set.
340
- *
341
- * @param assetGroups - Optional groups of processed assets to merge.
342
- * @returns The deduplicated asset subset contributed by this merge operation.
343
- */
344
- appendProcessedDependencies(...assetGroups) {
345
- const nextDependencies = this.htmlTransformer.dedupeProcessedAssets(assetGroups.flatMap((assets) => assets ?? []));
346
- if (nextDependencies.length === 0) {
347
- return nextDependencies;
348
- }
349
- const session = getComponentRenderContext()?.renderState?.session;
350
- const existingPackage = session?.pagePackage;
351
- const existingDependencies = existingPackage?.assets ?? [];
352
- const mergedDependencies = this.htmlTransformer.dedupeProcessedAssets([
353
- ...existingDependencies,
354
- ...nextDependencies,
355
- ]);
356
- const pagePackage = createPagePackage(mergedDependencies, {
357
- pageBrowserGraph: existingPackage?.pageBrowserGraph,
358
- });
359
- if (session) {
360
- session.pagePackage = pagePackage;
361
- }
362
- return nextDependencies;
363
- }
364
334
  /**
365
335
  * Renders a route page through optional layout and document shells.
366
336
  *
@@ -382,8 +352,7 @@ export class IntegrationRenderer {
382
352
  });
383
353
  return renderPageDocumentShell({
384
354
  renderComponentWithForeignChildren: (renderInput) => this.renderComponentWithForeignChildren(renderInput),
385
- appendProcessedDependencies: (...assetGroups) => this.appendProcessedDependencies(...assetGroups),
386
- }, { ...input, layouts, composeChildren, inheritedOwner: this.name }, this.DOC_TYPE);
355
+ }, { ...input, layouts, composeChildren }, this.DOC_TYPE);
387
356
  }
388
357
  serializeStringRenderChildren(children) {
389
358
  if (children === undefined) {
@@ -419,15 +388,10 @@ export class IntegrationRenderer {
419
388
  const props = serializedChildren === undefined ? input.props : { ...input.props, children: serializedChildren };
420
389
  const content = await component(props);
421
390
  this.assertStringRenderContent(input, content);
422
- const html = content;
423
- const assets = input.component.config?.dependencies
424
- ? await this.processComponentDependencies([input.component])
425
- : undefined;
426
391
  return {
427
- html,
392
+ html: content,
428
393
  canAttachAttributes: true,
429
394
  integrationName: this.name,
430
- assets,
431
395
  };
432
396
  }
433
397
  /**
@@ -446,21 +410,13 @@ export class IntegrationRenderer {
446
410
  runtimeContext: this.getQueuedForeignSubtreeContext(input),
447
411
  getOwningRenderer: (integrationName, rendererCache) => this.resolveOwningRenderer(integrationName, rendererCache),
448
412
  };
449
- const queuedForeignSubtreeResolution = this.integrationHooks.renderQueuedChildren
413
+ const html = this.integrationHooks.renderQueuedChildren
450
414
  ? await resolveQueuedHtml({
451
415
  ...queuedOptions,
452
416
  renderQueuedChildren: this.integrationHooks.renderQueuedChildren,
453
417
  })
454
418
  : await resolveStringQueuedHtml(queuedOptions);
455
- const mergedAssets = this.htmlTransformer.dedupeProcessedAssets([
456
- ...(componentRender.assets ?? []),
457
- ...queuedForeignSubtreeResolution.assets,
458
- ]);
459
- return {
460
- ...componentRender,
461
- html: queuedForeignSubtreeResolution.html,
462
- assets: mergedAssets.length > 0 ? mergedAssets : undefined,
463
- };
419
+ return { ...componentRender, html };
464
420
  }
465
421
  constructor({ appConfig, assetProcessingService, assetProcessingIntegration, resolvedIntegrationDependencies, hooks, }) {
466
422
  this.appConfig = appConfig;
@@ -483,7 +439,6 @@ export class IntegrationRenderer {
483
439
  resolvedIntegrationDependencies,
484
440
  hooks: {},
485
441
  resolveDependencies: (components, options) => this.resolveDependencies(components, options),
486
- resolveComponentDependencies: (components, options) => this.processComponentDependencies(components, options),
487
442
  resolveDependencyPath: (componentDir, pathUrl) => this.resolveDependencyPath(componentDir, pathUrl),
488
443
  applyPendingLazyTriggers: (assets, configs) => this.dependencyResolverService.applyPendingLazyTriggers(assets, configs),
489
444
  })
@@ -570,11 +525,10 @@ export class IntegrationRenderer {
570
525
  applyAttributesToHtmlElement: (html, attributes) => this.applyAttributesToHtmlElement(html, attributes),
571
526
  });
572
527
  }
573
- async transformRouteResponse(response, htmlContributions, pagePackage, renderOptions) {
574
- const resolvedPagePackage = getComponentRenderContext()?.renderState?.session?.pagePackage ?? pagePackage;
528
+ async transformRouteResponse(response, htmlContributions, renderOptions) {
575
529
  const transformedResponse = this.htmlTransformer.transform(response, {
576
530
  contributions: htmlContributions,
577
- pagePackage: resolvedPagePackage,
531
+ pagePackage: renderOptions.pagePackage,
578
532
  });
579
533
  const body = (transformedResponse.body ?? (await transformedResponse.text()));
580
534
  return this.finalizeDocument(body, renderOptions);
@@ -738,9 +692,8 @@ export class IntegrationRenderer {
738
692
  const renderState = getComponentRenderContext()?.renderState;
739
693
  if (renderState) {
740
694
  renderState.pageClientPlan = renderOptions.pageClientPlan;
741
- renderState.islandRenderAssetsByFile = renderOptions.islandRenderAssetsByFile;
695
+ renderState.preparedGraphComponents = renderOptions.preparedGraphComponents;
742
696
  }
743
- session.pagePackage = renderOptions.pagePackage;
744
697
  return this.routeRenderOrchestrator.executePrepared(renderOptions, this);
745
698
  });
746
699
  return value;
@@ -830,39 +783,11 @@ export class IntegrationRenderer {
830
783
  return this.integrationHooks.documentContributions?.(context);
831
784
  }
832
785
  /**
833
- * Renders the route through the shared document shell.
786
+ * Renders the route, wrapping whatever it throws as `Error rendering page`.
834
787
  * Integrations can add preparation and final HTML hooks around core composition.
835
788
  */
836
789
  async render(options) {
837
- const internalOptions = options;
838
- const renderRoute = async () => {
839
- await this.beforeRender(options);
840
- const documentShellProps = this.integrationHooks.documentShellProps?.(options);
841
- return await this.renderPageWithDocumentShell({
842
- page: {
843
- component: options.Page,
844
- props: {
845
- ...options.props,
846
- params: options.params ?? {},
847
- query: options.query ?? {},
848
- locals: options.pageLocals,
849
- },
850
- },
851
- layouts: resolveDocumentShellLayouts({
852
- layout: options.Layout,
853
- layoutEntries: options.layoutEntries,
854
- params: options.params,
855
- query: options.query,
856
- locals: options.locals,
857
- }),
858
- htmlTemplate: options.HtmlTemplate,
859
- metadata: options.metadata,
860
- pageProps: documentShellProps?.pageProps ?? options.pageProps ?? options.props ?? {},
861
- documentProps: documentShellProps?.documentProps,
862
- foreignChildRoots: internalOptions.pageDependencyComponents,
863
- transformDocumentHtml: (html) => this.transformDocumentHtml(html),
864
- });
865
- };
790
+ const renderRoute = () => this.renderRouteDocument(options);
866
791
  try {
867
792
  return await (this.integrationHooks.renderRoute?.(options, renderRoute) ?? renderRoute());
868
793
  }
@@ -870,6 +795,42 @@ export class IntegrationRenderer {
870
795
  throw this.createRenderError('Error rendering page', error);
871
796
  }
872
797
  }
798
+ /**
799
+ * Renders the route document through the shared document shell.
800
+ *
801
+ * @remarks
802
+ * A subclass with its own document model overrides this rather than `render()`,
803
+ * so its errors still go through core's wrap.
804
+ */
805
+ async renderRouteDocument(options) {
806
+ const internalOptions = options;
807
+ await this.beforeRender(options);
808
+ const documentShellProps = this.integrationHooks.documentShellProps?.(options);
809
+ return await this.renderPageWithDocumentShell({
810
+ page: {
811
+ component: options.Page,
812
+ props: {
813
+ ...options.props,
814
+ params: options.params ?? {},
815
+ query: options.query ?? {},
816
+ locals: options.pageLocals,
817
+ },
818
+ },
819
+ layouts: resolveDocumentShellLayouts({
820
+ layout: options.Layout,
821
+ layoutEntries: options.layoutEntries,
822
+ params: options.params,
823
+ query: options.query,
824
+ locals: options.locals,
825
+ }),
826
+ htmlTemplate: options.HtmlTemplate,
827
+ metadata: options.metadata,
828
+ pageProps: documentShellProps?.pageProps ?? options.pageProps ?? options.props ?? {},
829
+ documentProps: documentShellProps?.documentProps,
830
+ foreignChildRoots: internalOptions.pageDependencyComponents,
831
+ transformDocumentHtml: (html) => this.transformDocumentHtml(html),
832
+ });
833
+ }
873
834
  async beforeRender(options) {
874
835
  await this.integrationHooks.beforeRender?.(options);
875
836
  }
@@ -885,6 +846,7 @@ export class IntegrationRenderer {
885
846
  * renderer's nested foreign-child handoff.
886
847
  */
887
848
  async renderComponentWithForeignChildren(input) {
849
+ assertComponentInPreparedGraph(input.component, getComponentRenderContext()?.renderState?.preparedGraphComponents);
888
850
  return await executeComponentRender({
889
851
  currentIntegrationName: this.name,
890
852
  input,
@@ -924,8 +886,7 @@ export class IntegrationRenderer {
924
886
  *
925
887
  * @remarks
926
888
  * `renderQueuedChildren` renders a subtree's children inside this renderer
927
- * before the owning renderer renders the subtree around them. The returned
928
- * assets are the owning renderers' assets, deduplicated.
889
+ * before the owning renderer renders the subtree around them.
929
890
  */
930
891
  resolveQueuedForeignSubtrees(html, runtimeContext, renderQueuedChildren) {
931
892
  return resolveQueuedHtml({
@@ -939,9 +900,8 @@ export class IntegrationRenderer {
939
900
  /**
940
901
  * Stamps `result` as an Island Host when the component itself declares a client script.
941
902
  *
942
- * @remarks Reads the component's own declarations, excluding Foreign Children, instead of `result.assets`,
943
- * which also carries the assets of Foreign Subtrees and of declared Foreign Children. Components without
944
- * `dependencies` emit no assets of their own, so they are never stamped.
903
+ * @remarks Reads the component's own declarations, excluding Foreign Children: a component without
904
+ * scripts that wraps an island is not an island itself. Components without `dependencies` are never stamped.
945
905
  */
946
906
  finalizeIslandComponentRender(input, result) {
947
907
  const ownAssets = input.component.config?.dependencies
@@ -964,15 +924,6 @@ export class IntegrationRenderer {
964
924
  normalizeUnresolvedMarkerArtifactHtml(html) {
965
925
  return normalizeUnresolvedMarkerArtifactHtml(html);
966
926
  }
967
- /**
968
- * Island assets for the active render.
969
- *
970
- * @remarks
971
- * The render context owns the map; outside a render there are none.
972
- */
973
- getActiveIslandRenderAssets() {
974
- return getComponentRenderContext()?.renderState?.islandRenderAssetsByFile ?? new Map();
975
- }
976
927
  /**
977
928
  * @remarks
978
929
  * The active plan is the page owner's, but it answers for any renderer: a nested renderer of
@@ -987,17 +938,6 @@ export class IntegrationRenderer {
987
938
  const plan = collectPageClientPlan([component, ...(foreignChildRoots ?? [])].map((root) => ({ component: root })), this.name);
988
939
  return planHasForeignChildDescendants(plan, component, this.name, foreignChildRoots);
989
940
  }
990
- /**
991
- * Builds island client assets from the page client plan before SSR.
992
- *
993
- * @remarks
994
- * Default is none. Integrations that hydrate islands override this so
995
- * {@link IntegrationRenderer.execute} never starts a browser build during SSR.
996
- * Page owners also call this on other hydrating integrations listed in the plan.
997
- */
998
- async collectIslandRenderAssets(_plan) {
999
- return new Map();
1000
- }
1001
941
  /**
1002
942
  * Returns whether this renderer builds island and lazy-entry scripts in the
1003
943
  * app-wide grouped browser build that other page owners should run for the plan.
@@ -1010,8 +950,7 @@ export class IntegrationRenderer {
1010
950
  *
1011
951
  * @remarks
1012
952
  * The planning and merging live in `ownership-graph/page-client-browser-assets.ts`; this method
1013
- * supplies what only the renderer has: its own island assets, the owning renderers of other
1014
- * Integrations, and its asset service.
953
+ * supplies what only the renderer has: the owning renderers of other Integrations and its asset service.
1015
954
  */
1016
955
  async buildPageClientBrowserAssets(plan, route) {
1017
956
  const prebuilt = route ? await this.buildPrebuiltPageClientBrowserAssets(plan, route) : undefined;
@@ -1026,7 +965,6 @@ export class IntegrationRenderer {
1026
965
  return buildPageClientBrowserAssets({
1027
966
  plan,
1028
967
  integrationName: this.name,
1029
- collectOwnIslandAssets: (ownPlan) => this.collectIslandRenderAssets(ownPlan),
1030
968
  resolveContributor: async (integrationName) => {
1031
969
  const owning = await this.resolveOwningRenderer(integrationName, rendererCache);
1032
970
  return owning instanceof IntegrationRenderer
@@ -1065,7 +1003,6 @@ export class IntegrationRenderer {
1065
1003
  const processedAssets = [...prebuilt.processedAssets, ...fallbackAssets];
1066
1004
  return {
1067
1005
  processedAssets,
1068
- islandRenderAssetsByFile: prebuilt.islandRenderAssetsByFile,
1069
1006
  lazyTriggers: this.dependencyResolverService.applyPendingLazyTriggers(processedAssets, plan.lazyConfigs),
1070
1007
  };
1071
1008
  }
@@ -12,7 +12,6 @@ export type BuildPageClientBrowserAssetsInput = {
12
12
  plan: PageClientPlan;
13
13
  /** Name of the Integration building for the plan. */
14
14
  integrationName: string;
15
- collectOwnIslandAssets(plan: PageClientPlan): Promise<Map<string, ProcessedAsset[]>>;
16
15
  resolveContributor(integrationName: string): Promise<PageClientAssetsContributor | undefined>;
17
16
  processLazyEntries(entries: AssetDefinition[]): Promise<ProcessedAsset[]>;
18
17
  applyPendingLazyTriggers(assets: ProcessedAsset[], configs: EcoComponentConfig[]): ResolvedLazyTrigger[];
@@ -21,8 +20,8 @@ export type BuildPageClientBrowserAssetsInput = {
21
20
  * Builds island and lazy-entry browser assets from a page client plan.
22
21
  *
23
22
  * @remarks
24
- * The page owner collects its own island assets, then asks every other island-hydrating Integration
25
- * on the plan to contribute its grouped client build. Lazy entries join that grouped build when an
26
- * Integration includes them; otherwise they are processed here as one grouped batch.
23
+ * The page owner asks every other island-hydrating Integration on the plan to contribute its grouped
24
+ * client build. Lazy entries join that grouped build when an Integration includes them; otherwise they
25
+ * are processed here as one grouped batch.
27
26
  */
28
27
  export declare function buildPageClientBrowserAssets(input: BuildPageClientBrowserAssetsInput): Promise<PageClientBrowserAssets>;
@@ -1,24 +1,15 @@
1
1
  import { uniqueIslandIntegrationNames } from './page-client-plan.js';
2
- function mergeIslandRenderAssetMaps(target, source) {
3
- for (const [file, assets] of source) {
4
- const existing = target.get(file);
5
- target.set(file, existing ? [...existing, ...assets] : assets);
6
- }
7
- }
8
2
  /**
9
3
  * Builds island and lazy-entry browser assets from a page client plan.
10
4
  *
11
5
  * @remarks
12
- * The page owner collects its own island assets, then asks every other island-hydrating Integration
13
- * on the plan to contribute its grouped client build. Lazy entries join that grouped build when an
14
- * Integration includes them; otherwise they are processed here as one grouped batch.
6
+ * The page owner asks every other island-hydrating Integration on the plan to contribute its grouped
7
+ * client build. Lazy entries join that grouped build when an Integration includes them; otherwise they
8
+ * are processed here as one grouped batch.
15
9
  */
16
10
  export async function buildPageClientBrowserAssets(input) {
17
11
  const { plan } = input;
18
- const ownIslands = await input.collectOwnIslandAssets(plan);
19
- const islandRenderAssetsByFile = new Map();
20
- mergeIslandRenderAssetMaps(islandRenderAssetsByFile, ownIslands);
21
- const combined = [...ownIslands.values()].flat();
12
+ const combined = [];
22
13
  for (const integrationName of uniqueIslandIntegrationNames(plan)) {
23
14
  if (integrationName === input.integrationName) {
24
15
  continue;
@@ -28,7 +19,6 @@ export async function buildPageClientBrowserAssets(input) {
28
19
  continue;
29
20
  }
30
21
  const contributed = await contributor.buildPageClientBrowserAssets(plan);
31
- mergeIslandRenderAssetMaps(islandRenderAssetsByFile, contributed.islandRenderAssetsByFile);
32
22
  combined.push(...contributed.processedAssets);
33
23
  }
34
24
  const lazyAlreadyProcessed = combined.some((asset) => Boolean(asset.attributes?.['data-eco-lazy-key']));
@@ -38,7 +28,6 @@ export async function buildPageClientBrowserAssets(input) {
38
28
  const processedAssets = [...combined, ...processedLazy];
39
29
  return {
40
30
  processedAssets,
41
- islandRenderAssetsByFile,
42
31
  lazyTriggers: input.applyPendingLazyTriggers(processedAssets, plan.lazyConfigs),
43
32
  };
44
33
  }
@@ -0,0 +1,22 @@
1
+ import type { EcoComponent } from '../../../types/contracts.js';
2
+ import type { PreparedComponentGraph } from './component-graph.js';
3
+ /**
4
+ * Maps each prepared component's identity id to whether route preparation collects its assets,
5
+ * or returns `undefined` outside development.
6
+ *
7
+ * @remarks
8
+ * Only development renders are checked, so no map is built elsewhere. Assets are collected when
9
+ * the component has an identity file and so does every parent along some path to a root.
10
+ * Components are compared by identity id, because one file can declare several.
11
+ */
12
+ export declare function collectPreparedGraphComponents(graph: PreparedComponentGraph): ReadonlyMap<string, boolean> | undefined;
13
+ /**
14
+ * Fails a render that reaches a component whose assets route preparation did not collect.
15
+ *
16
+ * @remarks
17
+ * Without a map (production, or a partial view that prepares no graph) nothing is checked.
18
+ * A component without an identity file or a `dependencies` config has no assets to collect.
19
+ * A component that is declared but sits only under parents without an identity file gets its own
20
+ * message, because declaring it again would not help.
21
+ */
22
+ export declare function assertComponentInPreparedGraph(component: EcoComponent, preparedGraphComponents: ReadonlyMap<string, boolean> | undefined): void;
@@ -0,0 +1,45 @@
1
+ import { getComponentIdentity } from '../../../eco/component-identity.js';
2
+ import { isDevelopmentRuntime } from '../../../utils/runtime.js';
3
+ /**
4
+ * Maps each prepared component's identity id to whether route preparation collects its assets,
5
+ * or returns `undefined` outside development.
6
+ *
7
+ * @remarks
8
+ * Only development renders are checked, so no map is built elsewhere. Assets are collected when
9
+ * the component has an identity file and so does every parent along some path to a root.
10
+ * Components are compared by identity id, because one file can declare several.
11
+ */
12
+ export function collectPreparedGraphComponents(graph) {
13
+ if (!isDevelopmentRuntime()) {
14
+ return undefined;
15
+ }
16
+ const components = new Map();
17
+ for (const node of graph.nodes) {
18
+ components.set(node.componentId, node.dependencyCollectionVisible || components.get(node.componentId) === true);
19
+ }
20
+ return components;
21
+ }
22
+ /**
23
+ * Fails a render that reaches a component whose assets route preparation did not collect.
24
+ *
25
+ * @remarks
26
+ * Without a map (production, or a partial view that prepares no graph) nothing is checked.
27
+ * A component without an identity file or a `dependencies` config has no assets to collect.
28
+ * A component that is declared but sits only under parents without an identity file gets its own
29
+ * message, because declaring it again would not help.
30
+ */
31
+ export function assertComponentInPreparedGraph(component, preparedGraphComponents) {
32
+ if (!preparedGraphComponents || !component.config?.dependencies) {
33
+ return;
34
+ }
35
+ const identity = getComponentIdentity(component);
36
+ const collected = identity?.file ? preparedGraphComponents.get(identity.id) : undefined;
37
+ if (!identity?.file || collected) {
38
+ return;
39
+ }
40
+ const notCollected = `[ecopages] Component "${identity.file}" was rendered but route preparation did not collect it, so its stylesheets and scripts are not part of the page assets.`;
41
+ if (collected === false) {
42
+ throw new Error(`${notCollected} It is declared, but only under a parent without an identity file, and preparation collects nothing below such a parent. Declare that parent with eco.component() in its own module, or list the component from a parent that has one.`);
43
+ }
44
+ throw new Error(`${notCollected} Import it statically from the module that declares it with eco.component() (a named re-export works, \`export *\` does not), list it in the parent's dependencies.components, or return it in components from the Page's dependencies.`);
45
+ }
@@ -6,7 +6,6 @@ export type PlannedPageClientBuildEntry = PageClientBuildEntry & {
6
6
  };
7
7
  export type PrebuiltPageClientBrowserAssets = {
8
8
  processedAssets: ProcessedAsset[];
9
- islandRenderAssetsByFile: Map<string, ProcessedAsset[]>;
10
9
  fallbackDependencies: Array<{
11
10
  dependency: PageClientBuildEntry['dependency'];
12
11
  integrationName: string;
@@ -7,6 +7,7 @@ import { createPreparedComponentGraphBuilder, } from '../ownership-graph/compone
7
7
  import { OwnershipValidationService, throwIfOwnershipInvalid, } from '../ownership-graph/ownership-validation.service.js';
8
8
  import { collectComponentGraphWatchPaths, collectUsedIntegrationDependenciesFromNames, } from '../ownership-graph/component-graph-collectors.js';
9
9
  import { collectPageClientPlanFromGraph } from '../ownership-graph/page-client-plan.js';
10
+ import { collectPreparedGraphComponents } from '../ownership-graph/prepared-graph-membership.js';
10
11
  import { buildGlobalInjectorAssets } from '../page-browser-graph/global-injector-assets.service.js';
11
12
  import { mergePageBrowserGraphContributions } from '../page-browser-graph/page-browser-graph-contribution.merge.js';
12
13
  import { PageBrowserGraphService } from '../page-browser-graph/page-browser-graph.service.js';
@@ -210,7 +211,7 @@ export class RouteRenderOrchestrator {
210
211
  }),
211
212
  sourceDependencyPaths,
212
213
  pageClientPlan: clientPlan,
213
- islandRenderAssetsByFile: clientBrowserAssets.islandRenderAssetsByFile,
214
+ preparedGraphComponents: collectPreparedGraphComponents(preparedGraph),
214
215
  };
215
216
  }
216
217
  async resolveDeclaredPageBrowserGraph(input) {
@@ -253,7 +254,7 @@ export class RouteRenderOrchestrator {
253
254
  headers: {
254
255
  'Content-Type': 'text/html',
255
256
  },
256
- }), htmlFinalization.htmlContributions, renderOptions.pagePackage, renderOptions));
257
+ }), htmlFinalization.htmlContributions, renderOptions));
257
258
  return {
258
259
  body,
259
260
  cacheStrategy: renderOptions.cacheStrategy,
@@ -268,7 +269,7 @@ export class RouteRenderOrchestrator {
268
269
  headers: {
269
270
  'Content-Type': 'text/html',
270
271
  },
271
- }), htmlFinalization.htmlContributions, renderOptions.pagePackage, renderOptions));
272
+ }), htmlFinalization.htmlContributions, renderOptions));
272
273
  return {
273
274
  body,
274
275
  cacheStrategy: renderOptions.cacheStrategy,
@@ -44,6 +44,8 @@ export type RouteRegistryPageModule = {
44
44
  }>;
45
45
  }>;
46
46
  readonly staticProps?: unknown;
47
+ /** The Page's Cache Strategy; `'dynamic'` Pages render per request and are never expanded. */
48
+ readonly cache?: unknown;
47
49
  };
48
50
  export interface RouteRegistryPageModuleAdapter {
49
51
  loadPageModule(filePath: string): Promise<RouteRegistryPageModule>;
@@ -112,6 +112,9 @@ export class RouteRegistry {
112
112
  continue;
113
113
  }
114
114
  const pageModule = await this.pageModuleAdapter.loadPageModule(route.filePath);
115
+ if (pageModule.cache === 'dynamic') {
116
+ continue;
117
+ }
115
118
  const staticPaths = pageModule.staticPaths;
116
119
  if (this.buildMode) {
117
120
  invariant(staticPaths !== undefined, `[ecopages] Missing getStaticPaths in ${route.filePath}`);