@ecopages/core 0.4.0 → 0.6.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 (163) hide show
  1. package/README.md +19 -15
  2. package/package.json +13 -4
  3. package/src/adapters/create-app.js +9 -5
  4. package/src/adapters/node/create-app.d.ts +18 -16
  5. package/src/adapters/node/create-app.js +26 -30
  6. package/src/adapters/node/server-adapter.d.ts +26 -9
  7. package/src/adapters/node/server-adapter.js +38 -8
  8. package/src/adapters/shared/hmr/hmr-manager.js +3 -2
  9. package/src/adapters/shared/http/api-request-pipeline.js +2 -2
  10. package/src/adapters/shared/http/dist-file-handler.js +25 -7
  11. package/src/adapters/shared/runtime/render-context.d.ts +2 -1
  12. package/src/adapters/shared/runtime/render-context.js +18 -21
  13. package/src/adapters/shared/runtime/runtime-server-lifecycle.d.ts +4 -3
  14. package/src/adapters/shared/runtime/runtime-server-lifecycle.js +6 -4
  15. package/src/adapters/shared/runtime/server-request-pipeline.d.ts +6 -1
  16. package/src/adapters/shared/runtime/server-request-pipeline.js +11 -10
  17. package/src/adapters/shared/runtime/server-route-handler.js +4 -4
  18. package/src/adapters/shared/runtime/server-static-builder.d.ts +11 -11
  19. package/src/adapters/shared/runtime/server-static-builder.js +37 -18
  20. package/src/assets/app-browser-client-build.js +8 -21
  21. package/src/assets/app-browser-client-manifest.d.ts +1 -4
  22. package/src/assets/app-browser-client-manifest.js +6 -78
  23. package/src/assets/asset-processing-service/processors/script/file-script.processor.d.ts +2 -2
  24. package/src/assets/asset-processing-service/processors/script/file-script.processor.js +2 -2
  25. package/src/assets/browser-asset-output.d.ts +1 -1
  26. package/src/assets/browser-asset-output.js +1 -1
  27. package/src/build/app-build-manifest-runtime.d.ts +11 -1
  28. package/src/build/app-build-manifest-runtime.js +17 -3
  29. package/src/build/cache/pages-unified-graph-build.d.ts +32 -35
  30. package/src/build/cache/pages-unified-graph-build.js +206 -124
  31. package/src/build/cache/server-module-entries.d.ts +35 -0
  32. package/src/build/cache/server-module-entries.js +109 -0
  33. package/src/build/contracts/build-contracts.d.ts +5 -0
  34. package/src/build/contracts/content-virtual-modules.d.ts +9 -3
  35. package/src/build/contracts/content-virtual-modules.js +11 -5
  36. package/src/build/contracts.d.ts +1 -1
  37. package/src/build/contracts.js +1 -1
  38. package/src/build/copy-server-files.d.ts +10 -0
  39. package/src/build/copy-server-files.js +37 -0
  40. package/src/build/preserve-import-meta-transform.d.ts +1 -1
  41. package/src/build/preserve-import-meta-transform.js +1 -1
  42. package/src/build/production-build-id.d.ts +9 -0
  43. package/src/build/production-build-id.js +19 -0
  44. package/src/build/production-dist-complete.d.ts +5 -0
  45. package/src/build/production-dist-complete.js +101 -0
  46. package/src/build/production-route-list.d.ts +26 -0
  47. package/src/build/production-route-list.js +78 -0
  48. package/src/build/rolldown/rolldown-adapter-helpers.d.ts +2 -2
  49. package/src/build/rolldown/rolldown-adapter-helpers.js +56 -4
  50. package/src/build/rolldown/rolldown-build-adapter.js +1 -1
  51. package/src/build/rolldown/rolldown-plugin-bridge.js +2 -2
  52. package/src/build/runtime/build-request-identity.js +2 -1
  53. package/src/build/runtime/build-request-policy.d.ts +3 -2
  54. package/src/build/runtime/build-request-policy.js +5 -3
  55. package/src/build/server/import-view-module.d.ts +11 -0
  56. package/src/build/server/import-view-module.js +21 -0
  57. package/src/build/server/imported-view-plugin.d.ts +16 -0
  58. package/src/build/server/imported-view-plugin.js +59 -0
  59. package/src/build/server/page-module-import.service.d.ts +19 -20
  60. package/src/build/server/page-module-import.service.js +65 -36
  61. package/src/build/server/resolve-static-view.d.ts +9 -0
  62. package/src/build/server/resolve-static-view.js +28 -0
  63. package/src/build/server/route-module-build-cache-registry.d.ts +5 -3
  64. package/src/build/server/route-module-build-cache-registry.js +5 -3
  65. package/src/build/server/server-modules-manifest.d.ts +51 -0
  66. package/src/build/server/server-modules-manifest.js +129 -0
  67. package/src/build/server/view-reference.d.ts +38 -0
  68. package/src/build/server/view-reference.js +112 -0
  69. package/src/build/server-bundle-deploy-manifest.d.ts +9 -9
  70. package/src/build/server-bundle-deploy-manifest.js +24 -28
  71. package/src/build.d.ts +4 -2
  72. package/src/build.js +4 -2
  73. package/src/config/assembly/app-runtime.d.ts +15 -2
  74. package/src/config/assembly/app-runtime.js +3 -1
  75. package/src/config/assembly/finalize-config.js +64 -13
  76. package/src/config/index.d.ts +1 -0
  77. package/src/config/index.js +1 -0
  78. package/src/config/internal-types.d.ts +6 -0
  79. package/src/config/load-eco-config.d.ts +1 -0
  80. package/src/config/load-eco-config.js +11 -2
  81. package/src/config/resolve-eco-config-path.d.ts +2 -1
  82. package/src/config/resolve-eco-config-path.js +21 -15
  83. package/src/config/user-config-types.d.ts +9 -2
  84. package/src/dev/transform-server/dev-transform-server.js +1 -1
  85. package/src/dev/transform-server/dev-transform-vendor-registry.d.ts +29 -6
  86. package/src/dev/transform-server/dev-transform-vendor-registry.js +101 -53
  87. package/src/errors/http-error.d.ts +9 -0
  88. package/src/errors/http-error.js +11 -0
  89. package/src/html/html-transformer.service.d.ts +0 -21
  90. package/src/html/html-transformer.service.js +0 -32
  91. package/src/html-pages/html-page-module.d.ts +19 -0
  92. package/src/html-pages/html-page-module.js +66 -13
  93. package/src/html-pages/html-page-renderer.d.ts +6 -1
  94. package/src/html-pages/html-page-renderer.js +14 -6
  95. package/src/html-pages/html-pages.plugin.d.ts +10 -0
  96. package/src/html-pages/html-pages.plugin.js +7 -1
  97. package/src/index.d.ts +2 -0
  98. package/src/index.js +2 -0
  99. package/src/integration.d.ts +2 -2
  100. package/src/integration.js +1 -1
  101. package/src/islands/island-host.d.ts +1 -2
  102. package/src/islands/island-host.js +1 -2
  103. package/src/page-cache/page-cache-service.d.ts +8 -0
  104. package/src/page-cache/page-cache-service.js +12 -0
  105. package/src/plugins/integration-plugin.d.ts +34 -7
  106. package/src/plugins/integration-plugin.js +14 -2
  107. package/src/plugins/processor.d.ts +18 -1
  108. package/src/plugins/processor.js +20 -1
  109. package/src/plugins/server-dom.d.ts +29 -0
  110. package/src/plugins/server-dom.js +36 -0
  111. package/src/plugins/tsconfig-import-resolver.d.ts +3 -1
  112. package/src/plugins/tsconfig-import-resolver.js +4 -2
  113. package/src/processor.d.ts +1 -1
  114. package/src/route-renderer/error-pages/error-page-renderer.d.ts +6 -4
  115. package/src/route-renderer/error-pages/error-page-renderer.js +9 -5
  116. package/src/route-renderer/orchestration/document-shell/document-shell-render.service.d.ts +2 -44
  117. package/src/route-renderer/orchestration/document-shell/document-shell-render.service.js +14 -89
  118. package/src/route-renderer/orchestration/foreign-child/foreign-subtree-execution.service.d.ts +4 -16
  119. package/src/route-renderer/orchestration/foreign-child/foreign-subtree-execution.service.js +2 -10
  120. package/src/route-renderer/orchestration/foreign-child/render-session.d.ts +3 -5
  121. package/src/route-renderer/orchestration/integration-renderer.d.ts +21 -44
  122. package/src/route-renderer/orchestration/integration-renderer.js +69 -117
  123. package/src/route-renderer/orchestration/ownership-graph/page-client-browser-assets.d.ts +3 -4
  124. package/src/route-renderer/orchestration/ownership-graph/page-client-browser-assets.js +4 -15
  125. package/src/route-renderer/orchestration/ownership-graph/prepared-graph-membership.d.ts +22 -0
  126. package/src/route-renderer/orchestration/ownership-graph/prepared-graph-membership.js +45 -0
  127. package/src/route-renderer/orchestration/page-browser-graph/grouped-graph-build-plan.d.ts +0 -1
  128. package/src/route-renderer/orchestration/page-browser-graph/missing-production-browser-graph.d.ts +21 -0
  129. package/src/route-renderer/orchestration/page-browser-graph/missing-production-browser-graph.js +31 -0
  130. package/src/route-renderer/orchestration/page-browser-graph/page-browser-graph.service.js +58 -24
  131. package/src/route-renderer/orchestration/page-browser-graph/route-instance-key.d.ts +12 -0
  132. package/src/route-renderer/orchestration/page-browser-graph/route-instance-key.js +55 -0
  133. package/src/route-renderer/orchestration/route-pipeline/route-render-orchestrator.js +4 -3
  134. package/src/router/server/route-registry.d.ts +23 -1
  135. package/src/router/server/route-registry.js +41 -14
  136. package/src/static-site-generator/production-page-browser-graph-prebuild.d.ts +8 -2
  137. package/src/static-site-generator/production-page-browser-graph-prebuild.js +14 -13
  138. package/src/static-site-generator/static-site-generator.d.ts +19 -3
  139. package/src/static-site-generator/static-site-generator.js +78 -40
  140. package/src/types/build-types.d.ts +6 -0
  141. package/src/types/contracts.d.ts +26 -35
  142. package/src/types/eco-api-types.d.ts +1 -1
  143. package/src/types/public-types.d.ts +1 -0
  144. package/src/types/view-reference.d.ts +31 -0
  145. package/src/types/view-reference.js +15 -0
  146. package/src/utils/additional-watch-paths.d.ts +3 -3
  147. package/src/utils/additional-watch-paths.js +3 -1
  148. package/src/utils/resolve-entry-file.d.ts +4 -2
  149. package/src/utils/resolve-entry-file.js +4 -2
  150. package/src/utils/root-relative-path.d.ts +4 -0
  151. package/src/utils/root-relative-path.js +8 -0
  152. package/src/utils/server-bundle-context.d.ts +14 -0
  153. package/src/utils/server-bundle-context.js +45 -0
  154. package/src/watchers/project-watcher-ignore.d.ts +2 -5
  155. package/src/watchers/project-watcher-ignore.js +2 -5
  156. package/src/watchers/project-watcher.d.ts +9 -7
  157. package/src/watchers/project-watcher.js +100 -52
  158. package/src/watchers/workspace-package-watch-roots.d.ts +4 -4
  159. package/src/watchers/workspace-package-watch-roots.js +41 -25
  160. package/src/build/server/view-module-loader.d.ts +0 -10
  161. package/src/build/server/view-module-loader.js +0 -46
  162. package/src/route-renderer/orchestration/page-browser-graph/page-browser-graph-merge.utils.d.ts +0 -12
  163. package/src/route-renderer/orchestration/page-browser-graph/page-browser-graph-merge.utils.js +0 -32
@@ -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';
@@ -36,6 +37,7 @@ import { renderPageDocumentShell, } from './document-shell/document-shell-render
36
37
  import { resolveInnermostPageLayout, resolvePageLayoutComponents, resolveDocumentShellLayouts, } from './document-shell/layout-shell-props.service.js';
37
38
  import { finalizeIslandComponentRender } from '../../islands/island-host.js';
38
39
  import { isProductionRuntime } from '../../utils/runtime.js';
40
+ import { describeProductionBrowserGraphEntry, missingProductionBrowserGraphError, shouldRejectUnplannedProductionBrowserGraph, } from './page-browser-graph/missing-production-browser-graph.js';
39
41
  const syntheticExplicitViewKeys = new WeakMap();
40
42
  let nextSyntheticExplicitViewKey = 0;
41
43
  /**
@@ -193,7 +195,6 @@ export class IntegrationRenderer {
193
195
  pageClientBuildEntries,
194
196
  prebuiltPageClientBrowserAssets: {
195
197
  processedAssets: [],
196
- islandRenderAssetsByFile: new Map(),
197
198
  fallbackDependencies: [],
198
199
  },
199
200
  };
@@ -331,36 +332,6 @@ export class IntegrationRenderer {
331
332
  collectContribution: async () => mergePageBrowserGraphContributions(await this.collectPageBrowserGraphContribution(graphContext), resolvedPageDependencies?.contribution),
332
333
  });
333
334
  }
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
335
  /**
365
336
  * Renders a route page through optional layout and document shells.
366
337
  *
@@ -382,8 +353,7 @@ export class IntegrationRenderer {
382
353
  });
383
354
  return renderPageDocumentShell({
384
355
  renderComponentWithForeignChildren: (renderInput) => this.renderComponentWithForeignChildren(renderInput),
385
- appendProcessedDependencies: (...assetGroups) => this.appendProcessedDependencies(...assetGroups),
386
- }, { ...input, layouts, composeChildren, inheritedOwner: this.name }, this.DOC_TYPE);
356
+ }, { ...input, layouts, composeChildren }, this.DOC_TYPE);
387
357
  }
388
358
  serializeStringRenderChildren(children) {
389
359
  if (children === undefined) {
@@ -419,15 +389,10 @@ export class IntegrationRenderer {
419
389
  const props = serializedChildren === undefined ? input.props : { ...input.props, children: serializedChildren };
420
390
  const content = await component(props);
421
391
  this.assertStringRenderContent(input, content);
422
- const html = content;
423
- const assets = input.component.config?.dependencies
424
- ? await this.processComponentDependencies([input.component])
425
- : undefined;
426
392
  return {
427
- html,
393
+ html: content,
428
394
  canAttachAttributes: true,
429
395
  integrationName: this.name,
430
- assets,
431
396
  };
432
397
  }
433
398
  /**
@@ -446,21 +411,13 @@ export class IntegrationRenderer {
446
411
  runtimeContext: this.getQueuedForeignSubtreeContext(input),
447
412
  getOwningRenderer: (integrationName, rendererCache) => this.resolveOwningRenderer(integrationName, rendererCache),
448
413
  };
449
- const queuedForeignSubtreeResolution = this.integrationHooks.renderQueuedChildren
414
+ const html = this.integrationHooks.renderQueuedChildren
450
415
  ? await resolveQueuedHtml({
451
416
  ...queuedOptions,
452
417
  renderQueuedChildren: this.integrationHooks.renderQueuedChildren,
453
418
  })
454
419
  : 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
- };
420
+ return { ...componentRender, html };
464
421
  }
465
422
  constructor({ appConfig, assetProcessingService, assetProcessingIntegration, resolvedIntegrationDependencies, hooks, }) {
466
423
  this.appConfig = appConfig;
@@ -483,7 +440,6 @@ export class IntegrationRenderer {
483
440
  resolvedIntegrationDependencies,
484
441
  hooks: {},
485
442
  resolveDependencies: (components, options) => this.resolveDependencies(components, options),
486
- resolveComponentDependencies: (components, options) => this.processComponentDependencies(components, options),
487
443
  resolveDependencyPath: (componentDir, pathUrl) => this.resolveDependencyPath(componentDir, pathUrl),
488
444
  applyPendingLazyTriggers: (assets, configs) => this.dependencyResolverService.applyPendingLazyTriggers(assets, configs),
489
445
  })
@@ -570,11 +526,10 @@ export class IntegrationRenderer {
570
526
  applyAttributesToHtmlElement: (html, attributes) => this.applyAttributesToHtmlElement(html, attributes),
571
527
  });
572
528
  }
573
- async transformRouteResponse(response, htmlContributions, pagePackage, renderOptions) {
574
- const resolvedPagePackage = getComponentRenderContext()?.renderState?.session?.pagePackage ?? pagePackage;
529
+ async transformRouteResponse(response, htmlContributions, renderOptions) {
575
530
  const transformedResponse = this.htmlTransformer.transform(response, {
576
531
  contributions: htmlContributions,
577
- pagePackage: resolvedPagePackage,
532
+ pagePackage: renderOptions.pagePackage,
578
533
  });
579
534
  const body = (transformedResponse.body ?? (await transformedResponse.text()));
580
535
  return this.finalizeDocument(body, renderOptions);
@@ -738,9 +693,8 @@ export class IntegrationRenderer {
738
693
  const renderState = getComponentRenderContext()?.renderState;
739
694
  if (renderState) {
740
695
  renderState.pageClientPlan = renderOptions.pageClientPlan;
741
- renderState.islandRenderAssetsByFile = renderOptions.islandRenderAssetsByFile;
696
+ renderState.preparedGraphComponents = renderOptions.preparedGraphComponents;
742
697
  }
743
- session.pagePackage = renderOptions.pagePackage;
744
698
  return this.routeRenderOrchestrator.executePrepared(renderOptions, this);
745
699
  });
746
700
  return value;
@@ -830,39 +784,11 @@ export class IntegrationRenderer {
830
784
  return this.integrationHooks.documentContributions?.(context);
831
785
  }
832
786
  /**
833
- * Renders the route through the shared document shell.
787
+ * Renders the route, wrapping whatever it throws as `Error rendering page`.
834
788
  * Integrations can add preparation and final HTML hooks around core composition.
835
789
  */
836
790
  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
- };
791
+ const renderRoute = () => this.renderRouteDocument(options);
866
792
  try {
867
793
  return await (this.integrationHooks.renderRoute?.(options, renderRoute) ?? renderRoute());
868
794
  }
@@ -870,6 +796,42 @@ export class IntegrationRenderer {
870
796
  throw this.createRenderError('Error rendering page', error);
871
797
  }
872
798
  }
799
+ /**
800
+ * Renders the route document through the shared document shell.
801
+ *
802
+ * @remarks
803
+ * A subclass with its own document model overrides this rather than `render()`,
804
+ * so its errors still go through core's wrap.
805
+ */
806
+ async renderRouteDocument(options) {
807
+ const internalOptions = options;
808
+ await this.beforeRender(options);
809
+ const documentShellProps = this.integrationHooks.documentShellProps?.(options);
810
+ return await this.renderPageWithDocumentShell({
811
+ page: {
812
+ component: options.Page,
813
+ props: {
814
+ ...options.props,
815
+ params: options.params ?? {},
816
+ query: options.query ?? {},
817
+ locals: options.pageLocals,
818
+ },
819
+ },
820
+ layouts: resolveDocumentShellLayouts({
821
+ layout: options.Layout,
822
+ layoutEntries: options.layoutEntries,
823
+ params: options.params,
824
+ query: options.query,
825
+ locals: options.locals,
826
+ }),
827
+ htmlTemplate: options.HtmlTemplate,
828
+ metadata: options.metadata,
829
+ pageProps: documentShellProps?.pageProps ?? options.pageProps ?? options.props ?? {},
830
+ documentProps: documentShellProps?.documentProps,
831
+ foreignChildRoots: internalOptions.pageDependencyComponents,
832
+ transformDocumentHtml: (html) => this.transformDocumentHtml(html),
833
+ });
834
+ }
873
835
  async beforeRender(options) {
874
836
  await this.integrationHooks.beforeRender?.(options);
875
837
  }
@@ -885,6 +847,7 @@ export class IntegrationRenderer {
885
847
  * renderer's nested foreign-child handoff.
886
848
  */
887
849
  async renderComponentWithForeignChildren(input) {
850
+ assertComponentInPreparedGraph(input.component, getComponentRenderContext()?.renderState?.preparedGraphComponents);
888
851
  return await executeComponentRender({
889
852
  currentIntegrationName: this.name,
890
853
  input,
@@ -924,8 +887,7 @@ export class IntegrationRenderer {
924
887
  *
925
888
  * @remarks
926
889
  * `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.
890
+ * before the owning renderer renders the subtree around them.
929
891
  */
930
892
  resolveQueuedForeignSubtrees(html, runtimeContext, renderQueuedChildren) {
931
893
  return resolveQueuedHtml({
@@ -939,9 +901,8 @@ export class IntegrationRenderer {
939
901
  /**
940
902
  * Stamps `result` as an Island Host when the component itself declares a client script.
941
903
  *
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.
904
+ * @remarks Reads the component's own declarations, excluding Foreign Children: a component without
905
+ * scripts that wraps an island is not an island itself. Components without `dependencies` are never stamped.
945
906
  */
946
907
  finalizeIslandComponentRender(input, result) {
947
908
  const ownAssets = input.component.config?.dependencies
@@ -964,15 +925,6 @@ export class IntegrationRenderer {
964
925
  normalizeUnresolvedMarkerArtifactHtml(html) {
965
926
  return normalizeUnresolvedMarkerArtifactHtml(html);
966
927
  }
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
928
  /**
977
929
  * @remarks
978
930
  * The active plan is the page owner's, but it answers for any renderer: a nested renderer of
@@ -987,17 +939,6 @@ export class IntegrationRenderer {
987
939
  const plan = collectPageClientPlan([component, ...(foreignChildRoots ?? [])].map((root) => ({ component: root })), this.name);
988
940
  return planHasForeignChildDescendants(plan, component, this.name, foreignChildRoots);
989
941
  }
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
942
  /**
1002
943
  * Returns whether this renderer builds island and lazy-entry scripts in the
1003
944
  * app-wide grouped browser build that other page owners should run for the plan.
@@ -1010,8 +951,7 @@ export class IntegrationRenderer {
1010
951
  *
1011
952
  * @remarks
1012
953
  * 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.
954
+ * supplies what only the renderer has: the owning renderers of other Integrations and its asset service.
1015
955
  */
1016
956
  async buildPageClientBrowserAssets(plan, route) {
1017
957
  const prebuilt = route ? await this.buildPrebuiltPageClientBrowserAssets(plan, route) : undefined;
@@ -1026,7 +966,6 @@ export class IntegrationRenderer {
1026
966
  return buildPageClientBrowserAssets({
1027
967
  plan,
1028
968
  integrationName: this.name,
1029
- collectOwnIslandAssets: (ownPlan) => this.collectIslandRenderAssets(ownPlan),
1030
969
  resolveContributor: async (integrationName) => {
1031
970
  const owning = await this.resolveOwningRenderer(integrationName, rendererCache);
1032
971
  return owning instanceof IntegrationRenderer
@@ -1042,8 +981,10 @@ export class IntegrationRenderer {
1042
981
  }
1043
982
  async buildPrebuiltPageClientBrowserAssets(plan, route) {
1044
983
  const prebuiltInstance = this.resolvePrebuiltPageClientInstance(route);
1045
- if (!prebuiltInstance)
984
+ if (!prebuiltInstance) {
985
+ await this.rejectUnplannedProductionPageClientGraph(plan, route);
1046
986
  return undefined;
987
+ }
1047
988
  const currentEntries = await this.collectAppBrowserClientBuildEntries(plan);
1048
989
  const plannedEntries = prebuiltInstance.pageClientBuildEntries ?? [];
1049
990
  const hasMatchingEntries = JSON.stringify(currentEntries
@@ -1053,8 +994,12 @@ export class IntegrationRenderer {
1053
994
  .map((entry) => createAppBrowserClientEntryKey(entry.integrationName, entry.dependency))
1054
995
  .sort());
1055
996
  const prebuilt = hasMatchingEntries ? prebuiltInstance.prebuiltPageClientBrowserAssets : undefined;
1056
- if (!prebuilt)
997
+ if (!prebuilt) {
998
+ if (shouldRejectUnplannedProductionBrowserGraph(this.appConfig)) {
999
+ throw missingProductionBrowserGraphError(route.file, describeProductionBrowserGraphEntry(route.params));
1000
+ }
1057
1001
  return undefined;
1002
+ }
1058
1003
  const fallbackGroups = new Map();
1059
1004
  for (const { dependency, integrationName } of prebuilt.fallbackDependencies) {
1060
1005
  const dependencies = fallbackGroups.get(integrationName) ?? [];
@@ -1065,10 +1010,17 @@ export class IntegrationRenderer {
1065
1010
  const processedAssets = [...prebuilt.processedAssets, ...fallbackAssets];
1066
1011
  return {
1067
1012
  processedAssets,
1068
- islandRenderAssetsByFile: prebuilt.islandRenderAssetsByFile,
1069
1013
  lazyTriggers: this.dependencyResolverService.applyPendingLazyTriggers(processedAssets, plan.lazyConfigs),
1070
1014
  };
1071
1015
  }
1016
+ async rejectUnplannedProductionPageClientGraph(plan, route) {
1017
+ if (!shouldRejectUnplannedProductionBrowserGraph(this.appConfig))
1018
+ return;
1019
+ const currentEntries = await this.collectAppBrowserClientBuildEntries(plan);
1020
+ if (currentEntries.length > 0 || this.integrationHooks.buildIslandClientAssets) {
1021
+ throw missingProductionBrowserGraphError(route.file, describeProductionBrowserGraphEntry(route.params));
1022
+ }
1023
+ }
1072
1024
  resolvePrebuiltPageClientInstance(route) {
1073
1025
  const routeKey = createPrebuiltRoutePreparationKey(route);
1074
1026
  const exact = this.prebuiltPageClientBrowserAssets.get(routeKey);
@@ -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;
@@ -0,0 +1,21 @@
1
+ import type { EcoPagesAppConfig } from '../../../config/internal-types.js';
2
+ import type { PageParams } from '../../../types/contracts.js';
3
+ /**
4
+ * Formats the `entry …` label for {@link missingProductionBrowserGraphError}.
5
+ *
6
+ * @remarks
7
+ * Prefers Params when present. Otherwise formats the instance key next to its serializer.
8
+ */
9
+ export declare function describeProductionBrowserGraphEntry(params?: PageParams, dependencyInstanceKey?: string): string;
10
+ /**
11
+ * Returns whether production serving must reject a Page Browser Graph that was not built.
12
+ *
13
+ * @remarks
14
+ * True only after `ecopages start` restores the browser client manifest. Static export still
15
+ * builds a graph while writing HTML, including Lit workers that never load that manifest.
16
+ */
17
+ export declare function shouldRejectUnplannedProductionBrowserGraph(appConfig: EcoPagesAppConfig): boolean;
18
+ /**
19
+ * Error for a production request whose Page Browser Graph was not built by `ecopages build`.
20
+ */
21
+ export declare function missingProductionBrowserGraphError(routeFile: string, entry: string): Error;
@@ -0,0 +1,31 @@
1
+ import { isProductionRuntime } from '../../../utils/runtime.js';
2
+ import { requireAppRuntime } from '../../../utils/app-runtime.js';
3
+ import { describePageDependencyInstance, describePageDependencyInstanceKey } from './route-instance-key.js';
4
+ /**
5
+ * Formats the `entry …` label for {@link missingProductionBrowserGraphError}.
6
+ *
7
+ * @remarks
8
+ * Prefers Params when present. Otherwise formats the instance key next to its serializer.
9
+ */
10
+ export function describeProductionBrowserGraphEntry(params, dependencyInstanceKey) {
11
+ if (params && Object.keys(params).length > 0) {
12
+ return describePageDependencyInstance({ params });
13
+ }
14
+ return describePageDependencyInstanceKey(dependencyInstanceKey ?? '');
15
+ }
16
+ /**
17
+ * Returns whether production serving must reject a Page Browser Graph that was not built.
18
+ *
19
+ * @remarks
20
+ * True only after `ecopages start` restores the browser client manifest. Static export still
21
+ * builds a graph while writing HTML, including Lit workers that never load that manifest.
22
+ */
23
+ export function shouldRejectUnplannedProductionBrowserGraph(appConfig) {
24
+ return isProductionRuntime() && requireAppRuntime(appConfig).productionBrowserGraphsSealed;
25
+ }
26
+ /**
27
+ * Error for a production request whose Page Browser Graph was not built by `ecopages build`.
28
+ */
29
+ export function missingProductionBrowserGraphError(routeFile, entry) {
30
+ return new Error(`The production Page Browser Graph for ${routeFile} is missing from the manifest (entry ${entry}). Run \`ecopages build\` again.`);
31
+ }