@module-federation/bridge-react 2.7.0 → 2.8.0

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 (90) hide show
  1. package/dist/base.cjs.js +4 -4
  2. package/dist/base.d.ts +8 -311
  3. package/dist/base.es.js +5 -5
  4. package/dist/{bridge-base-CIOXqUYV.mjs → bridge-base-BaKy6CY_.mjs} +25 -92
  5. package/dist/{bridge-base-HLp3d7aF.js → bridge-base-Ch33UJuN.js} +25 -91
  6. package/dist/{createHelpers-DNBacpxb.js → createHelpers-19BP0xtB.js} +2 -3
  7. package/dist/{createHelpers-BY5Uj9_Z.mjs → createHelpers-BSHeKyd-.mjs} +2 -3
  8. package/dist/data-fetch-server-middleware.cjs.js +1 -1
  9. package/dist/data-fetch-server-middleware.d.ts +1 -15
  10. package/dist/data-fetch-server-middleware.es.js +1 -1
  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 +4 -4
  14. package/dist/data-fetch.cjs.js +3 -3
  15. package/dist/data-fetch.d.ts +4 -140
  16. package/dist/data-fetch.es.js +3 -3
  17. package/dist/error-boundary.d.ts +17 -0
  18. package/dist/error-boundary.spec.d.ts +1 -0
  19. package/dist/index.cjs.js +4 -4
  20. package/dist/index.d.ts +12 -299
  21. package/dist/index.es.js +5 -5
  22. package/dist/lazy/AwaitDataFetch.d.ts +24 -0
  23. package/dist/lazy/constant.d.ts +26 -0
  24. package/dist/lazy/createLazyComponent.d.ts +28 -0
  25. package/dist/lazy/data-fetch/cache.d.ts +34 -0
  26. package/dist/lazy/data-fetch/cache.spec.d.ts +1 -0
  27. package/dist/lazy/data-fetch/call-data-fetch.d.ts +1 -0
  28. package/dist/lazy/data-fetch/data-fetch-server-middleware.d.ts +3 -0
  29. package/dist/lazy/data-fetch/index.d.ts +6 -0
  30. package/dist/lazy/data-fetch/inject-data-fetch.d.ts +4 -0
  31. package/dist/lazy/data-fetch/prefetch.d.ts +9 -0
  32. package/dist/lazy/data-fetch/runtime-plugin.d.ts +3 -0
  33. package/dist/lazy/index.d.ts +9 -0
  34. package/dist/lazy/logger.d.ts +2 -0
  35. package/dist/lazy/types.d.ts +60 -0
  36. package/dist/lazy/utils.d.ts +48 -0
  37. package/dist/lazy/wrapNoSSR.d.ts +9 -0
  38. package/dist/{lazy-load-component-plugin-aj97Vt-4.mjs → lazy-load-component-plugin-DEu-DfZt.mjs} +2 -2
  39. package/dist/{lazy-load-component-plugin-BjMVNoep.js → lazy-load-component-plugin-FKp6nQa-.js} +2 -2
  40. package/dist/lazy-load-component-plugin.cjs.js +2 -2
  41. package/dist/lazy-load-component-plugin.d.ts +2 -16
  42. package/dist/lazy-load-component-plugin.es.js +2 -2
  43. package/dist/lazy-utils.cjs.js +1 -1
  44. package/dist/lazy-utils.d.ts +1 -149
  45. package/dist/lazy-utils.es.js +2 -2
  46. package/dist/plugin.d.ts +2 -22
  47. package/dist/plugins/lazy-load-component-plugin.d.ts +12 -0
  48. package/dist/plugins/lazy-load-component-plugin.spec.d.ts +1 -0
  49. package/dist/{prefetch-BwRDb4SJ.mjs → prefetch-CTZuFBqh.mjs} +314 -1
  50. package/dist/{prefetch-DLhPTofn.js → prefetch-D66kL1aM.js} +314 -1
  51. package/dist/provider/context.d.ts +3 -0
  52. package/dist/provider/plugin.d.ts +7 -0
  53. package/dist/provider/versions/bridge-base.d.ts +5 -0
  54. package/dist/provider/versions/legacy.d.ts +26 -0
  55. package/dist/provider/versions/v18.d.ts +19 -0
  56. package/dist/provider/versions/v19.d.ts +21 -0
  57. package/dist/remote/RemoteAppWrapper.d.ts +7 -0
  58. package/dist/remote/base-component/component.d.ts +2 -0
  59. package/dist/remote/base-component/create.d.ts +9 -0
  60. package/dist/remote/base-component/index.d.ts +5 -0
  61. package/dist/remote/createHelpers.d.ts +17 -0
  62. package/dist/remote/router-component/component.d.ts +8 -0
  63. package/dist/remote/router-component/create.d.ts +9 -0
  64. package/dist/remote/router-component/index.d.ts +5 -0
  65. package/dist/router/default.d.ts +7 -0
  66. package/dist/router/v5.d.ts +4 -0
  67. package/dist/router/v6.d.ts +7 -0
  68. package/dist/router/v7.d.ts +6 -0
  69. package/dist/router-v5.d.ts +1 -17
  70. package/dist/router-v6.d.ts +1 -20
  71. package/dist/router-v7.d.ts +1 -19
  72. package/dist/router.d.ts +1 -20
  73. package/dist/shared/size-limited-cache.d.ts +29 -0
  74. package/dist/shared/size-limited-cache.spec.d.ts +1 -0
  75. package/dist/size-limited-cache.cjs.js +82 -0
  76. package/dist/size-limited-cache.d.ts +1 -0
  77. package/dist/size-limited-cache.es.js +82 -0
  78. package/dist/types.d.ts +137 -0
  79. package/dist/utils/index.d.ts +4 -0
  80. package/dist/utils-5dGErM3C.js +588 -0
  81. package/dist/utils-BBP3hEeV.mjs +589 -0
  82. package/dist/v18.cjs.js +1 -1
  83. package/dist/v18.d.ts +3 -114
  84. package/dist/v18.es.js +1 -1
  85. package/dist/v19.cjs.js +1 -1
  86. package/dist/v19.d.ts +3 -115
  87. package/dist/v19.es.js +1 -1
  88. package/package.json +16 -11
  89. package/dist/utils-CFTy4LVE.js +0 -2029
  90. package/dist/utils-DGS4pYp8.mjs +0 -2030
@@ -0,0 +1,3 @@
1
+ import React from 'react';
2
+ import { ProviderParams } from '../types';
3
+ export declare const RouterContext: React.Context<ProviderParams | null>;
@@ -0,0 +1,7 @@
1
+ import type { ModuleFederationRuntimePlugin, ModuleFederation } from '@module-federation/runtime';
2
+ export type FederationRuntimeType = {
3
+ instance: ModuleFederation | null;
4
+ };
5
+ export declare const federationRuntime: FederationRuntimeType;
6
+ declare function BridgeReactPlugin(): ModuleFederationRuntimePlugin;
7
+ export default BridgeReactPlugin;
@@ -0,0 +1,5 @@
1
+ import type { ProviderFnParams, DestroyParams, RenderParams } from '../../types';
2
+ export declare function createBaseBridgeComponent<T>({ createRoot, defaultRootOptions, ...bridgeInfo }: ProviderFnParams<T>): () => {
3
+ render(info: RenderParams): Promise<void>;
4
+ destroy(info: DestroyParams): void;
5
+ };
@@ -0,0 +1,26 @@
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
+ import type { ProviderFnParams } from '../../types';
6
+ export interface CreateRootOptions {
7
+ identifierPrefix?: string;
8
+ onRecoverableError?: (error: unknown, errorInfo: unknown) => void;
9
+ }
10
+ export interface Root {
11
+ render(children: React.ReactNode): void;
12
+ unmount(): void;
13
+ }
14
+ /**
15
+ * Default createRoot function that automatically detects React version and uses the appropriate API(only support React 16/17, 18)
16
+ *
17
+ * Note: Users can also directly import version-specific bridge components:
18
+ * - import { createBridgeComponent } from '@module-federation/bridge-react'
19
+ * - import { createBridgeComponent } from '@module-federation/bridge-react/v18'
20
+ * - import { createBridgeComponent } from '@module-federation/bridge-react/v19'
21
+ */
22
+ export declare function createReact16Or17Root(container: Element | DocumentFragment): Root;
23
+ export declare function createBridgeComponent<T = any>(bridgeInfo: Omit<ProviderFnParams<T>, 'createRoot'>): () => {
24
+ render(info: import("../..").RenderParams): Promise<void>;
25
+ destroy(info: import("../..").DestroyParams): void;
26
+ };
@@ -0,0 +1,19 @@
1
+ /**
2
+ * Entry point for React 18 specific bridge components
3
+ */
4
+ import React from 'react';
5
+ import type { ProviderFnParams } from '../../types';
6
+ export interface CreateRootOptions {
7
+ identifierPrefix?: string;
8
+ onRecoverableError?: (error: unknown, errorInfo: unknown) => void;
9
+ }
10
+ export interface Root {
11
+ render(children: React.ReactNode): void;
12
+ unmount(): void;
13
+ }
14
+ export declare function createReact18Root(container: Element | DocumentFragment, options?: CreateRootOptions): Root;
15
+ export declare function hydrateReact18Root(container: Element | DocumentFragment, initialChildren: React.ReactNode, options?: CreateRootOptions): import("node_modules/@types/react-dom/client").Root;
16
+ export declare function createBridgeComponent<T = any>(bridgeInfo: Omit<ProviderFnParams<T>, 'createRoot'>): () => {
17
+ render(info: import("../..").RenderParams): Promise<void>;
18
+ destroy(info: import("../..").DestroyParams): void;
19
+ };
@@ -0,0 +1,21 @@
1
+ /**
2
+ * Entry point for React 19 specific bridge components
3
+ * This file provides support for React 19 version, using the new ReactDOM.createRoot API
4
+ */
5
+ import React from 'react';
6
+ import type { ProviderFnParams } from '../../types';
7
+ export interface CreateRootOptions {
8
+ identifierPrefix?: string;
9
+ onRecoverableError?: (error: unknown, errorInfo: unknown) => void;
10
+ transitionCallbacks?: unknown;
11
+ }
12
+ export interface Root {
13
+ render(children: React.ReactNode): void;
14
+ unmount(): void;
15
+ }
16
+ export declare function createReact19Root(container: Element | DocumentFragment, options?: CreateRootOptions): Root;
17
+ export declare function hydrateReact19Root(container: Element | DocumentFragment, initialChildren: React.ReactNode, options?: CreateRootOptions): Root;
18
+ export declare function createBridgeComponent<T = any>(bridgeInfo: Omit<ProviderFnParams<T>, 'createRoot'>): () => {
19
+ render(info: import("../..").RenderParams): Promise<void>;
20
+ destroy(info: import("../..").DestroyParams): void;
21
+ };
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Shared RemoteAppWrapper component used by both base and router versions
3
+ * This component handles the lifecycle of remote Module Federation apps
4
+ */
5
+ import React from 'react';
6
+ import { RemoteComponentProps, RemoteAppParams } from '../types';
7
+ export declare const RemoteAppWrapper: React.ForwardRefExoticComponent<Omit<RemoteAppParams & RemoteComponentProps<Record<string, unknown>>, "ref"> & React.RefAttributes<unknown>>;
@@ -0,0 +1,2 @@
1
+ import { RemoteAppWrapper } from '../RemoteAppWrapper';
2
+ export default RemoteAppWrapper;
@@ -0,0 +1,9 @@
1
+ import { type LazyRemoteComponentInfo } from '../createHelpers';
2
+ export type { LazyRemoteComponentInfo };
3
+ declare const createLazyRemoteComponent: <T = Record<string, unknown>, E extends keyof T = keyof T>(info: LazyRemoteComponentInfo<T, E>) => import("node_modules/@types/react").LazyExoticComponent<import("node_modules/@types/react").ForwardRefExoticComponent<Omit<import("../..").RemoteComponentProps<Record<string, unknown>>, "ref"> & import("node_modules/@types/react").RefAttributes<HTMLDivElement>>>;
4
+ export declare const createRemoteAppComponent: <T = Record<string, unknown>, E extends keyof T = keyof T>(info: LazyRemoteComponentInfo<T, E>) => import("node_modules/@types/react").ForwardRefExoticComponent<Omit<import("../..").RemoteComponentProps<Record<string, unknown>>, "ref"> & import("node_modules/@types/react").RefAttributes<HTMLDivElement>>;
5
+ /**
6
+ * @deprecated createRemoteComponent is deprecated, please use createRemoteAppComponent instead!
7
+ */
8
+ export declare const createRemoteComponent: <T = Record<string, unknown>, E extends keyof T = keyof T>(info: LazyRemoteComponentInfo<T, E>) => any;
9
+ export { createLazyRemoteComponent };
@@ -0,0 +1,5 @@
1
+ /**
2
+ * Base entry point without React Router dependencies
3
+ * Re-exports from base/create.tsx
4
+ */
5
+ export { createRemoteAppComponent, createRemoteComponent, createLazyRemoteComponent, type LazyRemoteComponentInfo, } from './create';
@@ -0,0 +1,17 @@
1
+ import React from 'react';
2
+ import { RemoteComponentParams, RemoteComponentProps } from '../types';
3
+ export type LazyRemoteComponentInfo<T, _E extends keyof T> = RemoteComponentParams<T>;
4
+ /**
5
+ * Creates a factory function for creating lazy remote components
6
+ * @param RemoteApp The RemoteAppWrapper component to use (with or without router)
7
+ */
8
+ export declare function createLazyRemoteComponentFactory(RemoteApp: React.ComponentType<any>): <T = Record<string, unknown>, E extends keyof T = keyof T>(info: LazyRemoteComponentInfo<T, E>) => React.LazyExoticComponent<React.ForwardRefExoticComponent<Omit<RemoteComponentProps<Record<string, unknown>>, "ref"> & React.RefAttributes<HTMLDivElement>>>;
9
+ /**
10
+ * Creates a factory function for creating remote app components
11
+ * @param RemoteApp The RemoteAppWrapper component to use (with or without router)
12
+ */
13
+ export declare function createRemoteAppComponentFactory(RemoteApp: React.ComponentType<any>): <T = Record<string, unknown>, E extends keyof T = keyof T>(info: LazyRemoteComponentInfo<T, E>) => React.ForwardRefExoticComponent<Omit<RemoteComponentProps<Record<string, unknown>>, "ref"> & React.RefAttributes<HTMLDivElement>>;
14
+ /**
15
+ * Creates the deprecated createRemoteComponent function
16
+ */
17
+ export declare function createDeprecatedRemoteComponentFactory<T = Record<string, unknown>, E extends keyof T = keyof T>(createFn: (info: LazyRemoteComponentInfo<T, E>) => any): (info: LazyRemoteComponentInfo<T, E>) => any;
@@ -0,0 +1,8 @@
1
+ import React from 'react';
2
+ import { RemoteAppWrapper } from '../RemoteAppWrapper';
3
+ interface ExtraDataProps {
4
+ basename?: string;
5
+ }
6
+ export declare function withRouterData<P extends Parameters<typeof RemoteAppWrapper>[0]>(WrappedComponent: React.ComponentType<P & ExtraDataProps>): React.FC<Omit<P, keyof ExtraDataProps>>;
7
+ declare const _default: React.FC<Omit<Omit<import("../../types").RemoteAppParams & import("../..").RemoteComponentProps<Record<string, unknown>>, "ref"> & React.RefAttributes<unknown>, "basename">>;
8
+ export default _default;
@@ -0,0 +1,9 @@
1
+ import { type LazyRemoteComponentInfo } from '../createHelpers';
2
+ export type { LazyRemoteComponentInfo };
3
+ declare const createLazyRemoteComponent: <T = Record<string, unknown>, E extends keyof T = keyof T>(info: LazyRemoteComponentInfo<T, E>) => import("node_modules/@types/react").LazyExoticComponent<import("node_modules/@types/react").ForwardRefExoticComponent<Omit<import("../..").RemoteComponentProps<Record<string, unknown>>, "ref"> & import("node_modules/@types/react").RefAttributes<HTMLDivElement>>>;
4
+ export declare const createRemoteAppComponent: <T = Record<string, unknown>, E extends keyof T = keyof T>(info: LazyRemoteComponentInfo<T, E>) => import("node_modules/@types/react").ForwardRefExoticComponent<Omit<import("../..").RemoteComponentProps<Record<string, unknown>>, "ref"> & import("node_modules/@types/react").RefAttributes<HTMLDivElement>>;
5
+ /**
6
+ * @deprecated createRemoteComponent is deprecated, please use createRemoteAppComponent instead!
7
+ */
8
+ export declare const createRemoteComponent: <T = Record<string, unknown>, E extends keyof T = keyof T>(info: LazyRemoteComponentInfo<T, E>) => any;
9
+ export { createLazyRemoteComponent };
@@ -0,0 +1,5 @@
1
+ /**
2
+ * Default entry point with React Router support
3
+ * Re-exports from router/create.tsx
4
+ */
5
+ export { createRemoteAppComponent, createRemoteComponent, createLazyRemoteComponent, type LazyRemoteComponentInfo, } from './create';
@@ -0,0 +1,7 @@
1
+ import React from 'react';
2
+ import * as ReactRouterDom from 'react-router-dom/';
3
+ declare function WrapperRouter(props: Parameters<typeof ReactRouterDom.BrowserRouter>[0] | Parameters<typeof ReactRouterDom.MemoryRouter>[0]): React.JSX.Element;
4
+ declare function WrapperRouterProvider(props: Parameters<typeof ReactRouterDom.RouterProvider>[0]): React.JSX.Element;
5
+ export * from 'react-router-dom/';
6
+ export { WrapperRouter as BrowserRouter };
7
+ export { WrapperRouterProvider as RouterProvider };
@@ -0,0 +1,4 @@
1
+ import React from 'react';
2
+ declare function WraperRouter(props: Record<string, unknown>): React.JSX.Element;
3
+ export * from 'react-router-dom/';
4
+ export { WraperRouter as BrowserRouter };
@@ -0,0 +1,7 @@
1
+ import React from 'react';
2
+ import * as ReactRouterDom from 'react-router-dom/dist/index.js';
3
+ declare function WraperRouter(props: Parameters<typeof ReactRouterDom.BrowserRouter>[0] | Parameters<typeof ReactRouterDom.MemoryRouter>[0]): React.JSX.Element;
4
+ declare function WraperRouterProvider(props: Parameters<typeof ReactRouterDom.RouterProvider>[0]): React.JSX.Element;
5
+ export * from 'react-router-dom/';
6
+ export { WraperRouter as BrowserRouter };
7
+ export { WraperRouterProvider as RouterProvider };
@@ -0,0 +1,6 @@
1
+ import React from 'react';
2
+ declare function WraperRouter(props: Record<string, unknown>): React.JSX.Element;
3
+ declare function WraperRouterProvider(props: Record<string, unknown>): React.JSX.Element;
4
+ export * from 'react-router';
5
+ export { WraperRouter as BrowserRouter };
6
+ export { WraperRouterProvider as RouterProvider };
@@ -1,17 +1 @@
1
- import { default as default_2 } from 'react';
2
-
3
- export declare function BrowserRouter(props: Record<string, unknown>): default_2.JSX.Element;
4
-
5
-
6
- export * from "react-router-dom/";
7
-
8
- export { }
9
-
10
-
11
- declare module '@module-federation/runtime-core' {
12
- interface ModuleFederation {
13
- createLazyComponent<T, E extends keyof T>(options: Omit<CreateLazyComponentOptions<T, E>, 'instance'>): ReturnType<typeof createLazyComponent<T, E>>;
14
- prefetch(options: Omit<PrefetchOptions, 'instance'>): ReturnType<typeof prefetch>;
15
- collectSSRAssets(options: Omit<Parameters<typeof collectSSRAssets>[0], 'instance'>): ReturnType<typeof collectSSRAssets>;
16
- }
17
- }
1
+ export * from './router/v5';
@@ -1,20 +1 @@
1
- import { default as default_2 } from 'react';
2
- import * as ReactRouterDom from 'react-router-dom/dist/index.js';
3
-
4
- export declare function BrowserRouter(props: Parameters<typeof ReactRouterDom.BrowserRouter>[0] | Parameters<typeof ReactRouterDom.MemoryRouter>[0]): default_2.JSX.Element;
5
-
6
- export declare function RouterProvider(props: Parameters<typeof ReactRouterDom.RouterProvider>[0]): default_2.JSX.Element;
7
-
8
-
9
- export * from "react-router-dom/";
10
-
11
- export { }
12
-
13
-
14
- declare module '@module-federation/runtime-core' {
15
- interface ModuleFederation {
16
- createLazyComponent<T, E extends keyof T>(options: Omit<CreateLazyComponentOptions<T, E>, 'instance'>): ReturnType<typeof createLazyComponent<T, E>>;
17
- prefetch(options: Omit<PrefetchOptions, 'instance'>): ReturnType<typeof prefetch>;
18
- collectSSRAssets(options: Omit<Parameters<typeof collectSSRAssets>[0], 'instance'>): ReturnType<typeof collectSSRAssets>;
19
- }
20
- }
1
+ export * from './router/v6';
@@ -1,19 +1 @@
1
- import { default as default_2 } from 'react';
2
-
3
- export declare function BrowserRouter(props: Record<string, unknown>): default_2.JSX.Element;
4
-
5
- export declare function RouterProvider(props: Record<string, unknown>): default_2.JSX.Element;
6
-
7
-
8
- export * from "react-router";
9
-
10
- export { }
11
-
12
-
13
- declare module '@module-federation/runtime-core' {
14
- interface ModuleFederation {
15
- createLazyComponent<T, E extends keyof T>(options: Omit<CreateLazyComponentOptions<T, E>, 'instance'>): ReturnType<typeof createLazyComponent<T, E>>;
16
- prefetch(options: Omit<PrefetchOptions, 'instance'>): ReturnType<typeof prefetch>;
17
- collectSSRAssets(options: Omit<Parameters<typeof collectSSRAssets>[0], 'instance'>): ReturnType<typeof collectSSRAssets>;
18
- }
19
- }
1
+ export * from './router/v7';
package/dist/router.d.ts CHANGED
@@ -1,20 +1 @@
1
- import { default as default_2 } from 'react';
2
- import * as ReactRouterDom from 'react-router-dom/';
3
-
4
- export declare function BrowserRouter(props: Parameters<typeof ReactRouterDom.BrowserRouter>[0] | Parameters<typeof ReactRouterDom.MemoryRouter>[0]): default_2.JSX.Element;
5
-
6
- export declare function RouterProvider(props: Parameters<typeof ReactRouterDom.RouterProvider>[0]): default_2.JSX.Element;
7
-
8
-
9
- export * from "react-router-dom/";
10
-
11
- export { }
12
-
13
-
14
- declare module '@module-federation/runtime-core' {
15
- interface ModuleFederation {
16
- createLazyComponent<T, E extends keyof T>(options: Omit<CreateLazyComponentOptions<T, E>, 'instance'>): ReturnType<typeof createLazyComponent<T, E>>;
17
- prefetch(options: Omit<PrefetchOptions, 'instance'>): ReturnType<typeof prefetch>;
18
- collectSSRAssets(options: Omit<Parameters<typeof collectSSRAssets>[0], 'instance'>): ReturnType<typeof collectSSRAssets>;
19
- }
20
- }
1
+ export * from './router/default';
@@ -0,0 +1,29 @@
1
+ export interface SizeLimitedCacheOptions<K, V> {
2
+ maxSize: number;
3
+ sizeCalculation?: (value: V, key: K) => number;
4
+ }
5
+ export interface SizeLimitedCacheSetOptions {
6
+ size?: number;
7
+ }
8
+ /**
9
+ * A small, size-aware least-recently-used cache.
10
+ *
11
+ * This intentionally implements only the operations used by federation
12
+ * packages. Reading or checking an entry refreshes its recency.
13
+ */
14
+ export declare class SizeLimitedCache<K, V> {
15
+ readonly maxSize: number;
16
+ private readonly entries;
17
+ private readonly sizeCalculation?;
18
+ private currentSize;
19
+ constructor(options: SizeLimitedCacheOptions<K, V>);
20
+ get size(): number;
21
+ get calculatedSize(): number;
22
+ get(key: K): V | undefined;
23
+ has(key: K): boolean;
24
+ set(key: K, value: V, options?: SizeLimitedCacheSetOptions): this;
25
+ delete(key: K): boolean;
26
+ clear(): void;
27
+ private refresh;
28
+ private evictUntilWithinLimit;
29
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,82 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
4
+ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
5
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
6
+ class SizeLimitedCache {
7
+ constructor(options) {
8
+ __publicField(this, "maxSize");
9
+ __publicField(this, "entries", /* @__PURE__ */ new Map());
10
+ __publicField(this, "sizeCalculation");
11
+ __publicField(this, "currentSize", 0);
12
+ if (!Number.isInteger(options.maxSize) || options.maxSize <= 0) {
13
+ throw new TypeError("maxSize must be a positive integer");
14
+ }
15
+ this.maxSize = options.maxSize;
16
+ this.sizeCalculation = options.sizeCalculation;
17
+ }
18
+ get size() {
19
+ return this.entries.size;
20
+ }
21
+ get calculatedSize() {
22
+ return this.currentSize;
23
+ }
24
+ get(key) {
25
+ const entry = this.entries.get(key);
26
+ if (!entry) {
27
+ return void 0;
28
+ }
29
+ this.refresh(key, entry);
30
+ return entry.value;
31
+ }
32
+ has(key) {
33
+ const entry = this.entries.get(key);
34
+ if (!entry) {
35
+ return false;
36
+ }
37
+ this.refresh(key, entry);
38
+ return true;
39
+ }
40
+ set(key, value, options = {}) {
41
+ var _a;
42
+ const entrySize = options.size ?? ((_a = this.sizeCalculation) == null ? void 0 : _a.call(this, value, key)) ?? 1;
43
+ if (!Number.isInteger(entrySize) || entrySize <= 0) {
44
+ throw new TypeError("entry size must be a positive integer");
45
+ }
46
+ this.delete(key);
47
+ if (entrySize > this.maxSize) {
48
+ return this;
49
+ }
50
+ this.entries.set(key, { value, size: entrySize });
51
+ this.currentSize += entrySize;
52
+ this.evictUntilWithinLimit();
53
+ return this;
54
+ }
55
+ delete(key) {
56
+ const entry = this.entries.get(key);
57
+ if (!entry) {
58
+ return false;
59
+ }
60
+ this.currentSize -= entry.size;
61
+ return this.entries.delete(key);
62
+ }
63
+ clear() {
64
+ this.entries.clear();
65
+ this.currentSize = 0;
66
+ }
67
+ refresh(key, entry) {
68
+ this.entries.delete(key);
69
+ this.entries.set(key, entry);
70
+ }
71
+ evictUntilWithinLimit() {
72
+ while (this.currentSize > this.maxSize) {
73
+ const oldest = this.entries.keys().next();
74
+ if (oldest.done) {
75
+ this.currentSize = 0;
76
+ return;
77
+ }
78
+ this.delete(oldest.value);
79
+ }
80
+ }
81
+ }
82
+ exports.SizeLimitedCache = SizeLimitedCache;
@@ -0,0 +1 @@
1
+ export * from './shared/size-limited-cache';
@@ -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
+ };
@@ -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;