@ecopages/react 0.2.0-alpha.5 → 0.2.0-alpha.51
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 +152 -29
- package/package.json +24 -12
- package/src/eco-embed.d.ts +11 -0
- package/src/eco-embed.js +11 -0
- package/src/react-hmr-strategy.d.ts +65 -43
- package/src/react-hmr-strategy.js +298 -145
- package/src/react-renderer.d.ts +169 -42
- package/src/react-renderer.js +484 -164
- package/src/react.constants.d.ts +1 -0
- package/src/react.constants.js +4 -0
- package/src/react.plugin.d.ts +40 -111
- package/src/react.plugin.js +136 -61
- package/src/react.types.d.ts +88 -0
- package/src/react.types.js +0 -0
- package/src/router-adapter.d.ts +7 -14
- package/src/runtime/use-sync-external-store-with-selector.d.ts +3 -0
- package/src/runtime/use-sync-external-store-with-selector.js +56 -0
- package/src/services/react-bundle.service.d.ts +22 -35
- package/src/services/react-bundle.service.js +41 -105
- package/src/services/react-hmr-page-metadata-cache.d.ts +9 -0
- package/src/services/react-hmr-page-metadata-cache.js +18 -2
- package/src/services/react-hydration-asset.service.d.ts +28 -19
- package/src/services/react-hydration-asset.service.js +85 -66
- package/src/services/react-mdx-config-dependency.service.d.ts +36 -0
- package/src/services/react-mdx-config-dependency.service.js +122 -0
- package/src/services/react-page-module.service.d.ts +10 -2
- package/src/services/react-page-module.service.js +47 -39
- package/src/services/react-page-payload.service.d.ts +46 -0
- package/src/services/react-page-payload.service.js +67 -0
- package/src/services/react-runtime-bundle.service.d.ts +20 -13
- package/src/services/react-runtime-bundle.service.js +146 -179
- package/src/utils/client-graph-boundary-plugin.d.ts +1 -1
- package/src/utils/client-graph-boundary-plugin.js +80 -3
- package/src/utils/component-config-traversal.d.ts +36 -0
- package/src/utils/component-config-traversal.js +54 -0
- package/src/utils/declared-modules.d.ts +1 -1
- package/src/utils/declared-modules.js +7 -16
- package/src/utils/dynamic.test.browser.d.ts +1 -0
- package/src/utils/dynamic.test.browser.js +33 -0
- package/src/utils/hydration-scripts.d.ts +27 -6
- package/src/utils/hydration-scripts.js +177 -44
- package/src/utils/hydration-scripts.test.browser.d.ts +1 -0
- package/src/utils/hydration-scripts.test.browser.js +198 -0
- package/src/utils/react-dom-runtime-interop-plugin.d.ts +5 -0
- package/src/utils/react-dom-runtime-interop-plugin.js +38 -0
- package/src/utils/react-mdx-loader-plugin.d.ts +1 -1
- package/src/utils/react-mdx-loader-plugin.js +13 -5
- package/src/utils/react-runtime-alias-map.d.ts +8 -0
- package/src/utils/react-runtime-alias-map.js +90 -0
- package/CHANGELOG.md +0 -67
- package/src/react-hmr-strategy.ts +0 -455
- package/src/react-renderer.ts +0 -403
- package/src/react.plugin.ts +0 -241
- package/src/router-adapter.ts +0 -95
- package/src/services/react-bundle.service.ts +0 -217
- package/src/services/react-hmr-page-metadata-cache.ts +0 -24
- package/src/services/react-hydration-asset.service.ts +0 -260
- package/src/services/react-page-module.service.ts +0 -214
- package/src/services/react-runtime-bundle.service.ts +0 -271
- package/src/utils/client-graph-boundary-plugin.ts +0 -710
- package/src/utils/client-only.ts +0 -27
- package/src/utils/declared-modules.ts +0 -99
- package/src/utils/dynamic.ts +0 -27
- package/src/utils/hmr-scripts.ts +0 -47
- package/src/utils/html-boundary.ts +0 -66
- package/src/utils/hydration-scripts.ts +0 -338
- package/src/utils/reachability-analyzer.ts +0 -593
- package/src/utils/react-mdx-loader-plugin.ts +0 -40
|
@@ -16,13 +16,29 @@ export interface ReactBundleServiceConfig {
|
|
|
16
16
|
rootDir: string;
|
|
17
17
|
routerAdapter?: ReactRouterAdapter;
|
|
18
18
|
mdxCompilerOptions?: CompileOptions;
|
|
19
|
+
nonReactExtensions?: string[];
|
|
20
|
+
jsxImportSource?: string;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Optional flags that adjust how a React client entry is bundled.
|
|
24
|
+
*/
|
|
25
|
+
export interface ReactClientBundleOptions {
|
|
26
|
+
/**
|
|
27
|
+
* When `true`, bundle React runtime dependencies into the emitted entry instead of
|
|
28
|
+
* rewriting them to external runtime specifiers.
|
|
29
|
+
*/
|
|
30
|
+
includeRuntime?: boolean;
|
|
31
|
+
/**
|
|
32
|
+
* When set, overrides the build adapter chunk splitting mode for this entry.
|
|
33
|
+
*/
|
|
34
|
+
splitting?: boolean;
|
|
19
35
|
}
|
|
20
36
|
/**
|
|
21
37
|
* Manages esbuild bundle configuration and plugin creation for React page/component builds.
|
|
22
38
|
*/
|
|
23
39
|
export declare class ReactBundleService {
|
|
24
|
-
private readonly config;
|
|
25
40
|
private readonly runtimeBundleService;
|
|
41
|
+
private readonly config;
|
|
26
42
|
constructor(config: ReactBundleServiceConfig);
|
|
27
43
|
/**
|
|
28
44
|
* Returns resolved runtime import paths for the React runtime.
|
|
@@ -31,43 +47,14 @@ export declare class ReactBundleService {
|
|
|
31
47
|
/**
|
|
32
48
|
* Creates esbuild bundle options for a page or component entry.
|
|
33
49
|
*
|
|
50
|
+
* @remarks
|
|
51
|
+
* React derives runtime specifier mappings from the core browser runtime manifest
|
|
52
|
+
* so ESM imports resolve to concrete runtime asset URLs during module loading.
|
|
53
|
+
*
|
|
34
54
|
* @param componentName - Generated unique component name for output naming
|
|
35
55
|
* @param isMdx - Whether the source file is an MDX file
|
|
36
56
|
* @param declaredModules - Explicitly declared browser module specifiers
|
|
37
57
|
* @returns Bundle options object for the build adapter
|
|
38
58
|
*/
|
|
39
|
-
createBundleOptions(componentName: string, isMdx: boolean, declaredModules: string[]): Promise<Record<string, unknown>>;
|
|
40
|
-
/**
|
|
41
|
-
* Creates the esbuild plugin that rewrites bare React specifiers
|
|
42
|
-
* to their runtime asset URLs.
|
|
43
|
-
*/
|
|
44
|
-
createRuntimeAliasPlugin(runtimeImports: ReactRuntimeImports): {
|
|
45
|
-
name: string;
|
|
46
|
-
setup(build: {
|
|
47
|
-
onResolve: (options: {
|
|
48
|
-
filter: RegExp;
|
|
49
|
-
namespace?: string;
|
|
50
|
-
}, callback: (args: {
|
|
51
|
-
path: string;
|
|
52
|
-
importer: string;
|
|
53
|
-
namespace: string;
|
|
54
|
-
}) => {
|
|
55
|
-
path?: string;
|
|
56
|
-
namespace?: string;
|
|
57
|
-
external?: boolean;
|
|
58
|
-
} | undefined) => void;
|
|
59
|
-
}): void;
|
|
60
|
-
};
|
|
61
|
-
/**
|
|
62
|
-
* Redirects `use-sync-external-store/shim` imports to React's built-in
|
|
63
|
-
* `useSyncExternalStore`.
|
|
64
|
-
*
|
|
65
|
-
* Libraries like React Aria still list `use-sync-external-store` as a
|
|
66
|
-
* dependency to support React 16/17. On React 18+ the `/shim` export is
|
|
67
|
-
* already a pass-through, but without this plugin esbuild would bundle
|
|
68
|
-
* the full CJS shim (including `process.env` branching) into the browser
|
|
69
|
-
* bundle. The plugin short-circuits the resolution so only a single clean
|
|
70
|
-
* ESM re-export is emitted.
|
|
71
|
-
*/
|
|
72
|
-
private createSyncExternalStorePlugin;
|
|
59
|
+
createBundleOptions(componentName: string, isMdx: boolean, declaredModules: string[], bundleOptions?: ReactClientBundleOptions): Promise<Record<string, unknown>>;
|
|
73
60
|
}
|
|
@@ -1,13 +1,22 @@
|
|
|
1
1
|
import { createClientGraphBoundaryPlugin } from "../utils/client-graph-boundary-plugin.js";
|
|
2
|
+
import {
|
|
3
|
+
getReactClientGraphAllowSpecifiers,
|
|
4
|
+
getReactRuntimeExternalSpecifiers
|
|
5
|
+
} from "../utils/react-runtime-alias-map.js";
|
|
6
|
+
import { createBrowserRuntimeImportRewritePlugin } from "@ecopages/core/build/browser-runtime-import-rewrite-plugin";
|
|
7
|
+
import { createForeignJsxOverridePlugin } from "@ecopages/core/plugins/foreign-jsx-override-plugin";
|
|
2
8
|
import { ReactRuntimeBundleService } from "./react-runtime-bundle.service.js";
|
|
9
|
+
import { createReactMdxLoaderPlugin } from "../utils/react-mdx-loader-plugin.js";
|
|
3
10
|
class ReactBundleService {
|
|
11
|
+
runtimeBundleService;
|
|
12
|
+
config;
|
|
4
13
|
constructor(config) {
|
|
5
14
|
this.config = config;
|
|
6
15
|
this.runtimeBundleService = new ReactRuntimeBundleService({
|
|
16
|
+
rootDir: config.rootDir,
|
|
7
17
|
routerAdapter: config.routerAdapter
|
|
8
18
|
});
|
|
9
19
|
}
|
|
10
|
-
runtimeBundleService;
|
|
11
20
|
/**
|
|
12
21
|
* Returns resolved runtime import paths for the React runtime.
|
|
13
22
|
*/
|
|
@@ -17,133 +26,60 @@ class ReactBundleService {
|
|
|
17
26
|
/**
|
|
18
27
|
* Creates esbuild bundle options for a page or component entry.
|
|
19
28
|
*
|
|
29
|
+
* @remarks
|
|
30
|
+
* React derives runtime specifier mappings from the core browser runtime manifest
|
|
31
|
+
* so ESM imports resolve to concrete runtime asset URLs during module loading.
|
|
32
|
+
*
|
|
20
33
|
* @param componentName - Generated unique component name for output naming
|
|
21
34
|
* @param isMdx - Whether the source file is an MDX file
|
|
22
35
|
* @param declaredModules - Explicitly declared browser module specifiers
|
|
23
36
|
* @returns Bundle options object for the build adapter
|
|
24
37
|
*/
|
|
25
|
-
async createBundleOptions(componentName, isMdx, declaredModules) {
|
|
38
|
+
async createBundleOptions(componentName, isMdx, declaredModules, bundleOptions = {}) {
|
|
26
39
|
const runtimeImports = this.getRuntimeImports();
|
|
27
40
|
const options = {
|
|
28
|
-
external: ["react", "react-dom", "react/jsx-runtime", "react/jsx-dev-runtime", "react-dom/client"],
|
|
29
41
|
mainFields: ["module", "browser", "main"],
|
|
30
42
|
naming: `${componentName}.[ext]`,
|
|
31
43
|
...import.meta.env?.NODE_ENV === "production" && {
|
|
32
44
|
minify: true,
|
|
33
|
-
splitting: false,
|
|
34
45
|
treeshaking: true
|
|
35
|
-
}
|
|
46
|
+
},
|
|
47
|
+
...bundleOptions.splitting === void 0 ? {} : { splitting: bundleOptions.splitting }
|
|
36
48
|
};
|
|
49
|
+
if (!bundleOptions.includeRuntime) {
|
|
50
|
+
const reactRuntimeSpecifiers = new Set(getReactRuntimeExternalSpecifiers());
|
|
51
|
+
options.external = [
|
|
52
|
+
...Object.values(runtimeImports).filter(
|
|
53
|
+
(specifier) => Boolean(specifier) && !reactRuntimeSpecifiers.has(
|
|
54
|
+
specifier
|
|
55
|
+
)
|
|
56
|
+
)
|
|
57
|
+
];
|
|
58
|
+
}
|
|
37
59
|
const graphBoundaryPlugin = createClientGraphBoundaryPlugin({
|
|
38
60
|
absWorkingDir: this.config.rootDir,
|
|
39
61
|
declaredModules,
|
|
40
|
-
alwaysAllowSpecifiers: [
|
|
41
|
-
"@ecopages/core",
|
|
42
|
-
"react",
|
|
43
|
-
"react-dom",
|
|
44
|
-
"react/jsx-runtime",
|
|
45
|
-
"react/jsx-dev-runtime",
|
|
46
|
-
"react-dom/client",
|
|
47
|
-
...this.config.routerAdapter ? [this.config.routerAdapter.importMapKey] : []
|
|
48
|
-
]
|
|
62
|
+
alwaysAllowSpecifiers: getReactClientGraphAllowSpecifiers([], this.config.routerAdapter)
|
|
49
63
|
});
|
|
50
|
-
const
|
|
51
|
-
|
|
64
|
+
const foreignJsxOverridePlugin = createForeignJsxOverridePlugin({
|
|
65
|
+
name: "react-renderer-foreign-jsx-override",
|
|
66
|
+
hostJsxImportSource: this.config.jsxImportSource ?? "react",
|
|
67
|
+
foreignExtensions: this.config.nonReactExtensions ?? []
|
|
68
|
+
});
|
|
69
|
+
const runtimeManifest = this.runtimeBundleService.getRuntimeManifest();
|
|
70
|
+
const runtimeRewritePlugin = createBrowserRuntimeImportRewritePlugin({
|
|
71
|
+
name: "react-renderer-runtime-import-rewrite",
|
|
72
|
+
manifest: runtimeManifest
|
|
73
|
+
});
|
|
74
|
+
const runtimePlugins = bundleOptions.includeRuntime ? [] : [runtimeRewritePlugin].filter((plugin) => plugin !== null);
|
|
52
75
|
if (isMdx && this.config.mdxCompilerOptions) {
|
|
53
|
-
const { createReactMdxLoaderPlugin } = await import("../utils/react-mdx-loader-plugin.js");
|
|
54
76
|
const mdxPlugin = createReactMdxLoaderPlugin(this.config.mdxCompilerOptions);
|
|
55
|
-
options.plugins = [graphBoundaryPlugin,
|
|
77
|
+
options.plugins = [foreignJsxOverridePlugin, graphBoundaryPlugin, ...runtimePlugins, mdxPlugin];
|
|
56
78
|
} else {
|
|
57
|
-
options.plugins = [
|
|
79
|
+
options.plugins = [foreignJsxOverridePlugin, graphBoundaryPlugin, ...runtimePlugins];
|
|
58
80
|
}
|
|
59
81
|
return options;
|
|
60
82
|
}
|
|
61
|
-
/**
|
|
62
|
-
* Creates the esbuild plugin that rewrites bare React specifiers
|
|
63
|
-
* to their runtime asset URLs.
|
|
64
|
-
*/
|
|
65
|
-
createRuntimeAliasPlugin(runtimeImports) {
|
|
66
|
-
const aliases = /* @__PURE__ */ new Map([
|
|
67
|
-
["react", runtimeImports.react],
|
|
68
|
-
["react-dom/client", runtimeImports.reactDomClient],
|
|
69
|
-
["react/jsx-runtime", runtimeImports.reactJsxRuntime],
|
|
70
|
-
["react/jsx-dev-runtime", runtimeImports.reactJsxDevRuntime],
|
|
71
|
-
["react-dom", runtimeImports.reactDom]
|
|
72
|
-
]);
|
|
73
|
-
if (this.config.routerAdapter && runtimeImports.router) {
|
|
74
|
-
aliases.set(this.config.routerAdapter.importMapKey, runtimeImports.router);
|
|
75
|
-
}
|
|
76
|
-
const escapeRegExp = (value) => value.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
77
|
-
const pattern = new RegExp(
|
|
78
|
-
`^(${Array.from(aliases.keys()).map((key) => escapeRegExp(key)).join("|")})$`
|
|
79
|
-
);
|
|
80
|
-
return {
|
|
81
|
-
name: "react-runtime-import-alias",
|
|
82
|
-
setup(build) {
|
|
83
|
-
build.onResolve({ filter: pattern }, (args) => {
|
|
84
|
-
const mappedPath = aliases.get(args.path);
|
|
85
|
-
if (!mappedPath) {
|
|
86
|
-
return void 0;
|
|
87
|
-
}
|
|
88
|
-
return {
|
|
89
|
-
path: mappedPath,
|
|
90
|
-
external: true
|
|
91
|
-
};
|
|
92
|
-
});
|
|
93
|
-
}
|
|
94
|
-
};
|
|
95
|
-
}
|
|
96
|
-
/**
|
|
97
|
-
* Redirects `use-sync-external-store/shim` imports to React's built-in
|
|
98
|
-
* `useSyncExternalStore`.
|
|
99
|
-
*
|
|
100
|
-
* Libraries like React Aria still list `use-sync-external-store` as a
|
|
101
|
-
* dependency to support React 16/17. On React 18+ the `/shim` export is
|
|
102
|
-
* already a pass-through, but without this plugin esbuild would bundle
|
|
103
|
-
* the full CJS shim (including `process.env` branching) into the browser
|
|
104
|
-
* bundle. The plugin short-circuits the resolution so only a single clean
|
|
105
|
-
* ESM re-export is emitted.
|
|
106
|
-
*/
|
|
107
|
-
createSyncExternalStorePlugin() {
|
|
108
|
-
return {
|
|
109
|
-
name: "react-renderer-use-sync-external-store-shim",
|
|
110
|
-
setup(build) {
|
|
111
|
-
build.onResolve({ filter: /^use-sync-external-store\/shim(?:\/index\.js)?$/ }, () => ({
|
|
112
|
-
path: "use-sync-external-store/shim",
|
|
113
|
-
namespace: "ecopages-react-renderer-shim"
|
|
114
|
-
}));
|
|
115
|
-
build.onLoad(
|
|
116
|
-
{ filter: /^use-sync-external-store\/shim$/, namespace: "ecopages-react-renderer-shim" },
|
|
117
|
-
() => ({
|
|
118
|
-
contents: "export { useSyncExternalStore } from 'react';",
|
|
119
|
-
loader: "js"
|
|
120
|
-
})
|
|
121
|
-
);
|
|
122
|
-
build.onLoad({ filter: /[\\/]use-sync-external-store[\\/]shim[\\/]index\.js$/ }, () => ({
|
|
123
|
-
contents: "export { useSyncExternalStore } from 'react';",
|
|
124
|
-
loader: "js"
|
|
125
|
-
}));
|
|
126
|
-
build.onLoad(
|
|
127
|
-
{
|
|
128
|
-
filter: /[\\/]use-sync-external-store[\\/]cjs[\\/]use-sync-external-store-shim\.development\.js$/
|
|
129
|
-
},
|
|
130
|
-
() => ({
|
|
131
|
-
contents: "export { useSyncExternalStore } from 'react';",
|
|
132
|
-
loader: "js"
|
|
133
|
-
})
|
|
134
|
-
);
|
|
135
|
-
build.onLoad(
|
|
136
|
-
{
|
|
137
|
-
filter: /[\\/]use-sync-external-store[\\/]cjs[\\/]use-sync-external-store-shim\.production\.js$/
|
|
138
|
-
},
|
|
139
|
-
() => ({
|
|
140
|
-
contents: "export { useSyncExternalStore } from 'react';",
|
|
141
|
-
loader: "js"
|
|
142
|
-
})
|
|
143
|
-
);
|
|
144
|
-
}
|
|
145
|
-
};
|
|
146
|
-
}
|
|
147
83
|
}
|
|
148
84
|
export {
|
|
149
85
|
ReactBundleService
|
|
@@ -6,6 +6,11 @@
|
|
|
6
6
|
*/
|
|
7
7
|
export declare class ReactHmrPageMetadataCache {
|
|
8
8
|
private readonly declaredModulesByEntrypoint;
|
|
9
|
+
private readonly ownedEntrypoints;
|
|
10
|
+
/**
|
|
11
|
+
* Marks an HMR entrypoint as React-owned.
|
|
12
|
+
*/
|
|
13
|
+
markOwnedEntrypoint(entrypointPath: string): void;
|
|
9
14
|
/**
|
|
10
15
|
* Stores the declared browser modules for a page entrypoint.
|
|
11
16
|
*/
|
|
@@ -14,4 +19,8 @@ export declare class ReactHmrPageMetadataCache {
|
|
|
14
19
|
* Returns the last known declared browser modules for a page entrypoint.
|
|
15
20
|
*/
|
|
16
21
|
getDeclaredModules(entrypointPath: string): string[] | undefined;
|
|
22
|
+
/**
|
|
23
|
+
* Returns true when the watched entrypoint is owned by the React integration.
|
|
24
|
+
*/
|
|
25
|
+
ownsEntrypoint(entrypointPath: string): boolean;
|
|
17
26
|
}
|
|
@@ -1,18 +1,34 @@
|
|
|
1
|
+
import path from "node:path";
|
|
1
2
|
class ReactHmrPageMetadataCache {
|
|
2
3
|
declaredModulesByEntrypoint = /* @__PURE__ */ new Map();
|
|
4
|
+
ownedEntrypoints = /* @__PURE__ */ new Set();
|
|
5
|
+
/**
|
|
6
|
+
* Marks an HMR entrypoint as React-owned.
|
|
7
|
+
*/
|
|
8
|
+
markOwnedEntrypoint(entrypointPath) {
|
|
9
|
+
this.ownedEntrypoints.add(path.resolve(entrypointPath));
|
|
10
|
+
}
|
|
3
11
|
/**
|
|
4
12
|
* Stores the declared browser modules for a page entrypoint.
|
|
5
13
|
*/
|
|
6
14
|
setDeclaredModules(entrypointPath, declaredModules) {
|
|
7
|
-
|
|
15
|
+
const resolvedEntrypointPath = path.resolve(entrypointPath);
|
|
16
|
+
this.markOwnedEntrypoint(resolvedEntrypointPath);
|
|
17
|
+
this.declaredModulesByEntrypoint.set(resolvedEntrypointPath, [...declaredModules]);
|
|
8
18
|
}
|
|
9
19
|
/**
|
|
10
20
|
* Returns the last known declared browser modules for a page entrypoint.
|
|
11
21
|
*/
|
|
12
22
|
getDeclaredModules(entrypointPath) {
|
|
13
|
-
const declaredModules = this.declaredModulesByEntrypoint.get(entrypointPath);
|
|
23
|
+
const declaredModules = this.declaredModulesByEntrypoint.get(path.resolve(entrypointPath));
|
|
14
24
|
return declaredModules ? [...declaredModules] : void 0;
|
|
15
25
|
}
|
|
26
|
+
/**
|
|
27
|
+
* Returns true when the watched entrypoint is owned by the React integration.
|
|
28
|
+
*/
|
|
29
|
+
ownsEntrypoint(entrypointPath) {
|
|
30
|
+
return this.ownedEntrypoints.has(path.resolve(entrypointPath));
|
|
31
|
+
}
|
|
16
32
|
}
|
|
17
33
|
export {
|
|
18
34
|
ReactHmrPageMetadataCache
|
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Hydration asset creation service for React integration.
|
|
3
3
|
*
|
|
4
|
-
* Builds the asset definitions
|
|
5
|
-
*
|
|
6
|
-
* island level.
|
|
4
|
+
* Builds the asset definitions required for client-side React rendering — both at
|
|
5
|
+
* the page level and the component island level.
|
|
7
6
|
*
|
|
8
7
|
* @module
|
|
9
8
|
*/
|
|
@@ -23,53 +22,63 @@ export interface ReactHydrationAssetServiceConfig {
|
|
|
23
22
|
bundleService: ReactBundleService;
|
|
24
23
|
hmrPageMetadataCache?: ReactHmrPageMetadataCache;
|
|
25
24
|
}
|
|
25
|
+
export declare function getReactIslandComponentKey(componentFile: string, config?: EcoComponentConfig): string;
|
|
26
26
|
/**
|
|
27
27
|
* Manages the creation of client-side hydration assets for React pages and component islands.
|
|
28
28
|
*/
|
|
29
29
|
export declare class ReactHydrationAssetService {
|
|
30
30
|
private readonly config;
|
|
31
|
+
private static readonly ROUTER_PAGE_GROUPED_BUNDLE_ID;
|
|
31
32
|
constructor(config: ReactHydrationAssetServiceConfig);
|
|
33
|
+
private getIslandBundleName;
|
|
34
|
+
private getIslandHydrationName;
|
|
35
|
+
private getRouterPageGroupedEntryName;
|
|
32
36
|
/**
|
|
33
|
-
* Resolves the import path for
|
|
37
|
+
* Resolves the browser import path used for a React-owned page or island module.
|
|
34
38
|
* Uses HMR manager for development or constructs static path for production.
|
|
35
39
|
*
|
|
36
40
|
* @param pagePath - Absolute path to the page source file
|
|
37
|
-
* @param
|
|
38
|
-
* @returns The resolved import path for the
|
|
41
|
+
* @param assetName - Generated asset name
|
|
42
|
+
* @returns The resolved browser import path for the module
|
|
39
43
|
*/
|
|
40
|
-
resolveAssetImportPath(pagePath: string,
|
|
44
|
+
resolveAssetImportPath(pagePath: string, assetName: string): Promise<string>;
|
|
41
45
|
/**
|
|
42
|
-
* Creates the
|
|
46
|
+
* Creates the page-owned route entry asset for hydration and client navigation.
|
|
43
47
|
*
|
|
44
48
|
* @param pagePath - Absolute path to the page source file
|
|
45
49
|
* @param componentName - Generated unique component name
|
|
46
|
-
* @param importPath - Resolved import path
|
|
50
|
+
* @param importPath - Resolved browser import path used by development HMR
|
|
47
51
|
* @param bundleOptions - Bundle configuration options
|
|
48
52
|
* @param isDevelopment - Whether running in development mode with HMR
|
|
49
53
|
* @param isMdx - Whether the source file is an MDX file
|
|
50
|
-
* @
|
|
51
|
-
* @returns Array of asset definitions for processing
|
|
54
|
+
* @returns One page-owned asset definition for processing
|
|
52
55
|
*/
|
|
53
|
-
createPageDependencies(pagePath: string, componentName: string, importPath: string, bundleOptions: Record<string, unknown>, isDevelopment: boolean,
|
|
56
|
+
createPageDependencies(pagePath: string, componentName: string, importPath: string, pageModuleUrlExpression: string, bundleOptions: Record<string, unknown>, isDevelopment: boolean, useBrowserRuntimeImports: boolean, isMdx: boolean): AssetDefinition[];
|
|
54
57
|
/**
|
|
55
58
|
* Builds client-side assets for a React component island.
|
|
56
59
|
*
|
|
57
|
-
* Includes the bundled component entry and
|
|
60
|
+
* Includes the bundled component entry and a shared hydration bootstrap script.
|
|
58
61
|
*
|
|
59
62
|
* @param componentFile - Absolute path to the component source file
|
|
60
|
-
* @param componentInstanceId - Unique instance ID for DOM targeting
|
|
61
|
-
* @param props - Serialized props for client-side hydration
|
|
62
63
|
* @param config - Optional component config with `__eco` metadata
|
|
63
64
|
* @returns Processed assets ready for injection
|
|
64
65
|
*/
|
|
65
|
-
buildComponentRenderAssets(componentFile: string,
|
|
66
|
+
buildComponentRenderAssets(componentFile: string, config?: EcoComponentConfig): Promise<ProcessedAsset[]>;
|
|
66
67
|
/**
|
|
67
|
-
*
|
|
68
|
+
* Creates the Page Browser Graph dependency declarations for a React page.
|
|
68
69
|
*
|
|
69
70
|
* @param pagePath - Absolute file path of the page
|
|
70
71
|
* @param isMdx - Whether the page is an MDX file
|
|
71
72
|
* @param declaredModules - Explicitly declared browser module specifiers
|
|
72
|
-
* @returns
|
|
73
|
+
* @returns Declarative assets for core-owned processing
|
|
74
|
+
*/
|
|
75
|
+
createPageBrowserGraphDependencies(pagePath: string, isMdx: boolean, declaredModules: string[]): Promise<AssetDefinition[]>;
|
|
76
|
+
/**
|
|
77
|
+
* Builds the Page Browser Graph assets for a React page.
|
|
78
|
+
*
|
|
79
|
+
* @remarks
|
|
80
|
+
* Kept as a compatibility wrapper while callers migrate to core-owned page
|
|
81
|
+
* graph assembly.
|
|
73
82
|
*/
|
|
74
|
-
|
|
83
|
+
buildPageBrowserGraphAssets(pagePath: string, isMdx: boolean, declaredModules: string[]): Promise<ProcessedAsset[]>;
|
|
75
84
|
}
|