@module-federation/bridge-react 0.0.0-next-20240913095223 → 0.0.0-next-20240918063302

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