@module-federation/bridge-react 0.0.0-next-20250618090118 → 0.0.0-next-20250620084158

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 (53) hide show
  1. package/CHANGELOG.md +3 -8
  2. package/__tests__/bridge.spec.tsx +7 -7
  3. package/dist/{bridge-base-DKPEvcPJ.js → bridge-base-BBH982Tz.cjs} +1 -1
  4. package/dist/{bridge-base-YDjQh_vg.mjs → bridge-base-P6pEjY1q.js} +1 -1
  5. package/dist/{index.esm-BjwhLgko.js → index-Cv3p6r66.cjs} +43 -21
  6. package/dist/{index.esm-nDSYG6Nj.mjs → index-D4yt7Udv.js} +43 -21
  7. package/dist/index.cjs.js +9 -427
  8. package/dist/index.d.ts +0 -77
  9. package/dist/index.es.js +11 -430
  10. package/dist/router-v5.cjs.js +1 -1
  11. package/dist/router-v5.es.js +1 -1
  12. package/dist/router-v6.cjs.js +1 -1
  13. package/dist/router-v6.es.js +1 -1
  14. package/dist/router.cjs.js +1 -1
  15. package/dist/router.es.js +1 -1
  16. package/dist/v18.cjs.js +1 -1
  17. package/dist/v18.es.js +1 -1
  18. package/dist/v19.cjs.js +1 -1
  19. package/dist/v19.es.js +1 -1
  20. package/package.json +5 -44
  21. package/src/index.ts +1 -21
  22. package/src/remote/component.tsx +3 -3
  23. package/src/remote/create.tsx +4 -17
  24. package/vite.config.ts +0 -13
  25. package/dist/data-fetch-runtime-plugin.cjs.js +0 -71
  26. package/dist/data-fetch-runtime-plugin.d.ts +0 -6
  27. package/dist/data-fetch-runtime-plugin.es.js +0 -72
  28. package/dist/data-fetch-server-middleware.cjs.js +0 -158
  29. package/dist/data-fetch-server-middleware.d.ts +0 -6
  30. package/dist/data-fetch-server-middleware.es.js +0 -159
  31. package/dist/data-fetch-utils.cjs.js +0 -90
  32. package/dist/data-fetch-utils.d.ts +0 -5
  33. package/dist/data-fetch-utils.es.js +0 -90
  34. package/dist/index-BYOQ_Qrb.js +0 -45
  35. package/dist/index-CUrEc0Q1.mjs +0 -46
  36. package/dist/lazy-utils.cjs.js +0 -22
  37. package/dist/lazy-utils.d.ts +0 -114
  38. package/dist/lazy-utils.es.js +0 -22
  39. package/dist/utils-DhtukXOQ.mjs +0 -327
  40. package/dist/utils-YoyAVYsh.js +0 -326
  41. package/src/lazy/AwaitDataFetch.tsx +0 -176
  42. package/src/lazy/constant.ts +0 -30
  43. package/src/lazy/createLazyComponent.tsx +0 -390
  44. package/src/lazy/data-fetch/call-data-fetch.ts +0 -13
  45. package/src/lazy/data-fetch/data-fetch-server-middleware.ts +0 -191
  46. package/src/lazy/data-fetch/index.ts +0 -2
  47. package/src/lazy/data-fetch/inject-data-fetch.ts +0 -109
  48. package/src/lazy/data-fetch/runtime-plugin.ts +0 -113
  49. package/src/lazy/index.ts +0 -18
  50. package/src/lazy/logger.ts +0 -6
  51. package/src/lazy/types.ts +0 -49
  52. package/src/lazy/utils.ts +0 -355
  53. package/src/lazy/wrapNoSSR.tsx +0 -10
@@ -1,90 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
- const lazyUtils = require("./utils-YoyAVYsh.js");
4
- const dataFetchFunction = async function(options) {
5
- var _a, _b;
6
- const [id, data, downgrade] = options;
7
- lazyUtils.logger.debug("==========call data fetch function!");
8
- if (data) {
9
- if (!id) {
10
- throw new Error("id is required!");
11
- }
12
- if (!lazyUtils.getDataFetchMap()) {
13
- lazyUtils.initDataFetchMap();
14
- }
15
- const dataFetchItem = lazyUtils.getDataFetchItem(id);
16
- if (dataFetchItem) {
17
- (_b = (_a = dataFetchItem[1]) == null ? void 0 : _a[1]) == null ? void 0 : _b.call(_a, data);
18
- dataFetchItem[2] = lazyUtils.MF_DATA_FETCH_STATUS.LOADED;
19
- return;
20
- }
21
- if (!dataFetchItem) {
22
- const dataFetchMap = lazyUtils.getDataFetchMap();
23
- let res;
24
- let rej;
25
- const p = new Promise((resolve, reject) => {
26
- res = resolve;
27
- rej = reject;
28
- });
29
- dataFetchMap[id] = [
30
- [
31
- async () => async () => {
32
- return "";
33
- },
34
- lazyUtils.MF_DATA_FETCH_TYPE.FETCH_SERVER
35
- ],
36
- [p, res, rej],
37
- lazyUtils.MF_DATA_FETCH_STATUS.LOADED
38
- ];
39
- res && res(data);
40
- return;
41
- }
42
- }
43
- if (downgrade) {
44
- const mfDowngrade2 = lazyUtils.getDowngradeTag();
45
- if (!mfDowngrade2) {
46
- globalThis[lazyUtils.DOWNGRADE_KEY] = id ? [id] : true;
47
- } else if (Array.isArray(mfDowngrade2) && id && !mfDowngrade2.includes(id)) {
48
- mfDowngrade2.push(id);
49
- }
50
- }
51
- const mfDowngrade = lazyUtils.getDowngradeTag();
52
- if (typeof mfDowngrade === "boolean") {
53
- return lazyUtils.callAllDowngrade();
54
- }
55
- if (Array.isArray(mfDowngrade)) {
56
- if (!id) {
57
- globalThis[lazyUtils.DOWNGRADE_KEY] = true;
58
- return lazyUtils.callAllDowngrade();
59
- }
60
- if (!mfDowngrade.includes(id)) {
61
- mfDowngrade.push(id);
62
- }
63
- return lazyUtils.callDowngrade(id);
64
- }
65
- };
66
- function injectDataFetch() {
67
- var _a;
68
- globalThis[_a = lazyUtils.DATA_FETCH_FUNCTION] || (globalThis[_a] = []);
69
- const dataFetch = globalThis[lazyUtils.DATA_FETCH_FUNCTION];
70
- if (dataFetch.push === dataFetchFunction) {
71
- return;
72
- }
73
- if (typeof window === "undefined") {
74
- return;
75
- }
76
- globalThis[lazyUtils.FS_HREF] = window.location.href;
77
- dataFetch.push = dataFetchFunction;
78
- }
79
- async function callDataFetch() {
80
- const dataFetch = globalThis[lazyUtils.DATA_FETCH_FUNCTION];
81
- if (dataFetch) {
82
- await Promise.all(
83
- dataFetch.map(async (options) => {
84
- await dataFetchFunction(options);
85
- })
86
- );
87
- }
88
- }
89
- exports.callDataFetch = callDataFetch;
90
- exports.injectDataFetch = injectDataFetch;
@@ -1,5 +0,0 @@
1
- export declare function callDataFetch(): Promise<void>;
2
-
3
- export declare function injectDataFetch(): void;
4
-
5
- export { }
@@ -1,90 +0,0 @@
1
- import { o as DATA_FETCH_FUNCTION, F as FS_HREF, l as logger, f as getDataFetchMap, h as initDataFetchMap, b as getDataFetchItem, e as MF_DATA_FETCH_STATUS, M as MF_DATA_FETCH_TYPE, r as DOWNGRADE_KEY, t as getDowngradeTag, u as callAllDowngrade, v as callDowngrade } from "./utils-DhtukXOQ.mjs";
2
- const dataFetchFunction = async function(options) {
3
- var _a, _b;
4
- const [id, data, downgrade] = options;
5
- logger.debug("==========call data fetch function!");
6
- if (data) {
7
- if (!id) {
8
- throw new Error("id is required!");
9
- }
10
- if (!getDataFetchMap()) {
11
- initDataFetchMap();
12
- }
13
- const dataFetchItem = getDataFetchItem(id);
14
- if (dataFetchItem) {
15
- (_b = (_a = dataFetchItem[1]) == null ? void 0 : _a[1]) == null ? void 0 : _b.call(_a, data);
16
- dataFetchItem[2] = MF_DATA_FETCH_STATUS.LOADED;
17
- return;
18
- }
19
- if (!dataFetchItem) {
20
- const dataFetchMap = getDataFetchMap();
21
- let res;
22
- let rej;
23
- const p = new Promise((resolve, reject) => {
24
- res = resolve;
25
- rej = reject;
26
- });
27
- dataFetchMap[id] = [
28
- [
29
- async () => async () => {
30
- return "";
31
- },
32
- MF_DATA_FETCH_TYPE.FETCH_SERVER
33
- ],
34
- [p, res, rej],
35
- MF_DATA_FETCH_STATUS.LOADED
36
- ];
37
- res && res(data);
38
- return;
39
- }
40
- }
41
- if (downgrade) {
42
- const mfDowngrade2 = getDowngradeTag();
43
- if (!mfDowngrade2) {
44
- globalThis[DOWNGRADE_KEY] = id ? [id] : true;
45
- } else if (Array.isArray(mfDowngrade2) && id && !mfDowngrade2.includes(id)) {
46
- mfDowngrade2.push(id);
47
- }
48
- }
49
- const mfDowngrade = getDowngradeTag();
50
- if (typeof mfDowngrade === "boolean") {
51
- return callAllDowngrade();
52
- }
53
- if (Array.isArray(mfDowngrade)) {
54
- if (!id) {
55
- globalThis[DOWNGRADE_KEY] = true;
56
- return callAllDowngrade();
57
- }
58
- if (!mfDowngrade.includes(id)) {
59
- mfDowngrade.push(id);
60
- }
61
- return callDowngrade(id);
62
- }
63
- };
64
- function injectDataFetch() {
65
- var _a;
66
- globalThis[_a = DATA_FETCH_FUNCTION] || (globalThis[_a] = []);
67
- const dataFetch = globalThis[DATA_FETCH_FUNCTION];
68
- if (dataFetch.push === dataFetchFunction) {
69
- return;
70
- }
71
- if (typeof window === "undefined") {
72
- return;
73
- }
74
- globalThis[FS_HREF] = window.location.href;
75
- dataFetch.push = dataFetchFunction;
76
- }
77
- async function callDataFetch() {
78
- const dataFetch = globalThis[DATA_FETCH_FUNCTION];
79
- if (dataFetch) {
80
- await Promise.all(
81
- dataFetch.map(async (options) => {
82
- await dataFetchFunction(options);
83
- })
84
- );
85
- }
86
- }
87
- export {
88
- callDataFetch,
89
- injectDataFetch
90
- };
@@ -1,45 +0,0 @@
1
- "use strict";
2
- const React = require("react");
3
- const index_esm = require("./index.esm-BjwhLgko.js");
4
- const RouterContext = React.createContext(null);
5
- const LoggerInstance = index_esm.createLogger(
6
- "[ Module Federation Bridge React ]"
7
- );
8
- function pathJoin(...args) {
9
- const res = args.reduce((res2, path) => {
10
- let nPath = path;
11
- if (!nPath || typeof nPath !== "string") {
12
- return res2;
13
- }
14
- if (nPath[0] !== "/") {
15
- nPath = `/${nPath}`;
16
- }
17
- const lastIndex = nPath.length - 1;
18
- if (nPath[lastIndex] === "/") {
19
- nPath = nPath.substring(0, lastIndex);
20
- }
21
- return res2 + nPath;
22
- }, "");
23
- return res || "/";
24
- }
25
- const getModuleName = (id) => {
26
- if (!id) {
27
- return id;
28
- }
29
- const idArray = id.split("/");
30
- if (idArray.length < 2) {
31
- return id;
32
- }
33
- return idArray[0] + "/" + idArray[1];
34
- };
35
- const getRootDomDefaultClassName = (moduleName) => {
36
- if (!moduleName) {
37
- return "";
38
- }
39
- const name = getModuleName(moduleName).replace(/\@/, "").replace(/\//, "-");
40
- return `bridge-root-component-${name}`;
41
- };
42
- exports.LoggerInstance = LoggerInstance;
43
- exports.RouterContext = RouterContext;
44
- exports.getRootDomDefaultClassName = getRootDomDefaultClassName;
45
- exports.pathJoin = pathJoin;
@@ -1,46 +0,0 @@
1
- import React__default from "react";
2
- import { c as createLogger } from "./index.esm-nDSYG6Nj.mjs";
3
- const RouterContext = React__default.createContext(null);
4
- const LoggerInstance = createLogger(
5
- "[ Module Federation Bridge React ]"
6
- );
7
- function pathJoin(...args) {
8
- const res = args.reduce((res2, path) => {
9
- let nPath = path;
10
- if (!nPath || typeof nPath !== "string") {
11
- return res2;
12
- }
13
- if (nPath[0] !== "/") {
14
- nPath = `/${nPath}`;
15
- }
16
- const lastIndex = nPath.length - 1;
17
- if (nPath[lastIndex] === "/") {
18
- nPath = nPath.substring(0, lastIndex);
19
- }
20
- return res2 + nPath;
21
- }, "");
22
- return res || "/";
23
- }
24
- const getModuleName = (id) => {
25
- if (!id) {
26
- return id;
27
- }
28
- const idArray = id.split("/");
29
- if (idArray.length < 2) {
30
- return id;
31
- }
32
- return idArray[0] + "/" + idArray[1];
33
- };
34
- const getRootDomDefaultClassName = (moduleName) => {
35
- if (!moduleName) {
36
- return "";
37
- }
38
- const name = getModuleName(moduleName).replace(/\@/, "").replace(/\//, "-");
39
- return `bridge-root-component-${name}`;
40
- };
41
- export {
42
- LoggerInstance as L,
43
- RouterContext as R,
44
- getRootDomDefaultClassName as g,
45
- pathJoin as p
46
- };
@@ -1,22 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
- require("./index.esm-BjwhLgko.js");
4
- const lazyUtils = require("./utils-YoyAVYsh.js");
5
- exports.callAllDowngrade = lazyUtils.callAllDowngrade;
6
- exports.callDowngrade = lazyUtils.callDowngrade;
7
- exports.fetchData = lazyUtils.fetchData;
8
- exports.flushDataFetch = lazyUtils.flushDataFetch;
9
- exports.getDataFetchIdWithErrorMsgs = lazyUtils.getDataFetchIdWithErrorMsgs;
10
- exports.getDataFetchInfo = lazyUtils.getDataFetchInfo;
11
- exports.getDataFetchItem = lazyUtils.getDataFetchItem;
12
- exports.getDataFetchMap = lazyUtils.getDataFetchMap;
13
- exports.getDataFetchMapKey = lazyUtils.getDataFetchMapKey;
14
- exports.getDowngradeTag = lazyUtils.getDowngradeTag;
15
- exports.getLoadedRemoteInfos = lazyUtils.getLoadedRemoteInfos;
16
- exports.initDataFetchMap = lazyUtils.initDataFetchMap;
17
- exports.isCSROnly = lazyUtils.isCSROnly;
18
- exports.isDataLoaderExpose = lazyUtils.isDataLoaderExpose;
19
- exports.loadDataFetchModule = lazyUtils.loadDataFetchModule;
20
- exports.setDataFetchItemLoadedStatus = lazyUtils.setDataFetchItemLoadedStatus;
21
- exports.setSSREnv = lazyUtils.setSSREnv;
22
- exports.wrapDataFetchId = lazyUtils.wrapDataFetchId;
@@ -1,114 +0,0 @@
1
- import { FederationHost } from '@module-federation/runtime';
2
- import { GlobalModuleInfo } from '@module-federation/sdk';
3
- import { ManifestProvider } from '@module-federation/sdk';
4
- import { ModuleInfo } from '@module-federation/sdk';
5
- import { PureEntryProvider } from '@module-federation/sdk';
6
- import { RemoteEntryType } from '@module-federation/sdk';
7
-
8
- export declare function callAllDowngrade(): void;
9
-
10
- export declare function callDowngrade(id: string, params?: DataFetchParams, remoteInfo?: NoSSRRemoteInfo): Promise<unknown>;
11
-
12
- declare type DataFetch<T> = (params: DataFetchParams) => Promise<T>;
13
-
14
- declare type DataFetchParams = {
15
- isDowngrade: boolean;
16
- } & Record<string, unknown>;
17
-
18
- export declare function fetchData(id: string, params: DataFetchParams, remoteInfo?: NoSSRRemoteInfo): Promise<unknown | undefined>;
19
-
20
- export declare const flushDataFetch: () => void;
21
-
22
- export declare const getDataFetchIdWithErrorMsgs: (errMsgs: string) => string | undefined;
23
-
24
- export declare const getDataFetchInfo: ({ name, alias, id, remoteSnapshot, }: {
25
- id: string;
26
- name: string;
27
- remoteSnapshot: GlobalModuleInfo[string];
28
- alias?: string;
29
- }) => {
30
- dataFetchName: string;
31
- dataFetchId: string;
32
- } | undefined;
33
-
34
- export declare function getDataFetchItem(id: string): MF_DATA_FETCH_MAP_VALUE;
35
-
36
- export declare function getDataFetchMap(): MF_DATA_FETCH_MAP;
37
-
38
- export declare function getDataFetchMapKey(dataFetchInfo?: ReturnType<typeof getDataFetchInfo>, hostInfo?: {
39
- name: string;
40
- version?: string;
41
- }): string | undefined;
42
-
43
- export declare function getDowngradeTag(): MF_SSR_DOWNGRADE;
44
-
45
- export declare function getLoadedRemoteInfos(id: string, instance: FederationHost | null): {
46
- snapshot: ModuleInfo | ManifestProvider | PureEntryProvider | undefined;
47
- expose: string;
48
- alias?: string;
49
- name: string;
50
- version?: string;
51
- buildVersion?: string;
52
- entry: string;
53
- type: RemoteEntryType;
54
- entryGlobalName: string;
55
- shareScope: string | string[];
56
- } | undefined;
57
-
58
- export declare function initDataFetchMap(): void;
59
-
60
- export declare function isCSROnly(): boolean;
61
-
62
- export declare function isDataLoaderExpose(exposeKey: string): boolean;
63
-
64
- export declare function loadDataFetchModule(instance: FederationHost, id: string): Promise<(params: DataFetchParams) => Promise<unknown>>;
65
-
66
- declare type MF_DATA_FETCH_MAP = Record<string, MF_DATA_FETCH_MAP_VALUE>;
67
-
68
- declare type MF_DATA_FETCH_MAP_VALUE = [
69
- [
70
- () => Promise<DataFetch<unknown>>,
71
- MF_DATA_FETCH_TYPE,
72
- Promise<DataFetch<unknown>>?
73
- ],
74
- MF_DATA_FETCH_MAP_VALUE_PROMISE_SET?,
75
- MF_DATA_FETCH_STATUS?
76
- ];
77
-
78
- declare type MF_DATA_FETCH_MAP_VALUE_PROMISE_SET = [
79
- Promise<unknown>,
80
- ((data: unknown) => void)?,
81
- ((err: unknown) => void)?
82
- ];
83
-
84
- declare const enum MF_DATA_FETCH_STATUS {
85
- LOADED = 1,
86
- LOADING = 2,
87
- AWAIT = 0,
88
- ERROR = 3
89
- }
90
-
91
- declare const enum MF_DATA_FETCH_TYPE {
92
- FETCH_SERVER = 1,
93
- FETCH_CLIENT = 2
94
- }
95
-
96
- declare type MF_SSR_DOWNGRADE = string[] | true | undefined;
97
-
98
- declare type NoSSRRemoteInfo = {
99
- name: string;
100
- version: string;
101
- ssrPublicPath: string;
102
- ssrRemoteEntry: string;
103
- globalName: string;
104
- };
105
-
106
- export declare function setDataFetchItemLoadedStatus(id: string): void;
107
-
108
- export declare function setSSREnv({ fetchServerQuery, }: {
109
- fetchServerQuery?: Record<string, unknown>;
110
- }): void;
111
-
112
- export declare const wrapDataFetchId: (id?: string) => string;
113
-
114
- export { }
@@ -1,22 +0,0 @@
1
- import "./index.esm-nDSYG6Nj.mjs";
2
- import { u, v, k, x, m, g, b, f, a, t, p, h, c, i, d, s, q, w } from "./utils-DhtukXOQ.mjs";
3
- export {
4
- u as callAllDowngrade,
5
- v as callDowngrade,
6
- k as fetchData,
7
- x as flushDataFetch,
8
- m as getDataFetchIdWithErrorMsgs,
9
- g as getDataFetchInfo,
10
- b as getDataFetchItem,
11
- f as getDataFetchMap,
12
- a as getDataFetchMapKey,
13
- t as getDowngradeTag,
14
- p as getLoadedRemoteInfos,
15
- h as initDataFetchMap,
16
- c as isCSROnly,
17
- i as isDataLoaderExpose,
18
- d as loadDataFetchModule,
19
- s as setDataFetchItemLoadedStatus,
20
- q as setSSREnv,
21
- w as wrapDataFetchId
22
- };