@module-federation/modern-js 0.15.0 → 0.17.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.
- package/dist/cjs/cli/configPlugin.js +5 -4
- package/dist/cjs/cli/configPlugin.spec.js +1 -3
- package/dist/cjs/cli/server/data-fetch-server-plugin.js +2 -143
- package/dist/cjs/cli/ssrPlugin.js +8 -8
- package/dist/cjs/constant.js +2 -49
- package/dist/cjs/{runtime/wrapNoSSR.js → react/index.js} +22 -13
- package/dist/cjs/runtime/index.js +0 -28
- package/dist/cjs/ssr-runtime/devPlugin.js +2 -2
- package/dist/cjs/ssr-runtime/injectDataFetchFunctionPlugin.js +6 -102
- package/dist/esm/cli/configPlugin.js +5 -4
- package/dist/esm/cli/configPlugin.spec.js +1 -3
- package/dist/esm/cli/server/data-fetch-server-plugin.js +2 -219
- package/dist/esm/cli/ssrPlugin.js +1 -1
- package/dist/esm/constant.js +1 -37
- package/dist/esm/react/index.js +12 -0
- package/dist/esm/runtime/index.js +0 -21
- package/dist/esm/ssr-runtime/devPlugin.js +1 -1
- package/dist/esm/ssr-runtime/injectDataFetchFunctionPlugin.js +4 -147
- package/dist/esm-node/cli/configPlugin.js +5 -4
- package/dist/esm-node/cli/configPlugin.spec.js +1 -3
- package/dist/esm-node/cli/server/data-fetch-server-plugin.js +2 -143
- package/dist/esm-node/cli/ssrPlugin.js +1 -1
- package/dist/esm-node/constant.js +1 -37
- package/dist/esm-node/react/index.js +12 -0
- package/dist/esm-node/runtime/index.js +0 -21
- package/dist/esm-node/ssr-runtime/devPlugin.js +1 -1
- package/dist/esm-node/ssr-runtime/injectDataFetchFunctionPlugin.js +4 -89
- package/dist/types/cli/index.d.ts +1 -1
- package/dist/types/cli/mfRuntimePlugins/inject-node-fetch.d.ts +2 -2
- package/dist/types/cli/mfRuntimePlugins/resolve-entry-ipv4.d.ts +2 -2
- package/dist/types/cli/mfRuntimePlugins/shared-strategy.d.ts +2 -2
- package/dist/types/constant.d.ts +0 -23
- package/dist/types/react/index.d.ts +2 -0
- package/dist/types/runtime/index.d.ts +0 -9
- package/dist/types/ssr-runtime/injectDataFetchFunctionPlugin.d.ts +0 -3
- package/package.json +24 -24
- package/dist/cjs/cli/mfRuntimePlugins/auto-fetch-data.js +0 -98
- package/dist/cjs/interfaces/global.js +0 -16
- package/dist/cjs/runtime/AwaitDataFetch.js +0 -144
- package/dist/cjs/runtime/createRemoteComponent.js +0 -327
- package/dist/cjs/ssr-runtime/downgrade.js +0 -114
- package/dist/cjs/utils/dataFetch.js +0 -211
- package/dist/cjs/utils/index.js +0 -54
- package/dist/esm/cli/mfRuntimePlugins/auto-fetch-data.js +0 -74
- package/dist/esm/interfaces/global.js +0 -0
- package/dist/esm/runtime/AwaitDataFetch.js +0 -131
- package/dist/esm/runtime/createRemoteComponent.js +0 -417
- package/dist/esm/runtime/wrapNoSSR.js +0 -12
- package/dist/esm/ssr-runtime/downgrade.js +0 -150
- package/dist/esm/utils/dataFetch.js +0 -237
- package/dist/esm/utils/index.js +0 -28
- package/dist/esm-node/cli/mfRuntimePlugins/auto-fetch-data.js +0 -68
- package/dist/esm-node/interfaces/global.js +0 -0
- package/dist/esm-node/runtime/AwaitDataFetch.js +0 -109
- package/dist/esm-node/runtime/createRemoteComponent.js +0 -291
- package/dist/esm-node/runtime/wrapNoSSR.js +0 -11
- package/dist/esm-node/ssr-runtime/downgrade.js +0 -88
- package/dist/esm-node/utils/dataFetch.js +0 -166
- package/dist/esm-node/utils/index.js +0 -27
- package/dist/types/cli/mfRuntimePlugins/auto-fetch-data.d.ts +0 -3
- package/dist/types/interfaces/global.d.ts +0 -27
- package/dist/types/runtime/AwaitDataFetch.d.ts +0 -19
- package/dist/types/runtime/createRemoteComponent.d.ts +0 -26
- package/dist/types/runtime/wrapNoSSR.d.ts +0 -9
- package/dist/types/ssr-runtime/downgrade.d.ts +0 -4
- package/dist/types/utils/dataFetch.d.ts +0 -26
- package/dist/types/utils/index.d.ts +0 -15
|
@@ -1,417 +0,0 @@
|
|
|
1
|
-
import { _ as _async_to_generator } from "@swc/helpers/_/_async_to_generator";
|
|
2
|
-
import { _ as _object_spread } from "@swc/helpers/_/_object_spread";
|
|
3
|
-
import { _ as _object_spread_props } from "@swc/helpers/_/_object_spread_props";
|
|
4
|
-
import { _ as _object_without_properties } from "@swc/helpers/_/_object_without_properties";
|
|
5
|
-
import { _ as _sliced_to_array } from "@swc/helpers/_/_sliced_to_array";
|
|
6
|
-
import { _ as _tagged_template_literal } from "@swc/helpers/_/_tagged_template_literal";
|
|
7
|
-
import { _ as _to_consumable_array } from "@swc/helpers/_/_to_consumable_array";
|
|
8
|
-
import { _ as _ts_generator } from "@swc/helpers/_/_ts_generator";
|
|
9
|
-
function _templateObject() {
|
|
10
|
-
var data = _tagged_template_literal([
|
|
11
|
-
"\n globalThis['",
|
|
12
|
-
"'] = globalThis['",
|
|
13
|
-
"'] || [];\n globalThis['",
|
|
14
|
-
"'].push(['",
|
|
15
|
-
"',",
|
|
16
|
-
"]);\n "
|
|
17
|
-
]);
|
|
18
|
-
_templateObject = function _templateObject2() {
|
|
19
|
-
return data;
|
|
20
|
-
};
|
|
21
|
-
return data;
|
|
22
|
-
}
|
|
23
|
-
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
24
|
-
import React, { useEffect, useState } from "react";
|
|
25
|
-
import logger from "../logger";
|
|
26
|
-
import { getInstance } from "@module-federation/enhanced/runtime";
|
|
27
|
-
import { AwaitDataFetch, transformError } from "./AwaitDataFetch";
|
|
28
|
-
import { fetchData, getDataFetchItem, getDataFetchMapKey } from "../utils/dataFetch";
|
|
29
|
-
import { getDataFetchInfo, getLoadedRemoteInfos, setDataFetchItemLoadedStatus, wrapDataFetchId } from "../utils";
|
|
30
|
-
import { DATA_FETCH_ERROR_PREFIX, DATA_FETCH_FUNCTION, FS_HREF, LOAD_REMOTE_ERROR_PREFIX, MF_DATA_FETCH_TYPE } from "../constant";
|
|
31
|
-
function getTargetModuleInfo(id) {
|
|
32
|
-
var instance = getInstance();
|
|
33
|
-
if (!instance) {
|
|
34
|
-
return;
|
|
35
|
-
}
|
|
36
|
-
var loadedRemoteInfo = getLoadedRemoteInfos(id, instance);
|
|
37
|
-
if (!loadedRemoteInfo) {
|
|
38
|
-
return;
|
|
39
|
-
}
|
|
40
|
-
var snapshot = loadedRemoteInfo.snapshot;
|
|
41
|
-
if (!snapshot) {
|
|
42
|
-
return;
|
|
43
|
-
}
|
|
44
|
-
var publicPath = "publicPath" in snapshot ? snapshot.publicPath : "getPublicPath" in snapshot ? new Function(snapshot.getPublicPath)() : "";
|
|
45
|
-
if (!publicPath) {
|
|
46
|
-
return;
|
|
47
|
-
}
|
|
48
|
-
var modules = "modules" in snapshot ? snapshot.modules : [];
|
|
49
|
-
var targetModule = modules.find(function(m) {
|
|
50
|
-
return m.modulePath === loadedRemoteInfo.expose;
|
|
51
|
-
});
|
|
52
|
-
if (!targetModule) {
|
|
53
|
-
return;
|
|
54
|
-
}
|
|
55
|
-
var remoteEntry = "remoteEntry" in snapshot ? snapshot.remoteEntry : "";
|
|
56
|
-
if (!remoteEntry) {
|
|
57
|
-
return;
|
|
58
|
-
}
|
|
59
|
-
return {
|
|
60
|
-
module: targetModule,
|
|
61
|
-
publicPath,
|
|
62
|
-
remoteEntry
|
|
63
|
-
};
|
|
64
|
-
}
|
|
65
|
-
function collectSSRAssets(options) {
|
|
66
|
-
var _ref = typeof options === "string" ? {
|
|
67
|
-
id: options
|
|
68
|
-
} : options, id = _ref.id, _ref_injectLink = _ref.injectLink, injectLink = _ref_injectLink === void 0 ? true : _ref_injectLink, _ref_injectScript = _ref.injectScript, injectScript = _ref_injectScript === void 0 ? false : _ref_injectScript;
|
|
69
|
-
var links = [];
|
|
70
|
-
var scripts = [];
|
|
71
|
-
var instance = getInstance();
|
|
72
|
-
if (!instance || !injectLink && !injectScript) {
|
|
73
|
-
return _to_consumable_array(scripts).concat(_to_consumable_array(links));
|
|
74
|
-
}
|
|
75
|
-
var moduleAndPublicPath = getTargetModuleInfo(id);
|
|
76
|
-
if (!moduleAndPublicPath) {
|
|
77
|
-
return _to_consumable_array(scripts).concat(_to_consumable_array(links));
|
|
78
|
-
}
|
|
79
|
-
var targetModule = moduleAndPublicPath.module, publicPath = moduleAndPublicPath.publicPath, remoteEntry = moduleAndPublicPath.remoteEntry;
|
|
80
|
-
if (injectLink) {
|
|
81
|
-
_to_consumable_array(targetModule.assets.css.sync).concat(_to_consumable_array(targetModule.assets.css.async)).sort().forEach(function(file, index) {
|
|
82
|
-
links.push(/* @__PURE__ */ _jsx("link", {
|
|
83
|
-
href: "".concat(publicPath).concat(file),
|
|
84
|
-
rel: "stylesheet",
|
|
85
|
-
type: "text/css"
|
|
86
|
-
}, "".concat(file.split(".")[0], "_").concat(index)));
|
|
87
|
-
});
|
|
88
|
-
}
|
|
89
|
-
if (injectScript) {
|
|
90
|
-
scripts.push(/* @__PURE__ */ _jsx("script", {
|
|
91
|
-
async: true,
|
|
92
|
-
src: "".concat(publicPath).concat(remoteEntry),
|
|
93
|
-
crossOrigin: "anonymous"
|
|
94
|
-
}, remoteEntry.split(".")[0]));
|
|
95
|
-
_to_consumable_array(targetModule.assets.js.sync).sort().forEach(function(file, index) {
|
|
96
|
-
scripts.push(/* @__PURE__ */ _jsx("script", {
|
|
97
|
-
async: true,
|
|
98
|
-
src: "".concat(publicPath).concat(file),
|
|
99
|
-
crossOrigin: "anonymous"
|
|
100
|
-
}, "".concat(file.split(".")[0], "_").concat(index)));
|
|
101
|
-
});
|
|
102
|
-
}
|
|
103
|
-
return _to_consumable_array(scripts).concat(_to_consumable_array(links));
|
|
104
|
-
}
|
|
105
|
-
function getServerNeedRemoteInfo(loadedRemoteInfo, id, noSSR) {
|
|
106
|
-
if (noSSR || typeof window !== "undefined" && window.location.href !== window[FS_HREF]) {
|
|
107
|
-
var _dataFetchItem_;
|
|
108
|
-
if (!(loadedRemoteInfo === null || loadedRemoteInfo === void 0 ? void 0 : loadedRemoteInfo.version)) {
|
|
109
|
-
throw new Error("".concat(loadedRemoteInfo === null || loadedRemoteInfo === void 0 ? void 0 : loadedRemoteInfo.name, " version is empty"));
|
|
110
|
-
}
|
|
111
|
-
var snapshot = loadedRemoteInfo.snapshot;
|
|
112
|
-
if (!snapshot) {
|
|
113
|
-
throw new Error("".concat(loadedRemoteInfo === null || loadedRemoteInfo === void 0 ? void 0 : loadedRemoteInfo.name, " snapshot is empty"));
|
|
114
|
-
}
|
|
115
|
-
var dataFetchItem = getDataFetchItem(id);
|
|
116
|
-
var isFetchServer = (dataFetchItem === null || dataFetchItem === void 0 ? void 0 : (_dataFetchItem_ = dataFetchItem[0]) === null || _dataFetchItem_ === void 0 ? void 0 : _dataFetchItem_[1]) === MF_DATA_FETCH_TYPE.FETCH_SERVER;
|
|
117
|
-
if (isFetchServer && (!("ssrPublicPath" in snapshot) || !snapshot.ssrPublicPath)) {
|
|
118
|
-
throw new Error("ssrPublicPath is required while fetching ".concat(loadedRemoteInfo === null || loadedRemoteInfo === void 0 ? void 0 : loadedRemoteInfo.name, " data in SSR project!"));
|
|
119
|
-
}
|
|
120
|
-
if (isFetchServer && (!("ssrRemoteEntry" in snapshot) || !snapshot.ssrRemoteEntry)) {
|
|
121
|
-
throw new Error("ssrRemoteEntry is required while loading ".concat(loadedRemoteInfo === null || loadedRemoteInfo === void 0 ? void 0 : loadedRemoteInfo.name, " data loader in SSR project!"));
|
|
122
|
-
}
|
|
123
|
-
return {
|
|
124
|
-
name: loadedRemoteInfo.name,
|
|
125
|
-
version: loadedRemoteInfo.version,
|
|
126
|
-
ssrPublicPath: "ssrPublicPath" in snapshot ? snapshot.ssrPublicPath || "" : "",
|
|
127
|
-
ssrRemoteEntry: "ssrRemoteEntry" in snapshot ? snapshot.ssrRemoteEntry || "" : "",
|
|
128
|
-
globalName: loadedRemoteInfo.entryGlobalName
|
|
129
|
-
};
|
|
130
|
-
}
|
|
131
|
-
return;
|
|
132
|
-
}
|
|
133
|
-
function createRemoteComponent(options) {
|
|
134
|
-
var exportName = (options === null || options === void 0 ? void 0 : options.export) || "default";
|
|
135
|
-
var callLoader = function() {
|
|
136
|
-
var _ref = _async_to_generator(function() {
|
|
137
|
-
var m;
|
|
138
|
-
return _ts_generator(this, function(_state) {
|
|
139
|
-
switch (_state.label) {
|
|
140
|
-
case 0:
|
|
141
|
-
logger.debug("callLoader start", Date.now());
|
|
142
|
-
return [
|
|
143
|
-
4,
|
|
144
|
-
options.loader()
|
|
145
|
-
];
|
|
146
|
-
case 1:
|
|
147
|
-
m = _state.sent();
|
|
148
|
-
logger.debug("callLoader end", Date.now());
|
|
149
|
-
if (!m) {
|
|
150
|
-
throw new Error("load remote failed");
|
|
151
|
-
}
|
|
152
|
-
return [
|
|
153
|
-
2,
|
|
154
|
-
m
|
|
155
|
-
];
|
|
156
|
-
}
|
|
157
|
-
});
|
|
158
|
-
});
|
|
159
|
-
return function callLoader2() {
|
|
160
|
-
return _ref.apply(this, arguments);
|
|
161
|
-
};
|
|
162
|
-
}();
|
|
163
|
-
var getData = function() {
|
|
164
|
-
var _ref = _async_to_generator(function(noSSR) {
|
|
165
|
-
var loadedRemoteInfo, moduleId, instance, m, e, errMsg, dataFetchMapKey, data, err, errMsg1;
|
|
166
|
-
return _ts_generator(this, function(_state) {
|
|
167
|
-
switch (_state.label) {
|
|
168
|
-
case 0:
|
|
169
|
-
instance = getInstance();
|
|
170
|
-
_state.label = 1;
|
|
171
|
-
case 1:
|
|
172
|
-
_state.trys.push([
|
|
173
|
-
1,
|
|
174
|
-
3,
|
|
175
|
-
,
|
|
176
|
-
4
|
|
177
|
-
]);
|
|
178
|
-
return [
|
|
179
|
-
4,
|
|
180
|
-
callLoader()
|
|
181
|
-
];
|
|
182
|
-
case 2:
|
|
183
|
-
m = _state.sent();
|
|
184
|
-
moduleId = m && m[Symbol.for("mf_module_id")];
|
|
185
|
-
if (!moduleId) {
|
|
186
|
-
throw new Error("moduleId is empty");
|
|
187
|
-
}
|
|
188
|
-
loadedRemoteInfo = getLoadedRemoteInfos(moduleId, instance);
|
|
189
|
-
if (!loadedRemoteInfo) {
|
|
190
|
-
throw new Error("can not find loaded remote('".concat(moduleId, "') info!"));
|
|
191
|
-
}
|
|
192
|
-
return [
|
|
193
|
-
3,
|
|
194
|
-
4
|
|
195
|
-
];
|
|
196
|
-
case 3:
|
|
197
|
-
e = _state.sent();
|
|
198
|
-
errMsg = "".concat(LOAD_REMOTE_ERROR_PREFIX).concat(e);
|
|
199
|
-
logger.debug(e);
|
|
200
|
-
throw new Error(errMsg);
|
|
201
|
-
case 4:
|
|
202
|
-
_state.trys.push([
|
|
203
|
-
4,
|
|
204
|
-
6,
|
|
205
|
-
,
|
|
206
|
-
7
|
|
207
|
-
]);
|
|
208
|
-
dataFetchMapKey = getDataFetchMapKey(getDataFetchInfo({
|
|
209
|
-
name: loadedRemoteInfo.name,
|
|
210
|
-
alias: loadedRemoteInfo.alias,
|
|
211
|
-
id: moduleId,
|
|
212
|
-
remoteSnapshot: loadedRemoteInfo.snapshot
|
|
213
|
-
}), {
|
|
214
|
-
name: instance.name,
|
|
215
|
-
version: instance === null || instance === void 0 ? void 0 : instance.options.version
|
|
216
|
-
});
|
|
217
|
-
logger.debug("getData dataFetchMapKey: ", dataFetchMapKey);
|
|
218
|
-
if (!dataFetchMapKey) {
|
|
219
|
-
return [
|
|
220
|
-
2
|
|
221
|
-
];
|
|
222
|
-
}
|
|
223
|
-
return [
|
|
224
|
-
4,
|
|
225
|
-
fetchData(dataFetchMapKey, _object_spread_props(_object_spread({}, options.dataFetchParams), {
|
|
226
|
-
isDowngrade: false
|
|
227
|
-
}), getServerNeedRemoteInfo(loadedRemoteInfo, dataFetchMapKey, noSSR))
|
|
228
|
-
];
|
|
229
|
-
case 5:
|
|
230
|
-
data = _state.sent();
|
|
231
|
-
setDataFetchItemLoadedStatus(dataFetchMapKey);
|
|
232
|
-
logger.debug("get data res: \n", data);
|
|
233
|
-
return [
|
|
234
|
-
2,
|
|
235
|
-
data
|
|
236
|
-
];
|
|
237
|
-
case 6:
|
|
238
|
-
err = _state.sent();
|
|
239
|
-
errMsg1 = "".concat(DATA_FETCH_ERROR_PREFIX).concat(wrapDataFetchId(dataFetchMapKey)).concat(err);
|
|
240
|
-
logger.debug(errMsg1);
|
|
241
|
-
throw new Error(errMsg1);
|
|
242
|
-
case 7:
|
|
243
|
-
return [
|
|
244
|
-
2
|
|
245
|
-
];
|
|
246
|
-
}
|
|
247
|
-
});
|
|
248
|
-
});
|
|
249
|
-
return function getData2(noSSR) {
|
|
250
|
-
return _ref.apply(this, arguments);
|
|
251
|
-
};
|
|
252
|
-
}();
|
|
253
|
-
var LazyComponent = /* @__PURE__ */ React.lazy(/* @__PURE__ */ _async_to_generator(function() {
|
|
254
|
-
var m, moduleId, instance, loadedRemoteInfo, dataFetchMapKey, assets, Com;
|
|
255
|
-
return _ts_generator(this, function(_state) {
|
|
256
|
-
switch (_state.label) {
|
|
257
|
-
case 0:
|
|
258
|
-
return [
|
|
259
|
-
4,
|
|
260
|
-
callLoader()
|
|
261
|
-
];
|
|
262
|
-
case 1:
|
|
263
|
-
m = _state.sent();
|
|
264
|
-
moduleId = m && m[Symbol.for("mf_module_id")];
|
|
265
|
-
instance = getInstance();
|
|
266
|
-
loadedRemoteInfo = getLoadedRemoteInfos(moduleId, instance);
|
|
267
|
-
loadedRemoteInfo === null || loadedRemoteInfo === void 0 ? void 0 : loadedRemoteInfo.snapshot;
|
|
268
|
-
dataFetchMapKey = loadedRemoteInfo ? getDataFetchMapKey(getDataFetchInfo({
|
|
269
|
-
name: loadedRemoteInfo.name,
|
|
270
|
-
alias: loadedRemoteInfo.alias,
|
|
271
|
-
id: moduleId,
|
|
272
|
-
remoteSnapshot: loadedRemoteInfo.snapshot
|
|
273
|
-
}), {
|
|
274
|
-
name: instance.name,
|
|
275
|
-
version: instance === null || instance === void 0 ? void 0 : instance.options.version
|
|
276
|
-
}) : void 0;
|
|
277
|
-
logger.debug("LazyComponent dataFetchMapKey: ", dataFetchMapKey);
|
|
278
|
-
assets = collectSSRAssets({
|
|
279
|
-
id: moduleId
|
|
280
|
-
});
|
|
281
|
-
Com = m[exportName];
|
|
282
|
-
if (exportName in m && typeof Com === "function") {
|
|
283
|
-
return [
|
|
284
|
-
2,
|
|
285
|
-
{
|
|
286
|
-
default: function(props) {
|
|
287
|
-
return /* @__PURE__ */ _jsxs(_Fragment, {
|
|
288
|
-
children: [
|
|
289
|
-
globalThis.FEDERATION_SSR && dataFetchMapKey && /* @__PURE__ */ _jsx("script", {
|
|
290
|
-
suppressHydrationWarning: true,
|
|
291
|
-
dangerouslySetInnerHTML: {
|
|
292
|
-
__html: String.raw(_templateObject(), DATA_FETCH_FUNCTION, DATA_FETCH_FUNCTION, DATA_FETCH_FUNCTION, dataFetchMapKey, JSON.stringify(props.mfData))
|
|
293
|
-
}
|
|
294
|
-
}),
|
|
295
|
-
globalThis.FEDERATION_SSR && assets,
|
|
296
|
-
/* @__PURE__ */ _jsx(Com, _object_spread({}, props))
|
|
297
|
-
]
|
|
298
|
-
});
|
|
299
|
-
}
|
|
300
|
-
}
|
|
301
|
-
];
|
|
302
|
-
} else {
|
|
303
|
-
throw Error("Make sure that ".concat(moduleId, " has the correct export when export is ").concat(String(exportName)));
|
|
304
|
-
}
|
|
305
|
-
return [
|
|
306
|
-
2
|
|
307
|
-
];
|
|
308
|
-
}
|
|
309
|
-
});
|
|
310
|
-
}));
|
|
311
|
-
return function(props) {
|
|
312
|
-
var key = props.key, args = _object_without_properties(props, [
|
|
313
|
-
"key"
|
|
314
|
-
]);
|
|
315
|
-
if (globalThis.FEDERATION_SSR && !options.noSSR) {
|
|
316
|
-
var key1 = props.key, args1 = _object_without_properties(props, [
|
|
317
|
-
"key"
|
|
318
|
-
]);
|
|
319
|
-
return /* @__PURE__ */ _jsx(AwaitDataFetch, {
|
|
320
|
-
resolve: getData(options.noSSR),
|
|
321
|
-
loading: options.loading,
|
|
322
|
-
errorElement: options.fallback,
|
|
323
|
-
children: function(data2) {
|
|
324
|
-
return /* @__PURE__ */ _jsx(LazyComponent, _object_spread_props(_object_spread({}, args1), {
|
|
325
|
-
mfData: data2
|
|
326
|
-
}));
|
|
327
|
-
}
|
|
328
|
-
});
|
|
329
|
-
} else {
|
|
330
|
-
var _useState = _sliced_to_array(useState(null), 2), data = _useState[0], setData = _useState[1];
|
|
331
|
-
var _useState1 = _sliced_to_array(useState(true), 2), loading = _useState1[0], setLoading = _useState1[1];
|
|
332
|
-
var _useState2 = _sliced_to_array(useState(null), 2), error = _useState2[0], setError = _useState2[1];
|
|
333
|
-
useEffect(function() {
|
|
334
|
-
var isMounted = true;
|
|
335
|
-
var fetchDataAsync = function() {
|
|
336
|
-
var _ref = _async_to_generator(function() {
|
|
337
|
-
var result, e;
|
|
338
|
-
return _ts_generator(this, function(_state) {
|
|
339
|
-
switch (_state.label) {
|
|
340
|
-
case 0:
|
|
341
|
-
_state.trys.push([
|
|
342
|
-
0,
|
|
343
|
-
2,
|
|
344
|
-
3,
|
|
345
|
-
4
|
|
346
|
-
]);
|
|
347
|
-
setLoading(true);
|
|
348
|
-
return [
|
|
349
|
-
4,
|
|
350
|
-
getData(options.noSSR)
|
|
351
|
-
];
|
|
352
|
-
case 1:
|
|
353
|
-
result = _state.sent();
|
|
354
|
-
if (isMounted) {
|
|
355
|
-
setData(result);
|
|
356
|
-
}
|
|
357
|
-
return [
|
|
358
|
-
3,
|
|
359
|
-
4
|
|
360
|
-
];
|
|
361
|
-
case 2:
|
|
362
|
-
e = _state.sent();
|
|
363
|
-
if (isMounted) {
|
|
364
|
-
setError(transformError(e));
|
|
365
|
-
}
|
|
366
|
-
return [
|
|
367
|
-
3,
|
|
368
|
-
4
|
|
369
|
-
];
|
|
370
|
-
case 3:
|
|
371
|
-
if (isMounted) {
|
|
372
|
-
setLoading(false);
|
|
373
|
-
}
|
|
374
|
-
return [
|
|
375
|
-
7
|
|
376
|
-
];
|
|
377
|
-
case 4:
|
|
378
|
-
return [
|
|
379
|
-
2
|
|
380
|
-
];
|
|
381
|
-
}
|
|
382
|
-
});
|
|
383
|
-
});
|
|
384
|
-
return function fetchDataAsync2() {
|
|
385
|
-
return _ref.apply(this, arguments);
|
|
386
|
-
};
|
|
387
|
-
}();
|
|
388
|
-
fetchDataAsync();
|
|
389
|
-
return function() {
|
|
390
|
-
isMounted = false;
|
|
391
|
-
};
|
|
392
|
-
}, []);
|
|
393
|
-
if (loading) {
|
|
394
|
-
return /* @__PURE__ */ _jsx(_Fragment, {
|
|
395
|
-
children: options.loading
|
|
396
|
-
});
|
|
397
|
-
}
|
|
398
|
-
if (error) {
|
|
399
|
-
return /* @__PURE__ */ _jsx(_Fragment, {
|
|
400
|
-
children: typeof options.fallback === "function" ? options.fallback(error) : options.fallback
|
|
401
|
-
});
|
|
402
|
-
}
|
|
403
|
-
return /* @__PURE__ */ _jsx(LazyComponent, _object_spread_props(_object_spread({}, args), {
|
|
404
|
-
mfData: data
|
|
405
|
-
}));
|
|
406
|
-
}
|
|
407
|
-
};
|
|
408
|
-
}
|
|
409
|
-
function createRemoteSSRComponent(options) {
|
|
410
|
-
logger.warn("createRemoteSSRComponent is deprecated, please use createRemoteComponent instead!");
|
|
411
|
-
return createRemoteComponent(options);
|
|
412
|
-
}
|
|
413
|
-
export {
|
|
414
|
-
collectSSRAssets,
|
|
415
|
-
createRemoteComponent,
|
|
416
|
-
createRemoteSSRComponent
|
|
417
|
-
};
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { _ as _object_spread } from "@swc/helpers/_/_object_spread";
|
|
2
|
-
import { _ as _object_spread_props } from "@swc/helpers/_/_object_spread_props";
|
|
3
|
-
function wrapNoSSR(createComponentFn) {
|
|
4
|
-
return function(options) {
|
|
5
|
-
return createComponentFn(_object_spread_props(_object_spread({}, options), {
|
|
6
|
-
noSSR: true
|
|
7
|
-
}));
|
|
8
|
-
};
|
|
9
|
-
}
|
|
10
|
-
export {
|
|
11
|
-
wrapNoSSR
|
|
12
|
-
};
|
|
@@ -1,150 +0,0 @@
|
|
|
1
|
-
import { _ as _async_to_generator } from "@swc/helpers/_/_async_to_generator";
|
|
2
|
-
import { _ as _object_spread } from "@swc/helpers/_/_object_spread";
|
|
3
|
-
import { _ as _object_spread_props } from "@swc/helpers/_/_object_spread_props";
|
|
4
|
-
import { _ as _type_of } from "@swc/helpers/_/_type_of";
|
|
5
|
-
import { _ as _ts_generator } from "@swc/helpers/_/_ts_generator";
|
|
6
|
-
import { DATA_FETCH_QUERY, DOWNGRADE_KEY } from "../constant";
|
|
7
|
-
import { MF_DATA_FETCH_STATUS, MF_DATA_FETCH_TYPE } from "../constant";
|
|
8
|
-
import { getDataFetchMap } from "../utils";
|
|
9
|
-
function getDowngradeTag() {
|
|
10
|
-
return globalThis[DOWNGRADE_KEY];
|
|
11
|
-
}
|
|
12
|
-
function callAllDowngrade() {
|
|
13
|
-
var dataFetchMap = getDataFetchMap();
|
|
14
|
-
if (!dataFetchMap) {
|
|
15
|
-
return;
|
|
16
|
-
}
|
|
17
|
-
Object.keys(dataFetchMap).forEach(function(key) {
|
|
18
|
-
callDowngrade(key);
|
|
19
|
-
});
|
|
20
|
-
}
|
|
21
|
-
function callDowngrade(id, params, remoteInfo) {
|
|
22
|
-
return _callDowngrade.apply(this, arguments);
|
|
23
|
-
}
|
|
24
|
-
function _callDowngrade() {
|
|
25
|
-
_callDowngrade = _async_to_generator(function(id, params, remoteInfo) {
|
|
26
|
-
var dataFetchMap, mfDataFetch, promise, res, rej, dataFetchType, currentUrl, fetchServerQuery, fetchUrl, data, e;
|
|
27
|
-
return _ts_generator(this, function(_state) {
|
|
28
|
-
switch (_state.label) {
|
|
29
|
-
case 0:
|
|
30
|
-
dataFetchMap = getDataFetchMap();
|
|
31
|
-
if (!dataFetchMap) {
|
|
32
|
-
return [
|
|
33
|
-
2
|
|
34
|
-
];
|
|
35
|
-
}
|
|
36
|
-
mfDataFetch = dataFetchMap[id];
|
|
37
|
-
if (!((mfDataFetch === null || mfDataFetch === void 0 ? void 0 : mfDataFetch[2]) === MF_DATA_FETCH_STATUS.AWAIT))
|
|
38
|
-
return [
|
|
39
|
-
3,
|
|
40
|
-
6
|
|
41
|
-
];
|
|
42
|
-
mfDataFetch[2] = MF_DATA_FETCH_STATUS.LOADING;
|
|
43
|
-
if (mfDataFetch[1]) {
|
|
44
|
-
promise = mfDataFetch[1][0];
|
|
45
|
-
res = mfDataFetch[1][1];
|
|
46
|
-
rej = mfDataFetch[1][2];
|
|
47
|
-
} else {
|
|
48
|
-
promise = new Promise(function(resolve, reject) {
|
|
49
|
-
res = resolve;
|
|
50
|
-
rej = reject;
|
|
51
|
-
});
|
|
52
|
-
mfDataFetch[1] = [
|
|
53
|
-
promise,
|
|
54
|
-
res,
|
|
55
|
-
rej
|
|
56
|
-
];
|
|
57
|
-
}
|
|
58
|
-
dataFetchType = mfDataFetch[0][1];
|
|
59
|
-
if (!(dataFetchType === MF_DATA_FETCH_TYPE.FETCH_CLIENT))
|
|
60
|
-
return [
|
|
61
|
-
3,
|
|
62
|
-
1
|
|
63
|
-
];
|
|
64
|
-
try {
|
|
65
|
-
mfDataFetch[0][0]().then(function(getDataFetchFn) {
|
|
66
|
-
return getDataFetchFn(_object_spread_props(_object_spread({}, params), {
|
|
67
|
-
isDowngrade: true
|
|
68
|
-
})).then(function(data2) {
|
|
69
|
-
mfDataFetch[2] = MF_DATA_FETCH_STATUS.LOADED;
|
|
70
|
-
res(data2);
|
|
71
|
-
});
|
|
72
|
-
});
|
|
73
|
-
} catch (e2) {
|
|
74
|
-
mfDataFetch[2] = MF_DATA_FETCH_STATUS.ERROR;
|
|
75
|
-
rej(e2);
|
|
76
|
-
}
|
|
77
|
-
return [
|
|
78
|
-
3,
|
|
79
|
-
5
|
|
80
|
-
];
|
|
81
|
-
case 1:
|
|
82
|
-
if (!(dataFetchType === MF_DATA_FETCH_TYPE.FETCH_SERVER))
|
|
83
|
-
return [
|
|
84
|
-
3,
|
|
85
|
-
5
|
|
86
|
-
];
|
|
87
|
-
_state.label = 2;
|
|
88
|
-
case 2:
|
|
89
|
-
_state.trys.push([
|
|
90
|
-
2,
|
|
91
|
-
4,
|
|
92
|
-
,
|
|
93
|
-
5
|
|
94
|
-
]);
|
|
95
|
-
currentUrl = new URL(window.location.href);
|
|
96
|
-
currentUrl.searchParams.set(DATA_FETCH_QUERY, encodeURIComponent(id));
|
|
97
|
-
if (params) {
|
|
98
|
-
currentUrl.searchParams.set("params", encodeURIComponent(JSON.stringify(params)));
|
|
99
|
-
}
|
|
100
|
-
if (remoteInfo) {
|
|
101
|
-
currentUrl.searchParams.set("remoteInfo", encodeURIComponent(JSON.stringify(remoteInfo)));
|
|
102
|
-
}
|
|
103
|
-
fetchServerQuery = globalThis.FEDERATION_SERVER_QUERY;
|
|
104
|
-
if (fetchServerQuery && (typeof fetchServerQuery === "undefined" ? "undefined" : _type_of(fetchServerQuery)) === "object") {
|
|
105
|
-
Object.keys(fetchServerQuery).forEach(function(key) {
|
|
106
|
-
currentUrl.searchParams.set(key, JSON.stringify(fetchServerQuery[key]));
|
|
107
|
-
});
|
|
108
|
-
}
|
|
109
|
-
fetchUrl = currentUrl.toString();
|
|
110
|
-
return [
|
|
111
|
-
4,
|
|
112
|
-
fetch(fetchUrl).then(function(res2) {
|
|
113
|
-
return res2.json();
|
|
114
|
-
})
|
|
115
|
-
];
|
|
116
|
-
case 3:
|
|
117
|
-
data = _state.sent();
|
|
118
|
-
mfDataFetch[2] = MF_DATA_FETCH_STATUS.LOADED;
|
|
119
|
-
res(data);
|
|
120
|
-
return [
|
|
121
|
-
3,
|
|
122
|
-
5
|
|
123
|
-
];
|
|
124
|
-
case 4:
|
|
125
|
-
e = _state.sent();
|
|
126
|
-
mfDataFetch[2] = MF_DATA_FETCH_STATUS.ERROR;
|
|
127
|
-
rej(e);
|
|
128
|
-
return [
|
|
129
|
-
3,
|
|
130
|
-
5
|
|
131
|
-
];
|
|
132
|
-
case 5:
|
|
133
|
-
return [
|
|
134
|
-
2,
|
|
135
|
-
promise
|
|
136
|
-
];
|
|
137
|
-
case 6:
|
|
138
|
-
return [
|
|
139
|
-
2
|
|
140
|
-
];
|
|
141
|
-
}
|
|
142
|
-
});
|
|
143
|
-
});
|
|
144
|
-
return _callDowngrade.apply(this, arguments);
|
|
145
|
-
}
|
|
146
|
-
export {
|
|
147
|
-
callAllDowngrade,
|
|
148
|
-
callDowngrade,
|
|
149
|
-
getDowngradeTag
|
|
150
|
-
};
|