@module-federation/devtools 0.0.0-fix-capture-timeout-20260324112210 → 0.0.0-fix-valid-same-id-20260429034727

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.
@@ -0,0 +1,124 @@
1
+ const FUNCTION_PLACEHOLDER = "function(){}";
2
+ const UNDEFINED_PLACEHOLDER = "[undefined]";
3
+ const CIRCULAR_PLACEHOLDER = "[circular]";
4
+ const NON_SERIALIZABLE_PLACEHOLDER = "[unserializable]";
5
+ const toStringTag = (value) => Object.prototype.toString.call(value).slice(8, -1);
6
+ const isPlainObject = (value) => {
7
+ if (!value || typeof value !== "object") {
8
+ return false;
9
+ }
10
+ const proto = Object.getPrototypeOf(value);
11
+ return proto === Object.prototype || proto === null;
12
+ };
13
+ const sanitizeValue = (value, seen) => {
14
+ if (value === null || typeof value === "string" || typeof value === "number") {
15
+ return Number.isNaN(value) ? "[NaN]" : value;
16
+ }
17
+ if (typeof value === "boolean") {
18
+ return value;
19
+ }
20
+ if (typeof value === "function") {
21
+ return FUNCTION_PLACEHOLDER;
22
+ }
23
+ if (typeof value === "undefined") {
24
+ return UNDEFINED_PLACEHOLDER;
25
+ }
26
+ if (typeof value === "bigint" || typeof value === "symbol") {
27
+ return String(value);
28
+ }
29
+ if (!(value instanceof Object)) {
30
+ return NON_SERIALIZABLE_PLACEHOLDER;
31
+ }
32
+ if (seen.has(value)) {
33
+ return CIRCULAR_PLACEHOLDER;
34
+ }
35
+ if (Array.isArray(value)) {
36
+ const next2 = [];
37
+ seen.set(value, next2);
38
+ value.forEach((item, index) => {
39
+ next2[index] = sanitizeValue(item, seen);
40
+ });
41
+ return next2;
42
+ }
43
+ if (value instanceof Date) {
44
+ return value.toISOString();
45
+ }
46
+ if (value instanceof RegExp) {
47
+ return value.toString();
48
+ }
49
+ if (value instanceof Error) {
50
+ const next2 = {
51
+ name: value.name,
52
+ message: value.message,
53
+ stack: value.stack || ""
54
+ };
55
+ seen.set(value, next2);
56
+ return next2;
57
+ }
58
+ if (value instanceof Map) {
59
+ const next2 = [];
60
+ seen.set(value, next2);
61
+ next2.push(
62
+ ...Array.from(value.entries()).map(([key, item]) => [
63
+ sanitizeValue(key, seen),
64
+ sanitizeValue(item, seen)
65
+ ])
66
+ );
67
+ return next2;
68
+ }
69
+ if (value instanceof Set) {
70
+ const next2 = [];
71
+ seen.set(value, next2);
72
+ next2.push(
73
+ ...Array.from(value.values()).map((item) => sanitizeValue(item, seen))
74
+ );
75
+ return next2;
76
+ }
77
+ if (ArrayBuffer.isView(value)) {
78
+ return Array.from(new Uint8Array(value.buffer));
79
+ }
80
+ if (value instanceof ArrayBuffer) {
81
+ return Array.from(new Uint8Array(value));
82
+ }
83
+ if (typeof Node !== "undefined" && value instanceof Node) {
84
+ return `[${toStringTag(value)}]`;
85
+ }
86
+ if (typeof Window !== "undefined" && value instanceof Window) {
87
+ return "[Window]";
88
+ }
89
+ if (typeof Document !== "undefined" && value instanceof Document) {
90
+ return "[Document]";
91
+ }
92
+ const next = {};
93
+ seen.set(value, next);
94
+ const entries = isPlainObject(value) ? Object.keys(value).map((key) => {
95
+ try {
96
+ return [key, value[key]];
97
+ } catch (_error) {
98
+ return [key, NON_SERIALIZABLE_PLACEHOLDER];
99
+ }
100
+ }) : Reflect.ownKeys(value).map((key) => {
101
+ try {
102
+ return [
103
+ String(key),
104
+ value[key]
105
+ ];
106
+ } catch (_error) {
107
+ return [String(key), NON_SERIALIZABLE_PLACEHOLDER];
108
+ }
109
+ });
110
+ entries.forEach(([key, item]) => {
111
+ try {
112
+ next[key] = sanitizeValue(item, seen);
113
+ } catch (_error) {
114
+ next[key] = NON_SERIALIZABLE_PLACEHOLDER;
115
+ }
116
+ });
117
+ return next;
118
+ };
119
+ const sanitizePostMessagePayload = (payload) => {
120
+ return sanitizeValue(payload, /* @__PURE__ */ new WeakMap());
121
+ };
122
+ export {
123
+ sanitizePostMessagePayload
124
+ };
@@ -1,32 +1,4 @@
1
1
  "use strict";
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropSymbols = Object.getOwnPropertySymbols;
4
- var __hasOwnProp = Object.prototype.hasOwnProperty;
5
- var __propIsEnum = Object.prototype.propertyIsEnumerable;
6
- var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
7
- var __spreadValues = (a, b) => {
8
- for (var prop in b || (b = {}))
9
- if (__hasOwnProp.call(b, prop))
10
- __defNormalProp(a, prop, b[prop]);
11
- if (__getOwnPropSymbols)
12
- for (var prop of __getOwnPropSymbols(b)) {
13
- if (__propIsEnum.call(b, prop))
14
- __defNormalProp(a, prop, b[prop]);
15
- }
16
- return a;
17
- };
18
- var __objRest = (source, exclude) => {
19
- var target = {};
20
- for (var prop in source)
21
- if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
22
- target[prop] = source[prop];
23
- if (source != null && __getOwnPropSymbols)
24
- for (var prop of __getOwnPropSymbols(source)) {
25
- if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
26
- target[prop] = source[prop];
27
- }
28
- return target;
29
- };
30
2
  var __async = (__this, __arguments, generator) => {
31
3
  return new Promise((resolve, reject) => {
32
4
  var fulfilled = (value) => {
@@ -47,31 +19,176 @@ var __async = (__this, __arguments, generator) => {
47
19
  step((generator = generator.apply(__this, __arguments)).next());
48
20
  });
49
21
  };
50
- var import_sdk = require("@module-federation/sdk");
51
22
  var import__ = require("../index");
52
- var import_sdk2 = require("../sdk");
23
+ var import_sdk = require("../sdk");
53
24
  var import_constant = require("../../template/constant");
54
25
  var _a;
55
26
  const SUPPORT_PKGS = ["react", "react-dom"];
56
- const fetchAndExecuteUmdSync = (url) => {
27
+ const DEFAULT_SHARE_SCOPE = "default";
28
+ const DEFAULT_GLOBAL_KEY_MAP = {
29
+ react: "React",
30
+ "react-dom": "ReactDOM"
31
+ };
32
+ const sanitizeWindowKey = (value) => value.replace(/[^a-zA-Z0-9_$]/g, "_");
33
+ const getShareScopes = (scope) => Array.isArray(scope) && scope.length ? scope : [DEFAULT_SHARE_SCOPE];
34
+ const getDefaultGlobalKey = (pkgName) => DEFAULT_GLOBAL_KEY_MAP[pkgName];
35
+ const getScopedGlobalKey = (scope, pkgName) => `${sanitizeWindowKey(scope)}_${sanitizeWindowKey(pkgName)}`;
36
+ const getWindowValue = (key) => window[key];
37
+ const setWindowValue = (key, value) => {
38
+ window[key] = value;
39
+ };
40
+ const setScopeGlobals = (pkgName, scopes, source) => {
41
+ if (!source) {
42
+ return source;
43
+ }
44
+ scopes.forEach((scope) => {
45
+ setWindowValue(getScopedGlobalKey(scope, pkgName), source);
46
+ });
47
+ return source;
48
+ };
49
+ const getScopeGlobal = (pkgName, scopes) => {
50
+ for (const scope of scopes) {
51
+ const scopeGlobal = getWindowValue(getScopedGlobalKey(scope, pkgName));
52
+ if (scopeGlobal) {
53
+ return scopeGlobal;
54
+ }
55
+ }
56
+ return void 0;
57
+ };
58
+ const getEagerShareInfo = (eagerShare) => {
59
+ if (!Array.isArray(eagerShare) || eagerShare.length < 2) {
60
+ return null;
61
+ }
62
+ const [, version, scopes] = eagerShare;
63
+ if (typeof version !== "string") {
64
+ return null;
65
+ }
66
+ return {
67
+ version,
68
+ scopes: getShareScopes(scopes)
69
+ };
70
+ };
71
+ const updateEagerShareInfo = (devtoolsMessage2, pkgName, version, scopes) => {
72
+ const existing = getEagerShareInfo(devtoolsMessage2[import_constant.__EAGER_SHARE__]);
73
+ const mergedScopes = Array.from(
74
+ /* @__PURE__ */ new Set([...(existing == null ? void 0 : existing.scopes) || [], ...scopes])
75
+ );
76
+ devtoolsMessage2[import_constant.__EAGER_SHARE__] = [pkgName, version, mergedScopes];
77
+ return {
78
+ shouldReload: !existing || existing.version !== version
79
+ };
80
+ };
81
+ const requestUmdSourceSync = (url) => {
57
82
  try {
58
83
  const response = new XMLHttpRequest();
59
84
  response.open("GET", url, false);
60
85
  response.overrideMimeType("text/plain");
61
86
  response.send();
62
87
  if (response.status === 200) {
63
- const scriptContent = response.responseText;
64
- const moduleFunction = new Function(scriptContent);
65
- return moduleFunction(window);
66
- } else {
67
- throw new Error(
68
- `Failed to load module from ${url}: HTTP ${response.status}`
69
- );
88
+ return response.responseText;
70
89
  }
90
+ throw new Error(
91
+ `Failed to load module from ${url}: HTTP ${response.status}`
92
+ );
71
93
  } catch (error) {
72
94
  throw new Error(`Failed to fetch module from ${url}: ${error.message}`);
73
95
  }
74
96
  };
97
+ const requestUmdSource = (url) => new Promise((resolve, reject) => {
98
+ try {
99
+ const response = new XMLHttpRequest();
100
+ response.open("GET", url, true);
101
+ response.overrideMimeType("text/plain");
102
+ response.onload = () => {
103
+ if (response.status === 200) {
104
+ resolve(response.responseText);
105
+ return;
106
+ }
107
+ reject(
108
+ new Error(
109
+ `Failed to load module from ${url}: HTTP ${response.status}`
110
+ )
111
+ );
112
+ };
113
+ response.onerror = () => {
114
+ reject(new Error(`Failed to fetch module from ${url}`));
115
+ };
116
+ response.send();
117
+ } catch (error) {
118
+ reject(new Error(`Failed to fetch module from ${url}: ${error.message}`));
119
+ }
120
+ });
121
+ const createUmdSandbox = (pkgName, scopes) => {
122
+ const sandboxTarget = /* @__PURE__ */ Object.create(null);
123
+ const sandbox = new Proxy(sandboxTarget, {
124
+ get(target, key) {
125
+ if (typeof key === "symbol") {
126
+ return Reflect.get(target, key);
127
+ }
128
+ if (key in target) {
129
+ return target[key];
130
+ }
131
+ const value = window[key];
132
+ return typeof value === "function" ? value.bind(window) : value;
133
+ },
134
+ set(target, key, value) {
135
+ target[key] = value;
136
+ return true;
137
+ },
138
+ has(target, key) {
139
+ return key in target || key in window;
140
+ }
141
+ });
142
+ sandboxTarget.window = sandbox;
143
+ sandboxTarget.self = sandbox;
144
+ sandboxTarget.globalThis = sandbox;
145
+ sandboxTarget.global = sandbox;
146
+ sandboxTarget.document = window.document;
147
+ if (pkgName === "react-dom") {
148
+ sandboxTarget.React = getScopeGlobal("react", scopes);
149
+ }
150
+ return sandbox;
151
+ };
152
+ const executeUmdModule = (scriptContent, pkgName, scopes) => {
153
+ const sandbox = createUmdSandbox(pkgName, scopes);
154
+ const moduleFunction = new Function(
155
+ "window",
156
+ "self",
157
+ "globalThis",
158
+ "global",
159
+ "document",
160
+ "exports",
161
+ "module",
162
+ "define",
163
+ "require",
164
+ scriptContent
165
+ );
166
+ moduleFunction.call(
167
+ sandbox,
168
+ sandbox,
169
+ sandbox,
170
+ sandbox,
171
+ sandbox,
172
+ sandbox.document,
173
+ void 0,
174
+ void 0,
175
+ void 0,
176
+ void 0
177
+ );
178
+ return sandbox[getDefaultGlobalKey(pkgName)];
179
+ };
180
+ const loadUmdModuleSync = (pkgName, version, scopes) => executeUmdModule(
181
+ requestUmdSourceSync((0, import__.getUnpkgUrl)(pkgName, version)),
182
+ pkgName,
183
+ scopes
184
+ );
185
+ const loadUmdModule = (pkgName, version, scopes) => __async(exports, null, function* () {
186
+ return executeUmdModule(
187
+ yield requestUmdSource((0, import__.getUnpkgUrl)(pkgName, version)),
188
+ pkgName,
189
+ scopes
190
+ );
191
+ });
75
192
  const getDevtoolsMessage = () => {
76
193
  const devtoolsMessageStr = localStorage.getItem(import_constant.__FEDERATION_DEVTOOLS__);
77
194
  if (devtoolsMessageStr) {
@@ -84,18 +201,31 @@ const getDevtoolsMessage = () => {
84
201
  return null;
85
202
  };
86
203
  const devtoolsMessage = getDevtoolsMessage();
87
- if ((devtoolsMessage == null ? void 0 : devtoolsMessage[import_constant.__ENABLE_FAST_REFRESH__]) && (devtoolsMessage == null ? void 0 : devtoolsMessage[import_constant.__EAGER_SHARE__])) {
88
- const [_name, version] = devtoolsMessage[import_constant.__EAGER_SHARE__];
89
- fetchAndExecuteUmdSync((0, import__.getUnpkgUrl)("react", version));
90
- fetchAndExecuteUmdSync((0, import__.getUnpkgUrl)("react-dom", version));
204
+ const eagerShareInfo = getEagerShareInfo(devtoolsMessage == null ? void 0 : devtoolsMessage[import_constant.__EAGER_SHARE__]);
205
+ if ((devtoolsMessage == null ? void 0 : devtoolsMessage[import_constant.__ENABLE_FAST_REFRESH__]) && eagerShareInfo) {
206
+ const { version, scopes } = eagerShareInfo;
207
+ setScopeGlobals("react", scopes, loadUmdModuleSync("react", version, scopes));
208
+ setScopeGlobals(
209
+ "react-dom",
210
+ scopes,
211
+ loadUmdModuleSync("react-dom", version, scopes)
212
+ );
91
213
  }
92
214
  const fastRefreshPlugin = () => {
215
+ let orderResolve;
216
+ const orderPromise = new Promise((resolve) => {
217
+ orderResolve = resolve;
218
+ });
93
219
  return {
94
220
  name: "mf-fast-refresh-plugin",
95
- beforeInit(_a2) {
96
- var _b = _a2, { userOptions } = _b, args = __objRest(_b, ["userOptions"]);
97
- const shareInfo = userOptions.shared;
98
- const twinsShareInfo = args.shareInfo;
221
+ beforeRegisterShare(args) {
222
+ var _a2;
223
+ const { pkgName, shared } = args;
224
+ if (!SUPPORT_PKGS.includes(pkgName)) {
225
+ return args;
226
+ }
227
+ const supportPkgName = pkgName;
228
+ const shareScopes = getShareScopes(shared.scope);
99
229
  let enableFastRefresh = false;
100
230
  let devtoolsMessage2 = {};
101
231
  const devtoolsMessageStr = localStorage.getItem(import_constant.__FEDERATION_DEVTOOLS__);
@@ -108,106 +238,91 @@ const fastRefreshPlugin = () => {
108
238
  }
109
239
  }
110
240
  if (!enableFastRefresh) {
111
- return __spreadValues({
112
- userOptions
113
- }, args);
241
+ return args;
114
242
  }
115
- if (shareInfo && (0, import__.isObject)(shareInfo)) {
116
- let orderResolve;
117
- const orderPromise = new Promise((resolve) => {
118
- orderResolve = resolve;
119
- });
120
- Object.keys(shareInfo).forEach((share) => __async(this, null, function* () {
121
- const sharedArr = Array.isArray(shareInfo[share]) ? shareInfo[share] : [shareInfo[share]];
122
- let twinsSharedArr;
123
- if (twinsShareInfo) {
124
- twinsSharedArr = Array.isArray(twinsShareInfo[share]) ? twinsShareInfo[share] : [twinsShareInfo[share]];
243
+ if (((_a2 = shared.shareConfig) == null ? void 0 : _a2.eager) || shared.lib) {
244
+ if (!(devtoolsMessage2 == null ? void 0 : devtoolsMessage2[import_constant.__EAGER_SHARE__])) {
245
+ const eagerShareInfo2 = updateEagerShareInfo(
246
+ devtoolsMessage2,
247
+ pkgName,
248
+ shared.version,
249
+ shareScopes
250
+ );
251
+ localStorage.setItem(
252
+ import_constant.__FEDERATION_DEVTOOLS__,
253
+ JSON.stringify(devtoolsMessage2)
254
+ );
255
+ if (eagerShareInfo2.shouldReload) {
256
+ window.location.reload();
125
257
  }
126
- sharedArr.forEach((shared, idx) => {
127
- var _a3;
128
- if (!SUPPORT_PKGS.includes(share)) {
129
- return;
130
- }
131
- if ((_a3 = shared.shareConfig) == null ? void 0 : _a3.eager) {
132
- if (!(devtoolsMessage2 == null ? void 0 : devtoolsMessage2[import_constant.__EAGER_SHARE__])) {
133
- const eagerShare = [];
134
- eagerShare.push(share, shared.version);
135
- devtoolsMessage2[import_constant.__EAGER_SHARE__] = eagerShare;
136
- localStorage.setItem(
137
- import_constant.__FEDERATION_DEVTOOLS__,
138
- JSON.stringify(devtoolsMessage2)
139
- );
140
- window.location.reload();
141
- }
142
- if (share === "react-dom") {
143
- shared.lib = () => window.ReactDOM;
144
- }
145
- if (share === "react") {
146
- shared.lib = () => window.React;
147
- }
148
- return;
149
- }
150
- let get;
151
- if (share === "react") {
152
- get = () => (0, import_sdk.loadScript)((0, import__.getUnpkgUrl)(share, shared.version), {
153
- attrs: {
154
- defer: false,
155
- async: false,
156
- "data-mf-injected": "true"
157
- }
158
- }).then(() => {
159
- orderResolve();
160
- });
161
- }
162
- if (share === "react-dom") {
163
- get = () => orderPromise.then(
164
- () => (0, import_sdk.loadScript)((0, import__.getUnpkgUrl)(share, shared.version), {
165
- attrs: { defer: true, async: false }
166
- })
258
+ } else {
259
+ updateEagerShareInfo(
260
+ devtoolsMessage2,
261
+ pkgName,
262
+ shared.version,
263
+ shareScopes
264
+ );
265
+ localStorage.setItem(
266
+ import_constant.__FEDERATION_DEVTOOLS__,
267
+ JSON.stringify(devtoolsMessage2)
268
+ );
269
+ }
270
+ if (pkgName === "react-dom") {
271
+ shared.lib = () => getScopeGlobal(supportPkgName, shareScopes);
272
+ }
273
+ if (pkgName === "react") {
274
+ shared.lib = () => getScopeGlobal(supportPkgName, shareScopes);
275
+ }
276
+ return args;
277
+ }
278
+ let get;
279
+ if (pkgName === "react") {
280
+ get = () => loadUmdModule(supportPkgName, shared.version, shareScopes).then((moduleValue) => {
281
+ setScopeGlobals(supportPkgName, shareScopes, moduleValue);
282
+ return moduleValue;
283
+ }).then(() => {
284
+ orderResolve();
285
+ });
286
+ }
287
+ if (pkgName === "react-dom") {
288
+ get = () => orderPromise.then(
289
+ () => loadUmdModule(supportPkgName, shared.version, shareScopes)
290
+ ).then((result) => {
291
+ setScopeGlobals(supportPkgName, shareScopes, result);
292
+ return result;
293
+ });
294
+ }
295
+ if (typeof get === "function") {
296
+ const finalGet = get;
297
+ if (pkgName === "react") {
298
+ shared.get = () => __async(this, null, function* () {
299
+ if (!getScopeGlobal(supportPkgName, shareScopes)) {
300
+ yield finalGet();
301
+ console.warn(
302
+ "[Module Federation HMR]: You are using Module Federation Devtools to debug online host, it will cause your project load Dev mode React and ReactDOM. If not in this mode, please disable it in Module Federation Devtools"
167
303
  );
168
304
  }
169
- if (typeof get === "function") {
170
- if (share === "react") {
171
- shared.get = () => __async(this, null, function* () {
172
- if (!window.React) {
173
- yield get();
174
- console.warn(
175
- "[Module Federation HMR]: You are using Module Federation Devtools to debug online host, it will cause your project load Dev mode React and ReactDOM. If not in this mode, please disable it in Module Federation Devtools"
176
- );
177
- }
178
- shared.lib = () => window.React;
179
- return () => window.React;
180
- });
181
- }
182
- if (share === "react-dom") {
183
- shared.get = () => __async(this, null, function* () {
184
- if (!window.ReactDOM) {
185
- yield get();
186
- }
187
- shared.lib = () => window.ReactDOM;
188
- return () => window.ReactDOM;
189
- });
190
- }
191
- if (twinsShareInfo) {
192
- twinsSharedArr[idx].get = shared.get;
193
- }
305
+ shared.lib = () => getScopeGlobal(supportPkgName, shareScopes);
306
+ return () => getScopeGlobal(supportPkgName, shareScopes);
307
+ });
308
+ }
309
+ if (pkgName === "react-dom") {
310
+ shared.get = () => __async(this, null, function* () {
311
+ if (!getScopeGlobal(supportPkgName, shareScopes)) {
312
+ yield finalGet();
194
313
  }
314
+ shared.lib = () => getScopeGlobal(supportPkgName, shareScopes);
315
+ return () => getScopeGlobal(supportPkgName, shareScopes);
195
316
  });
196
- }));
197
- return __spreadValues({
198
- userOptions
199
- }, args);
200
- } else {
201
- return __spreadValues({
202
- userOptions
203
- }, args);
317
+ }
204
318
  }
319
+ return args;
205
320
  }
206
321
  };
207
322
  };
208
323
  if (!(window == null ? void 0 : window.__FEDERATION__)) {
209
- (0, import_sdk2.definePropertyGlobalVal)(window, "__FEDERATION__", {});
210
- (0, import_sdk2.definePropertyGlobalVal)(window, "__VMOK__", window.__FEDERATION__);
324
+ (0, import_sdk.definePropertyGlobalVal)(window, "__FEDERATION__", {});
325
+ (0, import_sdk.definePropertyGlobalVal)(window, "__VMOK__", window.__FEDERATION__);
211
326
  }
212
327
  if (!(window == null ? void 0 : window.__FEDERATION__.__GLOBAL_PLUGIN__)) {
213
328
  window.__FEDERATION__.__GLOBAL_PLUGIN__ = [];
@@ -74,6 +74,7 @@ __export(chrome_exports, {
74
74
  module.exports = __toCommonJS(chrome_exports);
75
75
  var import_constant = require("../../template/constant");
76
76
  var import_sdk2 = require("../sdk");
77
+ var import_safe_post_message = require("./safe-post-message");
77
78
  __reExport(chrome_exports, require("./storage"), module.exports);
78
79
  const sleep = (num) => {
79
80
  return new Promise((resolve) => {
@@ -169,8 +170,8 @@ const getGlobalModuleInfo = (callback) => __async(void 0, null, function* () {
169
170
  var _a, _b;
170
171
  if (typeof window !== "undefined" && ((_a = window.__FEDERATION__) == null ? void 0 : _a.moduleInfo)) {
171
172
  callback(
172
- JSON.parse(
173
- JSON.stringify((_b = window.__FEDERATION__) == null ? void 0 : _b.moduleInfo)
173
+ (0, import_safe_post_message.sanitizePostMessagePayload)(
174
+ (_b = window.__FEDERATION__) == null ? void 0 : _b.moduleInfo
174
175
  )
175
176
  );
176
177
  }
@@ -184,8 +185,8 @@ const getGlobalModuleInfo = (callback) => __async(void 0, null, function* () {
184
185
  (0, import_sdk2.definePropertyGlobalVal)(window, "__FEDERATION__", {});
185
186
  (0, import_sdk2.definePropertyGlobalVal)(window, "__VMOK__", window.__FEDERATION__);
186
187
  }
187
- window.__FEDERATION__.originModuleInfo = JSON.parse(
188
- JSON.stringify(data == null ? void 0 : data.moduleInfo)
188
+ window.__FEDERATION__.originModuleInfo = (0, import_safe_post_message.sanitizePostMessagePayload)(
189
+ data == null ? void 0 : data.moduleInfo
189
190
  );
190
191
  if (data == null ? void 0 : data.updateModule) {
191
192
  const moduleIds = Object.keys(window.__FEDERATION__.originModuleInfo);
@@ -201,10 +202,10 @@ const getGlobalModuleInfo = (callback) => __async(void 0, null, function* () {
201
202
  }
202
203
  }
203
204
  if (data == null ? void 0 : data.share) {
204
- window.__FEDERATION__.__SHARE__ = data.share;
205
+ window.__FEDERATION__.__SHARE__ = (0, import_safe_post_message.sanitizePostMessagePayload)(data.share);
205
206
  }
206
- window.__FEDERATION__.moduleInfo = JSON.parse(
207
- JSON.stringify(window.__FEDERATION__.originModuleInfo)
207
+ window.__FEDERATION__.moduleInfo = (0, import_safe_post_message.sanitizePostMessagePayload)(
208
+ window.__FEDERATION__.originModuleInfo
208
209
  );
209
210
  console.log("getGlobalModuleInfo window", window.__FEDERATION__);
210
211
  callback(window.__FEDERATION__.moduleInfo);
@@ -22,8 +22,8 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
22
22
  mod
23
23
  ));
24
24
  var import_helpers = __toESM(require("@module-federation/runtime/helpers"));
25
- var import_sdk = require("../sdk");
26
- var import_template = require("../../template");
25
+ var import_sdk = require("@module-federation/sdk");
26
+ var import_sdk2 = require("../sdk");
27
27
  var _a;
28
28
  const chromeOverrideRemotesPlugin = function() {
29
29
  return {
@@ -32,7 +32,7 @@ const chromeOverrideRemotesPlugin = function() {
32
32
  try {
33
33
  const { remote } = args;
34
34
  const overrideRemote = import_helpers.default.global.nativeGlobal.localStorage.getItem(
35
- import_template.__FEDERATION_DEVTOOLS__
35
+ import_sdk.MODULE_DEVTOOL_IDENTIFIER
36
36
  );
37
37
  if (!overrideRemote) {
38
38
  return args;
@@ -56,8 +56,8 @@ const chromeOverrideRemotesPlugin = function() {
56
56
  };
57
57
  };
58
58
  if (!(window == null ? void 0 : window.__FEDERATION__)) {
59
- (0, import_sdk.definePropertyGlobalVal)(window, "__FEDERATION__", {});
60
- (0, import_sdk.definePropertyGlobalVal)(window, "__VMOK__", window.__FEDERATION__);
59
+ (0, import_sdk2.definePropertyGlobalVal)(window, "__FEDERATION__", {});
60
+ (0, import_sdk2.definePropertyGlobalVal)(window, "__VMOK__", window.__FEDERATION__);
61
61
  }
62
62
  if (!(window == null ? void 0 : window.__FEDERATION__.__GLOBAL_PLUGIN__)) {
63
63
  window.__FEDERATION__.__GLOBAL_PLUGIN__ = [];
@@ -1,4 +1,5 @@
1
1
  "use strict";
2
+ var import_safe_post_message = require("./safe-post-message");
2
3
  if (window.moduleHandler) {
3
4
  window.removeEventListener("message", window.moduleHandler);
4
5
  } else {
@@ -9,11 +10,11 @@ if (window.moduleHandler) {
9
10
  }
10
11
  chrome.runtime.sendMessage({
11
12
  origin,
12
- data: {
13
+ data: (0, import_safe_post_message.sanitizePostMessagePayload)({
13
14
  moduleInfo: data.moduleInfo,
14
15
  updateModule: data.updateModule,
15
16
  share: data.share
16
- }
17
+ })
17
18
  }).catch(() => {
18
19
  return false;
19
20
  });
@@ -1,17 +1,11 @@
1
1
  "use strict";
2
+ var import_safe_post_message = require("./safe-post-message");
2
3
  var _a, _b;
3
4
  const moduleInfo = (_a = window == null ? void 0 : window.__FEDERATION__) == null ? void 0 : _a.moduleInfo;
4
5
  window.postMessage(
5
- {
6
+ (0, import_safe_post_message.sanitizePostMessagePayload)({
6
7
  moduleInfo,
7
- share: JSON.parse(
8
- JSON.stringify((_b = window == null ? void 0 : window.__FEDERATION__) == null ? void 0 : _b.__SHARE__, (_key, value) => {
9
- if (typeof value === "function") {
10
- return "Function";
11
- }
12
- return value;
13
- })
14
- )
15
- },
8
+ share: (_b = window == null ? void 0 : window.__FEDERATION__) == null ? void 0 : _b.__SHARE__
9
+ }),
16
10
  "*"
17
11
  );