@module-federation/bridge-react 0.0.0-next-20240723065243 → 0.0.0-next-20240723095610
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/CHANGELOG.md +2 -2
- package/dist/index.cjs.js +1 -1
- package/dist/index.d.ts +10 -4
- package/dist/index.es.js +1 -1
- package/package.json +2 -2
- package/src/create.tsx +18 -15
package/CHANGELOG.md
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
# @module-federation/bridge-react
|
|
2
2
|
|
|
3
|
-
## 0.0.0-next-
|
|
3
|
+
## 0.0.0-next-20240723095610
|
|
4
4
|
|
|
5
5
|
### Patch Changes
|
|
6
6
|
|
|
7
7
|
- chore: bump next
|
|
8
|
-
- @module-federation/bridge-shared@0.0.0-next-
|
|
8
|
+
- @module-federation/bridge-shared@0.0.0-next-20240723095610
|
|
9
9
|
|
|
10
10
|
## 0.2.6
|
|
11
11
|
|
package/dist/index.cjs.js
CHANGED
|
@@ -282,8 +282,8 @@ function createLazyRemoteComponent(info) {
|
|
|
282
282
|
});
|
|
283
283
|
}
|
|
284
284
|
function createRemoteComponent(info) {
|
|
285
|
-
const LazyComponent = createLazyRemoteComponent(info);
|
|
286
285
|
return React.forwardRef(function(props, ref) {
|
|
286
|
+
const LazyComponent = createLazyRemoteComponent(info);
|
|
287
287
|
return /* @__PURE__ */ React.createElement(ErrorBoundary, { FallbackComponent: info.fallback }, /* @__PURE__ */ React.createElement(React.Suspense, { fallback: info.loading }, /* @__PURE__ */ React.createElement(LazyComponent, { ...props, ref })));
|
|
288
288
|
});
|
|
289
289
|
}
|
package/dist/index.d.ts
CHANGED
|
@@ -2,8 +2,11 @@ import { ComponentType } from 'react';
|
|
|
2
2
|
import { default as default_2 } from 'react';
|
|
3
3
|
import { default as default_3 } from 'react-dom/client';
|
|
4
4
|
import { ErrorInfo } from 'react';
|
|
5
|
+
import { ForwardRefExoticComponent } from 'react';
|
|
5
6
|
import { PropsWithChildren } from 'react';
|
|
7
|
+
import { PropsWithoutRef } from 'react';
|
|
6
8
|
import * as React_2 from 'react';
|
|
9
|
+
import { RefAttributes } from 'react';
|
|
7
10
|
|
|
8
11
|
export declare function createBridgeComponent<T>(bridgeInfo: ProviderFnParams<T>): () => {
|
|
9
12
|
render(info: RenderFnParams & any): Promise<void>;
|
|
@@ -19,10 +22,7 @@ export declare function createRemoteComponent<T, E extends keyof T>(info: {
|
|
|
19
22
|
loading: default_2.ReactNode;
|
|
20
23
|
fallback: ErrorBoundaryPropsWithComponent['FallbackComponent'];
|
|
21
24
|
export?: E;
|
|
22
|
-
}):
|
|
23
|
-
basename?: ProviderParams["basename"];
|
|
24
|
-
memoryRoute?: ProviderParams["memoryRoute"];
|
|
25
|
-
} & ("__BRIDGE_FN__" extends keyof (T[E] extends (...args: any) => any ? ReturnType<T[E]> : never) ? (T[E] extends (...args: any) => any ? ReturnType<T[E]> : never)["__BRIDGE_FN__"] extends (...args: any) => any ? Parameters<(T[E] extends (...args: any) => any ? ReturnType<T[E]> : never)["__BRIDGE_FN__"]>[0] : {} : {})> & default_2.RefAttributes<unknown>>;
|
|
25
|
+
}): ForwardRefExoticComponent<PropsWithoutRef<RemoteProps> & RefAttributes<HTMLElement | HTMLDivElement>>;
|
|
26
26
|
|
|
27
27
|
declare type ErrorBoundaryPropsWithComponent = ErrorBoundarySharedProps & {
|
|
28
28
|
fallback?: never;
|
|
@@ -61,6 +61,12 @@ export declare interface ProviderParams {
|
|
|
61
61
|
};
|
|
62
62
|
}
|
|
63
63
|
|
|
64
|
+
declare type RemoteProps = {
|
|
65
|
+
basename?: ProviderParams['basename'];
|
|
66
|
+
memoryRoute?: ProviderParams['memoryRoute'];
|
|
67
|
+
[key: string]: any;
|
|
68
|
+
};
|
|
69
|
+
|
|
64
70
|
export declare interface RenderFnParams extends ProviderParams {
|
|
65
71
|
dom: HTMLElement;
|
|
66
72
|
}
|
package/dist/index.es.js
CHANGED
|
@@ -263,8 +263,8 @@ function createLazyRemoteComponent(info) {
|
|
|
263
263
|
});
|
|
264
264
|
}
|
|
265
265
|
function createRemoteComponent(info) {
|
|
266
|
-
const LazyComponent = createLazyRemoteComponent(info);
|
|
267
266
|
return forwardRef(function(props, ref) {
|
|
267
|
+
const LazyComponent = createLazyRemoteComponent(info);
|
|
268
268
|
return /* @__PURE__ */ React__default.createElement(ErrorBoundary, { FallbackComponent: info.fallback }, /* @__PURE__ */ React__default.createElement(React__default.Suspense, { fallback: info.loading }, /* @__PURE__ */ React__default.createElement(LazyComponent, { ...props, ref })));
|
|
269
269
|
});
|
|
270
270
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@module-federation/bridge-react",
|
|
3
|
-
"version": "0.0.0-next-
|
|
3
|
+
"version": "0.0.0-next-20240723095610",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public"
|
|
6
6
|
},
|
|
@@ -35,7 +35,7 @@
|
|
|
35
35
|
"dependencies": {
|
|
36
36
|
"@loadable/component": "^5.16.4",
|
|
37
37
|
"react-error-boundary": "^4.0.13",
|
|
38
|
-
"@module-federation/bridge-shared": "0.0.0-next-
|
|
38
|
+
"@module-federation/bridge-shared": "0.0.0-next-20240723095610"
|
|
39
39
|
},
|
|
40
40
|
"peerDependencies": {
|
|
41
41
|
"react": ">=16.9.0",
|
package/src/create.tsx
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import React, { forwardRef } from 'react';
|
|
2
|
+
import type { ForwardRefExoticComponent, PropsWithoutRef, RefAttributes } from 'react';
|
|
2
3
|
import type { ProviderParams } from '@module-federation/bridge-shared';
|
|
3
4
|
import { LoggerInstance } from './utils';
|
|
4
5
|
import {
|
|
@@ -83,27 +84,29 @@ function createLazyRemoteComponent<T, E extends keyof T>(info: {
|
|
|
83
84
|
});
|
|
84
85
|
}
|
|
85
86
|
|
|
87
|
+
type RemoteProps = {
|
|
88
|
+
basename?: ProviderParams['basename'];
|
|
89
|
+
memoryRoute?: ProviderParams['memoryRoute'];
|
|
90
|
+
[key: string]: any;
|
|
91
|
+
};
|
|
92
|
+
|
|
86
93
|
export function createRemoteComponent<T, E extends keyof T>(info: {
|
|
87
94
|
loader: () => Promise<T>;
|
|
88
95
|
loading: React.ReactNode;
|
|
89
96
|
fallback: ErrorBoundaryPropsWithComponent['FallbackComponent'];
|
|
90
97
|
export?: E;
|
|
91
|
-
}) {
|
|
92
|
-
type ExportType = T[E] extends (...args: any) => any
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
type RawComponentType = '__BRIDGE_FN__' extends keyof ExportType
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
98
|
+
}): ForwardRefExoticComponent< PropsWithoutRef<RemoteProps> & RefAttributes<HTMLElement | HTMLDivElement>> {
|
|
99
|
+
// type ExportType = T[E] extends (...args: any) => any
|
|
100
|
+
// ? ReturnType<T[E]>
|
|
101
|
+
// : never;
|
|
102
|
+
// type RawComponentType = '__BRIDGE_FN__' extends keyof ExportType
|
|
103
|
+
// ? ExportType['__BRIDGE_FN__'] extends (...args: any) => any
|
|
104
|
+
// ? Parameters<ExportType['__BRIDGE_FN__']>[0]
|
|
105
|
+
// : {}
|
|
106
|
+
// : {};
|
|
100
107
|
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
return forwardRef(function (props: {
|
|
104
|
-
basename?: ProviderParams['basename'];
|
|
105
|
-
memoryRoute?: ProviderParams['memoryRoute'];
|
|
106
|
-
} & RawComponentType, ref) {
|
|
108
|
+
return forwardRef(function (props, ref) {
|
|
109
|
+
const LazyComponent = createLazyRemoteComponent(info);
|
|
107
110
|
return (
|
|
108
111
|
<ErrorBoundary FallbackComponent={info.fallback}>
|
|
109
112
|
<React.Suspense fallback={info.loading}>
|