@ecopages/react 0.2.1 → 0.3.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 +178 -35
- package/package.json +80 -32
- package/src/app/client-only.js +10 -0
- package/src/app/dynamic.js +9 -0
- package/src/app/dynamic.test.browser.d.ts +1 -0
- package/src/app/dynamic.test.browser.js +38 -0
- package/src/bundling/bootstrap-package-paths.d.ts +5 -0
- package/src/bundling/bootstrap-package-paths.js +5 -0
- package/src/bundling/bundle.d.ts +78 -0
- package/src/bundling/bundle.js +130 -0
- package/src/bundling/runtime-alias-map.d.ts +12 -0
- package/src/bundling/runtime-alias-map.js +110 -0
- package/src/bundling/runtime-bundle.d.ts +70 -0
- package/src/bundling/runtime-bundle.js +233 -0
- package/src/{utils/react-dom-runtime-interop-plugin.d.ts → bundling/runtime-interop-plugin.d.ts} +1 -1
- package/src/bundling/runtime-interop-plugin.js +32 -0
- package/src/bundling/runtime-mode.d.ts +1 -0
- package/src/bundling/runtime-mode.js +10 -0
- package/src/bundling/runtime-modules.d.ts +21 -0
- package/src/bundling/runtime-modules.js +28 -0
- package/src/client-graph/ast-transform-eco-page.d.ts +10 -0
- package/src/client-graph/ast-transform-eco-page.js +71 -0
- package/src/client-graph/ast-transform-import-edits.d.ts +13 -0
- package/src/client-graph/ast-transform-import-edits.js +75 -0
- package/src/client-graph/ast-transform-walk-imports.d.ts +20 -0
- package/src/client-graph/ast-transform-walk-imports.js +105 -0
- package/src/client-graph/ast-transform.d.ts +12 -0
- package/src/client-graph/ast-transform.js +91 -0
- package/src/client-graph/ast-walk.d.ts +10 -0
- package/src/client-graph/ast-walk.js +26 -0
- package/src/client-graph/boundary-plugin-read-file-inline.d.ts +7 -0
- package/src/client-graph/boundary-plugin-read-file-inline.js +43 -0
- package/src/client-graph/boundary-plugin-transform.d.ts +16 -0
- package/src/client-graph/boundary-plugin-transform.js +31 -0
- package/src/client-graph/boundary-plugin.d.ts +23 -0
- package/src/client-graph/boundary-plugin.js +177 -0
- package/src/client-graph/component-config-traversal.d.ts +36 -0
- package/src/client-graph/component-config-traversal.js +77 -0
- package/src/{utils → client-graph}/declared-modules.d.ts +1 -1
- package/src/client-graph/declared-modules.js +69 -0
- package/src/client-graph/module-classification.d.ts +3 -0
- package/src/client-graph/module-classification.js +43 -0
- package/src/client-graph/reachability-analyzer.d.ts +26 -0
- package/src/client-graph/reachability-analyzer.js +55 -0
- package/src/client-graph/reachability-client-roots.d.ts +8 -0
- package/src/client-graph/reachability-client-roots.js +59 -0
- package/src/client-graph/reachability-export-names.d.ts +5 -0
- package/src/client-graph/reachability-export-names.js +34 -0
- package/src/client-graph/reachability-fallback-roots.d.ts +3 -0
- package/src/client-graph/reachability-fallback-roots.js +71 -0
- package/src/client-graph/reachability-preload.d.ts +10 -0
- package/src/client-graph/reachability-preload.js +30 -0
- package/src/client-graph/reachability-top-level-index.d.ts +14 -0
- package/src/client-graph/reachability-top-level-index.js +93 -0
- package/src/client-graph/reachability-traverse.d.ts +7 -0
- package/src/client-graph/reachability-traverse.js +201 -0
- package/src/client-graph/specifier-classification.d.ts +74 -0
- package/src/client-graph/specifier-classification.js +191 -0
- package/src/content/collection-component-cache.d.ts +25 -0
- package/src/content/collection-component-cache.js +62 -0
- package/src/{router-adapter.d.ts → contracts/router-adapter.d.ts} +7 -14
- package/src/contracts/router-adapter.js +6 -0
- package/src/dev-transform/react-dev-transform-contributor.d.ts +17 -0
- package/src/dev-transform/react-dev-transform-contributor.js +22 -0
- package/src/hmr/hmr-strategy-process.d.ts +34 -0
- package/src/hmr/hmr-strategy-process.js +83 -0
- package/src/hmr/hmr-strategy.d.ts +67 -0
- package/src/hmr/hmr-strategy.js +306 -0
- package/src/{services/react-hmr-page-metadata-cache.d.ts → hmr/page-metadata-cache.d.ts} +6 -2
- package/src/hmr/page-metadata-cache.js +44 -0
- package/src/hmr/react-hmr-dev-transform-plugins.d.ts +22 -0
- package/src/hmr/react-hmr-dev-transform-plugins.js +19 -0
- package/src/hydration/assert-no-bare-ecopages-imports.d.ts +4 -0
- package/src/hydration/assert-no-bare-ecopages-imports.js +7 -0
- package/src/hydration/bootstrap-imports.d.ts +25 -0
- package/src/hydration/bootstrap-imports.js +33 -0
- package/src/hydration/browser/island-hydration.d.ts +82 -0
- package/src/hydration/browser/island-hydration.js +251 -0
- package/src/hydration/browser/page-hydration-hmr.d.ts +11 -0
- package/src/hydration/browser/page-hydration-hmr.js +56 -0
- package/src/hydration/browser/page-hydration-module.d.ts +8 -0
- package/src/hydration/browser/page-hydration-module.js +17 -0
- package/src/hydration/browser/page-hydration.d.ts +54 -0
- package/src/hydration/browser/page-hydration.js +177 -0
- package/src/hydration/compiled-page-hydration-options.d.ts +20 -0
- package/src/hydration/compiled-page-hydration-options.js +1 -0
- package/src/hydration/hydration-asset.d.ts +127 -0
- package/src/hydration/hydration-asset.js +379 -0
- package/src/hydration/hydration-lifecycle.test.browser.d.ts +1 -0
- package/src/hydration/hydration-lifecycle.test.browser.js +461 -0
- package/src/hydration/hydration-page-entry-source.d.ts +5 -0
- package/src/hydration/hydration-page-entry-source.js +87 -0
- package/src/hydration/hydration-script-compiler.d.ts +48 -0
- package/src/hydration/hydration-script-compiler.js +213 -0
- package/src/hydration/page-data-manifest.d.ts +58 -0
- package/src/hydration/page-data-manifest.js +97 -0
- package/src/hydration/page-data-reader.d.ts +17 -0
- package/src/hydration/page-data-reader.js +31 -0
- package/src/hydration/page-payload.d.ts +68 -0
- package/src/hydration/page-payload.js +106 -0
- package/src/hydration/serialize-page-data-script.d.ts +27 -0
- package/src/hydration/serialize-page-data-script.js +30 -0
- package/src/mdx/mdx-config-dependency.d.ts +37 -0
- package/src/mdx/mdx-config-dependency.js +107 -0
- package/src/mdx/mdx-loader-plugin.d.ts +8 -0
- package/src/mdx/mdx-loader-plugin.js +11 -0
- package/src/page/page-module.d.ts +46 -0
- package/src/page/page-module.js +74 -0
- package/src/plugin/react.constants.d.ts +1 -0
- package/src/plugin/react.constants.js +1 -0
- package/src/plugin/react.plugin.d.ts +71 -0
- package/src/plugin/react.plugin.js +210 -0
- package/src/plugin/react.types.d.ts +106 -0
- package/src/plugin/react.types.js +1 -0
- package/src/render/component-ownership.d.ts +49 -0
- package/src/render/component-ownership.js +47 -0
- package/src/render/component-ssr.d.ts +59 -0
- package/src/render/component-ssr.js +76 -0
- package/src/render/eco-embed.d.ts +11 -0
- package/src/render/eco-embed.js +9 -0
- package/src/render/errors.d.ts +16 -0
- package/src/render/errors.js +23 -0
- package/src/render/html-boundary.js +59 -0
- package/src/render/layout-compose.d.ts +66 -0
- package/src/render/layout-compose.js +134 -0
- package/src/render/react-renderer.d.ts +114 -0
- package/src/render/react-renderer.js +490 -0
- package/src/render/react-runtime.d.ts +13 -0
- package/src/render/react-runtime.js +26 -0
- package/src/render/unified-layout-composition.d.ts +22 -0
- package/src/render/unified-layout-composition.js +31 -0
- package/src/runtime/use-sync-external-store-with-selector.d.ts +3 -0
- package/src/runtime/use-sync-external-store-with-selector.js +54 -0
- package/CHANGELOG.md +0 -29
- package/src/react-hmr-strategy.d.ts +0 -148
- package/src/react-hmr-strategy.js +0 -313
- package/src/react-renderer.d.ts +0 -213
- package/src/react-renderer.js +0 -654
- package/src/react.plugin.d.ts +0 -147
- package/src/react.plugin.js +0 -146
- package/src/router-adapter.js +0 -0
- package/src/services/react-bundle.service.d.ts +0 -47
- package/src/services/react-bundle.service.js +0 -93
- package/src/services/react-hmr-page-metadata-cache.js +0 -35
- package/src/services/react-hydration-asset.service.d.ts +0 -76
- package/src/services/react-hydration-asset.service.js +0 -210
- package/src/services/react-page-module.service.d.ts +0 -83
- package/src/services/react-page-module.service.js +0 -162
- package/src/services/react-runtime-bundle.service.d.ts +0 -40
- package/src/services/react-runtime-bundle.service.js +0 -130
- package/src/utils/client-graph-boundary-plugin.d.ts +0 -43
- package/src/utils/client-graph-boundary-plugin.js +0 -494
- package/src/utils/client-only.js +0 -19
- package/src/utils/declared-modules.js +0 -59
- package/src/utils/dynamic.js +0 -12
- package/src/utils/hmr-scripts.d.ts +0 -18
- package/src/utils/hmr-scripts.js +0 -31
- package/src/utils/html-boundary.js +0 -55
- package/src/utils/hydration-scripts.d.ts +0 -86
- package/src/utils/hydration-scripts.js +0 -285
- package/src/utils/reachability-analyzer.d.ts +0 -66
- package/src/utils/reachability-analyzer.js +0 -339
- package/src/utils/react-dom-runtime-interop-plugin.js +0 -29
- package/src/utils/react-mdx-loader-plugin.d.ts +0 -3
- package/src/utils/react-mdx-loader-plugin.js +0 -45
- package/src/utils/react-runtime-specifier-map.d.ts +0 -6
- package/src/utils/react-runtime-specifier-map.js +0 -37
- package/src/utils/use-sync-external-store-shim-plugin.d.ts +0 -5
- package/src/utils/use-sync-external-store-shim-plugin.js +0 -41
- /package/src/{utils → app}/client-only.d.ts +0 -0
- /package/src/{utils → app}/dynamic.d.ts +0 -0
- /package/src/{declarations.d.ts → contracts/declarations.d.ts} +0 -0
- /package/src/{utils → render}/html-boundary.d.ts +0 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Ownership helpers for deciding whether a component stays in the React render lane.
|
|
3
|
+
*/
|
|
4
|
+
import type { EcoComponent, EcoComponentConfig, EcoPagesElement } from '@ecopages/core';
|
|
5
|
+
import type { FunctionComponent } from 'react';
|
|
6
|
+
export type SerializableProps = Record<string, unknown>;
|
|
7
|
+
export type ReactRenderableComponent<P extends SerializableProps = SerializableProps> = FunctionComponent<P> & {
|
|
8
|
+
config?: EcoComponentConfig;
|
|
9
|
+
requires?: string | readonly string[];
|
|
10
|
+
};
|
|
11
|
+
export type RequiresAwareComponent = {
|
|
12
|
+
requires?: string | readonly string[];
|
|
13
|
+
};
|
|
14
|
+
/**
|
|
15
|
+
* Reads the declared integration name for a component or layout.
|
|
16
|
+
*
|
|
17
|
+
* @remarks
|
|
18
|
+
* Honors both the explicit `config.integration` override and build-time
|
|
19
|
+
* `getComponentIdentity(component)?.integration` attribution.
|
|
20
|
+
*/
|
|
21
|
+
export declare function getComponentIntegration(component?: {
|
|
22
|
+
config?: EcoComponentConfig;
|
|
23
|
+
} | null): string | undefined;
|
|
24
|
+
/**
|
|
25
|
+
* Returns whether a component should stay inside the React render lane.
|
|
26
|
+
*
|
|
27
|
+
* @remarks
|
|
28
|
+
* Components without explicit integration metadata are treated as React-owned
|
|
29
|
+
* because this renderer only receives them after the route pipeline has already
|
|
30
|
+
* selected the React integration.
|
|
31
|
+
*/
|
|
32
|
+
export declare function isReactManagedComponent(component: {
|
|
33
|
+
config?: EcoComponentConfig;
|
|
34
|
+
} | null | undefined, reactIntegrationName: string): boolean;
|
|
35
|
+
export declare function getComponentRequires(component?: (EcoComponent & RequiresAwareComponent) | null): string | readonly string[] | undefined;
|
|
36
|
+
/**
|
|
37
|
+
* Commits a framework-agnostic component to React semantics.
|
|
38
|
+
*
|
|
39
|
+
* @remarks
|
|
40
|
+
* Core keeps `EcoComponent` broad so integrations can share the same public surface;
|
|
41
|
+
* once the React renderer is executing, `createElement()` needs a concrete React
|
|
42
|
+
* component signature.
|
|
43
|
+
*/
|
|
44
|
+
export declare function asReactComponent<P extends SerializableProps>(component: unknown): ReactRenderableComponent<P>;
|
|
45
|
+
/**
|
|
46
|
+
* Commits a mixed-shell component to the string-returning contract required by
|
|
47
|
+
* non-React layouts and HTML templates.
|
|
48
|
+
*/
|
|
49
|
+
export declare function asNonReactShellComponent<P extends SerializableProps>(component: unknown): (props: P) => EcoPagesElement | Promise<EcoPagesElement>;
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Ownership helpers for deciding whether a component stays in the React render lane.
|
|
3
|
+
*/
|
|
4
|
+
import { getComponentOwner } from '@ecopages/core';
|
|
5
|
+
/**
|
|
6
|
+
* Reads the declared integration name for a component or layout.
|
|
7
|
+
*
|
|
8
|
+
* @remarks
|
|
9
|
+
* Honors both the explicit `config.integration` override and build-time
|
|
10
|
+
* `getComponentIdentity(component)?.integration` attribution.
|
|
11
|
+
*/
|
|
12
|
+
export function getComponentIntegration(component) {
|
|
13
|
+
return getComponentOwner(component?.config);
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Returns whether a component should stay inside the React render lane.
|
|
17
|
+
*
|
|
18
|
+
* @remarks
|
|
19
|
+
* Components without explicit integration metadata are treated as React-owned
|
|
20
|
+
* because this renderer only receives them after the route pipeline has already
|
|
21
|
+
* selected the React integration.
|
|
22
|
+
*/
|
|
23
|
+
export function isReactManagedComponent(component, reactIntegrationName) {
|
|
24
|
+
const integration = getComponentIntegration(component);
|
|
25
|
+
return integration === undefined || integration === reactIntegrationName;
|
|
26
|
+
}
|
|
27
|
+
export function getComponentRequires(component) {
|
|
28
|
+
return component?.requires;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Commits a framework-agnostic component to React semantics.
|
|
32
|
+
*
|
|
33
|
+
* @remarks
|
|
34
|
+
* Core keeps `EcoComponent` broad so integrations can share the same public surface;
|
|
35
|
+
* once the React renderer is executing, `createElement()` needs a concrete React
|
|
36
|
+
* component signature.
|
|
37
|
+
*/
|
|
38
|
+
export function asReactComponent(component) {
|
|
39
|
+
return component;
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Commits a mixed-shell component to the string-returning contract required by
|
|
43
|
+
* non-React layouts and HTML templates.
|
|
44
|
+
*/
|
|
45
|
+
export function asNonReactShellComponent(component) {
|
|
46
|
+
return component;
|
|
47
|
+
}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* React component SSR helpers: renderToString, foreign-subtree HTML, island attributes.
|
|
3
|
+
*/
|
|
4
|
+
/**
|
|
5
|
+
* React component SSR helpers: renderToString, foreign-subtree HTML, island attributes.
|
|
6
|
+
*/
|
|
7
|
+
import type { EcoComponent, EcoPagesElement } from '@ecopages/core';
|
|
8
|
+
import type { ComponentRenderInput } from '@ecopages/core/integration';
|
|
9
|
+
import type { IntegrationRenderer } from '@ecopages/core/integration';
|
|
10
|
+
import type { ReactNode } from 'react';
|
|
11
|
+
import { type SerializableProps } from './component-ownership.js';
|
|
12
|
+
import type { ReactRuntimeModules } from './react-runtime.js';
|
|
13
|
+
export type ReactComponentRenderContext = {
|
|
14
|
+
componentInstanceId?: string;
|
|
15
|
+
};
|
|
16
|
+
export type ReactForeignSubtreeResolutionContext = {
|
|
17
|
+
rendererCache: Map<string, IntegrationRenderer<any>>;
|
|
18
|
+
componentInstanceScope?: string;
|
|
19
|
+
nextForeignSubtreeId: number;
|
|
20
|
+
queuedResolutions: Array<{
|
|
21
|
+
token: string;
|
|
22
|
+
component: EcoComponent;
|
|
23
|
+
props: Record<string, unknown>;
|
|
24
|
+
componentInstanceId: string;
|
|
25
|
+
}>;
|
|
26
|
+
rawChildrenToken?: string;
|
|
27
|
+
rawChildrenHtml?: string;
|
|
28
|
+
};
|
|
29
|
+
export declare function buildHydrationProps(props: SerializableProps | undefined): SerializableProps;
|
|
30
|
+
/**
|
|
31
|
+
* Renders a non-React layout or HTML template and enforces that mixed shells
|
|
32
|
+
* return serialized HTML.
|
|
33
|
+
*/
|
|
34
|
+
export declare function renderNonReactShellComponent<P extends SerializableProps>(Component: (props: P) => EcoPagesElement | Promise<EcoPagesElement>, props: P, label: 'Layout' | 'HtmlTemplate' | 'Component'): Promise<string>;
|
|
35
|
+
/**
|
|
36
|
+
* Renders one React component while preserving already-resolved child HTML.
|
|
37
|
+
*
|
|
38
|
+
* @remarks
|
|
39
|
+
* When nested foreign-subtree resolution has already produced child HTML, the child
|
|
40
|
+
* payload must remain raw SSR output rather than a React string child, otherwise
|
|
41
|
+
* React would escape it. This helper renders a unique token through React and swaps
|
|
42
|
+
* that token back to the resolved HTML afterward.
|
|
43
|
+
*/
|
|
44
|
+
export declare function renderComponentHtml(options: {
|
|
45
|
+
input: ComponentRenderInput;
|
|
46
|
+
context: ReactComponentRenderContext;
|
|
47
|
+
runtimeContext?: ReactForeignSubtreeResolutionContext;
|
|
48
|
+
runtime: ReactRuntimeModules;
|
|
49
|
+
}): string;
|
|
50
|
+
export declare function toReactNode(children: unknown, integrationName: string): ReactNode;
|
|
51
|
+
/**
|
|
52
|
+
* Restores raw child HTML placeholders stored on the foreign-subtree runtime context.
|
|
53
|
+
*
|
|
54
|
+
* @remarks
|
|
55
|
+
* Queued foreign-subtree resolution may render children through a fragment path before
|
|
56
|
+
* nested integration tokens are resolved. React must never see resolved child HTML as a
|
|
57
|
+
* normal string child or it would escape it.
|
|
58
|
+
*/
|
|
59
|
+
export declare function restoreRuntimeChildHtml(html: string, runtimeContext: ReactForeignSubtreeResolutionContext | undefined): string;
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* React component SSR helpers: renderToString, foreign-subtree HTML, island attributes.
|
|
3
|
+
*/
|
|
4
|
+
import { isValidElement } from 'react';
|
|
5
|
+
import { asReactComponent } from './component-ownership.js';
|
|
6
|
+
import { ReactRenderError } from './errors.js';
|
|
7
|
+
export function buildHydrationProps(props) {
|
|
8
|
+
if (!props || !Object.prototype.hasOwnProperty.call(props, 'locals')) {
|
|
9
|
+
return props ?? {};
|
|
10
|
+
}
|
|
11
|
+
const { locals: _locals, ...hydrationProps } = props;
|
|
12
|
+
return hydrationProps;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Renders a non-React layout or HTML template and enforces that mixed shells
|
|
16
|
+
* return serialized HTML.
|
|
17
|
+
*/
|
|
18
|
+
export async function renderNonReactShellComponent(Component, props, label) {
|
|
19
|
+
const output = await Component(props);
|
|
20
|
+
if (typeof output === 'string') {
|
|
21
|
+
return output;
|
|
22
|
+
}
|
|
23
|
+
throw new ReactRenderError(`${label} must return a string when used as a mixed shell for React pages.`);
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Renders one React component while preserving already-resolved child HTML.
|
|
27
|
+
*
|
|
28
|
+
* @remarks
|
|
29
|
+
* When nested foreign-subtree resolution has already produced child HTML, the child
|
|
30
|
+
* payload must remain raw SSR output rather than a React string child, otherwise
|
|
31
|
+
* React would escape it. This helper renders a unique token through React and swaps
|
|
32
|
+
* that token back to the resolved HTML afterward.
|
|
33
|
+
*/
|
|
34
|
+
export function renderComponentHtml(options) {
|
|
35
|
+
const { input, context, runtimeContext, runtime } = options;
|
|
36
|
+
const { react, reactDomServer } = runtime;
|
|
37
|
+
if (input.children === undefined) {
|
|
38
|
+
return reactDomServer.renderToString(react.createElement(asReactComponent(input.component), input.props));
|
|
39
|
+
}
|
|
40
|
+
if (isValidElement(input.children)) {
|
|
41
|
+
return reactDomServer.renderToString(react.createElement(asReactComponent(input.component), input.props, input.children));
|
|
42
|
+
}
|
|
43
|
+
const resolvedChildHtml = typeof input.children === 'string' ? input.children : String(input.children ?? '');
|
|
44
|
+
const rawChildrenToken = `__ECO_RAW_HTML_CHILD_${context.componentInstanceId ?? 'component'}__`;
|
|
45
|
+
if (runtimeContext) {
|
|
46
|
+
runtimeContext.rawChildrenToken = rawChildrenToken;
|
|
47
|
+
runtimeContext.rawChildrenHtml = resolvedChildHtml;
|
|
48
|
+
}
|
|
49
|
+
const html = reactDomServer.renderToString(react.createElement(asReactComponent(input.component), input.props, rawChildrenToken));
|
|
50
|
+
return html.split(rawChildrenToken).join(resolvedChildHtml);
|
|
51
|
+
}
|
|
52
|
+
export function toReactNode(children, integrationName) {
|
|
53
|
+
if (children === null ||
|
|
54
|
+
typeof children === 'string' ||
|
|
55
|
+
typeof children === 'number' ||
|
|
56
|
+
typeof children === 'boolean' ||
|
|
57
|
+
isValidElement(children) ||
|
|
58
|
+
Array.isArray(children)) {
|
|
59
|
+
return children;
|
|
60
|
+
}
|
|
61
|
+
throw new TypeError(`[ecopages] ${integrationName} renderer expected a React node child.`);
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Restores raw child HTML placeholders stored on the foreign-subtree runtime context.
|
|
65
|
+
*
|
|
66
|
+
* @remarks
|
|
67
|
+
* Queued foreign-subtree resolution may render children through a fragment path before
|
|
68
|
+
* nested integration tokens are resolved. React must never see resolved child HTML as a
|
|
69
|
+
* normal string child or it would escape it.
|
|
70
|
+
*/
|
|
71
|
+
export function restoreRuntimeChildHtml(html, runtimeContext) {
|
|
72
|
+
if (!runtimeContext?.rawChildrenToken || runtimeContext.rawChildrenHtml === undefined) {
|
|
73
|
+
return html;
|
|
74
|
+
}
|
|
75
|
+
return html.split(runtimeContext.rawChildrenToken).join(runtimeContext.rawChildrenHtml);
|
|
76
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { EcoComponent, EcoEmbedProps as CoreEcoEmbedProps } from '@ecopages/core';
|
|
2
|
+
import type { ReactNode } from 'react';
|
|
3
|
+
/**
|
|
4
|
+
* Props for the React-owned `EcoEmbed` adapter.
|
|
5
|
+
*/
|
|
6
|
+
export type EcoEmbedProps<TComponent extends EcoComponent> = CoreEcoEmbedProps<TComponent>;
|
|
7
|
+
/**
|
|
8
|
+
* Renders a foreign or same-integration eco component from a React JSX file
|
|
9
|
+
* without forcing inline mixed-JSX authoring.
|
|
10
|
+
*/
|
|
11
|
+
export declare function EcoEmbed<TComponent extends EcoComponent>({ component, props, children, }: EcoEmbedProps<TComponent>): ReactNode;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/** @jsxImportSource react */
|
|
2
|
+
import { eco } from '@ecopages/core';
|
|
3
|
+
/**
|
|
4
|
+
* Renders a foreign or same-integration eco component from a React JSX file
|
|
5
|
+
* without forcing inline mixed-JSX authoring.
|
|
6
|
+
*/
|
|
7
|
+
export function EcoEmbed({ component, props, children, }) {
|
|
8
|
+
return eco.embed(component, props, children);
|
|
9
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Errors thrown by the React integration renderer and bundling paths.
|
|
3
|
+
*/
|
|
4
|
+
/**
|
|
5
|
+
* Error thrown when an error occurs while rendering a React component.
|
|
6
|
+
*/
|
|
7
|
+
export declare class ReactRenderError extends Error {
|
|
8
|
+
constructor(message: string);
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Error thrown when an error occurs while bundling a React component.
|
|
12
|
+
*/
|
|
13
|
+
export declare class BundleError extends Error {
|
|
14
|
+
readonly logs: string[];
|
|
15
|
+
constructor(message: string, logs: string[]);
|
|
16
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Errors thrown by the React integration renderer and bundling paths.
|
|
3
|
+
*/
|
|
4
|
+
/**
|
|
5
|
+
* Error thrown when an error occurs while rendering a React component.
|
|
6
|
+
*/
|
|
7
|
+
export class ReactRenderError extends Error {
|
|
8
|
+
constructor(message) {
|
|
9
|
+
super(message);
|
|
10
|
+
this.name = 'ReactRenderError';
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Error thrown when an error occurs while bundling a React component.
|
|
15
|
+
*/
|
|
16
|
+
export class BundleError extends Error {
|
|
17
|
+
logs;
|
|
18
|
+
constructor(message, logs) {
|
|
19
|
+
super(message);
|
|
20
|
+
this.name = 'BundleError';
|
|
21
|
+
this.logs = logs;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
const VOID_TAGS = new Set([
|
|
2
|
+
'area',
|
|
3
|
+
'base',
|
|
4
|
+
'br',
|
|
5
|
+
'col',
|
|
6
|
+
'embed',
|
|
7
|
+
'hr',
|
|
8
|
+
'img',
|
|
9
|
+
'input',
|
|
10
|
+
'link',
|
|
11
|
+
'meta',
|
|
12
|
+
'param',
|
|
13
|
+
'source',
|
|
14
|
+
'track',
|
|
15
|
+
'wbr',
|
|
16
|
+
]);
|
|
17
|
+
/**
|
|
18
|
+
* Returns true when HTML contains exactly one root element node.
|
|
19
|
+
*
|
|
20
|
+
* Used by component-level React rendering to decide whether root attributes can
|
|
21
|
+
* be attached safely without introducing synthetic wrapper nodes.
|
|
22
|
+
*/
|
|
23
|
+
export function hasSingleRootElement(html) {
|
|
24
|
+
const firstTagMatch = html.match(/^\s*<([a-zA-Z][a-zA-Z0-9:-]*)\b[^>]*>/);
|
|
25
|
+
if (!firstTagMatch) {
|
|
26
|
+
return false;
|
|
27
|
+
}
|
|
28
|
+
const firstTag = firstTagMatch[1].toLowerCase();
|
|
29
|
+
const firstTagText = firstTagMatch[0];
|
|
30
|
+
const firstTagStart = firstTagMatch.index ?? 0;
|
|
31
|
+
const firstTagEnd = firstTagStart + firstTagText.length;
|
|
32
|
+
const isSelfClosing = /\/\s*>$/.test(firstTagText);
|
|
33
|
+
if (isSelfClosing || VOID_TAGS.has(firstTag)) {
|
|
34
|
+
return html.slice(firstTagEnd).trim().length === 0;
|
|
35
|
+
}
|
|
36
|
+
const tokenRegex = /<\/?([a-zA-Z][a-zA-Z0-9:-]*)\b[^>]*>/g;
|
|
37
|
+
tokenRegex.lastIndex = firstTagEnd;
|
|
38
|
+
let depth = 1;
|
|
39
|
+
for (let token = tokenRegex.exec(html); token; token = tokenRegex.exec(html)) {
|
|
40
|
+
const tagText = token[0];
|
|
41
|
+
const tagName = token[1].toLowerCase();
|
|
42
|
+
const isClosing = tagText.startsWith('</');
|
|
43
|
+
const tokenSelfClosing = /\/\s*>$/.test(tagText);
|
|
44
|
+
if (VOID_TAGS.has(tagName) || tokenSelfClosing) {
|
|
45
|
+
continue;
|
|
46
|
+
}
|
|
47
|
+
if (isClosing) {
|
|
48
|
+
depth--;
|
|
49
|
+
if (depth === 0) {
|
|
50
|
+
const afterRoot = html.slice(token.index + token[0].length).trim();
|
|
51
|
+
return afterRoot.length === 0;
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
else {
|
|
55
|
+
depth++;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
return false;
|
|
59
|
+
}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import * as bundledReact from 'react';
|
|
2
|
+
import type { FunctionComponent, ReactElement } from 'react';
|
|
3
|
+
import type { EcoComponent, EcoPageLayoutEntry, LayoutPropsContext } from '@ecopages/core';
|
|
4
|
+
import type { EcoComponentConfig } from '@ecopages/core';
|
|
5
|
+
export type LayoutComposeContext = LayoutPropsContext;
|
|
6
|
+
export type ReactRuntime = typeof bundledReact;
|
|
7
|
+
export type LayoutComposeOptions = {
|
|
8
|
+
context?: LayoutComposeContext;
|
|
9
|
+
/** @remarks Pass the app-resolved React runtime during SSR so composition matches `renderToString`. */
|
|
10
|
+
react?: ReactRuntime;
|
|
11
|
+
/**
|
|
12
|
+
* Optional resolver that substitutes cached layout instances and React keys
|
|
13
|
+
* for SPA layout persistence.
|
|
14
|
+
*/
|
|
15
|
+
resolvePersistedTier?: (layout: EcoComponent, index: number) => {
|
|
16
|
+
layout: EcoComponent;
|
|
17
|
+
key?: string;
|
|
18
|
+
};
|
|
19
|
+
};
|
|
20
|
+
export type LayoutShellEntry = {
|
|
21
|
+
component: EcoComponent;
|
|
22
|
+
props?: Record<string, unknown>;
|
|
23
|
+
};
|
|
24
|
+
export type ComposablePage<P extends Record<string, unknown> = Record<string, unknown>> = FunctionComponent<P> & {
|
|
25
|
+
config?: Pick<EcoComponentConfig, 'layouts' | 'layoutEntries'>;
|
|
26
|
+
};
|
|
27
|
+
/**
|
|
28
|
+
* Reads request-scoped layout context from serialized page props.
|
|
29
|
+
*/
|
|
30
|
+
export declare function resolveLayoutContext(pageProps: Record<string, unknown>): LayoutComposeContext;
|
|
31
|
+
/**
|
|
32
|
+
* Builds layout prop factory context from document-shell layout entries.
|
|
33
|
+
*
|
|
34
|
+
* @remarks
|
|
35
|
+
* Route-scoped `locals` come from shell layout props, not `pageProps.locals` (pageLocals).
|
|
36
|
+
*/
|
|
37
|
+
export declare function resolveLayoutContextFromShell(pageProps: Record<string, unknown>, shellLayouts: LayoutShellEntry[]): LayoutComposeContext;
|
|
38
|
+
/**
|
|
39
|
+
* Resolves props for one layout entry, merging shell locals with an optional factory.
|
|
40
|
+
*/
|
|
41
|
+
export declare function resolveLayoutEntryProps(entry: EcoPageLayoutEntry, context: LayoutComposeContext): Record<string, unknown>;
|
|
42
|
+
/**
|
|
43
|
+
* @remarks
|
|
44
|
+
* Eco page components are wider than React layout composition input; runtime checks narrow callables.
|
|
45
|
+
*/
|
|
46
|
+
export declare function assertComposablePage(Page: unknown): ComposablePage;
|
|
47
|
+
/**
|
|
48
|
+
* Builds the client or SSR React tree for a page and its outer→inner layout stack.
|
|
49
|
+
*
|
|
50
|
+
* @remarks
|
|
51
|
+
* Layout prop factories receive `LayoutPropsContext`. For SSR, pass `options.react` from the
|
|
52
|
+
* app-resolved runtime. Client code can omit it and use the bundled React import.
|
|
53
|
+
*/
|
|
54
|
+
export declare function composeLayoutPageTree<P extends Record<string, unknown>>(Page: ComposablePage<P>, pageProps: P, options?: LayoutComposeOptions): ReactElement;
|
|
55
|
+
/**
|
|
56
|
+
* Builds a layout tree from explicit document-shell layout entries.
|
|
57
|
+
*
|
|
58
|
+
* @remarks
|
|
59
|
+
* Use when the route renderer passes per-tier props (e.g. route `locals` on the layout tier).
|
|
60
|
+
* Shell `entry.props` are authoritative; page config normalization is not required.
|
|
61
|
+
*/
|
|
62
|
+
export declare function composeLayoutPageTreeFromShell<P extends Record<string, unknown>>(Page: ComposablePage<P>, pageProps: P, shellLayouts: LayoutShellEntry[], options?: LayoutComposeOptions): ReactElement;
|
|
63
|
+
/**
|
|
64
|
+
* Normalizes page config layout metadata to an outer→inner component list.
|
|
65
|
+
*/
|
|
66
|
+
export declare function normalizePageLayoutComponents(layouts?: EcoComponent[]): EcoComponent[];
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
import * as bundledReact from 'react';
|
|
2
|
+
function resolveReact(options) {
|
|
3
|
+
return options?.react ?? bundledReact;
|
|
4
|
+
}
|
|
5
|
+
/**
|
|
6
|
+
* @remarks
|
|
7
|
+
* Eco components are wider than React's `createElement` input; runtime checks narrow callables.
|
|
8
|
+
*/
|
|
9
|
+
function toReactComponent(component) {
|
|
10
|
+
if (typeof component !== 'function') {
|
|
11
|
+
throw new TypeError('[ecopages] Expected a function component for layout composition.');
|
|
12
|
+
}
|
|
13
|
+
return component;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Reads request-scoped layout context from serialized page props.
|
|
17
|
+
*/
|
|
18
|
+
export function resolveLayoutContext(pageProps) {
|
|
19
|
+
const context = {};
|
|
20
|
+
if (pageProps.params !== undefined) {
|
|
21
|
+
context.params = pageProps.params;
|
|
22
|
+
}
|
|
23
|
+
if (pageProps.query !== undefined) {
|
|
24
|
+
context.query = pageProps.query;
|
|
25
|
+
}
|
|
26
|
+
if (pageProps.locals !== undefined) {
|
|
27
|
+
context.locals = pageProps.locals;
|
|
28
|
+
}
|
|
29
|
+
return context;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Builds layout prop factory context from document-shell layout entries.
|
|
33
|
+
*
|
|
34
|
+
* @remarks
|
|
35
|
+
* Route-scoped `locals` come from shell layout props, not `pageProps.locals` (pageLocals).
|
|
36
|
+
*/
|
|
37
|
+
export function resolveLayoutContextFromShell(pageProps, shellLayouts) {
|
|
38
|
+
const context = {};
|
|
39
|
+
if (pageProps.params !== undefined) {
|
|
40
|
+
context.params = pageProps.params;
|
|
41
|
+
}
|
|
42
|
+
if (pageProps.query !== undefined) {
|
|
43
|
+
context.query = pageProps.query;
|
|
44
|
+
}
|
|
45
|
+
for (const entry of shellLayouts) {
|
|
46
|
+
if (entry.props !== undefined && Object.prototype.hasOwnProperty.call(entry.props, 'locals')) {
|
|
47
|
+
context.locals = entry.props.locals;
|
|
48
|
+
break;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
return context;
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Resolves props for one layout entry, merging shell locals with an optional factory.
|
|
55
|
+
*/
|
|
56
|
+
export function resolveLayoutEntryProps(entry, context) {
|
|
57
|
+
const shellProps = context.locals ? { locals: context.locals } : {};
|
|
58
|
+
if (!entry.props) {
|
|
59
|
+
return shellProps;
|
|
60
|
+
}
|
|
61
|
+
return {
|
|
62
|
+
...shellProps,
|
|
63
|
+
...entry.props(context),
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* @remarks
|
|
68
|
+
* Eco page components are wider than React layout composition input; runtime checks narrow callables.
|
|
69
|
+
*/
|
|
70
|
+
export function assertComposablePage(Page) {
|
|
71
|
+
if (typeof Page !== 'function') {
|
|
72
|
+
throw new TypeError('[ecopages] Expected a function page component for layout composition.');
|
|
73
|
+
}
|
|
74
|
+
return Page;
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Builds the client or SSR React tree for a page and its outer→inner layout stack.
|
|
78
|
+
*
|
|
79
|
+
* @remarks
|
|
80
|
+
* Layout prop factories receive `LayoutPropsContext`. For SSR, pass `options.react` from the
|
|
81
|
+
* app-resolved runtime. Client code can omit it and use the bundled React import.
|
|
82
|
+
*/
|
|
83
|
+
export function composeLayoutPageTree(Page, pageProps, options) {
|
|
84
|
+
const { createElement } = resolveReact(options);
|
|
85
|
+
const context = options?.context ?? resolveLayoutContext(pageProps);
|
|
86
|
+
const pageElement = createElement(Page, pageProps);
|
|
87
|
+
const layoutEntries = Page.config?.layoutEntries;
|
|
88
|
+
const resolvePersistedTier = options?.resolvePersistedTier;
|
|
89
|
+
if (layoutEntries && layoutEntries.length > 0) {
|
|
90
|
+
return [...layoutEntries].reverse().reduce((children, entry, reverseIndex) => {
|
|
91
|
+
const index = layoutEntries.length - 1 - reverseIndex;
|
|
92
|
+
const layoutProps = resolveLayoutEntryProps(entry, context);
|
|
93
|
+
const tier = resolvePersistedTier?.(entry.component, index);
|
|
94
|
+
const Layout = toReactComponent(tier?.layout ?? entry.component);
|
|
95
|
+
const elementProps = tier?.key ? { key: tier.key, ...layoutProps } : layoutProps;
|
|
96
|
+
return createElement(Layout, elementProps, children);
|
|
97
|
+
}, pageElement);
|
|
98
|
+
}
|
|
99
|
+
const layouts = Page.config?.layouts;
|
|
100
|
+
if (layouts && layouts.length > 0) {
|
|
101
|
+
const layoutProps = context.locals ? { locals: context.locals } : {};
|
|
102
|
+
return [...layouts].reverse().reduce((children, Layout, reverseIndex) => {
|
|
103
|
+
const index = layouts.length - 1 - reverseIndex;
|
|
104
|
+
const tier = resolvePersistedTier?.(Layout, index);
|
|
105
|
+
const ResolvedLayout = toReactComponent(tier?.layout ?? Layout);
|
|
106
|
+
const elementProps = tier?.key ? { key: tier.key, ...layoutProps } : layoutProps;
|
|
107
|
+
return createElement(ResolvedLayout, elementProps, children);
|
|
108
|
+
}, pageElement);
|
|
109
|
+
}
|
|
110
|
+
return pageElement;
|
|
111
|
+
}
|
|
112
|
+
/**
|
|
113
|
+
* Builds a layout tree from explicit document-shell layout entries.
|
|
114
|
+
*
|
|
115
|
+
* @remarks
|
|
116
|
+
* Use when the route renderer passes per-tier props (e.g. route `locals` on the layout tier).
|
|
117
|
+
* Shell `entry.props` are authoritative; page config normalization is not required.
|
|
118
|
+
*/
|
|
119
|
+
export function composeLayoutPageTreeFromShell(Page, pageProps, shellLayouts, options) {
|
|
120
|
+
const { createElement } = resolveReact(options);
|
|
121
|
+
if (shellLayouts.length === 0) {
|
|
122
|
+
return composeLayoutPageTree(Page, pageProps, options);
|
|
123
|
+
}
|
|
124
|
+
const pageElement = createElement(Page, pageProps);
|
|
125
|
+
return [...shellLayouts].reverse().reduce((children, entry) => {
|
|
126
|
+
return createElement(toReactComponent(entry.component), entry.props ?? {}, children);
|
|
127
|
+
}, pageElement);
|
|
128
|
+
}
|
|
129
|
+
/**
|
|
130
|
+
* Normalizes page config layout metadata to an outer→inner component list.
|
|
131
|
+
*/
|
|
132
|
+
export function normalizePageLayoutComponents(layouts) {
|
|
133
|
+
return layouts && layouts.length > 0 ? layouts : [];
|
|
134
|
+
}
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* React IntegrationRenderer orchestrator.
|
|
3
|
+
*
|
|
4
|
+
* @remarks
|
|
5
|
+
* Wires services and delegates SSR / layout composition / ownership details to
|
|
6
|
+
* focused modules under `render/`. Prefer changing those modules for
|
|
7
|
+
* implementation work; keep this file as the IntegrationRenderer seam.
|
|
8
|
+
*
|
|
9
|
+
* @module
|
|
10
|
+
*/
|
|
11
|
+
/**
|
|
12
|
+
* React IntegrationRenderer orchestrator.
|
|
13
|
+
*
|
|
14
|
+
* @remarks
|
|
15
|
+
* Wires services and delegates SSR / layout composition / ownership details to
|
|
16
|
+
* focused modules under `render/`. Prefer changing those modules for
|
|
17
|
+
* implementation work; keep this file as the IntegrationRenderer seam.
|
|
18
|
+
*
|
|
19
|
+
* @module
|
|
20
|
+
*/
|
|
21
|
+
import type { EcoComponent } from '@ecopages/core';
|
|
22
|
+
import { type IntegrationRendererOptions } from '@ecopages/core/integration';
|
|
23
|
+
import type { ReactNode } from 'react';
|
|
24
|
+
import type { ReactRendererConfig } from '../plugin/react.types.js';
|
|
25
|
+
import type { ReactRouterAdapter } from '../contracts/router-adapter.js';
|
|
26
|
+
import { BundleService } from '../bundling/bundle.js';
|
|
27
|
+
import { HmrPageMetadataCache } from '../hmr/page-metadata-cache.js';
|
|
28
|
+
import { MdxConfigDependencyService } from '../mdx/mdx-config-dependency.js';
|
|
29
|
+
import { PageModuleService } from '../page/page-module.js';
|
|
30
|
+
import { PagePayloadService } from '../hydration/page-payload.js';
|
|
31
|
+
import { HydrationAssetService } from '../hydration/hydration-asset.js';
|
|
32
|
+
import { type DocumentShellComposeChildrenContext, type DocumentShellComposeChildrenResult, type DocumentShellLayoutInput } from '@ecopages/core/integration';
|
|
33
|
+
import { type ReactRuntimeModules } from './react-runtime.js';
|
|
34
|
+
export type { ReactRendererConfig } from '../plugin/react.types.js';
|
|
35
|
+
export { BundleError, ReactRenderError } from './errors.js';
|
|
36
|
+
export type ReactRendererOptions = IntegrationRendererOptions & {
|
|
37
|
+
reactConfig?: ReactRendererConfig;
|
|
38
|
+
};
|
|
39
|
+
declare const ReactIntegrationRenderer: new (options: IntegrationRendererOptions) => import("@ecopages/core/integration").IntegrationRenderer<ReactNode> & {
|
|
40
|
+
name: string;
|
|
41
|
+
};
|
|
42
|
+
/** Renderer adapter that contributes React-specific behavior through core hooks. */
|
|
43
|
+
export declare class ReactRenderer extends ReactIntegrationRenderer {
|
|
44
|
+
private reactRuntimeModules?;
|
|
45
|
+
private readonly runtimeStateRef;
|
|
46
|
+
private readonly hookTargets;
|
|
47
|
+
constructor(options: ReactRendererOptions);
|
|
48
|
+
get routerAdapter(): ReactRouterAdapter | undefined;
|
|
49
|
+
get mdxExtensions(): string[];
|
|
50
|
+
get hmrPageMetadataCache(): HmrPageMetadataCache | undefined;
|
|
51
|
+
get forceBrowserGraph(): boolean;
|
|
52
|
+
get bundleService(): BundleService;
|
|
53
|
+
get pageModuleService(): PageModuleService;
|
|
54
|
+
get hydrationAssetService(): HydrationAssetService;
|
|
55
|
+
get pagePayloadService(): PagePayloadService;
|
|
56
|
+
get mdxConfigDependencyService(): MdxConfigDependencyService;
|
|
57
|
+
private getRuntimeState;
|
|
58
|
+
/**
|
|
59
|
+
* Builds React island and lazy-entry modules in one grouped browser build.
|
|
60
|
+
*/
|
|
61
|
+
private buildPageClientBrowserAssetsHook;
|
|
62
|
+
private collectAppBrowserClientBuildEntriesHook;
|
|
63
|
+
private getRouterDocumentAttributes;
|
|
64
|
+
protected resolveReactRuntimeModules(): ReactRuntimeModules;
|
|
65
|
+
private getReactRuntimeModules;
|
|
66
|
+
private resolveReactQueuedForeignSubtreeHtml;
|
|
67
|
+
private renderQueuedChildrenToHtml;
|
|
68
|
+
private buildPagePayload;
|
|
69
|
+
/**
|
|
70
|
+
* Renders a React component for component-level orchestration.
|
|
71
|
+
*
|
|
72
|
+
* Behavior:
|
|
73
|
+
* - SSR always returns the component's own root HTML (no synthetic wrapper).
|
|
74
|
+
* - When an explicit component instance id is provided, a stable
|
|
75
|
+
* `data-eco-component-id` attribute is attached so island hydration can target it.
|
|
76
|
+
* - Without an explicit instance id, component renders remain plain SSR output.
|
|
77
|
+
* - When resolved child HTML is provided, that foreign subtree is treated as a pure SSR
|
|
78
|
+
* composition step and does not emit hydration assets for the parent wrapper.
|
|
79
|
+
*
|
|
80
|
+
* This preserves DOM shape for global CSS/layout selectors while keeping a
|
|
81
|
+
* deterministic mount target per component instance.
|
|
82
|
+
*/
|
|
83
|
+
private renderComponentHook;
|
|
84
|
+
private renderForeignComponentWithSerializedHtml;
|
|
85
|
+
/**
|
|
86
|
+
* Emits a server island host only for eligible, single-root component renders.
|
|
87
|
+
*
|
|
88
|
+
* @remarks
|
|
89
|
+
* Renderer-owned services stay on this class so SSR helpers do not receive
|
|
90
|
+
* wrappers around the renderer's own methods.
|
|
91
|
+
*/
|
|
92
|
+
private renderReactManagedComponent;
|
|
93
|
+
private renderQueuedChildrenHook;
|
|
94
|
+
/**
|
|
95
|
+
* Checks if the given file path corresponds to an MDX file based on configured extensions.
|
|
96
|
+
* @param filePath - The file path to check
|
|
97
|
+
* @returns True if the file is an MDX file
|
|
98
|
+
*/
|
|
99
|
+
isMdxFile(filePath: string): boolean;
|
|
100
|
+
private normalizeImportedPageFileHook;
|
|
101
|
+
private collectPageBrowserGraphContributionHook;
|
|
102
|
+
private composeReactLayoutPageChildrenForShell;
|
|
103
|
+
protected resolveComposeChildren(options: {
|
|
104
|
+
page: {
|
|
105
|
+
component: EcoComponent;
|
|
106
|
+
props: Record<string, unknown>;
|
|
107
|
+
};
|
|
108
|
+
shellLayouts: DocumentShellLayoutInput[];
|
|
109
|
+
foreignChildRoots?: ReadonlyArray<EcoComponent | Partial<EcoComponent>>;
|
|
110
|
+
}): ((context: DocumentShellComposeChildrenContext) => Promise<DocumentShellComposeChildrenResult>) | undefined;
|
|
111
|
+
private buildDocumentShellProps;
|
|
112
|
+
private getHtmlDocumentContributionsHook;
|
|
113
|
+
private getDocumentAttributesHook;
|
|
114
|
+
}
|