@module-federation/bridge-react 0.0.0-next-20240927195332 → 0.0.0-next-20240930091801

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
@@ -2,6 +2,7 @@ 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";
5
6
  import ReactDOM from "react-dom";
6
7
  const ErrorBoundaryContext = createContext(null);
7
8
  const initialState = {
@@ -14,17 +15,17 @@ class ErrorBoundary extends Component {
14
15
  this.resetErrorBoundary = this.resetErrorBoundary.bind(this);
15
16
  this.state = initialState;
16
17
  }
17
- static getDerivedStateFromError(error) {
18
+ static getDerivedStateFromError(error2) {
18
19
  return {
19
20
  didCatch: true,
20
- error
21
+ error: error2
21
22
  };
22
23
  }
23
24
  resetErrorBoundary() {
24
25
  const {
25
- error
26
+ error: error2
26
27
  } = this.state;
27
- if (error !== null) {
28
+ if (error2 !== null) {
28
29
  var _this$props$onReset, _this$props;
29
30
  for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
30
31
  args[_key] = arguments[_key];
@@ -36,9 +37,9 @@ class ErrorBoundary extends Component {
36
37
  this.setState(initialState);
37
38
  }
38
39
  }
39
- componentDidCatch(error, info) {
40
+ componentDidCatch(error2, info) {
40
41
  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);
42
+ (_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
43
  }
43
44
  componentDidUpdate(prevProps, prevState) {
44
45
  const {
@@ -66,12 +67,12 @@ class ErrorBoundary extends Component {
66
67
  } = this.props;
67
68
  const {
68
69
  didCatch,
69
- error
70
+ error: error2
70
71
  } = this.state;
71
72
  let childToRender = children;
72
73
  if (didCatch) {
73
74
  const props = {
74
- error,
75
+ error: error2,
75
76
  resetErrorBoundary: this.resetErrorBoundary
76
77
  };
77
78
  if (typeof fallbackRender === "function") {
@@ -81,13 +82,13 @@ class ErrorBoundary extends Component {
81
82
  } else if (fallback === null || isValidElement(fallback)) {
82
83
  childToRender = fallback;
83
84
  } else {
84
- throw error;
85
+ throw error2;
85
86
  }
86
87
  }
87
88
  return createElement(ErrorBoundaryContext.Provider, {
88
89
  value: {
89
90
  didCatch,
90
- error,
91
+ error: error2,
91
92
  resetErrorBoundary: this.resetErrorBoundary
92
93
  }
93
94
  }, childToRender);
@@ -98,7 +99,1015 @@ function hasArrayChanged() {
98
99
  let b = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : [];
99
100
  return a.length !== b.length || a.some((item, index) => !Object.is(item, b[index]));
100
101
  }
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 safeGetLocalStorageItem() {
115
+ try {
116
+ if (typeof window !== "undefined" && window.localStorage) {
117
+ return localStorage.getItem(BROWSER_LOG_KEY) === BROWSER_LOG_VALUE;
118
+ }
119
+ } catch (error2) {
120
+ return typeof document !== "undefined";
121
+ }
122
+ return false;
123
+ }
124
+ let Logger = class Logger2 {
125
+ info(msg, info) {
126
+ if (this.enable) {
127
+ const argsToString = safeToString(info) || "";
128
+ if (isBrowserEnv()) {
129
+ console.info(`%c ${this.identifier}: ${msg} ${argsToString}`, "color:#3300CC");
130
+ } else {
131
+ console.info("\x1B[34m%s", `${this.identifier}: ${msg} ${argsToString ? `
132
+ ${argsToString}` : ""}`);
133
+ }
134
+ }
135
+ }
136
+ logOriginalInfo(...args) {
137
+ if (this.enable) {
138
+ if (isBrowserEnv()) {
139
+ console.info(`%c ${this.identifier}: OriginalInfo`, "color:#3300CC");
140
+ console.log(...args);
141
+ } else {
142
+ console.info(`%c ${this.identifier}: OriginalInfo`, "color:#3300CC");
143
+ console.log(...args);
144
+ }
145
+ }
146
+ }
147
+ constructor(identifier) {
148
+ this.enable = false;
149
+ this.identifier = identifier || DEBUG_LOG;
150
+ if (isBrowserEnv() && safeGetLocalStorageItem()) {
151
+ this.enable = true;
152
+ } else if (isDebugMode()) {
153
+ this.enable = true;
154
+ }
155
+ }
156
+ };
157
+ new Logger();
158
+ function safeToString(info) {
159
+ try {
160
+ return JSON.stringify(info, null, 2);
161
+ } catch (e) {
162
+ return "";
163
+ }
164
+ }
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.6";
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();
516
+ this.onerror = error;
517
+ this.type = type;
518
+ }
519
+ }
520
+ class AsyncWaterfallHook extends SyncHook {
521
+ emit(data) {
522
+ if (!isObject(data)) {
523
+ error(`The response data for the "${this.type}" hook must be an object.`);
524
+ }
525
+ const ls = Array.from(this.listeners);
526
+ if (ls.length > 0) {
527
+ let i = 0;
528
+ const processError = (e) => {
529
+ warn(e);
530
+ this.onerror(e);
531
+ return data;
532
+ };
533
+ const call = (prevData) => {
534
+ if (checkReturnData(data, prevData)) {
535
+ data = prevData;
536
+ if (i < ls.length) {
537
+ try {
538
+ return Promise.resolve(ls[i++](data)).then(call, processError);
539
+ } catch (e) {
540
+ return processError(e);
541
+ }
542
+ }
543
+ } else {
544
+ this.onerror(`A plugin returned an incorrect value for the "${this.type}" type.`);
545
+ }
546
+ return data;
547
+ };
548
+ return Promise.resolve(call(data));
549
+ }
550
+ return Promise.resolve(data);
551
+ }
552
+ constructor(type) {
553
+ super();
554
+ this.onerror = error;
555
+ this.type = type;
556
+ }
557
+ }
558
+ class PluginSystem {
559
+ applyPlugin(plugin) {
560
+ assert(isPlainObject(plugin), "Plugin configuration is invalid.");
561
+ const pluginName = plugin.name;
562
+ assert(pluginName, "A name must be provided by the plugin.");
563
+ if (!this.registerPlugins[pluginName]) {
564
+ this.registerPlugins[pluginName] = plugin;
565
+ Object.keys(this.lifecycle).forEach((key) => {
566
+ const pluginLife = plugin[key];
567
+ if (pluginLife) {
568
+ this.lifecycle[key].on(pluginLife);
569
+ }
570
+ });
571
+ }
572
+ }
573
+ removePlugin(pluginName) {
574
+ assert(pluginName, "A name is required.");
575
+ const plugin = this.registerPlugins[pluginName];
576
+ assert(plugin, `The plugin "${pluginName}" is not registered.`);
577
+ Object.keys(plugin).forEach((key) => {
578
+ if (key !== "name") {
579
+ this.lifecycle[key].remove(plugin[key]);
580
+ }
581
+ });
582
+ }
583
+ // eslint-disable-next-line @typescript-eslint/no-shadow
584
+ inherit({ lifecycle, registerPlugins: registerPlugins2 }) {
585
+ Object.keys(lifecycle).forEach((hookName) => {
586
+ assert(!this.lifecycle[hookName], `The hook "${hookName}" has a conflict and cannot be inherited.`);
587
+ this.lifecycle[hookName] = lifecycle[hookName];
588
+ });
589
+ Object.keys(registerPlugins2).forEach((pluginName) => {
590
+ assert(!this.registerPlugins[pluginName], `The plugin "${pluginName}" has a conflict and cannot be inherited.`);
591
+ this.applyPlugin(registerPlugins2[pluginName]);
592
+ });
593
+ }
594
+ constructor(lifecycle) {
595
+ this.registerPlugins = {};
596
+ this.lifecycle = lifecycle;
597
+ this.lifecycleKeys = Object.keys(lifecycle);
598
+ }
599
+ }
600
+ const buildIdentifier = "[0-9A-Za-z-]+";
601
+ const build = `(?:\\+(${buildIdentifier}(?:\\.${buildIdentifier})*))`;
602
+ const numericIdentifier = "0|[1-9]\\d*";
603
+ const numericIdentifierLoose = "[0-9]+";
604
+ const nonNumericIdentifier = "\\d*[a-zA-Z-][a-zA-Z0-9-]*";
605
+ const preReleaseIdentifierLoose = `(?:${numericIdentifierLoose}|${nonNumericIdentifier})`;
606
+ const preReleaseLoose = `(?:-?(${preReleaseIdentifierLoose}(?:\\.${preReleaseIdentifierLoose})*))`;
607
+ const preReleaseIdentifier = `(?:${numericIdentifier}|${nonNumericIdentifier})`;
608
+ const preRelease = `(?:-(${preReleaseIdentifier}(?:\\.${preReleaseIdentifier})*))`;
609
+ const xRangeIdentifier = `${numericIdentifier}|x|X|\\*`;
610
+ const xRangePlain = `[v=\\s]*(${xRangeIdentifier})(?:\\.(${xRangeIdentifier})(?:\\.(${xRangeIdentifier})(?:${preRelease})?${build}?)?)?`;
611
+ const hyphenRange = `^\\s*(${xRangePlain})\\s+-\\s+(${xRangePlain})\\s*$`;
612
+ const mainVersionLoose = `(${numericIdentifierLoose})\\.(${numericIdentifierLoose})\\.(${numericIdentifierLoose})`;
613
+ const loosePlain = `[v=\\s]*${mainVersionLoose}${preReleaseLoose}?${build}?`;
614
+ const gtlt = "((?:<|>)?=?)";
615
+ const comparatorTrim = `(\\s*)${gtlt}\\s*(${loosePlain}|${xRangePlain})`;
616
+ const loneTilde = "(?:~>?)";
617
+ const tildeTrim = `(\\s*)${loneTilde}\\s+`;
618
+ const loneCaret = "(?:\\^)";
619
+ const caretTrim = `(\\s*)${loneCaret}\\s+`;
620
+ const star = "(<|>)?=?\\s*\\*";
621
+ const caret = `^${loneCaret}${xRangePlain}$`;
622
+ const mainVersion = `(${numericIdentifier})\\.(${numericIdentifier})\\.(${numericIdentifier})`;
623
+ const fullPlain = `v?${mainVersion}${preRelease}?${build}?`;
624
+ const tilde = `^${loneTilde}${xRangePlain}$`;
625
+ const xRange = `^${gtlt}\\s*${xRangePlain}$`;
626
+ const comparator = `^${gtlt}\\s*(${fullPlain})$|^$`;
627
+ const gte0 = "^\\s*>=\\s*0.0.0\\s*$";
628
+ function parseRegex(source) {
629
+ return new RegExp(source);
630
+ }
631
+ function isXVersion(version) {
632
+ return !version || version.toLowerCase() === "x" || version === "*";
633
+ }
634
+ function pipe(...fns) {
635
+ return (x) => fns.reduce((v, f2) => f2(v), x);
636
+ }
637
+ function extractComparator(comparatorString) {
638
+ return comparatorString.match(parseRegex(comparator));
639
+ }
640
+ function combineVersion(major, minor, patch, preRelease2) {
641
+ const mainVersion2 = `${major}.${minor}.${patch}`;
642
+ if (preRelease2) {
643
+ return `${mainVersion2}-${preRelease2}`;
644
+ }
645
+ return mainVersion2;
646
+ }
647
+ function parseHyphen(range) {
648
+ return range.replace(parseRegex(hyphenRange), (_range, from, fromMajor, fromMinor, fromPatch, _fromPreRelease, _fromBuild, to, toMajor, toMinor, toPatch, toPreRelease) => {
649
+ if (isXVersion(fromMajor)) {
650
+ from = "";
651
+ } else if (isXVersion(fromMinor)) {
652
+ from = `>=${fromMajor}.0.0`;
653
+ } else if (isXVersion(fromPatch)) {
654
+ from = `>=${fromMajor}.${fromMinor}.0`;
655
+ } else {
656
+ from = `>=${from}`;
657
+ }
658
+ if (isXVersion(toMajor)) {
659
+ to = "";
660
+ } else if (isXVersion(toMinor)) {
661
+ to = `<${Number(toMajor) + 1}.0.0-0`;
662
+ } else if (isXVersion(toPatch)) {
663
+ to = `<${toMajor}.${Number(toMinor) + 1}.0-0`;
664
+ } else if (toPreRelease) {
665
+ to = `<=${toMajor}.${toMinor}.${toPatch}-${toPreRelease}`;
666
+ } else {
667
+ to = `<=${to}`;
668
+ }
669
+ return `${from} ${to}`.trim();
670
+ });
671
+ }
672
+ function parseComparatorTrim(range) {
673
+ return range.replace(parseRegex(comparatorTrim), "$1$2$3");
674
+ }
675
+ function parseTildeTrim(range) {
676
+ return range.replace(parseRegex(tildeTrim), "$1~");
677
+ }
678
+ function parseCaretTrim(range) {
679
+ return range.replace(parseRegex(caretTrim), "$1^");
680
+ }
681
+ function parseCarets(range) {
682
+ return range.trim().split(/\s+/).map((rangeVersion) => rangeVersion.replace(parseRegex(caret), (_, major, minor, patch, preRelease2) => {
683
+ if (isXVersion(major)) {
684
+ return "";
685
+ } else if (isXVersion(minor)) {
686
+ return `>=${major}.0.0 <${Number(major) + 1}.0.0-0`;
687
+ } else if (isXVersion(patch)) {
688
+ if (major === "0") {
689
+ return `>=${major}.${minor}.0 <${major}.${Number(minor) + 1}.0-0`;
690
+ } else {
691
+ return `>=${major}.${minor}.0 <${Number(major) + 1}.0.0-0`;
692
+ }
693
+ } else if (preRelease2) {
694
+ if (major === "0") {
695
+ if (minor === "0") {
696
+ return `>=${major}.${minor}.${patch}-${preRelease2} <${major}.${minor}.${Number(patch) + 1}-0`;
697
+ } else {
698
+ return `>=${major}.${minor}.${patch}-${preRelease2} <${major}.${Number(minor) + 1}.0-0`;
699
+ }
700
+ } else {
701
+ return `>=${major}.${minor}.${patch}-${preRelease2} <${Number(major) + 1}.0.0-0`;
702
+ }
703
+ } else {
704
+ if (major === "0") {
705
+ if (minor === "0") {
706
+ return `>=${major}.${minor}.${patch} <${major}.${minor}.${Number(patch) + 1}-0`;
707
+ } else {
708
+ return `>=${major}.${minor}.${patch} <${major}.${Number(minor) + 1}.0-0`;
709
+ }
710
+ }
711
+ return `>=${major}.${minor}.${patch} <${Number(major) + 1}.0.0-0`;
712
+ }
713
+ })).join(" ");
714
+ }
715
+ function parseTildes(range) {
716
+ return range.trim().split(/\s+/).map((rangeVersion) => rangeVersion.replace(parseRegex(tilde), (_, major, minor, patch, preRelease2) => {
717
+ if (isXVersion(major)) {
718
+ return "";
719
+ } else if (isXVersion(minor)) {
720
+ return `>=${major}.0.0 <${Number(major) + 1}.0.0-0`;
721
+ } else if (isXVersion(patch)) {
722
+ return `>=${major}.${minor}.0 <${major}.${Number(minor) + 1}.0-0`;
723
+ } else if (preRelease2) {
724
+ return `>=${major}.${minor}.${patch}-${preRelease2} <${major}.${Number(minor) + 1}.0-0`;
725
+ }
726
+ return `>=${major}.${minor}.${patch} <${major}.${Number(minor) + 1}.0-0`;
727
+ })).join(" ");
728
+ }
729
+ function parseXRanges(range) {
730
+ return range.split(/\s+/).map((rangeVersion) => rangeVersion.trim().replace(parseRegex(xRange), (ret, gtlt2, major, minor, patch, preRelease2) => {
731
+ const isXMajor = isXVersion(major);
732
+ const isXMinor = isXMajor || isXVersion(minor);
733
+ const isXPatch = isXMinor || isXVersion(patch);
734
+ if (gtlt2 === "=" && isXPatch) {
735
+ gtlt2 = "";
736
+ }
737
+ preRelease2 = "";
738
+ if (isXMajor) {
739
+ if (gtlt2 === ">" || gtlt2 === "<") {
740
+ return "<0.0.0-0";
741
+ } else {
742
+ return "*";
743
+ }
744
+ } else if (gtlt2 && isXPatch) {
745
+ if (isXMinor) {
746
+ minor = 0;
747
+ }
748
+ patch = 0;
749
+ if (gtlt2 === ">") {
750
+ gtlt2 = ">=";
751
+ if (isXMinor) {
752
+ major = Number(major) + 1;
753
+ minor = 0;
754
+ patch = 0;
755
+ } else {
756
+ minor = Number(minor) + 1;
757
+ patch = 0;
758
+ }
759
+ } else if (gtlt2 === "<=") {
760
+ gtlt2 = "<";
761
+ if (isXMinor) {
762
+ major = Number(major) + 1;
763
+ } else {
764
+ minor = Number(minor) + 1;
765
+ }
766
+ }
767
+ if (gtlt2 === "<") {
768
+ preRelease2 = "-0";
769
+ }
770
+ return `${gtlt2 + major}.${minor}.${patch}${preRelease2}`;
771
+ } else if (isXMinor) {
772
+ return `>=${major}.0.0${preRelease2} <${Number(major) + 1}.0.0-0`;
773
+ } else if (isXPatch) {
774
+ return `>=${major}.${minor}.0${preRelease2} <${major}.${Number(minor) + 1}.0-0`;
775
+ }
776
+ return ret;
777
+ })).join(" ");
778
+ }
779
+ function parseStar(range) {
780
+ return range.trim().replace(parseRegex(star), "");
781
+ }
782
+ function parseGTE0(comparatorString) {
783
+ return comparatorString.trim().replace(parseRegex(gte0), "");
784
+ }
785
+ function compareAtom(rangeAtom, versionAtom) {
786
+ rangeAtom = Number(rangeAtom) || rangeAtom;
787
+ versionAtom = Number(versionAtom) || versionAtom;
788
+ if (rangeAtom > versionAtom) {
789
+ return 1;
790
+ }
791
+ if (rangeAtom === versionAtom) {
792
+ return 0;
793
+ }
794
+ return -1;
795
+ }
796
+ function comparePreRelease(rangeAtom, versionAtom) {
797
+ const { preRelease: rangePreRelease } = rangeAtom;
798
+ const { preRelease: versionPreRelease } = versionAtom;
799
+ if (rangePreRelease === void 0 && Boolean(versionPreRelease)) {
800
+ return 1;
801
+ }
802
+ if (Boolean(rangePreRelease) && versionPreRelease === void 0) {
803
+ return -1;
804
+ }
805
+ if (rangePreRelease === void 0 && versionPreRelease === void 0) {
806
+ return 0;
807
+ }
808
+ for (let i = 0, n = rangePreRelease.length; i <= n; i++) {
809
+ const rangeElement = rangePreRelease[i];
810
+ const versionElement = versionPreRelease[i];
811
+ if (rangeElement === versionElement) {
812
+ continue;
813
+ }
814
+ if (rangeElement === void 0 && versionElement === void 0) {
815
+ return 0;
816
+ }
817
+ if (!rangeElement) {
818
+ return 1;
819
+ }
820
+ if (!versionElement) {
821
+ return -1;
822
+ }
823
+ return compareAtom(rangeElement, versionElement);
824
+ }
825
+ return 0;
826
+ }
827
+ function compareVersion(rangeAtom, versionAtom) {
828
+ return compareAtom(rangeAtom.major, versionAtom.major) || compareAtom(rangeAtom.minor, versionAtom.minor) || compareAtom(rangeAtom.patch, versionAtom.patch) || comparePreRelease(rangeAtom, versionAtom);
829
+ }
830
+ function eq(rangeAtom, versionAtom) {
831
+ return rangeAtom.version === versionAtom.version;
832
+ }
833
+ function compare(rangeAtom, versionAtom) {
834
+ switch (rangeAtom.operator) {
835
+ case "":
836
+ case "=":
837
+ return eq(rangeAtom, versionAtom);
838
+ case ">":
839
+ return compareVersion(rangeAtom, versionAtom) < 0;
840
+ case ">=":
841
+ return eq(rangeAtom, versionAtom) || compareVersion(rangeAtom, versionAtom) < 0;
842
+ case "<":
843
+ return compareVersion(rangeAtom, versionAtom) > 0;
844
+ case "<=":
845
+ return eq(rangeAtom, versionAtom) || compareVersion(rangeAtom, versionAtom) > 0;
846
+ case void 0: {
847
+ return true;
848
+ }
849
+ default:
850
+ return false;
851
+ }
852
+ }
853
+ function parseComparatorString(range) {
854
+ return pipe(
855
+ // handle caret
856
+ // ^ --> * (any, kinda silly)
857
+ // ^2, ^2.x, ^2.x.x --> >=2.0.0 <3.0.0-0
858
+ // ^2.0, ^2.0.x --> >=2.0.0 <3.0.0-0
859
+ // ^1.2, ^1.2.x --> >=1.2.0 <2.0.0-0
860
+ // ^1.2.3 --> >=1.2.3 <2.0.0-0
861
+ // ^1.2.0 --> >=1.2.0 <2.0.0-0
862
+ parseCarets,
863
+ // handle tilde
864
+ // ~, ~> --> * (any, kinda silly)
865
+ // ~2, ~2.x, ~2.x.x, ~>2, ~>2.x ~>2.x.x --> >=2.0.0 <3.0.0-0
866
+ // ~2.0, ~2.0.x, ~>2.0, ~>2.0.x --> >=2.0.0 <2.1.0-0
867
+ // ~1.2, ~1.2.x, ~>1.2, ~>1.2.x --> >=1.2.0 <1.3.0-0
868
+ // ~1.2.3, ~>1.2.3 --> >=1.2.3 <1.3.0-0
869
+ // ~1.2.0, ~>1.2.0 --> >=1.2.0 <1.3.0-0
870
+ parseTildes,
871
+ parseXRanges,
872
+ parseStar
873
+ )(range);
874
+ }
875
+ function parseRange(range) {
876
+ return pipe(
877
+ // handle hyphenRange
878
+ // `1.2.3 - 1.2.4` => `>=1.2.3 <=1.2.4`
879
+ parseHyphen,
880
+ // handle trim comparator
881
+ // `> 1.2.3 < 1.2.5` => `>1.2.3 <1.2.5`
882
+ parseComparatorTrim,
883
+ // handle trim tilde
884
+ // `~ 1.2.3` => `~1.2.3`
885
+ parseTildeTrim,
886
+ // handle trim caret
887
+ // `^ 1.2.3` => `^1.2.3`
888
+ parseCaretTrim
889
+ )(range.trim()).split(/\s+/).join(" ");
890
+ }
891
+ function satisfy(version, range) {
892
+ if (!version) {
893
+ return false;
894
+ }
895
+ const parsedRange = parseRange(range);
896
+ const parsedComparator = parsedRange.split(" ").map((rangeVersion) => parseComparatorString(rangeVersion)).join(" ");
897
+ const comparators = parsedComparator.split(/\s+/).map((comparator2) => parseGTE0(comparator2));
898
+ const extractedVersion = extractComparator(version);
899
+ if (!extractedVersion) {
900
+ return false;
901
+ }
902
+ const [, versionOperator, , versionMajor, versionMinor, versionPatch, versionPreRelease] = extractedVersion;
903
+ const versionAtom = {
904
+ operator: versionOperator,
905
+ version: combineVersion(versionMajor, versionMinor, versionPatch, versionPreRelease),
906
+ major: versionMajor,
907
+ minor: versionMinor,
908
+ patch: versionPatch,
909
+ preRelease: versionPreRelease == null ? void 0 : versionPreRelease.split(".")
910
+ };
911
+ for (const comparator2 of comparators) {
912
+ const extractedComparator = extractComparator(comparator2);
913
+ if (!extractedComparator) {
914
+ return false;
915
+ }
916
+ const [, rangeOperator, , rangeMajor, rangeMinor, rangePatch, rangePreRelease] = extractedComparator;
917
+ const rangeAtom = {
918
+ operator: rangeOperator,
919
+ version: combineVersion(rangeMajor, rangeMinor, rangePatch, rangePreRelease),
920
+ major: rangeMajor,
921
+ minor: rangeMinor,
922
+ patch: rangePatch,
923
+ preRelease: rangePreRelease == null ? void 0 : rangePreRelease.split(".")
924
+ };
925
+ if (!compare(rangeAtom, versionAtom)) {
926
+ return false;
927
+ }
928
+ }
929
+ return true;
930
+ }
931
+ function versionLt(a, b) {
932
+ const transformInvalidVersion = (version) => {
933
+ const isNumberVersion = !Number.isNaN(Number(version));
934
+ if (isNumberVersion) {
935
+ const splitArr = version.split(".");
936
+ let validVersion = version;
937
+ for (let i = 0; i < 3 - splitArr.length; i++) {
938
+ validVersion += ".0";
939
+ }
940
+ return validVersion;
941
+ }
942
+ return version;
943
+ };
944
+ if (satisfy(transformInvalidVersion(a), `<=${transformInvalidVersion(b)}`)) {
945
+ return true;
946
+ } else {
947
+ return false;
948
+ }
949
+ }
950
+ const findVersion = (shareVersionMap, cb) => {
951
+ const callback = cb || function(prev, cur) {
952
+ return versionLt(prev, cur);
953
+ };
954
+ return Object.keys(shareVersionMap).reduce((prev, cur) => {
955
+ if (!prev) {
956
+ return cur;
957
+ }
958
+ if (callback(prev, cur)) {
959
+ return cur;
960
+ }
961
+ if (prev === "0") {
962
+ return cur;
963
+ }
964
+ return prev;
965
+ }, 0);
966
+ };
967
+ const isLoaded = (shared) => {
968
+ return Boolean(shared.loaded) || typeof shared.lib === "function";
969
+ };
970
+ function findSingletonVersionOrderByVersion(shareScopeMap, scope, pkgName) {
971
+ const versions = shareScopeMap[scope][pkgName];
972
+ const callback = function(prev, cur) {
973
+ return !isLoaded(versions[prev]) && versionLt(prev, cur);
974
+ };
975
+ return findVersion(shareScopeMap[scope][pkgName], callback);
976
+ }
977
+ function findSingletonVersionOrderByLoaded(shareScopeMap, scope, pkgName) {
978
+ const versions = shareScopeMap[scope][pkgName];
979
+ const callback = function(prev, cur) {
980
+ if (isLoaded(versions[cur])) {
981
+ if (isLoaded(versions[prev])) {
982
+ return Boolean(versionLt(prev, cur));
983
+ } else {
984
+ return true;
985
+ }
986
+ }
987
+ if (isLoaded(versions[prev])) {
988
+ return false;
989
+ }
990
+ return versionLt(prev, cur);
991
+ };
992
+ return findVersion(shareScopeMap[scope][pkgName], callback);
993
+ }
994
+ function getFindShareFunction(strategy) {
995
+ if (strategy === "loaded-first") {
996
+ return findSingletonVersionOrderByLoaded;
997
+ }
998
+ return findSingletonVersionOrderByVersion;
999
+ }
1000
+ function getRegisteredShare(localShareScopeMap, pkgName, shareInfo, resolveShare) {
1001
+ if (!localShareScopeMap) {
1002
+ return;
1003
+ }
1004
+ const { shareConfig, scope = DEFAULT_SCOPE, strategy } = shareInfo;
1005
+ const scopes = Array.isArray(scope) ? scope : [
1006
+ scope
1007
+ ];
1008
+ for (const sc of scopes) {
1009
+ if (shareConfig && localShareScopeMap[sc] && localShareScopeMap[sc][pkgName]) {
1010
+ const { requiredVersion } = shareConfig;
1011
+ const findShareFunction = getFindShareFunction(strategy);
1012
+ const maxOrSingletonVersion = findShareFunction(localShareScopeMap, sc, pkgName);
1013
+ const defaultResolver = () => {
1014
+ if (shareConfig.singleton) {
1015
+ if (typeof requiredVersion === "string" && !satisfy(maxOrSingletonVersion, requiredVersion)) {
1016
+ 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})`;
1017
+ if (shareConfig.strictVersion) {
1018
+ error(msg);
1019
+ } else {
1020
+ warn(msg);
1021
+ }
1022
+ }
1023
+ return localShareScopeMap[sc][pkgName][maxOrSingletonVersion];
1024
+ } else {
1025
+ if (requiredVersion === false || requiredVersion === "*") {
1026
+ return localShareScopeMap[sc][pkgName][maxOrSingletonVersion];
1027
+ }
1028
+ if (satisfy(maxOrSingletonVersion, requiredVersion)) {
1029
+ return localShareScopeMap[sc][pkgName][maxOrSingletonVersion];
1030
+ }
1031
+ for (const [versionKey, versionValue] of Object.entries(localShareScopeMap[sc][pkgName])) {
1032
+ if (satisfy(versionKey, requiredVersion)) {
1033
+ return versionValue;
1034
+ }
1035
+ }
1036
+ }
1037
+ };
1038
+ const params = {
1039
+ shareScopeMap: localShareScopeMap,
1040
+ scope: sc,
1041
+ pkgName,
1042
+ version: maxOrSingletonVersion,
1043
+ GlobalFederation: Global.__FEDERATION__,
1044
+ resolver: defaultResolver
1045
+ };
1046
+ const resolveShared = resolveShare.emit(params) || params;
1047
+ return resolveShared.resolver();
1048
+ }
1049
+ }
1050
+ }
1051
+ function getGlobalShareScope() {
1052
+ return Global.__FEDERATION__.__SHARE__;
1053
+ }
1054
+ var pluginHelper = /* @__PURE__ */ Object.freeze({
1055
+ __proto__: null,
1056
+ SyncHook,
1057
+ AsyncHook,
1058
+ SyncWaterfallHook,
1059
+ AsyncWaterfallHook,
1060
+ PluginSystem
1061
+ });
1062
+ const ShareUtils = {
1063
+ getRegisteredShare,
1064
+ getGlobalShareScope
1065
+ };
1066
+ const GlobalUtils = {
1067
+ Global,
1068
+ nativeGlobal,
1069
+ resetFederationGlobalInfo,
1070
+ getGlobalFederationInstance,
1071
+ setGlobalFederationInstance,
1072
+ getGlobalFederationConstructor,
1073
+ setGlobalFederationConstructor,
1074
+ getInfoWithoutType,
1075
+ getGlobalSnapshot,
1076
+ getTargetSnapshotInfoByModuleInfo,
1077
+ getGlobalSnapshotInfoByModuleInfo,
1078
+ setGlobalSnapshotInfoByModuleInfo,
1079
+ addGlobalSnapshot,
1080
+ getRemoteEntryExports,
1081
+ registerGlobalPlugins,
1082
+ getGlobalHostPlugins,
1083
+ getPreloaded,
1084
+ setPreloaded,
1085
+ registerPlugins,
1086
+ pluginHelper
1087
+ };
1088
+ var helpers = {
1089
+ global: GlobalUtils,
1090
+ share: ShareUtils
1091
+ };
1092
+ function registerBridgeLifeCycle() {
1093
+ var _a;
1094
+ const { registerPlugins: registerPlugins2, pluginHelper: pluginHelper2 } = helpers.global;
1095
+ const host = getInstance();
1096
+ const pluginSystem = new pluginHelper2.PluginSystem({
1097
+ beforeBridgeRender: new pluginHelper2.SyncHook(),
1098
+ beforeBridgeDestroy: 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
+ }
101
1109
  const RemoteAppWrapper = forwardRef(function(props, ref) {
1110
+ const bridgeHook = registerBridgeLifeCycle();
102
1111
  const RemoteApp2 = () => {
103
1112
  LoggerInstance.log(`RemoteAppWrapper RemoteApp props >>>`, { props });
104
1113
  const {
@@ -116,6 +1125,7 @@ const RemoteAppWrapper = forwardRef(function(props, ref) {
116
1125
  const providerInfoRef = useRef(null);
117
1126
  useEffect(() => {
118
1127
  const renderTimeout = setTimeout(() => {
1128
+ var _a, _b;
119
1129
  const providerReturn = providerInfo();
120
1130
  providerInfoRef.current = providerReturn;
121
1131
  const renderProps = {
@@ -131,18 +1141,33 @@ const RemoteAppWrapper = forwardRef(function(props, ref) {
131
1141
  `createRemoteComponent LazyComponent render >>>`,
132
1142
  renderProps
133
1143
  );
1144
+ if (bridgeHook && ((_a = bridgeHook == null ? void 0 : bridgeHook.lifecycle) == null ? void 0 : _a.beforeBridgeRender)) {
1145
+ (_b = bridgeHook == null ? void 0 : bridgeHook.lifecycle) == null ? void 0 : _b.beforeBridgeRender.emit({
1146
+ ...renderProps
1147
+ });
1148
+ }
134
1149
  providerReturn.render(renderProps);
135
1150
  });
136
1151
  return () => {
137
1152
  clearTimeout(renderTimeout);
138
1153
  setTimeout(() => {
139
- var _a, _b;
1154
+ var _a, _b, _c, _d;
140
1155
  if ((_a = providerInfoRef.current) == null ? void 0 : _a.destroy) {
141
1156
  LoggerInstance.log(
142
1157
  `createRemoteComponent LazyComponent destroy >>>`,
143
1158
  { moduleName, basename, dom: renderDom.current }
144
1159
  );
145
- (_b = providerInfoRef.current) == null ? void 0 : _b.destroy({
1160
+ if (bridgeHook && ((_b = bridgeHook == null ? void 0 : bridgeHook.lifecycle) == null ? void 0 : _b.beforeBridgeDestroy)) {
1161
+ (_c = bridgeHook == null ? void 0 : bridgeHook.lifecycle) == null ? void 0 : _c.beforeBridgeDestroy.emit({
1162
+ moduleName,
1163
+ dom: renderDom.current,
1164
+ basename,
1165
+ memoryRoute,
1166
+ fallback,
1167
+ ...resProps
1168
+ });
1169
+ }
1170
+ (_d = providerInfoRef.current) == null ? void 0 : _d.destroy({
146
1171
  dom: renderDom.current
147
1172
  });
148
1173
  }
@@ -270,8 +1295,8 @@ function createLazyRemoteComponent(info) {
270
1295
  )}`
271
1296
  );
272
1297
  }
273
- } catch (error) {
274
- throw error;
1298
+ } catch (error2) {
1299
+ throw error2;
275
1300
  }
276
1301
  });
277
1302
  }
@@ -308,7 +1333,7 @@ if (process.env.NODE_ENV === "production") {
308
1333
  };
309
1334
  }
310
1335
  function createBridgeComponent(bridgeInfo) {
311
- return () => {
1336
+ return (params) => {
312
1337
  const rootMap = /* @__PURE__ */ new Map();
313
1338
  const RawComponent = (info) => {
314
1339
  const { appInfo, propsInfo, ...restProps } = info;
@@ -324,6 +1349,7 @@ function createBridgeComponent(bridgeInfo) {
324
1349
  };
325
1350
  return {
326
1351
  async render(info) {
1352
+ var _a;
327
1353
  LoggerInstance.log(`createBridgeComponent render Info`, info);
328
1354
  const {
329
1355
  moduleName,
@@ -347,6 +1373,8 @@ function createBridgeComponent(bridgeInfo) {
347
1373
  }
348
1374
  ))
349
1375
  );
1376
+ 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);
1377
+ beforeBridgeRender && beforeBridgeRender(info);
350
1378
  if (atLeastReact18(React)) {
351
1379
  if (bridgeInfo == null ? void 0 : bridgeInfo.render) {
352
1380
  Promise.resolve(
@@ -363,9 +1391,15 @@ function createBridgeComponent(bridgeInfo) {
363
1391
  }
364
1392
  },
365
1393
  async destroy(info) {
1394
+ var _a;
366
1395
  LoggerInstance.log(`createBridgeComponent destroy Info`, {
367
1396
  dom: info.dom
368
1397
  });
1398
+ if ((bridgeInfo == null ? void 0 : bridgeInfo.hooks) && (bridgeInfo == null ? void 0 : bridgeInfo.hooks.beforeBridgeDestroy) && typeof (bridgeInfo == null ? void 0 : bridgeInfo.hooks.beforeBridgeDestroy) === "function") {
1399
+ bridgeInfo.hooks.beforeBridgeDestroy(info);
1400
+ }
1401
+ 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);
1402
+ beforeBridgeDestroy && beforeBridgeDestroy(info);
369
1403
  if (atLeastReact18(React)) {
370
1404
  const root = rootMap.get(info.dom);
371
1405
  root == null ? void 0 : root.unmount();