@ecopages/core 0.2.0-beta.26 → 0.2.0-beta.28
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.
- package/README.md +1 -1
- package/package.json +98 -74
- package/src/adapters/bun/server-adapter.js +2 -2
- package/src/adapters/node/server-adapter.js +2 -2
- package/src/adapters/shared/hmr-entrypoint-registrar.d.ts +10 -0
- package/src/adapters/shared/hmr-entrypoint-registrar.js +34 -10
- package/src/adapters/shared/runtime-server-lifecycle.js +1 -1
- package/src/adapters/shared/server-static-builder.d.ts +2 -1
- package/src/adapters/shared/server-static-builder.js +16 -14
- package/src/adapters/shared/shared-hmr-manager.d.ts +11 -4
- package/src/adapters/shared/shared-hmr-manager.js +22 -3
- package/src/build/README.md +92 -46
- package/src/build/app-build-manifest-runtime.d.ts +28 -2
- package/src/build/app-build-manifest-runtime.js +26 -10
- package/src/build/{browser-runtime-plugin.d.ts → browser/browser-runtime-plugin.d.ts} +1 -1
- package/src/build/{browser-runtime-plugin.js → browser/browser-runtime-plugin.js} +1 -1
- package/src/build/{jsx-ownership-plugins.d.ts → browser/jsx-ownership-plugins.d.ts} +2 -2
- package/src/build/{jsx-ownership-plugins.js → browser/jsx-ownership-plugins.js} +2 -2
- package/src/build/build-adapter.d.ts +18 -21
- package/src/build/build-adapter.js +8 -43
- package/src/build/{build-input-fingerprint.d.ts → cache/build-input-fingerprint.d.ts} +3 -3
- package/src/build/cache/cache-constants.d.ts +4 -0
- package/src/build/cache/cache-constants.js +6 -0
- package/src/build/cache/cache-keys.d.ts +22 -0
- package/src/build/cache/cache-keys.js +63 -0
- package/src/build/{dev-browser-script-cache.d.ts → cache/dev-browser-script-cache.d.ts} +2 -2
- package/src/build/{dev-browser-script-cache.js → cache/dev-browser-script-cache.js} +4 -4
- package/src/build/{pages-unified-graph-build.d.ts → cache/pages-unified-graph-build.d.ts} +1 -1
- package/src/build/{pages-unified-graph-build.js → cache/pages-unified-graph-build.js} +18 -26
- package/src/build/{production-build-cache.d.ts → cache/production-build-cache.d.ts} +1 -1
- package/src/build/{production-build-cache.js → cache/production-build-cache.js} +2 -2
- package/src/build/{server-entry-build-cache.d.ts → cache/server-entry-build-cache.d.ts} +3 -4
- package/src/build/{server-entry-build-cache.js → cache/server-entry-build-cache.js} +16 -12
- package/src/build/{build-contracts.d.ts → contracts/build-contracts.d.ts} +1 -2
- package/src/build/contracts/build-manifest.d.ts +90 -0
- package/src/build/{build-manifest.js → contracts/build-manifest.js} +2 -2
- package/src/build/{rolldown-adapter-helpers.d.ts → rolldown/rolldown-adapter-helpers.d.ts} +20 -3
- package/src/build/{rolldown-adapter-helpers.js → rolldown/rolldown-adapter-helpers.js} +26 -6
- package/src/build/{rolldown-build-adapter.d.ts → rolldown/rolldown-build-adapter.d.ts} +1 -1
- package/src/build/{rolldown-plugin-bridge.d.ts → rolldown/rolldown-plugin-bridge.d.ts} +2 -2
- package/src/build/{rolldown-plugin-bridge.js → rolldown/rolldown-plugin-bridge.js} +1 -1
- package/src/build/{rolldown-source-transform-pass.d.ts → rolldown/rolldown-source-transform-pass.d.ts} +1 -1
- package/src/build/{rolldown-source-transform-pass.js → rolldown/rolldown-source-transform-pass.js} +4 -1
- package/src/build/{runtime-build-output-normalizer.js → rolldown/runtime-build-output-normalizer.js} +2 -2
- package/src/build/{build-profile-options.d.ts → runtime/build-profile-options.d.ts} +2 -2
- package/src/build/runtime/build-request-identity.d.ts +17 -0
- package/src/build/runtime/build-request-identity.js +54 -0
- package/src/build/runtime/build-request-policy.d.ts +59 -0
- package/src/build/runtime/build-request-policy.js +46 -0
- package/src/build/{build-runtime.d.ts → runtime/build-runtime.d.ts} +8 -4
- package/src/build/{build-runtime.js → runtime/build-runtime.js} +11 -11
- package/src/build/{deduping-build-executor.d.ts → runtime/deduping-build-executor.d.ts} +2 -9
- package/src/build/runtime/deduping-build-executor.js +34 -0
- package/src/build/{parallel-build-executor.d.ts → runtime/parallel-build-executor.d.ts} +1 -1
- package/src/build/{serialized-build-executor.d.ts → runtime/serialized-build-executor.d.ts} +1 -1
- package/src/config/config-builder.d.ts +1 -1
- package/src/diagnostics/startup-trace.d.ts +49 -2
- package/src/diagnostics/startup-trace.js +140 -8
- package/src/eco/eco.js +2 -2
- package/src/eco/eco.utils.d.ts +1 -1
- package/src/eco/eco.utils.js +1 -1
- package/src/hmr/client/hmr-runtime.js +2 -2
- package/src/hmr/hmr-file-change-prep.d.ts +10 -0
- package/src/hmr/hmr-file-change-prep.js +17 -0
- package/src/plugins/alias-resolver-plugin.d.ts +1 -1
- package/src/plugins/eco-component-meta-plugin.d.ts +1 -1
- package/src/plugins/foreign-jsx-override-plugin.d.ts +1 -1
- package/src/plugins/integration-plugin.d.ts +16 -5
- package/src/plugins/integration-plugin.js +11 -1
- package/src/plugins/processor.d.ts +36 -8
- package/src/plugins/source-transform.d.ts +1 -1
- package/src/route-renderer/GRAPH.md +22 -28
- package/src/route-renderer/README.md +12 -7
- package/src/route-renderer/orchestration/{document-shell-render.service.d.ts → document-shell/document-shell-render.service.d.ts} +19 -2
- package/src/route-renderer/orchestration/{document-shell-render.service.js → document-shell/document-shell-render.service.js} +28 -0
- package/src/route-renderer/orchestration/{layout-shell-props.service.d.ts → document-shell/layout-shell-props.service.d.ts} +1 -1
- package/src/route-renderer/orchestration/{component-render-context.d.ts → foreign-child/component-render-context.d.ts} +5 -5
- package/src/route-renderer/orchestration/{component-render-context.js → foreign-child/component-render-context.js} +1 -1
- package/src/route-renderer/orchestration/{render-output.utils.d.ts → foreign-child/foreign-child-output.utils.d.ts} +15 -7
- package/src/route-renderer/orchestration/{render-output.utils.js → foreign-child/foreign-child-output.utils.js} +31 -26
- package/src/route-renderer/orchestration/{foreign-subtree-execution.service.d.ts → foreign-child/foreign-subtree-execution.service.d.ts} +5 -5
- package/src/route-renderer/orchestration/{foreign-subtree-execution.service.js → foreign-child/foreign-subtree-execution.service.js} +7 -3
- package/src/route-renderer/orchestration/foreign-child/owning-renderer-resolution.d.ts +19 -0
- package/src/route-renderer/orchestration/foreign-child/owning-renderer-resolution.js +35 -0
- package/src/route-renderer/orchestration/integration-renderer.d.ts +14 -97
- package/src/route-renderer/orchestration/integration-renderer.js +90 -247
- package/src/route-renderer/orchestration/integration-renderer.test-fixtures.d.ts +75 -0
- package/src/route-renderer/orchestration/integration-renderer.test-fixtures.js +177 -0
- package/src/route-renderer/orchestration/{component-graph-collectors.d.ts → ownership-graph/component-graph-collectors.d.ts} +4 -4
- package/src/route-renderer/orchestration/{component-graph-collectors.js → ownership-graph/component-graph-collectors.js} +1 -1
- package/src/route-renderer/orchestration/{component-graph.d.ts → ownership-graph/component-graph.d.ts} +1 -3
- package/src/route-renderer/orchestration/{component-graph.js → ownership-graph/component-graph.js} +0 -2
- package/src/route-renderer/orchestration/{ownership-validation.service.d.ts → ownership-graph/ownership-validation.service.d.ts} +2 -2
- package/src/route-renderer/orchestration/{ownership-validation.service.js → ownership-graph/ownership-validation.service.js} +3 -4
- package/src/route-renderer/orchestration/{global-injector-assets.service.d.ts → page-browser-graph/global-injector-assets.service.d.ts} +3 -3
- package/src/route-renderer/orchestration/{global-injector-assets.service.js → page-browser-graph/global-injector-assets.service.js} +2 -2
- package/src/route-renderer/orchestration/{page-browser-graph-contribution.loader.d.ts → page-browser-graph/page-browser-graph-contribution.loader.d.ts} +1 -1
- package/src/route-renderer/orchestration/page-browser-graph/page-browser-graph-merge.utils.d.ts +12 -0
- package/src/route-renderer/orchestration/page-browser-graph/page-browser-graph-merge.utils.js +29 -0
- package/src/route-renderer/orchestration/page-browser-graph/page-browser-graph-session.d.ts +106 -0
- package/src/route-renderer/orchestration/page-browser-graph/page-browser-graph-session.js +436 -0
- package/src/route-renderer/orchestration/{page-browser-graph.service.d.ts → page-browser-graph/page-browser-graph.service.d.ts} +12 -6
- package/src/route-renderer/orchestration/{page-browser-graph.service.js → page-browser-graph/page-browser-graph.service.js} +91 -42
- package/src/route-renderer/orchestration/{processed-asset-dedupe.d.ts → page-browser-graph/processed-asset-dedupe.d.ts} +1 -1
- package/src/route-renderer/orchestration/{integration-route-render-adapter.d.ts → route-pipeline/integration-route-render-adapter.d.ts} +3 -10
- package/src/route-renderer/orchestration/{integration-route-render-adapter.js → route-pipeline/integration-route-render-adapter.js} +1 -3
- package/src/route-renderer/orchestration/route-pipeline/marker-artifact.utils.d.ts +6 -0
- package/src/route-renderer/orchestration/route-pipeline/marker-artifact.utils.js +27 -0
- package/src/route-renderer/orchestration/{route-html-finalization.service.d.ts → route-pipeline/route-html-finalization.service.d.ts} +2 -3
- package/src/route-renderer/orchestration/route-pipeline/route-html-finalization.service.js +21 -0
- package/src/route-renderer/orchestration/{route-prepared-options.builder.d.ts → route-pipeline/route-prepared-options.builder.d.ts} +3 -4
- package/src/route-renderer/orchestration/{route-prepared-options.builder.js → route-pipeline/route-prepared-options.builder.js} +3 -12
- package/src/route-renderer/orchestration/{route-prepared-options.utils.js → route-pipeline/route-prepared-options.utils.js} +1 -1
- package/src/route-renderer/orchestration/{route-render-orchestrator.d.ts → route-pipeline/route-render-orchestrator.d.ts} +8 -17
- package/src/route-renderer/orchestration/{route-render-orchestrator.js → route-pipeline/route-render-orchestrator.js} +12 -19
- package/src/route-renderer/orchestration/string-markup-renderer.js +1 -1
- package/src/services/assets/asset-processing-service/asset-processing.service.js +1 -1
- package/src/services/assets/asset-processing-service/assets.types.d.ts +1 -1
- package/src/services/assets/asset-processing-service/browser-runtime-asset.factory.d.ts +1 -1
- package/src/services/assets/asset-processing-service/processors/base/base-script-processor.d.ts +0 -2
- package/src/services/assets/asset-processing-service/processors/base/base-script-processor.js +2 -15
- package/src/services/assets/asset-processing-service/processors/script/content-script.processor.js +1 -1
- package/src/services/assets/browser-bundle.service.d.ts +27 -31
- package/src/services/assets/browser-bundle.service.js +12 -23
- package/src/services/html/html-transformer.service.js +1 -1
- package/src/services/invalidation/development-invalidation.service.d.ts +5 -0
- package/src/services/invalidation/development-invalidation.service.js +8 -9
- package/src/services/module-loading/app-server-module-transpiler.service.d.ts +8 -0
- package/src/services/module-loading/app-server-module-transpiler.service.js +1 -7
- package/src/services/module-loading/page-module-import.service.d.ts +1 -1
- package/src/services/module-loading/page-module-import.service.js +40 -28
- package/src/services/module-loading/route-module-build-cache.store.js +1 -1
- package/src/services/module-loading/route-module-build-manifest.d.ts +2 -9
- package/src/services/module-loading/route-module-build-manifest.js +12 -43
- package/src/services/module-loading/server-module-transpiler.service.d.ts +1 -1
- package/src/static-site-generator/README.md +1 -1
- package/src/static-site-generator/production-page-browser-graph-prebuild.d.ts +28 -0
- package/src/static-site-generator/production-page-browser-graph-prebuild.js +22 -0
- package/src/static-site-generator/static-build-invalidation.d.ts +2 -2
- package/src/static-site-generator/static-build-invalidation.js +3 -3
- package/src/static-site-generator/static-site-generator.js +23 -1
- package/src/types/internal-types.d.ts +10 -4
- package/src/types/public-types.d.ts +59 -10
- package/src/watchers/project-watcher.d.ts +3 -3
- package/src/watchers/project-watcher.js +15 -5
- package/src/build/build-manifest.d.ts +0 -33
- package/src/build/deduping-build-executor.js +0 -56
- package/src/build/runtime-build-executor.d.ts +0 -14
- package/src/build/runtime-build-executor.js +0 -16
- package/src/route-renderer/orchestration/declared-ownership-graph.d.ts +0 -1
- package/src/route-renderer/orchestration/declared-ownership-graph.js +0 -8
- package/src/route-renderer/orchestration/route-html-finalization.service.js +0 -26
- package/src/route-renderer/orchestration/template-serialization.d.ts +0 -38
- package/src/route-renderer/orchestration/template-serialization.js +0 -45
- /package/src/build/{browser-runtime-manifest.d.ts → browser/browser-runtime-manifest.d.ts} +0 -0
- /package/src/build/{browser-runtime-manifest.js → browser/browser-runtime-manifest.js} +0 -0
- /package/src/build/{browser-runtime-plugin-helpers.d.ts → browser/browser-runtime-plugin-helpers.d.ts} +0 -0
- /package/src/build/{browser-runtime-plugin-helpers.js → browser/browser-runtime-plugin-helpers.js} +0 -0
- /package/src/build/{lit-static-render-worker-context.d.ts → browser/lit-static-render-worker-context.d.ts} +0 -0
- /package/src/build/{lit-static-render-worker-context.js → browser/lit-static-render-worker-context.js} +0 -0
- /package/src/build/{build-input-fingerprint.js → cache/build-input-fingerprint.js} +0 -0
- /package/src/build/{build-contracts.js → contracts/build-contracts.js} +0 -0
- /package/src/build/{build-types.d.ts → contracts/build-types.d.ts} +0 -0
- /package/src/build/{build-types.js → contracts/build-types.js} +0 -0
- /package/src/build/{rolldown-build-adapter.js → rolldown/rolldown-build-adapter.js} +0 -0
- /package/src/build/{rolldown-build-invocation-metrics.d.ts → rolldown/rolldown-build-invocation-metrics.d.ts} +0 -0
- /package/src/build/{rolldown-build-invocation-metrics.js → rolldown/rolldown-build-invocation-metrics.js} +0 -0
- /package/src/build/{runtime-build-output-normalizer.d.ts → rolldown/runtime-build-output-normalizer.d.ts} +0 -0
- /package/src/build/{server-side-css-shim-plugin.d.ts → rolldown/server-side-css-shim-plugin.d.ts} +0 -0
- /package/src/build/{server-side-css-shim-plugin.js → rolldown/server-side-css-shim-plugin.js} +0 -0
- /package/src/build/{build-profile-options.js → runtime/build-profile-options.js} +0 -0
- /package/src/build/{parallel-build-executor.js → runtime/parallel-build-executor.js} +0 -0
- /package/src/build/{serialized-build-executor.js → runtime/serialized-build-executor.js} +0 -0
- /package/src/route-renderer/orchestration/{layout-shell-props.service.js → document-shell/layout-shell-props.service.js} +0 -0
- /package/src/route-renderer/orchestration/{page-browser-graph-contribution.loader.js → page-browser-graph/page-browser-graph-contribution.loader.js} +0 -0
- /package/src/route-renderer/orchestration/{processed-asset-dedupe.js → page-browser-graph/processed-asset-dedupe.js} +0 -0
- /package/src/route-renderer/orchestration/{route-prepared-options.utils.d.ts → route-pipeline/route-prepared-options.utils.d.ts} +0 -0
|
@@ -4,16 +4,16 @@
|
|
|
4
4
|
* @module
|
|
5
5
|
*/
|
|
6
6
|
import type { EcoPagesAppConfig, IHmrManager } from '../../types/internal-types.js';
|
|
7
|
-
import type { ComponentRenderInput, ComponentRenderResult, EcoComponent,
|
|
7
|
+
import type { ComponentRenderInput, ComponentRenderResult, EcoComponent, EcoPageFile, EcoPagesElement, HtmlTemplateProps, IntegrationRendererRenderOptions, PageBrowserGraphContribution, PageBrowserGraphContributionContext, PageBrowserGraphResult, PageMetadataProps, RouteRendererBody, RouteRendererOptions, RouteRenderResult } from '../../types/public-types.js';
|
|
8
8
|
import { type AssetProcessingService, type ProcessedAsset } from '../../services/assets/asset-processing-service/index.js';
|
|
9
9
|
import { HtmlTransformerService } from '../../services/html/html-transformer.service.js';
|
|
10
10
|
import type { HtmlDocumentContribution } from '../../services/html/html-transformer.service.js';
|
|
11
11
|
import { HttpError } from '../../errors/http-error.js';
|
|
12
12
|
import { DependencyResolverService } from '../page-loading/dependency-resolver.js';
|
|
13
13
|
import { PageModuleLoaderService } from '../page-loading/page-module-loader.js';
|
|
14
|
-
import { RouteRenderOrchestrator, type RouteRenderOrchestratorAdapter, type RouteRenderOrchestratorResolvedInputs } from './route-render-orchestrator.js';
|
|
15
|
-
import type { ForeignChildRuntime } from './component-render-context.js';
|
|
16
|
-
import { ForeignSubtreeExecutionService
|
|
14
|
+
import { RouteRenderOrchestrator, type RouteRenderOrchestratorAdapter, type RouteRenderOrchestratorResolvedInputs } from './route-pipeline/route-render-orchestrator.js';
|
|
15
|
+
import type { ForeignChildRuntime } from './foreign-child/component-render-context.js';
|
|
16
|
+
import { ForeignSubtreeExecutionService } from './foreign-child/foreign-subtree-execution.service.js';
|
|
17
17
|
/**
|
|
18
18
|
* Controls how one route module is loaded outside the normal render path.
|
|
19
19
|
*
|
|
@@ -67,6 +67,14 @@ export declare abstract class IntegrationRenderer<C = EcoPagesElement> {
|
|
|
67
67
|
private renderExclusiveChain;
|
|
68
68
|
protected DOC_TYPE: string;
|
|
69
69
|
private runRenderExclusive;
|
|
70
|
+
/**
|
|
71
|
+
* Activates the owning integration runtime on first render or graph use.
|
|
72
|
+
*/
|
|
73
|
+
protected ensureIntegrationRuntimeActivated(): Promise<void>;
|
|
74
|
+
/**
|
|
75
|
+
* Prebuilds the production Page Browser Graph for one route file.
|
|
76
|
+
*/
|
|
77
|
+
prebuildProductionPageBrowserGraph(routeFile: string): Promise<void>;
|
|
70
78
|
/**
|
|
71
79
|
* Loads one route module through the owning renderer's import path.
|
|
72
80
|
*
|
|
@@ -110,7 +118,6 @@ export declare abstract class IntegrationRenderer<C = EcoPagesElement> {
|
|
|
110
118
|
*/
|
|
111
119
|
protected prepareViewDependencies(view: EcoComponent, layout?: EcoComponent): Promise<ProcessedAsset[]>;
|
|
112
120
|
protected resolvePageBrowserGraphForFile(filePath: string): Promise<PageBrowserGraphResult | undefined>;
|
|
113
|
-
protected mergePageBrowserGraphIntoPagePackage(pageBrowserGraph?: PageBrowserGraphResult): PageBrowserGraphResult | undefined;
|
|
114
121
|
/**
|
|
115
122
|
* Merges component-scoped assets into the active HTML transformer state.
|
|
116
123
|
*
|
|
@@ -170,6 +177,7 @@ export declare abstract class IntegrationRenderer<C = EcoPagesElement> {
|
|
|
170
177
|
props: P;
|
|
171
178
|
ctx: RenderToResponseContext;
|
|
172
179
|
layout?: EcoComponent;
|
|
180
|
+
transformDocumentHtml?: (html: string) => string;
|
|
173
181
|
}): Promise<Response>;
|
|
174
182
|
/**
|
|
175
183
|
* Renders a route page through optional layout and document shells.
|
|
@@ -199,20 +207,6 @@ export declare abstract class IntegrationRenderer<C = EcoPagesElement> {
|
|
|
199
207
|
transformDocumentHtml?: (html: string) => string;
|
|
200
208
|
}): Promise<string>;
|
|
201
209
|
protected renderStringComponentWithSerializedChildren(input: ComponentRenderInput, component: (props: Record<string, unknown>) => Promise<EcoPagesElement> | EcoPagesElement): Promise<ComponentRenderResult>;
|
|
202
|
-
protected getForeignSubtreeTokenPrefix(): string;
|
|
203
|
-
protected getForeignSubtreeResolutionContextKey(): string;
|
|
204
|
-
protected createQueuedForeignSubtreeExecutionRuntime<TContext extends QueuedForeignSubtreeResolutionContext>(options: {
|
|
205
|
-
renderInput: ComponentRenderInput;
|
|
206
|
-
rendererCache: Map<string, IntegrationRenderer<any>>;
|
|
207
|
-
runtimeContextKey?: string;
|
|
208
|
-
tokenPrefix?: string;
|
|
209
|
-
createRuntimeContext?: (integrationContext: BaseIntegrationContext & Record<string, unknown>, rendererCache: Map<string, unknown>) => TContext;
|
|
210
|
-
}): ForeignChildRuntime;
|
|
211
|
-
protected getQueuedForeignSubtreeResolutionContext<TContext extends QueuedForeignSubtreeResolutionContext>(input: ComponentRenderInput): TContext | undefined;
|
|
212
|
-
protected resolveQueuedForeignSubtreeHtml<TContext extends QueuedForeignSubtreeResolutionContext>(html: string, runtimeContext: TContext | undefined, renderQueuedChildren: ForeignSubtreeQueuedHtmlOptions<TContext>['renderQueuedChildren'], queueLabel?: string): Promise<{
|
|
213
|
-
assets: ProcessedAsset[];
|
|
214
|
-
html: string;
|
|
215
|
-
}>;
|
|
216
210
|
/**
|
|
217
211
|
* Renders a string-first component, then resolves any queued foreign
|
|
218
212
|
* boundaries before returning final component HTML.
|
|
@@ -225,16 +219,6 @@ export declare abstract class IntegrationRenderer<C = EcoPagesElement> {
|
|
|
225
219
|
rendererModules?: unknown;
|
|
226
220
|
runtimeOrigin: string;
|
|
227
221
|
});
|
|
228
|
-
/**
|
|
229
|
-
* Returns the HTML path from the provided file path.
|
|
230
|
-
* It extracts the path relative to the pages directory and removes the 'index' part if present.
|
|
231
|
-
*
|
|
232
|
-
* @param file - The file path to extract the HTML path from.
|
|
233
|
-
* @returns The extracted HTML path.
|
|
234
|
-
*/
|
|
235
|
-
protected getHtmlPath({ file }: {
|
|
236
|
-
file: string;
|
|
237
|
-
}): string;
|
|
238
222
|
/**
|
|
239
223
|
* Returns the HTML template component.
|
|
240
224
|
* It imports the HTML template from the specified path in the app configuration.
|
|
@@ -262,27 +246,6 @@ export declare abstract class IntegrationRenderer<C = EcoPagesElement> {
|
|
|
262
246
|
* @returns The resolved dependency path.
|
|
263
247
|
*/
|
|
264
248
|
protected resolveDependencyPath(componentDir: string, pathUrl: string): string;
|
|
265
|
-
/**
|
|
266
|
-
* Extracts the dependencies from the provided component configuration.
|
|
267
|
-
* It resolves the paths for scripts and stylesheets based on the component directory.
|
|
268
|
-
*
|
|
269
|
-
* @param componentDir - The component directory path.
|
|
270
|
-
* @param scripts - The scripts to extract.
|
|
271
|
-
* @param stylesheets - The stylesheets to extract.
|
|
272
|
-
* @returns The extracted dependencies.
|
|
273
|
-
*/
|
|
274
|
-
protected extractDependencies({ componentDir, scripts, stylesheets, }: {
|
|
275
|
-
componentDir: string;
|
|
276
|
-
} & EcoComponentDependencies): EcoComponentDependencies;
|
|
277
|
-
/**
|
|
278
|
-
* Resolves lazy script paths to public asset URLs.
|
|
279
|
-
* Converts source paths to their final bundled output paths.
|
|
280
|
-
*
|
|
281
|
-
* @param componentDir - The component directory path.
|
|
282
|
-
* @param scripts - The lazy script paths to resolve.
|
|
283
|
-
* @returns Comma-separated string of resolved public script paths.
|
|
284
|
-
*/
|
|
285
|
-
protected resolveLazyScripts(componentDir: string, scripts: string[]): string;
|
|
286
249
|
/**
|
|
287
250
|
* Collects the dependencies for the provided components.
|
|
288
251
|
* Combines component-specific dependencies with global integration dependencies.
|
|
@@ -312,14 +275,7 @@ export declare abstract class IntegrationRenderer<C = EcoPagesElement> {
|
|
|
312
275
|
}): Promise<{
|
|
313
276
|
resolvedDependencies: ProcessedAsset[];
|
|
314
277
|
}>;
|
|
315
|
-
protected resolveRoutePageComponentRender(input: {
|
|
316
|
-
Page: EcoComponent;
|
|
317
|
-
Layout?: EcoComponent;
|
|
318
|
-
props: Record<string, unknown>;
|
|
319
|
-
routeOptions: RouteRendererOptions;
|
|
320
|
-
}): Promise<ComponentRenderResult | undefined>;
|
|
321
278
|
protected renderRouteBody(renderOptions: IntegrationRendererRenderOptions<C>): Promise<RouteRendererBody>;
|
|
322
|
-
protected transformRouteResponse(response: Response, htmlContributions?: HtmlDocumentContribution[], pagePackage?: PagePackageResult): Promise<RouteRendererBody>;
|
|
323
279
|
/**
|
|
324
280
|
* Prepares the render options for the integration renderer.
|
|
325
281
|
* It imports the page file, collects dependencies, and prepares the render options.
|
|
@@ -328,19 +284,6 @@ export declare abstract class IntegrationRenderer<C = EcoPagesElement> {
|
|
|
328
284
|
* @returns The prepared render options.
|
|
329
285
|
*/
|
|
330
286
|
protected prepareRenderOptions(options: RouteRendererOptions, adapter?: RouteRenderOrchestratorAdapter<C>): Promise<IntegrationRendererRenderOptions<C>>;
|
|
331
|
-
/**
|
|
332
|
-
* Controls whether the page root should be rendered through `renderComponent()`
|
|
333
|
-
* during route option preparation in component-capable modes.
|
|
334
|
-
*
|
|
335
|
-
* Integrations that already own page-level hydration (for example router-driven
|
|
336
|
-
* React rendering) can override this and return `false` to avoid duplicate root
|
|
337
|
-
* mount assets and competing hydration entrypoints.
|
|
338
|
-
*/
|
|
339
|
-
protected shouldRenderPageComponent(_input: {
|
|
340
|
-
Page: EcoComponent;
|
|
341
|
-
Layout?: EcoComponent;
|
|
342
|
-
options: RouteRendererOptions;
|
|
343
|
-
}): boolean;
|
|
344
287
|
/**
|
|
345
288
|
* Executes the integration renderer with the provided options.
|
|
346
289
|
*
|
|
@@ -348,7 +291,7 @@ export declare abstract class IntegrationRenderer<C = EcoPagesElement> {
|
|
|
348
291
|
* 1. Build normalized render options (`prepareRenderOptions`).
|
|
349
292
|
* 2. Render the route body once.
|
|
350
293
|
* 3. Reject unresolved route-level eco-marker artifacts.
|
|
351
|
-
* 4. Optionally apply
|
|
294
|
+
* 4. Optionally apply document attributes for integration-owned document boundaries.
|
|
352
295
|
* 5. Run HTML transformer with final dependency set.
|
|
353
296
|
*
|
|
354
297
|
* Stream-safety note: the first render result is normalized to a string once,
|
|
@@ -359,21 +302,6 @@ export declare abstract class IntegrationRenderer<C = EcoPagesElement> {
|
|
|
359
302
|
* @returns Rendered route body plus effective cache strategy.
|
|
360
303
|
*/
|
|
361
304
|
execute(options: RouteRendererOptions): Promise<RouteRenderResult>;
|
|
362
|
-
/**
|
|
363
|
-
* Finalizes already-resolved HTML for explicit renderer-owned paths.
|
|
364
|
-
*
|
|
365
|
-
* This keeps document and root-attribute stamping plus HTML transformation
|
|
366
|
-
* available after a renderer has completed nested foreign-subtree resolution without
|
|
367
|
-
* routing back through shared route execution.
|
|
368
|
-
*/
|
|
369
|
-
protected finalizeResolvedHtml(options: {
|
|
370
|
-
html: string;
|
|
371
|
-
partial?: boolean;
|
|
372
|
-
componentRootAttributes?: Record<string, string>;
|
|
373
|
-
documentAttributes?: Record<string, string>;
|
|
374
|
-
transformHtml?: boolean;
|
|
375
|
-
htmlContributions?: HtmlDocumentContribution[];
|
|
376
|
-
}): Promise<string>;
|
|
377
305
|
/**
|
|
378
306
|
* Returns document-level attributes to stamp onto the rendered `<html>` tag.
|
|
379
307
|
*
|
|
@@ -393,17 +321,6 @@ export declare abstract class IntegrationRenderer<C = EcoPagesElement> {
|
|
|
393
321
|
* response finalization logic.
|
|
394
322
|
*/
|
|
395
323
|
protected getHtmlDocumentContributions(_options: HtmlDocumentContributionContext<C>): HtmlDocumentContribution[] | undefined;
|
|
396
|
-
/**
|
|
397
|
-
* Returns a renderer instance for a given integration name.
|
|
398
|
-
*
|
|
399
|
-
* Uses a per-execution cache to avoid repeated renderer initialization.
|
|
400
|
-
*
|
|
401
|
-
* @param integrationName Target integration name.
|
|
402
|
-
* @param cache Render-pass renderer cache.
|
|
403
|
-
* @returns Renderer for the requested integration.
|
|
404
|
-
* @throws Error when no integration plugin matches `integrationName`.
|
|
405
|
-
*/
|
|
406
|
-
protected getIntegrationRendererForName(integrationName: string, cache: Map<string, ForeignSubtreeExecutionOwningRenderer>): ForeignSubtreeExecutionOwningRenderer;
|
|
407
324
|
/**
|
|
408
325
|
* Abstract method to render the integration-specific component.
|
|
409
326
|
* This method should be implemented by the specific integration renderer.
|
|
@@ -6,24 +6,31 @@ import { invariant } from "../../utils/invariant.js";
|
|
|
6
6
|
import { HttpError } from "../../errors/http-error.js";
|
|
7
7
|
import { DependencyResolverService } from "../page-loading/dependency-resolver.js";
|
|
8
8
|
import { PageModuleLoaderService } from "../page-loading/page-module-loader.js";
|
|
9
|
-
import { OwnershipValidationService } from "./ownership-validation.service.js";
|
|
10
|
-
import { hasForeignChildDescendantsInGraph } from "./component-graph-collectors.js";
|
|
9
|
+
import { OwnershipValidationService } from "./ownership-graph/ownership-validation.service.js";
|
|
10
|
+
import { hasForeignChildDescendantsInGraph } from "./ownership-graph/component-graph-collectors.js";
|
|
11
11
|
import {
|
|
12
12
|
RouteRenderOrchestrator
|
|
13
|
-
} from "./route-render-orchestrator.js";
|
|
14
|
-
import { createIntegrationRouteRenderAdapter } from "./integration-route-render-adapter.js";
|
|
15
|
-
import { loadPageBrowserGraphContribution } from "./page-browser-graph-contribution.loader.js";
|
|
16
|
-
import { normalizeUnresolvedMarkerArtifactHtml
|
|
13
|
+
} from "./route-pipeline/route-render-orchestrator.js";
|
|
14
|
+
import { createIntegrationRouteRenderAdapter } from "./route-pipeline/integration-route-render-adapter.js";
|
|
15
|
+
import { loadPageBrowserGraphContribution } from "./page-browser-graph/page-browser-graph-contribution.loader.js";
|
|
16
|
+
import { normalizeUnresolvedMarkerArtifactHtml } from "./route-pipeline/marker-artifact.utils.js";
|
|
17
|
+
import { isMarkupNodeLike } from "./foreign-child/foreign-child-output.utils.js";
|
|
17
18
|
import {
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
19
|
+
getForeignSubtreeResolutionContextKey,
|
|
20
|
+
getForeignSubtreeTokenPrefix,
|
|
21
|
+
resolveOwningIntegrationRenderer
|
|
22
|
+
} from "./foreign-child/owning-renderer-resolution.js";
|
|
23
|
+
import { ensureIntegrationRuntimeReady } from "../../build/app-build-manifest-runtime.js";
|
|
24
|
+
import { ForeignSubtreeExecutionService } from "./foreign-child/foreign-subtree-execution.service.js";
|
|
21
25
|
import {
|
|
22
|
-
applyDocumentShellAttributeStamping,
|
|
23
26
|
composeDocumentShell,
|
|
27
|
+
finalizeDocumentShellHtml,
|
|
24
28
|
renderPageDocumentShell
|
|
25
|
-
} from "./document-shell-render.service.js";
|
|
26
|
-
import {
|
|
29
|
+
} from "./document-shell/document-shell-render.service.js";
|
|
30
|
+
import {
|
|
31
|
+
resolveInnermostPageLayout,
|
|
32
|
+
resolvePageLayoutComponents
|
|
33
|
+
} from "./document-shell/layout-shell-props.service.js";
|
|
27
34
|
class IntegrationRenderer {
|
|
28
35
|
appConfig;
|
|
29
36
|
assetProcessingService;
|
|
@@ -45,13 +52,33 @@ class IntegrationRenderer {
|
|
|
45
52
|
renderExclusiveChain = Promise.resolve();
|
|
46
53
|
DOC_TYPE = "<!DOCTYPE html>";
|
|
47
54
|
runRenderExclusive(operation) {
|
|
48
|
-
const run = this.renderExclusiveChain.then(
|
|
55
|
+
const run = this.renderExclusiveChain.then(async () => {
|
|
56
|
+
await this.ensureIntegrationRuntimeActivated();
|
|
57
|
+
return operation();
|
|
58
|
+
});
|
|
49
59
|
this.renderExclusiveChain = run.then(
|
|
50
60
|
() => void 0,
|
|
51
61
|
() => void 0
|
|
52
62
|
);
|
|
53
63
|
return run;
|
|
54
64
|
}
|
|
65
|
+
/**
|
|
66
|
+
* Activates the owning integration runtime on first render or graph use.
|
|
67
|
+
*/
|
|
68
|
+
async ensureIntegrationRuntimeActivated() {
|
|
69
|
+
await ensureIntegrationRuntimeReady({
|
|
70
|
+
appConfig: this.appConfig,
|
|
71
|
+
integrationName: this.name,
|
|
72
|
+
runtimeOrigin: this.runtimeOrigin
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* Prebuilds the production Page Browser Graph for one route file.
|
|
77
|
+
*/
|
|
78
|
+
async prebuildProductionPageBrowserGraph(routeFile) {
|
|
79
|
+
await this.ensureIntegrationRuntimeActivated();
|
|
80
|
+
await this.resolvePageBrowserGraphForFile(routeFile);
|
|
81
|
+
}
|
|
55
82
|
/**
|
|
56
83
|
* Loads one route module through the owning renderer's import path.
|
|
57
84
|
*
|
|
@@ -165,36 +192,6 @@ class IntegrationRenderer {
|
|
|
165
192
|
)
|
|
166
193
|
});
|
|
167
194
|
}
|
|
168
|
-
mergePageBrowserGraphIntoPagePackage(pageBrowserGraph) {
|
|
169
|
-
if (!pageBrowserGraph) {
|
|
170
|
-
return void 0;
|
|
171
|
-
}
|
|
172
|
-
const currentPagePackage = this.htmlTransformer.getPagePackage();
|
|
173
|
-
const mergedPageBrowserGraph = currentPagePackage?.pageBrowserGraph ? {
|
|
174
|
-
entryAssets: this.htmlTransformer.dedupeProcessedAssets([
|
|
175
|
-
...currentPagePackage.pageBrowserGraph.entryAssets,
|
|
176
|
-
...pageBrowserGraph.entryAssets
|
|
177
|
-
]),
|
|
178
|
-
chunkAssets: this.htmlTransformer.dedupeProcessedAssets([
|
|
179
|
-
...currentPagePackage.pageBrowserGraph.chunkAssets,
|
|
180
|
-
...pageBrowserGraph.chunkAssets
|
|
181
|
-
])
|
|
182
|
-
} : pageBrowserGraph;
|
|
183
|
-
const pageBrowserGraphAssetKeys = new Set(
|
|
184
|
-
[...mergedPageBrowserGraph.entryAssets, ...mergedPageBrowserGraph.chunkAssets].map(
|
|
185
|
-
(asset) => buildProcessedAssetDedupeKey(asset)
|
|
186
|
-
)
|
|
187
|
-
);
|
|
188
|
-
const baseAssets = currentPagePackage ? currentPagePackage.assets.filter(
|
|
189
|
-
(asset) => !pageBrowserGraphAssetKeys.has(buildProcessedAssetDedupeKey(asset))
|
|
190
|
-
) : this.htmlTransformer.getProcessedDependencies();
|
|
191
|
-
this.htmlTransformer.setPagePackage(
|
|
192
|
-
createPagePackage(this.htmlTransformer.dedupeProcessedAssets(baseAssets), {
|
|
193
|
-
pageBrowserGraph: mergedPageBrowserGraph
|
|
194
|
-
})
|
|
195
|
-
);
|
|
196
|
-
return mergedPageBrowserGraph;
|
|
197
|
-
}
|
|
198
195
|
/**
|
|
199
196
|
* Merges component-scoped assets into the active HTML transformer state.
|
|
200
197
|
*
|
|
@@ -281,9 +278,13 @@ class IntegrationRenderer {
|
|
|
281
278
|
* @returns HTML response for the explicit view render.
|
|
282
279
|
*/
|
|
283
280
|
async renderViewWithDocumentShell(input) {
|
|
281
|
+
await this.ensureIntegrationRuntimeActivated();
|
|
284
282
|
const normalizedProps = input.props ?? {};
|
|
285
283
|
if (input.ctx.partial) {
|
|
286
|
-
return this.renderPartialViewResponse(
|
|
284
|
+
return this.renderPartialViewResponse({
|
|
285
|
+
...input,
|
|
286
|
+
transformHtml: input.transformDocumentHtml
|
|
287
|
+
});
|
|
287
288
|
}
|
|
288
289
|
await this.prepareViewDependencies(input.view, input.layout);
|
|
289
290
|
const HtmlTemplate = await this.getHtmlTemplate();
|
|
@@ -307,9 +308,12 @@ class IntegrationRenderer {
|
|
|
307
308
|
}
|
|
308
309
|
}
|
|
309
310
|
);
|
|
310
|
-
const
|
|
311
|
-
|
|
312
|
-
|
|
311
|
+
const transformedDocumentHtml = input.transformDocumentHtml ? input.transformDocumentHtml(documentHtml) : documentHtml;
|
|
312
|
+
this.appendProcessedDependencies(this.getRendererBootstrapDependencies(false));
|
|
313
|
+
const html = await finalizeDocumentShellHtml(this.htmlTransformer, {
|
|
314
|
+
html: `${this.DOC_TYPE}${transformedDocumentHtml}`,
|
|
315
|
+
partial: false,
|
|
316
|
+
htmlContributions: this.getHtmlDocumentContributions({ partial: false })
|
|
313
317
|
});
|
|
314
318
|
return this.createHtmlResponse(html, input.ctx);
|
|
315
319
|
}
|
|
@@ -346,7 +350,14 @@ class IntegrationRenderer {
|
|
|
346
350
|
}
|
|
347
351
|
const props = serializedChildren === void 0 ? input.props : { ...input.props, children: serializedChildren };
|
|
348
352
|
const content = await component(props);
|
|
349
|
-
|
|
353
|
+
if (typeof content !== "string") {
|
|
354
|
+
const componentFile = input.component.config?.__eco?.file ?? "unknown component";
|
|
355
|
+
const contentTag = Object.prototype.toString.call(content);
|
|
356
|
+
throw new TypeError(
|
|
357
|
+
`[ecopages] ${this.name} renderer expected a string render result for ${componentFile}, received ${contentTag}.`
|
|
358
|
+
);
|
|
359
|
+
}
|
|
360
|
+
const html = content;
|
|
350
361
|
const assets = input.component.config?.dependencies && typeof this.assetProcessingService?.processDependencies === "function" ? await this.processComponentDependencies([input.component]) : void 0;
|
|
351
362
|
return {
|
|
352
363
|
html,
|
|
@@ -356,39 +367,6 @@ class IntegrationRenderer {
|
|
|
356
367
|
assets
|
|
357
368
|
};
|
|
358
369
|
}
|
|
359
|
-
getForeignSubtreeTokenPrefix() {
|
|
360
|
-
return `__${this.name}_foreign_subtree__`;
|
|
361
|
-
}
|
|
362
|
-
getForeignSubtreeResolutionContextKey() {
|
|
363
|
-
return `__${this.name}_foreign_subtree_runtime__`;
|
|
364
|
-
}
|
|
365
|
-
createQueuedForeignSubtreeExecutionRuntime(options) {
|
|
366
|
-
return this.foreignSubtreeExecutionService.createQueuedRuntime({
|
|
367
|
-
renderInput: options.renderInput,
|
|
368
|
-
rendererCache: options.rendererCache,
|
|
369
|
-
runtimeContextKey: options.runtimeContextKey ?? this.getForeignSubtreeResolutionContextKey(),
|
|
370
|
-
tokenPrefix: options.tokenPrefix ?? this.getForeignSubtreeTokenPrefix(),
|
|
371
|
-
createRuntimeContext: options.createRuntimeContext
|
|
372
|
-
});
|
|
373
|
-
}
|
|
374
|
-
getQueuedForeignSubtreeResolutionContext(input) {
|
|
375
|
-
return this.foreignSubtreeExecutionService.getQueuedRuntimeContext(
|
|
376
|
-
input,
|
|
377
|
-
this.getForeignSubtreeResolutionContextKey()
|
|
378
|
-
);
|
|
379
|
-
}
|
|
380
|
-
async resolveQueuedForeignSubtreeHtml(html, runtimeContext, renderQueuedChildren, queueLabel = this.name) {
|
|
381
|
-
return this.foreignSubtreeExecutionService.resolveQueuedHtml({
|
|
382
|
-
currentIntegrationName: this.name,
|
|
383
|
-
html,
|
|
384
|
-
runtimeContext,
|
|
385
|
-
queueLabel,
|
|
386
|
-
getOwningRenderer: (integrationName, rendererCache) => this.getIntegrationRendererForName(integrationName, rendererCache),
|
|
387
|
-
applyAttributesToFirstElement: (resolvedHtml, attributes) => this.htmlTransformer.applyAttributesToFirstElement(resolvedHtml, attributes),
|
|
388
|
-
dedupeProcessedAssets: (assets) => this.htmlTransformer.dedupeProcessedAssets(assets),
|
|
389
|
-
renderQueuedChildren
|
|
390
|
-
});
|
|
391
|
-
}
|
|
392
370
|
/**
|
|
393
371
|
* Renders a string-first component, then resolves any queued foreign
|
|
394
372
|
* boundaries before returning final component HTML.
|
|
@@ -399,9 +377,16 @@ class IntegrationRenderer {
|
|
|
399
377
|
currentIntegrationName: this.name,
|
|
400
378
|
renderInput: input,
|
|
401
379
|
html: componentRender.html,
|
|
402
|
-
runtimeContextKey: this.
|
|
380
|
+
runtimeContextKey: getForeignSubtreeResolutionContextKey(this.name),
|
|
403
381
|
queueLabel: "String",
|
|
404
|
-
getOwningRenderer: (integrationName, rendererCache) =>
|
|
382
|
+
getOwningRenderer: (integrationName, rendererCache) => resolveOwningIntegrationRenderer({
|
|
383
|
+
appConfig: this.appConfig,
|
|
384
|
+
runtimeOrigin: this.runtimeOrigin,
|
|
385
|
+
currentIntegrationName: this.name,
|
|
386
|
+
currentRenderer: this,
|
|
387
|
+
integrationName,
|
|
388
|
+
cache: rendererCache
|
|
389
|
+
}),
|
|
405
390
|
applyAttributesToFirstElement: (html, attributes) => this.htmlTransformer.applyAttributesToFirstElement(html, attributes),
|
|
406
391
|
dedupeProcessedAssets: (assets) => this.htmlTransformer.dedupeProcessedAssets(assets)
|
|
407
392
|
});
|
|
@@ -435,23 +420,6 @@ class IntegrationRenderer {
|
|
|
435
420
|
ownershipValidationService: new OwnershipValidationService(appConfig)
|
|
436
421
|
});
|
|
437
422
|
}
|
|
438
|
-
/**
|
|
439
|
-
* Returns the HTML path from the provided file path.
|
|
440
|
-
* It extracts the path relative to the pages directory and removes the 'index' part if present.
|
|
441
|
-
*
|
|
442
|
-
* @param file - The file path to extract the HTML path from.
|
|
443
|
-
* @returns The extracted HTML path.
|
|
444
|
-
*/
|
|
445
|
-
getHtmlPath({ file }) {
|
|
446
|
-
const pagesDir = this.appConfig.absolutePaths.pagesDir;
|
|
447
|
-
const pagesIndex = file.indexOf(pagesDir);
|
|
448
|
-
if (pagesIndex === -1) return file;
|
|
449
|
-
const startIndex = file.indexOf(pagesDir) + pagesDir.length;
|
|
450
|
-
const endIndex = file.lastIndexOf("/");
|
|
451
|
-
const path = file.substring(startIndex, endIndex);
|
|
452
|
-
if (path === "/index") return "";
|
|
453
|
-
return path;
|
|
454
|
-
}
|
|
455
423
|
/**
|
|
456
424
|
* Returns the HTML template component.
|
|
457
425
|
* It imports the HTML template from the specified path in the app configuration.
|
|
@@ -505,46 +473,6 @@ class IntegrationRenderer {
|
|
|
505
473
|
resolveDependencyPath(componentDir, pathUrl) {
|
|
506
474
|
return this.dependencyResolverService.resolveDependencyPath(componentDir, pathUrl);
|
|
507
475
|
}
|
|
508
|
-
/**
|
|
509
|
-
* Extracts the dependencies from the provided component configuration.
|
|
510
|
-
* It resolves the paths for scripts and stylesheets based on the component directory.
|
|
511
|
-
*
|
|
512
|
-
* @param componentDir - The component directory path.
|
|
513
|
-
* @param scripts - The scripts to extract.
|
|
514
|
-
* @param stylesheets - The stylesheets to extract.
|
|
515
|
-
* @returns The extracted dependencies.
|
|
516
|
-
*/
|
|
517
|
-
extractDependencies({
|
|
518
|
-
componentDir,
|
|
519
|
-
scripts,
|
|
520
|
-
stylesheets
|
|
521
|
-
}) {
|
|
522
|
-
const scriptsPaths = [
|
|
523
|
-
...new Set(
|
|
524
|
-
(scripts ?? []).filter((script) => typeof script === "string" ? true : !script.lazy).map((script) => typeof script === "string" ? script : script.src).filter((script) => Boolean(script)).map((script) => this.resolveDependencyPath(componentDir, script))
|
|
525
|
-
)
|
|
526
|
-
];
|
|
527
|
-
const stylesheetsPaths = [
|
|
528
|
-
...new Set(
|
|
529
|
-
(stylesheets ?? []).map((style) => typeof style === "string" ? style : style.src).filter((style) => Boolean(style)).map((style) => this.resolveDependencyPath(componentDir, style))
|
|
530
|
-
)
|
|
531
|
-
];
|
|
532
|
-
return {
|
|
533
|
-
scripts: scriptsPaths,
|
|
534
|
-
stylesheets: stylesheetsPaths
|
|
535
|
-
};
|
|
536
|
-
}
|
|
537
|
-
/**
|
|
538
|
-
* Resolves lazy script paths to public asset URLs.
|
|
539
|
-
* Converts source paths to their final bundled output paths.
|
|
540
|
-
*
|
|
541
|
-
* @param componentDir - The component directory path.
|
|
542
|
-
* @param scripts - The lazy script paths to resolve.
|
|
543
|
-
* @returns Comma-separated string of resolved public script paths.
|
|
544
|
-
*/
|
|
545
|
-
resolveLazyScripts(componentDir, scripts) {
|
|
546
|
-
return this.dependencyResolverService.resolveLazyScripts(componentDir, scripts);
|
|
547
|
-
}
|
|
548
476
|
/**
|
|
549
477
|
* Collects the dependencies for the provided components.
|
|
550
478
|
* Combines component-specific dependencies with global integration dependencies.
|
|
@@ -579,13 +507,19 @@ class IntegrationRenderer {
|
|
|
579
507
|
resolveRouteDependencies: (input) => this.resolveRouteDependencies(input),
|
|
580
508
|
importPageFile: (file) => this.importPageFile(file),
|
|
581
509
|
collectPageBrowserGraphContribution: (context) => this.collectPageBrowserGraphContribution(context),
|
|
582
|
-
resolveRoutePageComponentRender: (input) => this.resolveRoutePageComponentRender(input),
|
|
583
510
|
renderRouteBody: (renderOptions) => this.renderRouteBody(renderOptions),
|
|
584
511
|
getDocumentAttributes: (renderOptions) => this.getDocumentAttributes(renderOptions),
|
|
585
512
|
getHtmlDocumentContributions: (options) => this.getHtmlDocumentContributions(options),
|
|
586
|
-
applyAttributesToFirstBodyElement: (html, attributes) => this.applyAttributesToFirstBodyElement(html, attributes),
|
|
587
513
|
applyAttributesToHtmlElement: (html, attributes) => this.applyAttributesToHtmlElement(html, attributes),
|
|
588
|
-
transformRouteResponse: (response, htmlContributions, pagePackage) =>
|
|
514
|
+
transformRouteResponse: async (response, htmlContributions, pagePackage) => {
|
|
515
|
+
const resolvedPagePackage = this.htmlTransformer.getPagePackage() ?? pagePackage;
|
|
516
|
+
const transformedResponse = await this.htmlTransformer.transform(
|
|
517
|
+
response,
|
|
518
|
+
htmlContributions,
|
|
519
|
+
resolvedPagePackage
|
|
520
|
+
);
|
|
521
|
+
return transformedResponse.body ?? await transformedResponse.text();
|
|
522
|
+
}
|
|
589
523
|
});
|
|
590
524
|
}
|
|
591
525
|
async resolveRouteRenderInputs(routeOptions) {
|
|
@@ -617,34 +551,9 @@ class IntegrationRenderer {
|
|
|
617
551
|
resolvedDependencies: await this.resolveDependencies(input.components)
|
|
618
552
|
};
|
|
619
553
|
}
|
|
620
|
-
async resolveRoutePageComponentRender(input) {
|
|
621
|
-
if (!this.shouldRenderPageComponent({ Page: input.Page, Layout: input.Layout, options: input.routeOptions })) {
|
|
622
|
-
return void 0;
|
|
623
|
-
}
|
|
624
|
-
return this.renderComponentWithForeignChildren({
|
|
625
|
-
component: input.Page,
|
|
626
|
-
props: {
|
|
627
|
-
...input.props,
|
|
628
|
-
params: input.routeOptions.params || {},
|
|
629
|
-
query: input.routeOptions.query || {}
|
|
630
|
-
},
|
|
631
|
-
integrationContext: {
|
|
632
|
-
componentInstanceId: "eco-page-root"
|
|
633
|
-
}
|
|
634
|
-
});
|
|
635
|
-
}
|
|
636
554
|
async renderRouteBody(renderOptions) {
|
|
637
555
|
return this.render(renderOptions);
|
|
638
556
|
}
|
|
639
|
-
async transformRouteResponse(response, htmlContributions, pagePackage) {
|
|
640
|
-
const resolvedPagePackage = this.htmlTransformer.getPagePackage() ?? pagePackage;
|
|
641
|
-
const transformedResponse = await this.htmlTransformer.transform(
|
|
642
|
-
response,
|
|
643
|
-
htmlContributions,
|
|
644
|
-
resolvedPagePackage
|
|
645
|
-
);
|
|
646
|
-
return transformedResponse.body ?? await transformedResponse.text();
|
|
647
|
-
}
|
|
648
557
|
/**
|
|
649
558
|
* Prepares the render options for the integration renderer.
|
|
650
559
|
* It imports the page file, collects dependencies, and prepares the render options.
|
|
@@ -658,17 +567,6 @@ class IntegrationRenderer {
|
|
|
658
567
|
this.htmlTransformer.setPagePackage(renderOptions.pagePackage);
|
|
659
568
|
return renderOptions;
|
|
660
569
|
}
|
|
661
|
-
/**
|
|
662
|
-
* Controls whether the page root should be rendered through `renderComponent()`
|
|
663
|
-
* during route option preparation in component-capable modes.
|
|
664
|
-
*
|
|
665
|
-
* Integrations that already own page-level hydration (for example router-driven
|
|
666
|
-
* React rendering) can override this and return `false` to avoid duplicate root
|
|
667
|
-
* mount assets and competing hydration entrypoints.
|
|
668
|
-
*/
|
|
669
|
-
shouldRenderPageComponent(_input) {
|
|
670
|
-
return true;
|
|
671
|
-
}
|
|
672
570
|
/**
|
|
673
571
|
* Executes the integration renderer with the provided options.
|
|
674
572
|
*
|
|
@@ -676,7 +574,7 @@ class IntegrationRenderer {
|
|
|
676
574
|
* 1. Build normalized render options (`prepareRenderOptions`).
|
|
677
575
|
* 2. Render the route body once.
|
|
678
576
|
* 3. Reject unresolved route-level eco-marker artifacts.
|
|
679
|
-
* 4. Optionally apply
|
|
577
|
+
* 4. Optionally apply document attributes for integration-owned document boundaries.
|
|
680
578
|
* 5. Run HTML transformer with final dependency set.
|
|
681
579
|
*
|
|
682
580
|
* Stream-safety note: the first render result is normalized to a string once,
|
|
@@ -694,42 +592,6 @@ class IntegrationRenderer {
|
|
|
694
592
|
return this.routeRenderOrchestrator.executePrepared(renderOptions, adapter);
|
|
695
593
|
});
|
|
696
594
|
}
|
|
697
|
-
/**
|
|
698
|
-
* Finalizes already-resolved HTML for explicit renderer-owned paths.
|
|
699
|
-
*
|
|
700
|
-
* This keeps document and root-attribute stamping plus HTML transformation
|
|
701
|
-
* available after a renderer has completed nested foreign-subtree resolution without
|
|
702
|
-
* routing back through shared route execution.
|
|
703
|
-
*/
|
|
704
|
-
async finalizeResolvedHtml(options) {
|
|
705
|
-
const rendererBootstrapDependencies = this.getRendererBootstrapDependencies(options.partial);
|
|
706
|
-
this.appendProcessedDependencies(rendererBootstrapDependencies);
|
|
707
|
-
let html = applyDocumentShellAttributeStamping(
|
|
708
|
-
options.html,
|
|
709
|
-
{
|
|
710
|
-
applyAttributesToFirstBodyElement: (nextHtml, attributes) => this.htmlTransformer.applyAttributesToFirstBodyElement(nextHtml, attributes),
|
|
711
|
-
applyAttributesToHtmlElement: (nextHtml, attributes) => this.htmlTransformer.applyAttributesToHtmlElement(nextHtml, attributes)
|
|
712
|
-
},
|
|
713
|
-
{
|
|
714
|
-
componentRootAttributes: options.componentRootAttributes,
|
|
715
|
-
documentAttributes: options.documentAttributes
|
|
716
|
-
}
|
|
717
|
-
);
|
|
718
|
-
const shouldTransform = options.transformHtml ?? !options.partial;
|
|
719
|
-
if (!shouldTransform) {
|
|
720
|
-
return html;
|
|
721
|
-
}
|
|
722
|
-
const htmlContributions = options.htmlContributions ?? this.getHtmlDocumentContributions({
|
|
723
|
-
partial: options.partial
|
|
724
|
-
});
|
|
725
|
-
const transformedResponse = await this.htmlTransformer.transform(
|
|
726
|
-
new Response(html, {
|
|
727
|
-
headers: { "Content-Type": "text/html" }
|
|
728
|
-
}),
|
|
729
|
-
htmlContributions
|
|
730
|
-
);
|
|
731
|
-
return await transformedResponse.text();
|
|
732
|
-
}
|
|
733
595
|
/**
|
|
734
596
|
* Returns document-level attributes to stamp onto the rendered `<html>` tag.
|
|
735
597
|
*
|
|
@@ -757,34 +619,6 @@ class IntegrationRenderer {
|
|
|
757
619
|
getHtmlDocumentContributions(_options) {
|
|
758
620
|
return void 0;
|
|
759
621
|
}
|
|
760
|
-
/**
|
|
761
|
-
* Returns a renderer instance for a given integration name.
|
|
762
|
-
*
|
|
763
|
-
* Uses a per-execution cache to avoid repeated renderer initialization.
|
|
764
|
-
*
|
|
765
|
-
* @param integrationName Target integration name.
|
|
766
|
-
* @param cache Render-pass renderer cache.
|
|
767
|
-
* @returns Renderer for the requested integration.
|
|
768
|
-
* @throws Error when no integration plugin matches `integrationName`.
|
|
769
|
-
*/
|
|
770
|
-
getIntegrationRendererForName(integrationName, cache) {
|
|
771
|
-
if (cache.has(integrationName)) {
|
|
772
|
-
return cache.get(integrationName);
|
|
773
|
-
}
|
|
774
|
-
if (integrationName === this.name) {
|
|
775
|
-
cache.set(integrationName, this);
|
|
776
|
-
return this;
|
|
777
|
-
}
|
|
778
|
-
const integrationPlugin = this.appConfig.integrations.find(
|
|
779
|
-
(integration) => integration.name === integrationName
|
|
780
|
-
);
|
|
781
|
-
invariant(!!integrationPlugin, `[ecopages] Integration not found for foreign owner: ${integrationName}`);
|
|
782
|
-
const renderer = integrationPlugin.initializeRenderer({
|
|
783
|
-
rendererModules: this.appConfig.runtime?.rendererModuleContext
|
|
784
|
-
});
|
|
785
|
-
cache.set(integrationName, renderer);
|
|
786
|
-
return renderer;
|
|
787
|
-
}
|
|
788
622
|
/**
|
|
789
623
|
* Renders one component under this integration's foreign-child runtime and resolves
|
|
790
624
|
* any nested foreign children captured during that render.
|
|
@@ -804,7 +638,14 @@ class IntegrationRenderer {
|
|
|
804
638
|
renderInput,
|
|
805
639
|
rendererCache
|
|
806
640
|
}),
|
|
807
|
-
getOwningRenderer: (integrationName, rendererCache) =>
|
|
641
|
+
getOwningRenderer: (integrationName, rendererCache) => resolveOwningIntegrationRenderer({
|
|
642
|
+
appConfig: this.appConfig,
|
|
643
|
+
runtimeOrigin: this.runtimeOrigin,
|
|
644
|
+
currentIntegrationName: this.name,
|
|
645
|
+
currentRenderer: this,
|
|
646
|
+
integrationName,
|
|
647
|
+
cache: rendererCache
|
|
648
|
+
})
|
|
808
649
|
});
|
|
809
650
|
}
|
|
810
651
|
normalizeComponentRenderOutput(result) {
|
|
@@ -891,9 +732,11 @@ class IntegrationRenderer {
|
|
|
891
732
|
* context or a different foreign-child execution strategy.
|
|
892
733
|
*/
|
|
893
734
|
createForeignChildRuntime(options) {
|
|
894
|
-
return this.
|
|
735
|
+
return this.foreignSubtreeExecutionService.createQueuedRuntime({
|
|
895
736
|
renderInput: options.renderInput,
|
|
896
|
-
rendererCache: options.rendererCache
|
|
737
|
+
rendererCache: options.rendererCache,
|
|
738
|
+
runtimeContextKey: getForeignSubtreeResolutionContextKey(this.name),
|
|
739
|
+
tokenPrefix: getForeignSubtreeTokenPrefix(this.name)
|
|
897
740
|
});
|
|
898
741
|
}
|
|
899
742
|
/**
|