@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.
Files changed (161) hide show
  1. package/dist/base.cjs.js +4 -4
  2. package/dist/base.d.ts +8 -311
  3. package/dist/base.es.js +11 -11
  4. package/dist/{bridge-base-CPSTBjEp.mjs → bridge-base-CHnL6Q9P.mjs} +63 -103
  5. package/dist/{bridge-base-RStDxH71.js → bridge-base-DSYKAGGD.js} +63 -102
  6. package/dist/{createHelpers-Ui5pt7je.mjs → createHelpers-D3Sg5lKp.mjs} +32 -17
  7. package/dist/{createHelpers-B_L612IN.js → createHelpers-D6thyyLv.js} +30 -15
  8. package/dist/data-fetch-server-middleware.cjs.js +4 -4
  9. package/dist/data-fetch-server-middleware.d.ts +1 -15
  10. package/dist/data-fetch-server-middleware.es.js +2 -2
  11. package/dist/data-fetch-utils.cjs.js +2 -2
  12. package/dist/data-fetch-utils.d.ts +1 -81
  13. package/dist/data-fetch-utils.es.js +7 -7
  14. package/dist/data-fetch.cjs.js +22 -0
  15. package/dist/data-fetch.d.ts +4 -0
  16. package/dist/data-fetch.es.js +22 -0
  17. package/dist/error-boundary.d.ts +17 -0
  18. package/dist/error-boundary.spec.d.ts +1 -0
  19. package/dist/{index-DyQNwY2M.mjs → index-Bs2NxD2z.mjs} +1 -1
  20. package/dist/{index-DRSBaSu3.js → index-DbjGCKOr.js} +2 -2
  21. package/dist/index.cjs.js +27 -6
  22. package/dist/index.d.ts +12 -299
  23. package/dist/index.es.js +34 -13
  24. package/dist/lazy/AwaitDataFetch.d.ts +24 -0
  25. package/dist/lazy/HydratedStylesheetAssets.d.ts +4 -0
  26. package/dist/lazy/constant.d.ts +26 -0
  27. package/dist/lazy/createLazyComponent.d.ts +28 -0
  28. package/dist/lazy/data-fetch/cache.d.ts +34 -0
  29. package/dist/lazy/data-fetch/cache.spec.d.ts +1 -0
  30. package/dist/lazy/data-fetch/call-data-fetch.d.ts +1 -0
  31. package/dist/lazy/data-fetch/data-fetch-server-middleware.d.ts +3 -0
  32. package/{src/lazy/data-fetch/index.ts → dist/lazy/data-fetch/index.d.ts} +1 -11
  33. package/dist/lazy/data-fetch/inject-data-fetch.d.ts +4 -0
  34. package/dist/lazy/data-fetch/prefetch.d.ts +9 -0
  35. package/dist/lazy/data-fetch/runtime-plugin.d.ts +3 -0
  36. package/dist/lazy/index.d.ts +9 -0
  37. package/dist/lazy/logger.d.ts +2 -0
  38. package/dist/lazy/types.d.ts +60 -0
  39. package/dist/lazy/utils.d.ts +48 -0
  40. package/dist/lazy/wrapNoSSR.d.ts +9 -0
  41. package/dist/{lazy-load-component-plugin-BvnyaA6i.js → lazy-load-component-plugin-DSURjnZ0.js} +170 -44
  42. package/dist/{lazy-load-component-plugin-CVcFMRce.mjs → lazy-load-component-plugin-NZphPG7_.mjs} +174 -48
  43. package/dist/lazy-load-component-plugin.cjs.js +2 -2
  44. package/dist/lazy-load-component-plugin.d.ts +2 -16
  45. package/dist/lazy-load-component-plugin.es.js +2 -2
  46. package/dist/lazy-utils.cjs.js +2 -2
  47. package/dist/lazy-utils.d.ts +1 -149
  48. package/dist/lazy-utils.es.js +19 -19
  49. package/dist/logger-DwWkXsWl.mjs +139 -0
  50. package/dist/logger-Dxblx6P-.js +138 -0
  51. package/dist/plugin.d.ts +2 -22
  52. package/dist/plugins/lazy-load-component-plugin.d.ts +12 -0
  53. package/dist/plugins/lazy-load-component-plugin.spec.d.ts +1 -0
  54. package/dist/prefetch-Bxf6DSx_.js +1477 -0
  55. package/dist/prefetch-TKq_EK_q.mjs +1478 -0
  56. package/dist/provider/context.d.ts +3 -0
  57. package/dist/provider/plugin.d.ts +7 -0
  58. package/dist/provider/versions/bridge-base.d.ts +5 -0
  59. package/dist/provider/versions/legacy.d.ts +26 -0
  60. package/dist/provider/versions/v18.d.ts +19 -0
  61. package/dist/provider/versions/v19.d.ts +21 -0
  62. package/dist/remote/RemoteAppWrapper.d.ts +7 -0
  63. package/dist/remote/base-component/create.d.ts +9 -0
  64. package/dist/remote/base-component/index.d.ts +5 -0
  65. package/dist/remote/createHelpers.d.ts +17 -0
  66. package/dist/remote/router-component/component.d.ts +8 -0
  67. package/dist/remote/router-component/create.d.ts +9 -0
  68. package/dist/remote/router-component/index.d.ts +5 -0
  69. package/dist/router/default.d.ts +7 -0
  70. package/dist/router/v5.d.ts +4 -0
  71. package/dist/router/v6.d.ts +7 -0
  72. package/dist/router/v7.d.ts +6 -0
  73. package/dist/router-v5.cjs.js +5 -3
  74. package/dist/router-v5.d.ts +1 -18
  75. package/dist/router-v5.es.js +5 -3
  76. package/dist/router-v6.cjs.js +1 -1
  77. package/dist/router-v6.d.ts +1 -20
  78. package/dist/router-v6.es.js +1 -1
  79. package/dist/router-v7.cjs.js +5 -3
  80. package/dist/router-v7.d.ts +1 -20
  81. package/dist/router-v7.es.js +5 -3
  82. package/dist/router.cjs.js +1 -1
  83. package/dist/router.d.ts +1 -20
  84. package/dist/router.es.js +1 -1
  85. package/dist/shared/size-limited-cache.d.ts +29 -0
  86. package/dist/shared/size-limited-cache.spec.d.ts +1 -0
  87. package/dist/size-limited-cache.cjs.js +82 -0
  88. package/dist/size-limited-cache.d.ts +1 -0
  89. package/dist/size-limited-cache.es.js +82 -0
  90. package/dist/types.d.ts +137 -0
  91. package/dist/utils/index.d.ts +4 -0
  92. package/dist/utils-5dGErM3C.js +588 -0
  93. package/dist/utils-BBP3hEeV.mjs +589 -0
  94. package/dist/v18.cjs.js +1 -1
  95. package/dist/v18.d.ts +3 -114
  96. package/dist/v18.es.js +1 -1
  97. package/dist/v19.cjs.js +1 -1
  98. package/dist/v19.d.ts +3 -115
  99. package/dist/v19.es.js +1 -1
  100. package/package.json +35 -14
  101. package/CHANGELOG.md +0 -735
  102. package/__tests__/bridge.spec.tsx +0 -160
  103. package/__tests__/createLazyComponent.spec.tsx +0 -209
  104. package/__tests__/prefetch.spec.ts +0 -156
  105. package/__tests__/router.spec.tsx +0 -82
  106. package/__tests__/setupTests.ts +0 -8
  107. package/__tests__/util.ts +0 -36
  108. package/dist/index.esm-BWaKho-8.js +0 -491
  109. package/dist/index.esm-CPwSeCvw.mjs +0 -492
  110. package/dist/prefetch-CK3EZdY4.mjs +0 -1273
  111. package/dist/prefetch-MiXeF8KH.js +0 -1272
  112. package/dist/utils-dUgb9Jkm.mjs +0 -2016
  113. package/dist/utils-tM9yE73c.js +0 -2015
  114. package/jest.config.ts +0 -21
  115. package/project.json +0 -23
  116. package/src/base.ts +0 -50
  117. package/src/index.ts +0 -50
  118. package/src/lazy/AwaitDataFetch.tsx +0 -215
  119. package/src/lazy/constant.ts +0 -30
  120. package/src/lazy/createLazyComponent.tsx +0 -411
  121. package/src/lazy/data-fetch/cache.ts +0 -291
  122. package/src/lazy/data-fetch/call-data-fetch.ts +0 -13
  123. package/src/lazy/data-fetch/data-fetch-server-middleware.ts +0 -196
  124. package/src/lazy/data-fetch/inject-data-fetch.ts +0 -109
  125. package/src/lazy/data-fetch/prefetch.ts +0 -112
  126. package/src/lazy/data-fetch/runtime-plugin.ts +0 -115
  127. package/src/lazy/index.ts +0 -35
  128. package/src/lazy/logger.ts +0 -6
  129. package/src/lazy/types.ts +0 -75
  130. package/src/lazy/utils.ts +0 -372
  131. package/src/lazy/wrapNoSSR.tsx +0 -10
  132. package/src/modern-app-env.d.ts +0 -2
  133. package/src/plugins/lazy-load-component-plugin.spec.ts +0 -21
  134. package/src/plugins/lazy-load-component-plugin.ts +0 -57
  135. package/src/provider/context.tsx +0 -4
  136. package/src/provider/plugin.ts +0 -22
  137. package/src/provider/versions/bridge-base.tsx +0 -150
  138. package/src/provider/versions/legacy.ts +0 -87
  139. package/src/provider/versions/v18.ts +0 -47
  140. package/src/provider/versions/v19.ts +0 -48
  141. package/src/remote/RemoteAppWrapper.tsx +0 -108
  142. package/src/remote/base-component/create.tsx +0 -23
  143. package/src/remote/base-component/index.tsx +0 -10
  144. package/src/remote/createHelpers.tsx +0 -130
  145. package/src/remote/router-component/component.tsx +0 -104
  146. package/src/remote/router-component/create.tsx +0 -23
  147. package/src/remote/router-component/index.tsx +0 -10
  148. package/src/router/default.tsx +0 -73
  149. package/src/router/v5.tsx +0 -43
  150. package/src/router/v6.tsx +0 -74
  151. package/src/router/v7.tsx +0 -75
  152. package/src/types.ts +0 -147
  153. package/src/utils/index.ts +0 -44
  154. package/src/v18.ts +0 -9
  155. package/src/v19.ts +0 -9
  156. package/tsconfig.json +0 -42
  157. package/tsconfig.node.json +0 -11
  158. package/tsconfig.spec.json +0 -26
  159. package/vite.config.ts +0 -112
  160. package/vitest.config.ts +0 -27
  161. /package/{src/remote/base-component/component.tsx → dist/remote/base-component/component.d.ts} +0 -0
package/dist/base.cjs.js CHANGED
@@ -1,10 +1,10 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
- const createHelpers = require("./createHelpers-B_L612IN.js");
4
- const lazyLoadComponentPlugin = require("./lazy-load-component-plugin-BvnyaA6i.js");
5
- const lazyUtils = require("./utils-tM9yE73c.js");
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
6
  const dataFetchUtils = require("./data-fetch-utils.cjs.js");
7
- const prefetch = require("./prefetch-MiXeF8KH.js");
7
+ const prefetch = require("./prefetch-Bxf6DSx_.js");
8
8
  const createRemoteAppComponent = createHelpers.createRemoteAppComponentFactory(createHelpers.RemoteAppWrapper);
9
9
  const createRemoteComponent = createHelpers.createDeprecatedRemoteComponentFactory(
10
10
  createRemoteAppComponent
package/dist/base.d.ts CHANGED
@@ -1,311 +1,8 @@
1
- import { default as default_2 } from 'react';
2
- import { ForwardRefExoticComponent } from 'react';
3
- import { getInstance } from '@module-federation/runtime';
4
- import { ModuleFederationRuntimePlugin } from '@module-federation/runtime';
5
- import * as React_2 from 'react';
6
- import { ReactNode } from 'react';
7
- import { RefAttributes } from 'react';
8
-
9
- export declare const autoFetchDataPlugin: () => ModuleFederationRuntimePlugin;
10
-
11
- export declare function cache<T>(fn: DataFetch<T>, options?: CacheOptions): DataFetch<T>;
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_2<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
- * Parameters for the remote component
222
- */
223
- declare interface RemoteComponentProps_2<T = Record<string, unknown>> {
224
- props?: T;
225
- fallback?: React_2.ComponentType<{
226
- error: Error;
227
- }>;
228
- loading?: React_2.ReactNode;
229
- [key: string]: unknown;
230
- }
231
-
232
- /**
233
- * Interface for a remote module provider
234
- */
235
- export declare interface RemoteModule {
236
- provider: () => {
237
- render: (info: RenderFnParams) => void;
238
- destroy: (info: {
239
- dom: any;
240
- }) => void;
241
- };
242
- }
243
-
244
- /**
245
- * Parameters for the render function, extending ProviderParams
246
- */
247
- export declare interface RenderFnParams extends ProviderParams {
248
- dom: HTMLElement;
249
- fallback?: React_2.ComponentType<{
250
- error: Error;
251
- }>;
252
- [key: string]: unknown;
253
- }
254
-
255
- /**
256
- * Parameters for the render function
257
- */
258
- export declare interface RenderParams {
259
- moduleName?: string;
260
- basename?: string;
261
- memoryRoute?: {
262
- entryPath: string;
263
- initialState?: Record<string, unknown>;
264
- };
265
- dom: HTMLElement;
266
- /**
267
- * Options to pass to createRoot for React 18 and 19
268
- * @example
269
- * {
270
- * identifierPrefix: 'app-',
271
- * onRecoverableError: (err) => console.error(err)
272
- * }
273
- */
274
- rootOptions?: CreateRootOptions_2;
275
- [key: string]: unknown;
276
- }
277
-
278
- export declare function revalidateTag(tag: string): void;
279
-
280
- export declare interface Root {
281
- render(children: React.ReactNode): void;
282
- unmount(): void;
283
- }
284
-
285
- /**
286
- * Interface for a React root object
287
- */
288
- declare interface Root_2 {
289
- render(children: React_2.ReactNode): void;
290
- unmount(): void;
291
- }
292
-
293
- /**
294
- * Type for a root element, which can be either an HTMLElement or a React root
295
- */
296
- export declare type RootType = HTMLElement | Root_2;
297
-
298
- export declare function setSSREnv({ fetchServerQuery, }: {
299
- fetchServerQuery?: Record<string, unknown>;
300
- }): void;
301
-
302
- export { }
303
-
304
-
305
- declare module '@module-federation/runtime-core' {
306
- interface ModuleFederation {
307
- createLazyComponent<T, E extends keyof T>(options: Omit<CreateLazyComponentOptions<T, E>, 'instance'>): ReturnType<typeof createLazyComponent<T, E>>;
308
- prefetch(options: Omit<PrefetchOptions, 'instance'>): ReturnType<typeof prefetch>;
309
- collectSSRAssets(options: Omit<Parameters<typeof collectSSRAssets>[0], 'instance'>): ReturnType<typeof collectSSRAssets>;
310
- }
311
- }
1
+ export { createBridgeComponent } from './provider/versions/legacy';
2
+ export { createRemoteComponent, createRemoteAppComponent, } from './remote/base-component';
3
+ export type { LazyRemoteComponentInfo } from './remote/base-component';
4
+ export { ERROR_TYPE, createLazyComponent, collectSSRAssets, callDataFetch, setSSREnv, autoFetchDataPlugin, CacheSize, CacheTime, configureCache, generateKey, cache, revalidateTag, clearStore, prefetch, } from './lazy';
5
+ export { lazyLoadComponentPlugin } from './plugins/lazy-load-component-plugin';
6
+ export type { CreateRootOptions, Root } from './provider/versions/legacy';
7
+ export type { ProviderParams, ProviderFnParams, RootType, DestroyParams, RenderParams, RemoteComponentParams, RenderFnParams, RemoteComponentProps, RemoteModule, } from './types';
8
+ export type { DataFetchParams, NoSSRRemoteInfo, CollectSSRAssetsOptions, CreateLazyComponentOptions, CacheStatus, CacheStatsInfo, } from './lazy';
package/dist/base.es.js CHANGED
@@ -1,9 +1,9 @@
1
- import { c as createDeprecatedRemoteComponentFactory, a as createRemoteAppComponentFactory, R as RemoteAppWrapper } from "./createHelpers-Ui5pt7je.mjs";
2
- import { b } from "./createHelpers-Ui5pt7je.mjs";
3
- import { b as b2, a, c, l } from "./lazy-load-component-plugin-CVcFMRce.mjs";
4
- import { C, a as a2, E, b as b3, d, c as c2, g, r, s } from "./utils-dUgb9Jkm.mjs";
1
+ import { c as createRemoteAppComponentFactory, a as createDeprecatedRemoteComponentFactory, R as RemoteAppWrapper } 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
5
  import { callDataFetch } from "./data-fetch-utils.es.js";
6
- import { p } from "./prefetch-CK3EZdY4.mjs";
6
+ import { p } from "./prefetch-TKq_EK_q.mjs";
7
7
  const createRemoteAppComponent = createRemoteAppComponentFactory(RemoteAppWrapper);
8
8
  const createRemoteComponent = createDeprecatedRemoteComponentFactory(
9
9
  createRemoteAppComponent
@@ -12,14 +12,14 @@ export {
12
12
  C as CacheSize,
13
13
  a2 as CacheTime,
14
14
  E as ERROR_TYPE,
15
- b2 as autoFetchDataPlugin,
16
- b3 as cache,
15
+ a as autoFetchDataPlugin,
16
+ c2 as cache,
17
17
  callDataFetch,
18
- d as clearStore,
19
- a as collectSSRAssets,
20
- c2 as configureCache,
18
+ b3 as clearStore,
19
+ c as collectSSRAssets,
20
+ d as configureCache,
21
21
  b as createBridgeComponent,
22
- c as createLazyComponent,
22
+ b2 as createLazyComponent,
23
23
  createRemoteAppComponent,
24
24
  createRemoteComponent,
25
25
  g as generateKey,
@@ -1,102 +1,36 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
3
+ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
1
4
  import * as React from "react";
2
- import { Component, createElement, createContext } from "react";
3
- import { L as LoggerInstance, R as RouterContext } from "./index-DyQNwY2M.mjs";
5
+ import { L as LoggerInstance, R as RouterContext } from "./index-Bs2NxD2z.mjs";
4
6
  import { federationRuntime } from "./plugin.es.js";
5
- const ErrorBoundaryContext = createContext(null);
6
- const initialState = {
7
- didCatch: false,
8
- error: null
9
- };
10
- class ErrorBoundary extends Component {
11
- constructor(props) {
12
- super(props);
13
- this.resetErrorBoundary = this.resetErrorBoundary.bind(this);
14
- this.state = initialState;
15
- }
16
- static getDerivedStateFromError(error) {
17
- return {
18
- didCatch: true,
19
- error
20
- };
21
- }
22
- resetErrorBoundary() {
23
- const {
24
- error
25
- } = this.state;
26
- if (error !== null) {
27
- var _this$props$onReset, _this$props;
28
- for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
29
- args[_key] = arguments[_key];
7
+ const initialState = { didCatch: false, error: null };
8
+ class ErrorBoundary extends React.Component {
9
+ constructor() {
10
+ super(...arguments);
11
+ __publicField(this, "state", initialState);
12
+ __publicField(this, "resetErrorBoundary", (..._args) => {
13
+ if (this.state.didCatch) {
14
+ this.setState(initialState);
30
15
  }
31
- (_this$props$onReset = (_this$props = this.props).onReset) === null || _this$props$onReset === void 0 ? void 0 : _this$props$onReset.call(_this$props, {
32
- args,
33
- reason: "imperative-api"
34
- });
35
- this.setState(initialState);
36
- }
37
- }
38
- componentDidCatch(error, info) {
39
- var _this$props$onError, _this$props2;
40
- (_this$props$onError = (_this$props2 = this.props).onError) === null || _this$props$onError === void 0 ? void 0 : _this$props$onError.call(_this$props2, error, info);
16
+ });
41
17
  }
42
- componentDidUpdate(prevProps, prevState) {
43
- const {
44
- didCatch
45
- } = this.state;
46
- const {
47
- resetKeys
48
- } = this.props;
49
- if (didCatch && prevState.error !== null && hasArrayChanged(prevProps.resetKeys, resetKeys)) {
50
- var _this$props$onReset2, _this$props3;
51
- (_this$props$onReset2 = (_this$props3 = this.props).onReset) === null || _this$props$onReset2 === void 0 ? void 0 : _this$props$onReset2.call(_this$props3, {
52
- next: resetKeys,
53
- prev: prevProps.resetKeys,
54
- reason: "keys"
55
- });
56
- this.setState(initialState);
57
- }
18
+ static getDerivedStateFromError(error) {
19
+ return { didCatch: true, error };
58
20
  }
59
21
  render() {
60
- const {
61
- children,
62
- fallbackRender,
63
- FallbackComponent,
64
- fallback
65
- } = this.props;
66
- const {
67
- didCatch,
68
- error
69
- } = this.state;
70
- let childToRender = children;
71
- if (didCatch) {
72
- const props = {
73
- error,
74
- resetErrorBoundary: this.resetErrorBoundary
75
- };
76
- if (typeof fallbackRender === "function") {
77
- childToRender = fallbackRender(props);
78
- } else if (FallbackComponent) {
79
- childToRender = createElement(FallbackComponent, props);
80
- } else if (fallback !== void 0) {
81
- childToRender = fallback;
82
- } else {
83
- throw error;
84
- }
22
+ if (this.state.didCatch) {
23
+ return /* @__PURE__ */ React.createElement(
24
+ this.props.FallbackComponent,
25
+ {
26
+ error: this.state.error,
27
+ resetErrorBoundary: this.resetErrorBoundary
28
+ }
29
+ );
85
30
  }
86
- return createElement(ErrorBoundaryContext.Provider, {
87
- value: {
88
- didCatch,
89
- error,
90
- resetErrorBoundary: this.resetErrorBoundary
91
- }
92
- }, childToRender);
31
+ return this.props.children;
93
32
  }
94
33
  }
95
- function hasArrayChanged() {
96
- let a = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : [];
97
- let b = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : [];
98
- return a.length !== b.length || a.some((item, index) => !Object.is(item, b[index]));
99
- }
100
34
  function createBaseBridgeComponent({
101
35
  createRoot,
102
36
  defaultRootOptions,
@@ -121,14 +55,18 @@ function createBaseBridgeComponent({
121
55
  }
122
56
  ));
123
57
  };
124
- const DefaultFallback = ({ error }) => /* @__PURE__ */ React.createElement("div", { role: "alert" }, /* @__PURE__ */ React.createElement("p", null, "Something went wrong:"), /* @__PURE__ */ React.createElement("pre", { style: { color: "red" } }, error.message));
58
+ const DefaultFallback = ({ error }) => /* @__PURE__ */ React.createElement("div", { role: "alert" }, /* @__PURE__ */ React.createElement("p", null, "Something went wrong:"), /* @__PURE__ */ React.createElement("pre", { style: { color: "red" } }, error instanceof Error ? error.message : String(error)));
59
+ const omitHostFallback = (props) => {
60
+ const nextProps = { ...props };
61
+ delete nextProps.fallback;
62
+ return nextProps;
63
+ };
125
64
  const BridgeWrapper = ({
126
65
  basename,
127
66
  moduleName,
128
67
  memoryRoute,
129
- propsInfo,
130
- fallback
131
- }) => /* @__PURE__ */ React.createElement(ErrorBoundary, { FallbackComponent: fallback || DefaultFallback }, /* @__PURE__ */ React.createElement(
68
+ propsInfo
69
+ }) => /* @__PURE__ */ React.createElement(ErrorBoundary, { FallbackComponent: DefaultFallback }, /* @__PURE__ */ React.createElement(
132
70
  RawComponent,
133
71
  {
134
72
  appInfo: {
@@ -148,33 +86,41 @@ function createBaseBridgeComponent({
148
86
  dom,
149
87
  basename,
150
88
  memoryRoute,
151
- fallback,
152
89
  rootOptions,
153
90
  ...propsInfo
154
91
  } = info;
92
+ const operationContext = {
93
+ side: "producer",
94
+ framework: "react",
95
+ operation: rootMap.has(dom) ? "update" : "render",
96
+ reason: "direct"
97
+ };
155
98
  const mergedRootOptions = {
156
99
  ...defaultRootOptions,
157
100
  ...rootOptions
158
101
  };
159
- const beforeBridgeRenderRes = ((_c = (_b = (_a = instance == null ? void 0 : instance.bridgeHook) == null ? void 0 : _a.lifecycle) == null ? void 0 : _b.beforeBridgeRender) == null ? void 0 : _c.emit(info)) || {};
102
+ const beforeBridgeRenderRes = ((_c = (_b = (_a = instance == null ? void 0 : instance.bridgeHook) == null ? void 0 : _a.lifecycle) == null ? void 0 : _b.beforeBridgeRender) == null ? void 0 : _c.emit(
103
+ info,
104
+ operationContext
105
+ )) || {};
160
106
  const rootComponentWithErrorBoundary = /* @__PURE__ */ React.createElement(
161
107
  BridgeWrapper,
162
108
  {
163
109
  basename,
164
110
  moduleName,
165
111
  memoryRoute,
166
- fallback,
167
112
  propsInfo: {
168
- ...propsInfo,
113
+ ...omitHostFallback(propsInfo),
169
114
  basename,
170
115
  ...beforeBridgeRenderRes == null ? void 0 : beforeBridgeRenderRes.extraProps
171
116
  }
172
117
  }
173
118
  );
174
119
  if (bridgeInfo.render) {
175
- await Promise.resolve(
120
+ const root = await Promise.resolve(
176
121
  bridgeInfo.render(rootComponentWithErrorBoundary, dom)
177
- ).then((root) => rootMap.set(dom, root));
122
+ );
123
+ rootMap.set(dom, root);
178
124
  } else {
179
125
  let root = rootMap.get(dom);
180
126
  if (!root && createRoot) {
@@ -185,13 +131,25 @@ function createBaseBridgeComponent({
185
131
  root.render(rootComponentWithErrorBoundary);
186
132
  }
187
133
  }
188
- ((_f = (_e = (_d = instance == null ? void 0 : instance.bridgeHook) == null ? void 0 : _d.lifecycle) == null ? void 0 : _e.afterBridgeRender) == null ? void 0 : _f.emit(info)) || {};
134
+ ((_f = (_e = (_d = instance == null ? void 0 : instance.bridgeHook) == null ? void 0 : _d.lifecycle) == null ? void 0 : _e.afterBridgeRender) == null ? void 0 : _f.emit(info, {
135
+ context: operationContext
136
+ })) || {};
189
137
  },
190
138
  destroy(info) {
191
- var _a, _b, _c;
139
+ var _a, _b, _c, _d, _e, _f;
192
140
  const { dom } = info;
193
141
  LoggerInstance.debug(`createBridgeComponent destroy Info`, info);
194
142
  const root = rootMap.get(dom);
143
+ const operationContext = {
144
+ side: "producer",
145
+ framework: "react",
146
+ operation: "destroy",
147
+ reason: "direct"
148
+ };
149
+ (_c = (_b = (_a = instance == null ? void 0 : instance.bridgeHook) == null ? void 0 : _a.lifecycle) == null ? void 0 : _b.beforeBridgeDestroy) == null ? void 0 : _c.emit(
150
+ info,
151
+ operationContext
152
+ );
195
153
  if (root) {
196
154
  if ("unmount" in root) {
197
155
  root.unmount();
@@ -200,7 +158,9 @@ function createBaseBridgeComponent({
200
158
  }
201
159
  rootMap.delete(dom);
202
160
  }
203
- (_c = (_b = (_a = instance == null ? void 0 : instance.bridgeHook) == null ? void 0 : _a.lifecycle) == null ? void 0 : _b.afterBridgeDestroy) == null ? void 0 : _c.emit(info);
161
+ (_f = (_e = (_d = instance == null ? void 0 : instance.bridgeHook) == null ? void 0 : _d.lifecycle) == null ? void 0 : _e.afterBridgeDestroy) == null ? void 0 : _f.emit(info, {
162
+ context: operationContext
163
+ });
204
164
  }
205
165
  };
206
166
  };