@ecopages/core 0.8.0 → 0.10.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.
- package/README.md +2 -2
- package/package.json +14 -4
- package/src/adapters/node/create-app.d.ts +5 -5
- package/src/adapters/node/create-app.js +1 -1
- package/src/adapters/node/server-adapter.d.ts +1 -0
- package/src/adapters/node/server-adapter.js +4 -1
- package/src/adapters/shared/hmr/hmr-manager.d.ts +2 -0
- package/src/adapters/shared/hmr/hmr-manager.js +8 -4
- package/src/adapters/shared/http/api-request-pipeline.d.ts +16 -3
- package/src/adapters/shared/http/api-request-pipeline.js +23 -16
- package/src/adapters/shared/http/define-api-handler.d.ts +8 -8
- package/src/adapters/shared/http/explicit-static-route-matcher.js +8 -4
- package/src/adapters/shared/http/file-route-middleware-pipeline.d.ts +10 -11
- package/src/adapters/shared/http/file-route-middleware-pipeline.js +5 -6
- package/src/adapters/shared/http/fs-server-response-matcher.js +12 -4
- package/src/adapters/shared/http/run-middleware-chain.d.ts +29 -2
- package/src/adapters/shared/http/run-middleware-chain.js +108 -10
- package/src/adapters/shared/runtime/render-context.d.ts +2 -0
- package/src/adapters/shared/runtime/render-context.js +6 -21
- package/src/adapters/shared/runtime/server-request-pipeline.d.ts +2 -2
- package/src/adapters/shared/runtime/server-request-pipeline.js +4 -3
- package/src/adapters/shared/runtime/server-static-builder.js +4 -1
- package/src/adapters/shared/runtime/unattached-scripts.d.ts +17 -0
- package/src/adapters/shared/runtime/unattached-scripts.js +57 -0
- package/src/adapters/shared/ws/node-http-websocket-upgrades.js +3 -2
- package/src/adapters/shared/ws/ws-pattern-matcher.d.ts +14 -1
- package/src/adapters/shared/ws/ws-pattern-matcher.js +14 -13
- package/src/assets/app-browser-client-build.js +3 -0
- package/src/assets/asset-processing-service/asset-processing.service.d.ts +9 -0
- package/src/assets/asset-processing-service/asset-processing.service.js +19 -0
- package/src/assets/asset-processing-service/processed-asset-ledger.d.ts +16 -2
- package/src/assets/asset-processing-service/processed-asset-ledger.js +31 -3
- package/src/build/build-graph.d.ts +19 -2
- package/src/build/build-graph.js +19 -18
- package/src/build/cache/pages-unified-graph-build.d.ts +4 -6
- package/src/build/cache/pages-unified-graph-build.js +14 -51
- package/src/build/cache/server-module-entries.d.ts +5 -9
- package/src/build/cache/server-module-entries.js +5 -58
- package/src/build/contracts/build-contracts.d.ts +15 -0
- package/src/build/contracts.d.ts +1 -1
- package/src/build/contracts.js +1 -1
- package/src/build/production-asset-ledger.d.ts +1 -1
- package/src/build/production-asset-ledger.js +4 -2
- package/src/build/rolldown/file-role-grammar-plugin.d.ts +11 -0
- package/src/build/rolldown/file-role-grammar-plugin.js +32 -0
- package/src/build/rolldown/rolldown-adapter-helpers.d.ts +11 -0
- package/src/build/rolldown/rolldown-adapter-helpers.js +79 -10
- package/src/build/rolldown/ssr-script-entries-plugin.d.ts +31 -0
- package/src/build/rolldown/ssr-script-entries-plugin.js +104 -0
- package/src/build/runtime/build-request-policy.js +4 -1
- package/src/build/server/server-modules-manifest.d.ts +6 -1
- package/src/build/server/server-modules-manifest.js +10 -1
- package/src/build/server/view-reference.d.ts +9 -0
- package/src/build/server/view-reference.js +11 -0
- package/src/build.d.ts +3 -1
- package/src/build.js +3 -1
- package/src/cli.d.ts +14 -0
- package/src/cli.js +14 -0
- package/src/config/assembly/app-runtime.d.ts +13 -0
- package/src/config/assembly/app-runtime.js +2 -0
- package/src/config/assembly/finalize-config.js +13 -8
- package/src/config/internal-types.d.ts +0 -12
- package/src/config/resolve-eco-config-path.d.ts +2 -0
- package/src/config/resolve-eco-config-path.js +2 -1
- package/src/config/server-config-bundle.d.ts +0 -1
- package/src/config/server-config-bundle.js +1 -1
- package/src/config/user-config-types.d.ts +0 -12
- package/src/declarations.d.ts +2 -0
- package/src/dev/invalidation/development-invalidation.service.d.ts +0 -2
- package/src/dev/invalidation/development-invalidation.service.js +1 -11
- package/src/dev/transform-server/dev-transform-vendor-registry.js +33 -19
- package/src/eco/discovered-dependencies.d.ts +5 -0
- package/src/eco/discovered-dependencies.js +9 -0
- package/src/eco/eco.browser.js +6 -26
- package/src/eco/eco.js +24 -16
- package/src/eco/migration-docs.d.ts +7 -0
- package/src/eco/migration-docs.js +7 -0
- package/src/eco/page-data-hooks.d.ts +27 -0
- package/src/eco/page-data-hooks.js +64 -0
- package/src/eco/page-layout-normalization.d.ts +2 -2
- package/src/hmr/client/hmr-runtime.js +1 -1
- package/src/hmr/strategies/js-hmr-strategy.d.ts +0 -2
- package/src/hmr/strategies/server-rendered-template-hmr-strategy.d.ts +2 -1
- package/src/hmr/strategies/server-rendered-template-hmr-strategy.js +4 -3
- package/src/html/html-rewriter.d.ts +9 -7
- package/src/html/html-rewriter.js +26 -41
- package/src/html/html-transformer.service.d.ts +2 -2
- package/src/html/html-transformer.service.js +21 -15
- package/src/html-pages/html-page-module-scripts.js +2 -1
- package/src/html-pages/html-pages.plugin.d.ts +1 -1
- package/src/html-pages/html-pages.plugin.js +1 -1
- package/src/index.d.ts +1 -0
- package/src/index.js +1 -0
- package/src/integration.d.ts +2 -2
- package/src/integration.js +2 -2
- package/src/islands/island-host.d.ts +16 -5
- package/src/islands/island-host.js +8 -1
- package/src/middleware/create-middleware.d.ts +41 -0
- package/src/middleware/create-middleware.js +72 -0
- package/src/plugins/component-import-discovery.d.ts +14 -1
- package/src/plugins/component-import-discovery.js +36 -16
- package/src/plugins/eco-component-meta-plugin.d.ts +38 -0
- package/src/plugins/eco-component-meta-plugin.js +208 -44
- package/src/plugins/ecopages-virtual-imports.d.ts +15 -0
- package/src/plugins/ecopages-virtual-imports.js +25 -0
- package/src/plugins/integration-plugin.d.ts +1 -1
- package/src/plugins/integration-plugin.js +1 -1
- package/src/plugins/tsconfig-import-resolver.d.ts +2 -0
- package/src/plugins/tsconfig-import-resolver.js +7 -5
- package/src/route-renderer/error-pages/error-page-renderer.js +32 -3
- package/src/route-renderer/explicit-view-render-preparation.d.ts +28 -3
- package/src/route-renderer/explicit-view-render-preparation.js +63 -11
- package/src/route-renderer/orchestration/document-shell/layout-shell-props.service.d.ts +15 -5
- package/src/route-renderer/orchestration/document-shell/layout-shell-props.service.js +27 -15
- package/src/route-renderer/orchestration/foreign-child/foreign-subtree-execution.service.d.ts +24 -9
- package/src/route-renderer/orchestration/foreign-child/foreign-subtree-execution.service.js +73 -50
- package/src/route-renderer/orchestration/integration-renderer.d.ts +42 -11
- package/src/route-renderer/orchestration/integration-renderer.js +83 -43
- package/src/route-renderer/orchestration/route-pipeline/route-prepared-options.builder.js +0 -3
- package/src/route-renderer/orchestration/route-pipeline/route-render-orchestrator.d.ts +36 -11
- package/src/route-renderer/orchestration/route-pipeline/route-render-orchestrator.js +74 -62
- package/src/route-renderer/page-declaration.d.ts +25 -0
- package/src/route-renderer/page-declaration.js +39 -0
- package/src/route-renderer/page-loading/component-declarations.d.ts +65 -0
- package/src/route-renderer/page-loading/component-declarations.js +77 -0
- package/src/route-renderer/page-loading/component-dependency-collection.d.ts +4 -16
- package/src/route-renderer/page-loading/component-dependency-collection.js +36 -105
- package/src/route-renderer/page-loading/declared-asset-collection.d.ts +19 -14
- package/src/route-renderer/page-loading/declared-asset-collection.js +66 -67
- package/src/route-renderer/page-loading/dependency-resolver.d.ts +18 -10
- package/src/route-renderer/page-loading/dependency-resolver.js +58 -99
- package/src/route-renderer/page-loading/lazy-entry-collection.d.ts +19 -26
- package/src/route-renderer/page-loading/lazy-entry-collection.js +53 -64
- package/src/route-renderer/page-loading/module-declaration-aggregation.d.ts +17 -3
- package/src/route-renderer/page-loading/module-declaration-aggregation.js +14 -13
- package/src/route-renderer/page-loading/page-module-loader.d.ts +31 -12
- package/src/route-renderer/page-loading/page-module-loader.js +66 -35
- package/src/route-renderer/page-loading/resolved-page-dependencies.js +14 -9
- package/src/router/server/pages-dir.d.ts +7 -0
- package/src/router/server/pages-dir.js +7 -0
- package/src/router/server/route-registry.d.ts +22 -10
- package/src/router/server/route-registry.js +54 -23
- package/src/router/server/segment-path-matcher.d.ts +29 -5
- package/src/router/server/segment-path-matcher.js +22 -19
- package/src/static-site-generator/production-page-browser-graph-prebuild.d.ts +2 -2
- package/src/static-site-generator/production-page-browser-graph-prebuild.js +5 -5
- package/src/static-site-generator/static-site-generator.d.ts +17 -2
- package/src/static-site-generator/static-site-generator.js +52 -18
- package/src/types/contracts.d.ts +216 -160
- package/src/types/eco-api-types.d.ts +86 -51
- package/src/types/locals-brand.d.ts +9 -0
- package/src/types/locals-brand.js +9 -0
- package/src/types/middleware-types.d.ts +143 -0
- package/src/types/middleware-types.js +1 -0
- package/src/types/public-types.d.ts +3 -2
- package/src/utils/file-roles.d.ts +48 -0
- package/src/utils/file-roles.js +85 -0
- package/src/utils/node-builtin.d.ts +10 -0
- package/src/utils/node-builtin.js +13 -0
- package/src/watchers/project-watcher.js +2 -2
- package/src/build/contracts/server-only-specifier.d.ts +0 -8
- package/src/build/contracts/server-only-specifier.js +0 -11
- package/src/route-renderer/orchestration/route-pipeline/marker-artifact.utils.d.ts +0 -5
- package/src/route-renderer/orchestration/route-pipeline/marker-artifact.utils.js +0 -11
- package/src/route-renderer/orchestration/route-pipeline/route-prepared-options.utils.d.ts +0 -4
- package/src/route-renderer/orchestration/route-pipeline/route-prepared-options.utils.js +0 -30
- package/src/route-renderer/page-loading/ecopages-virtual-imports.d.ts +0 -12
- package/src/route-renderer/page-loading/ecopages-virtual-imports.js +0 -100
- package/src/utils/endpoint-file-extensions.d.ts +0 -11
- package/src/utils/endpoint-file-extensions.js +0 -13
- package/src/utils/locals-utils.d.ts +0 -15
- package/src/utils/locals-utils.js +0 -34
|
@@ -1,13 +1,41 @@
|
|
|
1
1
|
import { getComponentOwner } from '../eco/component-identity.js';
|
|
2
|
+
import { assertNoRouteProps, isDynamicPage } from '../eco/page-data-hooks.js';
|
|
2
3
|
import { ensureIntegrationRuntimeReady } from '../build/app-build-manifest-runtime.js';
|
|
4
|
+
import { assertViewDeclaredIn } from './page-declaration.js';
|
|
3
5
|
/**
|
|
4
|
-
*
|
|
6
|
+
* Fails for a view that a render without a request cannot serve: one that declares `middleware`, or a Dynamic Page
|
|
7
|
+
* that declares `props`.
|
|
5
8
|
*
|
|
6
9
|
* @remarks
|
|
7
|
-
*
|
|
10
|
+
* `app.static()`, error pages and static generation render a view with no request, so no middleware runs, its
|
|
11
|
+
* layout factories receive no locals, and a Dynamic Page's `props` hook, which is a request handler, cannot run.
|
|
12
|
+
* Ignoring the list would serve the view unguarded while its types promise the locals the guard provides, and a
|
|
13
|
+
* skipped Dynamic Page would build and then fail on every request. Static generation calls this before it skips a
|
|
14
|
+
* Dynamic Page, so both fail the build. `view` is `EcoPageComponent<any>` for the reason given on
|
|
15
|
+
* `readViewPropsWithoutRequest`: a View loader erases the props type.
|
|
16
|
+
* @throws When the view declares a non-empty `middleware` list, or has `cache: 'dynamic'` and `props`, naming the
|
|
17
|
+
* route and the view's file.
|
|
18
|
+
*/
|
|
19
|
+
export function assertViewRendersWithoutRequest(routePath, view) {
|
|
20
|
+
const name = view.config?.identity?.file ?? 'its view';
|
|
21
|
+
if (view.middleware?.length) {
|
|
22
|
+
throw new Error(`[ecopages] ${routePath} renders ${name} without a request, so it cannot declare middleware: no middleware would run and the view would be served unguarded. Serve it from the pages directory, or render it from a route handler with ctx.render and give the handler the middleware.`);
|
|
23
|
+
}
|
|
24
|
+
if (isDynamicPage(view) && view.props) {
|
|
25
|
+
throw new Error(`[ecopages] ${routePath} renders ${name} without a request, so a view with cache: 'dynamic' cannot declare props. Serve it from the pages directory, or render it from a route handler with the props it needs.`);
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Resolves the renderer for one explicit view without reading its `props` hook.
|
|
30
|
+
*
|
|
31
|
+
* @remarks
|
|
32
|
+
* Static export planning calls this so a dynamic route whose `props`
|
|
8
33
|
* reads params is not invoked before a slug exists.
|
|
9
34
|
*/
|
|
10
35
|
export function resolveExplicitViewRenderer(input) {
|
|
36
|
+
if (input.declaredIn)
|
|
37
|
+
assertViewDeclaredIn(input.declaredIn.file, input.view, input.declaredIn.rootDir);
|
|
38
|
+
assertViewRendersWithoutRequest(input.routePath, input.view);
|
|
11
39
|
const integrationName = getComponentOwner(input.view);
|
|
12
40
|
if (!integrationName) {
|
|
13
41
|
throw new Error(input.errors.missingIntegration(input.routePath));
|
|
@@ -22,8 +50,35 @@ export function resolveExplicitViewRenderer(input) {
|
|
|
22
50
|
};
|
|
23
51
|
}
|
|
24
52
|
/**
|
|
25
|
-
*
|
|
53
|
+
* Runs the `props` hook of a view rendered without a request, with the build context.
|
|
54
|
+
*
|
|
55
|
+
* @remarks
|
|
56
|
+
* A Dynamic Page view still renders per request through `app.static()`, with no `props`: {@link
|
|
57
|
+
* assertViewRendersWithoutRequest} has already rejected one that declares them.
|
|
58
|
+
*
|
|
59
|
+
* `view` is `EcoPageComponent<any>` because a View loader erases the props type: that member of the union is not
|
|
60
|
+
* assignable to `EcoPageComponent<unknown>` or `EcoPageComponent<Record<string, unknown>>`, so a narrower type
|
|
61
|
+
* would reject every loaded view. The hook's result is returned as the props the renderer passes back to it.
|
|
62
|
+
*/
|
|
63
|
+
async function readViewPropsWithoutRequest(input) {
|
|
64
|
+
const { view } = input;
|
|
65
|
+
if (isDynamicPage(view) || !view.props) {
|
|
66
|
+
return {};
|
|
67
|
+
}
|
|
68
|
+
const props = await view.props({
|
|
69
|
+
params: input.params,
|
|
70
|
+
appConfig: input.appConfig,
|
|
71
|
+
runtimeOrigin: input.runtimeOrigin,
|
|
72
|
+
});
|
|
73
|
+
assertNoRouteProps(props, view.config?.identity?.file ?? input.routePath);
|
|
74
|
+
return props;
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Resolves the renderer and props needed to render one explicit static
|
|
26
78
|
* view at runtime or during static generation.
|
|
79
|
+
*
|
|
80
|
+
* @remarks
|
|
81
|
+
* No request exists here, so the view's `props` hook receives the build context.
|
|
27
82
|
*/
|
|
28
83
|
export async function prepareExplicitStaticRender(input) {
|
|
29
84
|
const integrationName = getComponentOwner(input.view);
|
|
@@ -33,14 +88,11 @@ export async function prepareExplicitStaticRender(input) {
|
|
|
33
88
|
integrationName,
|
|
34
89
|
});
|
|
35
90
|
}
|
|
36
|
-
const { renderer, view } = resolveExplicitViewRenderer(
|
|
37
|
-
|
|
38
|
-
?
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
runtimeOrigin: input.runtimeOrigin,
|
|
42
|
-
})).props
|
|
43
|
-
: {};
|
|
91
|
+
const { renderer, view } = resolveExplicitViewRenderer({
|
|
92
|
+
...input,
|
|
93
|
+
declaredIn: input.viewFile ? { file: input.viewFile, rootDir: input.appConfig.rootDir } : undefined,
|
|
94
|
+
});
|
|
95
|
+
const props = await readViewPropsWithoutRequest(input);
|
|
44
96
|
return {
|
|
45
97
|
renderer,
|
|
46
98
|
props,
|
|
@@ -8,11 +8,12 @@ export type DocumentShellLayoutResolutionInput = LayoutShellPropsContext & {
|
|
|
8
8
|
layoutEntries?: EcoPageLayoutEntry[];
|
|
9
9
|
};
|
|
10
10
|
/**
|
|
11
|
-
* Resolves the
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
*
|
|
11
|
+
* Resolves the props one layout tier renders with: what its `props` factory returns, or nothing.
|
|
12
|
+
*
|
|
13
|
+
* @remarks
|
|
14
|
+
* A layout receives request data only through its factory, so the server and the browser render the tier from
|
|
15
|
+
* the same props. The factory sees `locals`; the layout itself does not. A Static Page renders without a request,
|
|
16
|
+
* so its factories receive empty `locals`; their type has no `locals` to read.
|
|
16
17
|
*/
|
|
17
18
|
export declare function resolveLayoutEntryProps(entry: EcoPageLayoutEntry, context: LayoutShellPropsContext): Record<string, unknown>;
|
|
18
19
|
/**
|
|
@@ -22,6 +23,15 @@ export declare function resolveLayoutEntryProps(entry: EcoPageLayoutEntry, conte
|
|
|
22
23
|
* silently fall back to the innermost layout and discard route-specific props.
|
|
23
24
|
*/
|
|
24
25
|
export declare function resolveDocumentShellLayouts(input: DocumentShellLayoutResolutionInput): DocumentShellLayoutInput[];
|
|
26
|
+
/**
|
|
27
|
+
* Resolves the layouts of one render, once per `render` object, the render options both callers hold.
|
|
28
|
+
*
|
|
29
|
+
* @remarks
|
|
30
|
+
* The document shell renders each tier from these props and an integration writes the same props into its page
|
|
31
|
+
* payload. Resolving them for each would run every layout factory twice per request, and a factory that is not
|
|
32
|
+
* deterministic, such as one reading the clock, would give the HTML and the payload different values.
|
|
33
|
+
*/
|
|
34
|
+
export declare function resolveRenderLayouts(render: object, input: DocumentShellLayoutResolutionInput): DocumentShellLayoutInput[];
|
|
25
35
|
/**
|
|
26
36
|
* Reads the normalized layout stack from a page component config.
|
|
27
37
|
*/
|
|
@@ -1,26 +1,21 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Resolves the
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
* Resolves props for one layout entry, merging shell props with an optional factory.
|
|
2
|
+
* Resolves the props one layout tier renders with: what its `props` factory returns, or nothing.
|
|
3
|
+
*
|
|
4
|
+
* @remarks
|
|
5
|
+
* A layout receives request data only through its factory, so the server and the browser render the tier from
|
|
6
|
+
* the same props. The factory sees `locals`; the layout itself does not. A Static Page renders without a request,
|
|
7
|
+
* so its factories receive empty `locals`; their type has no `locals` to read.
|
|
9
8
|
*/
|
|
10
9
|
export function resolveLayoutEntryProps(entry, context) {
|
|
11
|
-
const shellProps = resolveLayoutShellProps(context);
|
|
12
10
|
if (!entry.props) {
|
|
13
|
-
return
|
|
11
|
+
return {};
|
|
14
12
|
}
|
|
15
13
|
const layoutPropsContext = {
|
|
16
14
|
params: context.params,
|
|
17
15
|
query: context.query,
|
|
18
|
-
locals: context.locals,
|
|
19
|
-
};
|
|
20
|
-
return {
|
|
21
|
-
...shellProps,
|
|
22
|
-
...entry.props(layoutPropsContext),
|
|
16
|
+
locals: context.locals ?? {},
|
|
23
17
|
};
|
|
18
|
+
return entry.props(layoutPropsContext);
|
|
24
19
|
}
|
|
25
20
|
/**
|
|
26
21
|
* Resolves declarative layout entries into the document-shell inputs used during route render.
|
|
@@ -35,7 +30,24 @@ export function resolveDocumentShellLayouts(input) {
|
|
|
35
30
|
props: resolveLayoutEntryProps(entry, input),
|
|
36
31
|
}));
|
|
37
32
|
}
|
|
38
|
-
return input.layout ? [{ component: input.layout, props:
|
|
33
|
+
return input.layout ? [{ component: input.layout, props: {} }] : [];
|
|
34
|
+
}
|
|
35
|
+
const layoutsByRender = new WeakMap();
|
|
36
|
+
/**
|
|
37
|
+
* Resolves the layouts of one render, once per `render` object, the render options both callers hold.
|
|
38
|
+
*
|
|
39
|
+
* @remarks
|
|
40
|
+
* The document shell renders each tier from these props and an integration writes the same props into its page
|
|
41
|
+
* payload. Resolving them for each would run every layout factory twice per request, and a factory that is not
|
|
42
|
+
* deterministic, such as one reading the clock, would give the HTML and the payload different values.
|
|
43
|
+
*/
|
|
44
|
+
export function resolveRenderLayouts(render, input) {
|
|
45
|
+
let layouts = layoutsByRender.get(render);
|
|
46
|
+
if (!layouts) {
|
|
47
|
+
layouts = resolveDocumentShellLayouts(input);
|
|
48
|
+
layoutsByRender.set(render, layouts);
|
|
49
|
+
}
|
|
50
|
+
return layouts;
|
|
39
51
|
}
|
|
40
52
|
/**
|
|
41
53
|
* Reads the normalized layout stack from a page component config.
|
package/src/route-renderer/orchestration/foreign-child/foreign-subtree-execution.service.d.ts
CHANGED
|
@@ -35,8 +35,16 @@ export type QueuedForeignSubtreeChildRenderResult = {
|
|
|
35
35
|
html?: string;
|
|
36
36
|
children?: unknown;
|
|
37
37
|
};
|
|
38
|
-
/**
|
|
39
|
-
export type
|
|
38
|
+
/** Replaces every queued Foreign Subtree token in `html` with the subtree's markup. */
|
|
39
|
+
export type ResolveForeignSubtreeTokens = (html: string) => Promise<string>;
|
|
40
|
+
/**
|
|
41
|
+
* Renders the children of one queued foreign subtree inside the host renderer.
|
|
42
|
+
*
|
|
43
|
+
* @remarks
|
|
44
|
+
* Serialized children may hold tokens of Foreign Children queued in the same render; pass them through
|
|
45
|
+
* `resolveTokens`, since core does not scan the returned HTML again.
|
|
46
|
+
*/
|
|
47
|
+
export type RenderQueuedForeignSubtreeChildren<TContext extends QueuedForeignSubtreeResolutionContext> = (children: unknown, runtimeContext: TContext, resolveTokens: ResolveForeignSubtreeTokens) => Promise<QueuedForeignSubtreeChildRenderResult>;
|
|
40
48
|
export interface ForeignSubtreeExecutionOwningRenderer {
|
|
41
49
|
readonly name: string;
|
|
42
50
|
renderComponentWithForeignChildren(input: ComponentRenderInput): Promise<ComponentRenderResult>;
|
|
@@ -49,7 +57,6 @@ export interface ForeignSubtreeExecutionRenderOptions {
|
|
|
49
57
|
currentIntegrationName: string;
|
|
50
58
|
input: InternalComponentRenderInput;
|
|
51
59
|
renderComponent(input: ComponentRenderInput): Promise<ComponentRenderResult>;
|
|
52
|
-
normalizeComponentRenderOutput(result: ComponentRenderResult): ComponentRenderResult;
|
|
53
60
|
hasForeignChildDescendants(component: EcoComponent, foreignChildRoots?: ReadonlyArray<EcoComponent | Partial<EcoComponent>>): boolean;
|
|
54
61
|
createForeignChildRuntime(options: {
|
|
55
62
|
renderInput: ComponentRenderInput;
|
|
@@ -60,8 +67,8 @@ export interface ForeignSubtreeExecutionRenderOptions {
|
|
|
60
67
|
export interface ForeignSubtreeQueuedRuntimeOptions<TContext extends QueuedForeignSubtreeResolutionContext> {
|
|
61
68
|
renderInput: ComponentRenderInput;
|
|
62
69
|
rendererCache: Map<string, ForeignSubtreeExecutionOwningRenderer>;
|
|
63
|
-
|
|
64
|
-
|
|
70
|
+
/** The Integration whose render queues the tokens; it names the token prefix and the runtime context key. */
|
|
71
|
+
integrationName: string;
|
|
65
72
|
createRuntimeContext?: (integrationContext: BaseIntegrationContext & Record<string, unknown>, rendererCache: Map<string, unknown>) => TContext;
|
|
66
73
|
}
|
|
67
74
|
export interface ForeignSubtreeQueuedHtmlOptions<TContext extends QueuedForeignSubtreeResolutionContext> {
|
|
@@ -75,7 +82,8 @@ export type ForeignSubtreeStringQueuedHtmlOptions = Omit<ForeignSubtreeQueuedHtm
|
|
|
75
82
|
export interface ResolveQueuedForeignSubtreeTokensOptions<TContext extends QueuedForeignSubtreeResolutionContext> {
|
|
76
83
|
html: string;
|
|
77
84
|
runtimeContext?: TContext;
|
|
78
|
-
|
|
85
|
+
/** The Integration whose render queued the tokens; it names the token prefix and error messages. */
|
|
86
|
+
integrationName: string;
|
|
79
87
|
renderQueuedChildren: RenderQueuedForeignSubtreeChildren<TContext>;
|
|
80
88
|
resolveForeignSubtree: (input: ComponentRenderInput, rendererCache: Map<string, unknown>) => Promise<ComponentRenderResult | undefined>;
|
|
81
89
|
}
|
|
@@ -85,8 +93,7 @@ export declare function createQueuedRuntime<TContext extends QueuedForeignSubtre
|
|
|
85
93
|
export declare function createQueueRuntime<TContext extends QueuedForeignSubtreeResolutionContext>(options: {
|
|
86
94
|
renderInput: ComponentRenderInput;
|
|
87
95
|
rendererCache: Map<string, unknown>;
|
|
88
|
-
|
|
89
|
-
tokenPrefix: string;
|
|
96
|
+
integrationName: string;
|
|
90
97
|
shouldQueueForeignChild: (input: QueuedForeignChildDecisionInput) => boolean;
|
|
91
98
|
createRuntimeContext?: (integrationContext: QueuedForeignSubtreeIntegrationContext, rendererCache: Map<string, unknown>) => TContext;
|
|
92
99
|
}): ForeignChildRuntime;
|
|
@@ -101,6 +108,15 @@ export declare function getRuntimeContext<TContext extends QueuedForeignSubtreeR
|
|
|
101
108
|
*/
|
|
102
109
|
export declare function resolveStringQueuedHtml(options: ForeignSubtreeStringQueuedHtmlOptions): Promise<string>;
|
|
103
110
|
export declare function resolveQueuedHtml<TContext extends QueuedForeignSubtreeResolutionContext>(options: ForeignSubtreeQueuedHtmlOptions<TContext>): Promise<string>;
|
|
111
|
+
/**
|
|
112
|
+
* Places the Foreign Subtrees queued during one render over their tokens in `html`.
|
|
113
|
+
*
|
|
114
|
+
* @remarks
|
|
115
|
+
* The HTML is scanned once: each token is rendered by its owning renderer when the scan reaches it, its children
|
|
116
|
+
* first, and the owner's root attributes are set on the subtree's leading element. The subtree's markup is scanned
|
|
117
|
+
* the same way, since structured children can carry tokens of this render into the owner's output. A token that
|
|
118
|
+
* appears twice is rendered once. A subtree that reaches its own token again is a cycle and throws.
|
|
119
|
+
*/
|
|
104
120
|
export declare function resolveQueuedForeignSubtreeTokens<TContext extends QueuedForeignSubtreeResolutionContext>(options: ResolveQueuedForeignSubtreeTokensOptions<TContext>): Promise<string>;
|
|
105
121
|
/**
|
|
106
122
|
* Runs one component render under the current integration's render context and
|
|
@@ -111,5 +127,4 @@ export declare function resolveQueuedForeignSubtreeTokens<TContext extends Queue
|
|
|
111
127
|
* integration, even when no foreign-child runtime is installed.
|
|
112
128
|
*/
|
|
113
129
|
export declare function executeComponentRender(options: ForeignSubtreeExecutionRenderOptions): Promise<ComponentRenderResult>;
|
|
114
|
-
export declare function resolveQueuedTokens(html: string, queuedResolutionsByToken: Map<string, QueuedForeignSubtreeResolution>, resolveToken: (token: string) => Promise<string>): Promise<string>;
|
|
115
130
|
export {};
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { applyAttributesToFirstElement } from '../../../html/html-transformer.service.js';
|
|
2
|
+
import { getForeignSubtreeResolutionContextKey, getForeignSubtreeTokenPrefix } from './owning-renderer-resolution.js';
|
|
2
3
|
import { getComponentOwner } from '../../../eco/component-identity.js';
|
|
3
4
|
import { getComponentRenderContext, runWithComponentRenderContext, } from '../../../eco/component-render-context.js';
|
|
4
5
|
import { isMarkupNodeLike } from '../../../eco/component-render-output.js';
|
|
@@ -32,14 +33,17 @@ export function createQueuedRuntime(options) {
|
|
|
32
33
|
return createQueueRuntime({
|
|
33
34
|
renderInput: options.renderInput,
|
|
34
35
|
rendererCache: options.rendererCache,
|
|
35
|
-
|
|
36
|
-
tokenPrefix: options.tokenPrefix,
|
|
36
|
+
integrationName: options.integrationName,
|
|
37
37
|
shouldQueueForeignChild: (input) => shouldDelegateForeignChild(input),
|
|
38
38
|
createRuntimeContext: options.createRuntimeContext,
|
|
39
39
|
});
|
|
40
40
|
}
|
|
41
41
|
export function createQueueRuntime(options) {
|
|
42
|
-
const runtimeContext = ensureRuntimeContext(
|
|
42
|
+
const runtimeContext = ensureRuntimeContext({
|
|
43
|
+
...options,
|
|
44
|
+
runtimeContextKey: getForeignSubtreeResolutionContextKey(options.integrationName),
|
|
45
|
+
});
|
|
46
|
+
const tokenPrefix = getForeignSubtreeTokenPrefix(options.integrationName);
|
|
43
47
|
const interceptForeignChild = (input) => {
|
|
44
48
|
if (!options.shouldQueueForeignChild(input)) {
|
|
45
49
|
return {
|
|
@@ -52,7 +56,7 @@ export function createQueueRuntime(options) {
|
|
|
52
56
|
}
|
|
53
57
|
runtimeContext.nextForeignSubtreeId += 1;
|
|
54
58
|
const foreignSubtreeId = runtimeContext.nextForeignSubtreeId;
|
|
55
|
-
const token = createForeignSubtreeToken(
|
|
59
|
+
const token = createForeignSubtreeToken(tokenPrefix, runtimeContext, foreignSubtreeId);
|
|
56
60
|
runtimeContext.queuedResolutions.push({
|
|
57
61
|
token,
|
|
58
62
|
component: input.component,
|
|
@@ -90,7 +94,7 @@ export function getRuntimeContext(input, runtimeContextKey) {
|
|
|
90
94
|
export async function resolveStringQueuedHtml(options) {
|
|
91
95
|
return resolveQueuedHtml({
|
|
92
96
|
...options,
|
|
93
|
-
renderQueuedChildren: async (children, _runtimeContext,
|
|
97
|
+
renderQueuedChildren: async (children, _runtimeContext, resolveTokens) => {
|
|
94
98
|
if (children === undefined) {
|
|
95
99
|
return {};
|
|
96
100
|
}
|
|
@@ -98,8 +102,7 @@ export async function resolveStringQueuedHtml(options) {
|
|
|
98
102
|
assertForeignChildrenNotOpaque(children, options.currentIntegrationName);
|
|
99
103
|
return { children };
|
|
100
104
|
}
|
|
101
|
-
|
|
102
|
-
return { html };
|
|
105
|
+
return { html: await resolveTokens(typeof children === 'string' ? children : (children.outerHTML ?? '')) };
|
|
103
106
|
},
|
|
104
107
|
});
|
|
105
108
|
}
|
|
@@ -107,7 +110,7 @@ export async function resolveQueuedHtml(options) {
|
|
|
107
110
|
return resolveQueuedForeignSubtreeTokens({
|
|
108
111
|
html: options.html,
|
|
109
112
|
runtimeContext: options.runtimeContext,
|
|
110
|
-
|
|
113
|
+
integrationName: options.currentIntegrationName,
|
|
111
114
|
renderQueuedChildren: options.renderQueuedChildren,
|
|
112
115
|
resolveForeignSubtree: (input, rendererCache) => resolveForeignChildInOwningRenderer({
|
|
113
116
|
currentIntegrationName: options.currentIntegrationName,
|
|
@@ -117,38 +120,46 @@ export async function resolveQueuedHtml(options) {
|
|
|
117
120
|
}),
|
|
118
121
|
});
|
|
119
122
|
}
|
|
123
|
+
/**
|
|
124
|
+
* Places the Foreign Subtrees queued during one render over their tokens in `html`.
|
|
125
|
+
*
|
|
126
|
+
* @remarks
|
|
127
|
+
* The HTML is scanned once: each token is rendered by its owning renderer when the scan reaches it, its children
|
|
128
|
+
* first, and the owner's root attributes are set on the subtree's leading element. The subtree's markup is scanned
|
|
129
|
+
* the same way, since structured children can carry tokens of this render into the owner's output. A token that
|
|
130
|
+
* appears twice is rendered once. A subtree that reaches its own token again is a cycle and throws.
|
|
131
|
+
*/
|
|
120
132
|
export async function resolveQueuedForeignSubtreeTokens(options) {
|
|
121
|
-
|
|
133
|
+
const runtimeContext = options.runtimeContext;
|
|
134
|
+
if (!runtimeContext || runtimeContext.queuedResolutions.length === 0) {
|
|
122
135
|
return options.html;
|
|
123
136
|
}
|
|
124
|
-
const
|
|
137
|
+
const tokenPrefix = getForeignSubtreeTokenPrefix(options.integrationName);
|
|
125
138
|
const queuedResolutionsByToken = new Map();
|
|
126
|
-
const
|
|
139
|
+
const placedHtmlByToken = new Map();
|
|
127
140
|
const resolvingTokens = new Set();
|
|
128
|
-
const
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
}
|
|
141
|
+
const findResolution = (token) => {
|
|
142
|
+
const queued = runtimeContext.queuedResolutions;
|
|
143
|
+
for (let index = queuedResolutionsByToken.size; index < queued.length; index += 1) {
|
|
144
|
+
queuedResolutionsByToken.set(queued[index].token, queued[index]);
|
|
133
145
|
}
|
|
146
|
+
return queuedResolutionsByToken.get(token);
|
|
134
147
|
};
|
|
135
|
-
const
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
return cachedHtml;
|
|
148
|
+
const placeToken = async (token) => {
|
|
149
|
+
const placedHtml = placedHtmlByToken.get(token);
|
|
150
|
+
if (placedHtml !== undefined) {
|
|
151
|
+
return placedHtml;
|
|
140
152
|
}
|
|
141
|
-
const resolution =
|
|
153
|
+
const resolution = findResolution(token);
|
|
142
154
|
if (!resolution) {
|
|
143
|
-
return
|
|
155
|
+
return undefined;
|
|
144
156
|
}
|
|
145
157
|
if (resolvingTokens.has(token)) {
|
|
146
|
-
throw new Error(`[ecopages] ${options.
|
|
158
|
+
throw new Error(`[ecopages] ${options.integrationName} foreign-subtree queue contains a cycle or unresolved dependency links.`);
|
|
147
159
|
}
|
|
148
160
|
resolvingTokens.add(token);
|
|
149
161
|
try {
|
|
150
|
-
const renderedChildren = await options.renderQueuedChildren(resolution.props.children, runtimeContext,
|
|
151
|
-
syncQueuedResolutions();
|
|
162
|
+
const renderedChildren = await options.renderQueuedChildren(resolution.props.children, runtimeContext, resolveTokens);
|
|
152
163
|
const foreignSubtreeRender = await options.resolveForeignSubtree({
|
|
153
164
|
component: resolution.component,
|
|
154
165
|
props: { ...resolution.props },
|
|
@@ -159,28 +170,50 @@ export async function resolveQueuedForeignSubtreeTokens(options) {
|
|
|
159
170
|
},
|
|
160
171
|
}, runtimeContext.rendererCache);
|
|
161
172
|
if (!foreignSubtreeRender) {
|
|
162
|
-
throw new Error(`[ecopages] ${options.
|
|
173
|
+
throw new Error(`[ecopages] ${options.integrationName} queued foreign subtree could not resolve its owning renderer.`);
|
|
163
174
|
}
|
|
164
|
-
const
|
|
175
|
+
const stampedHtml = foreignSubtreeRender.canAttachAttributes && foreignSubtreeRender.rootAttributes
|
|
165
176
|
? applyAttributesToFirstElement(foreignSubtreeRender.html, foreignSubtreeRender.rootAttributes)
|
|
166
177
|
: foreignSubtreeRender.html;
|
|
167
|
-
|
|
168
|
-
|
|
178
|
+
const html = await resolveTokens(stampedHtml);
|
|
179
|
+
placedHtmlByToken.set(token, html);
|
|
180
|
+
return html;
|
|
169
181
|
}
|
|
170
182
|
finally {
|
|
171
183
|
resolvingTokens.delete(token);
|
|
172
184
|
}
|
|
173
185
|
};
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
186
|
+
const resolveTokens = (html) => spliceTokens(html, tokenPrefix, placeToken);
|
|
187
|
+
return resolveTokens(options.html);
|
|
188
|
+
}
|
|
189
|
+
/**
|
|
190
|
+
* Replaces each `tokenPrefix` token in `html` that `place` knows, in one pass.
|
|
191
|
+
*
|
|
192
|
+
* @remarks
|
|
193
|
+
* A token is `<prefix><scope>__<id>__`, and no scope contains `__` (see {@link createForeignSubtreeToken}). Text that
|
|
194
|
+
* starts like a token but that `place` does not know is kept as written.
|
|
195
|
+
*/
|
|
196
|
+
async function spliceTokens(html, tokenPrefix, place) {
|
|
197
|
+
let start = html.indexOf(tokenPrefix);
|
|
198
|
+
if (start === -1) {
|
|
199
|
+
return html;
|
|
200
|
+
}
|
|
201
|
+
let output = '';
|
|
202
|
+
let copied = 0;
|
|
203
|
+
while (start !== -1) {
|
|
204
|
+
const scopeEnd = html.indexOf('__', start + tokenPrefix.length);
|
|
205
|
+
const idEnd = scopeEnd === -1 ? -1 : html.indexOf('__', scopeEnd + 2);
|
|
206
|
+
const end = idEnd === -1 ? -1 : idEnd + 2;
|
|
207
|
+
const placed = end === -1 ? undefined : await place(html.slice(start, end));
|
|
208
|
+
if (placed === undefined) {
|
|
209
|
+
start = html.indexOf(tokenPrefix, start + tokenPrefix.length);
|
|
179
210
|
continue;
|
|
180
211
|
}
|
|
181
|
-
|
|
212
|
+
output += `${html.slice(copied, start)}${placed}`;
|
|
213
|
+
copied = end;
|
|
214
|
+
start = html.indexOf(tokenPrefix, end);
|
|
182
215
|
}
|
|
183
|
-
return
|
|
216
|
+
return `${output}${html.slice(copied)}`;
|
|
184
217
|
}
|
|
185
218
|
/**
|
|
186
219
|
* Runs one component render under the current integration's render context and
|
|
@@ -206,12 +239,12 @@ export async function executeComponentRender(options) {
|
|
|
206
239
|
const activeRenderContext = getComponentRenderContext();
|
|
207
240
|
if (!hasForeignChildren) {
|
|
208
241
|
if (activeRenderContext && activeRenderContext.currentIntegration === options.currentIntegrationName) {
|
|
209
|
-
return
|
|
242
|
+
return await options.renderComponent(options.input);
|
|
210
243
|
}
|
|
211
244
|
const sameIntegrationExecution = await runWithComponentRenderContext({
|
|
212
245
|
currentIntegration: options.currentIntegrationName,
|
|
213
246
|
}, async () => options.renderComponent(options.input));
|
|
214
|
-
return
|
|
247
|
+
return sameIntegrationExecution.value;
|
|
215
248
|
}
|
|
216
249
|
const execution = await runWithComponentRenderContext({
|
|
217
250
|
currentIntegration: options.currentIntegrationName,
|
|
@@ -220,7 +253,7 @@ export async function executeComponentRender(options) {
|
|
|
220
253
|
rendererCache,
|
|
221
254
|
}),
|
|
222
255
|
}, async () => options.renderComponent(options.input));
|
|
223
|
-
return
|
|
256
|
+
return execution.value;
|
|
224
257
|
}
|
|
225
258
|
function getRendererCache(integrationContext) {
|
|
226
259
|
if (integrationContext?.rendererCache instanceof Map) {
|
|
@@ -270,16 +303,6 @@ async function runInForeignOwningRenderer(options) {
|
|
|
270
303
|
children: delegatedChildren,
|
|
271
304
|
});
|
|
272
305
|
}
|
|
273
|
-
export async function resolveQueuedTokens(html, queuedResolutionsByToken, resolveToken) {
|
|
274
|
-
let resolvedHtml = html;
|
|
275
|
-
for (const token of queuedResolutionsByToken.keys()) {
|
|
276
|
-
if (!resolvedHtml.includes(token)) {
|
|
277
|
-
continue;
|
|
278
|
-
}
|
|
279
|
-
resolvedHtml = resolvedHtml.split(token).join(await resolveToken(token));
|
|
280
|
-
}
|
|
281
|
-
return resolvedHtml;
|
|
282
|
-
}
|
|
283
306
|
function createForeignSubtreeToken(tokenPrefix, runtimeContext, foreignSubtreeId) {
|
|
284
307
|
return `${tokenPrefix}${runtimeContext.componentInstanceScope ?? 'root'}__${foreignSubtreeId}__`;
|
|
285
308
|
}
|
|
@@ -150,7 +150,7 @@ export type PlannedRouteInstance = {
|
|
|
150
150
|
routeFile: string;
|
|
151
151
|
params?: RouteRendererOptions['params'];
|
|
152
152
|
query?: RouteRendererOptions['query'];
|
|
153
|
-
|
|
153
|
+
skipPropsHook?: RouteRendererOptions['skipPropsHook'];
|
|
154
154
|
isRouteTemplate?: boolean;
|
|
155
155
|
};
|
|
156
156
|
/** One renderer's production routes: what they need from the app-wide browser build, and how to prepare them. */
|
|
@@ -214,7 +214,9 @@ export declare abstract class IntegrationRenderer<C = EcoPagesElement> {
|
|
|
214
214
|
* @remarks
|
|
215
215
|
* The scripts the route's render would bundle, from the shell, the page Dependencies, the Page Browser Graph
|
|
216
216
|
* dependencies and the components and scripts its contribution names, go to `bundledScripts`, prepared as asset
|
|
217
|
-
* processing prepares them.
|
|
217
|
+
* processing prepares them. A Dynamic Page is planned without its `props` hook, which is its request handler: the
|
|
218
|
+
* build has no request to give it. A plan without the `props` hook also skips `metadata`, which would read props
|
|
219
|
+
* that were never resolved. Planning does not read metadata, and static export never renders from such a plan.
|
|
218
220
|
*/
|
|
219
221
|
private planRouteInstance;
|
|
220
222
|
private runInRenderSession;
|
|
@@ -228,6 +230,25 @@ export declare abstract class IntegrationRenderer<C = EcoPagesElement> {
|
|
|
228
230
|
* `getStaticPaths` or `getMetadata` fails here with an error that points to the codemod.
|
|
229
231
|
*/
|
|
230
232
|
loadPageModule(file: string, options?: RouteModuleLoadOptions): Promise<EcoPageFile>;
|
|
233
|
+
/**
|
|
234
|
+
* Imports a route module and fails unless it is a Page this Integration accepts.
|
|
235
|
+
*
|
|
236
|
+
* @remarks
|
|
237
|
+
* The legacy-export check runs first, so a module that still exports `getStaticProps` gets the codemod message.
|
|
238
|
+
*/
|
|
239
|
+
protected importRouteModule(file: string, options?: RouteModuleLoadOptions): Promise<EcoPageFile>;
|
|
240
|
+
/**
|
|
241
|
+
* Fails when the default export of a route module is not a Page that the file itself declares.
|
|
242
|
+
*
|
|
243
|
+
* @remarks
|
|
244
|
+
* A Page is a declared component whose build-time identity names this route file: an `eco.page()` result
|
|
245
|
+
* (also an HTML Page or an MDX module, which the Integration stamps the same way). The identity transform
|
|
246
|
+
* stamps the file that holds the literal `eco.page(...)` call, so a Page made by a wrapper in another file,
|
|
247
|
+
* or re-exported from one, names that other file and fails here. A function with a `config` that fails the
|
|
248
|
+
* check gets the literal-call message; anything else gets the not-a-Page message with the fixes.
|
|
249
|
+
* @throws When the module has no default export that is a Page declared in `file`.
|
|
250
|
+
*/
|
|
251
|
+
private assertPageModule;
|
|
231
252
|
setHmrManager(hmrManager: IHmrManager): void;
|
|
232
253
|
/**
|
|
233
254
|
* Build response headers with optional custom headers.
|
|
@@ -388,7 +409,7 @@ export declare abstract class IntegrationRenderer<C = EcoPagesElement> {
|
|
|
388
409
|
preparedGraph?: true;
|
|
389
410
|
}): Promise<ProcessedAsset[]>;
|
|
390
411
|
getRouteHtmlFinalization(renderOptions: InternalIntegrationRendererRenderOptions<C>): RouteHtmlFinalization;
|
|
391
|
-
|
|
412
|
+
transformRouteHtml(html: string, htmlContributions: HtmlDocumentContribution[] | undefined, renderOptions: InternalIntegrationRendererRenderOptions<C>): Promise<RouteRendererBody>;
|
|
392
413
|
protected finalizeDocument(body: RouteRendererBody, renderOptions: IntegrationRendererRenderOptions<C>): Promise<RouteRendererBody> | RouteRendererBody;
|
|
393
414
|
resolveRouteRenderInputs(routeOptions: RouteRendererOptions, options?: {
|
|
394
415
|
skipMetadata?: boolean;
|
|
@@ -398,12 +419,25 @@ export declare abstract class IntegrationRenderer<C = EcoPagesElement> {
|
|
|
398
419
|
ownerFile: string;
|
|
399
420
|
}): Promise<PageBrowserGraphContribution | undefined>;
|
|
400
421
|
resolvePageDependenciesForRoute(context: PageBrowserGraphContributionContext): Promise<ResolvedPageDependencies | undefined>;
|
|
401
|
-
/**
|
|
422
|
+
/**
|
|
423
|
+
* Resolves a route's component assets.
|
|
424
|
+
*
|
|
425
|
+
* @remarks `declarationOrder` returns them in the order the asset ledger records them, for a recorded shell.
|
|
426
|
+
*/
|
|
402
427
|
resolveRouteDependencies(input: {
|
|
403
428
|
components: (EcoComponent | Partial<EcoComponent>)[];
|
|
429
|
+
declarationOrder?: boolean;
|
|
404
430
|
}): Promise<{
|
|
405
431
|
resolvedDependencies: ProcessedAsset[];
|
|
406
432
|
}>;
|
|
433
|
+
/**
|
|
434
|
+
* Holds the lazy client entries of a route's shell components for the page client build.
|
|
435
|
+
*
|
|
436
|
+
* @remarks
|
|
437
|
+
* Processing the shell holds them as a side effect; a shell read from the asset ledger is not processed, so its
|
|
438
|
+
* lazy entries are collected here.
|
|
439
|
+
*/
|
|
440
|
+
prepareRouteLazyDependencies(components: (EcoComponent | Partial<EcoComponent>)[]): void;
|
|
407
441
|
renderRouteBody(renderOptions: InternalIntegrationRendererRenderOptions<C>): Promise<RouteRendererBody>;
|
|
408
442
|
/**
|
|
409
443
|
* Prepares the render options for the integration renderer.
|
|
@@ -420,9 +454,8 @@ export declare abstract class IntegrationRenderer<C = EcoPagesElement> {
|
|
|
420
454
|
* Execution flow:
|
|
421
455
|
* 1. Build normalized render options (`prepareRenderOptions`).
|
|
422
456
|
* 2. Render the route body once.
|
|
423
|
-
* 3.
|
|
424
|
-
* 4.
|
|
425
|
-
* 5. Run HTML transformer with final dependency set.
|
|
457
|
+
* 3. Optionally apply document attributes for integration-owned document boundaries.
|
|
458
|
+
* 4. Run HTML transformer with final dependency set.
|
|
426
459
|
*
|
|
427
460
|
* Stream-safety note: the first render result is normalized to a string once,
|
|
428
461
|
* then the pipeline continues with that immutable HTML value to avoid disturbed
|
|
@@ -450,7 +483,7 @@ export declare abstract class IntegrationRenderer<C = EcoPagesElement> {
|
|
|
450
483
|
*
|
|
451
484
|
* @remarks
|
|
452
485
|
* `file` is the view's identity file, or a stable synthetic key when the view has
|
|
453
|
-
* none. `props` are the view's final props: its `
|
|
486
|
+
* none. `props` are the view's final props: its `props` hook is the caller's
|
|
454
487
|
* to run, so it is not run here.
|
|
455
488
|
*/
|
|
456
489
|
executeExplicitView<P>(view: EcoComponent<P>, props: P, ctx?: Omit<ExplicitViewRenderContext, 'partial'>): Promise<RouteRenderResult>;
|
|
@@ -524,14 +557,12 @@ export declare abstract class IntegrationRenderer<C = EcoPagesElement> {
|
|
|
524
557
|
*/
|
|
525
558
|
protected resolveQueuedForeignSubtrees<TContext extends QueuedForeignSubtreeResolutionContext>(html: string, runtimeContext: TContext | undefined, renderQueuedChildren: RenderQueuedForeignSubtreeChildren<TContext>): Promise<string>;
|
|
526
559
|
/**
|
|
527
|
-
* Stamps `result` as an Island Host when the component itself
|
|
560
|
+
* Stamps `result` as an Island Host when the component itself ships a client script.
|
|
528
561
|
*
|
|
529
562
|
* @remarks Reads the component's own declarations, excluding Foreign Children: a component without
|
|
530
563
|
* scripts that wraps an island is not an island itself. Components without `dependencies` are never stamped.
|
|
531
564
|
*/
|
|
532
565
|
protected finalizeIslandComponentRender(input: ComponentRenderInput, result: ComponentRenderResult): ComponentRenderResult;
|
|
533
|
-
private normalizeComponentRenderOutput;
|
|
534
|
-
protected normalizeUnresolvedMarkerArtifactHtml(html: string): string;
|
|
535
566
|
/**
|
|
536
567
|
* @remarks
|
|
537
568
|
* The active plan is the page owner's, but it answers for any renderer: a nested renderer of
|