@module-federation/modern-js 0.0.0-next-20250522125627 → 0.0.0-next-20250522130707
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/LICENSE +21 -0
- package/dist/cjs/cli/configPlugin.js +390 -0
- package/dist/cjs/cli/configPlugin.spec.js +114 -0
- package/dist/cjs/cli/index.js +85 -0
- package/dist/cjs/cli/manifest.js +75 -0
- package/dist/cjs/cli/mfRuntimePlugins/auto-fetch-data.js +98 -0
- package/dist/cjs/cli/mfRuntimePlugins/inject-node-fetch.js +44 -0
- package/dist/cjs/cli/mfRuntimePlugins/resolve-entry-ipv4.js +82 -0
- package/dist/cjs/cli/mfRuntimePlugins/shared-strategy.js +43 -0
- package/dist/cjs/cli/server/data-fetch-server-plugin.js +184 -0
- package/dist/cjs/cli/ssrPlugin.js +222 -0
- package/dist/cjs/cli/utils.js +90 -0
- package/dist/cjs/constant.js +78 -0
- package/dist/cjs/interfaces/bundler.js +16 -0
- package/dist/cjs/interfaces/global.js +16 -0
- package/dist/cjs/logger.js +27 -0
- package/dist/cjs/runtime/AwaitDataFetch.js +144 -0
- package/dist/cjs/runtime/createRemoteComponent.js +327 -0
- package/dist/cjs/runtime/index.js +47 -0
- package/dist/cjs/runtime/wrapNoSSR.js +35 -0
- package/dist/cjs/ssr-runtime/SSRLiveReload.js +43 -0
- package/dist/cjs/ssr-runtime/devPlugin.js +71 -0
- package/dist/cjs/ssr-runtime/downgrade.js +108 -0
- package/dist/cjs/ssr-runtime/injectDataFetchFunctionPlugin.js +129 -0
- package/dist/cjs/types/index.js +16 -0
- package/dist/cjs/utils/dataFetch.js +200 -0
- package/dist/cjs/utils/index.js +54 -0
- package/dist/esm/cli/configPlugin.js +399 -0
- package/dist/esm/cli/configPlugin.spec.js +110 -0
- package/dist/esm/cli/index.js +79 -0
- package/dist/esm/cli/manifest.js +41 -0
- package/dist/esm/cli/mfRuntimePlugins/auto-fetch-data.js +74 -0
- package/dist/esm/cli/mfRuntimePlugins/inject-node-fetch.js +16 -0
- package/dist/esm/cli/mfRuntimePlugins/resolve-entry-ipv4.js +74 -0
- package/dist/esm/cli/mfRuntimePlugins/shared-strategy.js +25 -0
- package/dist/esm/cli/server/data-fetch-server-plugin.js +237 -0
- package/dist/esm/cli/ssrPlugin.js +204 -0
- package/dist/esm/cli/utils.js +53 -0
- package/dist/esm/constant.js +42 -0
- package/dist/esm/interfaces/bundler.js +0 -0
- package/dist/esm/interfaces/global.js +0 -0
- package/dist/esm/logger.js +7 -0
- package/dist/esm/runtime/AwaitDataFetch.js +131 -0
- package/dist/esm/runtime/createRemoteComponent.js +417 -0
- package/dist/esm/runtime/index.js +20 -0
- package/dist/esm/runtime/wrapNoSSR.js +12 -0
- package/dist/esm/ssr-runtime/SSRLiveReload.js +26 -0
- package/dist/esm/ssr-runtime/devPlugin.js +73 -0
- package/dist/esm/ssr-runtime/downgrade.js +141 -0
- package/dist/esm/ssr-runtime/injectDataFetchFunctionPlugin.js +171 -0
- package/dist/esm/types/index.js +0 -0
- package/dist/esm/utils/dataFetch.js +227 -0
- package/dist/esm/utils/index.js +28 -0
- package/dist/esm-node/cli/configPlugin.js +349 -0
- package/dist/esm-node/cli/configPlugin.spec.js +91 -0
- package/dist/esm-node/cli/index.js +60 -0
- package/dist/esm-node/cli/manifest.js +41 -0
- package/dist/esm-node/cli/mfRuntimePlugins/auto-fetch-data.js +68 -0
- package/dist/esm-node/cli/mfRuntimePlugins/inject-node-fetch.js +14 -0
- package/dist/esm-node/cli/mfRuntimePlugins/resolve-entry-ipv4.js +62 -0
- package/dist/esm-node/cli/mfRuntimePlugins/shared-strategy.js +23 -0
- package/dist/esm-node/cli/server/data-fetch-server-plugin.js +154 -0
- package/dist/esm-node/cli/ssrPlugin.js +186 -0
- package/dist/esm-node/cli/utils.js +53 -0
- package/dist/esm-node/constant.js +42 -0
- package/dist/esm-node/interfaces/bundler.js +0 -0
- package/dist/esm-node/interfaces/global.js +0 -0
- package/dist/esm-node/logger.js +7 -0
- package/dist/esm-node/runtime/AwaitDataFetch.js +109 -0
- package/dist/esm-node/runtime/createRemoteComponent.js +291 -0
- package/dist/esm-node/runtime/index.js +20 -0
- package/dist/esm-node/runtime/wrapNoSSR.js +11 -0
- package/dist/esm-node/ssr-runtime/SSRLiveReload.js +19 -0
- package/dist/esm-node/ssr-runtime/devPlugin.js +37 -0
- package/dist/esm-node/ssr-runtime/downgrade.js +82 -0
- package/dist/esm-node/ssr-runtime/injectDataFetchFunctionPlugin.js +95 -0
- package/dist/esm-node/types/index.js +0 -0
- package/dist/esm-node/utils/dataFetch.js +156 -0
- package/dist/esm-node/utils/index.js +27 -0
- package/dist/types/cli/configPlugin.d.ts +21 -0
- package/dist/types/cli/configPlugin.spec.d.ts +1 -0
- package/dist/types/cli/index.d.ts +6 -0
- package/dist/types/cli/manifest.d.ts +2 -0
- package/dist/types/cli/mfRuntimePlugins/auto-fetch-data.d.ts +3 -0
- package/dist/types/cli/mfRuntimePlugins/inject-node-fetch.d.ts +3 -0
- package/dist/types/cli/mfRuntimePlugins/resolve-entry-ipv4.d.ts +3 -0
- package/dist/types/cli/mfRuntimePlugins/shared-strategy.d.ts +3 -0
- package/dist/types/cli/server/data-fetch-server-plugin.d.ts +3 -0
- package/dist/types/cli/ssrPlugin.d.ts +6 -0
- package/dist/types/cli/utils.d.ts +6 -0
- package/dist/types/constant.d.ts +25 -0
- package/dist/types/interfaces/bundler.d.ts +18 -0
- package/dist/types/interfaces/global.d.ts +27 -0
- package/dist/types/logger.d.ts +2 -0
- package/dist/types/runtime/AwaitDataFetch.d.ts +19 -0
- package/dist/types/runtime/createRemoteComponent.d.ts +26 -0
- package/dist/types/runtime/index.d.ts +9 -0
- package/dist/types/runtime/wrapNoSSR.d.ts +9 -0
- package/dist/types/ssr-runtime/SSRLiveReload.d.ts +1 -0
- package/dist/types/ssr-runtime/devPlugin.d.ts +2 -0
- package/dist/types/ssr-runtime/downgrade.d.ts +4 -0
- package/dist/types/ssr-runtime/injectDataFetchFunctionPlugin.d.ts +2 -0
- package/dist/types/types/index.d.ts +22 -0
- package/dist/types/utils/dataFetch.d.ts +25 -0
- package/dist/types/utils/index.d.ts +15 -0
- package/package.json +8 -8
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
+
var injectDataFetchFunctionPlugin_exports = {};
|
|
30
|
+
__export(injectDataFetchFunctionPlugin_exports, {
|
|
31
|
+
injectDataFetchFunctionPlugin: () => injectDataFetchFunctionPlugin
|
|
32
|
+
});
|
|
33
|
+
module.exports = __toCommonJS(injectDataFetchFunctionPlugin_exports);
|
|
34
|
+
var import_constant = require("../constant");
|
|
35
|
+
var import_logger = __toESM(require("../logger"));
|
|
36
|
+
var import_utils = require("../utils");
|
|
37
|
+
var import_downgrade = require("./downgrade");
|
|
38
|
+
const injectDataFetchFunctionPlugin = () => ({
|
|
39
|
+
name: "@module-federation/inject-data-fetch-function-plugin",
|
|
40
|
+
setup: (api) => {
|
|
41
|
+
api.onBeforeRender(async () => {
|
|
42
|
+
var _globalThis, _DATA_FETCH_FUNCTION;
|
|
43
|
+
globalThis.FEDERATION_SSR = true;
|
|
44
|
+
if (typeof window === "undefined") {
|
|
45
|
+
return;
|
|
46
|
+
}
|
|
47
|
+
const dataFetchFunction = async function(options) {
|
|
48
|
+
const [id, data, downgrade] = options;
|
|
49
|
+
import_logger.default.debug("==========call data fetch function!");
|
|
50
|
+
if (data) {
|
|
51
|
+
if (!id) {
|
|
52
|
+
throw new Error("id is required!");
|
|
53
|
+
}
|
|
54
|
+
if (!(0, import_utils.getDataFetchMap)()) {
|
|
55
|
+
(0, import_utils.initDataFetchMap)();
|
|
56
|
+
}
|
|
57
|
+
const dataFetchItem = (0, import_utils.getDataFetchItem)(id);
|
|
58
|
+
if (dataFetchItem) {
|
|
59
|
+
var _dataFetchItem__, _dataFetchItem_;
|
|
60
|
+
(_dataFetchItem_ = dataFetchItem[1]) === null || _dataFetchItem_ === void 0 ? void 0 : (_dataFetchItem__ = _dataFetchItem_[1]) === null || _dataFetchItem__ === void 0 ? void 0 : _dataFetchItem__.call(_dataFetchItem_, data);
|
|
61
|
+
dataFetchItem[2] = import_constant.MF_DATA_FETCH_STATUS.LOADED;
|
|
62
|
+
return;
|
|
63
|
+
}
|
|
64
|
+
if (!dataFetchItem) {
|
|
65
|
+
const dataFetchMap = (0, import_utils.getDataFetchMap)();
|
|
66
|
+
let res;
|
|
67
|
+
let rej;
|
|
68
|
+
const p = new Promise((resolve, reject) => {
|
|
69
|
+
res = resolve;
|
|
70
|
+
rej = reject;
|
|
71
|
+
});
|
|
72
|
+
dataFetchMap[id] = [
|
|
73
|
+
[
|
|
74
|
+
async () => async () => {
|
|
75
|
+
return "";
|
|
76
|
+
},
|
|
77
|
+
import_constant.MF_DATA_FETCH_TYPE.FETCH_SERVER
|
|
78
|
+
],
|
|
79
|
+
[
|
|
80
|
+
p,
|
|
81
|
+
res,
|
|
82
|
+
rej
|
|
83
|
+
],
|
|
84
|
+
import_constant.MF_DATA_FETCH_STATUS.LOADED
|
|
85
|
+
];
|
|
86
|
+
res(data);
|
|
87
|
+
return;
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
if (downgrade) {
|
|
91
|
+
const mfDowngrade2 = (0, import_downgrade.getDowngradeTag)();
|
|
92
|
+
if (!mfDowngrade2) {
|
|
93
|
+
globalThis[import_constant.DOWNGRADE_KEY] = id ? [
|
|
94
|
+
id
|
|
95
|
+
] : true;
|
|
96
|
+
} else if (Array.isArray(mfDowngrade2) && id && !mfDowngrade2.includes(id)) {
|
|
97
|
+
mfDowngrade2.push(id);
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
const mfDowngrade = (0, import_downgrade.getDowngradeTag)();
|
|
101
|
+
if (typeof mfDowngrade === "boolean") {
|
|
102
|
+
return (0, import_downgrade.callAllDowngrade)();
|
|
103
|
+
}
|
|
104
|
+
if (Array.isArray(mfDowngrade)) {
|
|
105
|
+
if (!id) {
|
|
106
|
+
globalThis[import_constant.DOWNGRADE_KEY] = true;
|
|
107
|
+
return (0, import_downgrade.callAllDowngrade)();
|
|
108
|
+
}
|
|
109
|
+
if (mfDowngrade.includes(id)) {
|
|
110
|
+
return;
|
|
111
|
+
}
|
|
112
|
+
mfDowngrade.push(id);
|
|
113
|
+
return (0, import_downgrade.callDowngrade)(id);
|
|
114
|
+
}
|
|
115
|
+
};
|
|
116
|
+
globalThis[import_constant.FS_HREF] = window.location.href;
|
|
117
|
+
(_globalThis = globalThis)[_DATA_FETCH_FUNCTION = import_constant.DATA_FETCH_FUNCTION] || (_globalThis[_DATA_FETCH_FUNCTION] = []);
|
|
118
|
+
const dataFetch = globalThis[import_constant.DATA_FETCH_FUNCTION];
|
|
119
|
+
await Promise.all(dataFetch.map(async (options) => {
|
|
120
|
+
await dataFetchFunction(options);
|
|
121
|
+
}));
|
|
122
|
+
dataFetch.push = dataFetchFunction;
|
|
123
|
+
});
|
|
124
|
+
}
|
|
125
|
+
});
|
|
126
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
127
|
+
0 && (module.exports = {
|
|
128
|
+
injectDataFetchFunctionPlugin
|
|
129
|
+
});
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __copyProps = (to, from, except, desc) => {
|
|
7
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
8
|
+
for (let key of __getOwnPropNames(from))
|
|
9
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
10
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
11
|
+
}
|
|
12
|
+
return to;
|
|
13
|
+
};
|
|
14
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
15
|
+
var types_exports = {};
|
|
16
|
+
module.exports = __toCommonJS(types_exports);
|
|
@@ -0,0 +1,200 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
+
var dataFetch_exports = {};
|
|
30
|
+
__export(dataFetch_exports, {
|
|
31
|
+
fetchData: () => fetchData,
|
|
32
|
+
flushDataFetch: () => flushDataFetch,
|
|
33
|
+
getDataFetchIdWithErrorMsgs: () => getDataFetchIdWithErrorMsgs,
|
|
34
|
+
getDataFetchInfo: () => getDataFetchInfo,
|
|
35
|
+
getDataFetchItem: () => getDataFetchItem,
|
|
36
|
+
getDataFetchMap: () => getDataFetchMap,
|
|
37
|
+
getDataFetchMapKey: () => getDataFetchMapKey,
|
|
38
|
+
initDataFetchMap: () => initDataFetchMap,
|
|
39
|
+
loadDataFetchModule: () => loadDataFetchModule,
|
|
40
|
+
setDataFetchItemLoadedStatus: () => setDataFetchItemLoadedStatus,
|
|
41
|
+
wrapDataFetchId: () => wrapDataFetchId
|
|
42
|
+
});
|
|
43
|
+
module.exports = __toCommonJS(dataFetch_exports);
|
|
44
|
+
var import_sdk = require("@module-federation/sdk");
|
|
45
|
+
var import_utils = require("../utils");
|
|
46
|
+
var import_logger = __toESM(require("../logger"));
|
|
47
|
+
var import_downgrade = require("../ssr-runtime/downgrade");
|
|
48
|
+
var import_constant = require("../constant");
|
|
49
|
+
var import_constant2 = require("@module-federation/rsbuild-plugin/constant");
|
|
50
|
+
const getDataFetchInfo = ({ name, alias, id, remoteSnapshot }) => {
|
|
51
|
+
if (!remoteSnapshot) {
|
|
52
|
+
return;
|
|
53
|
+
}
|
|
54
|
+
if (!("modules" in remoteSnapshot)) {
|
|
55
|
+
return;
|
|
56
|
+
}
|
|
57
|
+
const regex = new RegExp(`^${name}(/[^/].*|)$`);
|
|
58
|
+
const nameOrAlias = regex.test(id) ? name : alias || name;
|
|
59
|
+
const expose = id.replace(nameOrAlias, "");
|
|
60
|
+
let dataFetchName = "";
|
|
61
|
+
let dataFetchId = "";
|
|
62
|
+
if (expose.startsWith("/")) {
|
|
63
|
+
dataFetchName = `${expose.slice(1)}.${import_constant2.DATA_FETCH_IDENTIFIER}`;
|
|
64
|
+
dataFetchId = `${id}.${import_constant2.DATA_FETCH_IDENTIFIER}`;
|
|
65
|
+
} else if (expose === "") {
|
|
66
|
+
dataFetchName = import_constant2.DATA_FETCH_IDENTIFIER;
|
|
67
|
+
dataFetchId = `${id}/${import_constant2.DATA_FETCH_IDENTIFIER}`;
|
|
68
|
+
} else {
|
|
69
|
+
return;
|
|
70
|
+
}
|
|
71
|
+
if (!dataFetchName || !dataFetchId) {
|
|
72
|
+
return;
|
|
73
|
+
}
|
|
74
|
+
if (!remoteSnapshot.modules.find((module2) => module2.moduleName === dataFetchName)) {
|
|
75
|
+
return;
|
|
76
|
+
}
|
|
77
|
+
return {
|
|
78
|
+
dataFetchName,
|
|
79
|
+
dataFetchId
|
|
80
|
+
};
|
|
81
|
+
};
|
|
82
|
+
function initDataFetchMap() {
|
|
83
|
+
var _globalThis;
|
|
84
|
+
(_globalThis = globalThis).__MF_DATA_FETCH_MAP__ || (_globalThis.__MF_DATA_FETCH_MAP__ = {});
|
|
85
|
+
}
|
|
86
|
+
function getDataFetchItem(id) {
|
|
87
|
+
var _globalThis___MF_DATA_FETCH_MAP__;
|
|
88
|
+
return (_globalThis___MF_DATA_FETCH_MAP__ = globalThis.__MF_DATA_FETCH_MAP__) === null || _globalThis___MF_DATA_FETCH_MAP__ === void 0 ? void 0 : _globalThis___MF_DATA_FETCH_MAP__[id];
|
|
89
|
+
}
|
|
90
|
+
function getDataFetchMap() {
|
|
91
|
+
return globalThis.__MF_DATA_FETCH_MAP__;
|
|
92
|
+
}
|
|
93
|
+
const flushDataFetch = () => {
|
|
94
|
+
globalThis.__MF_DATA_FETCH_MAP__ = {};
|
|
95
|
+
globalThis[import_constant.DOWNGRADE_KEY] = void 0;
|
|
96
|
+
};
|
|
97
|
+
function setDataFetchItemLoadedStatus(id) {
|
|
98
|
+
const dataFetchItem = getDataFetchItem(id);
|
|
99
|
+
if (!dataFetchItem) {
|
|
100
|
+
return;
|
|
101
|
+
}
|
|
102
|
+
dataFetchItem[2] = import_constant.MF_DATA_FETCH_STATUS.LOADED;
|
|
103
|
+
}
|
|
104
|
+
const wrapDataFetchId = (id) => {
|
|
105
|
+
return `${import_constant.WRAP_DATA_FETCH_ID_IDENTIFIER}${id}${import_constant.WRAP_DATA_FETCH_ID_IDENTIFIER}`;
|
|
106
|
+
};
|
|
107
|
+
const getDataFetchIdWithErrorMsgs = (errMsgs) => {
|
|
108
|
+
const firstIdentifierIndex = errMsgs.indexOf(import_constant.WRAP_DATA_FETCH_ID_IDENTIFIER);
|
|
109
|
+
if (firstIdentifierIndex === -1) {
|
|
110
|
+
return void 0;
|
|
111
|
+
}
|
|
112
|
+
const secondIdentifierIndex = errMsgs.indexOf(import_constant.WRAP_DATA_FETCH_ID_IDENTIFIER, firstIdentifierIndex + import_constant.WRAP_DATA_FETCH_ID_IDENTIFIER.length);
|
|
113
|
+
if (secondIdentifierIndex === -1) {
|
|
114
|
+
return void 0;
|
|
115
|
+
}
|
|
116
|
+
return errMsgs.substring(firstIdentifierIndex + import_constant.WRAP_DATA_FETCH_ID_IDENTIFIER.length, secondIdentifierIndex);
|
|
117
|
+
};
|
|
118
|
+
async function fetchData(id, params, remoteInfo) {
|
|
119
|
+
const callFetchData = async () => {
|
|
120
|
+
const item = getDataFetchItem(id);
|
|
121
|
+
if (!item) {
|
|
122
|
+
return;
|
|
123
|
+
}
|
|
124
|
+
const [fetchDataFnArr, ..._rest] = item;
|
|
125
|
+
const fetchDataFn = await fetchDataFnArr[2];
|
|
126
|
+
if (!fetchDataFn) {
|
|
127
|
+
return;
|
|
128
|
+
}
|
|
129
|
+
return fetchDataFn(params);
|
|
130
|
+
};
|
|
131
|
+
if ((0, import_sdk.isBrowserEnv)()) {
|
|
132
|
+
var _dataFetchItem_;
|
|
133
|
+
const dataFetchItem = getDataFetchItem(id);
|
|
134
|
+
if (!dataFetchItem) {
|
|
135
|
+
throw new Error(`dataFetchItem not found, id: ${id}`);
|
|
136
|
+
}
|
|
137
|
+
if ((_dataFetchItem_ = dataFetchItem[1]) === null || _dataFetchItem_ === void 0 ? void 0 : _dataFetchItem_[0]) {
|
|
138
|
+
return dataFetchItem[1][0];
|
|
139
|
+
}
|
|
140
|
+
if ((0, import_utils.isCSROnly)()) {
|
|
141
|
+
import_logger.default.debug("==========csr only!");
|
|
142
|
+
return callFetchData();
|
|
143
|
+
}
|
|
144
|
+
if (remoteInfo) {
|
|
145
|
+
return (0, import_downgrade.callDowngrade)(id, params, remoteInfo);
|
|
146
|
+
}
|
|
147
|
+
const mfDowngrade = (0, import_downgrade.getDowngradeTag)();
|
|
148
|
+
if (mfDowngrade) {
|
|
149
|
+
if (typeof mfDowngrade === "boolean") {
|
|
150
|
+
return (0, import_downgrade.callDowngrade)(id, params);
|
|
151
|
+
}
|
|
152
|
+
if (mfDowngrade.includes(id)) {
|
|
153
|
+
return (0, import_downgrade.callDowngrade)(id, params);
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
let res;
|
|
157
|
+
let rej;
|
|
158
|
+
const p = new Promise((resolve, reject) => {
|
|
159
|
+
res = resolve;
|
|
160
|
+
rej = reject;
|
|
161
|
+
});
|
|
162
|
+
dataFetchItem[1] = [
|
|
163
|
+
p,
|
|
164
|
+
res,
|
|
165
|
+
rej
|
|
166
|
+
];
|
|
167
|
+
dataFetchItem[2] = import_constant.MF_DATA_FETCH_STATUS.AWAIT;
|
|
168
|
+
return dataFetchItem[1][0];
|
|
169
|
+
}
|
|
170
|
+
return callFetchData();
|
|
171
|
+
}
|
|
172
|
+
function getDataFetchMapKey(dataFetchInfo, hostInfo) {
|
|
173
|
+
if (!dataFetchInfo || !hostInfo) {
|
|
174
|
+
return;
|
|
175
|
+
}
|
|
176
|
+
const { dataFetchId } = dataFetchInfo;
|
|
177
|
+
return (0, import_sdk.composeKeyWithSeparator)(dataFetchId, hostInfo.name, hostInfo.version);
|
|
178
|
+
}
|
|
179
|
+
async function loadDataFetchModule(instance, id) {
|
|
180
|
+
return instance.loadRemote(id).then((m) => {
|
|
181
|
+
if (m && typeof m === "object" && "fetchData" in m && typeof m.fetchData === "function") {
|
|
182
|
+
return m.fetchData;
|
|
183
|
+
}
|
|
184
|
+
throw new Error(`fetchData not found in remote ${id}, ${JSON.stringify(m)}`);
|
|
185
|
+
});
|
|
186
|
+
}
|
|
187
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
188
|
+
0 && (module.exports = {
|
|
189
|
+
fetchData,
|
|
190
|
+
flushDataFetch,
|
|
191
|
+
getDataFetchIdWithErrorMsgs,
|
|
192
|
+
getDataFetchInfo,
|
|
193
|
+
getDataFetchItem,
|
|
194
|
+
getDataFetchMap,
|
|
195
|
+
getDataFetchMapKey,
|
|
196
|
+
initDataFetchMap,
|
|
197
|
+
loadDataFetchModule,
|
|
198
|
+
setDataFetchItemLoadedStatus,
|
|
199
|
+
wrapDataFetchId
|
|
200
|
+
});
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
|
19
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
20
|
+
var utils_exports = {};
|
|
21
|
+
__export(utils_exports, {
|
|
22
|
+
getLoadedRemoteInfos: () => getLoadedRemoteInfos,
|
|
23
|
+
isCSROnly: () => isCSROnly
|
|
24
|
+
});
|
|
25
|
+
module.exports = __toCommonJS(utils_exports);
|
|
26
|
+
__reExport(utils_exports, require("./dataFetch"), module.exports);
|
|
27
|
+
function getLoadedRemoteInfos(id, instance) {
|
|
28
|
+
if (!instance) {
|
|
29
|
+
return;
|
|
30
|
+
}
|
|
31
|
+
const { name, expose } = instance.remoteHandler.idToRemoteMap[id] || {};
|
|
32
|
+
if (!name) {
|
|
33
|
+
return;
|
|
34
|
+
}
|
|
35
|
+
const module2 = instance.moduleCache.get(name);
|
|
36
|
+
if (!module2) {
|
|
37
|
+
return;
|
|
38
|
+
}
|
|
39
|
+
const { remoteSnapshot } = instance.snapshotHandler.getGlobalRemoteInfo(module2.remoteInfo);
|
|
40
|
+
return {
|
|
41
|
+
...module2.remoteInfo,
|
|
42
|
+
snapshot: remoteSnapshot,
|
|
43
|
+
expose
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
function isCSROnly() {
|
|
47
|
+
return window._SSR_DATA === void 0;
|
|
48
|
+
}
|
|
49
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
50
|
+
0 && (module.exports = {
|
|
51
|
+
getLoadedRemoteInfos,
|
|
52
|
+
isCSROnly,
|
|
53
|
+
...require("./dataFetch")
|
|
54
|
+
});
|