@module-federation/bridge-react 0.0.0-docs-remove-invalid-lark-link-20251205062649
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 +728 -0
- package/LICENSE +21 -0
- package/README.md +131 -0
- package/__tests__/bridge.spec.tsx +160 -0
- package/__tests__/createLazyComponent.spec.tsx +209 -0
- package/__tests__/prefetch.spec.ts +156 -0
- package/__tests__/router.spec.tsx +82 -0
- package/__tests__/setupTests.ts +8 -0
- package/__tests__/util.ts +36 -0
- package/dist/base.cjs.js +29 -0
- package/dist/base.d.ts +311 -0
- package/dist/base.es.js +30 -0
- package/dist/bridge-base-CPSTBjEp.mjs +211 -0
- package/dist/bridge-base-RStDxH71.js +226 -0
- package/dist/createHelpers-B_L612IN.js +190 -0
- package/dist/createHelpers-Ui5pt7je.mjs +191 -0
- package/dist/data-fetch-server-middleware.cjs.js +163 -0
- package/dist/data-fetch-server-middleware.d.ts +15 -0
- package/dist/data-fetch-server-middleware.es.js +164 -0
- package/dist/data-fetch-utils.cjs.js +24 -0
- package/dist/data-fetch-utils.d.ts +81 -0
- package/dist/data-fetch-utils.es.js +26 -0
- package/dist/index-DRSBaSu3.js +45 -0
- package/dist/index-DyQNwY2M.mjs +46 -0
- package/dist/index.cjs.js +125 -0
- package/dist/index.d.ts +299 -0
- package/dist/index.es.js +109 -0
- package/dist/index.esm-BWaKho-8.js +491 -0
- package/dist/index.esm-CPwSeCvw.mjs +492 -0
- package/dist/lazy-load-component-plugin-CSRkMmKF.js +521 -0
- package/dist/lazy-load-component-plugin-DXqhuywC.mjs +522 -0
- package/dist/lazy-load-component-plugin.cjs.js +6 -0
- package/dist/lazy-load-component-plugin.d.ts +16 -0
- package/dist/lazy-load-component-plugin.es.js +6 -0
- package/dist/lazy-utils.cjs.js +24 -0
- package/dist/lazy-utils.d.ts +149 -0
- package/dist/lazy-utils.es.js +24 -0
- package/dist/plugin.cjs.js +14 -0
- package/dist/plugin.d.ts +22 -0
- package/dist/plugin.es.js +14 -0
- package/dist/prefetch-A3QkU5oZ.js +1272 -0
- package/dist/prefetch-zMJL79zx.mjs +1273 -0
- package/dist/router-v5.cjs.js +55 -0
- package/dist/router-v5.d.ts +18 -0
- package/dist/router-v5.es.js +32 -0
- package/dist/router-v6.cjs.js +84 -0
- package/dist/router-v6.d.ts +20 -0
- package/dist/router-v6.es.js +61 -0
- package/dist/router-v7.cjs.js +83 -0
- package/dist/router-v7.d.ts +20 -0
- package/dist/router-v7.es.js +61 -0
- package/dist/router.cjs.js +82 -0
- package/dist/router.d.ts +20 -0
- package/dist/router.es.js +60 -0
- package/dist/utils-dUgb9Jkm.mjs +2016 -0
- package/dist/utils-tM9yE73c.js +2015 -0
- package/dist/v18.cjs.js +15 -0
- package/dist/v18.d.ts +114 -0
- package/dist/v18.es.js +15 -0
- package/dist/v19.cjs.js +15 -0
- package/dist/v19.d.ts +115 -0
- package/dist/v19.es.js +15 -0
- package/jest.config.ts +21 -0
- package/package.json +173 -0
- package/project.json +23 -0
- package/src/base.ts +50 -0
- package/src/index.ts +50 -0
- package/src/lazy/AwaitDataFetch.tsx +215 -0
- package/src/lazy/constant.ts +30 -0
- package/src/lazy/createLazyComponent.tsx +411 -0
- package/src/lazy/data-fetch/cache.ts +291 -0
- package/src/lazy/data-fetch/call-data-fetch.ts +13 -0
- package/src/lazy/data-fetch/data-fetch-server-middleware.ts +196 -0
- package/src/lazy/data-fetch/index.ts +16 -0
- package/src/lazy/data-fetch/inject-data-fetch.ts +109 -0
- package/src/lazy/data-fetch/prefetch.ts +112 -0
- package/src/lazy/data-fetch/runtime-plugin.ts +115 -0
- package/src/lazy/index.ts +35 -0
- package/src/lazy/logger.ts +6 -0
- package/src/lazy/types.ts +75 -0
- package/src/lazy/utils.ts +372 -0
- package/src/lazy/wrapNoSSR.tsx +10 -0
- package/src/modern-app-env.d.ts +2 -0
- package/src/plugins/lazy-load-component-plugin.spec.ts +21 -0
- package/src/plugins/lazy-load-component-plugin.ts +57 -0
- package/src/provider/context.tsx +4 -0
- package/src/provider/plugin.ts +22 -0
- package/src/provider/versions/bridge-base.tsx +150 -0
- package/src/provider/versions/legacy.ts +87 -0
- package/src/provider/versions/v18.ts +47 -0
- package/src/provider/versions/v19.ts +48 -0
- package/src/remote/RemoteAppWrapper.tsx +108 -0
- package/src/remote/base-component/component.tsx +2 -0
- package/src/remote/base-component/create.tsx +23 -0
- package/src/remote/base-component/index.tsx +10 -0
- package/src/remote/createHelpers.tsx +130 -0
- package/src/remote/router-component/component.tsx +104 -0
- package/src/remote/router-component/create.tsx +23 -0
- package/src/remote/router-component/index.tsx +10 -0
- package/src/router/default.tsx +73 -0
- package/src/router/v5.tsx +43 -0
- package/src/router/v6.tsx +74 -0
- package/src/router/v7.tsx +75 -0
- package/src/types.ts +147 -0
- package/src/utils/index.ts +44 -0
- package/src/v18.ts +9 -0
- package/src/v19.ts +9 -0
- package/tsconfig.json +42 -0
- package/tsconfig.node.json +11 -0
- package/tsconfig.spec.json +26 -0
- package/vite.config.ts +112 -0
- package/vitest.config.ts +27 -0
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
// Test file for router
|
|
2
|
+
import { render } from '@testing-library/react';
|
|
3
|
+
import React from 'react';
|
|
4
|
+
import {
|
|
5
|
+
Link,
|
|
6
|
+
Routes,
|
|
7
|
+
Route,
|
|
8
|
+
Outlet,
|
|
9
|
+
createBrowserRouter,
|
|
10
|
+
} from 'react-router-dom';
|
|
11
|
+
import { BrowserRouter, RouterProvider } from '../src/router/default';
|
|
12
|
+
import { RouterContext } from '../src/provider/context';
|
|
13
|
+
import { getHtml, getWindowImpl } from './util';
|
|
14
|
+
|
|
15
|
+
describe('react router proxy', () => {
|
|
16
|
+
it('BrowserRouter not wraper context', async () => {
|
|
17
|
+
let { container } = render(
|
|
18
|
+
<RouterContext.Provider value={{ basename: '/test' } as any}>
|
|
19
|
+
<BrowserRouter basename="/" window={getWindowImpl('/test', false)}>
|
|
20
|
+
<ul>
|
|
21
|
+
<li>
|
|
22
|
+
<Link to="/">Home</Link>
|
|
23
|
+
</li>
|
|
24
|
+
<li>
|
|
25
|
+
<Link to="/detail">Detail</Link>
|
|
26
|
+
</li>
|
|
27
|
+
</ul>
|
|
28
|
+
<Routes>
|
|
29
|
+
<Route path="/" Component={() => <div>home page</div>} />
|
|
30
|
+
<Route path="/detail" Component={() => <div>detail page</div>} />
|
|
31
|
+
</Routes>
|
|
32
|
+
</BrowserRouter>
|
|
33
|
+
</RouterContext.Provider>,
|
|
34
|
+
);
|
|
35
|
+
expect(getHtml(container)).toMatch('home page');
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
it('RouterProvider', async () => {
|
|
39
|
+
function Layout() {
|
|
40
|
+
return (
|
|
41
|
+
<>
|
|
42
|
+
<ul>
|
|
43
|
+
<li>
|
|
44
|
+
<Link to="/">Home</Link>
|
|
45
|
+
</li>
|
|
46
|
+
<li>
|
|
47
|
+
<Link to="/detail">Detail</Link>
|
|
48
|
+
</li>
|
|
49
|
+
</ul>
|
|
50
|
+
<Outlet />
|
|
51
|
+
</>
|
|
52
|
+
);
|
|
53
|
+
}
|
|
54
|
+
const router = createBrowserRouter(
|
|
55
|
+
[
|
|
56
|
+
{
|
|
57
|
+
path: '/',
|
|
58
|
+
element: <Layout />,
|
|
59
|
+
children: [
|
|
60
|
+
{
|
|
61
|
+
index: true,
|
|
62
|
+
element: <div>home page</div>,
|
|
63
|
+
},
|
|
64
|
+
{
|
|
65
|
+
path: '/detail',
|
|
66
|
+
element: <div>detail page</div>,
|
|
67
|
+
},
|
|
68
|
+
],
|
|
69
|
+
},
|
|
70
|
+
],
|
|
71
|
+
{
|
|
72
|
+
window: getWindowImpl('/test', false),
|
|
73
|
+
},
|
|
74
|
+
);
|
|
75
|
+
let { container } = render(
|
|
76
|
+
<RouterContext.Provider value={{ basename: '/test' } as any}>
|
|
77
|
+
<RouterProvider router={router} />
|
|
78
|
+
</RouterContext.Provider>,
|
|
79
|
+
);
|
|
80
|
+
expect(getHtml(container)).toMatch('home page');
|
|
81
|
+
});
|
|
82
|
+
});
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
// In vitest, you can use the setupFiles option in your configuration file to import any necessary setup files for your tests.
|
|
2
|
+
// For example, if you want to use testing-library's custom matchers, you can import them in a setup file like this:
|
|
3
|
+
import '@testing-library/jest-dom';
|
|
4
|
+
|
|
5
|
+
// Fix TextEncoder/TextDecoder not defined in Node.js
|
|
6
|
+
import { TextEncoder, TextDecoder } from 'util';
|
|
7
|
+
global.TextEncoder = TextEncoder;
|
|
8
|
+
global.TextDecoder = TextDecoder as any;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { JSDOM } from 'jsdom';
|
|
2
|
+
import { prettyDOM } from '@testing-library/react';
|
|
3
|
+
|
|
4
|
+
export async function sleep(time: number) {
|
|
5
|
+
return new Promise((resolve) => {
|
|
6
|
+
setTimeout(() => {
|
|
7
|
+
resolve(null);
|
|
8
|
+
}, time);
|
|
9
|
+
});
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export function createContainer() {
|
|
13
|
+
const container = document.createElement('div');
|
|
14
|
+
container.setAttribute('id', 'container');
|
|
15
|
+
document.body.appendChild(container);
|
|
16
|
+
|
|
17
|
+
return {
|
|
18
|
+
clean: () => {
|
|
19
|
+
document.body.removeChild(container);
|
|
20
|
+
},
|
|
21
|
+
container,
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export function getWindowImpl(initialUrl: string, isHash = false): Window {
|
|
26
|
+
// Need to use our own custom DOM in order to get a working history
|
|
27
|
+
const dom = new JSDOM(`<!DOCTYPE html>`, { url: 'http://localhost/' });
|
|
28
|
+
dom.window.history.replaceState(null, '', (isHash ? '#' : '') + initialUrl);
|
|
29
|
+
return dom.window as unknown as Window;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export function getHtml(container: HTMLElement) {
|
|
33
|
+
return prettyDOM(container, undefined, {
|
|
34
|
+
highlight: false,
|
|
35
|
+
});
|
|
36
|
+
}
|
package/dist/base.cjs.js
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
+
const createHelpers = require("./createHelpers-B_L612IN.js");
|
|
4
|
+
const lazyLoadComponentPlugin = require("./lazy-load-component-plugin-CSRkMmKF.js");
|
|
5
|
+
const lazyUtils = require("./utils-tM9yE73c.js");
|
|
6
|
+
const dataFetchUtils = require("./data-fetch-utils.cjs.js");
|
|
7
|
+
const prefetch = require("./prefetch-A3QkU5oZ.js");
|
|
8
|
+
const createRemoteAppComponent = createHelpers.createRemoteAppComponentFactory(createHelpers.RemoteAppWrapper);
|
|
9
|
+
const createRemoteComponent = createHelpers.createDeprecatedRemoteComponentFactory(
|
|
10
|
+
createRemoteAppComponent
|
|
11
|
+
);
|
|
12
|
+
exports.createBridgeComponent = createHelpers.createBridgeComponent;
|
|
13
|
+
exports.autoFetchDataPlugin = lazyLoadComponentPlugin.autoFetchData;
|
|
14
|
+
exports.collectSSRAssets = lazyLoadComponentPlugin.collectSSRAssets;
|
|
15
|
+
exports.createLazyComponent = lazyLoadComponentPlugin.createLazyComponent;
|
|
16
|
+
exports.lazyLoadComponentPlugin = lazyLoadComponentPlugin.lazyLoadComponentPlugin;
|
|
17
|
+
exports.CacheSize = lazyUtils.CacheSize;
|
|
18
|
+
exports.CacheTime = lazyUtils.CacheTime;
|
|
19
|
+
exports.ERROR_TYPE = lazyUtils.ERROR_TYPE;
|
|
20
|
+
exports.cache = lazyUtils.cache;
|
|
21
|
+
exports.clearStore = lazyUtils.clearStore;
|
|
22
|
+
exports.configureCache = lazyUtils.configureCache;
|
|
23
|
+
exports.generateKey = lazyUtils.generateKey;
|
|
24
|
+
exports.revalidateTag = lazyUtils.revalidateTag;
|
|
25
|
+
exports.setSSREnv = lazyUtils.setSSREnv;
|
|
26
|
+
exports.callDataFetch = dataFetchUtils.callDataFetch;
|
|
27
|
+
exports.prefetch = prefetch.prefetch;
|
|
28
|
+
exports.createRemoteAppComponent = createRemoteAppComponent;
|
|
29
|
+
exports.createRemoteComponent = createRemoteComponent;
|
package/dist/base.d.ts
ADDED
|
@@ -0,0 +1,311 @@
|
|
|
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
|
+
}
|
package/dist/base.es.js
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
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-DXqhuywC.mjs";
|
|
4
|
+
import { C, a as a2, E, b as b3, d, c as c2, g, r, s } from "./utils-dUgb9Jkm.mjs";
|
|
5
|
+
import { callDataFetch } from "./data-fetch-utils.es.js";
|
|
6
|
+
import { p } from "./prefetch-zMJL79zx.mjs";
|
|
7
|
+
const createRemoteAppComponent = createRemoteAppComponentFactory(RemoteAppWrapper);
|
|
8
|
+
const createRemoteComponent = createDeprecatedRemoteComponentFactory(
|
|
9
|
+
createRemoteAppComponent
|
|
10
|
+
);
|
|
11
|
+
export {
|
|
12
|
+
C as CacheSize,
|
|
13
|
+
a2 as CacheTime,
|
|
14
|
+
E as ERROR_TYPE,
|
|
15
|
+
b2 as autoFetchDataPlugin,
|
|
16
|
+
b3 as cache,
|
|
17
|
+
callDataFetch,
|
|
18
|
+
d as clearStore,
|
|
19
|
+
a as collectSSRAssets,
|
|
20
|
+
c2 as configureCache,
|
|
21
|
+
b as createBridgeComponent,
|
|
22
|
+
c as createLazyComponent,
|
|
23
|
+
createRemoteAppComponent,
|
|
24
|
+
createRemoteComponent,
|
|
25
|
+
g as generateKey,
|
|
26
|
+
l as lazyLoadComponentPlugin,
|
|
27
|
+
p as prefetch,
|
|
28
|
+
r as revalidateTag,
|
|
29
|
+
s as setSSREnv
|
|
30
|
+
};
|