@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
@@ -27,6 +27,17 @@ export class HttpError extends Error {
27
27
  error.name === 'HttpError' &&
28
28
  typeof error.status === 'number');
29
29
  }
30
+ /**
31
+ * Answers with an error's status and JSON body, whichever `HttpError` class threw it.
32
+ *
33
+ * @remarks
34
+ * An error that passed {@link HttpError.isHttpError} may come from an app bundle's own copy of
35
+ * this class, or be a duck-typed object without `toResponse()`, so the response is rebuilt from
36
+ * its fields.
37
+ */
38
+ static responseFor(error) {
39
+ return new HttpError(error.status, error.message, error.details).toResponse();
40
+ }
30
41
  /**
31
42
  * Serialize error to JSON for API responses.
32
43
  */
@@ -1,4 +1,3 @@
1
- import type { ProcessedAsset } from '../assets/asset-processing-service/assets.types.js';
2
1
  import type { PagePackageResult } from '../types/contracts.js';
3
2
  export type HtmlDocumentContributionPlacement = 'head-prepend' | 'head-append' | 'body-prepend' | 'body-append';
4
3
  export type HtmlDocumentContribution = {
@@ -26,30 +25,10 @@ export declare class HtmlTransformerService {
26
25
  * Sets attributes on the first `<html>` start tag.
27
26
  */
28
27
  applyAttributesToHtmlElement(html: string, attributes: Record<string, string>): string;
29
- /**
30
- * Sets attributes on the element that directly follows the `<body>` start tag.
31
- *
32
- * @remarks
33
- * Nothing is stamped when text or a comment comes first (whitespace aside).
34
- */
35
- applyAttributesToFirstBodyElement(html: string, attributes: Record<string, string>): string;
36
- /**
37
- * Removes duplicate processed assets while preserving first-seen order.
38
- *
39
- * @remarks
40
- * Dedupe keys include structural asset fields and HTML attributes so repeated
41
- * orchestration passes can merge assets safely without collapsing distinct tag
42
- * variants.
43
- */
44
- dedupeProcessedAssets(assets: ProcessedAsset[]): ProcessedAsset[];
45
28
  /**
46
29
  * Injects page assets and document contributions into a streaming HTML response.
47
30
  */
48
31
  transform(res: Response, input?: PageAssetInjection): Response;
49
- /**
50
- * Injects page assets and document contributions into a complete HTML string.
51
- */
52
- injectPageAssets(html: string, input?: PageAssetInjection): string;
53
32
  /**
54
33
  * @remarks
55
34
  * Each slot is inserted as one joined string, so contributions and assets keep
@@ -43,44 +43,12 @@ export class HtmlTransformerService {
43
43
  applyAttributesToHtmlElement(html, attributes) {
44
44
  return stampAttributes(html, attributes, (element) => element.tagName === 'html');
45
45
  }
46
- /**
47
- * Sets attributes on the element that directly follows the `<body>` start tag.
48
- *
49
- * @remarks
50
- * Nothing is stamped when text or a comment comes first (whitespace aside).
51
- */
52
- applyAttributesToFirstBodyElement(html, attributes) {
53
- let insideBody = false;
54
- return stampAttributes(html, attributes, (element) => {
55
- if (insideBody)
56
- return true;
57
- insideBody = element.tagName === 'body';
58
- return false;
59
- }, { leadingOnly: true });
60
- }
61
- /**
62
- * Removes duplicate processed assets while preserving first-seen order.
63
- *
64
- * @remarks
65
- * Dedupe keys include structural asset fields and HTML attributes so repeated
66
- * orchestration passes can merge assets safely without collapsing distinct tag
67
- * variants.
68
- */
69
- dedupeProcessedAssets(assets) {
70
- return dedupeProcessedAssets(assets);
71
- }
72
46
  /**
73
47
  * Injects page assets and document contributions into a streaming HTML response.
74
48
  */
75
49
  transform(res, input = {}) {
76
50
  return this.createRewriter(input.contributions ?? [], input.pagePackage).transform(res);
77
51
  }
78
- /**
79
- * Injects page assets and document contributions into a complete HTML string.
80
- */
81
- injectPageAssets(html, input = {}) {
82
- return this.createRewriter(input.contributions ?? [], input.pagePackage).transform(html);
83
- }
84
52
  /**
85
53
  * @remarks
86
54
  * Each slot is inserted as one joined string, so contributions and assets keep
@@ -31,10 +31,11 @@ export declare class HtmlPageRenderer extends StringMarkupRenderer {
31
31
  * A direct call reconciles here, so the Page head is never dropped.
32
32
  */
33
33
  render(options: IntegrationRendererRenderOptions): Promise<RouteRendererBody>;
34
+ renderRouteBody(options: InternalIntegrationRendererRenderOptions): Promise<RouteRendererBody>;
34
35
  /**
35
36
  * Renders the Page body and retains its head until core document contributions have been applied.
36
37
  */
37
- renderRouteBody(options: InternalIntegrationRendererRenderOptions): Promise<RouteRendererBody>;
38
+ protected renderRouteDocument(options: IntegrationRendererRenderOptions): Promise<RouteRendererBody>;
38
39
  private finalizeHtmlPageDocument;
39
40
  private renderHtmlPage;
40
41
  /**
@@ -86,13 +86,15 @@ export class HtmlPageRenderer extends StringMarkupRenderer {
86
86
  * A direct call reconciles here, so the Page head is never dropped.
87
87
  */
88
88
  async render(options) {
89
- const { html, head } = await this.renderHtmlPage(options);
90
- return reconcileHtmlPageDocument(html, head);
89
+ return this.finalizeHtmlPageDocument(await super.render(options), options);
90
+ }
91
+ async renderRouteBody(options) {
92
+ return super.render(options);
91
93
  }
92
94
  /**
93
95
  * Renders the Page body and retains its head until core document contributions have been applied.
94
96
  */
95
- async renderRouteBody(options) {
97
+ async renderRouteDocument(options) {
96
98
  const rendered = await this.renderHtmlPage(options);
97
99
  this.renderedHeads.set(options, rendered.head);
98
100
  return rendered.html;
@@ -6,12 +6,11 @@ export { type ForeignChildInterceptionInput, type ForeignChildInterceptionResult
6
6
  export { ensurePageConfigLayouts } from './eco/page-layout-normalization.js';
7
7
  export { collectJsxExtensions, createJsxImportSourcePragma, filterJsxSourceExtensions, isJsxSourceExtension, } from './plugins/jsx-import-source.utils.js';
8
8
  export { resolveDocumentShellLayouts, resolveInnermostPageLayout, resolveLayoutEntryProps, resolveLayoutShellProps, resolvePageLayoutComponents, type DocumentShellLayoutResolutionInput, type LayoutShellPropsContext, } from './route-renderer/orchestration/document-shell/layout-shell-props.service.js';
9
- export { mergePageBrowserGraph } from './route-renderer/orchestration/page-browser-graph/page-browser-graph-merge.utils.js';
10
9
  export { isRegisteredDevTransformEntrypoint, isRegisteredScriptEntrypoint } from './hmr/hmr-entrypoint-output.js';
11
10
  export { type HmrRegisteredEntrypointsContext } from './hmr/hmr-registered-entrypoints-context.js';
12
11
  export { HmrStrategy, HmrStrategyType } from './hmr/hmr-strategy.js';
13
12
  export { type DefinedIntegration, defineIntegration } from './plugins/define-integration.js';
14
- export { type AnyIntegrationPlugin, type EcoBuildOnLoadArgs, type EcoBuildOnLoadResult, type EcoBuildOnResolveArgs, type EcoBuildOnResolveResult, type EcoBuildPlugin, type EcoBuildPluginBuilder, IntegrationPlugin, type IntegrationPluginConfig, type IntegrationRendererBase, type IntegrationRuntimeContext, mergeIntegrationOptions, type StaticExportContext, type StaticExportRelease, } from './plugins/integration-plugin.js';
13
+ export { type AnyIntegrationPlugin, type EcoBuildOnLoadArgs, type EcoBuildOnLoadResult, type EcoBuildImportKind, type EcoBuildOnResolveArgs, type EcoBuildOnResolveResult, type EcoBuildPlugin, type EcoBuildPluginBuilder, IntegrationPlugin, type IntegrationPluginConfig, type IntegrationRendererBase, type IntegrationRuntimeContext, mergeIntegrationOptions, type StaticExportContext, type StaticExportRelease, } from './plugins/integration-plugin.js';
15
14
  export { CUSTOM_ELEMENT_SSR_PRELOAD_CACHE_SCOPES, CustomElementScriptPreloader, type CustomElementScriptPreloadScopeState, type CustomElementSsrPreloadComponent, invalidateCustomElementScriptPreload, } from './route-renderer/orchestration/custom-element-scripts/custom-element-script-preloader.js';
16
15
  export { createCustomElementServerModuleImporter, createSharedServerModuleImporter, } from './route-renderer/orchestration/custom-element-scripts/custom-element-server-module-importer.js';
17
16
  export { createCustomElementSsrPipelineImporter } from './route-renderer/orchestration/custom-element-scripts/custom-element-ssr-preload-entrypoint.js';
@@ -5,7 +5,6 @@ export { getComponentRenderContext, runWithComponentRenderContext, } from './eco
5
5
  export { ensurePageConfigLayouts } from './eco/page-layout-normalization.js';
6
6
  export { collectJsxExtensions, createJsxImportSourcePragma, filterJsxSourceExtensions, isJsxSourceExtension, } from './plugins/jsx-import-source.utils.js';
7
7
  export { resolveDocumentShellLayouts, resolveInnermostPageLayout, resolveLayoutEntryProps, resolveLayoutShellProps, resolvePageLayoutComponents, } from './route-renderer/orchestration/document-shell/layout-shell-props.service.js';
8
- export { mergePageBrowserGraph } from './route-renderer/orchestration/page-browser-graph/page-browser-graph-merge.utils.js';
9
8
  export { isRegisteredDevTransformEntrypoint, isRegisteredScriptEntrypoint } from './hmr/hmr-entrypoint-output.js';
10
9
  export {} from './hmr/hmr-registered-entrypoints-context.js';
11
10
  export { HmrStrategy, HmrStrategyType } from './hmr/hmr-strategy.js';
@@ -27,8 +27,7 @@ export declare function componentRenderHasIslandBootstrap(assets: Array<{
27
27
  *
28
28
  * @param ownAssets - Assets of the component and its same-Integration nested components, excluding Foreign Children
29
29
  * and the Foreign Subtrees rendered inside it.
30
- * @remarks The decision ignores `result.assets`, which usually also carries Foreign Subtree assets: a component
31
- * without scripts that wraps an island is not an island itself.
30
+ * @remarks A component without scripts that wraps an island is not an island itself.
32
31
  */
33
32
  export declare function finalizeIslandComponentRender<T extends {
34
33
  canAttachAttributes: boolean;
@@ -46,8 +46,7 @@ export function componentRenderHasIslandBootstrap(assets) {
46
46
  *
47
47
  * @param ownAssets - Assets of the component and its same-Integration nested components, excluding Foreign Children
48
48
  * and the Foreign Subtrees rendered inside it.
49
- * @remarks The decision ignores `result.assets`, which usually also carries Foreign Subtree assets: a component
50
- * without scripts that wraps an island is not an island itself.
49
+ * @remarks A component without scripts that wraps an island is not an island itself.
51
50
  */
52
51
  export function finalizeIslandComponentRender(input, result, ownAssets) {
53
52
  const componentInstanceId = input.integrationContext?.componentInstanceId;
@@ -7,7 +7,7 @@ import type { IntegrationRenderer, IntegrationRendererOptions } from '../route-r
7
7
  import { AssetProcessingService } from '../assets/asset-processing-service/asset-processing.service.js';
8
8
  import type { AssetDefinition, ProcessedAsset } from '../assets/asset-processing-service/assets.types.js';
9
9
  import type { StaticExportContext, StaticExportRelease } from '../static-site-generator/static-export-context.js';
10
- export type { EcoBuildLoader, EcoBuildOnLoadArgs, EcoBuildOnLoadResult, EcoBuildOnResolveArgs, EcoBuildOnResolveResult, EcoBuildPlugin, EcoBuildPluginBuilder, } from '../build/contracts/build-types.js';
10
+ export type { EcoBuildLoader, EcoBuildOnLoadArgs, EcoBuildOnLoadResult, EcoBuildImportKind, EcoBuildOnResolveArgs, EcoBuildOnResolveResult, EcoBuildPlugin, EcoBuildPluginBuilder, } from '../build/contracts/build-types.js';
11
11
  export type { PageBrowserGraphContribution, PageBrowserGraphContributionContext } from '../types/contracts.js';
12
12
  export type { StaticExportContext, StaticExportRelease } from '../static-site-generator/static-export-context.js';
13
13
  export type { HtmlDocumentContribution, HtmlDocumentContributionContext, } from '../route-renderer/orchestration/integration-renderer.js';
@@ -1,7 +1,7 @@
1
1
  import type { EcoBuildPlugin } from '../build/contracts/build-types.js';
2
2
  import type { EcoPagesAppConfig, IClientBridge } from '../config/internal-types.js';
3
3
  import { GENERATED_BASE_PATHS } from '../constants.js';
4
- export type { EcoBuildLoader, EcoBuildOnLoadArgs, EcoBuildOnLoadResult, EcoBuildOnResolveArgs, EcoBuildOnResolveResult, EcoBuildPlugin, EcoBuildPluginBuilder, } from '../build/contracts/build-types.js';
4
+ export type { EcoBuildLoader, EcoBuildOnLoadArgs, EcoBuildOnLoadResult, EcoBuildImportKind, EcoBuildOnResolveArgs, EcoBuildOnResolveResult, EcoBuildPlugin, EcoBuildPluginBuilder, } from '../build/contracts/build-types.js';
5
5
  export declare const PROCESSOR_ERRORS: {
6
6
  readonly CACHE_DIRECTORY_NOT_SET: "Cache directory not set in context";
7
7
  };
@@ -11,6 +11,8 @@ export declare function isBarePackageImportSpecifier(specifier: string, projectR
11
11
  /**
12
12
  * Resolves a bare npm package entry for browser vendor prebundles.
13
13
  *
14
+ * @param fromDirectory - Where resolution starts. Defaults to `projectRoot`; a vendor's own dependency
15
+ * resolves from the importing file's directory, since strict installs do not expose it at the root.
14
16
  * @returns The entry `path` and the installed package's root `package.json`
15
17
  * (`packageJsonPath`), which stays the root manifest when the entry sits below a
16
18
  * nested one such as `cjs/package.json`.
@@ -22,7 +24,7 @@ export declare function isBarePackageImportSpecifier(specifier: string, projectR
22
24
  * export condition so legacy UMD `exports.browser` entries cannot win during
23
25
  * Rolldown bundling.
24
26
  */
25
- export declare function resolveBarePackageBrowserEntry(projectRoot: string, specifier: string): {
27
+ export declare function resolveBarePackageBrowserEntry(projectRoot: string, specifier: string, fromDirectory?: string): {
26
28
  path: string;
27
29
  packageJsonPath?: string;
28
30
  } | undefined;
@@ -153,6 +153,8 @@ function getBrowserPackageResolver(projectRoot, mainFields, conditionNames) {
153
153
  /**
154
154
  * Resolves a bare npm package entry for browser vendor prebundles.
155
155
  *
156
+ * @param fromDirectory - Where resolution starts. Defaults to `projectRoot`; a vendor's own dependency
157
+ * resolves from the importing file's directory, since strict installs do not expose it at the root.
156
158
  * @returns The entry `path` and the installed package's root `package.json`
157
159
  * (`packageJsonPath`), which stays the root manifest when the entry sits below a
158
160
  * nested one such as `cjs/package.json`.
@@ -164,11 +166,11 @@ function getBrowserPackageResolver(projectRoot, mainFields, conditionNames) {
164
166
  * export condition so legacy UMD `exports.browser` entries cannot win during
165
167
  * Rolldown bundling.
166
168
  */
167
- export function resolveBarePackageBrowserEntry(projectRoot, specifier) {
169
+ export function resolveBarePackageBrowserEntry(projectRoot, specifier, fromDirectory = projectRoot) {
168
170
  const browserFirst = usesBrowserFirstPackageResolution(specifier);
169
171
  const mainFields = browserFirst ? BROWSER_FIRST_MAIN_FIELDS : MODULE_FIRST_MAIN_FIELDS;
170
172
  const conditionNames = browserFirst ? BROWSER_FIRST_CONDITION_NAMES : MODULE_FIRST_CONDITION_NAMES;
171
- const result = getBrowserPackageResolver(projectRoot, mainFields, conditionNames).sync(projectRoot, specifier);
173
+ const result = getBrowserPackageResolver(projectRoot, mainFields, conditionNames).sync(fromDirectory, specifier);
172
174
  if (result.error || !result.path) {
173
175
  return undefined;
174
176
  }
@@ -1,4 +1,4 @@
1
1
  export { writeHashedBrowserAsset } from './assets/hashed-browser-asset.js';
2
2
  export type { AssetDefinition, ProcessedAsset } from './types/asset-types.js';
3
- export { type EcoBuildOnLoadResult, type EcoBuildOnResolveArgs, type EcoBuildPlugin, type EcoBuildPluginBuilder, mergeProcessorOptions, Processor, type ProcessorConfig, type ProcessorContext, type ProcessorWatchChanges, type ProcessorWatchConfig, resolveGeneratedPath, writeGeneratedTypesPackage, } from './plugins/processor.js';
3
+ export { type EcoBuildOnLoadResult, type EcoBuildImportKind, type EcoBuildOnResolveArgs, type EcoBuildPlugin, type EcoBuildPluginBuilder, mergeProcessorOptions, Processor, type ProcessorConfig, type ProcessorContext, type ProcessorWatchChanges, type ProcessorWatchConfig, resolveGeneratedPath, writeGeneratedTypesPackage, } from './plugins/processor.js';
4
4
  export { getEcopagesEnv, isDevelopmentRuntime, isEcopagesEnvDisabled, isEcopagesEnvEnabled, isProductionRuntime, type EcopagesBooleanEnvironmentVariable, type EcopagesEnvironmentVariable, } from './env.js';
@@ -1,7 +1,5 @@
1
1
  import type { BaseIntegrationContext, ComponentRenderResult, EcoComponent, PageMetadataProps } from '../../../types/contracts.js';
2
2
  import type { InternalComponentRenderInput } from '../../../config/internal-types.js';
3
- import type { ProcessedAsset } from '../../../assets/asset-processing-service/index.js';
4
- import { HtmlTransformerService, type HtmlDocumentContribution } from '../../../html/html-transformer.service.js';
5
3
  export type DocumentShellLayoutInput = {
6
4
  component: EcoComponent;
7
5
  props?: Record<string, unknown>;
@@ -9,7 +7,6 @@ export type DocumentShellLayoutInput = {
9
7
  export type DocumentShellComposeChildrenContext = {
10
8
  primaryComponent: EcoComponent;
11
9
  primaryProps: Record<string, unknown>;
12
- primaryRender?: ComponentRenderResult;
13
10
  layouts: DocumentShellLayoutInput[];
14
11
  rendererCache: BaseIntegrationContext['rendererCache'];
15
12
  renderComponentWithForeignChildren: DocumentShellRenderDependencies['renderComponentWithForeignChildren'];
@@ -17,25 +14,16 @@ export type DocumentShellComposeChildrenContext = {
17
14
  export type DocumentShellComposeChildrenResult = {
18
15
  /** Serialized or element children passed to the HTML template shell. */
19
16
  children: unknown;
20
- layoutRenders: ComponentRenderResult[];
21
- /**
22
- * Primary/page render assets when the hook performs unified composition.
23
- *
24
- * @remarks
25
- * Omit only when the default sequential string path runs (core renders primary first).
26
- */
27
- primaryRender?: ComponentRenderResult;
28
17
  };
29
18
  /**
30
19
  * Optional hook that replaces default sequential string layout wrapping.
31
20
  *
32
21
  * @remarks
33
22
  * When provided, core skips the initial primary render and expects the hook to return
34
- * `children` for the HTML template. Supply `primaryRender` so dependency assets still merge.
23
+ * `children` for the HTML template.
35
24
  */
36
25
  export type DocumentShellComposeChildrenHook = (context: DocumentShellComposeChildrenContext) => Promise<DocumentShellComposeChildrenResult>;
37
26
  export type DocumentShellComposeInput = {
38
- inheritedOwner: string;
39
27
  primaryComponent: EcoComponent;
40
28
  primaryProps: Record<string, unknown>;
41
29
  /** Components whose ownership graphs must join the foreign-child decision. */
@@ -47,7 +35,6 @@ export type DocumentShellComposeInput = {
47
35
  documentProps: Record<string, unknown>;
48
36
  };
49
37
  export type DocumentShellPageRenderInput = {
50
- inheritedOwner: string;
51
38
  page: {
52
39
  component: EcoComponent;
53
40
  props: Record<string, unknown>;
@@ -65,16 +52,11 @@ export type DocumentShellPageRenderInput = {
65
52
  };
66
53
  export type DocumentShellRenderDependencies = {
67
54
  renderComponentWithForeignChildren(input: InternalComponentRenderInput): Promise<ComponentRenderResult>;
68
- appendProcessedDependencies(...assetGroups: Array<readonly ProcessedAsset[] | undefined>): ProcessedAsset[];
69
- };
70
- export type DocumentShellAttributeStamping = {
71
- applyAttributesToFirstBodyElement(html: string, attributes: Record<string, string>): string;
72
- applyAttributesToHtmlElement(html: string, attributes: Record<string, string>): string;
73
55
  };
74
56
  /**
75
57
  * Default sequential string-child composition for document shell layers.
76
58
  */
77
- export declare function composeSequentialLayoutChildren(context: DocumentShellComposeChildrenContext): Promise<DocumentShellComposeChildrenResult>;
59
+ export declare function composeSequentialLayoutChildren(context: DocumentShellComposeChildrenContext, primaryHtml: string): Promise<DocumentShellComposeChildrenResult>;
78
60
  /**
79
61
  * Composes page or view content through optional layout and document shells.
80
62
  *
@@ -84,31 +66,7 @@ export declare function composeSequentialLayoutChildren(context: DocumentShellCo
84
66
  export declare function composeDocumentShell(dependencies: DocumentShellRenderDependencies, input: DocumentShellComposeInput): Promise<{
85
67
  documentHtml: string;
86
68
  }>;
87
- /**
88
- * Applies optional component-root and document-root attribute stamping before HTML
89
- * transformation runs on explicit renderer-owned paths.
90
- */
91
- export declare function applyDocumentShellAttributeStamping(html: string, stamping: DocumentShellAttributeStamping, options: {
92
- componentRootAttributes?: Record<string, string>;
93
- documentAttributes?: Record<string, string>;
94
- }): string;
95
69
  /**
96
70
  * Builds the final serialized document HTML for one route page render.
97
71
  */
98
72
  export declare function renderPageDocumentShell(dependencies: DocumentShellRenderDependencies, input: DocumentShellPageRenderInput, docType: string): Promise<string>;
99
- /**
100
- * Finalizes already-resolved HTML for explicit renderer-owned paths.
101
- *
102
- * @remarks
103
- * Callers append renderer bootstrap dependencies before invoking this helper.
104
- * Stamps document/root attributes and runs HTML transformation after nested
105
- * foreign-subtree resolution without routing back through shared route execution.
106
- */
107
- export declare function finalizeDocumentShellHtml(htmlTransformer: HtmlTransformerService, options: {
108
- html: string;
109
- partial?: boolean;
110
- componentRootAttributes?: Record<string, string>;
111
- documentAttributes?: Record<string, string>;
112
- transformHtml?: boolean;
113
- htmlContributions?: HtmlDocumentContribution[];
114
- }): Promise<string>;
@@ -1,5 +1,3 @@
1
- import { getComponentOwner } from '../../../eco/component-identity.js';
2
- import { HtmlTransformerService } from '../../../html/html-transformer.service.js';
3
1
  import { getComponentRenderContext } from '../../../eco/component-render-context.js';
4
2
  function resolveDocumentShellLayouts(input) {
5
3
  if (input.layouts && input.layouts.length > 0) {
@@ -7,18 +5,11 @@ function resolveDocumentShellLayouts(input) {
7
5
  }
8
6
  return input.layout ? [input.layout] : [];
9
7
  }
10
- function resolveComponentIntegrationName(component, inheritedOwner) {
11
- return getComponentOwner(component, inheritedOwner);
12
- }
13
8
  /**
14
9
  * Default sequential string-child composition for document shell layers.
15
10
  */
16
- export async function composeSequentialLayoutChildren(context) {
17
- if (!context.primaryRender) {
18
- throw new Error('[ecopages] composeSequentialLayoutChildren requires primaryRender.');
19
- }
20
- let children = context.primaryRender.html;
21
- const layoutRenders = [];
11
+ export async function composeSequentialLayoutChildren(context, primaryHtml) {
12
+ let children = primaryHtml;
22
13
  for (const layout of [...context.layouts].reverse()) {
23
14
  const layoutRender = await context.renderComponentWithForeignChildren({
24
15
  component: layout.component,
@@ -26,13 +17,9 @@ export async function composeSequentialLayoutChildren(context) {
26
17
  children,
27
18
  integrationContext: { rendererCache: context.rendererCache },
28
19
  });
29
- layoutRenders.push(layoutRender);
30
20
  children = layoutRender.html;
31
21
  }
32
- return {
33
- children,
34
- layoutRenders,
35
- };
22
+ return { children };
36
23
  }
37
24
  /**
38
25
  * Composes page or view content through optional layout and document shells.
@@ -44,45 +31,25 @@ export async function composeDocumentShell(dependencies, input) {
44
31
  const rendererCache = (getComponentRenderContext()?.renderState?.session?.rendererCache ??
45
32
  new Map());
46
33
  const layouts = resolveDocumentShellLayouts(input);
47
- const composeChildren = input.composeChildren ?? composeSequentialLayoutChildren;
48
- const usesCustomComposeChildren = input.composeChildren !== undefined;
49
- let primaryRender;
34
+ const composeContext = {
35
+ primaryComponent: input.primaryComponent,
36
+ primaryProps: input.primaryProps,
37
+ layouts,
38
+ rendererCache,
39
+ renderComponentWithForeignChildren: dependencies.renderComponentWithForeignChildren,
40
+ };
50
41
  let children;
51
- let layoutRenders;
52
- if (usesCustomComposeChildren) {
53
- const composed = await composeChildren({
54
- primaryComponent: input.primaryComponent,
55
- primaryProps: input.primaryProps,
56
- layouts,
57
- rendererCache,
58
- renderComponentWithForeignChildren: dependencies.renderComponentWithForeignChildren,
59
- });
60
- children = composed.children;
61
- layoutRenders = composed.layoutRenders;
62
- primaryRender = composed.primaryRender ?? {
63
- html: typeof composed.children === 'string' ? composed.children : '',
64
- assets: [],
65
- canAttachAttributes: true,
66
- integrationName: resolveComponentIntegrationName(input.primaryComponent, input.inheritedOwner),
67
- };
42
+ if (input.composeChildren) {
43
+ ({ children } = await input.composeChildren(composeContext));
68
44
  }
69
45
  else {
70
- primaryRender = await dependencies.renderComponentWithForeignChildren({
46
+ const primaryRender = await dependencies.renderComponentWithForeignChildren({
71
47
  component: input.primaryComponent,
72
48
  props: input.primaryProps,
73
49
  foreignChildRoots: input.foreignChildRoots,
74
50
  integrationContext: { rendererCache },
75
51
  });
76
- const composed = await composeChildren({
77
- primaryComponent: input.primaryComponent,
78
- primaryProps: input.primaryProps,
79
- primaryRender,
80
- layouts,
81
- rendererCache,
82
- renderComponentWithForeignChildren: dependencies.renderComponentWithForeignChildren,
83
- });
84
- children = composed.children;
85
- layoutRenders = composed.layoutRenders;
52
+ ({ children } = await composeSequentialLayoutChildren(composeContext, primaryRender.html));
86
53
  }
87
54
  const documentRender = await dependencies.renderComponentWithForeignChildren({
88
55
  component: input.htmlTemplate,
@@ -90,31 +57,15 @@ export async function composeDocumentShell(dependencies, input) {
90
57
  children,
91
58
  integrationContext: { rendererCache },
92
59
  });
93
- dependencies.appendProcessedDependencies(primaryRender.assets, ...layoutRenders.map((layoutRender) => layoutRender.assets), documentRender.assets);
94
60
  return {
95
61
  documentHtml: documentRender.html,
96
62
  };
97
63
  }
98
- /**
99
- * Applies optional component-root and document-root attribute stamping before HTML
100
- * transformation runs on explicit renderer-owned paths.
101
- */
102
- export function applyDocumentShellAttributeStamping(html, stamping, options) {
103
- let nextHtml = html;
104
- if (options.componentRootAttributes && Object.keys(options.componentRootAttributes).length > 0) {
105
- nextHtml = stamping.applyAttributesToFirstBodyElement(nextHtml, options.componentRootAttributes);
106
- }
107
- if (options.documentAttributes && Object.keys(options.documentAttributes).length > 0) {
108
- nextHtml = stamping.applyAttributesToHtmlElement(nextHtml, options.documentAttributes);
109
- }
110
- return nextHtml;
111
- }
112
64
  /**
113
65
  * Builds the final serialized document HTML for one route page render.
114
66
  */
115
67
  export async function renderPageDocumentShell(dependencies, input, docType) {
116
68
  const { documentHtml: composedDocumentHtml } = await composeDocumentShell(dependencies, {
117
- inheritedOwner: input.inheritedOwner,
118
69
  primaryComponent: input.page.component,
119
70
  primaryProps: input.page.props,
120
71
  foreignChildRoots: input.foreignChildRoots,
@@ -133,29 +84,3 @@ export async function renderPageDocumentShell(dependencies, input, docType) {
133
84
  : composedDocumentHtml;
134
85
  return `${docType}${documentHtml}`;
135
86
  }
136
- /**
137
- * Finalizes already-resolved HTML for explicit renderer-owned paths.
138
- *
139
- * @remarks
140
- * Callers append renderer bootstrap dependencies before invoking this helper.
141
- * Stamps document/root attributes and runs HTML transformation after nested
142
- * foreign-subtree resolution without routing back through shared route execution.
143
- */
144
- export async function finalizeDocumentShellHtml(htmlTransformer, options) {
145
- const html = applyDocumentShellAttributeStamping(options.html, {
146
- applyAttributesToFirstBodyElement: (nextHtml, attributes) => htmlTransformer.applyAttributesToFirstBodyElement(nextHtml, attributes),
147
- applyAttributesToHtmlElement: (nextHtml, attributes) => htmlTransformer.applyAttributesToHtmlElement(nextHtml, attributes),
148
- }, {
149
- componentRootAttributes: options.componentRootAttributes,
150
- documentAttributes: options.documentAttributes,
151
- });
152
- const shouldTransform = options.transformHtml ?? !options.partial;
153
- if (!shouldTransform) {
154
- return html;
155
- }
156
- const context = getComponentRenderContext()?.renderState;
157
- return htmlTransformer.injectPageAssets(html, {
158
- contributions: options.htmlContributions,
159
- pagePackage: context?.session?.pagePackage,
160
- });
161
- }
@@ -1,4 +1,3 @@
1
- import type { ProcessedAsset } from '../../../assets/asset-processing-service/index.js';
2
1
  import type { BaseIntegrationContext, ComponentRenderInput, ComponentRenderResult, EcoComponent } from '../../../types/contracts.js';
3
2
  import type { InternalComponentRenderInput } from '../../../config/internal-types.js';
4
3
  import { type ForeignChildRuntime } from '../../../eco/component-render-context.js';
@@ -30,9 +29,7 @@ type QueuedForeignSubtreeIntegrationContext = BaseIntegrationContext & Record<st
30
29
  * @remarks
31
30
  * Set `html` when the host serialized the children, or `children` to pass them
32
31
  * to the owning renderer unserialized. Leave both unset when there are no
33
- * children. Assets are not returned here: the owning renderer reports the
34
- * foreign component's assets, and host components' assets come from their
35
- * declared dependencies.
32
+ * children.
36
33
  */
37
34
  export type QueuedForeignSubtreeChildRenderResult = {
38
35
  html?: string;
@@ -102,18 +99,9 @@ export declare function getRuntimeContext<TContext extends QueuedForeignSubtreeR
102
99
  * resolved. Structured children pass to the owning renderer unchanged; opaque
103
100
  * objects are rejected.
104
101
  */
105
- export declare function resolveStringQueuedHtml(options: ForeignSubtreeStringQueuedHtmlOptions): Promise<{
106
- assets: ProcessedAsset[];
107
- html: string;
108
- }>;
109
- export declare function resolveQueuedHtml<TContext extends QueuedForeignSubtreeResolutionContext>(options: ForeignSubtreeQueuedHtmlOptions<TContext>): Promise<{
110
- assets: ProcessedAsset[];
111
- html: string;
112
- }>;
113
- export declare function resolveQueuedForeignSubtreeTokens<TContext extends QueuedForeignSubtreeResolutionContext>(options: ResolveQueuedForeignSubtreeTokensOptions<TContext>): Promise<{
114
- assets: ProcessedAsset[];
115
- html: string;
116
- }>;
102
+ export declare function resolveStringQueuedHtml(options: ForeignSubtreeStringQueuedHtmlOptions): Promise<string>;
103
+ export declare function resolveQueuedHtml<TContext extends QueuedForeignSubtreeResolutionContext>(options: ForeignSubtreeQueuedHtmlOptions<TContext>): Promise<string>;
104
+ export declare function resolveQueuedForeignSubtreeTokens<TContext extends QueuedForeignSubtreeResolutionContext>(options: ResolveQueuedForeignSubtreeTokensOptions<TContext>): Promise<string>;
117
105
  /**
118
106
  * Runs one component render under the current integration's render context and
119
107
  * resolves any queued foreign subtrees captured during that render.
@@ -3,7 +3,6 @@ import { getComponentOwner } from '../../../eco/component-identity.js';
3
3
  import { getComponentRenderContext, runWithComponentRenderContext, } from '../../../eco/component-render-context.js';
4
4
  import { isMarkupNodeLike } from '../../../eco/component-render-output.js';
5
5
  import { assertForeignChildrenNotOpaque } from './foreign-child-output.utils.js';
6
- import { dedupeProcessedAssets } from '../../../assets/processed-asset-dedupe.js';
7
6
  /**
8
7
  * Executes one component render tree under Foreign Child support.
9
8
  *
@@ -120,13 +119,12 @@ export async function resolveQueuedHtml(options) {
120
119
  }
121
120
  export async function resolveQueuedForeignSubtreeTokens(options) {
122
121
  if (!options.runtimeContext || options.runtimeContext.queuedResolutions.length === 0) {
123
- return { assets: [], html: options.html };
122
+ return options.html;
124
123
  }
125
124
  const runtimeContext = options.runtimeContext;
126
125
  const queuedResolutionsByToken = new Map();
127
126
  const resolvedHtmlByToken = new Map();
128
127
  const resolvingTokens = new Set();
129
- const collectedAssets = [];
130
128
  const syncQueuedResolutions = () => {
131
129
  for (const resolution of runtimeContext.queuedResolutions) {
132
130
  if (!queuedResolutionsByToken.has(resolution.token)) {
@@ -163,9 +161,6 @@ export async function resolveQueuedForeignSubtreeTokens(options) {
163
161
  if (!foreignSubtreeRender) {
164
162
  throw new Error(`[ecopages] ${options.queueLabel} queued foreign subtree could not resolve its owning renderer.`);
165
163
  }
166
- if ((foreignSubtreeRender.assets?.length ?? 0) > 0) {
167
- collectedAssets.push(...(foreignSubtreeRender.assets ?? []));
168
- }
169
164
  const resolvedHtml = foreignSubtreeRender.canAttachAttributes && foreignSubtreeRender.rootAttributes
170
165
  ? applyAttributesToFirstElement(foreignSubtreeRender.html, foreignSubtreeRender.rootAttributes)
171
166
  : foreignSubtreeRender.html;
@@ -185,10 +180,7 @@ export async function resolveQueuedForeignSubtreeTokens(options) {
185
180
  }
186
181
  resolvedHtml = resolvedHtml.split(resolution.token).join(await resolveToken(resolution.token));
187
182
  }
188
- return {
189
- assets: dedupeProcessedAssets(collectedAssets),
190
- html: resolvedHtml,
191
- };
183
+ return resolvedHtml;
192
184
  }
193
185
  /**
194
186
  * Runs one component render under the current integration's render context and
@@ -1,23 +1,21 @@
1
1
  import type { ProcessedAsset } from '../../../assets/asset-processing-service/assets.types.js';
2
- import type { PagePackageResult } from '../../../types/contracts.js';
3
2
  import type { PageClientPlan } from '../ownership-graph/page-client-plan.js';
4
3
  /**
5
4
  * Mutable state for one route or view render.
6
5
  *
7
6
  * @remarks
8
7
  * Integration renderers are cached per Integration. This session keeps one
9
- * render's assets, integration dependencies, and foreign-renderer cache from
10
- * leaking into another render on the same instance.
8
+ * render's integration dependencies and foreign-renderer cache from leaking
9
+ * into another render on the same instance.
11
10
  */
12
11
  export type RenderSession = {
13
- pagePackage?: PagePackageResult;
14
12
  resolvedIntegrationDependencies: ProcessedAsset[];
15
13
  rendererCache: Map<string, unknown>;
16
14
  };
17
15
  /** Renderer-owned state attached to an active Eco component render context. */
18
16
  export type RouteRenderContextState = {
19
17
  pageClientPlan?: PageClientPlan;
20
- islandRenderAssetsByFile?: ReadonlyMap<string, ProcessedAsset[]>;
18
+ preparedGraphComponents?: ReadonlyMap<string, boolean>;
21
19
  session?: RenderSession;
22
20
  };
23
21
  /**