@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
package/dist/index.es.js CHANGED
@@ -1,12 +1,12 @@
1
- import { R as RemoteAppWrapper, c as createRemoteAppComponentFactory, a as createDeprecatedRemoteComponentFactory } from "./createHelpers-BY5Uj9_Z.mjs";
2
- import { b } from "./createHelpers-BY5Uj9_Z.mjs";
3
- import { a, c, b as b2, l } from "./lazy-load-component-plugin-aj97Vt-4.mjs";
4
- import { C, a as a2, E, c as c2, b as b3, d, g, r, s } from "./utils-DGS4pYp8.mjs";
1
+ import { R as RemoteAppWrapper, c as createRemoteAppComponentFactory, a as createDeprecatedRemoteComponentFactory } from "./createHelpers-BSHeKyd-.mjs";
2
+ import { b } from "./createHelpers-BSHeKyd-.mjs";
3
+ import { a, c, b as b2, l } from "./lazy-load-component-plugin-DEu-DfZt.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
6
  import React__default, { forwardRef, useContext, useState, useEffect } from "react";
7
7
  import * as ReactRouterDOM from "react-router-dom";
8
8
  import { p as pathJoin, L as LoggerInstance } from "./index-Bs2NxD2z.mjs";
9
- import { p } from "./prefetch-BwRDb4SJ.mjs";
9
+ import { p } from "./prefetch-CTZuFBqh.mjs";
10
10
  function e() {
11
11
  const t = new PopStateEvent("popstate", { state: window.history.state });
12
12
  window.dispatchEvent(t);
@@ -0,0 +1,24 @@
1
+ import React, { ReactNode } from 'react';
2
+ import type { DataFetchParams } from './types';
3
+ export type ErrorInfo = {
4
+ error: Error;
5
+ errorType: number;
6
+ dataFetchMapKey?: string;
7
+ };
8
+ export declare const transformError: (err: string | Error) => ErrorInfo;
9
+ export interface AwaitProps<T> {
10
+ resolve: T | Promise<T>;
11
+ loading?: ReactNode;
12
+ delayLoading?: number;
13
+ errorElement?: ReactNode | ((errorInfo: ErrorInfo) => ReactNode);
14
+ children: (data: T) => ReactNode;
15
+ params?: DataFetchParams;
16
+ }
17
+ export interface AwaitErrorHandlerProps<T = any> extends Omit<AwaitProps<T>, 'resolve'> {
18
+ resolve: () => T | string;
19
+ }
20
+ export declare function AwaitDataFetch<T>({ resolve, loading, errorElement, children, params, delayLoading, }: AwaitProps<T>): React.JSX.Element;
21
+ export declare const DelayedLoading: ({ delayLoading, children, }: {
22
+ delayLoading?: number;
23
+ children: ReactNode;
24
+ }) => ReactNode;
@@ -0,0 +1,26 @@
1
+ export declare const PLUGIN_IDENTIFIER = "[ Module Federation React ]";
2
+ export declare const DOWNGRADE_KEY = "_mfSSRDowngrade";
3
+ export declare const DATA_FETCH_MAP_KEY = "__MF_DATA_FETCH_MAP__";
4
+ export declare const DATA_FETCH_FUNCTION = "_mfDataFetch";
5
+ export declare const FS_HREF = "_mfFSHref";
6
+ export declare const ERROR_TYPE: {
7
+ DATA_FETCH: number;
8
+ LOAD_REMOTE: number;
9
+ UNKNOWN: number;
10
+ };
11
+ export declare const WRAP_DATA_FETCH_ID_IDENTIFIER = "wrap_dfip_identifier";
12
+ export declare const enum MF_DATA_FETCH_TYPE {
13
+ FETCH_SERVER = 1,
14
+ FETCH_CLIENT = 2
15
+ }
16
+ export declare const enum MF_DATA_FETCH_STATUS {
17
+ LOADED = 1,
18
+ LOADING = 2,
19
+ AWAIT = 0,
20
+ ERROR = 3
21
+ }
22
+ export declare const DATA_FETCH_IDENTIFIER = "data";
23
+ export declare const DATA_FETCH_CLIENT_SUFFIX = ".client";
24
+ export declare const DATA_FETCH_QUERY = "x-mf-data-fetch";
25
+ export declare const DATA_FETCH_ERROR_PREFIX = "caught the following error during dataFetch: ";
26
+ export declare const LOAD_REMOTE_ERROR_PREFIX = "caught the following error during loadRemote: ";
@@ -0,0 +1,28 @@
1
+ import type { getInstance } from '@module-federation/runtime';
2
+ import React, { ReactNode } from 'react';
3
+ import type { ErrorInfo } from './AwaitDataFetch';
4
+ import type { DataFetchParams } from './types';
5
+ export type IProps = {
6
+ id: string;
7
+ instance: ReturnType<typeof getInstance>;
8
+ injectScript?: boolean;
9
+ injectLink?: boolean;
10
+ };
11
+ export type CreateLazyComponentOptions<T, E extends keyof T> = {
12
+ loader: () => Promise<T>;
13
+ instance: ReturnType<typeof getInstance>;
14
+ loading: React.ReactNode;
15
+ delayLoading?: number;
16
+ fallback: ReactNode | ((errorInfo: ErrorInfo) => ReactNode);
17
+ export?: E;
18
+ dataFetchParams?: DataFetchParams;
19
+ noSSR?: boolean;
20
+ injectScript?: boolean;
21
+ injectLink?: boolean;
22
+ };
23
+ type ReactKey = {
24
+ key?: React.Key | null;
25
+ };
26
+ export declare function collectSSRAssets(options: IProps): ReactNode[];
27
+ 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) => React.JSX.Element;
28
+ export {};
@@ -0,0 +1,34 @@
1
+ import type { CacheConfig, DataFetch, DataFetchParams } from '../types';
2
+ export declare const CacheSize: {
3
+ readonly KB: 1024;
4
+ readonly MB: number;
5
+ readonly GB: number;
6
+ };
7
+ export declare const CacheTime: {
8
+ readonly SECOND: 1000;
9
+ readonly MINUTE: number;
10
+ readonly HOUR: number;
11
+ readonly DAY: number;
12
+ readonly WEEK: number;
13
+ readonly MONTH: number;
14
+ };
15
+ export type CacheStatus = 'hit' | 'stale' | 'miss';
16
+ export interface CacheStatsInfo {
17
+ status: CacheStatus;
18
+ key: string | symbol;
19
+ params: DataFetchParams;
20
+ result: any;
21
+ }
22
+ interface CacheOptions {
23
+ tag?: string | string[];
24
+ maxAge?: number;
25
+ revalidate?: number;
26
+ getKey?: <Args extends any[]>(...args: Args) => string;
27
+ onCache?: (info: CacheStatsInfo) => boolean;
28
+ }
29
+ export declare function configureCache(config: CacheConfig): void;
30
+ export declare function generateKey(dataFetchOptions: DataFetchParams): string;
31
+ export declare function cache<T>(fn: DataFetch<T>, options?: CacheOptions): DataFetch<T>;
32
+ export declare function revalidateTag(tag: string): void;
33
+ export declare function clearStore(): void;
34
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export declare function callDataFetch(): Promise<void>;
@@ -0,0 +1,3 @@
1
+ import type { MiddlewareHandler } from 'hono';
2
+ declare const dataFetchServerMiddleware: MiddlewareHandler;
3
+ export default dataFetchServerMiddleware;
@@ -0,0 +1,6 @@
1
+ export { callDataFetch } from './call-data-fetch';
2
+ export { injectDataFetch } from './inject-data-fetch';
3
+ export { CacheSize, CacheTime, configureCache, generateKey, cache, revalidateTag, clearStore, } from './cache';
4
+ export type { CacheStatus, CacheStatsInfo } from './cache';
5
+ export type { PrefetchOptions } from './prefetch';
6
+ export { prefetch } from './prefetch';
@@ -0,0 +1,4 @@
1
+ import { dataFetchFunctionOptions } from '../types';
2
+ declare const dataFetchFunction: (options: dataFetchFunctionOptions) => Promise<unknown>;
3
+ export declare function injectDataFetch(): void;
4
+ export { dataFetchFunction };
@@ -0,0 +1,9 @@
1
+ import type { getInstance } from '@module-federation/runtime';
2
+ import { DataFetchParams } from '../types';
3
+ export type PrefetchOptions = {
4
+ id: string;
5
+ instance: ReturnType<typeof getInstance>;
6
+ dataFetchParams?: DataFetchParams;
7
+ preloadComponentResource?: boolean;
8
+ };
9
+ export declare function prefetch(options: PrefetchOptions): Promise<void>;
@@ -0,0 +1,3 @@
1
+ import type { ModuleFederationRuntimePlugin } from '@module-federation/runtime';
2
+ declare const autoFetchData: () => ModuleFederationRuntimePlugin;
3
+ export default autoFetchData;
@@ -0,0 +1,9 @@
1
+ import autoFetchDataPlugin from './data-fetch/runtime-plugin';
2
+ export { ERROR_TYPE } from './constant';
3
+ export type { DataFetchParams, NoSSRRemoteInfo } from './types';
4
+ export type { CreateLazyComponentOptions, IProps as CollectSSRAssetsOptions, } from './createLazyComponent';
5
+ export { createLazyComponent, collectSSRAssets } from './createLazyComponent';
6
+ export { injectDataFetch, callDataFetch, CacheSize, CacheTime, configureCache, generateKey, cache, revalidateTag, clearStore, prefetch, } from './data-fetch';
7
+ export { setSSREnv } from './utils';
8
+ export { autoFetchDataPlugin };
9
+ export type { CacheStatus, CacheStatsInfo, PrefetchOptions, } from './data-fetch';
@@ -0,0 +1,2 @@
1
+ declare const logger: import("@module-federation/sdk").Logger;
2
+ export default logger;
@@ -0,0 +1,60 @@
1
+ import { MF_DATA_FETCH_TYPE, MF_DATA_FETCH_STATUS } from './constant';
2
+ import type { SizeLimitedCache } from '../shared/size-limited-cache';
3
+ export type dataFetchFunctionOptions = [
4
+ id?: string,
5
+ data?: unknown,
6
+ downgrade?: boolean
7
+ ];
8
+ declare global {
9
+ var _mfSSRDowngrade: string[] | true | undefined;
10
+ var __MF_DATA_FETCH_MAP__: MF_DATA_FETCH_MAP | undefined;
11
+ var FEDERATION_SERVER_QUERY: Record<string, unknown> | undefined;
12
+ var FEDERATION_SSR: boolean | undefined;
13
+ var _mfFSHref: string | undefined;
14
+ var _mfDataFetch: Array<dataFetchFunctionOptions> | undefined;
15
+ var __MF_DATA_FETCH_CACHE__: MF_DATA_FETCH_CACHE | undefined;
16
+ }
17
+ export interface CacheItem<T> {
18
+ data: T;
19
+ timestamp: number;
20
+ isRevalidating?: boolean;
21
+ }
22
+ export type DataFetchParams = {
23
+ isDowngrade: boolean;
24
+ _id?: string;
25
+ } & Record<string, unknown>;
26
+ export type DataFetch<T> = (params: DataFetchParams) => Promise<T>;
27
+ export type MF_DATA_FETCH_MAP_VALUE_PROMISE_SET = [
28
+ Promise<unknown>,
29
+ ((data: unknown) => void)?,
30
+ ((err: unknown) => void)?
31
+ ];
32
+ export type MF_DATA_FETCH_MAP_VALUE = [
33
+ [
34
+ () => Promise<DataFetch<unknown>>,
35
+ MF_DATA_FETCH_TYPE,
36
+ Promise<DataFetch<unknown>>?
37
+ ],
38
+ MF_DATA_FETCH_MAP_VALUE_PROMISE_SET?,
39
+ MF_DATA_FETCH_STATUS?
40
+ ];
41
+ export type MF_DATA_FETCH_MAP = Record<string, MF_DATA_FETCH_MAP_VALUE>;
42
+ export type MF_SSR_DOWNGRADE = string[] | true | undefined;
43
+ export type NoSSRRemoteInfo = {
44
+ name: string;
45
+ version: string;
46
+ ssrPublicPath: string;
47
+ ssrRemoteEntry: string;
48
+ globalName: string;
49
+ };
50
+ export interface CacheConfig {
51
+ maxSize?: number;
52
+ unstable_shouldDisable?: ({ request, }: {
53
+ request: Request;
54
+ }) => boolean | Promise<boolean>;
55
+ }
56
+ export type MF_DATA_FETCH_CACHE = {
57
+ cacheStore?: SizeLimitedCache<string, Map<string, CacheItem<any>>>;
58
+ tagKeyMap?: Map<string, Set<string>>;
59
+ cacheConfig?: CacheConfig;
60
+ };
@@ -0,0 +1,48 @@
1
+ import type { GlobalModuleInfo } from '@module-federation/sdk';
2
+ import type { DataFetchParams, MF_DATA_FETCH_MAP, NoSSRRemoteInfo, MF_SSR_DOWNGRADE, MF_DATA_FETCH_CACHE } from './types';
3
+ import type { ModuleFederation } from '@module-federation/runtime';
4
+ export declare const getDataFetchInfo: ({ name, alias, id, remoteSnapshot, }: {
5
+ id: string;
6
+ name: string;
7
+ remoteSnapshot: GlobalModuleInfo[string];
8
+ alias?: string;
9
+ }) => {
10
+ dataFetchName: string;
11
+ dataFetchId: string;
12
+ dataFetchKey: string;
13
+ } | undefined;
14
+ export declare function initDataFetchMap(): void;
15
+ export declare function getDataFetchItem(id: string): import("./types").MF_DATA_FETCH_MAP_VALUE;
16
+ export declare function getDataFetchMap(): MF_DATA_FETCH_MAP;
17
+ export declare function getDataFetchCache(): MF_DATA_FETCH_CACHE;
18
+ export declare const flushDataFetch: () => void;
19
+ export declare function setDataFetchItemLoadedStatus(id: string): void;
20
+ export declare const wrapDataFetchId: (id?: string) => string;
21
+ export declare const getDataFetchIdWithErrorMsgs: (errMsgs: string) => string | undefined;
22
+ export declare function fetchData(id: string, params: DataFetchParams, remoteInfo?: NoSSRRemoteInfo): Promise<unknown | undefined>;
23
+ export declare function getDataFetchMapKey(dataFetchInfo?: ReturnType<typeof getDataFetchInfo>, hostInfo?: {
24
+ name: string;
25
+ version?: string;
26
+ }): string | undefined;
27
+ export declare function loadDataFetchModule(instance: ModuleFederation, id: string): Promise<(params: DataFetchParams) => Promise<unknown>>;
28
+ export declare function isDataLoaderExpose(exposeKey: string): boolean;
29
+ export declare function getDowngradeTag(): MF_SSR_DOWNGRADE;
30
+ export declare function callAllDowngrade(): void;
31
+ export declare function callDowngrade(id: string, params?: DataFetchParams, remoteInfo?: NoSSRRemoteInfo): Promise<unknown>;
32
+ export declare function isCSROnly(): boolean;
33
+ export declare function isServerEnv(): boolean;
34
+ export declare function setSSREnv({ fetchServerQuery, }: {
35
+ fetchServerQuery?: Record<string, unknown>;
36
+ }): void;
37
+ export declare function getLoadedRemoteInfos(id: string, instance: ModuleFederation | null): {
38
+ alias?: string;
39
+ name: string;
40
+ version?: string;
41
+ buildVersion?: string;
42
+ entry: string;
43
+ type: import("@module-federation/sdk").RemoteEntryType;
44
+ entryGlobalName: string;
45
+ shareScope: string | string[];
46
+ snapshot: import("@module-federation/sdk").ManifestProvider | import("@module-federation/sdk").PureEntryProvider | import("@module-federation/sdk").ModuleInfo | undefined;
47
+ expose: string;
48
+ } | undefined;
@@ -0,0 +1,9 @@
1
+ import { createLazyComponent } from './createLazyComponent';
2
+ import type { CreateLazyComponentOptions } from './createLazyComponent';
3
+ export declare function wrapNoSSR<T, E extends keyof T>(createLazyComponentFn: typeof createLazyComponent<T, E>): (options: Omit<CreateLazyComponentOptions<T, E>, 'noSSR'>) => (props: T[E] extends (...args: any) => any ? Parameters<T[E]>[0] extends undefined ? {
4
+ key?: React.Key | null;
5
+ } : Parameters<T[E]>[0] & {
6
+ key?: React.Key | null;
7
+ } : {
8
+ key?: React.Key | null;
9
+ }) => import("node_modules/@types/react").JSX.Element;
@@ -1,5 +1,5 @@
1
- import { i as injectDataFetch, p as prefetch } from "./prefetch-BwRDb4SJ.mjs";
2
- import { i as initDataFetchMap, k as isDataLoaderExpose, m as getDataFetchInfo, n as getDataFetchMapKey, l as logger, o as getDataFetchItem, p as DATA_FETCH_CLIENT_SUFFIX, q as MF_DATA_FETCH_TYPE, t as isCSROnly, M as MF_DATA_FETCH_STATUS, j as loadDataFetchModule, e as getDataFetchMap, u as isServerEnv, v as getDataFetchIdWithErrorMsgs, w as DATA_FETCH_ERROR_PREFIX, E as ERROR_TYPE, x as wrapDataFetchId, L as LOAD_REMOTE_ERROR_PREFIX, y as DATA_FETCH_FUNCTION, z as getLoadedRemoteInfos, h as fetchData$1, A as setDataFetchItemLoadedStatus, F as FS_HREF } from "./utils-DGS4pYp8.mjs";
1
+ import { i as injectDataFetch, p as prefetch } from "./prefetch-CTZuFBqh.mjs";
2
+ import { i as initDataFetchMap, k as isDataLoaderExpose, m as getDataFetchInfo, n as getDataFetchMapKey, l as logger, o as getDataFetchItem, p as DATA_FETCH_CLIENT_SUFFIX, q as MF_DATA_FETCH_TYPE, t as isCSROnly, M as MF_DATA_FETCH_STATUS, j as loadDataFetchModule, e as getDataFetchMap, u as isServerEnv, v as getDataFetchIdWithErrorMsgs, w as DATA_FETCH_ERROR_PREFIX, E as ERROR_TYPE, x as wrapDataFetchId, L as LOAD_REMOTE_ERROR_PREFIX, y as DATA_FETCH_FUNCTION, z as getLoadedRemoteInfos, h as fetchData$1, A as setDataFetchItemLoadedStatus, F as FS_HREF } from "./utils-BBP3hEeV.mjs";
3
3
  import React__default, { useRef, useState, Suspense, useEffect } from "react";
4
4
  const autoFetchData = () => {
5
5
  initDataFetchMap();
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
- const prefetch = require("./prefetch-DLhPTofn.js");
3
- const lazyUtils = require("./utils-CFTy4LVE.js");
2
+ const prefetch = require("./prefetch-D66kL1aM.js");
3
+ const lazyUtils = require("./utils-5dGErM3C.js");
4
4
  const React = require("react");
5
5
  const autoFetchData = () => {
6
6
  lazyUtils.initDataFetchMap();
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: "Module" } });
3
- const lazyLoadComponentPlugin = require("./lazy-load-component-plugin-BjMVNoep.js");
4
- require("./prefetch-DLhPTofn.js");
3
+ const lazyLoadComponentPlugin = require("./lazy-load-component-plugin-FKp6nQa-.js");
4
+ require("./prefetch-D66kL1aM.js");
5
5
  exports.default = lazyLoadComponentPlugin.lazyLoadComponentPlugin;
6
6
  exports.lazyLoadComponentPlugin = lazyLoadComponentPlugin.lazyLoadComponentPlugin;
@@ -1,16 +1,2 @@
1
- import { ModuleFederationRuntimePlugin } from '@module-federation/runtime';
2
-
3
- declare function lazyLoadComponentPlugin(): ModuleFederationRuntimePlugin;
4
- export default lazyLoadComponentPlugin;
5
- export { lazyLoadComponentPlugin }
6
-
7
- export { }
8
-
9
-
10
- declare module '@module-federation/runtime-core' {
11
- interface ModuleFederation {
12
- createLazyComponent<T, E extends keyof T>(options: Omit<CreateLazyComponentOptions<T, E>, 'instance'>): ReturnType<typeof createLazyComponent<T, E>>;
13
- prefetch(options: Omit<PrefetchOptions, 'instance'>): ReturnType<typeof prefetch>;
14
- collectSSRAssets(options: Omit<Parameters<typeof collectSSRAssets>[0], 'instance'>): ReturnType<typeof collectSSRAssets>;
15
- }
16
- }
1
+ export { default } from './plugins/lazy-load-component-plugin';
2
+ export * from './plugins/lazy-load-component-plugin';
@@ -1,5 +1,5 @@
1
- import { l, l as l2 } from "./lazy-load-component-plugin-aj97Vt-4.mjs";
2
- import "./prefetch-BwRDb4SJ.mjs";
1
+ import { l, l as l2 } from "./lazy-load-component-plugin-DEu-DfZt.mjs";
2
+ import "./prefetch-CTZuFBqh.mjs";
3
3
  export {
4
4
  l as default,
5
5
  l2 as lazyLoadComponentPlugin
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
3
  require("./logger-Dxblx6P-.js");
4
- const lazyUtils = require("./utils-CFTy4LVE.js");
4
+ const lazyUtils = require("./utils-5dGErM3C.js");
5
5
  exports.callAllDowngrade = lazyUtils.callAllDowngrade;
6
6
  exports.callDowngrade = lazyUtils.callDowngrade;
7
7
  exports.fetchData = lazyUtils.fetchData;
@@ -1,149 +1 @@
1
- import { GlobalModuleInfo } from '@module-federation/sdk';
2
- import { LRUCache } from 'lru-cache';
3
- import { ManifestProvider } from '@module-federation/sdk';
4
- import { ModuleFederation } from '@module-federation/runtime';
5
- import { ModuleInfo } from '@module-federation/sdk';
6
- import { PureEntryProvider } from '@module-federation/sdk';
7
- import { RemoteEntryType } from '@module-federation/sdk';
8
-
9
- declare interface CacheConfig {
10
- maxSize?: number;
11
- unstable_shouldDisable?: ({ request, }: {
12
- request: Request;
13
- }) => boolean | Promise<boolean>;
14
- }
15
-
16
- declare interface CacheItem<T> {
17
- data: T;
18
- timestamp: number;
19
- isRevalidating?: boolean;
20
- }
21
-
22
- export declare function callAllDowngrade(): void;
23
-
24
- export declare function callDowngrade(id: string, params?: DataFetchParams, remoteInfo?: NoSSRRemoteInfo): Promise<unknown>;
25
-
26
- declare type DataFetch<T> = (params: DataFetchParams) => Promise<T>;
27
-
28
- declare type DataFetchParams = {
29
- isDowngrade: boolean;
30
- _id?: string;
31
- } & Record<string, unknown>;
32
-
33
- export declare function fetchData(id: string, params: DataFetchParams, remoteInfo?: NoSSRRemoteInfo): Promise<unknown | undefined>;
34
-
35
- export declare const flushDataFetch: () => void;
36
-
37
- export declare function getDataFetchCache(): MF_DATA_FETCH_CACHE;
38
-
39
- export declare const getDataFetchIdWithErrorMsgs: (errMsgs: string) => string | undefined;
40
-
41
- export declare const getDataFetchInfo: ({ name, alias, id, remoteSnapshot, }: {
42
- id: string;
43
- name: string;
44
- remoteSnapshot: GlobalModuleInfo[string];
45
- alias?: string;
46
- }) => {
47
- dataFetchName: string;
48
- dataFetchId: string;
49
- dataFetchKey: string;
50
- } | undefined;
51
-
52
- export declare function getDataFetchItem(id: string): MF_DATA_FETCH_MAP_VALUE;
53
-
54
- export declare function getDataFetchMap(): MF_DATA_FETCH_MAP;
55
-
56
- export declare function getDataFetchMapKey(dataFetchInfo?: ReturnType<typeof getDataFetchInfo>, hostInfo?: {
57
- name: string;
58
- version?: string;
59
- }): string | undefined;
60
-
61
- export declare function getDowngradeTag(): MF_SSR_DOWNGRADE;
62
-
63
- export declare function getLoadedRemoteInfos(id: string, instance: ModuleFederation | null): {
64
- snapshot: ModuleInfo | ManifestProvider | PureEntryProvider | undefined;
65
- expose: string;
66
- alias?: string;
67
- name: string;
68
- version?: string;
69
- buildVersion?: string;
70
- entry: string;
71
- type: RemoteEntryType;
72
- entryGlobalName: string;
73
- shareScope: string | string[];
74
- } | undefined;
75
-
76
- export declare function initDataFetchMap(): void;
77
-
78
- export declare function isCSROnly(): boolean;
79
-
80
- export declare function isDataLoaderExpose(exposeKey: string): boolean;
81
-
82
- export declare function isServerEnv(): boolean;
83
-
84
- export declare function loadDataFetchModule(instance: ModuleFederation, id: string): Promise<(params: DataFetchParams) => Promise<unknown>>;
85
-
86
- declare type MF_DATA_FETCH_CACHE = {
87
- cacheStore?: LRUCache<string, Map<string, CacheItem<any>>>;
88
- tagKeyMap?: Map<string, Set<string>>;
89
- cacheConfig?: CacheConfig;
90
- };
91
-
92
- declare type MF_DATA_FETCH_MAP = Record<string, MF_DATA_FETCH_MAP_VALUE>;
93
-
94
- declare type MF_DATA_FETCH_MAP_VALUE = [
95
- [
96
- () => Promise<DataFetch<unknown>>,
97
- MF_DATA_FETCH_TYPE,
98
- Promise<DataFetch<unknown>>?
99
- ],
100
- MF_DATA_FETCH_MAP_VALUE_PROMISE_SET?,
101
- MF_DATA_FETCH_STATUS?
102
- ];
103
-
104
- declare type MF_DATA_FETCH_MAP_VALUE_PROMISE_SET = [
105
- Promise<unknown>,
106
- ((data: unknown) => void)?,
107
- ((err: unknown) => void)?
108
- ];
109
-
110
- declare const enum MF_DATA_FETCH_STATUS {
111
- LOADED = 1,
112
- LOADING = 2,
113
- AWAIT = 0,
114
- ERROR = 3
115
- }
116
-
117
- declare const enum MF_DATA_FETCH_TYPE {
118
- FETCH_SERVER = 1,
119
- FETCH_CLIENT = 2
120
- }
121
-
122
- declare type MF_SSR_DOWNGRADE = string[] | true | undefined;
123
-
124
- declare type NoSSRRemoteInfo = {
125
- name: string;
126
- version: string;
127
- ssrPublicPath: string;
128
- ssrRemoteEntry: string;
129
- globalName: string;
130
- };
131
-
132
- export declare function setDataFetchItemLoadedStatus(id: string): void;
133
-
134
- export declare function setSSREnv({ fetchServerQuery, }: {
135
- fetchServerQuery?: Record<string, unknown>;
136
- }): void;
137
-
138
- export declare const wrapDataFetchId: (id?: string) => string;
139
-
140
- export { }
141
-
142
-
143
- declare module '@module-federation/runtime-core' {
144
- interface ModuleFederation {
145
- createLazyComponent<T, E extends keyof T>(options: Omit<CreateLazyComponentOptions<T, E>, 'instance'>): ReturnType<typeof createLazyComponent<T, E>>;
146
- prefetch(options: Omit<PrefetchOptions, 'instance'>): ReturnType<typeof prefetch>;
147
- collectSSRAssets(options: Omit<Parameters<typeof collectSSRAssets>[0], 'instance'>): ReturnType<typeof collectSSRAssets>;
148
- }
149
- }
1
+ export * from './lazy/utils';
@@ -1,11 +1,11 @@
1
1
  import "./logger-DwWkXsWl.mjs";
2
- import { H, I, h, f, N, v, m, o, e, n, J, z, i, t, k, u, j, A, s, x } from "./utils-DGS4pYp8.mjs";
2
+ import { H, I, h, f, O, v, m, o, e, n, J, z, i, t, k, u, j, A, s, x } from "./utils-BBP3hEeV.mjs";
3
3
  export {
4
4
  H as callAllDowngrade,
5
5
  I as callDowngrade,
6
6
  h as fetchData,
7
7
  f as flushDataFetch,
8
- N as getDataFetchCache,
8
+ O as getDataFetchCache,
9
9
  v as getDataFetchIdWithErrorMsgs,
10
10
  m as getDataFetchInfo,
11
11
  o as getDataFetchItem,
package/dist/plugin.d.ts CHANGED
@@ -1,22 +1,2 @@
1
- import { ModuleFederation } from '@module-federation/runtime';
2
- import { ModuleFederationRuntimePlugin } from '@module-federation/runtime';
3
-
4
- declare function BridgeReactPlugin(): ModuleFederationRuntimePlugin;
5
- export default BridgeReactPlugin;
6
-
7
- export declare const federationRuntime: FederationRuntimeType;
8
-
9
- export declare type FederationRuntimeType = {
10
- instance: ModuleFederation | null;
11
- };
12
-
13
- export { }
14
-
15
-
16
- declare module '@module-federation/runtime-core' {
17
- interface ModuleFederation {
18
- createLazyComponent<T, E extends keyof T>(options: Omit<CreateLazyComponentOptions<T, E>, 'instance'>): ReturnType<typeof createLazyComponent<T, E>>;
19
- prefetch(options: Omit<PrefetchOptions, 'instance'>): ReturnType<typeof prefetch>;
20
- collectSSRAssets(options: Omit<Parameters<typeof collectSSRAssets>[0], 'instance'>): ReturnType<typeof collectSSRAssets>;
21
- }
22
- }
1
+ export { default } from './provider/plugin';
2
+ export * from './provider/plugin';
@@ -0,0 +1,12 @@
1
+ import type { ModuleFederationRuntimePlugin } from '@module-federation/runtime';
2
+ import { createLazyComponent, prefetch, collectSSRAssets } from '../lazy';
3
+ import type { CreateLazyComponentOptions, PrefetchOptions } from '../lazy';
4
+ declare module '@module-federation/runtime-core' {
5
+ interface ModuleFederation {
6
+ createLazyComponent<T, E extends keyof T>(options: Omit<CreateLazyComponentOptions<T, E>, 'instance'>): ReturnType<typeof createLazyComponent<T, E>>;
7
+ prefetch(options: Omit<PrefetchOptions, 'instance'>): ReturnType<typeof prefetch>;
8
+ collectSSRAssets(options: Omit<Parameters<typeof collectSSRAssets>[0], 'instance'>): ReturnType<typeof collectSSRAssets>;
9
+ }
10
+ }
11
+ export declare function lazyLoadComponentPlugin(): ModuleFederationRuntimePlugin;
12
+ export default lazyLoadComponentPlugin;
@@ -0,0 +1 @@
1
+ export {};