@module-federation/bridge-react 2.8.2 → 2.9.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/base.cjs.js CHANGED
@@ -1,10 +1,10 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
- const createHelpers = require("./createHelpers-19BP0xtB.js");
4
- const lazyLoadComponentPlugin = require("./lazy-load-component-plugin-DeTbkGlM.js");
3
+ const createHelpers = require("./createHelpers-D6thyyLv.js");
4
+ const lazyLoadComponentPlugin = require("./lazy-load-component-plugin-CRqjWQ5N.js");
5
5
  const lazyUtils = require("./utils-5dGErM3C.js");
6
6
  const dataFetchUtils = require("./data-fetch-utils.cjs.js");
7
- const prefetch = require("./prefetch-CfMDdqO-.js");
7
+ const prefetch = require("./prefetch-CMvAw8F3.js");
8
8
  const createRemoteAppComponent = createHelpers.createRemoteAppComponentFactory(createHelpers.RemoteAppWrapper);
9
9
  const createRemoteComponent = createHelpers.createDeprecatedRemoteComponentFactory(
10
10
  createRemoteAppComponent
package/dist/base.es.js CHANGED
@@ -1,9 +1,9 @@
1
- import { c as createRemoteAppComponentFactory, a as createDeprecatedRemoteComponentFactory, R as RemoteAppWrapper } from "./createHelpers-BSHeKyd-.mjs";
2
- import { b } from "./createHelpers-BSHeKyd-.mjs";
3
- import { a, c, b as b2, l } from "./lazy-load-component-plugin-DQFjLSsW.mjs";
1
+ import { c as createRemoteAppComponentFactory, a as createDeprecatedRemoteComponentFactory, R as RemoteAppWrapper } from "./createHelpers-D3Sg5lKp.mjs";
2
+ import { b } from "./createHelpers-D3Sg5lKp.mjs";
3
+ import { a, c, b as b2, l } from "./lazy-load-component-plugin-CyRfqVSE.mjs";
4
4
  import { C, a as a2, E, c as c2, b as b3, d, g, r, s } from "./utils-BBP3hEeV.mjs";
5
5
  import { callDataFetch } from "./data-fetch-utils.es.js";
6
- import { p } from "./prefetch-BJZbf9LF.mjs";
6
+ import { p } from "./prefetch-xvZIEaJL.mjs";
7
7
  const createRemoteAppComponent = createRemoteAppComponentFactory(RemoteAppWrapper);
8
8
  const createRemoteComponent = createDeprecatedRemoteComponentFactory(
9
9
  createRemoteAppComponent
@@ -89,11 +89,20 @@ function createBaseBridgeComponent({
89
89
  rootOptions,
90
90
  ...propsInfo
91
91
  } = info;
92
+ const operationContext = {
93
+ side: "producer",
94
+ framework: "react",
95
+ operation: rootMap.has(dom) ? "update" : "render",
96
+ reason: "direct"
97
+ };
92
98
  const mergedRootOptions = {
93
99
  ...defaultRootOptions,
94
100
  ...rootOptions
95
101
  };
96
- const beforeBridgeRenderRes = ((_c = (_b = (_a = instance == null ? void 0 : instance.bridgeHook) == null ? void 0 : _a.lifecycle) == null ? void 0 : _b.beforeBridgeRender) == null ? void 0 : _c.emit(info)) || {};
102
+ const beforeBridgeRenderRes = ((_c = (_b = (_a = instance == null ? void 0 : instance.bridgeHook) == null ? void 0 : _a.lifecycle) == null ? void 0 : _b.beforeBridgeRender) == null ? void 0 : _c.emit(
103
+ info,
104
+ operationContext
105
+ )) || {};
97
106
  const rootComponentWithErrorBoundary = /* @__PURE__ */ React.createElement(
98
107
  BridgeWrapper,
99
108
  {
@@ -108,9 +117,10 @@ function createBaseBridgeComponent({
108
117
  }
109
118
  );
110
119
  if (bridgeInfo.render) {
111
- await Promise.resolve(
120
+ const root = await Promise.resolve(
112
121
  bridgeInfo.render(rootComponentWithErrorBoundary, dom)
113
- ).then((root) => rootMap.set(dom, root));
122
+ );
123
+ rootMap.set(dom, root);
114
124
  } else {
115
125
  let root = rootMap.get(dom);
116
126
  if (!root && createRoot) {
@@ -121,13 +131,25 @@ function createBaseBridgeComponent({
121
131
  root.render(rootComponentWithErrorBoundary);
122
132
  }
123
133
  }
124
- ((_f = (_e = (_d = instance == null ? void 0 : instance.bridgeHook) == null ? void 0 : _d.lifecycle) == null ? void 0 : _e.afterBridgeRender) == null ? void 0 : _f.emit(info)) || {};
134
+ ((_f = (_e = (_d = instance == null ? void 0 : instance.bridgeHook) == null ? void 0 : _d.lifecycle) == null ? void 0 : _e.afterBridgeRender) == null ? void 0 : _f.emit(info, {
135
+ context: operationContext
136
+ })) || {};
125
137
  },
126
138
  destroy(info) {
127
- var _a, _b, _c;
139
+ var _a, _b, _c, _d, _e, _f;
128
140
  const { dom } = info;
129
141
  LoggerInstance.debug(`createBridgeComponent destroy Info`, info);
130
142
  const root = rootMap.get(dom);
143
+ const operationContext = {
144
+ side: "producer",
145
+ framework: "react",
146
+ operation: "destroy",
147
+ reason: "direct"
148
+ };
149
+ (_c = (_b = (_a = instance == null ? void 0 : instance.bridgeHook) == null ? void 0 : _a.lifecycle) == null ? void 0 : _b.beforeBridgeDestroy) == null ? void 0 : _c.emit(
150
+ info,
151
+ operationContext
152
+ );
131
153
  if (root) {
132
154
  if ("unmount" in root) {
133
155
  root.unmount();
@@ -136,7 +158,9 @@ function createBaseBridgeComponent({
136
158
  }
137
159
  rootMap.delete(dom);
138
160
  }
139
- (_c = (_b = (_a = instance == null ? void 0 : instance.bridgeHook) == null ? void 0 : _a.lifecycle) == null ? void 0 : _b.afterBridgeDestroy) == null ? void 0 : _c.emit(info);
161
+ (_f = (_e = (_d = instance == null ? void 0 : instance.bridgeHook) == null ? void 0 : _d.lifecycle) == null ? void 0 : _e.afterBridgeDestroy) == null ? void 0 : _f.emit(info, {
162
+ context: operationContext
163
+ });
140
164
  }
141
165
  };
142
166
  };
@@ -107,11 +107,20 @@ function createBaseBridgeComponent({
107
107
  rootOptions,
108
108
  ...propsInfo
109
109
  } = info;
110
+ const operationContext = {
111
+ side: "producer",
112
+ framework: "react",
113
+ operation: rootMap.has(dom) ? "update" : "render",
114
+ reason: "direct"
115
+ };
110
116
  const mergedRootOptions = {
111
117
  ...defaultRootOptions,
112
118
  ...rootOptions
113
119
  };
114
- const beforeBridgeRenderRes = ((_c = (_b = (_a = instance == null ? void 0 : instance.bridgeHook) == null ? void 0 : _a.lifecycle) == null ? void 0 : _b.beforeBridgeRender) == null ? void 0 : _c.emit(info)) || {};
120
+ const beforeBridgeRenderRes = ((_c = (_b = (_a = instance == null ? void 0 : instance.bridgeHook) == null ? void 0 : _a.lifecycle) == null ? void 0 : _b.beforeBridgeRender) == null ? void 0 : _c.emit(
121
+ info,
122
+ operationContext
123
+ )) || {};
115
124
  const rootComponentWithErrorBoundary = /* @__PURE__ */ React__namespace.createElement(
116
125
  BridgeWrapper,
117
126
  {
@@ -126,9 +135,10 @@ function createBaseBridgeComponent({
126
135
  }
127
136
  );
128
137
  if (bridgeInfo.render) {
129
- await Promise.resolve(
138
+ const root = await Promise.resolve(
130
139
  bridgeInfo.render(rootComponentWithErrorBoundary, dom)
131
- ).then((root) => rootMap.set(dom, root));
140
+ );
141
+ rootMap.set(dom, root);
132
142
  } else {
133
143
  let root = rootMap.get(dom);
134
144
  if (!root && createRoot) {
@@ -139,13 +149,25 @@ function createBaseBridgeComponent({
139
149
  root.render(rootComponentWithErrorBoundary);
140
150
  }
141
151
  }
142
- ((_f = (_e = (_d = instance == null ? void 0 : instance.bridgeHook) == null ? void 0 : _d.lifecycle) == null ? void 0 : _e.afterBridgeRender) == null ? void 0 : _f.emit(info)) || {};
152
+ ((_f = (_e = (_d = instance == null ? void 0 : instance.bridgeHook) == null ? void 0 : _d.lifecycle) == null ? void 0 : _e.afterBridgeRender) == null ? void 0 : _f.emit(info, {
153
+ context: operationContext
154
+ })) || {};
143
155
  },
144
156
  destroy(info) {
145
- var _a, _b, _c;
157
+ var _a, _b, _c, _d, _e, _f;
146
158
  const { dom } = info;
147
159
  index.LoggerInstance.debug(`createBridgeComponent destroy Info`, info);
148
160
  const root = rootMap.get(dom);
161
+ const operationContext = {
162
+ side: "producer",
163
+ framework: "react",
164
+ operation: "destroy",
165
+ reason: "direct"
166
+ };
167
+ (_c = (_b = (_a = instance == null ? void 0 : instance.bridgeHook) == null ? void 0 : _a.lifecycle) == null ? void 0 : _b.beforeBridgeDestroy) == null ? void 0 : _c.emit(
168
+ info,
169
+ operationContext
170
+ );
149
171
  if (root) {
150
172
  if ("unmount" in root) {
151
173
  root.unmount();
@@ -154,7 +176,9 @@ function createBaseBridgeComponent({
154
176
  }
155
177
  rootMap.delete(dom);
156
178
  }
157
- (_c = (_b = (_a = instance == null ? void 0 : instance.bridgeHook) == null ? void 0 : _a.lifecycle) == null ? void 0 : _b.afterBridgeDestroy) == null ? void 0 : _c.emit(info);
179
+ (_f = (_e = (_d = instance == null ? void 0 : instance.bridgeHook) == null ? void 0 : _d.lifecycle) == null ? void 0 : _e.afterBridgeDestroy) == null ? void 0 : _f.emit(info, {
180
+ context: operationContext
181
+ });
158
182
  }
159
183
  };
160
184
  };
@@ -1,4 +1,4 @@
1
- import { c as createBaseBridgeComponent, E as ErrorBoundary } from "./bridge-base-BaKy6CY_.mjs";
1
+ import { c as createBaseBridgeComponent, E as ErrorBoundary } from "./bridge-base-CHnL6Q9P.mjs";
2
2
  import ReactDOM from "react-dom";
3
3
  import { L as LoggerInstance, g as getRootDomDefaultClassName } from "./index-Bs2NxD2z.mjs";
4
4
  import React__default, { forwardRef, useRef, useState, useEffect } from "react";
@@ -57,31 +57,36 @@ const RemoteAppWrapper = forwardRef(function(props, ref) {
57
57
  providerInfoRef.current = providerReturn;
58
58
  setInitialized(true);
59
59
  return () => {
60
- var _a, _b, _c, _d, _e, _f, _g, _h;
60
+ var _a, _b, _c, _d, _e, _f, _g;
61
61
  if ((_a = providerInfoRef.current) == null ? void 0 : _a.destroy) {
62
62
  LoggerInstance.debug(
63
63
  `createRemoteAppComponent LazyComponent destroy >>>`,
64
64
  { moduleName, basename, dom: renderDom.current }
65
65
  );
66
- (_d = (_c = (_b = instance == null ? void 0 : instance.bridgeHook) == null ? void 0 : _b.lifecycle) == null ? void 0 : _c.beforeBridgeDestroy) == null ? void 0 : _d.emit({
66
+ const destroyInfo = {
67
67
  moduleName,
68
68
  dom: renderDom.current,
69
69
  basename,
70
70
  memoryRoute,
71
71
  fallback,
72
72
  ...resProps
73
- });
74
- (_e = providerInfoRef.current) == null ? void 0 : _e.destroy({
73
+ };
74
+ const operationContext = {
75
+ side: "consumer",
76
+ framework: "react",
77
+ operation: "destroy",
78
+ reason: "unmount"
79
+ };
80
+ (_d = (_c = (_b = instance == null ? void 0 : instance.bridgeHook) == null ? void 0 : _b.lifecycle) == null ? void 0 : _c.beforeBridgeDestroy) == null ? void 0 : _d.emit(
81
+ destroyInfo,
82
+ operationContext
83
+ );
84
+ providerInfoRef.current.destroy({
75
85
  moduleName,
76
86
  dom: renderDom.current
77
87
  });
78
- (_h = (_g = (_f = instance == null ? void 0 : instance.bridgeHook) == null ? void 0 : _f.lifecycle) == null ? void 0 : _g.afterBridgeDestroy) == null ? void 0 : _h.emit({
79
- moduleName,
80
- dom: renderDom.current,
81
- basename,
82
- memoryRoute,
83
- fallback,
84
- ...resProps
88
+ (_g = (_f = (_e = instance == null ? void 0 : instance.bridgeHook) == null ? void 0 : _e.lifecycle) == null ? void 0 : _f.afterBridgeDestroy) == null ? void 0 : _g.emit(destroyInfo, {
89
+ context: operationContext
85
90
  });
86
91
  }
87
92
  };
@@ -98,10 +103,20 @@ const RemoteAppWrapper = forwardRef(function(props, ref) {
98
103
  ...resProps
99
104
  };
100
105
  renderDom.current = rootRef.current;
101
- const beforeBridgeRenderRes = ((_c = (_b = (_a = instance == null ? void 0 : instance.bridgeHook) == null ? void 0 : _a.lifecycle) == null ? void 0 : _b.beforeBridgeRender) == null ? void 0 : _c.emit(renderProps)) || {};
106
+ const operationContext = {
107
+ side: "consumer",
108
+ framework: "react",
109
+ operation: "render"
110
+ };
111
+ const beforeBridgeRenderRes = ((_c = (_b = (_a = instance == null ? void 0 : instance.bridgeHook) == null ? void 0 : _a.lifecycle) == null ? void 0 : _b.beforeBridgeRender) == null ? void 0 : _c.emit(
112
+ renderProps,
113
+ operationContext
114
+ )) || {};
102
115
  renderProps = { ...renderProps, ...beforeBridgeRenderRes.extraProps };
103
116
  providerInfoRef.current.render(renderProps);
104
- (_f = (_e = (_d = instance == null ? void 0 : instance.bridgeHook) == null ? void 0 : _d.lifecycle) == null ? void 0 : _e.afterBridgeRender) == null ? void 0 : _f.emit(renderProps);
117
+ (_f = (_e = (_d = instance == null ? void 0 : instance.bridgeHook) == null ? void 0 : _d.lifecycle) == null ? void 0 : _e.afterBridgeRender) == null ? void 0 : _f.emit(renderProps, {
118
+ context: operationContext
119
+ });
105
120
  }, [initialized, ...Object.values(props)]);
106
121
  const rootComponentClassName = `${getRootDomDefaultClassName(moduleName)} ${className || ""}`;
107
122
  return /* @__PURE__ */ React__default.createElement("div", { className: rootComponentClassName, style, ref: rootRef }, loading);
@@ -1,5 +1,5 @@
1
1
  "use strict";
2
- const bridgeBase = require("./bridge-base-Ch33UJuN.js");
2
+ const bridgeBase = require("./bridge-base-DSYKAGGD.js");
3
3
  const ReactDOM = require("react-dom");
4
4
  const index = require("./index-DbjGCKOr.js");
5
5
  const React = require("react");
@@ -58,31 +58,36 @@ const RemoteAppWrapper = React.forwardRef(function(props, ref) {
58
58
  providerInfoRef.current = providerReturn;
59
59
  setInitialized(true);
60
60
  return () => {
61
- var _a, _b, _c, _d, _e, _f, _g, _h;
61
+ var _a, _b, _c, _d, _e, _f, _g;
62
62
  if ((_a = providerInfoRef.current) == null ? void 0 : _a.destroy) {
63
63
  index.LoggerInstance.debug(
64
64
  `createRemoteAppComponent LazyComponent destroy >>>`,
65
65
  { moduleName, basename, dom: renderDom.current }
66
66
  );
67
- (_d = (_c = (_b = instance == null ? void 0 : instance.bridgeHook) == null ? void 0 : _b.lifecycle) == null ? void 0 : _c.beforeBridgeDestroy) == null ? void 0 : _d.emit({
67
+ const destroyInfo = {
68
68
  moduleName,
69
69
  dom: renderDom.current,
70
70
  basename,
71
71
  memoryRoute,
72
72
  fallback,
73
73
  ...resProps
74
- });
75
- (_e = providerInfoRef.current) == null ? void 0 : _e.destroy({
74
+ };
75
+ const operationContext = {
76
+ side: "consumer",
77
+ framework: "react",
78
+ operation: "destroy",
79
+ reason: "unmount"
80
+ };
81
+ (_d = (_c = (_b = instance == null ? void 0 : instance.bridgeHook) == null ? void 0 : _b.lifecycle) == null ? void 0 : _c.beforeBridgeDestroy) == null ? void 0 : _d.emit(
82
+ destroyInfo,
83
+ operationContext
84
+ );
85
+ providerInfoRef.current.destroy({
76
86
  moduleName,
77
87
  dom: renderDom.current
78
88
  });
79
- (_h = (_g = (_f = instance == null ? void 0 : instance.bridgeHook) == null ? void 0 : _f.lifecycle) == null ? void 0 : _g.afterBridgeDestroy) == null ? void 0 : _h.emit({
80
- moduleName,
81
- dom: renderDom.current,
82
- basename,
83
- memoryRoute,
84
- fallback,
85
- ...resProps
89
+ (_g = (_f = (_e = instance == null ? void 0 : instance.bridgeHook) == null ? void 0 : _e.lifecycle) == null ? void 0 : _f.afterBridgeDestroy) == null ? void 0 : _g.emit(destroyInfo, {
90
+ context: operationContext
86
91
  });
87
92
  }
88
93
  };
@@ -99,10 +104,20 @@ const RemoteAppWrapper = React.forwardRef(function(props, ref) {
99
104
  ...resProps
100
105
  };
101
106
  renderDom.current = rootRef.current;
102
- const beforeBridgeRenderRes = ((_c = (_b = (_a = instance == null ? void 0 : instance.bridgeHook) == null ? void 0 : _a.lifecycle) == null ? void 0 : _b.beforeBridgeRender) == null ? void 0 : _c.emit(renderProps)) || {};
107
+ const operationContext = {
108
+ side: "consumer",
109
+ framework: "react",
110
+ operation: "render"
111
+ };
112
+ const beforeBridgeRenderRes = ((_c = (_b = (_a = instance == null ? void 0 : instance.bridgeHook) == null ? void 0 : _a.lifecycle) == null ? void 0 : _b.beforeBridgeRender) == null ? void 0 : _c.emit(
113
+ renderProps,
114
+ operationContext
115
+ )) || {};
103
116
  renderProps = { ...renderProps, ...beforeBridgeRenderRes.extraProps };
104
117
  providerInfoRef.current.render(renderProps);
105
- (_f = (_e = (_d = instance == null ? void 0 : instance.bridgeHook) == null ? void 0 : _d.lifecycle) == null ? void 0 : _e.afterBridgeRender) == null ? void 0 : _f.emit(renderProps);
118
+ (_f = (_e = (_d = instance == null ? void 0 : instance.bridgeHook) == null ? void 0 : _d.lifecycle) == null ? void 0 : _e.afterBridgeRender) == null ? void 0 : _f.emit(renderProps, {
119
+ context: operationContext
120
+ });
106
121
  }, [initialized, ...Object.values(props)]);
107
122
  const rootComponentClassName = `${index.getRootDomDefaultClassName(moduleName)} ${className || ""}`;
108
123
  return /* @__PURE__ */ React.createElement("div", { className: rootComponentClassName, style, ref: rootRef }, loading);
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
3
  const lazyUtils = require("./utils-5dGErM3C.js");
4
- const prefetch = require("./prefetch-CfMDdqO-.js");
4
+ const prefetch = require("./prefetch-CMvAw8F3.js");
5
5
  async function callDataFetch() {
6
6
  const dataFetch = globalThis[lazyUtils.DATA_FETCH_FUNCTION];
7
7
  if (dataFetch) {
@@ -1,7 +1,7 @@
1
1
  import { y as DATA_FETCH_FUNCTION } from "./utils-BBP3hEeV.mjs";
2
2
  import { C, a, c, b, d, g, r } from "./utils-BBP3hEeV.mjs";
3
- import { d as dataFetchFunction } from "./prefetch-BJZbf9LF.mjs";
4
- import { i, p } from "./prefetch-BJZbf9LF.mjs";
3
+ import { d as dataFetchFunction } from "./prefetch-xvZIEaJL.mjs";
4
+ import { i, p } from "./prefetch-xvZIEaJL.mjs";
5
5
  async function callDataFetch() {
6
6
  const dataFetch = globalThis[DATA_FETCH_FUNCTION];
7
7
  if (dataFetch) {
@@ -1,9 +1,9 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
- const lazyLoadComponentPlugin = require("./lazy-load-component-plugin-DeTbkGlM.js");
3
+ const lazyLoadComponentPlugin = require("./lazy-load-component-plugin-CRqjWQ5N.js");
4
4
  const lazyUtils = require("./utils-5dGErM3C.js");
5
5
  const dataFetchUtils = require("./data-fetch-utils.cjs.js");
6
- const prefetch = require("./prefetch-CfMDdqO-.js");
6
+ const prefetch = require("./prefetch-CMvAw8F3.js");
7
7
  exports.autoFetchDataPlugin = lazyLoadComponentPlugin.autoFetchData;
8
8
  exports.collectSSRAssets = lazyLoadComponentPlugin.collectSSRAssets;
9
9
  exports.createLazyComponent = lazyLoadComponentPlugin.createLazyComponent;
@@ -1,7 +1,7 @@
1
- import { a, c, b, l } from "./lazy-load-component-plugin-DQFjLSsW.mjs";
1
+ import { a, c, b, l } from "./lazy-load-component-plugin-CyRfqVSE.mjs";
2
2
  import { C, a as a2, E, c as c2, b as b2, d, f, g, r, s } from "./utils-BBP3hEeV.mjs";
3
3
  import { callDataFetch } from "./data-fetch-utils.es.js";
4
- import { p } from "./prefetch-BJZbf9LF.mjs";
4
+ import { p } from "./prefetch-xvZIEaJL.mjs";
5
5
  export {
6
6
  C as CacheSize,
7
7
  a2 as CacheTime,
package/dist/index.cjs.js CHANGED
@@ -1,13 +1,14 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
- const createHelpers = require("./createHelpers-19BP0xtB.js");
4
- const lazyLoadComponentPlugin = require("./lazy-load-component-plugin-DeTbkGlM.js");
3
+ const createHelpers = require("./createHelpers-D6thyyLv.js");
4
+ const lazyLoadComponentPlugin = require("./lazy-load-component-plugin-CRqjWQ5N.js");
5
5
  const lazyUtils = require("./utils-5dGErM3C.js");
6
6
  const dataFetchUtils = require("./data-fetch-utils.cjs.js");
7
7
  const React = require("react");
8
8
  const ReactRouterDOM = require("react-router-dom");
9
9
  const index = require("./index-DbjGCKOr.js");
10
- const prefetch = require("./prefetch-CfMDdqO-.js");
10
+ const plugin = require("./plugin.cjs.js");
11
+ const prefetch = require("./prefetch-CMvAw8F3.js");
11
12
  function _interopNamespaceDefault(e2) {
12
13
  const n = Object.create(null, { [Symbol.toStringTag]: { value: "Module" } });
13
14
  if (e2) {
@@ -81,6 +82,7 @@ function withRouterData(WrappedComponent) {
81
82
  const location = ReactRouterDOM__namespace.useLocation();
82
83
  const [pathname, setPathname] = React.useState(location.pathname);
83
84
  React.useEffect(() => {
85
+ var _a2;
84
86
  if (pathname !== "" && pathname !== location.pathname) {
85
87
  index.LoggerInstance.debug(
86
88
  `createRemoteAppComponent dispatchPopstateEnv >>>`,
@@ -89,7 +91,26 @@ function withRouterData(WrappedComponent) {
89
91
  pathname: location.pathname
90
92
  }
91
93
  );
94
+ const route = {
95
+ action: "host-to-remote",
96
+ mechanism: "popstate",
97
+ from: pathname,
98
+ to: location.pathname,
99
+ basename
100
+ };
101
+ const operationContext = {
102
+ side: "consumer",
103
+ framework: "react",
104
+ operation: "route-sync",
105
+ moduleName: props.moduleName,
106
+ route
107
+ };
92
108
  e();
109
+ (_a2 = plugin.federationRuntime.instance) == null ? void 0 : _a2.bridgeHook.lifecycle.afterBridgeRouteSync.emit(
110
+ {
111
+ context: operationContext
112
+ }
113
+ );
93
114
  }
94
115
  setPathname(location.pathname);
95
116
  }, [location]);
package/dist/index.es.js CHANGED
@@ -1,12 +1,13 @@
1
- import { R as RemoteAppWrapper, c as createRemoteAppComponentFactory, a as createDeprecatedRemoteComponentFactory } from "./createHelpers-BSHeKyd-.mjs";
2
- import { b } from "./createHelpers-BSHeKyd-.mjs";
3
- import { a, c, b as b2, l } from "./lazy-load-component-plugin-DQFjLSsW.mjs";
1
+ import { R as RemoteAppWrapper, c as createRemoteAppComponentFactory, a as createDeprecatedRemoteComponentFactory } from "./createHelpers-D3Sg5lKp.mjs";
2
+ import { b } from "./createHelpers-D3Sg5lKp.mjs";
3
+ import { a, c, b as b2, l } from "./lazy-load-component-plugin-CyRfqVSE.mjs";
4
4
  import { C, a as a2, E, c as c2, b as b3, d, g, r, s } from "./utils-BBP3hEeV.mjs";
5
5
  import { callDataFetch } from "./data-fetch-utils.es.js";
6
6
  import React__default, { forwardRef, useContext, useState, useEffect } from "react";
7
7
  import * as ReactRouterDOM from "react-router-dom";
8
8
  import { p as pathJoin, L as LoggerInstance } from "./index-Bs2NxD2z.mjs";
9
- import { p } from "./prefetch-BJZbf9LF.mjs";
9
+ import { federationRuntime } from "./plugin.es.js";
10
+ import { p } from "./prefetch-xvZIEaJL.mjs";
10
11
  function e() {
11
12
  const t = new PopStateEvent("popstate", { state: window.history.state });
12
13
  window.dispatchEvent(t);
@@ -63,6 +64,7 @@ function withRouterData(WrappedComponent) {
63
64
  const location = ReactRouterDOM.useLocation();
64
65
  const [pathname, setPathname] = useState(location.pathname);
65
66
  useEffect(() => {
67
+ var _a2;
66
68
  if (pathname !== "" && pathname !== location.pathname) {
67
69
  LoggerInstance.debug(
68
70
  `createRemoteAppComponent dispatchPopstateEnv >>>`,
@@ -71,7 +73,26 @@ function withRouterData(WrappedComponent) {
71
73
  pathname: location.pathname
72
74
  }
73
75
  );
76
+ const route = {
77
+ action: "host-to-remote",
78
+ mechanism: "popstate",
79
+ from: pathname,
80
+ to: location.pathname,
81
+ basename
82
+ };
83
+ const operationContext = {
84
+ side: "consumer",
85
+ framework: "react",
86
+ operation: "route-sync",
87
+ moduleName: props.moduleName,
88
+ route
89
+ };
74
90
  e();
91
+ (_a2 = federationRuntime.instance) == null ? void 0 : _a2.bridgeHook.lifecycle.afterBridgeRouteSync.emit(
92
+ {
93
+ context: operationContext
94
+ }
95
+ );
75
96
  }
76
97
  setPathname(location.pathname);
77
98
  }, [location]);
@@ -1,5 +1,5 @@
1
1
  "use strict";
2
- const prefetch = require("./prefetch-CfMDdqO-.js");
2
+ const prefetch = require("./prefetch-CMvAw8F3.js");
3
3
  const lazyUtils = require("./utils-5dGErM3C.js");
4
4
  const React = require("react");
5
5
  const autoFetchData = () => {
@@ -1,4 +1,4 @@
1
- import { i as injectDataFetch, p as prefetch } from "./prefetch-BJZbf9LF.mjs";
1
+ import { i as injectDataFetch, p as prefetch } from "./prefetch-xvZIEaJL.mjs";
2
2
  import { i as initDataFetchMap, k as isDataLoaderExpose, m as getDataFetchInfo, n as getDataFetchMapKey, l as logger, o as getDataFetchItem, p as DATA_FETCH_CLIENT_SUFFIX, q as MF_DATA_FETCH_TYPE, t as isCSROnly, M as MF_DATA_FETCH_STATUS, j as loadDataFetchModule, e as getDataFetchMap, u as isServerEnv, v as getDataFetchIdWithErrorMsgs, w as DATA_FETCH_ERROR_PREFIX, E as ERROR_TYPE, x as wrapDataFetchId, L as LOAD_REMOTE_ERROR_PREFIX, y as DATA_FETCH_FUNCTION, z as getLoadedRemoteInfos, h as fetchData$1, A as setDataFetchItemLoadedStatus, F as FS_HREF } from "./utils-BBP3hEeV.mjs";
3
3
  import React__default, { useRef, useState, useEffect, Suspense } from "react";
4
4
  const autoFetchData = () => {
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: "Module" } });
3
- const lazyLoadComponentPlugin = require("./lazy-load-component-plugin-DeTbkGlM.js");
4
- require("./prefetch-CfMDdqO-.js");
3
+ const lazyLoadComponentPlugin = require("./lazy-load-component-plugin-CRqjWQ5N.js");
4
+ require("./prefetch-CMvAw8F3.js");
5
5
  exports.default = lazyLoadComponentPlugin.lazyLoadComponentPlugin;
6
6
  exports.lazyLoadComponentPlugin = lazyLoadComponentPlugin.lazyLoadComponentPlugin;
@@ -1,5 +1,5 @@
1
- import { l, l as l2 } from "./lazy-load-component-plugin-DQFjLSsW.mjs";
2
- import "./prefetch-BJZbf9LF.mjs";
1
+ import { l, l as l2 } from "./lazy-load-component-plugin-CyRfqVSE.mjs";
2
+ import "./prefetch-xvZIEaJL.mjs";
3
3
  export {
4
4
  l as default,
5
5
  l2 as lazyLoadComponentPlugin
@@ -492,6 +492,7 @@ const processModuleAlias = (name, subPath) => {
492
492
  moduleName = moduleName + subPath;
493
493
  return moduleName;
494
494
  };
495
+ const MAX_PRELOADED_ASSETS = 2e3;
495
496
  const CurrentGlobal = typeof globalThis === "object" ? globalThis : window;
496
497
  const nativeGlobal = (() => {
497
498
  try {
@@ -513,7 +514,7 @@ function includeOwnProperty(target, key) {
513
514
  if (!includeOwnProperty(CurrentGlobal, "__GLOBAL_LOADING_REMOTE_ENTRY__")) definePropertyGlobalVal(CurrentGlobal, "__GLOBAL_LOADING_REMOTE_ENTRY__", {});
514
515
  const globalLoading = CurrentGlobal.__GLOBAL_LOADING_REMOTE_ENTRY__;
515
516
  function setGlobalDefaultVal(target) {
516
- var _a, _b, _c, _d, _e, _f;
517
+ var _a, _b, _c, _d, _e, _f, _g;
517
518
  if (includeOwnProperty(target, "__VMOK__") && !includeOwnProperty(target, "__FEDERATION__")) definePropertyGlobalVal(target, "__FEDERATION__", target.__VMOK__);
518
519
  if (!includeOwnProperty(target, "__FEDERATION__")) {
519
520
  definePropertyGlobalVal(target, "__FEDERATION__", {
@@ -522,7 +523,8 @@ function setGlobalDefaultVal(target) {
522
523
  moduleInfo: {},
523
524
  __SHARE__: {},
524
525
  __MANIFEST_LOADING__: {},
525
- __PRELOADED_MAP__: /* @__PURE__ */ new Map()
526
+ __PRELOADED_MAP__: /* @__PURE__ */ new Map(),
527
+ __PRELOADED_ASSETS__: /* @__PURE__ */ new Set()
526
528
  });
527
529
  definePropertyGlobalVal(target, "__VMOK__", target.__FEDERATION__);
528
530
  }
@@ -532,6 +534,7 @@ function setGlobalDefaultVal(target) {
532
534
  (_d = target.__FEDERATION__).__SHARE__ ?? (_d.__SHARE__ = {});
533
535
  (_e = target.__FEDERATION__).__MANIFEST_LOADING__ ?? (_e.__MANIFEST_LOADING__ = {});
534
536
  (_f = target.__FEDERATION__).__PRELOADED_MAP__ ?? (_f.__PRELOADED_MAP__ = /* @__PURE__ */ new Map());
537
+ (_g = target.__FEDERATION__).__PRELOADED_ASSETS__ ?? (_g.__PRELOADED_ASSETS__ = /* @__PURE__ */ new Set());
535
538
  }
536
539
  setGlobalDefaultVal(CurrentGlobal);
537
540
  setGlobalDefaultVal(nativeGlobal);
@@ -542,6 +545,15 @@ const getRemoteEntryExports = (name, globalName) => {
542
545
  entryExports: CurrentGlobal[remoteEntryKey]
543
546
  };
544
547
  };
548
+ const getPreloadedAsset = (url) => CurrentGlobal.__FEDERATION__.__PRELOADED_ASSETS__.has(url);
549
+ const setPreloadedAsset = (url) => {
550
+ const preloadedAssets = CurrentGlobal.__FEDERATION__.__PRELOADED_ASSETS__;
551
+ preloadedAssets.add(url);
552
+ if (preloadedAssets.size > MAX_PRELOADED_ASSETS) {
553
+ const oldestUrl = preloadedAssets.values().next().value;
554
+ if (oldestUrl !== void 0) preloadedAssets.delete(oldestUrl);
555
+ }
556
+ };
545
557
  const DEFAULT_SCOPE = "default";
546
558
  const DEFAULT_REMOTE_TYPE = "global";
547
559
  function composeRemoteRequestId(remoteName, expose) {
@@ -622,6 +634,7 @@ const runtimeDescMap = {
622
634
  ...runtimeDescMap
623
635
  });
624
636
  const importCallback = ".then(callbacks[0]).catch(callbacks[1])";
637
+ const remoteEntryLoadingOrigins = /* @__PURE__ */ new WeakMap();
625
638
  const esmRemoteEntryLoadErrorMessages = [
626
639
  "Failed to fetch dynamically imported module",
627
640
  "Importing a module script failed",
@@ -773,7 +786,16 @@ function getRemoteEntryUniqueKey(remoteInfo) {
773
786
  async function getRemoteEntry(params) {
774
787
  const { origin, remoteEntryExports, remoteInfo, getEntryUrl, resourceContext, _inErrorHandling = false } = params;
775
788
  const uniqueKey = getRemoteEntryUniqueKey(remoteInfo);
776
- if (remoteEntryExports) return remoteEntryExports;
789
+ if (remoteEntryExports) {
790
+ await origin.loaderHook.lifecycle.afterLoadEntry.emit({
791
+ origin,
792
+ remoteInfo,
793
+ remoteEntryExports,
794
+ resourceContext,
795
+ cached: true
796
+ });
797
+ return remoteEntryExports;
798
+ }
777
799
  if (!globalLoading[uniqueKey]) {
778
800
  const loadEntryHook = origin.remoteHandler.hooks.lifecycle.loadEntry;
779
801
  const loaderHook = origin.loaderHook;
@@ -781,7 +803,8 @@ async function getRemoteEntry(params) {
781
803
  origin,
782
804
  loaderHook,
783
805
  remoteInfo,
784
- remoteEntryExports
806
+ remoteEntryExports,
807
+ resourceContext
785
808
  }).then((res) => {
786
809
  if (res) return res;
787
810
  return (typeof ENV_TARGET !== "undefined" ? ENV_TARGET === "web" : logger.isBrowserEnvValue) ? loadEntryDom({
@@ -799,46 +822,69 @@ async function getRemoteEntry(params) {
799
822
  await origin.loaderHook.lifecycle.afterLoadEntry.emit({
800
823
  origin,
801
824
  remoteInfo,
802
- remoteEntryExports: res
825
+ remoteEntryExports: res,
826
+ resourceContext
803
827
  });
804
828
  return res;
805
- }).catch(async (err) => {
806
- const uniqueKey2 = getRemoteEntryUniqueKey(remoteInfo);
807
- const isScriptExecutionError = err instanceof Error && err.message.includes("ScriptExecutionError");
808
- if (err instanceof Error && err.message.includes(RUNTIME_008) && !isScriptExecutionError && !_inErrorHandling) {
829
+ }).catch(async (loadError) => {
830
+ const isScriptExecutionError = loadError instanceof Error && loadError.message.includes("ScriptExecutionError");
831
+ if (loadError instanceof Error && loadError.message.includes(RUNTIME_008) && !isScriptExecutionError && !_inErrorHandling) {
809
832
  const wrappedGetRemoteEntry = (params2) => {
810
833
  return getRemoteEntry({
811
834
  ...params2,
812
835
  _inErrorHandling: true
813
836
  });
814
837
  };
815
- const RemoteEntryExports = await origin.loaderHook.lifecycle.loadEntryError.emit({
838
+ const recoveredRemoteEntryExports = await origin.loaderHook.lifecycle.loadEntryError.emit({
816
839
  getRemoteEntry: wrappedGetRemoteEntry,
817
840
  origin,
818
841
  remoteInfo,
819
842
  remoteEntryExports,
820
843
  globalLoading,
821
- uniqueKey: uniqueKey2
844
+ uniqueKey
822
845
  });
823
- if (RemoteEntryExports) {
846
+ if (recoveredRemoteEntryExports) {
824
847
  await origin.loaderHook.lifecycle.afterLoadEntry.emit({
825
848
  origin,
826
849
  remoteInfo,
827
- remoteEntryExports: RemoteEntryExports,
850
+ remoteEntryExports: recoveredRemoteEntryExports,
851
+ resourceContext,
852
+ error: loadError,
828
853
  recovered: true
829
854
  });
830
- return RemoteEntryExports;
855
+ return recoveredRemoteEntryExports;
831
856
  }
832
857
  }
833
858
  await origin.loaderHook.lifecycle.afterLoadEntry.emit({
834
859
  origin,
835
860
  remoteInfo,
836
- error: err
861
+ resourceContext,
862
+ error: loadError
837
863
  });
838
- throw err;
864
+ throw loadError;
839
865
  });
866
+ remoteEntryLoadingOrigins.set(globalLoading[uniqueKey], origin);
840
867
  }
841
- return globalLoading[uniqueKey];
868
+ const remoteEntryLoading = globalLoading[uniqueKey];
869
+ if (remoteEntryLoadingOrigins.get(remoteEntryLoading) !== origin) try {
870
+ const result = await remoteEntryLoading;
871
+ await origin.loaderHook.lifecycle.afterLoadEntry.emit({
872
+ origin,
873
+ remoteInfo,
874
+ remoteEntryExports: result,
875
+ resourceContext
876
+ });
877
+ return result;
878
+ } catch (loadError) {
879
+ await origin.loaderHook.lifecycle.afterLoadEntry.emit({
880
+ origin,
881
+ remoteInfo,
882
+ resourceContext,
883
+ error: loadError
884
+ });
885
+ throw loadError;
886
+ }
887
+ return remoteEntryLoading;
842
888
  }
843
889
  function getRemoteInfo(remote) {
844
890
  return {
@@ -899,6 +945,12 @@ function createAssetResult(context, url, status, error2) {
899
945
  error: error2
900
946
  };
901
947
  }
948
+ function preloadAssetOnce(context, url, recordPreloadedAssets, preload) {
949
+ if (!recordPreloadedAssets) return preload();
950
+ if (getPreloadedAsset(url)) return Promise.resolve(createAssetResult(context, url, "cached"));
951
+ setPreloadedAsset(url);
952
+ return preload();
953
+ }
902
954
  async function waitForRemoteEntryPreload(host, remoteInfo, entryRemoteInfo, context) {
903
955
  const cachedRemote = host.moduleCache.get(entryRemoteInfo.name);
904
956
  const url = entryRemoteInfo.entry;
@@ -985,7 +1037,7 @@ function createResourceContext(baseContext, resourceType) {
985
1037
  function preloadAssets(remoteInfo, host, assets, useLinkPreload = true, baseContext = {
986
1038
  initiator: "preloadRemote",
987
1039
  id: remoteInfo.name
988
- }) {
1040
+ }, recordPreloadedAssets = true) {
989
1041
  const { cssAssets, jsAssetsWithoutEntry, entryAssets } = assets;
990
1042
  const results = [];
991
1043
  if (host.options.inBrowser) {
@@ -999,13 +1051,14 @@ function preloadAssets(remoteInfo, host, assets, useLinkPreload = true, baseCont
999
1051
  as: "style"
1000
1052
  };
1001
1053
  cssAssets.forEach((cssUrl) => {
1002
- results.push(waitForLinkPreload({
1054
+ const context = createResourceContext(baseContext, "css");
1055
+ results.push(preloadAssetOnce(context, cssUrl, recordPreloadedAssets, () => waitForLinkPreload({
1003
1056
  host,
1004
1057
  remoteInfo,
1005
1058
  url: cssUrl,
1006
1059
  attrs: defaultAttrs2,
1007
- context: createResourceContext(baseContext, "css")
1008
- }));
1060
+ context
1061
+ })));
1009
1062
  });
1010
1063
  } else {
1011
1064
  const defaultAttrs2 = {
@@ -1013,14 +1066,15 @@ function preloadAssets(remoteInfo, host, assets, useLinkPreload = true, baseCont
1013
1066
  type: "text/css"
1014
1067
  };
1015
1068
  cssAssets.forEach((cssUrl) => {
1016
- results.push(waitForLinkPreload({
1069
+ const context = createResourceContext(baseContext, "css");
1070
+ results.push(preloadAssetOnce(context, cssUrl, recordPreloadedAssets, () => waitForLinkPreload({
1017
1071
  host,
1018
1072
  remoteInfo,
1019
1073
  url: cssUrl,
1020
1074
  attrs: defaultAttrs2,
1021
1075
  needDeleteLink: false,
1022
- context: createResourceContext(baseContext, "css")
1023
- }));
1076
+ context
1077
+ })));
1024
1078
  });
1025
1079
  }
1026
1080
  let preloadJsAsset = waitForScriptPreload;
@@ -1042,13 +1096,14 @@ function preloadAssets(remoteInfo, host, assets, useLinkPreload = true, baseCont
1042
1096
  };
1043
1097
  }
1044
1098
  jsAssetsWithoutEntry.forEach((jsUrl) => {
1045
- results.push(preloadJsAsset({
1099
+ const context = createResourceContext(baseContext, "js");
1100
+ results.push(preloadAssetOnce(context, jsUrl, recordPreloadedAssets, () => preloadJsAsset({
1046
1101
  host,
1047
1102
  remoteInfo,
1048
1103
  url: jsUrl,
1049
1104
  attrs: defaultAttrs,
1050
- context: createResourceContext(baseContext, "js")
1051
- }));
1105
+ context
1106
+ })));
1052
1107
  });
1053
1108
  }
1054
1109
  return Promise.all(results);
@@ -1094,25 +1149,27 @@ var Module$1 = class {
1094
1149
  this.remoteInfo = remoteInfo;
1095
1150
  this.host = host;
1096
1151
  }
1097
- async getEntry(expose) {
1098
- if (this.remoteEntryExports) return this.remoteEntryExports;
1152
+ async getEntry(expose, resourceContext) {
1153
+ const effectiveResourceContext = resourceContext || {
1154
+ initiator: "loadRemote",
1155
+ id: composeRemoteRequestId(this.remoteInfo.name, expose),
1156
+ resourceType: "remoteEntry",
1157
+ url: this.remoteInfo.entry,
1158
+ expose
1159
+ };
1099
1160
  const remoteEntryExports = await getRemoteEntry({
1100
1161
  origin: this.host,
1101
1162
  remoteInfo: this.remoteInfo,
1102
1163
  remoteEntryExports: this.remoteEntryExports,
1103
- resourceContext: {
1104
- initiator: "loadRemote",
1105
- id: composeRemoteRequestId(this.remoteInfo.name, expose),
1106
- resourceType: "remoteEntry"
1107
- }
1164
+ resourceContext: effectiveResourceContext
1108
1165
  });
1109
1166
  assert(remoteEntryExports, `remoteEntryExports is undefined
1110
1167
  ${lazyUtils.safeToString(this.remoteInfo)}`);
1111
1168
  this.remoteEntryExports = remoteEntryExports;
1112
1169
  return this.remoteEntryExports;
1113
1170
  }
1114
- async init(id, remoteSnapshot, rawInitScope, expose) {
1115
- const remoteEntryExports = await this.getEntry(expose);
1171
+ async init(id, remoteSnapshot, rawInitScope, expose, resourceContext) {
1172
+ const remoteEntryExports = await this.getEntry(expose, resourceContext);
1116
1173
  if (this.inited) {
1117
1174
  await this.host.loaderHook.lifecycle.afterInitRemote.emit({
1118
1175
  id,
@@ -491,6 +491,7 @@ const processModuleAlias = (name, subPath) => {
491
491
  moduleName = moduleName + subPath;
492
492
  return moduleName;
493
493
  };
494
+ const MAX_PRELOADED_ASSETS = 2e3;
494
495
  const CurrentGlobal = typeof globalThis === "object" ? globalThis : window;
495
496
  const nativeGlobal = (() => {
496
497
  try {
@@ -512,7 +513,7 @@ function includeOwnProperty(target, key) {
512
513
  if (!includeOwnProperty(CurrentGlobal, "__GLOBAL_LOADING_REMOTE_ENTRY__")) definePropertyGlobalVal(CurrentGlobal, "__GLOBAL_LOADING_REMOTE_ENTRY__", {});
513
514
  const globalLoading = CurrentGlobal.__GLOBAL_LOADING_REMOTE_ENTRY__;
514
515
  function setGlobalDefaultVal(target) {
515
- var _a, _b, _c, _d, _e, _f;
516
+ var _a, _b, _c, _d, _e, _f, _g;
516
517
  if (includeOwnProperty(target, "__VMOK__") && !includeOwnProperty(target, "__FEDERATION__")) definePropertyGlobalVal(target, "__FEDERATION__", target.__VMOK__);
517
518
  if (!includeOwnProperty(target, "__FEDERATION__")) {
518
519
  definePropertyGlobalVal(target, "__FEDERATION__", {
@@ -521,7 +522,8 @@ function setGlobalDefaultVal(target) {
521
522
  moduleInfo: {},
522
523
  __SHARE__: {},
523
524
  __MANIFEST_LOADING__: {},
524
- __PRELOADED_MAP__: /* @__PURE__ */ new Map()
525
+ __PRELOADED_MAP__: /* @__PURE__ */ new Map(),
526
+ __PRELOADED_ASSETS__: /* @__PURE__ */ new Set()
525
527
  });
526
528
  definePropertyGlobalVal(target, "__VMOK__", target.__FEDERATION__);
527
529
  }
@@ -531,6 +533,7 @@ function setGlobalDefaultVal(target) {
531
533
  (_d = target.__FEDERATION__).__SHARE__ ?? (_d.__SHARE__ = {});
532
534
  (_e = target.__FEDERATION__).__MANIFEST_LOADING__ ?? (_e.__MANIFEST_LOADING__ = {});
533
535
  (_f = target.__FEDERATION__).__PRELOADED_MAP__ ?? (_f.__PRELOADED_MAP__ = /* @__PURE__ */ new Map());
536
+ (_g = target.__FEDERATION__).__PRELOADED_ASSETS__ ?? (_g.__PRELOADED_ASSETS__ = /* @__PURE__ */ new Set());
534
537
  }
535
538
  setGlobalDefaultVal(CurrentGlobal);
536
539
  setGlobalDefaultVal(nativeGlobal);
@@ -541,6 +544,15 @@ const getRemoteEntryExports = (name, globalName) => {
541
544
  entryExports: CurrentGlobal[remoteEntryKey]
542
545
  };
543
546
  };
547
+ const getPreloadedAsset = (url) => CurrentGlobal.__FEDERATION__.__PRELOADED_ASSETS__.has(url);
548
+ const setPreloadedAsset = (url) => {
549
+ const preloadedAssets = CurrentGlobal.__FEDERATION__.__PRELOADED_ASSETS__;
550
+ preloadedAssets.add(url);
551
+ if (preloadedAssets.size > MAX_PRELOADED_ASSETS) {
552
+ const oldestUrl = preloadedAssets.values().next().value;
553
+ if (oldestUrl !== void 0) preloadedAssets.delete(oldestUrl);
554
+ }
555
+ };
544
556
  const DEFAULT_SCOPE = "default";
545
557
  const DEFAULT_REMOTE_TYPE = "global";
546
558
  function composeRemoteRequestId(remoteName, expose) {
@@ -621,6 +633,7 @@ const runtimeDescMap = {
621
633
  ...runtimeDescMap
622
634
  });
623
635
  const importCallback = ".then(callbacks[0]).catch(callbacks[1])";
636
+ const remoteEntryLoadingOrigins = /* @__PURE__ */ new WeakMap();
624
637
  const esmRemoteEntryLoadErrorMessages = [
625
638
  "Failed to fetch dynamically imported module",
626
639
  "Importing a module script failed",
@@ -772,7 +785,16 @@ function getRemoteEntryUniqueKey(remoteInfo) {
772
785
  async function getRemoteEntry(params) {
773
786
  const { origin, remoteEntryExports, remoteInfo, getEntryUrl, resourceContext, _inErrorHandling = false } = params;
774
787
  const uniqueKey = getRemoteEntryUniqueKey(remoteInfo);
775
- if (remoteEntryExports) return remoteEntryExports;
788
+ if (remoteEntryExports) {
789
+ await origin.loaderHook.lifecycle.afterLoadEntry.emit({
790
+ origin,
791
+ remoteInfo,
792
+ remoteEntryExports,
793
+ resourceContext,
794
+ cached: true
795
+ });
796
+ return remoteEntryExports;
797
+ }
776
798
  if (!globalLoading[uniqueKey]) {
777
799
  const loadEntryHook = origin.remoteHandler.hooks.lifecycle.loadEntry;
778
800
  const loaderHook = origin.loaderHook;
@@ -780,7 +802,8 @@ async function getRemoteEntry(params) {
780
802
  origin,
781
803
  loaderHook,
782
804
  remoteInfo,
783
- remoteEntryExports
805
+ remoteEntryExports,
806
+ resourceContext
784
807
  }).then((res) => {
785
808
  if (res) return res;
786
809
  return (typeof ENV_TARGET !== "undefined" ? ENV_TARGET === "web" : isBrowserEnvValue) ? loadEntryDom({
@@ -798,46 +821,69 @@ async function getRemoteEntry(params) {
798
821
  await origin.loaderHook.lifecycle.afterLoadEntry.emit({
799
822
  origin,
800
823
  remoteInfo,
801
- remoteEntryExports: res
824
+ remoteEntryExports: res,
825
+ resourceContext
802
826
  });
803
827
  return res;
804
- }).catch(async (err) => {
805
- const uniqueKey2 = getRemoteEntryUniqueKey(remoteInfo);
806
- const isScriptExecutionError = err instanceof Error && err.message.includes("ScriptExecutionError");
807
- if (err instanceof Error && err.message.includes(RUNTIME_008) && !isScriptExecutionError && !_inErrorHandling) {
828
+ }).catch(async (loadError) => {
829
+ const isScriptExecutionError = loadError instanceof Error && loadError.message.includes("ScriptExecutionError");
830
+ if (loadError instanceof Error && loadError.message.includes(RUNTIME_008) && !isScriptExecutionError && !_inErrorHandling) {
808
831
  const wrappedGetRemoteEntry = (params2) => {
809
832
  return getRemoteEntry({
810
833
  ...params2,
811
834
  _inErrorHandling: true
812
835
  });
813
836
  };
814
- const RemoteEntryExports = await origin.loaderHook.lifecycle.loadEntryError.emit({
837
+ const recoveredRemoteEntryExports = await origin.loaderHook.lifecycle.loadEntryError.emit({
815
838
  getRemoteEntry: wrappedGetRemoteEntry,
816
839
  origin,
817
840
  remoteInfo,
818
841
  remoteEntryExports,
819
842
  globalLoading,
820
- uniqueKey: uniqueKey2
843
+ uniqueKey
821
844
  });
822
- if (RemoteEntryExports) {
845
+ if (recoveredRemoteEntryExports) {
823
846
  await origin.loaderHook.lifecycle.afterLoadEntry.emit({
824
847
  origin,
825
848
  remoteInfo,
826
- remoteEntryExports: RemoteEntryExports,
849
+ remoteEntryExports: recoveredRemoteEntryExports,
850
+ resourceContext,
851
+ error: loadError,
827
852
  recovered: true
828
853
  });
829
- return RemoteEntryExports;
854
+ return recoveredRemoteEntryExports;
830
855
  }
831
856
  }
832
857
  await origin.loaderHook.lifecycle.afterLoadEntry.emit({
833
858
  origin,
834
859
  remoteInfo,
835
- error: err
860
+ resourceContext,
861
+ error: loadError
836
862
  });
837
- throw err;
863
+ throw loadError;
838
864
  });
865
+ remoteEntryLoadingOrigins.set(globalLoading[uniqueKey], origin);
839
866
  }
840
- return globalLoading[uniqueKey];
867
+ const remoteEntryLoading = globalLoading[uniqueKey];
868
+ if (remoteEntryLoadingOrigins.get(remoteEntryLoading) !== origin) try {
869
+ const result = await remoteEntryLoading;
870
+ await origin.loaderHook.lifecycle.afterLoadEntry.emit({
871
+ origin,
872
+ remoteInfo,
873
+ remoteEntryExports: result,
874
+ resourceContext
875
+ });
876
+ return result;
877
+ } catch (loadError) {
878
+ await origin.loaderHook.lifecycle.afterLoadEntry.emit({
879
+ origin,
880
+ remoteInfo,
881
+ resourceContext,
882
+ error: loadError
883
+ });
884
+ throw loadError;
885
+ }
886
+ return remoteEntryLoading;
841
887
  }
842
888
  function getRemoteInfo(remote) {
843
889
  return {
@@ -898,6 +944,12 @@ function createAssetResult(context, url, status, error2) {
898
944
  error: error2
899
945
  };
900
946
  }
947
+ function preloadAssetOnce(context, url, recordPreloadedAssets, preload) {
948
+ if (!recordPreloadedAssets) return preload();
949
+ if (getPreloadedAsset(url)) return Promise.resolve(createAssetResult(context, url, "cached"));
950
+ setPreloadedAsset(url);
951
+ return preload();
952
+ }
901
953
  async function waitForRemoteEntryPreload(host, remoteInfo, entryRemoteInfo, context) {
902
954
  const cachedRemote = host.moduleCache.get(entryRemoteInfo.name);
903
955
  const url = entryRemoteInfo.entry;
@@ -984,7 +1036,7 @@ function createResourceContext(baseContext, resourceType) {
984
1036
  function preloadAssets(remoteInfo, host, assets, useLinkPreload = true, baseContext = {
985
1037
  initiator: "preloadRemote",
986
1038
  id: remoteInfo.name
987
- }) {
1039
+ }, recordPreloadedAssets = true) {
988
1040
  const { cssAssets, jsAssetsWithoutEntry, entryAssets } = assets;
989
1041
  const results = [];
990
1042
  if (host.options.inBrowser) {
@@ -998,13 +1050,14 @@ function preloadAssets(remoteInfo, host, assets, useLinkPreload = true, baseCont
998
1050
  as: "style"
999
1051
  };
1000
1052
  cssAssets.forEach((cssUrl) => {
1001
- results.push(waitForLinkPreload({
1053
+ const context = createResourceContext(baseContext, "css");
1054
+ results.push(preloadAssetOnce(context, cssUrl, recordPreloadedAssets, () => waitForLinkPreload({
1002
1055
  host,
1003
1056
  remoteInfo,
1004
1057
  url: cssUrl,
1005
1058
  attrs: defaultAttrs2,
1006
- context: createResourceContext(baseContext, "css")
1007
- }));
1059
+ context
1060
+ })));
1008
1061
  });
1009
1062
  } else {
1010
1063
  const defaultAttrs2 = {
@@ -1012,14 +1065,15 @@ function preloadAssets(remoteInfo, host, assets, useLinkPreload = true, baseCont
1012
1065
  type: "text/css"
1013
1066
  };
1014
1067
  cssAssets.forEach((cssUrl) => {
1015
- results.push(waitForLinkPreload({
1068
+ const context = createResourceContext(baseContext, "css");
1069
+ results.push(preloadAssetOnce(context, cssUrl, recordPreloadedAssets, () => waitForLinkPreload({
1016
1070
  host,
1017
1071
  remoteInfo,
1018
1072
  url: cssUrl,
1019
1073
  attrs: defaultAttrs2,
1020
1074
  needDeleteLink: false,
1021
- context: createResourceContext(baseContext, "css")
1022
- }));
1075
+ context
1076
+ })));
1023
1077
  });
1024
1078
  }
1025
1079
  let preloadJsAsset = waitForScriptPreload;
@@ -1041,13 +1095,14 @@ function preloadAssets(remoteInfo, host, assets, useLinkPreload = true, baseCont
1041
1095
  };
1042
1096
  }
1043
1097
  jsAssetsWithoutEntry.forEach((jsUrl) => {
1044
- results.push(preloadJsAsset({
1098
+ const context = createResourceContext(baseContext, "js");
1099
+ results.push(preloadAssetOnce(context, jsUrl, recordPreloadedAssets, () => preloadJsAsset({
1045
1100
  host,
1046
1101
  remoteInfo,
1047
1102
  url: jsUrl,
1048
1103
  attrs: defaultAttrs,
1049
- context: createResourceContext(baseContext, "js")
1050
- }));
1104
+ context
1105
+ })));
1051
1106
  });
1052
1107
  }
1053
1108
  return Promise.all(results);
@@ -1093,25 +1148,27 @@ var Module$1 = class {
1093
1148
  this.remoteInfo = remoteInfo;
1094
1149
  this.host = host;
1095
1150
  }
1096
- async getEntry(expose) {
1097
- if (this.remoteEntryExports) return this.remoteEntryExports;
1151
+ async getEntry(expose, resourceContext) {
1152
+ const effectiveResourceContext = resourceContext || {
1153
+ initiator: "loadRemote",
1154
+ id: composeRemoteRequestId(this.remoteInfo.name, expose),
1155
+ resourceType: "remoteEntry",
1156
+ url: this.remoteInfo.entry,
1157
+ expose
1158
+ };
1098
1159
  const remoteEntryExports = await getRemoteEntry({
1099
1160
  origin: this.host,
1100
1161
  remoteInfo: this.remoteInfo,
1101
1162
  remoteEntryExports: this.remoteEntryExports,
1102
- resourceContext: {
1103
- initiator: "loadRemote",
1104
- id: composeRemoteRequestId(this.remoteInfo.name, expose),
1105
- resourceType: "remoteEntry"
1106
- }
1163
+ resourceContext: effectiveResourceContext
1107
1164
  });
1108
1165
  assert(remoteEntryExports, `remoteEntryExports is undefined
1109
1166
  ${safeToString(this.remoteInfo)}`);
1110
1167
  this.remoteEntryExports = remoteEntryExports;
1111
1168
  return this.remoteEntryExports;
1112
1169
  }
1113
- async init(id, remoteSnapshot, rawInitScope, expose) {
1114
- const remoteEntryExports = await this.getEntry(expose);
1170
+ async init(id, remoteSnapshot, rawInitScope, expose, resourceContext) {
1171
+ const remoteEntryExports = await this.getEntry(expose, resourceContext);
1115
1172
  if (this.inited) {
1116
1173
  await this.host.loaderHook.lifecycle.afterInitRemote.emit({
1117
1174
  id,
package/dist/v18.cjs.js CHANGED
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
3
  const client = require("react-dom/client");
4
- const bridgeBase = require("./bridge-base-Ch33UJuN.js");
4
+ const bridgeBase = require("./bridge-base-DSYKAGGD.js");
5
5
  function createReact18Root(container, options) {
6
6
  return client.createRoot(container, options);
7
7
  }
package/dist/v18.es.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import { createRoot } from "react-dom/client";
2
- import { c as createBaseBridgeComponent } from "./bridge-base-BaKy6CY_.mjs";
2
+ import { c as createBaseBridgeComponent } from "./bridge-base-CHnL6Q9P.mjs";
3
3
  function createReact18Root(container, options) {
4
4
  return createRoot(container, options);
5
5
  }
package/dist/v19.cjs.js CHANGED
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
3
  const client = require("react-dom/client");
4
- const bridgeBase = require("./bridge-base-Ch33UJuN.js");
4
+ const bridgeBase = require("./bridge-base-DSYKAGGD.js");
5
5
  function createReact19Root(container, options) {
6
6
  return client.createRoot(container, options);
7
7
  }
package/dist/v19.es.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import { createRoot } from "react-dom/client";
2
- import { c as createBaseBridgeComponent } from "./bridge-base-BaKy6CY_.mjs";
2
+ import { c as createBaseBridgeComponent } from "./bridge-base-CHnL6Q9P.mjs";
3
3
  function createReact19Root(container, options) {
4
4
  return createRoot(container, options);
5
5
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@module-federation/bridge-react",
3
- "version": "2.8.2",
3
+ "version": "2.9.0",
4
4
  "sideEffects": false,
5
5
  "publishConfig": {
6
6
  "access": "public"
@@ -147,7 +147,7 @@
147
147
  }
148
148
  },
149
149
  "dependencies": {
150
- "@module-federation/sdk": "2.8.2"
150
+ "@module-federation/sdk": "2.9.0"
151
151
  },
152
152
  "peerDependencies": {
153
153
  "react": ">=16.9.0",
@@ -175,13 +175,13 @@
175
175
  "react": "18.3.1",
176
176
  "react-dom": "18.3.1",
177
177
  "react-router-dom": "6.30.3",
178
- "react-router": "7.16.0",
178
+ "react-router": "7.18.2",
179
179
  "typescript": "7.0.2",
180
180
  "vite": "^5.4.21",
181
- "hono": "4.12.26",
182
- "@module-federation/runtime": "2.8.2",
183
- "@module-federation/bridge-shared": "2.8.2",
184
- "@module-federation/runtime-core": "2.8.2"
181
+ "hono": "4.13.1",
182
+ "@module-federation/bridge-shared": "2.9.0",
183
+ "@module-federation/runtime": "2.9.0",
184
+ "@module-federation/runtime-core": "2.9.0"
185
185
  },
186
186
  "scripts": {
187
187
  "dev": "vite",