@module-federation/bridge-react 0.0.0-next-20241021083129 → 0.0.0-next-20241025122930
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/CHANGELOG.md +15 -5
- package/dist/index.cjs.js +19 -1075
- package/dist/index.d.ts +5 -19
- package/dist/index.es.js +19 -1075
- package/dist/router.cjs.js +1 -1
- package/dist/router.es.js +1 -1
- package/package.json +5 -6
- package/src/create.tsx +2 -2
- package/src/provider.tsx +8 -62
- package/src/remote/index.tsx +3 -50
- package/src/router-v5.tsx +1 -0
- package/src/router.tsx +1 -1
- package/src/lifecycle.ts +0 -28
package/dist/index.es.js
CHANGED
|
@@ -2,7 +2,6 @@ import * as React from "react";
|
|
|
2
2
|
import React__default, { createContext, Component, createElement, isValidElement, forwardRef, useRef, useEffect, useContext, useState } from "react";
|
|
3
3
|
import { L as LoggerInstance, p as pathJoin, f, a as atLeastReact18, R as RouterContext } from "./context-Bw2PEwa6.js";
|
|
4
4
|
import * as ReactRouterDOM from "react-router-dom";
|
|
5
|
-
import { getInstance } from "@module-federation/runtime";
|
|
6
5
|
import ReactDOM from "react-dom";
|
|
7
6
|
const ErrorBoundaryContext = createContext(null);
|
|
8
7
|
const initialState = {
|
|
@@ -15,17 +14,17 @@ class ErrorBoundary extends Component {
|
|
|
15
14
|
this.resetErrorBoundary = this.resetErrorBoundary.bind(this);
|
|
16
15
|
this.state = initialState;
|
|
17
16
|
}
|
|
18
|
-
static getDerivedStateFromError(
|
|
17
|
+
static getDerivedStateFromError(error) {
|
|
19
18
|
return {
|
|
20
19
|
didCatch: true,
|
|
21
|
-
error
|
|
20
|
+
error
|
|
22
21
|
};
|
|
23
22
|
}
|
|
24
23
|
resetErrorBoundary() {
|
|
25
24
|
const {
|
|
26
|
-
error
|
|
25
|
+
error
|
|
27
26
|
} = this.state;
|
|
28
|
-
if (
|
|
27
|
+
if (error !== null) {
|
|
29
28
|
var _this$props$onReset, _this$props;
|
|
30
29
|
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
31
30
|
args[_key] = arguments[_key];
|
|
@@ -37,9 +36,9 @@ class ErrorBoundary extends Component {
|
|
|
37
36
|
this.setState(initialState);
|
|
38
37
|
}
|
|
39
38
|
}
|
|
40
|
-
componentDidCatch(
|
|
39
|
+
componentDidCatch(error, info) {
|
|
41
40
|
var _this$props$onError, _this$props2;
|
|
42
|
-
(_this$props$onError = (_this$props2 = this.props).onError) === null || _this$props$onError === void 0 ? void 0 : _this$props$onError.call(_this$props2,
|
|
41
|
+
(_this$props$onError = (_this$props2 = this.props).onError) === null || _this$props$onError === void 0 ? void 0 : _this$props$onError.call(_this$props2, error, info);
|
|
43
42
|
}
|
|
44
43
|
componentDidUpdate(prevProps, prevState) {
|
|
45
44
|
const {
|
|
@@ -67,12 +66,12 @@ class ErrorBoundary extends Component {
|
|
|
67
66
|
} = this.props;
|
|
68
67
|
const {
|
|
69
68
|
didCatch,
|
|
70
|
-
error
|
|
69
|
+
error
|
|
71
70
|
} = this.state;
|
|
72
71
|
let childToRender = children;
|
|
73
72
|
if (didCatch) {
|
|
74
73
|
const props = {
|
|
75
|
-
error
|
|
74
|
+
error,
|
|
76
75
|
resetErrorBoundary: this.resetErrorBoundary
|
|
77
76
|
};
|
|
78
77
|
if (typeof fallbackRender === "function") {
|
|
@@ -82,13 +81,13 @@ class ErrorBoundary extends Component {
|
|
|
82
81
|
} else if (fallback === null || isValidElement(fallback)) {
|
|
83
82
|
childToRender = fallback;
|
|
84
83
|
} else {
|
|
85
|
-
throw
|
|
84
|
+
throw error;
|
|
86
85
|
}
|
|
87
86
|
}
|
|
88
87
|
return createElement(ErrorBoundaryContext.Provider, {
|
|
89
88
|
value: {
|
|
90
89
|
didCatch,
|
|
91
|
-
error
|
|
90
|
+
error,
|
|
92
91
|
resetErrorBoundary: this.resetErrorBoundary
|
|
93
92
|
}
|
|
94
93
|
}, childToRender);
|
|
@@ -99,1026 +98,7 @@ function hasArrayChanged() {
|
|
|
99
98
|
let b = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : [];
|
|
100
99
|
return a.length !== b.length || a.some((item, index) => !Object.is(item, b[index]));
|
|
101
100
|
}
|
|
102
|
-
const BROWSER_LOG_KEY = "FEDERATION_DEBUG";
|
|
103
|
-
const BROWSER_LOG_VALUE = "1";
|
|
104
|
-
function isBrowserEnv() {
|
|
105
|
-
return typeof window !== "undefined";
|
|
106
|
-
}
|
|
107
|
-
function isDebugMode() {
|
|
108
|
-
if (typeof process !== "undefined" && process.env && process.env["FEDERATION_DEBUG"]) {
|
|
109
|
-
return Boolean(process.env["FEDERATION_DEBUG"]);
|
|
110
|
-
}
|
|
111
|
-
return typeof FEDERATION_DEBUG !== "undefined" && Boolean(FEDERATION_DEBUG);
|
|
112
|
-
}
|
|
113
|
-
const DEBUG_LOG = "[ FEDERATION DEBUG ]";
|
|
114
|
-
function safeToString$1(info) {
|
|
115
|
-
try {
|
|
116
|
-
return JSON.stringify(info, null, 2);
|
|
117
|
-
} catch (e) {
|
|
118
|
-
return "";
|
|
119
|
-
}
|
|
120
|
-
}
|
|
121
|
-
function safeGetLocalStorageItem() {
|
|
122
|
-
try {
|
|
123
|
-
if (typeof window !== "undefined" && window.localStorage) {
|
|
124
|
-
return localStorage.getItem(BROWSER_LOG_KEY) === BROWSER_LOG_VALUE;
|
|
125
|
-
}
|
|
126
|
-
} catch (error2) {
|
|
127
|
-
return typeof document !== "undefined";
|
|
128
|
-
}
|
|
129
|
-
return false;
|
|
130
|
-
}
|
|
131
|
-
let Logger = class Logger2 {
|
|
132
|
-
info(msg, info) {
|
|
133
|
-
if (this.enable) {
|
|
134
|
-
const argsToString = safeToString$1(info) || "";
|
|
135
|
-
if (isBrowserEnv()) {
|
|
136
|
-
console.info(`%c ${this.identifier}: ${msg} ${argsToString}`, "color:#3300CC");
|
|
137
|
-
} else {
|
|
138
|
-
console.info("\x1B[34m%s", `${this.identifier}: ${msg} ${argsToString ? `
|
|
139
|
-
${argsToString}` : ""}`);
|
|
140
|
-
}
|
|
141
|
-
}
|
|
142
|
-
}
|
|
143
|
-
logOriginalInfo(...args) {
|
|
144
|
-
if (this.enable) {
|
|
145
|
-
if (isBrowserEnv()) {
|
|
146
|
-
console.info(`%c ${this.identifier}: OriginalInfo`, "color:#3300CC");
|
|
147
|
-
console.log(...args);
|
|
148
|
-
} else {
|
|
149
|
-
console.info(`%c ${this.identifier}: OriginalInfo`, "color:#3300CC");
|
|
150
|
-
console.log(...args);
|
|
151
|
-
}
|
|
152
|
-
}
|
|
153
|
-
}
|
|
154
|
-
constructor(identifier) {
|
|
155
|
-
this.enable = false;
|
|
156
|
-
this.identifier = identifier || DEBUG_LOG;
|
|
157
|
-
if (isBrowserEnv() && safeGetLocalStorageItem()) {
|
|
158
|
-
this.enable = true;
|
|
159
|
-
} else if (isDebugMode()) {
|
|
160
|
-
this.enable = true;
|
|
161
|
-
}
|
|
162
|
-
}
|
|
163
|
-
};
|
|
164
|
-
new Logger();
|
|
165
|
-
function _extends() {
|
|
166
|
-
_extends = Object.assign || function assign(target) {
|
|
167
|
-
for (var i = 1; i < arguments.length; i++) {
|
|
168
|
-
var source = arguments[i];
|
|
169
|
-
for (var key in source)
|
|
170
|
-
if (Object.prototype.hasOwnProperty.call(source, key))
|
|
171
|
-
target[key] = source[key];
|
|
172
|
-
}
|
|
173
|
-
return target;
|
|
174
|
-
};
|
|
175
|
-
return _extends.apply(this, arguments);
|
|
176
|
-
}
|
|
177
|
-
function _object_without_properties_loose(source, excluded) {
|
|
178
|
-
if (source == null)
|
|
179
|
-
return {};
|
|
180
|
-
var target = {};
|
|
181
|
-
var sourceKeys = Object.keys(source);
|
|
182
|
-
var key, i;
|
|
183
|
-
for (i = 0; i < sourceKeys.length; i++) {
|
|
184
|
-
key = sourceKeys[i];
|
|
185
|
-
if (excluded.indexOf(key) >= 0)
|
|
186
|
-
continue;
|
|
187
|
-
target[key] = source[key];
|
|
188
|
-
}
|
|
189
|
-
return target;
|
|
190
|
-
}
|
|
191
|
-
function getBuilderId() {
|
|
192
|
-
return typeof FEDERATION_BUILD_IDENTIFIER !== "undefined" ? FEDERATION_BUILD_IDENTIFIER : "";
|
|
193
|
-
}
|
|
194
|
-
const LOG_CATEGORY = "[ Federation Runtime ]";
|
|
195
|
-
function assert(condition, msg) {
|
|
196
|
-
if (!condition) {
|
|
197
|
-
error(msg);
|
|
198
|
-
}
|
|
199
|
-
}
|
|
200
|
-
function error(msg) {
|
|
201
|
-
if (msg instanceof Error) {
|
|
202
|
-
msg.message = `${LOG_CATEGORY}: ${msg.message}`;
|
|
203
|
-
throw msg;
|
|
204
|
-
}
|
|
205
|
-
throw new Error(`${LOG_CATEGORY}: ${msg}`);
|
|
206
|
-
}
|
|
207
|
-
function warn(msg) {
|
|
208
|
-
if (msg instanceof Error) {
|
|
209
|
-
msg.message = `${LOG_CATEGORY}: ${msg.message}`;
|
|
210
|
-
console.warn(msg);
|
|
211
|
-
} else {
|
|
212
|
-
console.warn(`${LOG_CATEGORY}: ${msg}`);
|
|
213
|
-
}
|
|
214
|
-
}
|
|
215
|
-
function getFMId(remoteInfo) {
|
|
216
|
-
if ("version" in remoteInfo && remoteInfo.version) {
|
|
217
|
-
return `${remoteInfo.name}:${remoteInfo.version}`;
|
|
218
|
-
} else if ("entry" in remoteInfo && remoteInfo.entry) {
|
|
219
|
-
return `${remoteInfo.name}:${remoteInfo.entry}`;
|
|
220
|
-
} else {
|
|
221
|
-
return `${remoteInfo.name}`;
|
|
222
|
-
}
|
|
223
|
-
}
|
|
224
|
-
function isObject(val) {
|
|
225
|
-
return val && typeof val === "object";
|
|
226
|
-
}
|
|
227
|
-
const objectToString = Object.prototype.toString;
|
|
228
|
-
function isPlainObject(val) {
|
|
229
|
-
return objectToString.call(val) === "[object Object]";
|
|
230
|
-
}
|
|
231
|
-
const nativeGlobal = (() => {
|
|
232
|
-
try {
|
|
233
|
-
return new Function("return this")();
|
|
234
|
-
} catch (e) {
|
|
235
|
-
return globalThis;
|
|
236
|
-
}
|
|
237
|
-
})();
|
|
238
|
-
const Global = nativeGlobal;
|
|
239
|
-
function definePropertyGlobalVal(target, key, val) {
|
|
240
|
-
Object.defineProperty(target, key, {
|
|
241
|
-
value: val,
|
|
242
|
-
configurable: false,
|
|
243
|
-
writable: true
|
|
244
|
-
});
|
|
245
|
-
}
|
|
246
|
-
function includeOwnProperty(target, key) {
|
|
247
|
-
return Object.hasOwnProperty.call(target, key);
|
|
248
|
-
}
|
|
249
|
-
if (!includeOwnProperty(globalThis, "__GLOBAL_LOADING_REMOTE_ENTRY__")) {
|
|
250
|
-
definePropertyGlobalVal(globalThis, "__GLOBAL_LOADING_REMOTE_ENTRY__", {});
|
|
251
|
-
}
|
|
252
|
-
function setGlobalDefaultVal(target) {
|
|
253
|
-
var _target___FEDERATION__, _target___FEDERATION__1, _target___FEDERATION__2, _target___FEDERATION__3, _target___FEDERATION__4, _target___FEDERATION__5;
|
|
254
|
-
if (includeOwnProperty(target, "__VMOK__") && !includeOwnProperty(target, "__FEDERATION__")) {
|
|
255
|
-
definePropertyGlobalVal(target, "__FEDERATION__", target.__VMOK__);
|
|
256
|
-
}
|
|
257
|
-
if (!includeOwnProperty(target, "__FEDERATION__")) {
|
|
258
|
-
definePropertyGlobalVal(target, "__FEDERATION__", {
|
|
259
|
-
__GLOBAL_PLUGIN__: [],
|
|
260
|
-
__INSTANCES__: [],
|
|
261
|
-
moduleInfo: {},
|
|
262
|
-
__SHARE__: {},
|
|
263
|
-
__MANIFEST_LOADING__: {},
|
|
264
|
-
__PRELOADED_MAP__: /* @__PURE__ */ new Map()
|
|
265
|
-
});
|
|
266
|
-
definePropertyGlobalVal(target, "__VMOK__", target.__FEDERATION__);
|
|
267
|
-
}
|
|
268
|
-
var ___GLOBAL_PLUGIN__;
|
|
269
|
-
(___GLOBAL_PLUGIN__ = (_target___FEDERATION__ = target.__FEDERATION__).__GLOBAL_PLUGIN__) != null ? ___GLOBAL_PLUGIN__ : _target___FEDERATION__.__GLOBAL_PLUGIN__ = [];
|
|
270
|
-
var ___INSTANCES__;
|
|
271
|
-
(___INSTANCES__ = (_target___FEDERATION__1 = target.__FEDERATION__).__INSTANCES__) != null ? ___INSTANCES__ : _target___FEDERATION__1.__INSTANCES__ = [];
|
|
272
|
-
var _moduleInfo;
|
|
273
|
-
(_moduleInfo = (_target___FEDERATION__2 = target.__FEDERATION__).moduleInfo) != null ? _moduleInfo : _target___FEDERATION__2.moduleInfo = {};
|
|
274
|
-
var ___SHARE__;
|
|
275
|
-
(___SHARE__ = (_target___FEDERATION__3 = target.__FEDERATION__).__SHARE__) != null ? ___SHARE__ : _target___FEDERATION__3.__SHARE__ = {};
|
|
276
|
-
var ___MANIFEST_LOADING__;
|
|
277
|
-
(___MANIFEST_LOADING__ = (_target___FEDERATION__4 = target.__FEDERATION__).__MANIFEST_LOADING__) != null ? ___MANIFEST_LOADING__ : _target___FEDERATION__4.__MANIFEST_LOADING__ = {};
|
|
278
|
-
var ___PRELOADED_MAP__;
|
|
279
|
-
(___PRELOADED_MAP__ = (_target___FEDERATION__5 = target.__FEDERATION__).__PRELOADED_MAP__) != null ? ___PRELOADED_MAP__ : _target___FEDERATION__5.__PRELOADED_MAP__ = /* @__PURE__ */ new Map();
|
|
280
|
-
}
|
|
281
|
-
setGlobalDefaultVal(globalThis);
|
|
282
|
-
setGlobalDefaultVal(nativeGlobal);
|
|
283
|
-
function resetFederationGlobalInfo() {
|
|
284
|
-
globalThis.__FEDERATION__.__GLOBAL_PLUGIN__ = [];
|
|
285
|
-
globalThis.__FEDERATION__.__INSTANCES__ = [];
|
|
286
|
-
globalThis.__FEDERATION__.moduleInfo = {};
|
|
287
|
-
globalThis.__FEDERATION__.__SHARE__ = {};
|
|
288
|
-
globalThis.__FEDERATION__.__MANIFEST_LOADING__ = {};
|
|
289
|
-
}
|
|
290
|
-
function getGlobalFederationInstance(name, version) {
|
|
291
|
-
const buildId = getBuilderId();
|
|
292
|
-
return globalThis.__FEDERATION__.__INSTANCES__.find((GMInstance) => {
|
|
293
|
-
if (buildId && GMInstance.options.id === getBuilderId()) {
|
|
294
|
-
return true;
|
|
295
|
-
}
|
|
296
|
-
if (GMInstance.options.name === name && !GMInstance.options.version && !version) {
|
|
297
|
-
return true;
|
|
298
|
-
}
|
|
299
|
-
if (GMInstance.options.name === name && version && GMInstance.options.version === version) {
|
|
300
|
-
return true;
|
|
301
|
-
}
|
|
302
|
-
return false;
|
|
303
|
-
});
|
|
304
|
-
}
|
|
305
|
-
function setGlobalFederationInstance(FederationInstance) {
|
|
306
|
-
globalThis.__FEDERATION__.__INSTANCES__.push(FederationInstance);
|
|
307
|
-
}
|
|
308
|
-
function getGlobalFederationConstructor() {
|
|
309
|
-
return globalThis.__FEDERATION__.__DEBUG_CONSTRUCTOR__;
|
|
310
|
-
}
|
|
311
|
-
function setGlobalFederationConstructor(FederationConstructor, isDebug = isDebugMode()) {
|
|
312
|
-
if (isDebug) {
|
|
313
|
-
globalThis.__FEDERATION__.__DEBUG_CONSTRUCTOR__ = FederationConstructor;
|
|
314
|
-
globalThis.__FEDERATION__.__DEBUG_CONSTRUCTOR_VERSION__ = "0.6.11";
|
|
315
|
-
}
|
|
316
|
-
}
|
|
317
|
-
function getInfoWithoutType(target, key) {
|
|
318
|
-
if (typeof key === "string") {
|
|
319
|
-
const keyRes = target[key];
|
|
320
|
-
if (keyRes) {
|
|
321
|
-
return {
|
|
322
|
-
value: target[key],
|
|
323
|
-
key
|
|
324
|
-
};
|
|
325
|
-
} else {
|
|
326
|
-
const targetKeys = Object.keys(target);
|
|
327
|
-
for (const targetKey of targetKeys) {
|
|
328
|
-
const [targetTypeOrName, _] = targetKey.split(":");
|
|
329
|
-
const nKey = `${targetTypeOrName}:${key}`;
|
|
330
|
-
const typeWithKeyRes = target[nKey];
|
|
331
|
-
if (typeWithKeyRes) {
|
|
332
|
-
return {
|
|
333
|
-
value: typeWithKeyRes,
|
|
334
|
-
key: nKey
|
|
335
|
-
};
|
|
336
|
-
}
|
|
337
|
-
}
|
|
338
|
-
return {
|
|
339
|
-
value: void 0,
|
|
340
|
-
key
|
|
341
|
-
};
|
|
342
|
-
}
|
|
343
|
-
} else {
|
|
344
|
-
throw new Error("key must be string");
|
|
345
|
-
}
|
|
346
|
-
}
|
|
347
|
-
const getGlobalSnapshot = () => nativeGlobal.__FEDERATION__.moduleInfo;
|
|
348
|
-
const getTargetSnapshotInfoByModuleInfo = (moduleInfo, snapshot) => {
|
|
349
|
-
const moduleKey = getFMId(moduleInfo);
|
|
350
|
-
const getModuleInfo = getInfoWithoutType(snapshot, moduleKey).value;
|
|
351
|
-
if (getModuleInfo && !getModuleInfo.version && "version" in moduleInfo && moduleInfo["version"]) {
|
|
352
|
-
getModuleInfo.version = moduleInfo["version"];
|
|
353
|
-
}
|
|
354
|
-
if (getModuleInfo) {
|
|
355
|
-
return getModuleInfo;
|
|
356
|
-
}
|
|
357
|
-
if ("version" in moduleInfo && moduleInfo["version"]) {
|
|
358
|
-
const { version } = moduleInfo, resModuleInfo = _object_without_properties_loose(moduleInfo, [
|
|
359
|
-
"version"
|
|
360
|
-
]);
|
|
361
|
-
const moduleKeyWithoutVersion = getFMId(resModuleInfo);
|
|
362
|
-
const getModuleInfoWithoutVersion = getInfoWithoutType(nativeGlobal.__FEDERATION__.moduleInfo, moduleKeyWithoutVersion).value;
|
|
363
|
-
if ((getModuleInfoWithoutVersion == null ? void 0 : getModuleInfoWithoutVersion.version) === version) {
|
|
364
|
-
return getModuleInfoWithoutVersion;
|
|
365
|
-
}
|
|
366
|
-
}
|
|
367
|
-
return;
|
|
368
|
-
};
|
|
369
|
-
const getGlobalSnapshotInfoByModuleInfo = (moduleInfo) => getTargetSnapshotInfoByModuleInfo(moduleInfo, nativeGlobal.__FEDERATION__.moduleInfo);
|
|
370
|
-
const setGlobalSnapshotInfoByModuleInfo = (remoteInfo, moduleDetailInfo) => {
|
|
371
|
-
const moduleKey = getFMId(remoteInfo);
|
|
372
|
-
nativeGlobal.__FEDERATION__.moduleInfo[moduleKey] = moduleDetailInfo;
|
|
373
|
-
return nativeGlobal.__FEDERATION__.moduleInfo;
|
|
374
|
-
};
|
|
375
|
-
const addGlobalSnapshot = (moduleInfos) => {
|
|
376
|
-
nativeGlobal.__FEDERATION__.moduleInfo = _extends({}, nativeGlobal.__FEDERATION__.moduleInfo, moduleInfos);
|
|
377
|
-
return () => {
|
|
378
|
-
const keys = Object.keys(moduleInfos);
|
|
379
|
-
for (const key of keys) {
|
|
380
|
-
delete nativeGlobal.__FEDERATION__.moduleInfo[key];
|
|
381
|
-
}
|
|
382
|
-
};
|
|
383
|
-
};
|
|
384
|
-
const getRemoteEntryExports = (name, globalName) => {
|
|
385
|
-
const remoteEntryKey = globalName || `__FEDERATION_${name}:custom__`;
|
|
386
|
-
const entryExports = globalThis[remoteEntryKey];
|
|
387
|
-
return {
|
|
388
|
-
remoteEntryKey,
|
|
389
|
-
entryExports
|
|
390
|
-
};
|
|
391
|
-
};
|
|
392
|
-
const registerGlobalPlugins = (plugins) => {
|
|
393
|
-
const { __GLOBAL_PLUGIN__ } = nativeGlobal.__FEDERATION__;
|
|
394
|
-
plugins.forEach((plugin) => {
|
|
395
|
-
if (__GLOBAL_PLUGIN__.findIndex((p) => p.name === plugin.name) === -1) {
|
|
396
|
-
__GLOBAL_PLUGIN__.push(plugin);
|
|
397
|
-
} else {
|
|
398
|
-
warn(`The plugin ${plugin.name} has been registered.`);
|
|
399
|
-
}
|
|
400
|
-
});
|
|
401
|
-
};
|
|
402
|
-
const getGlobalHostPlugins = () => nativeGlobal.__FEDERATION__.__GLOBAL_PLUGIN__;
|
|
403
|
-
const getPreloaded = (id) => globalThis.__FEDERATION__.__PRELOADED_MAP__.get(id);
|
|
404
|
-
const setPreloaded = (id) => globalThis.__FEDERATION__.__PRELOADED_MAP__.set(id, true);
|
|
405
|
-
function registerPlugins(plugins, hookInstances) {
|
|
406
|
-
const globalPlugins = getGlobalHostPlugins();
|
|
407
|
-
if (globalPlugins.length > 0) {
|
|
408
|
-
globalPlugins.forEach((plugin) => {
|
|
409
|
-
if (plugins == null ? void 0 : plugins.find((item) => item.name !== plugin.name)) {
|
|
410
|
-
plugins.push(plugin);
|
|
411
|
-
}
|
|
412
|
-
});
|
|
413
|
-
}
|
|
414
|
-
if (plugins && plugins.length > 0) {
|
|
415
|
-
plugins.forEach((plugin) => {
|
|
416
|
-
hookInstances.forEach((hookInstance) => {
|
|
417
|
-
hookInstance.applyPlugin(plugin);
|
|
418
|
-
});
|
|
419
|
-
});
|
|
420
|
-
}
|
|
421
|
-
return plugins;
|
|
422
|
-
}
|
|
423
|
-
const DEFAULT_SCOPE = "default";
|
|
424
|
-
class SyncHook {
|
|
425
|
-
on(fn) {
|
|
426
|
-
if (typeof fn === "function") {
|
|
427
|
-
this.listeners.add(fn);
|
|
428
|
-
}
|
|
429
|
-
}
|
|
430
|
-
once(fn) {
|
|
431
|
-
const self = this;
|
|
432
|
-
this.on(function wrapper(...args) {
|
|
433
|
-
self.remove(wrapper);
|
|
434
|
-
return fn.apply(null, args);
|
|
435
|
-
});
|
|
436
|
-
}
|
|
437
|
-
emit(...data) {
|
|
438
|
-
let result;
|
|
439
|
-
if (this.listeners.size > 0) {
|
|
440
|
-
this.listeners.forEach((fn) => {
|
|
441
|
-
result = fn(...data);
|
|
442
|
-
});
|
|
443
|
-
}
|
|
444
|
-
return result;
|
|
445
|
-
}
|
|
446
|
-
remove(fn) {
|
|
447
|
-
this.listeners.delete(fn);
|
|
448
|
-
}
|
|
449
|
-
removeAll() {
|
|
450
|
-
this.listeners.clear();
|
|
451
|
-
}
|
|
452
|
-
constructor(type) {
|
|
453
|
-
this.type = "";
|
|
454
|
-
this.listeners = /* @__PURE__ */ new Set();
|
|
455
|
-
if (type) {
|
|
456
|
-
this.type = type;
|
|
457
|
-
}
|
|
458
|
-
}
|
|
459
|
-
}
|
|
460
|
-
class AsyncHook extends SyncHook {
|
|
461
|
-
emit(...data) {
|
|
462
|
-
let result;
|
|
463
|
-
const ls = Array.from(this.listeners);
|
|
464
|
-
if (ls.length > 0) {
|
|
465
|
-
let i = 0;
|
|
466
|
-
const call = (prev) => {
|
|
467
|
-
if (prev === false) {
|
|
468
|
-
return false;
|
|
469
|
-
} else if (i < ls.length) {
|
|
470
|
-
return Promise.resolve(ls[i++].apply(null, data)).then(call);
|
|
471
|
-
} else {
|
|
472
|
-
return prev;
|
|
473
|
-
}
|
|
474
|
-
};
|
|
475
|
-
result = call();
|
|
476
|
-
}
|
|
477
|
-
return Promise.resolve(result);
|
|
478
|
-
}
|
|
479
|
-
}
|
|
480
|
-
function checkReturnData(originalData, returnedData) {
|
|
481
|
-
if (!isObject(returnedData)) {
|
|
482
|
-
return false;
|
|
483
|
-
}
|
|
484
|
-
if (originalData !== returnedData) {
|
|
485
|
-
for (const key in originalData) {
|
|
486
|
-
if (!(key in returnedData)) {
|
|
487
|
-
return false;
|
|
488
|
-
}
|
|
489
|
-
}
|
|
490
|
-
}
|
|
491
|
-
return true;
|
|
492
|
-
}
|
|
493
|
-
class SyncWaterfallHook extends SyncHook {
|
|
494
|
-
emit(data) {
|
|
495
|
-
if (!isObject(data)) {
|
|
496
|
-
error(`The data for the "${this.type}" hook should be an object.`);
|
|
497
|
-
}
|
|
498
|
-
for (const fn of this.listeners) {
|
|
499
|
-
try {
|
|
500
|
-
const tempData = fn(data);
|
|
501
|
-
if (checkReturnData(data, tempData)) {
|
|
502
|
-
data = tempData;
|
|
503
|
-
} else {
|
|
504
|
-
this.onerror(`A plugin returned an unacceptable value for the "${this.type}" type.`);
|
|
505
|
-
break;
|
|
506
|
-
}
|
|
507
|
-
} catch (e) {
|
|
508
|
-
warn(e);
|
|
509
|
-
this.onerror(e);
|
|
510
|
-
}
|
|
511
|
-
}
|
|
512
|
-
return data;
|
|
513
|
-
}
|
|
514
|
-
constructor(type) {
|
|
515
|
-
super(), this.onerror = error;
|
|
516
|
-
this.type = type;
|
|
517
|
-
}
|
|
518
|
-
}
|
|
519
|
-
class AsyncWaterfallHook extends SyncHook {
|
|
520
|
-
emit(data) {
|
|
521
|
-
if (!isObject(data)) {
|
|
522
|
-
error(`The response data for the "${this.type}" hook must be an object.`);
|
|
523
|
-
}
|
|
524
|
-
const ls = Array.from(this.listeners);
|
|
525
|
-
if (ls.length > 0) {
|
|
526
|
-
let i = 0;
|
|
527
|
-
const processError = (e) => {
|
|
528
|
-
warn(e);
|
|
529
|
-
this.onerror(e);
|
|
530
|
-
return data;
|
|
531
|
-
};
|
|
532
|
-
const call = (prevData) => {
|
|
533
|
-
if (checkReturnData(data, prevData)) {
|
|
534
|
-
data = prevData;
|
|
535
|
-
if (i < ls.length) {
|
|
536
|
-
try {
|
|
537
|
-
return Promise.resolve(ls[i++](data)).then(call, processError);
|
|
538
|
-
} catch (e) {
|
|
539
|
-
return processError(e);
|
|
540
|
-
}
|
|
541
|
-
}
|
|
542
|
-
} else {
|
|
543
|
-
this.onerror(`A plugin returned an incorrect value for the "${this.type}" type.`);
|
|
544
|
-
}
|
|
545
|
-
return data;
|
|
546
|
-
};
|
|
547
|
-
return Promise.resolve(call(data));
|
|
548
|
-
}
|
|
549
|
-
return Promise.resolve(data);
|
|
550
|
-
}
|
|
551
|
-
constructor(type) {
|
|
552
|
-
super(), this.onerror = error;
|
|
553
|
-
this.type = type;
|
|
554
|
-
}
|
|
555
|
-
}
|
|
556
|
-
class PluginSystem {
|
|
557
|
-
applyPlugin(plugin) {
|
|
558
|
-
assert(isPlainObject(plugin), "Plugin configuration is invalid.");
|
|
559
|
-
const pluginName = plugin.name;
|
|
560
|
-
assert(pluginName, "A name must be provided by the plugin.");
|
|
561
|
-
if (!this.registerPlugins[pluginName]) {
|
|
562
|
-
this.registerPlugins[pluginName] = plugin;
|
|
563
|
-
Object.keys(this.lifecycle).forEach((key) => {
|
|
564
|
-
const pluginLife = plugin[key];
|
|
565
|
-
if (pluginLife) {
|
|
566
|
-
this.lifecycle[key].on(pluginLife);
|
|
567
|
-
}
|
|
568
|
-
});
|
|
569
|
-
}
|
|
570
|
-
}
|
|
571
|
-
removePlugin(pluginName) {
|
|
572
|
-
assert(pluginName, "A name is required.");
|
|
573
|
-
const plugin = this.registerPlugins[pluginName];
|
|
574
|
-
assert(plugin, `The plugin "${pluginName}" is not registered.`);
|
|
575
|
-
Object.keys(plugin).forEach((key) => {
|
|
576
|
-
if (key !== "name") {
|
|
577
|
-
this.lifecycle[key].remove(plugin[key]);
|
|
578
|
-
}
|
|
579
|
-
});
|
|
580
|
-
}
|
|
581
|
-
// eslint-disable-next-line @typescript-eslint/no-shadow
|
|
582
|
-
inherit({ lifecycle, registerPlugins: registerPlugins2 }) {
|
|
583
|
-
Object.keys(lifecycle).forEach((hookName) => {
|
|
584
|
-
assert(!this.lifecycle[hookName], `The hook "${hookName}" has a conflict and cannot be inherited.`);
|
|
585
|
-
this.lifecycle[hookName] = lifecycle[hookName];
|
|
586
|
-
});
|
|
587
|
-
Object.keys(registerPlugins2).forEach((pluginName) => {
|
|
588
|
-
assert(!this.registerPlugins[pluginName], `The plugin "${pluginName}" has a conflict and cannot be inherited.`);
|
|
589
|
-
this.applyPlugin(registerPlugins2[pluginName]);
|
|
590
|
-
});
|
|
591
|
-
}
|
|
592
|
-
constructor(lifecycle) {
|
|
593
|
-
this.registerPlugins = {};
|
|
594
|
-
this.lifecycle = lifecycle;
|
|
595
|
-
this.lifecycleKeys = Object.keys(lifecycle);
|
|
596
|
-
}
|
|
597
|
-
}
|
|
598
|
-
const buildIdentifier = "[0-9A-Za-z-]+";
|
|
599
|
-
const build = `(?:\\+(${buildIdentifier}(?:\\.${buildIdentifier})*))`;
|
|
600
|
-
const numericIdentifier = "0|[1-9]\\d*";
|
|
601
|
-
const numericIdentifierLoose = "[0-9]+";
|
|
602
|
-
const nonNumericIdentifier = "\\d*[a-zA-Z-][a-zA-Z0-9-]*";
|
|
603
|
-
const preReleaseIdentifierLoose = `(?:${numericIdentifierLoose}|${nonNumericIdentifier})`;
|
|
604
|
-
const preReleaseLoose = `(?:-?(${preReleaseIdentifierLoose}(?:\\.${preReleaseIdentifierLoose})*))`;
|
|
605
|
-
const preReleaseIdentifier = `(?:${numericIdentifier}|${nonNumericIdentifier})`;
|
|
606
|
-
const preRelease = `(?:-(${preReleaseIdentifier}(?:\\.${preReleaseIdentifier})*))`;
|
|
607
|
-
const xRangeIdentifier = `${numericIdentifier}|x|X|\\*`;
|
|
608
|
-
const xRangePlain = `[v=\\s]*(${xRangeIdentifier})(?:\\.(${xRangeIdentifier})(?:\\.(${xRangeIdentifier})(?:${preRelease})?${build}?)?)?`;
|
|
609
|
-
const hyphenRange = `^\\s*(${xRangePlain})\\s+-\\s+(${xRangePlain})\\s*$`;
|
|
610
|
-
const mainVersionLoose = `(${numericIdentifierLoose})\\.(${numericIdentifierLoose})\\.(${numericIdentifierLoose})`;
|
|
611
|
-
const loosePlain = `[v=\\s]*${mainVersionLoose}${preReleaseLoose}?${build}?`;
|
|
612
|
-
const gtlt = "((?:<|>)?=?)";
|
|
613
|
-
const comparatorTrim = `(\\s*)${gtlt}\\s*(${loosePlain}|${xRangePlain})`;
|
|
614
|
-
const loneTilde = "(?:~>?)";
|
|
615
|
-
const tildeTrim = `(\\s*)${loneTilde}\\s+`;
|
|
616
|
-
const loneCaret = "(?:\\^)";
|
|
617
|
-
const caretTrim = `(\\s*)${loneCaret}\\s+`;
|
|
618
|
-
const star = "(<|>)?=?\\s*\\*";
|
|
619
|
-
const caret = `^${loneCaret}${xRangePlain}$`;
|
|
620
|
-
const mainVersion = `(${numericIdentifier})\\.(${numericIdentifier})\\.(${numericIdentifier})`;
|
|
621
|
-
const fullPlain = `v?${mainVersion}${preRelease}?${build}?`;
|
|
622
|
-
const tilde = `^${loneTilde}${xRangePlain}$`;
|
|
623
|
-
const xRange = `^${gtlt}\\s*${xRangePlain}$`;
|
|
624
|
-
const comparator = `^${gtlt}\\s*(${fullPlain})$|^$`;
|
|
625
|
-
const gte0 = "^\\s*>=\\s*0.0.0\\s*$";
|
|
626
|
-
function parseRegex(source) {
|
|
627
|
-
return new RegExp(source);
|
|
628
|
-
}
|
|
629
|
-
function isXVersion(version) {
|
|
630
|
-
return !version || version.toLowerCase() === "x" || version === "*";
|
|
631
|
-
}
|
|
632
|
-
function pipe(...fns) {
|
|
633
|
-
return (x) => fns.reduce((v, f2) => f2(v), x);
|
|
634
|
-
}
|
|
635
|
-
function extractComparator(comparatorString) {
|
|
636
|
-
return comparatorString.match(parseRegex(comparator));
|
|
637
|
-
}
|
|
638
|
-
function combineVersion(major, minor, patch, preRelease2) {
|
|
639
|
-
const mainVersion2 = `${major}.${minor}.${patch}`;
|
|
640
|
-
if (preRelease2) {
|
|
641
|
-
return `${mainVersion2}-${preRelease2}`;
|
|
642
|
-
}
|
|
643
|
-
return mainVersion2;
|
|
644
|
-
}
|
|
645
|
-
function parseHyphen(range) {
|
|
646
|
-
return range.replace(parseRegex(hyphenRange), (_range, from, fromMajor, fromMinor, fromPatch, _fromPreRelease, _fromBuild, to, toMajor, toMinor, toPatch, toPreRelease) => {
|
|
647
|
-
if (isXVersion(fromMajor)) {
|
|
648
|
-
from = "";
|
|
649
|
-
} else if (isXVersion(fromMinor)) {
|
|
650
|
-
from = `>=${fromMajor}.0.0`;
|
|
651
|
-
} else if (isXVersion(fromPatch)) {
|
|
652
|
-
from = `>=${fromMajor}.${fromMinor}.0`;
|
|
653
|
-
} else {
|
|
654
|
-
from = `>=${from}`;
|
|
655
|
-
}
|
|
656
|
-
if (isXVersion(toMajor)) {
|
|
657
|
-
to = "";
|
|
658
|
-
} else if (isXVersion(toMinor)) {
|
|
659
|
-
to = `<${Number(toMajor) + 1}.0.0-0`;
|
|
660
|
-
} else if (isXVersion(toPatch)) {
|
|
661
|
-
to = `<${toMajor}.${Number(toMinor) + 1}.0-0`;
|
|
662
|
-
} else if (toPreRelease) {
|
|
663
|
-
to = `<=${toMajor}.${toMinor}.${toPatch}-${toPreRelease}`;
|
|
664
|
-
} else {
|
|
665
|
-
to = `<=${to}`;
|
|
666
|
-
}
|
|
667
|
-
return `${from} ${to}`.trim();
|
|
668
|
-
});
|
|
669
|
-
}
|
|
670
|
-
function parseComparatorTrim(range) {
|
|
671
|
-
return range.replace(parseRegex(comparatorTrim), "$1$2$3");
|
|
672
|
-
}
|
|
673
|
-
function parseTildeTrim(range) {
|
|
674
|
-
return range.replace(parseRegex(tildeTrim), "$1~");
|
|
675
|
-
}
|
|
676
|
-
function parseCaretTrim(range) {
|
|
677
|
-
return range.replace(parseRegex(caretTrim), "$1^");
|
|
678
|
-
}
|
|
679
|
-
function parseCarets(range) {
|
|
680
|
-
return range.trim().split(/\s+/).map((rangeVersion) => rangeVersion.replace(parseRegex(caret), (_, major, minor, patch, preRelease2) => {
|
|
681
|
-
if (isXVersion(major)) {
|
|
682
|
-
return "";
|
|
683
|
-
} else if (isXVersion(minor)) {
|
|
684
|
-
return `>=${major}.0.0 <${Number(major) + 1}.0.0-0`;
|
|
685
|
-
} else if (isXVersion(patch)) {
|
|
686
|
-
if (major === "0") {
|
|
687
|
-
return `>=${major}.${minor}.0 <${major}.${Number(minor) + 1}.0-0`;
|
|
688
|
-
} else {
|
|
689
|
-
return `>=${major}.${minor}.0 <${Number(major) + 1}.0.0-0`;
|
|
690
|
-
}
|
|
691
|
-
} else if (preRelease2) {
|
|
692
|
-
if (major === "0") {
|
|
693
|
-
if (minor === "0") {
|
|
694
|
-
return `>=${major}.${minor}.${patch}-${preRelease2} <${major}.${minor}.${Number(patch) + 1}-0`;
|
|
695
|
-
} else {
|
|
696
|
-
return `>=${major}.${minor}.${patch}-${preRelease2} <${major}.${Number(minor) + 1}.0-0`;
|
|
697
|
-
}
|
|
698
|
-
} else {
|
|
699
|
-
return `>=${major}.${minor}.${patch}-${preRelease2} <${Number(major) + 1}.0.0-0`;
|
|
700
|
-
}
|
|
701
|
-
} else {
|
|
702
|
-
if (major === "0") {
|
|
703
|
-
if (minor === "0") {
|
|
704
|
-
return `>=${major}.${minor}.${patch} <${major}.${minor}.${Number(patch) + 1}-0`;
|
|
705
|
-
} else {
|
|
706
|
-
return `>=${major}.${minor}.${patch} <${major}.${Number(minor) + 1}.0-0`;
|
|
707
|
-
}
|
|
708
|
-
}
|
|
709
|
-
return `>=${major}.${minor}.${patch} <${Number(major) + 1}.0.0-0`;
|
|
710
|
-
}
|
|
711
|
-
})).join(" ");
|
|
712
|
-
}
|
|
713
|
-
function parseTildes(range) {
|
|
714
|
-
return range.trim().split(/\s+/).map((rangeVersion) => rangeVersion.replace(parseRegex(tilde), (_, major, minor, patch, preRelease2) => {
|
|
715
|
-
if (isXVersion(major)) {
|
|
716
|
-
return "";
|
|
717
|
-
} else if (isXVersion(minor)) {
|
|
718
|
-
return `>=${major}.0.0 <${Number(major) + 1}.0.0-0`;
|
|
719
|
-
} else if (isXVersion(patch)) {
|
|
720
|
-
return `>=${major}.${minor}.0 <${major}.${Number(minor) + 1}.0-0`;
|
|
721
|
-
} else if (preRelease2) {
|
|
722
|
-
return `>=${major}.${minor}.${patch}-${preRelease2} <${major}.${Number(minor) + 1}.0-0`;
|
|
723
|
-
}
|
|
724
|
-
return `>=${major}.${minor}.${patch} <${major}.${Number(minor) + 1}.0-0`;
|
|
725
|
-
})).join(" ");
|
|
726
|
-
}
|
|
727
|
-
function parseXRanges(range) {
|
|
728
|
-
return range.split(/\s+/).map((rangeVersion) => rangeVersion.trim().replace(parseRegex(xRange), (ret, gtlt2, major, minor, patch, preRelease2) => {
|
|
729
|
-
const isXMajor = isXVersion(major);
|
|
730
|
-
const isXMinor = isXMajor || isXVersion(minor);
|
|
731
|
-
const isXPatch = isXMinor || isXVersion(patch);
|
|
732
|
-
if (gtlt2 === "=" && isXPatch) {
|
|
733
|
-
gtlt2 = "";
|
|
734
|
-
}
|
|
735
|
-
preRelease2 = "";
|
|
736
|
-
if (isXMajor) {
|
|
737
|
-
if (gtlt2 === ">" || gtlt2 === "<") {
|
|
738
|
-
return "<0.0.0-0";
|
|
739
|
-
} else {
|
|
740
|
-
return "*";
|
|
741
|
-
}
|
|
742
|
-
} else if (gtlt2 && isXPatch) {
|
|
743
|
-
if (isXMinor) {
|
|
744
|
-
minor = 0;
|
|
745
|
-
}
|
|
746
|
-
patch = 0;
|
|
747
|
-
if (gtlt2 === ">") {
|
|
748
|
-
gtlt2 = ">=";
|
|
749
|
-
if (isXMinor) {
|
|
750
|
-
major = Number(major) + 1;
|
|
751
|
-
minor = 0;
|
|
752
|
-
patch = 0;
|
|
753
|
-
} else {
|
|
754
|
-
minor = Number(minor) + 1;
|
|
755
|
-
patch = 0;
|
|
756
|
-
}
|
|
757
|
-
} else if (gtlt2 === "<=") {
|
|
758
|
-
gtlt2 = "<";
|
|
759
|
-
if (isXMinor) {
|
|
760
|
-
major = Number(major) + 1;
|
|
761
|
-
} else {
|
|
762
|
-
minor = Number(minor) + 1;
|
|
763
|
-
}
|
|
764
|
-
}
|
|
765
|
-
if (gtlt2 === "<") {
|
|
766
|
-
preRelease2 = "-0";
|
|
767
|
-
}
|
|
768
|
-
return `${gtlt2 + major}.${minor}.${patch}${preRelease2}`;
|
|
769
|
-
} else if (isXMinor) {
|
|
770
|
-
return `>=${major}.0.0${preRelease2} <${Number(major) + 1}.0.0-0`;
|
|
771
|
-
} else if (isXPatch) {
|
|
772
|
-
return `>=${major}.${minor}.0${preRelease2} <${major}.${Number(minor) + 1}.0-0`;
|
|
773
|
-
}
|
|
774
|
-
return ret;
|
|
775
|
-
})).join(" ");
|
|
776
|
-
}
|
|
777
|
-
function parseStar(range) {
|
|
778
|
-
return range.trim().replace(parseRegex(star), "");
|
|
779
|
-
}
|
|
780
|
-
function parseGTE0(comparatorString) {
|
|
781
|
-
return comparatorString.trim().replace(parseRegex(gte0), "");
|
|
782
|
-
}
|
|
783
|
-
function compareAtom(rangeAtom, versionAtom) {
|
|
784
|
-
rangeAtom = Number(rangeAtom) || rangeAtom;
|
|
785
|
-
versionAtom = Number(versionAtom) || versionAtom;
|
|
786
|
-
if (rangeAtom > versionAtom) {
|
|
787
|
-
return 1;
|
|
788
|
-
}
|
|
789
|
-
if (rangeAtom === versionAtom) {
|
|
790
|
-
return 0;
|
|
791
|
-
}
|
|
792
|
-
return -1;
|
|
793
|
-
}
|
|
794
|
-
function comparePreRelease(rangeAtom, versionAtom) {
|
|
795
|
-
const { preRelease: rangePreRelease } = rangeAtom;
|
|
796
|
-
const { preRelease: versionPreRelease } = versionAtom;
|
|
797
|
-
if (rangePreRelease === void 0 && Boolean(versionPreRelease)) {
|
|
798
|
-
return 1;
|
|
799
|
-
}
|
|
800
|
-
if (Boolean(rangePreRelease) && versionPreRelease === void 0) {
|
|
801
|
-
return -1;
|
|
802
|
-
}
|
|
803
|
-
if (rangePreRelease === void 0 && versionPreRelease === void 0) {
|
|
804
|
-
return 0;
|
|
805
|
-
}
|
|
806
|
-
for (let i = 0, n = rangePreRelease.length; i <= n; i++) {
|
|
807
|
-
const rangeElement = rangePreRelease[i];
|
|
808
|
-
const versionElement = versionPreRelease[i];
|
|
809
|
-
if (rangeElement === versionElement) {
|
|
810
|
-
continue;
|
|
811
|
-
}
|
|
812
|
-
if (rangeElement === void 0 && versionElement === void 0) {
|
|
813
|
-
return 0;
|
|
814
|
-
}
|
|
815
|
-
if (!rangeElement) {
|
|
816
|
-
return 1;
|
|
817
|
-
}
|
|
818
|
-
if (!versionElement) {
|
|
819
|
-
return -1;
|
|
820
|
-
}
|
|
821
|
-
return compareAtom(rangeElement, versionElement);
|
|
822
|
-
}
|
|
823
|
-
return 0;
|
|
824
|
-
}
|
|
825
|
-
function compareVersion(rangeAtom, versionAtom) {
|
|
826
|
-
return compareAtom(rangeAtom.major, versionAtom.major) || compareAtom(rangeAtom.minor, versionAtom.minor) || compareAtom(rangeAtom.patch, versionAtom.patch) || comparePreRelease(rangeAtom, versionAtom);
|
|
827
|
-
}
|
|
828
|
-
function eq(rangeAtom, versionAtom) {
|
|
829
|
-
return rangeAtom.version === versionAtom.version;
|
|
830
|
-
}
|
|
831
|
-
function compare(rangeAtom, versionAtom) {
|
|
832
|
-
switch (rangeAtom.operator) {
|
|
833
|
-
case "":
|
|
834
|
-
case "=":
|
|
835
|
-
return eq(rangeAtom, versionAtom);
|
|
836
|
-
case ">":
|
|
837
|
-
return compareVersion(rangeAtom, versionAtom) < 0;
|
|
838
|
-
case ">=":
|
|
839
|
-
return eq(rangeAtom, versionAtom) || compareVersion(rangeAtom, versionAtom) < 0;
|
|
840
|
-
case "<":
|
|
841
|
-
return compareVersion(rangeAtom, versionAtom) > 0;
|
|
842
|
-
case "<=":
|
|
843
|
-
return eq(rangeAtom, versionAtom) || compareVersion(rangeAtom, versionAtom) > 0;
|
|
844
|
-
case void 0: {
|
|
845
|
-
return true;
|
|
846
|
-
}
|
|
847
|
-
default:
|
|
848
|
-
return false;
|
|
849
|
-
}
|
|
850
|
-
}
|
|
851
|
-
function parseComparatorString(range) {
|
|
852
|
-
return pipe(
|
|
853
|
-
// handle caret
|
|
854
|
-
// ^ --> * (any, kinda silly)
|
|
855
|
-
// ^2, ^2.x, ^2.x.x --> >=2.0.0 <3.0.0-0
|
|
856
|
-
// ^2.0, ^2.0.x --> >=2.0.0 <3.0.0-0
|
|
857
|
-
// ^1.2, ^1.2.x --> >=1.2.0 <2.0.0-0
|
|
858
|
-
// ^1.2.3 --> >=1.2.3 <2.0.0-0
|
|
859
|
-
// ^1.2.0 --> >=1.2.0 <2.0.0-0
|
|
860
|
-
parseCarets,
|
|
861
|
-
// handle tilde
|
|
862
|
-
// ~, ~> --> * (any, kinda silly)
|
|
863
|
-
// ~2, ~2.x, ~2.x.x, ~>2, ~>2.x ~>2.x.x --> >=2.0.0 <3.0.0-0
|
|
864
|
-
// ~2.0, ~2.0.x, ~>2.0, ~>2.0.x --> >=2.0.0 <2.1.0-0
|
|
865
|
-
// ~1.2, ~1.2.x, ~>1.2, ~>1.2.x --> >=1.2.0 <1.3.0-0
|
|
866
|
-
// ~1.2.3, ~>1.2.3 --> >=1.2.3 <1.3.0-0
|
|
867
|
-
// ~1.2.0, ~>1.2.0 --> >=1.2.0 <1.3.0-0
|
|
868
|
-
parseTildes,
|
|
869
|
-
parseXRanges,
|
|
870
|
-
parseStar
|
|
871
|
-
)(range);
|
|
872
|
-
}
|
|
873
|
-
function parseRange(range) {
|
|
874
|
-
return pipe(
|
|
875
|
-
// handle hyphenRange
|
|
876
|
-
// `1.2.3 - 1.2.4` => `>=1.2.3 <=1.2.4`
|
|
877
|
-
parseHyphen,
|
|
878
|
-
// handle trim comparator
|
|
879
|
-
// `> 1.2.3 < 1.2.5` => `>1.2.3 <1.2.5`
|
|
880
|
-
parseComparatorTrim,
|
|
881
|
-
// handle trim tilde
|
|
882
|
-
// `~ 1.2.3` => `~1.2.3`
|
|
883
|
-
parseTildeTrim,
|
|
884
|
-
// handle trim caret
|
|
885
|
-
// `^ 1.2.3` => `^1.2.3`
|
|
886
|
-
parseCaretTrim
|
|
887
|
-
)(range.trim()).split(/\s+/).join(" ");
|
|
888
|
-
}
|
|
889
|
-
function satisfy(version, range) {
|
|
890
|
-
if (!version) {
|
|
891
|
-
return false;
|
|
892
|
-
}
|
|
893
|
-
const parsedRange = parseRange(range);
|
|
894
|
-
const parsedComparator = parsedRange.split(" ").map((rangeVersion) => parseComparatorString(rangeVersion)).join(" ");
|
|
895
|
-
const comparators = parsedComparator.split(/\s+/).map((comparator2) => parseGTE0(comparator2));
|
|
896
|
-
const extractedVersion = extractComparator(version);
|
|
897
|
-
if (!extractedVersion) {
|
|
898
|
-
return false;
|
|
899
|
-
}
|
|
900
|
-
const [, versionOperator, , versionMajor, versionMinor, versionPatch, versionPreRelease] = extractedVersion;
|
|
901
|
-
const versionAtom = {
|
|
902
|
-
operator: versionOperator,
|
|
903
|
-
version: combineVersion(versionMajor, versionMinor, versionPatch, versionPreRelease),
|
|
904
|
-
major: versionMajor,
|
|
905
|
-
minor: versionMinor,
|
|
906
|
-
patch: versionPatch,
|
|
907
|
-
preRelease: versionPreRelease == null ? void 0 : versionPreRelease.split(".")
|
|
908
|
-
};
|
|
909
|
-
for (const comparator2 of comparators) {
|
|
910
|
-
const extractedComparator = extractComparator(comparator2);
|
|
911
|
-
if (!extractedComparator) {
|
|
912
|
-
return false;
|
|
913
|
-
}
|
|
914
|
-
const [, rangeOperator, , rangeMajor, rangeMinor, rangePatch, rangePreRelease] = extractedComparator;
|
|
915
|
-
const rangeAtom = {
|
|
916
|
-
operator: rangeOperator,
|
|
917
|
-
version: combineVersion(rangeMajor, rangeMinor, rangePatch, rangePreRelease),
|
|
918
|
-
major: rangeMajor,
|
|
919
|
-
minor: rangeMinor,
|
|
920
|
-
patch: rangePatch,
|
|
921
|
-
preRelease: rangePreRelease == null ? void 0 : rangePreRelease.split(".")
|
|
922
|
-
};
|
|
923
|
-
if (!compare(rangeAtom, versionAtom)) {
|
|
924
|
-
return false;
|
|
925
|
-
}
|
|
926
|
-
}
|
|
927
|
-
return true;
|
|
928
|
-
}
|
|
929
|
-
function versionLt(a, b) {
|
|
930
|
-
const transformInvalidVersion = (version) => {
|
|
931
|
-
const isNumberVersion = !Number.isNaN(Number(version));
|
|
932
|
-
if (isNumberVersion) {
|
|
933
|
-
const splitArr = version.split(".");
|
|
934
|
-
let validVersion = version;
|
|
935
|
-
for (let i = 0; i < 3 - splitArr.length; i++) {
|
|
936
|
-
validVersion += ".0";
|
|
937
|
-
}
|
|
938
|
-
return validVersion;
|
|
939
|
-
}
|
|
940
|
-
return version;
|
|
941
|
-
};
|
|
942
|
-
if (satisfy(transformInvalidVersion(a), `<=${transformInvalidVersion(b)}`)) {
|
|
943
|
-
return true;
|
|
944
|
-
} else {
|
|
945
|
-
return false;
|
|
946
|
-
}
|
|
947
|
-
}
|
|
948
|
-
const findVersion = (shareVersionMap, cb) => {
|
|
949
|
-
const callback = cb || function(prev, cur) {
|
|
950
|
-
return versionLt(prev, cur);
|
|
951
|
-
};
|
|
952
|
-
return Object.keys(shareVersionMap).reduce((prev, cur) => {
|
|
953
|
-
if (!prev) {
|
|
954
|
-
return cur;
|
|
955
|
-
}
|
|
956
|
-
if (callback(prev, cur)) {
|
|
957
|
-
return cur;
|
|
958
|
-
}
|
|
959
|
-
if (prev === "0") {
|
|
960
|
-
return cur;
|
|
961
|
-
}
|
|
962
|
-
return prev;
|
|
963
|
-
}, 0);
|
|
964
|
-
};
|
|
965
|
-
const isLoaded = (shared) => {
|
|
966
|
-
return Boolean(shared.loaded) || typeof shared.lib === "function";
|
|
967
|
-
};
|
|
968
|
-
function findSingletonVersionOrderByVersion(shareScopeMap, scope, pkgName) {
|
|
969
|
-
const versions = shareScopeMap[scope][pkgName];
|
|
970
|
-
const callback = function(prev, cur) {
|
|
971
|
-
return !isLoaded(versions[prev]) && versionLt(prev, cur);
|
|
972
|
-
};
|
|
973
|
-
return findVersion(shareScopeMap[scope][pkgName], callback);
|
|
974
|
-
}
|
|
975
|
-
function findSingletonVersionOrderByLoaded(shareScopeMap, scope, pkgName) {
|
|
976
|
-
const versions = shareScopeMap[scope][pkgName];
|
|
977
|
-
const callback = function(prev, cur) {
|
|
978
|
-
if (isLoaded(versions[cur])) {
|
|
979
|
-
if (isLoaded(versions[prev])) {
|
|
980
|
-
return Boolean(versionLt(prev, cur));
|
|
981
|
-
} else {
|
|
982
|
-
return true;
|
|
983
|
-
}
|
|
984
|
-
}
|
|
985
|
-
if (isLoaded(versions[prev])) {
|
|
986
|
-
return false;
|
|
987
|
-
}
|
|
988
|
-
return versionLt(prev, cur);
|
|
989
|
-
};
|
|
990
|
-
return findVersion(shareScopeMap[scope][pkgName], callback);
|
|
991
|
-
}
|
|
992
|
-
function getFindShareFunction(strategy) {
|
|
993
|
-
if (strategy === "loaded-first") {
|
|
994
|
-
return findSingletonVersionOrderByLoaded;
|
|
995
|
-
}
|
|
996
|
-
return findSingletonVersionOrderByVersion;
|
|
997
|
-
}
|
|
998
|
-
function getRegisteredShare(localShareScopeMap, pkgName, shareInfo, resolveShare) {
|
|
999
|
-
if (!localShareScopeMap) {
|
|
1000
|
-
return;
|
|
1001
|
-
}
|
|
1002
|
-
const { shareConfig, scope = DEFAULT_SCOPE, strategy } = shareInfo;
|
|
1003
|
-
const scopes = Array.isArray(scope) ? scope : [
|
|
1004
|
-
scope
|
|
1005
|
-
];
|
|
1006
|
-
for (const sc of scopes) {
|
|
1007
|
-
if (shareConfig && localShareScopeMap[sc] && localShareScopeMap[sc][pkgName]) {
|
|
1008
|
-
const { requiredVersion } = shareConfig;
|
|
1009
|
-
const findShareFunction = getFindShareFunction(strategy);
|
|
1010
|
-
const maxOrSingletonVersion = findShareFunction(localShareScopeMap, sc, pkgName);
|
|
1011
|
-
const defaultResolver = () => {
|
|
1012
|
-
if (shareConfig.singleton) {
|
|
1013
|
-
if (typeof requiredVersion === "string" && !satisfy(maxOrSingletonVersion, requiredVersion)) {
|
|
1014
|
-
const msg = `Version ${maxOrSingletonVersion} from ${maxOrSingletonVersion && localShareScopeMap[sc][pkgName][maxOrSingletonVersion].from} of shared singleton module ${pkgName} does not satisfy the requirement of ${shareInfo.from} which needs ${requiredVersion})`;
|
|
1015
|
-
if (shareConfig.strictVersion) {
|
|
1016
|
-
error(msg);
|
|
1017
|
-
} else {
|
|
1018
|
-
warn(msg);
|
|
1019
|
-
}
|
|
1020
|
-
}
|
|
1021
|
-
return localShareScopeMap[sc][pkgName][maxOrSingletonVersion];
|
|
1022
|
-
} else {
|
|
1023
|
-
if (requiredVersion === false || requiredVersion === "*") {
|
|
1024
|
-
return localShareScopeMap[sc][pkgName][maxOrSingletonVersion];
|
|
1025
|
-
}
|
|
1026
|
-
if (satisfy(maxOrSingletonVersion, requiredVersion)) {
|
|
1027
|
-
return localShareScopeMap[sc][pkgName][maxOrSingletonVersion];
|
|
1028
|
-
}
|
|
1029
|
-
for (const [versionKey, versionValue] of Object.entries(localShareScopeMap[sc][pkgName])) {
|
|
1030
|
-
if (satisfy(versionKey, requiredVersion)) {
|
|
1031
|
-
return versionValue;
|
|
1032
|
-
}
|
|
1033
|
-
}
|
|
1034
|
-
}
|
|
1035
|
-
};
|
|
1036
|
-
const params = {
|
|
1037
|
-
shareScopeMap: localShareScopeMap,
|
|
1038
|
-
scope: sc,
|
|
1039
|
-
pkgName,
|
|
1040
|
-
version: maxOrSingletonVersion,
|
|
1041
|
-
GlobalFederation: Global.__FEDERATION__,
|
|
1042
|
-
resolver: defaultResolver
|
|
1043
|
-
};
|
|
1044
|
-
const resolveShared = resolveShare.emit(params) || params;
|
|
1045
|
-
return resolveShared.resolver();
|
|
1046
|
-
}
|
|
1047
|
-
}
|
|
1048
|
-
}
|
|
1049
|
-
function getGlobalShareScope() {
|
|
1050
|
-
return Global.__FEDERATION__.__SHARE__;
|
|
1051
|
-
}
|
|
1052
|
-
var pluginHelper = /* @__PURE__ */ Object.freeze({
|
|
1053
|
-
__proto__: null,
|
|
1054
|
-
AsyncHook,
|
|
1055
|
-
AsyncWaterfallHook,
|
|
1056
|
-
PluginSystem,
|
|
1057
|
-
SyncHook,
|
|
1058
|
-
SyncWaterfallHook
|
|
1059
|
-
});
|
|
1060
|
-
const ShareUtils = {
|
|
1061
|
-
getRegisteredShare,
|
|
1062
|
-
getGlobalShareScope
|
|
1063
|
-
};
|
|
1064
|
-
const GlobalUtils = {
|
|
1065
|
-
Global,
|
|
1066
|
-
nativeGlobal,
|
|
1067
|
-
resetFederationGlobalInfo,
|
|
1068
|
-
getGlobalFederationInstance,
|
|
1069
|
-
setGlobalFederationInstance,
|
|
1070
|
-
getGlobalFederationConstructor,
|
|
1071
|
-
setGlobalFederationConstructor,
|
|
1072
|
-
getInfoWithoutType,
|
|
1073
|
-
getGlobalSnapshot,
|
|
1074
|
-
getTargetSnapshotInfoByModuleInfo,
|
|
1075
|
-
getGlobalSnapshotInfoByModuleInfo,
|
|
1076
|
-
setGlobalSnapshotInfoByModuleInfo,
|
|
1077
|
-
addGlobalSnapshot,
|
|
1078
|
-
getRemoteEntryExports,
|
|
1079
|
-
registerGlobalPlugins,
|
|
1080
|
-
getGlobalHostPlugins,
|
|
1081
|
-
getPreloaded,
|
|
1082
|
-
setPreloaded,
|
|
1083
|
-
registerPlugins,
|
|
1084
|
-
pluginHelper
|
|
1085
|
-
};
|
|
1086
|
-
var helpers = {
|
|
1087
|
-
global: GlobalUtils,
|
|
1088
|
-
share: ShareUtils
|
|
1089
|
-
};
|
|
1090
|
-
function registerBridgeLifeCycle() {
|
|
1091
|
-
var _a;
|
|
1092
|
-
const { registerPlugins: registerPlugins2, pluginHelper: pluginHelper2 } = helpers.global;
|
|
1093
|
-
const host = getInstance();
|
|
1094
|
-
const pluginSystem = new pluginHelper2.PluginSystem({
|
|
1095
|
-
beforeBridgeRender: new pluginHelper2.SyncHook(),
|
|
1096
|
-
afterBridgeRender: new pluginHelper2.SyncHook(),
|
|
1097
|
-
beforeBridgeDestroy: new pluginHelper2.SyncHook(),
|
|
1098
|
-
afterBridgeDestroy: new pluginHelper2.SyncHook()
|
|
1099
|
-
});
|
|
1100
|
-
if (host) {
|
|
1101
|
-
registerPlugins2(
|
|
1102
|
-
(_a = host == null ? void 0 : host.options) == null ? void 0 : _a.plugins,
|
|
1103
|
-
[pluginSystem]
|
|
1104
|
-
);
|
|
1105
|
-
return pluginSystem;
|
|
1106
|
-
}
|
|
1107
|
-
return null;
|
|
1108
|
-
}
|
|
1109
|
-
const getModuleName = (id) => {
|
|
1110
|
-
const idArray = id.split("/");
|
|
1111
|
-
if (idArray.length < 2) {
|
|
1112
|
-
return id;
|
|
1113
|
-
}
|
|
1114
|
-
return idArray[0] + "/" + idArray[1];
|
|
1115
|
-
};
|
|
1116
|
-
const getRootDomDefaultClassName = (moduleName) => {
|
|
1117
|
-
const name = getModuleName(moduleName).replace(/\@/, "").replace(/\//, "-");
|
|
1118
|
-
return `bridge-root-component-${name}`;
|
|
1119
|
-
};
|
|
1120
101
|
const RemoteAppWrapper = forwardRef(function(props, ref) {
|
|
1121
|
-
const bridgeHook = registerBridgeLifeCycle();
|
|
1122
102
|
const RemoteApp2 = () => {
|
|
1123
103
|
LoggerInstance.log(`RemoteAppWrapper RemoteApp props >>>`, { props });
|
|
1124
104
|
const {
|
|
@@ -1136,10 +116,9 @@ const RemoteAppWrapper = forwardRef(function(props, ref) {
|
|
|
1136
116
|
const providerInfoRef = useRef(null);
|
|
1137
117
|
useEffect(() => {
|
|
1138
118
|
const renderTimeout = setTimeout(() => {
|
|
1139
|
-
var _a, _b;
|
|
1140
119
|
const providerReturn = providerInfo();
|
|
1141
120
|
providerInfoRef.current = providerReturn;
|
|
1142
|
-
|
|
121
|
+
const renderProps = {
|
|
1143
122
|
moduleName,
|
|
1144
123
|
dom: rootRef.current,
|
|
1145
124
|
basename,
|
|
@@ -1152,55 +131,34 @@ const RemoteAppWrapper = forwardRef(function(props, ref) {
|
|
|
1152
131
|
`createRemoteComponent LazyComponent render >>>`,
|
|
1153
132
|
renderProps
|
|
1154
133
|
);
|
|
1155
|
-
if (bridgeHook && ((_a = bridgeHook == null ? void 0 : bridgeHook.lifecycle) == null ? void 0 : _a.beforeBridgeRender)) {
|
|
1156
|
-
const beforeBridgeRenderRes = (_b = bridgeHook == null ? void 0 : bridgeHook.lifecycle) == null ? void 0 : _b.beforeBridgeRender.emit({
|
|
1157
|
-
...renderProps
|
|
1158
|
-
});
|
|
1159
|
-
const extraProps = beforeBridgeRenderRes && typeof beforeBridgeRenderRes === "object" && (beforeBridgeRenderRes == null ? void 0 : beforeBridgeRenderRes.extraProps) ? beforeBridgeRenderRes == null ? void 0 : beforeBridgeRenderRes.extraProps : {};
|
|
1160
|
-
renderProps = {
|
|
1161
|
-
...renderProps,
|
|
1162
|
-
...extraProps
|
|
1163
|
-
};
|
|
1164
|
-
}
|
|
1165
134
|
providerReturn.render(renderProps);
|
|
1166
135
|
});
|
|
1167
136
|
return () => {
|
|
1168
137
|
clearTimeout(renderTimeout);
|
|
1169
138
|
setTimeout(() => {
|
|
1170
|
-
var _a, _b
|
|
139
|
+
var _a, _b;
|
|
1171
140
|
if ((_a = providerInfoRef.current) == null ? void 0 : _a.destroy) {
|
|
1172
141
|
LoggerInstance.log(
|
|
1173
142
|
`createRemoteComponent LazyComponent destroy >>>`,
|
|
1174
143
|
{ moduleName, basename, dom: renderDom.current }
|
|
1175
144
|
);
|
|
1176
|
-
|
|
1177
|
-
(_c = bridgeHook == null ? void 0 : bridgeHook.lifecycle) == null ? void 0 : _c.afterBridgeDestroy.emit({
|
|
1178
|
-
moduleName,
|
|
1179
|
-
dom: renderDom.current,
|
|
1180
|
-
basename,
|
|
1181
|
-
memoryRoute,
|
|
1182
|
-
fallback,
|
|
1183
|
-
...resProps
|
|
1184
|
-
});
|
|
1185
|
-
}
|
|
1186
|
-
(_d = providerInfoRef.current) == null ? void 0 : _d.destroy({
|
|
145
|
+
(_b = providerInfoRef.current) == null ? void 0 : _b.destroy({
|
|
1187
146
|
dom: renderDom.current
|
|
1188
147
|
});
|
|
1189
148
|
}
|
|
1190
149
|
});
|
|
1191
150
|
};
|
|
1192
151
|
}, []);
|
|
1193
|
-
const rootComponentClassName = `${getRootDomDefaultClassName(moduleName)} ${props == null ? void 0 : props.className}`;
|
|
1194
152
|
return /* @__PURE__ */ React__default.createElement(
|
|
1195
153
|
"div",
|
|
1196
154
|
{
|
|
1197
|
-
className:
|
|
155
|
+
className: props == null ? void 0 : props.className,
|
|
1198
156
|
style: props == null ? void 0 : props.style,
|
|
1199
157
|
ref: rootRef
|
|
1200
158
|
}
|
|
1201
159
|
);
|
|
1202
160
|
};
|
|
1203
|
-
RemoteApp2["__APP_VERSION__"] = "0.6.
|
|
161
|
+
RemoteApp2["__APP_VERSION__"] = "0.6.13";
|
|
1204
162
|
return /* @__PURE__ */ React__default.createElement(RemoteApp2, null);
|
|
1205
163
|
});
|
|
1206
164
|
function withRouterData(WrappedComponent) {
|
|
@@ -1312,8 +270,8 @@ function createLazyRemoteComponent(info) {
|
|
|
1312
270
|
)}`
|
|
1313
271
|
);
|
|
1314
272
|
}
|
|
1315
|
-
} catch (
|
|
1316
|
-
throw
|
|
273
|
+
} catch (error) {
|
|
274
|
+
throw error;
|
|
1317
275
|
}
|
|
1318
276
|
});
|
|
1319
277
|
}
|
|
@@ -1350,7 +308,7 @@ if (process.env.NODE_ENV === "production") {
|
|
|
1350
308
|
};
|
|
1351
309
|
}
|
|
1352
310
|
function createBridgeComponent(bridgeInfo) {
|
|
1353
|
-
return (
|
|
311
|
+
return () => {
|
|
1354
312
|
const rootMap = /* @__PURE__ */ new Map();
|
|
1355
313
|
const RawComponent = (info) => {
|
|
1356
314
|
const { appInfo, propsInfo, ...restProps } = info;
|
|
@@ -1366,7 +324,6 @@ function createBridgeComponent(bridgeInfo) {
|
|
|
1366
324
|
};
|
|
1367
325
|
return {
|
|
1368
326
|
async render(info) {
|
|
1369
|
-
var _a, _b;
|
|
1370
327
|
LoggerInstance.log(`createBridgeComponent render Info`, info);
|
|
1371
328
|
const {
|
|
1372
329
|
moduleName,
|
|
@@ -1376,9 +333,6 @@ function createBridgeComponent(bridgeInfo) {
|
|
|
1376
333
|
fallback,
|
|
1377
334
|
...propsInfo
|
|
1378
335
|
} = info;
|
|
1379
|
-
const beforeBridgeRender = (bridgeInfo == null ? void 0 : bridgeInfo.hooks) && (bridgeInfo == null ? void 0 : bridgeInfo.hooks.beforeBridgeRender) || ((_a = params == null ? void 0 : params.hooks) == null ? void 0 : _a.beforeBridgeRender);
|
|
1380
|
-
const beforeBridgeRenderRes = beforeBridgeRender && beforeBridgeRender(info);
|
|
1381
|
-
const extraProps = beforeBridgeRenderRes && typeof beforeBridgeRenderRes === "object" && (beforeBridgeRenderRes == null ? void 0 : beforeBridgeRenderRes.extraProps) ? beforeBridgeRenderRes == null ? void 0 : beforeBridgeRenderRes.extraProps : {};
|
|
1382
336
|
const rootComponentWithErrorBoundary = (
|
|
1383
337
|
// set ErrorBoundary for RawComponent rendering error, usually caused by user app rendering error
|
|
1384
338
|
/* @__PURE__ */ React.createElement(ErrorBoundary, { FallbackComponent: fallback }, /* @__PURE__ */ React.createElement(
|
|
@@ -1389,7 +343,7 @@ function createBridgeComponent(bridgeInfo) {
|
|
|
1389
343
|
basename,
|
|
1390
344
|
memoryRoute
|
|
1391
345
|
},
|
|
1392
|
-
propsInfo
|
|
346
|
+
propsInfo
|
|
1393
347
|
}
|
|
1394
348
|
))
|
|
1395
349
|
);
|
|
@@ -1407,19 +361,11 @@ function createBridgeComponent(bridgeInfo) {
|
|
|
1407
361
|
const renderFn = (bridgeInfo == null ? void 0 : bridgeInfo.render) || ReactDOM.render;
|
|
1408
362
|
renderFn == null ? void 0 : renderFn(rootComponentWithErrorBoundary, info.dom);
|
|
1409
363
|
}
|
|
1410
|
-
const afterBridgeRender = (bridgeInfo == null ? void 0 : bridgeInfo.hooks) && (bridgeInfo == null ? void 0 : bridgeInfo.hooks.afterBridgeDestroy) || ((_b = params == null ? void 0 : params.hooks) == null ? void 0 : _b.afterBridgeRender);
|
|
1411
|
-
afterBridgeRender && afterBridgeRender(info);
|
|
1412
364
|
},
|
|
1413
365
|
async destroy(info) {
|
|
1414
|
-
var _a, _b;
|
|
1415
366
|
LoggerInstance.log(`createBridgeComponent destroy Info`, {
|
|
1416
367
|
dom: info.dom
|
|
1417
368
|
});
|
|
1418
|
-
if ((bridgeInfo == null ? void 0 : bridgeInfo.hooks) && (bridgeInfo == null ? void 0 : bridgeInfo.hooks.beforeBridgeDestroy) && typeof (bridgeInfo == null ? void 0 : bridgeInfo.hooks.beforeBridgeDestroy) === "function") {
|
|
1419
|
-
bridgeInfo.hooks.beforeBridgeDestroy(info);
|
|
1420
|
-
}
|
|
1421
|
-
const beforeBridgeDestroy = (bridgeInfo == null ? void 0 : bridgeInfo.hooks) && (bridgeInfo == null ? void 0 : bridgeInfo.hooks.beforeBridgeDestroy) || ((_a = params == null ? void 0 : params.hooks) == null ? void 0 : _a.beforeBridgeDestroy);
|
|
1422
|
-
beforeBridgeDestroy && beforeBridgeDestroy(info);
|
|
1423
369
|
if (atLeastReact18(React)) {
|
|
1424
370
|
const root = rootMap.get(info.dom);
|
|
1425
371
|
root == null ? void 0 : root.unmount();
|
|
@@ -1427,8 +373,6 @@ function createBridgeComponent(bridgeInfo) {
|
|
|
1427
373
|
} else {
|
|
1428
374
|
ReactDOM.unmountComponentAtNode(info.dom);
|
|
1429
375
|
}
|
|
1430
|
-
const afterBridgeDestroy = (bridgeInfo == null ? void 0 : bridgeInfo.hooks) && (bridgeInfo == null ? void 0 : bridgeInfo.hooks.afterBridgeDestroy) || ((_b = params == null ? void 0 : params.hooks) == null ? void 0 : _b.afterBridgeDestroy);
|
|
1431
|
-
afterBridgeDestroy && afterBridgeDestroy(info);
|
|
1432
376
|
},
|
|
1433
377
|
rawComponent: bridgeInfo.rootComponent,
|
|
1434
378
|
__BRIDGE_FN__: (_args) => {
|