@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
|
@@ -0,0 +1,82 @@
|
|
|
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);
|
|
4
|
+
class SizeLimitedCache {
|
|
5
|
+
constructor(options) {
|
|
6
|
+
__publicField(this, "maxSize");
|
|
7
|
+
__publicField(this, "entries", /* @__PURE__ */ new Map());
|
|
8
|
+
__publicField(this, "sizeCalculation");
|
|
9
|
+
__publicField(this, "currentSize", 0);
|
|
10
|
+
if (!Number.isInteger(options.maxSize) || options.maxSize <= 0) {
|
|
11
|
+
throw new TypeError("maxSize must be a positive integer");
|
|
12
|
+
}
|
|
13
|
+
this.maxSize = options.maxSize;
|
|
14
|
+
this.sizeCalculation = options.sizeCalculation;
|
|
15
|
+
}
|
|
16
|
+
get size() {
|
|
17
|
+
return this.entries.size;
|
|
18
|
+
}
|
|
19
|
+
get calculatedSize() {
|
|
20
|
+
return this.currentSize;
|
|
21
|
+
}
|
|
22
|
+
get(key) {
|
|
23
|
+
const entry = this.entries.get(key);
|
|
24
|
+
if (!entry) {
|
|
25
|
+
return void 0;
|
|
26
|
+
}
|
|
27
|
+
this.refresh(key, entry);
|
|
28
|
+
return entry.value;
|
|
29
|
+
}
|
|
30
|
+
has(key) {
|
|
31
|
+
const entry = this.entries.get(key);
|
|
32
|
+
if (!entry) {
|
|
33
|
+
return false;
|
|
34
|
+
}
|
|
35
|
+
this.refresh(key, entry);
|
|
36
|
+
return true;
|
|
37
|
+
}
|
|
38
|
+
set(key, value, options = {}) {
|
|
39
|
+
var _a;
|
|
40
|
+
const entrySize = options.size ?? ((_a = this.sizeCalculation) == null ? void 0 : _a.call(this, value, key)) ?? 1;
|
|
41
|
+
if (!Number.isInteger(entrySize) || entrySize <= 0) {
|
|
42
|
+
throw new TypeError("entry size must be a positive integer");
|
|
43
|
+
}
|
|
44
|
+
this.delete(key);
|
|
45
|
+
if (entrySize > this.maxSize) {
|
|
46
|
+
return this;
|
|
47
|
+
}
|
|
48
|
+
this.entries.set(key, { value, size: entrySize });
|
|
49
|
+
this.currentSize += entrySize;
|
|
50
|
+
this.evictUntilWithinLimit();
|
|
51
|
+
return this;
|
|
52
|
+
}
|
|
53
|
+
delete(key) {
|
|
54
|
+
const entry = this.entries.get(key);
|
|
55
|
+
if (!entry) {
|
|
56
|
+
return false;
|
|
57
|
+
}
|
|
58
|
+
this.currentSize -= entry.size;
|
|
59
|
+
return this.entries.delete(key);
|
|
60
|
+
}
|
|
61
|
+
clear() {
|
|
62
|
+
this.entries.clear();
|
|
63
|
+
this.currentSize = 0;
|
|
64
|
+
}
|
|
65
|
+
refresh(key, entry) {
|
|
66
|
+
this.entries.delete(key);
|
|
67
|
+
this.entries.set(key, entry);
|
|
68
|
+
}
|
|
69
|
+
evictUntilWithinLimit() {
|
|
70
|
+
while (this.currentSize > this.maxSize) {
|
|
71
|
+
const oldest = this.entries.keys().next();
|
|
72
|
+
if (oldest.done) {
|
|
73
|
+
this.currentSize = 0;
|
|
74
|
+
return;
|
|
75
|
+
}
|
|
76
|
+
this.delete(oldest.value);
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
export {
|
|
81
|
+
SizeLimitedCache
|
|
82
|
+
};
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
export type ErrorFallbackProps = {
|
|
3
|
+
error: unknown;
|
|
4
|
+
resetErrorBoundary: (...args: unknown[]) => void;
|
|
5
|
+
};
|
|
6
|
+
/**
|
|
7
|
+
* Options for creating a React root
|
|
8
|
+
*/
|
|
9
|
+
export interface CreateRootOptions {
|
|
10
|
+
identifierPrefix?: string;
|
|
11
|
+
onRecoverableError?: (error: unknown) => void;
|
|
12
|
+
transitionCallbacks?: unknown;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Interface for a React root object
|
|
16
|
+
*/
|
|
17
|
+
export interface Root {
|
|
18
|
+
render(children: React.ReactNode): void;
|
|
19
|
+
unmount(): void;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Type for a root element, which can be either an HTMLElement or a React root
|
|
23
|
+
*/
|
|
24
|
+
export type RootType = HTMLElement | Root;
|
|
25
|
+
/**
|
|
26
|
+
* Parameters for the render function
|
|
27
|
+
*/
|
|
28
|
+
export interface RenderParams {
|
|
29
|
+
moduleName?: string;
|
|
30
|
+
basename?: string;
|
|
31
|
+
memoryRoute?: {
|
|
32
|
+
entryPath: string;
|
|
33
|
+
initialState?: Record<string, unknown>;
|
|
34
|
+
};
|
|
35
|
+
dom: HTMLElement;
|
|
36
|
+
/**
|
|
37
|
+
* Options to pass to createRoot for React 18 and 19
|
|
38
|
+
* @example
|
|
39
|
+
* {
|
|
40
|
+
* identifierPrefix: 'app-',
|
|
41
|
+
* onRecoverableError: (err) => console.error(err)
|
|
42
|
+
* }
|
|
43
|
+
*/
|
|
44
|
+
rootOptions?: CreateRootOptions;
|
|
45
|
+
[key: string]: unknown;
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Parameters for the destroy function
|
|
49
|
+
*/
|
|
50
|
+
export interface DestroyParams {
|
|
51
|
+
moduleName: string;
|
|
52
|
+
dom: HTMLElement;
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Parameters for the provider function
|
|
56
|
+
*/
|
|
57
|
+
export interface ProviderParams {
|
|
58
|
+
moduleName?: string;
|
|
59
|
+
basename?: string;
|
|
60
|
+
memoryRoute?: {
|
|
61
|
+
entryPath: string;
|
|
62
|
+
initialState?: Record<string, unknown>;
|
|
63
|
+
};
|
|
64
|
+
style?: React.CSSProperties;
|
|
65
|
+
className?: string;
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Parameters for the render function, extending ProviderParams
|
|
69
|
+
*/
|
|
70
|
+
export interface RenderFnParams extends ProviderParams {
|
|
71
|
+
dom: HTMLElement;
|
|
72
|
+
fallback?: React.ComponentType<{
|
|
73
|
+
error: Error;
|
|
74
|
+
}>;
|
|
75
|
+
[key: string]: unknown;
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* Parameters for the provider function
|
|
79
|
+
*/
|
|
80
|
+
export interface ProviderFnParams<T> {
|
|
81
|
+
rootComponent: React.ComponentType<T>;
|
|
82
|
+
render?: (App: React.ReactElement, id?: HTMLElement | string) => RootType | Promise<RootType>;
|
|
83
|
+
createRoot?: (container: Element | DocumentFragment, options?: CreateRootOptions) => Root;
|
|
84
|
+
/**
|
|
85
|
+
* Default options to pass to createRoot for React 18 and 19
|
|
86
|
+
* These options will be used when creating a root unless overridden by rootOptions in render params
|
|
87
|
+
* @example
|
|
88
|
+
* {
|
|
89
|
+
* identifierPrefix: 'app-',
|
|
90
|
+
* onRecoverableError: (err) => console.error(err)
|
|
91
|
+
* }
|
|
92
|
+
*/
|
|
93
|
+
defaultRootOptions?: CreateRootOptions;
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* Parameters for the remote component
|
|
97
|
+
*/
|
|
98
|
+
export interface RemoteComponentProps<T = Record<string, unknown>> {
|
|
99
|
+
props?: T;
|
|
100
|
+
fallback?: React.ComponentType<{
|
|
101
|
+
error: Error;
|
|
102
|
+
}>;
|
|
103
|
+
loading?: React.ReactNode;
|
|
104
|
+
[key: string]: unknown;
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* Parameters for the remote component loader
|
|
108
|
+
*/
|
|
109
|
+
export interface RemoteComponentParams<T = Record<string, unknown>, E extends keyof T = keyof T> {
|
|
110
|
+
loader: () => Promise<T>;
|
|
111
|
+
loading: React.ReactNode;
|
|
112
|
+
fallback: React.ComponentType<{
|
|
113
|
+
error: Error;
|
|
114
|
+
}>;
|
|
115
|
+
export?: E;
|
|
116
|
+
props?: T;
|
|
117
|
+
}
|
|
118
|
+
/**
|
|
119
|
+
* Interface for a remote module provider
|
|
120
|
+
*/
|
|
121
|
+
export interface RemoteModule {
|
|
122
|
+
provider: () => {
|
|
123
|
+
render: (info: RenderFnParams) => void;
|
|
124
|
+
destroy: (info: {
|
|
125
|
+
dom: any;
|
|
126
|
+
}) => void;
|
|
127
|
+
};
|
|
128
|
+
}
|
|
129
|
+
/**
|
|
130
|
+
* Parameters for a remote app component
|
|
131
|
+
*/
|
|
132
|
+
export interface RemoteAppParams extends ProviderParams {
|
|
133
|
+
moduleName: string;
|
|
134
|
+
providerInfo: NonNullable<RemoteModule['provider']>;
|
|
135
|
+
exportName: string | number | symbol;
|
|
136
|
+
fallback: React.ComponentType<ErrorFallbackProps>;
|
|
137
|
+
}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export declare const LoggerInstance: import("@module-federation/sdk").Logger;
|
|
2
|
+
export declare function pathJoin(...args: string[]): string;
|
|
3
|
+
export declare const getModuleName: (id: string) => string;
|
|
4
|
+
export declare const getRootDomDefaultClassName: (moduleName: string) => string;
|