@module-federation/bridge-react 0.0.0-perf-devtools-20260108034446 → 0.0.0-perf-website-code-usage-20260914033703
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/dist/base.cjs.js +4 -4
- package/dist/base.d.ts +8 -311
- package/dist/base.es.js +11 -11
- package/dist/{bridge-base-CPSTBjEp.mjs → bridge-base-CHnL6Q9P.mjs} +63 -103
- package/dist/{bridge-base-RStDxH71.js → bridge-base-DSYKAGGD.js} +63 -102
- package/dist/{createHelpers-Ui5pt7je.mjs → createHelpers-D3Sg5lKp.mjs} +32 -17
- package/dist/{createHelpers-B_L612IN.js → createHelpers-D6thyyLv.js} +30 -15
- package/dist/data-fetch-server-middleware.cjs.js +4 -4
- package/dist/data-fetch-server-middleware.d.ts +1 -15
- package/dist/data-fetch-server-middleware.es.js +2 -2
- package/dist/data-fetch-utils.cjs.js +2 -2
- package/dist/data-fetch-utils.d.ts +1 -81
- package/dist/data-fetch-utils.es.js +7 -7
- package/dist/data-fetch.cjs.js +22 -0
- package/dist/data-fetch.d.ts +4 -0
- package/dist/data-fetch.es.js +22 -0
- package/dist/error-boundary.d.ts +17 -0
- package/dist/error-boundary.spec.d.ts +1 -0
- package/dist/{index-DyQNwY2M.mjs → index-Bs2NxD2z.mjs} +1 -1
- package/dist/{index-DRSBaSu3.js → index-DbjGCKOr.js} +2 -2
- package/dist/index.cjs.js +27 -6
- package/dist/index.d.ts +12 -299
- package/dist/index.es.js +34 -13
- package/dist/lazy/AwaitDataFetch.d.ts +24 -0
- package/dist/lazy/HydratedStylesheetAssets.d.ts +4 -0
- package/dist/lazy/constant.d.ts +26 -0
- package/dist/lazy/createLazyComponent.d.ts +28 -0
- package/dist/lazy/data-fetch/cache.d.ts +34 -0
- package/dist/lazy/data-fetch/cache.spec.d.ts +1 -0
- package/dist/lazy/data-fetch/call-data-fetch.d.ts +1 -0
- package/dist/lazy/data-fetch/data-fetch-server-middleware.d.ts +3 -0
- package/{src/lazy/data-fetch/index.ts → dist/lazy/data-fetch/index.d.ts} +1 -11
- package/dist/lazy/data-fetch/inject-data-fetch.d.ts +4 -0
- package/dist/lazy/data-fetch/prefetch.d.ts +9 -0
- package/dist/lazy/data-fetch/runtime-plugin.d.ts +3 -0
- package/dist/lazy/index.d.ts +9 -0
- package/dist/lazy/logger.d.ts +2 -0
- package/dist/lazy/types.d.ts +60 -0
- package/dist/lazy/utils.d.ts +48 -0
- package/dist/lazy/wrapNoSSR.d.ts +9 -0
- package/dist/{lazy-load-component-plugin-BvnyaA6i.js → lazy-load-component-plugin-DSURjnZ0.js} +170 -44
- package/dist/{lazy-load-component-plugin-CVcFMRce.mjs → lazy-load-component-plugin-NZphPG7_.mjs} +174 -48
- package/dist/lazy-load-component-plugin.cjs.js +2 -2
- package/dist/lazy-load-component-plugin.d.ts +2 -16
- package/dist/lazy-load-component-plugin.es.js +2 -2
- package/dist/lazy-utils.cjs.js +2 -2
- package/dist/lazy-utils.d.ts +1 -149
- package/dist/lazy-utils.es.js +19 -19
- package/dist/logger-DwWkXsWl.mjs +139 -0
- package/dist/logger-Dxblx6P-.js +138 -0
- package/dist/plugin.d.ts +2 -22
- package/dist/plugins/lazy-load-component-plugin.d.ts +12 -0
- package/dist/plugins/lazy-load-component-plugin.spec.d.ts +1 -0
- package/dist/prefetch-Bxf6DSx_.js +1477 -0
- package/dist/prefetch-TKq_EK_q.mjs +1478 -0
- package/dist/provider/context.d.ts +3 -0
- package/dist/provider/plugin.d.ts +7 -0
- package/dist/provider/versions/bridge-base.d.ts +5 -0
- package/dist/provider/versions/legacy.d.ts +26 -0
- package/dist/provider/versions/v18.d.ts +19 -0
- package/dist/provider/versions/v19.d.ts +21 -0
- package/dist/remote/RemoteAppWrapper.d.ts +7 -0
- package/dist/remote/base-component/create.d.ts +9 -0
- package/dist/remote/base-component/index.d.ts +5 -0
- package/dist/remote/createHelpers.d.ts +17 -0
- package/dist/remote/router-component/component.d.ts +8 -0
- package/dist/remote/router-component/create.d.ts +9 -0
- package/dist/remote/router-component/index.d.ts +5 -0
- package/dist/router/default.d.ts +7 -0
- package/dist/router/v5.d.ts +4 -0
- package/dist/router/v6.d.ts +7 -0
- package/dist/router/v7.d.ts +6 -0
- package/dist/router-v5.cjs.js +5 -3
- package/dist/router-v5.d.ts +1 -18
- package/dist/router-v5.es.js +5 -3
- package/dist/router-v6.cjs.js +1 -1
- package/dist/router-v6.d.ts +1 -20
- package/dist/router-v6.es.js +1 -1
- package/dist/router-v7.cjs.js +5 -3
- package/dist/router-v7.d.ts +1 -20
- package/dist/router-v7.es.js +5 -3
- package/dist/router.cjs.js +1 -1
- package/dist/router.d.ts +1 -20
- package/dist/router.es.js +1 -1
- package/dist/shared/size-limited-cache.d.ts +29 -0
- package/dist/shared/size-limited-cache.spec.d.ts +1 -0
- package/dist/size-limited-cache.cjs.js +82 -0
- package/dist/size-limited-cache.d.ts +1 -0
- package/dist/size-limited-cache.es.js +82 -0
- package/dist/types.d.ts +137 -0
- package/dist/utils/index.d.ts +4 -0
- package/dist/utils-5dGErM3C.js +588 -0
- package/dist/utils-BBP3hEeV.mjs +589 -0
- package/dist/v18.cjs.js +1 -1
- package/dist/v18.d.ts +3 -114
- package/dist/v18.es.js +1 -1
- package/dist/v19.cjs.js +1 -1
- package/dist/v19.d.ts +3 -115
- package/dist/v19.es.js +1 -1
- package/package.json +35 -14
- package/CHANGELOG.md +0 -735
- package/__tests__/bridge.spec.tsx +0 -160
- package/__tests__/createLazyComponent.spec.tsx +0 -209
- package/__tests__/prefetch.spec.ts +0 -156
- package/__tests__/router.spec.tsx +0 -82
- package/__tests__/setupTests.ts +0 -8
- package/__tests__/util.ts +0 -36
- package/dist/index.esm-BWaKho-8.js +0 -491
- package/dist/index.esm-CPwSeCvw.mjs +0 -492
- package/dist/prefetch-CK3EZdY4.mjs +0 -1273
- package/dist/prefetch-MiXeF8KH.js +0 -1272
- package/dist/utils-dUgb9Jkm.mjs +0 -2016
- package/dist/utils-tM9yE73c.js +0 -2015
- package/jest.config.ts +0 -21
- package/project.json +0 -23
- package/src/base.ts +0 -50
- package/src/index.ts +0 -50
- package/src/lazy/AwaitDataFetch.tsx +0 -215
- package/src/lazy/constant.ts +0 -30
- package/src/lazy/createLazyComponent.tsx +0 -411
- package/src/lazy/data-fetch/cache.ts +0 -291
- package/src/lazy/data-fetch/call-data-fetch.ts +0 -13
- package/src/lazy/data-fetch/data-fetch-server-middleware.ts +0 -196
- package/src/lazy/data-fetch/inject-data-fetch.ts +0 -109
- package/src/lazy/data-fetch/prefetch.ts +0 -112
- package/src/lazy/data-fetch/runtime-plugin.ts +0 -115
- package/src/lazy/index.ts +0 -35
- package/src/lazy/logger.ts +0 -6
- package/src/lazy/types.ts +0 -75
- package/src/lazy/utils.ts +0 -372
- package/src/lazy/wrapNoSSR.tsx +0 -10
- package/src/modern-app-env.d.ts +0 -2
- package/src/plugins/lazy-load-component-plugin.spec.ts +0 -21
- package/src/plugins/lazy-load-component-plugin.ts +0 -57
- package/src/provider/context.tsx +0 -4
- package/src/provider/plugin.ts +0 -22
- package/src/provider/versions/bridge-base.tsx +0 -150
- package/src/provider/versions/legacy.ts +0 -87
- package/src/provider/versions/v18.ts +0 -47
- package/src/provider/versions/v19.ts +0 -48
- package/src/remote/RemoteAppWrapper.tsx +0 -108
- package/src/remote/base-component/create.tsx +0 -23
- package/src/remote/base-component/index.tsx +0 -10
- package/src/remote/createHelpers.tsx +0 -130
- package/src/remote/router-component/component.tsx +0 -104
- package/src/remote/router-component/create.tsx +0 -23
- package/src/remote/router-component/index.tsx +0 -10
- package/src/router/default.tsx +0 -73
- package/src/router/v5.tsx +0 -43
- package/src/router/v6.tsx +0 -74
- package/src/router/v7.tsx +0 -75
- package/src/types.ts +0 -147
- package/src/utils/index.ts +0 -44
- package/src/v18.ts +0 -9
- package/src/v19.ts +0 -9
- package/tsconfig.json +0 -42
- package/tsconfig.node.json +0 -11
- package/tsconfig.spec.json +0 -26
- package/vite.config.ts +0 -112
- package/vitest.config.ts +0 -27
- /package/{src/remote/base-component/component.tsx → dist/remote/base-component/component.d.ts} +0 -0
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React__default from "react";
|
|
2
|
-
import { c as createLogger } from "./
|
|
2
|
+
import { c as createLogger } from "./logger-DwWkXsWl.mjs";
|
|
3
3
|
const RouterContext = React__default.createContext(null);
|
|
4
4
|
const LoggerInstance = createLogger(
|
|
5
5
|
"[ Module Federation Bridge React ]"
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
const React = require("react");
|
|
3
|
-
const
|
|
3
|
+
const logger = require("./logger-Dxblx6P-.js");
|
|
4
4
|
const RouterContext = React.createContext(null);
|
|
5
|
-
const LoggerInstance =
|
|
5
|
+
const LoggerInstance = logger.createLogger(
|
|
6
6
|
"[ Module Federation Bridge React ]"
|
|
7
7
|
);
|
|
8
8
|
function pathJoin(...args) {
|
package/dist/index.cjs.js
CHANGED
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
-
const createHelpers = require("./createHelpers-
|
|
4
|
-
const lazyLoadComponentPlugin = require("./lazy-load-component-plugin-
|
|
3
|
+
const createHelpers = require("./createHelpers-D6thyyLv.js");
|
|
4
|
+
const lazyLoadComponentPlugin = require("./lazy-load-component-plugin-DSURjnZ0.js");
|
|
5
|
+
const lazyUtils = require("./utils-5dGErM3C.js");
|
|
6
|
+
const dataFetchUtils = require("./data-fetch-utils.cjs.js");
|
|
5
7
|
const React = require("react");
|
|
6
8
|
const ReactRouterDOM = require("react-router-dom");
|
|
7
|
-
const index = require("./index-
|
|
8
|
-
const
|
|
9
|
-
const
|
|
10
|
-
const prefetch = require("./prefetch-MiXeF8KH.js");
|
|
9
|
+
const index = require("./index-DbjGCKOr.js");
|
|
10
|
+
const plugin = require("./plugin.cjs.js");
|
|
11
|
+
const prefetch = require("./prefetch-Bxf6DSx_.js");
|
|
11
12
|
function _interopNamespaceDefault(e2) {
|
|
12
13
|
const n = Object.create(null, { [Symbol.toStringTag]: { value: "Module" } });
|
|
13
14
|
if (e2) {
|
|
@@ -81,6 +82,7 @@ function withRouterData(WrappedComponent) {
|
|
|
81
82
|
const location = ReactRouterDOM__namespace.useLocation();
|
|
82
83
|
const [pathname, setPathname] = React.useState(location.pathname);
|
|
83
84
|
React.useEffect(() => {
|
|
85
|
+
var _a2;
|
|
84
86
|
if (pathname !== "" && pathname !== location.pathname) {
|
|
85
87
|
index.LoggerInstance.debug(
|
|
86
88
|
`createRemoteAppComponent dispatchPopstateEnv >>>`,
|
|
@@ -89,7 +91,26 @@ function withRouterData(WrappedComponent) {
|
|
|
89
91
|
pathname: location.pathname
|
|
90
92
|
}
|
|
91
93
|
);
|
|
94
|
+
const route = {
|
|
95
|
+
action: "host-to-remote",
|
|
96
|
+
mechanism: "popstate",
|
|
97
|
+
from: pathname,
|
|
98
|
+
to: location.pathname,
|
|
99
|
+
basename
|
|
100
|
+
};
|
|
101
|
+
const operationContext = {
|
|
102
|
+
side: "consumer",
|
|
103
|
+
framework: "react",
|
|
104
|
+
operation: "route-sync",
|
|
105
|
+
moduleName: props.moduleName,
|
|
106
|
+
route
|
|
107
|
+
};
|
|
92
108
|
e();
|
|
109
|
+
(_a2 = plugin.federationRuntime.instance) == null ? void 0 : _a2.bridgeHook.lifecycle.afterBridgeRouteSync.emit(
|
|
110
|
+
{
|
|
111
|
+
context: operationContext
|
|
112
|
+
}
|
|
113
|
+
);
|
|
93
114
|
}
|
|
94
115
|
setPathname(location.pathname);
|
|
95
116
|
}, [location]);
|
package/dist/index.d.ts
CHANGED
|
@@ -1,299 +1,12 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
export
|
|
10
|
-
|
|
11
|
-
export
|
|
12
|
-
|
|
13
|
-
declare interface CacheConfig {
|
|
14
|
-
maxSize?: number;
|
|
15
|
-
unstable_shouldDisable?: ({ request, }: {
|
|
16
|
-
request: Request;
|
|
17
|
-
}) => boolean | Promise<boolean>;
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
declare interface CacheOptions {
|
|
21
|
-
tag?: string | string[];
|
|
22
|
-
maxAge?: number;
|
|
23
|
-
revalidate?: number;
|
|
24
|
-
getKey?: <Args extends any[]>(...args: Args) => string;
|
|
25
|
-
onCache?: (info: CacheStatsInfo) => boolean;
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
export declare const CacheSize: {
|
|
29
|
-
readonly KB: 1024;
|
|
30
|
-
readonly MB: number;
|
|
31
|
-
readonly GB: number;
|
|
32
|
-
};
|
|
33
|
-
|
|
34
|
-
export declare interface CacheStatsInfo {
|
|
35
|
-
status: CacheStatus;
|
|
36
|
-
key: string | symbol;
|
|
37
|
-
params: DataFetchParams;
|
|
38
|
-
result: any;
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
export declare type CacheStatus = 'hit' | 'stale' | 'miss';
|
|
42
|
-
|
|
43
|
-
export declare const CacheTime: {
|
|
44
|
-
readonly SECOND: 1000;
|
|
45
|
-
readonly MINUTE: number;
|
|
46
|
-
readonly HOUR: number;
|
|
47
|
-
readonly DAY: number;
|
|
48
|
-
readonly WEEK: number;
|
|
49
|
-
readonly MONTH: number;
|
|
50
|
-
};
|
|
51
|
-
|
|
52
|
-
export declare function callDataFetch(): Promise<void>;
|
|
53
|
-
|
|
54
|
-
export declare function clearStore(): void;
|
|
55
|
-
|
|
56
|
-
export declare function collectSSRAssets(options: CollectSSRAssetsOptions): default_2.ReactNode[];
|
|
57
|
-
|
|
58
|
-
export declare type CollectSSRAssetsOptions = {
|
|
59
|
-
id: string;
|
|
60
|
-
instance: ReturnType<typeof getInstance>;
|
|
61
|
-
injectScript?: boolean;
|
|
62
|
-
injectLink?: boolean;
|
|
63
|
-
};
|
|
64
|
-
|
|
65
|
-
export declare function configureCache(config: CacheConfig): void;
|
|
66
|
-
|
|
67
|
-
export declare function createBridgeComponent<T = any>(bridgeInfo: Omit<ProviderFnParams<T>, 'createRoot'>): () => {
|
|
68
|
-
render(info: RenderParams): Promise<void>;
|
|
69
|
-
destroy(info: DestroyParams): void;
|
|
70
|
-
};
|
|
71
|
-
|
|
72
|
-
export declare function createLazyComponent<T, E extends keyof T>(options: CreateLazyComponentOptions<T, E>): (props: T[E] extends (...args: any) => any ? Parameters<T[E]>[0] extends undefined ? ReactKey : Parameters<T[E]>[0] & ReactKey : ReactKey) => default_2.JSX.Element;
|
|
73
|
-
|
|
74
|
-
export declare type CreateLazyComponentOptions<T, E extends keyof T> = {
|
|
75
|
-
loader: () => Promise<T>;
|
|
76
|
-
instance: ReturnType<typeof getInstance>;
|
|
77
|
-
loading: default_2.ReactNode;
|
|
78
|
-
delayLoading?: number;
|
|
79
|
-
fallback: ReactNode | ((errorInfo: ErrorInfo) => ReactNode);
|
|
80
|
-
export?: E;
|
|
81
|
-
dataFetchParams?: DataFetchParams;
|
|
82
|
-
noSSR?: boolean;
|
|
83
|
-
injectScript?: boolean;
|
|
84
|
-
injectLink?: boolean;
|
|
85
|
-
};
|
|
86
|
-
|
|
87
|
-
export declare const createRemoteAppComponent: <T = Record<string, unknown>, E extends keyof T = keyof T>(info: LazyRemoteComponentInfo<T, E>) => ForwardRefExoticComponent<Omit<RemoteComponentProps<Record<string, unknown>>, "ref"> & RefAttributes<HTMLDivElement>>;
|
|
88
|
-
|
|
89
|
-
/**
|
|
90
|
-
* @deprecated createRemoteComponent is deprecated, please use createRemoteAppComponent instead!
|
|
91
|
-
*/
|
|
92
|
-
export declare const createRemoteComponent: <T = Record<string, unknown>, E extends keyof T = keyof T>(info: LazyRemoteComponentInfo<T, E>) => any;
|
|
93
|
-
|
|
94
|
-
export declare interface CreateRootOptions {
|
|
95
|
-
identifierPrefix?: string;
|
|
96
|
-
onRecoverableError?: (error: unknown, errorInfo: unknown) => void;
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
/**
|
|
100
|
-
* Options for creating a React root
|
|
101
|
-
*/
|
|
102
|
-
declare interface CreateRootOptions_2 {
|
|
103
|
-
identifierPrefix?: string;
|
|
104
|
-
onRecoverableError?: (error: unknown) => void;
|
|
105
|
-
transitionCallbacks?: unknown;
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
declare type DataFetch<T> = (params: DataFetchParams) => Promise<T>;
|
|
109
|
-
|
|
110
|
-
export declare type DataFetchParams = {
|
|
111
|
-
isDowngrade: boolean;
|
|
112
|
-
_id?: string;
|
|
113
|
-
} & Record<string, unknown>;
|
|
114
|
-
|
|
115
|
-
/**
|
|
116
|
-
* Parameters for the destroy function
|
|
117
|
-
*/
|
|
118
|
-
export declare interface DestroyParams {
|
|
119
|
-
moduleName: string;
|
|
120
|
-
dom: HTMLElement;
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
export declare const ERROR_TYPE: {
|
|
124
|
-
DATA_FETCH: number;
|
|
125
|
-
LOAD_REMOTE: number;
|
|
126
|
-
UNKNOWN: number;
|
|
127
|
-
};
|
|
128
|
-
|
|
129
|
-
declare type ErrorInfo = {
|
|
130
|
-
error: Error;
|
|
131
|
-
errorType: number;
|
|
132
|
-
dataFetchMapKey?: string;
|
|
133
|
-
};
|
|
134
|
-
|
|
135
|
-
export declare function generateKey(dataFetchOptions: DataFetchParams): string;
|
|
136
|
-
|
|
137
|
-
export declare function lazyLoadComponentPlugin(): ModuleFederationRuntimePlugin;
|
|
138
|
-
|
|
139
|
-
export declare type LazyRemoteComponentInfo<T, _E extends keyof T> = RemoteComponentParams<T>;
|
|
140
|
-
|
|
141
|
-
export declare type NoSSRRemoteInfo = {
|
|
142
|
-
name: string;
|
|
143
|
-
version: string;
|
|
144
|
-
ssrPublicPath: string;
|
|
145
|
-
ssrRemoteEntry: string;
|
|
146
|
-
globalName: string;
|
|
147
|
-
};
|
|
148
|
-
|
|
149
|
-
export declare function prefetch(options: PrefetchOptions): Promise<void>;
|
|
150
|
-
|
|
151
|
-
declare type PrefetchOptions = {
|
|
152
|
-
id: string;
|
|
153
|
-
instance: ReturnType<typeof getInstance>;
|
|
154
|
-
dataFetchParams?: DataFetchParams;
|
|
155
|
-
preloadComponentResource?: boolean;
|
|
156
|
-
};
|
|
157
|
-
|
|
158
|
-
/**
|
|
159
|
-
* Parameters for the provider function
|
|
160
|
-
*/
|
|
161
|
-
export declare interface ProviderFnParams<T> {
|
|
162
|
-
rootComponent: React_2.ComponentType<T>;
|
|
163
|
-
render?: (App: React_2.ReactElement, id?: HTMLElement | string) => RootType | Promise<RootType>;
|
|
164
|
-
createRoot?: (container: Element | DocumentFragment, options?: CreateRootOptions_2) => Root_2;
|
|
165
|
-
/**
|
|
166
|
-
* Default options to pass to createRoot for React 18 and 19
|
|
167
|
-
* These options will be used when creating a root unless overridden by rootOptions in render params
|
|
168
|
-
* @example
|
|
169
|
-
* {
|
|
170
|
-
* identifierPrefix: 'app-',
|
|
171
|
-
* onRecoverableError: (err) => console.error(err)
|
|
172
|
-
* }
|
|
173
|
-
*/
|
|
174
|
-
defaultRootOptions?: CreateRootOptions_2;
|
|
175
|
-
}
|
|
176
|
-
|
|
177
|
-
/**
|
|
178
|
-
* Parameters for the provider function
|
|
179
|
-
*/
|
|
180
|
-
export declare interface ProviderParams {
|
|
181
|
-
moduleName?: string;
|
|
182
|
-
basename?: string;
|
|
183
|
-
memoryRoute?: {
|
|
184
|
-
entryPath: string;
|
|
185
|
-
initialState?: Record<string, unknown>;
|
|
186
|
-
};
|
|
187
|
-
style?: React_2.CSSProperties;
|
|
188
|
-
className?: string;
|
|
189
|
-
}
|
|
190
|
-
|
|
191
|
-
declare type ReactKey = {
|
|
192
|
-
key?: default_2.Key | null;
|
|
193
|
-
};
|
|
194
|
-
|
|
195
|
-
/**
|
|
196
|
-
* Parameters for the remote component loader
|
|
197
|
-
*/
|
|
198
|
-
export declare interface RemoteComponentParams<T = Record<string, unknown>, E extends keyof T = keyof T> {
|
|
199
|
-
loader: () => Promise<T>;
|
|
200
|
-
loading: React_2.ReactNode;
|
|
201
|
-
fallback: React_2.ComponentType<{
|
|
202
|
-
error: Error;
|
|
203
|
-
}>;
|
|
204
|
-
export?: E;
|
|
205
|
-
props?: T;
|
|
206
|
-
}
|
|
207
|
-
|
|
208
|
-
/**
|
|
209
|
-
* Parameters for the remote component
|
|
210
|
-
*/
|
|
211
|
-
export declare interface RemoteComponentProps<T = Record<string, unknown>> {
|
|
212
|
-
props?: T;
|
|
213
|
-
fallback?: React_2.ComponentType<{
|
|
214
|
-
error: Error;
|
|
215
|
-
}>;
|
|
216
|
-
loading?: React_2.ReactNode;
|
|
217
|
-
[key: string]: unknown;
|
|
218
|
-
}
|
|
219
|
-
|
|
220
|
-
/**
|
|
221
|
-
* Interface for a remote module provider
|
|
222
|
-
*/
|
|
223
|
-
export declare interface RemoteModule {
|
|
224
|
-
provider: () => {
|
|
225
|
-
render: (info: RenderFnParams) => void;
|
|
226
|
-
destroy: (info: {
|
|
227
|
-
dom: any;
|
|
228
|
-
}) => void;
|
|
229
|
-
};
|
|
230
|
-
}
|
|
231
|
-
|
|
232
|
-
/**
|
|
233
|
-
* Parameters for the render function, extending ProviderParams
|
|
234
|
-
*/
|
|
235
|
-
export declare interface RenderFnParams extends ProviderParams {
|
|
236
|
-
dom: HTMLElement;
|
|
237
|
-
fallback?: React_2.ComponentType<{
|
|
238
|
-
error: Error;
|
|
239
|
-
}>;
|
|
240
|
-
[key: string]: unknown;
|
|
241
|
-
}
|
|
242
|
-
|
|
243
|
-
/**
|
|
244
|
-
* Parameters for the render function
|
|
245
|
-
*/
|
|
246
|
-
export declare interface RenderParams {
|
|
247
|
-
moduleName?: string;
|
|
248
|
-
basename?: string;
|
|
249
|
-
memoryRoute?: {
|
|
250
|
-
entryPath: string;
|
|
251
|
-
initialState?: Record<string, unknown>;
|
|
252
|
-
};
|
|
253
|
-
dom: HTMLElement;
|
|
254
|
-
/**
|
|
255
|
-
* Options to pass to createRoot for React 18 and 19
|
|
256
|
-
* @example
|
|
257
|
-
* {
|
|
258
|
-
* identifierPrefix: 'app-',
|
|
259
|
-
* onRecoverableError: (err) => console.error(err)
|
|
260
|
-
* }
|
|
261
|
-
*/
|
|
262
|
-
rootOptions?: CreateRootOptions_2;
|
|
263
|
-
[key: string]: unknown;
|
|
264
|
-
}
|
|
265
|
-
|
|
266
|
-
export declare function revalidateTag(tag: string): void;
|
|
267
|
-
|
|
268
|
-
export declare interface Root {
|
|
269
|
-
render(children: React.ReactNode): void;
|
|
270
|
-
unmount(): void;
|
|
271
|
-
}
|
|
272
|
-
|
|
273
|
-
/**
|
|
274
|
-
* Interface for a React root object
|
|
275
|
-
*/
|
|
276
|
-
declare interface Root_2 {
|
|
277
|
-
render(children: React_2.ReactNode): void;
|
|
278
|
-
unmount(): void;
|
|
279
|
-
}
|
|
280
|
-
|
|
281
|
-
/**
|
|
282
|
-
* Type for a root element, which can be either an HTMLElement or a React root
|
|
283
|
-
*/
|
|
284
|
-
export declare type RootType = HTMLElement | Root_2;
|
|
285
|
-
|
|
286
|
-
export declare function setSSREnv({ fetchServerQuery, }: {
|
|
287
|
-
fetchServerQuery?: Record<string, unknown>;
|
|
288
|
-
}): void;
|
|
289
|
-
|
|
290
|
-
export { }
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
declare module '@module-federation/runtime-core' {
|
|
294
|
-
interface ModuleFederation {
|
|
295
|
-
createLazyComponent<T, E extends keyof T>(options: Omit<CreateLazyComponentOptions<T, E>, 'instance'>): ReturnType<typeof createLazyComponent<T, E>>;
|
|
296
|
-
prefetch(options: Omit<PrefetchOptions, 'instance'>): ReturnType<typeof prefetch>;
|
|
297
|
-
collectSSRAssets(options: Omit<Parameters<typeof collectSSRAssets>[0], 'instance'>): ReturnType<typeof collectSSRAssets>;
|
|
298
|
-
}
|
|
299
|
-
}
|
|
1
|
+
/**
|
|
2
|
+
* Entry point for React 16/17 (legacy) specific bridge components
|
|
3
|
+
* This file provides support for React 16 and 17 versions, using the traditional ReactDOM.render API
|
|
4
|
+
*/
|
|
5
|
+
export { createBridgeComponent } from './provider/versions/legacy';
|
|
6
|
+
export { createRemoteComponent, createRemoteAppComponent, } from './remote/router-component';
|
|
7
|
+
export type { LazyRemoteComponentInfo } from './remote/router-component';
|
|
8
|
+
export { ERROR_TYPE, createLazyComponent, collectSSRAssets, callDataFetch, setSSREnv, autoFetchDataPlugin, CacheSize, CacheTime, configureCache, generateKey, cache, revalidateTag, clearStore, prefetch, } from './lazy';
|
|
9
|
+
export { lazyLoadComponentPlugin } from './plugins/lazy-load-component-plugin';
|
|
10
|
+
export type { CreateRootOptions, Root } from './provider/versions/legacy';
|
|
11
|
+
export type { ProviderParams, ProviderFnParams, RootType, DestroyParams, RenderParams, RemoteComponentParams, RenderFnParams, RemoteComponentProps, RemoteModule, } from './types';
|
|
12
|
+
export type { DataFetchParams, NoSSRRemoteInfo, CollectSSRAssetsOptions, CreateLazyComponentOptions, CacheStatus, CacheStatsInfo, } from './lazy';
|
package/dist/index.es.js
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
|
-
import { R as RemoteAppWrapper, c as
|
|
2
|
-
import { b } from "./createHelpers-
|
|
3
|
-
import { b as b2,
|
|
1
|
+
import { R as RemoteAppWrapper, c as createRemoteAppComponentFactory, a as createDeprecatedRemoteComponentFactory } from "./createHelpers-D3Sg5lKp.mjs";
|
|
2
|
+
import { b } from "./createHelpers-D3Sg5lKp.mjs";
|
|
3
|
+
import { a, c, b as b2, l } from "./lazy-load-component-plugin-NZphPG7_.mjs";
|
|
4
|
+
import { C, a as a2, E, c as c2, b as b3, d, g, r, s } from "./utils-BBP3hEeV.mjs";
|
|
5
|
+
import { callDataFetch } from "./data-fetch-utils.es.js";
|
|
4
6
|
import React__default, { forwardRef, useContext, useState, useEffect } from "react";
|
|
5
7
|
import * as ReactRouterDOM from "react-router-dom";
|
|
6
|
-
import { p as pathJoin, L as LoggerInstance } from "./index-
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import { p } from "./prefetch-CK3EZdY4.mjs";
|
|
8
|
+
import { p as pathJoin, L as LoggerInstance } from "./index-Bs2NxD2z.mjs";
|
|
9
|
+
import { federationRuntime } from "./plugin.es.js";
|
|
10
|
+
import { p } from "./prefetch-TKq_EK_q.mjs";
|
|
10
11
|
function e() {
|
|
11
12
|
const t = new PopStateEvent("popstate", { state: window.history.state });
|
|
12
13
|
window.dispatchEvent(t);
|
|
@@ -63,6 +64,7 @@ function withRouterData(WrappedComponent) {
|
|
|
63
64
|
const location = ReactRouterDOM.useLocation();
|
|
64
65
|
const [pathname, setPathname] = useState(location.pathname);
|
|
65
66
|
useEffect(() => {
|
|
67
|
+
var _a2;
|
|
66
68
|
if (pathname !== "" && pathname !== location.pathname) {
|
|
67
69
|
LoggerInstance.debug(
|
|
68
70
|
`createRemoteAppComponent dispatchPopstateEnv >>>`,
|
|
@@ -71,7 +73,26 @@ function withRouterData(WrappedComponent) {
|
|
|
71
73
|
pathname: location.pathname
|
|
72
74
|
}
|
|
73
75
|
);
|
|
76
|
+
const route = {
|
|
77
|
+
action: "host-to-remote",
|
|
78
|
+
mechanism: "popstate",
|
|
79
|
+
from: pathname,
|
|
80
|
+
to: location.pathname,
|
|
81
|
+
basename
|
|
82
|
+
};
|
|
83
|
+
const operationContext = {
|
|
84
|
+
side: "consumer",
|
|
85
|
+
framework: "react",
|
|
86
|
+
operation: "route-sync",
|
|
87
|
+
moduleName: props.moduleName,
|
|
88
|
+
route
|
|
89
|
+
};
|
|
74
90
|
e();
|
|
91
|
+
(_a2 = federationRuntime.instance) == null ? void 0 : _a2.bridgeHook.lifecycle.afterBridgeRouteSync.emit(
|
|
92
|
+
{
|
|
93
|
+
context: operationContext
|
|
94
|
+
}
|
|
95
|
+
);
|
|
75
96
|
}
|
|
76
97
|
setPathname(location.pathname);
|
|
77
98
|
}, [location]);
|
|
@@ -91,14 +112,14 @@ export {
|
|
|
91
112
|
C as CacheSize,
|
|
92
113
|
a2 as CacheTime,
|
|
93
114
|
E as ERROR_TYPE,
|
|
94
|
-
|
|
95
|
-
|
|
115
|
+
a as autoFetchDataPlugin,
|
|
116
|
+
c2 as cache,
|
|
96
117
|
callDataFetch,
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
118
|
+
b3 as clearStore,
|
|
119
|
+
c as collectSSRAssets,
|
|
120
|
+
d as configureCache,
|
|
100
121
|
b as createBridgeComponent,
|
|
101
|
-
|
|
122
|
+
b2 as createLazyComponent,
|
|
102
123
|
createRemoteAppComponent,
|
|
103
124
|
createRemoteComponent,
|
|
104
125
|
g as generateKey,
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import React, { ReactNode } from 'react';
|
|
2
|
+
import type { DataFetchParams } from './types';
|
|
3
|
+
export type ErrorInfo = {
|
|
4
|
+
error: Error;
|
|
5
|
+
errorType: number;
|
|
6
|
+
dataFetchMapKey?: string;
|
|
7
|
+
};
|
|
8
|
+
export declare const transformError: (err: string | Error) => ErrorInfo;
|
|
9
|
+
export interface AwaitProps<T> {
|
|
10
|
+
resolve: T | Promise<T>;
|
|
11
|
+
loading?: ReactNode;
|
|
12
|
+
delayLoading?: number;
|
|
13
|
+
errorElement?: ReactNode | ((errorInfo: ErrorInfo) => ReactNode);
|
|
14
|
+
children: (data: T) => ReactNode;
|
|
15
|
+
params?: DataFetchParams;
|
|
16
|
+
}
|
|
17
|
+
export interface AwaitErrorHandlerProps<T = any> extends Omit<AwaitProps<T>, 'resolve'> {
|
|
18
|
+
resolve: () => T | string;
|
|
19
|
+
}
|
|
20
|
+
export declare function AwaitDataFetch<T>({ resolve, loading, errorElement, children, params, delayLoading, }: AwaitProps<T>): React.JSX.Element;
|
|
21
|
+
export declare const DelayedLoading: ({ delayLoading, children, }: {
|
|
22
|
+
delayLoading?: number;
|
|
23
|
+
children: ReactNode;
|
|
24
|
+
}) => ReactNode;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
export declare const PLUGIN_IDENTIFIER = "[ Module Federation React ]";
|
|
2
|
+
export declare const DOWNGRADE_KEY = "_mfSSRDowngrade";
|
|
3
|
+
export declare const DATA_FETCH_MAP_KEY = "__MF_DATA_FETCH_MAP__";
|
|
4
|
+
export declare const DATA_FETCH_FUNCTION = "_mfDataFetch";
|
|
5
|
+
export declare const FS_HREF = "_mfFSHref";
|
|
6
|
+
export declare const ERROR_TYPE: {
|
|
7
|
+
DATA_FETCH: number;
|
|
8
|
+
LOAD_REMOTE: number;
|
|
9
|
+
UNKNOWN: number;
|
|
10
|
+
};
|
|
11
|
+
export declare const WRAP_DATA_FETCH_ID_IDENTIFIER = "wrap_dfip_identifier";
|
|
12
|
+
export declare const enum MF_DATA_FETCH_TYPE {
|
|
13
|
+
FETCH_SERVER = 1,
|
|
14
|
+
FETCH_CLIENT = 2
|
|
15
|
+
}
|
|
16
|
+
export declare const enum MF_DATA_FETCH_STATUS {
|
|
17
|
+
LOADED = 1,
|
|
18
|
+
LOADING = 2,
|
|
19
|
+
AWAIT = 0,
|
|
20
|
+
ERROR = 3
|
|
21
|
+
}
|
|
22
|
+
export declare const DATA_FETCH_IDENTIFIER = "data";
|
|
23
|
+
export declare const DATA_FETCH_CLIENT_SUFFIX = ".client";
|
|
24
|
+
export declare const DATA_FETCH_QUERY = "x-mf-data-fetch";
|
|
25
|
+
export declare const DATA_FETCH_ERROR_PREFIX = "caught the following error during dataFetch: ";
|
|
26
|
+
export declare const LOAD_REMOTE_ERROR_PREFIX = "caught the following error during loadRemote: ";
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import type { getInstance } from '@module-federation/runtime';
|
|
2
|
+
import React, { ReactNode } from 'react';
|
|
3
|
+
import type { ErrorInfo } from './AwaitDataFetch';
|
|
4
|
+
import type { DataFetchParams } from './types';
|
|
5
|
+
export type IProps = {
|
|
6
|
+
id: string;
|
|
7
|
+
instance: ReturnType<typeof getInstance>;
|
|
8
|
+
injectScript?: boolean;
|
|
9
|
+
injectLink?: boolean;
|
|
10
|
+
};
|
|
11
|
+
export type CreateLazyComponentOptions<T, E extends keyof T> = {
|
|
12
|
+
loader: () => Promise<T>;
|
|
13
|
+
instance: ReturnType<typeof getInstance>;
|
|
14
|
+
loading: React.ReactNode;
|
|
15
|
+
delayLoading?: number;
|
|
16
|
+
fallback: ReactNode | ((errorInfo: ErrorInfo) => ReactNode);
|
|
17
|
+
export?: E;
|
|
18
|
+
dataFetchParams?: DataFetchParams;
|
|
19
|
+
noSSR?: boolean;
|
|
20
|
+
injectScript?: boolean;
|
|
21
|
+
injectLink?: boolean;
|
|
22
|
+
};
|
|
23
|
+
type ReactKey = {
|
|
24
|
+
key?: React.Key | null;
|
|
25
|
+
};
|
|
26
|
+
export declare function collectSSRAssets(options: IProps): React.ReactNode[];
|
|
27
|
+
export declare function createLazyComponent<T, E extends keyof T>(options: CreateLazyComponentOptions<T, E>): (props: T[E] extends (...args: any) => any ? Parameters<T[E]>[0] extends undefined ? ReactKey : Parameters<T[E]>[0] & ReactKey : ReactKey) => React.JSX.Element;
|
|
28
|
+
export {};
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import type { CacheConfig, DataFetch, DataFetchParams } from '../types';
|
|
2
|
+
export declare const CacheSize: {
|
|
3
|
+
readonly KB: 1024;
|
|
4
|
+
readonly MB: number;
|
|
5
|
+
readonly GB: number;
|
|
6
|
+
};
|
|
7
|
+
export declare const CacheTime: {
|
|
8
|
+
readonly SECOND: 1000;
|
|
9
|
+
readonly MINUTE: number;
|
|
10
|
+
readonly HOUR: number;
|
|
11
|
+
readonly DAY: number;
|
|
12
|
+
readonly WEEK: number;
|
|
13
|
+
readonly MONTH: number;
|
|
14
|
+
};
|
|
15
|
+
export type CacheStatus = 'hit' | 'stale' | 'miss';
|
|
16
|
+
export interface CacheStatsInfo {
|
|
17
|
+
status: CacheStatus;
|
|
18
|
+
key: string | symbol;
|
|
19
|
+
params: DataFetchParams;
|
|
20
|
+
result: any;
|
|
21
|
+
}
|
|
22
|
+
interface CacheOptions {
|
|
23
|
+
tag?: string | string[];
|
|
24
|
+
maxAge?: number;
|
|
25
|
+
revalidate?: number;
|
|
26
|
+
getKey?: <Args extends any[]>(...args: Args) => string;
|
|
27
|
+
onCache?: (info: CacheStatsInfo) => boolean;
|
|
28
|
+
}
|
|
29
|
+
export declare function configureCache(config: CacheConfig): void;
|
|
30
|
+
export declare function generateKey(dataFetchOptions: DataFetchParams): string;
|
|
31
|
+
export declare function cache<T>(fn: DataFetch<T>, options?: CacheOptions): DataFetch<T>;
|
|
32
|
+
export declare function revalidateTag(tag: string): void;
|
|
33
|
+
export declare function clearStore(): void;
|
|
34
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function callDataFetch(): Promise<void>;
|
|
@@ -1,16 +1,6 @@
|
|
|
1
1
|
export { callDataFetch } from './call-data-fetch';
|
|
2
2
|
export { injectDataFetch } from './inject-data-fetch';
|
|
3
|
-
export {
|
|
4
|
-
CacheSize,
|
|
5
|
-
CacheTime,
|
|
6
|
-
configureCache,
|
|
7
|
-
generateKey,
|
|
8
|
-
cache,
|
|
9
|
-
revalidateTag,
|
|
10
|
-
clearStore,
|
|
11
|
-
} from './cache';
|
|
12
|
-
|
|
3
|
+
export { CacheSize, CacheTime, configureCache, generateKey, cache, revalidateTag, clearStore, } from './cache';
|
|
13
4
|
export type { CacheStatus, CacheStatsInfo } from './cache';
|
|
14
|
-
|
|
15
5
|
export type { PrefetchOptions } from './prefetch';
|
|
16
6
|
export { prefetch } from './prefetch';
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { getInstance } from '@module-federation/runtime';
|
|
2
|
+
import { DataFetchParams } from '../types';
|
|
3
|
+
export type PrefetchOptions = {
|
|
4
|
+
id: string;
|
|
5
|
+
instance: ReturnType<typeof getInstance>;
|
|
6
|
+
dataFetchParams?: DataFetchParams;
|
|
7
|
+
preloadComponentResource?: boolean;
|
|
8
|
+
};
|
|
9
|
+
export declare function prefetch(options: PrefetchOptions): Promise<void>;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import autoFetchDataPlugin from './data-fetch/runtime-plugin';
|
|
2
|
+
export { ERROR_TYPE } from './constant';
|
|
3
|
+
export type { DataFetchParams, NoSSRRemoteInfo } from './types';
|
|
4
|
+
export type { CreateLazyComponentOptions, IProps as CollectSSRAssetsOptions, } from './createLazyComponent';
|
|
5
|
+
export { createLazyComponent, collectSSRAssets } from './createLazyComponent';
|
|
6
|
+
export { injectDataFetch, callDataFetch, CacheSize, CacheTime, configureCache, generateKey, cache, revalidateTag, clearStore, prefetch, } from './data-fetch';
|
|
7
|
+
export { setSSREnv } from './utils';
|
|
8
|
+
export { autoFetchDataPlugin };
|
|
9
|
+
export type { CacheStatus, CacheStatsInfo, PrefetchOptions, } from './data-fetch';
|