@module-federation/devtools 0.0.0-perf-devtools-20260107043700 → 0.0.0-perf-website-code-usage-20260914033703
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/README.md +3 -0
- package/dist/es/App.css +6 -5
- package/dist/es/App.js +211 -63
- package/dist/es/App.module.js +1 -1
- package/dist/es/App_module.css +41 -39
- package/dist/es/component/DependencyGraph/index.js +11 -12
- package/dist/es/component/DependencyGraph/index_module.css +20 -17
- package/dist/es/component/DependencyGraphItem/index.js +23 -10
- package/dist/es/component/DependencyGraphItem/index_module.css +7 -7
- package/dist/es/component/Form/index.js +24 -31
- package/dist/es/component/Form/index.module.js +1 -1
- package/dist/es/component/Form/index_module.css +22 -25
- package/dist/es/component/LanguageSwitch.js +50 -0
- package/dist/es/component/Layout/index.js +27 -10
- package/dist/es/component/Layout/index_module.css +7 -7
- package/dist/es/component/LoadingTrace/index.js +944 -0
- package/dist/es/component/LoadingTrace/index.module.js +5 -0
- package/dist/es/component/LoadingTrace/index_module.css +876 -0
- package/dist/es/component/ModuleInfo/index.js +65 -41
- package/dist/es/component/ModuleInfo/index_module.css +12 -11
- package/dist/es/component/SharedDepsExplorer/FocusResultDisplay.js +5 -3
- package/dist/es/component/SharedDepsExplorer/FocusResultDisplay_module.css +5 -5
- package/dist/es/component/SharedDepsExplorer/index.js +223 -96
- package/dist/es/component/SharedDepsExplorer/index_module.css +12 -2
- package/dist/es/component/SharedDepsExplorer/share-utils.js +21 -5
- package/dist/es/component/ThemeToggle.js +19 -0
- package/dist/es/component/ThemeToggle.module.js +5 -0
- package/dist/es/component/ThemeToggle_module.css +12 -0
- package/dist/es/hooks/useDevtoolsTheme.js +77 -0
- package/dist/es/i18n/index.js +688 -0
- package/dist/es/utils/chrome/fast-refresh.js +297 -173
- package/dist/es/utils/chrome/index.js +42 -22
- package/dist/es/utils/chrome/messages.js +7 -1
- package/dist/es/utils/chrome/observability-plugin.js +93 -0
- package/dist/es/utils/chrome/observability-shared.js +99 -0
- package/dist/es/utils/chrome/observability.js +208 -0
- package/dist/es/utils/chrome/override-remote.js +7 -0
- package/dist/es/utils/chrome/post-message-listener.js +22 -4
- package/dist/es/utils/chrome/post-message-start.js +4 -10
- package/dist/es/utils/chrome/post-message.js +12 -3
- package/dist/es/utils/chrome/resolve-basic-proxy-core.js +4 -0
- package/dist/es/utils/chrome/safe-post-message.js +124 -0
- package/dist/es/utils/chrome/snapshot-plugin.js +2 -36
- package/dist/es/utils/data/index.js +5 -25
- package/dist/es/utils/sdk/graph.js +25 -11
- package/dist/es/vendor/basic-proxy-core.js +155 -0
- package/dist/es/worker/index.js +27 -8
- package/dist/lib/App.css +6 -5
- package/dist/lib/App.js +208 -64
- package/dist/lib/App.module.js +1 -2
- package/dist/lib/App_module.css +41 -39
- package/dist/lib/component/DependencyGraph/index.js +11 -13
- package/dist/lib/component/DependencyGraph/index.module.js +0 -1
- package/dist/lib/component/DependencyGraph/index_module.css +20 -17
- package/dist/lib/component/DependencyGraphItem/index.js +23 -11
- package/dist/lib/component/DependencyGraphItem/index.module.js +0 -1
- package/dist/lib/component/DependencyGraphItem/index_module.css +7 -7
- package/dist/lib/component/Form/index.js +24 -32
- package/dist/lib/component/Form/index.module.js +1 -2
- package/dist/lib/component/Form/index_module.css +22 -25
- package/dist/lib/component/LanguageSwitch.js +79 -0
- package/dist/lib/component/Layout/index.js +27 -11
- package/dist/lib/component/Layout/index.module.js +0 -1
- package/dist/lib/component/Layout/index_module.css +7 -7
- package/dist/lib/component/LoadingTrace/index.js +953 -0
- package/dist/lib/component/LoadingTrace/index.module.js +24 -0
- package/dist/lib/component/LoadingTrace/index_module.css +876 -0
- package/dist/lib/component/ModuleInfo/index.js +65 -42
- package/dist/lib/component/ModuleInfo/index.module.js +0 -1
- package/dist/lib/component/ModuleInfo/index_module.css +12 -11
- package/dist/lib/component/SharedDepsExplorer/FocusResultDisplay.js +5 -4
- package/dist/lib/component/SharedDepsExplorer/FocusResultDisplay.module.js +0 -1
- package/dist/lib/component/SharedDepsExplorer/FocusResultDisplay_module.css +5 -5
- package/dist/lib/component/SharedDepsExplorer/index.js +217 -95
- package/dist/lib/component/SharedDepsExplorer/index.module.js +0 -1
- package/dist/lib/component/SharedDepsExplorer/index_module.css +12 -2
- package/dist/lib/component/SharedDepsExplorer/share-utils.js +21 -6
- package/dist/lib/component/ThemeToggle.js +48 -0
- package/dist/lib/component/ThemeToggle.module.js +24 -0
- package/dist/lib/component/ThemeToggle_module.css +12 -0
- package/dist/lib/hooks/useDevtoolsTheme.js +100 -0
- package/dist/lib/i18n/index.js +721 -0
- package/dist/lib/init.js +0 -1
- package/dist/lib/template/constant.js +0 -1
- package/dist/lib/template/index.js +0 -1
- package/dist/lib/utils/chrome/fast-refresh.js +250 -136
- package/dist/lib/utils/chrome/index.js +43 -23
- package/dist/lib/utils/chrome/messages.js +11 -3
- package/dist/lib/utils/chrome/observability-plugin.js +85 -0
- package/dist/lib/utils/chrome/observability-shared.js +125 -0
- package/dist/lib/utils/chrome/observability.js +233 -0
- package/dist/lib/utils/chrome/override-remote.js +20 -0
- package/dist/lib/utils/chrome/post-message-init.js +0 -1
- package/dist/lib/utils/chrome/post-message-listener.js +19 -5
- package/dist/lib/utils/chrome/post-message-start.js +4 -11
- package/dist/lib/utils/chrome/post-message.js +12 -4
- package/dist/lib/utils/chrome/resolve-basic-proxy-core.js +27 -0
- package/dist/lib/utils/chrome/safe-post-message.js +147 -0
- package/dist/lib/utils/chrome/snapshot-plugin.js +5 -47
- package/dist/lib/utils/chrome/storage.js +0 -1
- package/dist/lib/utils/data/index.js +6 -29
- package/dist/lib/utils/index.js +0 -1
- package/dist/lib/utils/sdk/graph.js +25 -12
- package/dist/lib/utils/sdk/index.js +0 -1
- package/dist/lib/utils/types/common.js +0 -1
- package/dist/lib/utils/types/index.js +0 -1
- package/dist/lib/vendor/basic-proxy-core.js +147 -0
- package/dist/lib/worker/index.js +27 -9
- package/dist/types/App.css +13 -0
- package/dist/types/App.js +519 -0
- package/dist/types/App.module.js +24 -0
- package/dist/types/App_module.css +307 -0
- package/dist/types/component/DependencyGraph/index.js +225 -0
- package/dist/types/component/DependencyGraph/index.module.js +24 -0
- package/dist/types/component/DependencyGraph/index_module.css +100 -0
- package/dist/types/component/DependencyGraphItem/index.js +124 -0
- package/dist/types/component/DependencyGraphItem/index.module.js +24 -0
- package/dist/types/component/DependencyGraphItem/index_module.css +95 -0
- package/dist/types/component/Form/index.js +372 -0
- package/dist/types/component/Form/index.module.js +24 -0
- package/dist/types/component/Form/index_module.css +198 -0
- package/dist/types/component/LanguageSwitch.js +79 -0
- package/dist/types/component/Layout/index.js +471 -0
- package/dist/types/component/Layout/index.module.js +24 -0
- package/dist/types/component/Layout/index_module.css +68 -0
- package/dist/types/component/LoadingTrace/index.js +953 -0
- package/dist/types/component/LoadingTrace/index.module.js +24 -0
- package/dist/types/component/LoadingTrace/index_module.css +876 -0
- package/dist/types/component/ModuleInfo/index.js +342 -0
- package/dist/types/component/ModuleInfo/index.module.js +24 -0
- package/dist/types/component/ModuleInfo/index_module.css +184 -0
- package/dist/types/component/SharedDepsExplorer/FocusResultDisplay.js +64 -0
- package/dist/types/component/SharedDepsExplorer/FocusResultDisplay.module.js +24 -0
- package/dist/types/component/SharedDepsExplorer/FocusResultDisplay_module.css +45 -0
- package/dist/types/component/SharedDepsExplorer/index.js +635 -0
- package/dist/types/component/SharedDepsExplorer/index.module.js +24 -0
- package/dist/types/component/SharedDepsExplorer/index_module.css +467 -0
- package/dist/types/component/SharedDepsExplorer/share-utils.js +252 -0
- package/dist/types/component/ThemeToggle.js +48 -0
- package/dist/types/component/ThemeToggle.module.js +24 -0
- package/dist/types/component/ThemeToggle_module.css +12 -0
- package/dist/types/hooks/useDevtoolsTheme.js +100 -0
- package/dist/types/i18n/index.js +721 -0
- package/dist/types/init.js +8 -0
- package/dist/types/src/App.d.ts +1 -1
- package/dist/types/src/component/DependencyGraph/index.d.ts +1 -1
- package/dist/types/src/component/DependencyGraphItem/index.d.ts +1 -1
- package/dist/types/src/component/Form/index.d.ts +1 -1
- package/dist/types/src/component/LanguageSwitch.d.ts +2 -0
- package/dist/types/src/component/Layout/index.d.ts +1 -1
- package/dist/types/src/component/LoadingTrace/index.d.ts +6 -0
- package/dist/types/src/component/ModuleInfo/index.d.ts +1 -1
- package/dist/types/src/component/SharedDepsExplorer/index.d.ts +1 -1
- package/dist/types/src/component/SharedDepsExplorer/share-utils.d.ts +3 -2
- package/dist/types/src/component/ThemeToggle.d.ts +8 -0
- package/dist/types/src/hooks/useDevtoolsTheme.d.ts +2 -0
- package/dist/types/src/i18n/index.d.ts +5 -0
- package/dist/types/src/template/constant.d.ts +1 -1
- package/dist/types/src/utils/chrome/index.d.ts +2 -1
- package/dist/types/src/utils/chrome/messages.d.ts +3 -0
- package/dist/types/src/utils/chrome/observability-plugin.d.ts +1 -0
- package/dist/types/src/utils/chrome/observability-shared.d.ts +41 -0
- package/dist/types/src/utils/chrome/observability.d.ts +110 -0
- package/dist/types/src/utils/chrome/override-remote.d.ts +1 -0
- package/dist/types/src/utils/chrome/post-message-listener.d.ts +1 -0
- package/dist/types/src/utils/chrome/post-message-start.d.ts +1 -1
- package/dist/types/src/utils/chrome/resolve-basic-proxy-core.d.ts +6 -0
- package/dist/types/src/utils/chrome/safe-post-message.d.ts +1 -0
- package/dist/types/src/utils/chrome/snapshot-plugin.d.ts +0 -3
- package/dist/types/src/utils/data/index.d.ts +1 -2
- package/dist/types/src/utils/sdk/graph.d.ts +1 -1
- package/dist/types/src/utils/sdk/index.d.ts +2 -2
- package/dist/types/stories/index.stories.d.ts +2 -1
- package/dist/types/template/constant.js +84 -0
- package/dist/types/template/index.js +21 -0
- package/dist/types/utils/chrome/fast-refresh.js +329 -0
- package/dist/types/utils/chrome/index.js +321 -0
- package/dist/types/utils/chrome/messages.js +39 -0
- package/dist/types/utils/chrome/observability-plugin.js +85 -0
- package/dist/types/utils/chrome/observability-shared.js +125 -0
- package/dist/types/utils/chrome/observability.js +233 -0
- package/dist/types/utils/chrome/override-remote.js +20 -0
- package/dist/types/utils/chrome/post-message-init.js +5 -0
- package/dist/types/utils/chrome/post-message-listener.js +36 -0
- package/dist/types/utils/chrome/post-message-start.js +10 -0
- package/dist/types/utils/chrome/post-message.js +91 -0
- package/dist/types/utils/chrome/resolve-basic-proxy-core.js +27 -0
- package/dist/types/utils/chrome/safe-post-message.js +147 -0
- package/dist/types/utils/chrome/snapshot-plugin.js +17 -0
- package/dist/types/utils/chrome/storage.js +71 -0
- package/dist/types/utils/data/index.js +83 -0
- package/dist/types/utils/index.js +27 -0
- package/dist/types/utils/sdk/graph.js +213 -0
- package/dist/types/utils/sdk/index.js +104 -0
- package/dist/types/utils/types/common.js +15 -0
- package/dist/types/utils/types/index.js +21 -0
- package/dist/types/vendor/basic-proxy-core.js +147 -0
- package/dist/types/worker/index.js +175 -0
- package/install-deps.bash +7 -3
- package/package.json +47 -28
- package/dist/es/utils/data/snapshot.js +0 -82
- package/dist/lib/utils/data/snapshot.js +0 -107
- package/dist/types/src/utils/data/snapshot.d.ts +0 -3
package/dist/lib/init.js
CHANGED
|
@@ -1,32 +1,3 @@
|
|
|
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
1
|
var __async = (__this, __arguments, generator) => {
|
|
31
2
|
return new Promise((resolve, reject) => {
|
|
32
3
|
var fulfilled = (value) => {
|
|
@@ -47,31 +18,176 @@ var __async = (__this, __arguments, generator) => {
|
|
|
47
18
|
step((generator = generator.apply(__this, __arguments)).next());
|
|
48
19
|
});
|
|
49
20
|
};
|
|
50
|
-
var import_sdk = require("@module-federation/sdk");
|
|
51
21
|
var import__ = require("../index");
|
|
52
|
-
var
|
|
22
|
+
var import_sdk = require("../sdk");
|
|
53
23
|
var import_constant = require("../../template/constant");
|
|
54
24
|
var _a;
|
|
55
25
|
const SUPPORT_PKGS = ["react", "react-dom"];
|
|
56
|
-
const
|
|
26
|
+
const DEFAULT_SHARE_SCOPE = "default";
|
|
27
|
+
const DEFAULT_GLOBAL_KEY_MAP = {
|
|
28
|
+
react: "React",
|
|
29
|
+
"react-dom": "ReactDOM"
|
|
30
|
+
};
|
|
31
|
+
const sanitizeWindowKey = (value) => value.replace(/[^a-zA-Z0-9_$]/g, "_");
|
|
32
|
+
const getShareScopes = (scope) => Array.isArray(scope) && scope.length ? scope : [DEFAULT_SHARE_SCOPE];
|
|
33
|
+
const getDefaultGlobalKey = (pkgName) => DEFAULT_GLOBAL_KEY_MAP[pkgName];
|
|
34
|
+
const getScopedGlobalKey = (scope, pkgName) => `${sanitizeWindowKey(scope)}_${sanitizeWindowKey(pkgName)}`;
|
|
35
|
+
const getWindowValue = (key) => window[key];
|
|
36
|
+
const setWindowValue = (key, value) => {
|
|
37
|
+
window[key] = value;
|
|
38
|
+
};
|
|
39
|
+
const setScopeGlobals = (pkgName, scopes, source) => {
|
|
40
|
+
if (!source) {
|
|
41
|
+
return source;
|
|
42
|
+
}
|
|
43
|
+
scopes.forEach((scope) => {
|
|
44
|
+
setWindowValue(getScopedGlobalKey(scope, pkgName), source);
|
|
45
|
+
});
|
|
46
|
+
return source;
|
|
47
|
+
};
|
|
48
|
+
const getScopeGlobal = (pkgName, scopes) => {
|
|
49
|
+
for (const scope of scopes) {
|
|
50
|
+
const scopeGlobal = getWindowValue(getScopedGlobalKey(scope, pkgName));
|
|
51
|
+
if (scopeGlobal) {
|
|
52
|
+
return scopeGlobal;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
return void 0;
|
|
56
|
+
};
|
|
57
|
+
const getEagerShareInfo = (eagerShare) => {
|
|
58
|
+
if (!Array.isArray(eagerShare) || eagerShare.length < 2) {
|
|
59
|
+
return null;
|
|
60
|
+
}
|
|
61
|
+
const [, version, scopes] = eagerShare;
|
|
62
|
+
if (typeof version !== "string") {
|
|
63
|
+
return null;
|
|
64
|
+
}
|
|
65
|
+
return {
|
|
66
|
+
version,
|
|
67
|
+
scopes: getShareScopes(scopes)
|
|
68
|
+
};
|
|
69
|
+
};
|
|
70
|
+
const updateEagerShareInfo = (devtoolsMessage2, pkgName, version, scopes) => {
|
|
71
|
+
const existing = getEagerShareInfo(devtoolsMessage2[import_constant.__EAGER_SHARE__]);
|
|
72
|
+
const mergedScopes = Array.from(
|
|
73
|
+
/* @__PURE__ */ new Set([...(existing == null ? void 0 : existing.scopes) || [], ...scopes])
|
|
74
|
+
);
|
|
75
|
+
devtoolsMessage2[import_constant.__EAGER_SHARE__] = [pkgName, version, mergedScopes];
|
|
76
|
+
return {
|
|
77
|
+
shouldReload: !existing || existing.version !== version
|
|
78
|
+
};
|
|
79
|
+
};
|
|
80
|
+
const requestUmdSourceSync = (url) => {
|
|
57
81
|
try {
|
|
58
82
|
const response = new XMLHttpRequest();
|
|
59
83
|
response.open("GET", url, false);
|
|
60
84
|
response.overrideMimeType("text/plain");
|
|
61
85
|
response.send();
|
|
62
86
|
if (response.status === 200) {
|
|
63
|
-
|
|
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
|
-
);
|
|
87
|
+
return response.responseText;
|
|
70
88
|
}
|
|
89
|
+
throw new Error(
|
|
90
|
+
`Failed to load module from ${url}: HTTP ${response.status}`
|
|
91
|
+
);
|
|
71
92
|
} catch (error) {
|
|
72
93
|
throw new Error(`Failed to fetch module from ${url}: ${error.message}`);
|
|
73
94
|
}
|
|
74
95
|
};
|
|
96
|
+
const requestUmdSource = (url) => new Promise((resolve, reject) => {
|
|
97
|
+
try {
|
|
98
|
+
const response = new XMLHttpRequest();
|
|
99
|
+
response.open("GET", url, true);
|
|
100
|
+
response.overrideMimeType("text/plain");
|
|
101
|
+
response.onload = () => {
|
|
102
|
+
if (response.status === 200) {
|
|
103
|
+
resolve(response.responseText);
|
|
104
|
+
return;
|
|
105
|
+
}
|
|
106
|
+
reject(
|
|
107
|
+
new Error(
|
|
108
|
+
`Failed to load module from ${url}: HTTP ${response.status}`
|
|
109
|
+
)
|
|
110
|
+
);
|
|
111
|
+
};
|
|
112
|
+
response.onerror = () => {
|
|
113
|
+
reject(new Error(`Failed to fetch module from ${url}`));
|
|
114
|
+
};
|
|
115
|
+
response.send();
|
|
116
|
+
} catch (error) {
|
|
117
|
+
reject(new Error(`Failed to fetch module from ${url}: ${error.message}`));
|
|
118
|
+
}
|
|
119
|
+
});
|
|
120
|
+
const createUmdSandbox = (pkgName, scopes) => {
|
|
121
|
+
const sandboxTarget = /* @__PURE__ */ Object.create(null);
|
|
122
|
+
const sandbox = new Proxy(sandboxTarget, {
|
|
123
|
+
get(target, key) {
|
|
124
|
+
if (typeof key === "symbol") {
|
|
125
|
+
return Reflect.get(target, key);
|
|
126
|
+
}
|
|
127
|
+
if (key in target) {
|
|
128
|
+
return target[key];
|
|
129
|
+
}
|
|
130
|
+
const value = window[key];
|
|
131
|
+
return typeof value === "function" ? value.bind(window) : value;
|
|
132
|
+
},
|
|
133
|
+
set(target, key, value) {
|
|
134
|
+
target[key] = value;
|
|
135
|
+
return true;
|
|
136
|
+
},
|
|
137
|
+
has(target, key) {
|
|
138
|
+
return key in target || key in window;
|
|
139
|
+
}
|
|
140
|
+
});
|
|
141
|
+
sandboxTarget.window = sandbox;
|
|
142
|
+
sandboxTarget.self = sandbox;
|
|
143
|
+
sandboxTarget.globalThis = sandbox;
|
|
144
|
+
sandboxTarget.global = sandbox;
|
|
145
|
+
sandboxTarget.document = window.document;
|
|
146
|
+
if (pkgName === "react-dom") {
|
|
147
|
+
sandboxTarget.React = getScopeGlobal("react", scopes);
|
|
148
|
+
}
|
|
149
|
+
return sandbox;
|
|
150
|
+
};
|
|
151
|
+
const executeUmdModule = (scriptContent, pkgName, scopes) => {
|
|
152
|
+
const sandbox = createUmdSandbox(pkgName, scopes);
|
|
153
|
+
const moduleFunction = new Function(
|
|
154
|
+
"window",
|
|
155
|
+
"self",
|
|
156
|
+
"globalThis",
|
|
157
|
+
"global",
|
|
158
|
+
"document",
|
|
159
|
+
"exports",
|
|
160
|
+
"module",
|
|
161
|
+
"define",
|
|
162
|
+
"require",
|
|
163
|
+
scriptContent
|
|
164
|
+
);
|
|
165
|
+
moduleFunction.call(
|
|
166
|
+
sandbox,
|
|
167
|
+
sandbox,
|
|
168
|
+
sandbox,
|
|
169
|
+
sandbox,
|
|
170
|
+
sandbox,
|
|
171
|
+
sandbox.document,
|
|
172
|
+
void 0,
|
|
173
|
+
void 0,
|
|
174
|
+
void 0,
|
|
175
|
+
void 0
|
|
176
|
+
);
|
|
177
|
+
return sandbox[getDefaultGlobalKey(pkgName)];
|
|
178
|
+
};
|
|
179
|
+
const loadUmdModuleSync = (pkgName, version, scopes) => executeUmdModule(
|
|
180
|
+
requestUmdSourceSync((0, import__.getUnpkgUrl)(pkgName, version)),
|
|
181
|
+
pkgName,
|
|
182
|
+
scopes
|
|
183
|
+
);
|
|
184
|
+
const loadUmdModule = (pkgName, version, scopes) => __async(exports, null, function* () {
|
|
185
|
+
return executeUmdModule(
|
|
186
|
+
yield requestUmdSource((0, import__.getUnpkgUrl)(pkgName, version)),
|
|
187
|
+
pkgName,
|
|
188
|
+
scopes
|
|
189
|
+
);
|
|
190
|
+
});
|
|
75
191
|
const getDevtoolsMessage = () => {
|
|
76
192
|
const devtoolsMessageStr = localStorage.getItem(import_constant.__FEDERATION_DEVTOOLS__);
|
|
77
193
|
if (devtoolsMessageStr) {
|
|
@@ -84,18 +200,31 @@ const getDevtoolsMessage = () => {
|
|
|
84
200
|
return null;
|
|
85
201
|
};
|
|
86
202
|
const devtoolsMessage = getDevtoolsMessage();
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
203
|
+
const eagerShareInfo = getEagerShareInfo(devtoolsMessage == null ? void 0 : devtoolsMessage[import_constant.__EAGER_SHARE__]);
|
|
204
|
+
if ((devtoolsMessage == null ? void 0 : devtoolsMessage[import_constant.__ENABLE_FAST_REFRESH__]) && eagerShareInfo) {
|
|
205
|
+
const { version, scopes } = eagerShareInfo;
|
|
206
|
+
setScopeGlobals("react", scopes, loadUmdModuleSync("react", version, scopes));
|
|
207
|
+
setScopeGlobals(
|
|
208
|
+
"react-dom",
|
|
209
|
+
scopes,
|
|
210
|
+
loadUmdModuleSync("react-dom", version, scopes)
|
|
211
|
+
);
|
|
91
212
|
}
|
|
92
213
|
const fastRefreshPlugin = () => {
|
|
214
|
+
let orderResolve;
|
|
215
|
+
const orderPromise = new Promise((resolve) => {
|
|
216
|
+
orderResolve = resolve;
|
|
217
|
+
});
|
|
93
218
|
return {
|
|
94
219
|
name: "mf-fast-refresh-plugin",
|
|
95
|
-
|
|
96
|
-
var
|
|
97
|
-
const
|
|
98
|
-
|
|
220
|
+
beforeRegisterShare(args) {
|
|
221
|
+
var _a2;
|
|
222
|
+
const { pkgName, shared } = args;
|
|
223
|
+
if (!SUPPORT_PKGS.includes(pkgName)) {
|
|
224
|
+
return args;
|
|
225
|
+
}
|
|
226
|
+
const supportPkgName = pkgName;
|
|
227
|
+
const shareScopes = getShareScopes(shared.scope);
|
|
99
228
|
let enableFastRefresh = false;
|
|
100
229
|
let devtoolsMessage2 = {};
|
|
101
230
|
const devtoolsMessageStr = localStorage.getItem(import_constant.__FEDERATION_DEVTOOLS__);
|
|
@@ -108,106 +237,91 @@ const fastRefreshPlugin = () => {
|
|
|
108
237
|
}
|
|
109
238
|
}
|
|
110
239
|
if (!enableFastRefresh) {
|
|
111
|
-
return
|
|
112
|
-
userOptions
|
|
113
|
-
}, args);
|
|
240
|
+
return args;
|
|
114
241
|
}
|
|
115
|
-
if (
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
242
|
+
if (((_a2 = shared.shareConfig) == null ? void 0 : _a2.eager) || shared.lib) {
|
|
243
|
+
if (!(devtoolsMessage2 == null ? void 0 : devtoolsMessage2[import_constant.__EAGER_SHARE__])) {
|
|
244
|
+
const eagerShareInfo2 = updateEagerShareInfo(
|
|
245
|
+
devtoolsMessage2,
|
|
246
|
+
pkgName,
|
|
247
|
+
shared.version,
|
|
248
|
+
shareScopes
|
|
249
|
+
);
|
|
250
|
+
localStorage.setItem(
|
|
251
|
+
import_constant.__FEDERATION_DEVTOOLS__,
|
|
252
|
+
JSON.stringify(devtoolsMessage2)
|
|
253
|
+
);
|
|
254
|
+
if (eagerShareInfo2.shouldReload) {
|
|
255
|
+
window.location.reload();
|
|
125
256
|
}
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
257
|
+
} else {
|
|
258
|
+
updateEagerShareInfo(
|
|
259
|
+
devtoolsMessage2,
|
|
260
|
+
pkgName,
|
|
261
|
+
shared.version,
|
|
262
|
+
shareScopes
|
|
263
|
+
);
|
|
264
|
+
localStorage.setItem(
|
|
265
|
+
import_constant.__FEDERATION_DEVTOOLS__,
|
|
266
|
+
JSON.stringify(devtoolsMessage2)
|
|
267
|
+
);
|
|
268
|
+
}
|
|
269
|
+
if (pkgName === "react-dom") {
|
|
270
|
+
shared.lib = () => getScopeGlobal(supportPkgName, shareScopes);
|
|
271
|
+
}
|
|
272
|
+
if (pkgName === "react") {
|
|
273
|
+
shared.lib = () => getScopeGlobal(supportPkgName, shareScopes);
|
|
274
|
+
}
|
|
275
|
+
return args;
|
|
276
|
+
}
|
|
277
|
+
let get;
|
|
278
|
+
if (pkgName === "react") {
|
|
279
|
+
get = () => loadUmdModule(supportPkgName, shared.version, shareScopes).then((moduleValue) => {
|
|
280
|
+
setScopeGlobals(supportPkgName, shareScopes, moduleValue);
|
|
281
|
+
return moduleValue;
|
|
282
|
+
}).then(() => {
|
|
283
|
+
orderResolve();
|
|
284
|
+
});
|
|
285
|
+
}
|
|
286
|
+
if (pkgName === "react-dom") {
|
|
287
|
+
get = () => orderPromise.then(
|
|
288
|
+
() => loadUmdModule(supportPkgName, shared.version, shareScopes)
|
|
289
|
+
).then((result) => {
|
|
290
|
+
setScopeGlobals(supportPkgName, shareScopes, result);
|
|
291
|
+
return result;
|
|
292
|
+
});
|
|
293
|
+
}
|
|
294
|
+
if (typeof get === "function") {
|
|
295
|
+
const finalGet = get;
|
|
296
|
+
if (pkgName === "react") {
|
|
297
|
+
shared.get = () => __async(this, null, function* () {
|
|
298
|
+
if (!getScopeGlobal(supportPkgName, shareScopes)) {
|
|
299
|
+
yield finalGet();
|
|
300
|
+
console.warn(
|
|
301
|
+
"[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
302
|
);
|
|
168
303
|
}
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
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
|
-
}
|
|
304
|
+
shared.lib = () => getScopeGlobal(supportPkgName, shareScopes);
|
|
305
|
+
return () => getScopeGlobal(supportPkgName, shareScopes);
|
|
306
|
+
});
|
|
307
|
+
}
|
|
308
|
+
if (pkgName === "react-dom") {
|
|
309
|
+
shared.get = () => __async(this, null, function* () {
|
|
310
|
+
if (!getScopeGlobal(supportPkgName, shareScopes)) {
|
|
311
|
+
yield finalGet();
|
|
194
312
|
}
|
|
313
|
+
shared.lib = () => getScopeGlobal(supportPkgName, shareScopes);
|
|
314
|
+
return () => getScopeGlobal(supportPkgName, shareScopes);
|
|
195
315
|
});
|
|
196
|
-
}
|
|
197
|
-
return __spreadValues({
|
|
198
|
-
userOptions
|
|
199
|
-
}, args);
|
|
200
|
-
} else {
|
|
201
|
-
return __spreadValues({
|
|
202
|
-
userOptions
|
|
203
|
-
}, args);
|
|
316
|
+
}
|
|
204
317
|
}
|
|
318
|
+
return args;
|
|
205
319
|
}
|
|
206
320
|
};
|
|
207
321
|
};
|
|
208
322
|
if (!(window == null ? void 0 : window.__FEDERATION__)) {
|
|
209
|
-
(0,
|
|
210
|
-
(0,
|
|
323
|
+
(0, import_sdk.definePropertyGlobalVal)(window, "__FEDERATION__", {});
|
|
324
|
+
(0, import_sdk.definePropertyGlobalVal)(window, "__VMOK__", window.__FEDERATION__);
|
|
211
325
|
}
|
|
212
326
|
if (!(window == null ? void 0 : window.__FEDERATION__.__GLOBAL_PLUGIN__)) {
|
|
213
327
|
window.__FEDERATION__.__GLOBAL_PLUGIN__ = [];
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
"use strict";
|
|
2
1
|
var __defProp = Object.defineProperty;
|
|
3
2
|
var __defProps = Object.defineProperties;
|
|
4
3
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
@@ -66,6 +65,7 @@ __export(chrome_exports, {
|
|
|
66
65
|
injectPostMessage: () => injectPostMessage,
|
|
67
66
|
injectScript: () => injectScript,
|
|
68
67
|
injectToast: () => injectToast,
|
|
68
|
+
normalizeModuleInfoPayload: () => normalizeModuleInfoPayload,
|
|
69
69
|
refreshModuleInfo: () => refreshModuleInfo,
|
|
70
70
|
setChromeStorage: () => setChromeStorage,
|
|
71
71
|
setTargetTab: () => setTargetTab,
|
|
@@ -74,7 +74,25 @@ __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);
|
|
79
|
+
const isModuleInfoRecord = (value) => Boolean(value) && typeof value === "object" && !Array.isArray(value);
|
|
80
|
+
const isModuleInfoSyncMessage = (value) => isModuleInfoRecord(value) && ("moduleInfo" in value || "updateModule" in value || "share" in value);
|
|
81
|
+
const normalizeModuleInfoPayload = (moduleInfo) => {
|
|
82
|
+
const sanitized = (0, import_safe_post_message.sanitizePostMessagePayload)(moduleInfo);
|
|
83
|
+
if (!isModuleInfoRecord(sanitized)) {
|
|
84
|
+
return {};
|
|
85
|
+
}
|
|
86
|
+
return Object.entries(sanitized).reduce(
|
|
87
|
+
(moduleMap, [moduleId, snapshot]) => {
|
|
88
|
+
if (moduleId === "extendInfos" || isModuleInfoRecord(snapshot)) {
|
|
89
|
+
moduleMap[moduleId] = snapshot;
|
|
90
|
+
}
|
|
91
|
+
return moduleMap;
|
|
92
|
+
},
|
|
93
|
+
{}
|
|
94
|
+
);
|
|
95
|
+
};
|
|
78
96
|
const sleep = (num) => {
|
|
79
97
|
return new Promise((resolve) => {
|
|
80
98
|
setTimeout(() => {
|
|
@@ -104,10 +122,11 @@ const syncActiveTab = (tabId) => __async(void 0, null, function* () {
|
|
|
104
122
|
setTargetTab(tab);
|
|
105
123
|
return tab;
|
|
106
124
|
}
|
|
107
|
-
const
|
|
125
|
+
const tabs = yield getTabs({
|
|
108
126
|
active: true,
|
|
109
127
|
lastFocusedWindow: true
|
|
110
128
|
});
|
|
129
|
+
const activeTab = Array.isArray(tabs) ? tabs[0] : void 0;
|
|
111
130
|
setTargetTab(activeTab);
|
|
112
131
|
return activeTab;
|
|
113
132
|
} catch (error) {
|
|
@@ -130,9 +149,7 @@ function getInspectWindowTabId() {
|
|
|
130
149
|
function(info, error) {
|
|
131
150
|
const { tabId } = chrome.devtools.inspectedWindow;
|
|
132
151
|
getTabs().then((tabs) => {
|
|
133
|
-
const target = tabs.find(
|
|
134
|
-
(tab) => tab.id === tabId
|
|
135
|
-
);
|
|
152
|
+
const target = Array.isArray(tabs) ? tabs.find((tab) => tab.id === tabId) : void 0;
|
|
136
153
|
setTargetTab(target);
|
|
137
154
|
});
|
|
138
155
|
console.log(
|
|
@@ -168,43 +185,45 @@ const refreshModuleInfo = () => __async(void 0, null, function* () {
|
|
|
168
185
|
const getGlobalModuleInfo = (callback) => __async(void 0, null, function* () {
|
|
169
186
|
var _a, _b;
|
|
170
187
|
if (typeof window !== "undefined" && ((_a = window.__FEDERATION__) == null ? void 0 : _a.moduleInfo)) {
|
|
171
|
-
callback(
|
|
172
|
-
JSON.parse(
|
|
173
|
-
JSON.stringify((_b = window.__FEDERATION__) == null ? void 0 : _b.moduleInfo)
|
|
174
|
-
)
|
|
175
|
-
);
|
|
188
|
+
callback(normalizeModuleInfoPayload((_b = window.__FEDERATION__) == null ? void 0 : _b.moduleInfo));
|
|
176
189
|
}
|
|
177
190
|
yield sleep(300);
|
|
178
191
|
const listener = (message) => {
|
|
179
192
|
const { data } = message;
|
|
180
|
-
if (!data || (data == null ? void 0 : data.appInfos)) {
|
|
193
|
+
if (!isModuleInfoSyncMessage(data) || (data == null ? void 0 : data.appInfos)) {
|
|
181
194
|
return;
|
|
182
195
|
}
|
|
183
196
|
if (!(window == null ? void 0 : window.__FEDERATION__)) {
|
|
184
197
|
(0, import_sdk2.definePropertyGlobalVal)(window, "__FEDERATION__", {});
|
|
185
198
|
(0, import_sdk2.definePropertyGlobalVal)(window, "__VMOK__", window.__FEDERATION__);
|
|
186
199
|
}
|
|
187
|
-
window.__FEDERATION__.originModuleInfo =
|
|
188
|
-
|
|
200
|
+
window.__FEDERATION__.originModuleInfo = "moduleInfo" in data ? normalizeModuleInfoPayload(data.moduleInfo) : normalizeModuleInfoPayload(
|
|
201
|
+
window.__FEDERATION__.originModuleInfo || window.__FEDERATION__.moduleInfo
|
|
189
202
|
);
|
|
190
|
-
|
|
203
|
+
const updateModule = data.updateModule;
|
|
204
|
+
if (isModuleInfoRecord(updateModule) && typeof updateModule.name === "string") {
|
|
205
|
+
const updateModuleName = updateModule.name;
|
|
191
206
|
const moduleIds = Object.keys(window.__FEDERATION__.originModuleInfo);
|
|
192
207
|
const shouldUpdate = !moduleIds.some(
|
|
193
|
-
(id) => id.includes(
|
|
208
|
+
(id) => id.includes(updateModuleName)
|
|
194
209
|
);
|
|
195
210
|
if (shouldUpdate) {
|
|
196
|
-
const destination =
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
211
|
+
const destination = typeof updateModule.entry === "string" ? updateModule.entry : typeof updateModule.version === "string" ? updateModule.version : void 0;
|
|
212
|
+
if (destination) {
|
|
213
|
+
window.__FEDERATION__.originModuleInfo[`${updateModuleName}:${destination}`] = {
|
|
214
|
+
remoteEntry: destination,
|
|
215
|
+
version: destination
|
|
216
|
+
};
|
|
217
|
+
}
|
|
201
218
|
}
|
|
202
219
|
}
|
|
203
220
|
if (data == null ? void 0 : data.share) {
|
|
204
|
-
window.__FEDERATION__.__SHARE__ =
|
|
221
|
+
window.__FEDERATION__.__SHARE__ = (0, import_safe_post_message.sanitizePostMessagePayload)(
|
|
222
|
+
data.share
|
|
223
|
+
);
|
|
205
224
|
}
|
|
206
|
-
window.__FEDERATION__.moduleInfo =
|
|
207
|
-
|
|
225
|
+
window.__FEDERATION__.moduleInfo = normalizeModuleInfoPayload(
|
|
226
|
+
window.__FEDERATION__.originModuleInfo
|
|
208
227
|
);
|
|
209
228
|
console.log("getGlobalModuleInfo window", window.__FEDERATION__);
|
|
210
229
|
callback(window.__FEDERATION__.moduleInfo);
|
|
@@ -293,6 +312,7 @@ const setChromeStorage = (formData) => {
|
|
|
293
312
|
injectPostMessage,
|
|
294
313
|
injectScript,
|
|
295
314
|
injectToast,
|
|
315
|
+
normalizeModuleInfoPayload,
|
|
296
316
|
refreshModuleInfo,
|
|
297
317
|
setChromeStorage,
|
|
298
318
|
setTargetTab,
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
"use strict";
|
|
2
1
|
var __defProp = Object.defineProperty;
|
|
3
2
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
3
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
@@ -19,13 +18,22 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
19
18
|
var messages_exports = {};
|
|
20
19
|
__export(messages_exports, {
|
|
21
20
|
MESSAGE_ACTIVE_TAB_CHANGED: () => MESSAGE_ACTIVE_TAB_CHANGED,
|
|
22
|
-
|
|
21
|
+
MESSAGE_OBSERVABILITY_DEVTOOLS_EVENT: () => MESSAGE_OBSERVABILITY_DEVTOOLS_EVENT,
|
|
22
|
+
MESSAGE_OPEN_SIDE_PANEL: () => MESSAGE_OPEN_SIDE_PANEL,
|
|
23
|
+
OBSERVABILITY_DEVTOOLS_SOURCE: () => OBSERVABILITY_DEVTOOLS_SOURCE,
|
|
24
|
+
OBSERVABILITY_DEVTOOLS_STORAGE_KEY: () => OBSERVABILITY_DEVTOOLS_STORAGE_KEY
|
|
23
25
|
});
|
|
24
26
|
module.exports = __toCommonJS(messages_exports);
|
|
25
27
|
const MESSAGE_OPEN_SIDE_PANEL = "mf-devtools/open-side-panel";
|
|
26
28
|
const MESSAGE_ACTIVE_TAB_CHANGED = "mf-devtools/active-tab-changed";
|
|
29
|
+
const MESSAGE_OBSERVABILITY_DEVTOOLS_EVENT = "mf-devtools/observability-event";
|
|
30
|
+
const OBSERVABILITY_DEVTOOLS_SOURCE = "module-federation/observability";
|
|
31
|
+
const OBSERVABILITY_DEVTOOLS_STORAGE_KEY = "__MF_DEVTOOLS_OBSERVABILITY_CONFIG__";
|
|
27
32
|
// Annotate the CommonJS export names for ESM import in node:
|
|
28
33
|
0 && (module.exports = {
|
|
29
34
|
MESSAGE_ACTIVE_TAB_CHANGED,
|
|
30
|
-
|
|
35
|
+
MESSAGE_OBSERVABILITY_DEVTOOLS_EVENT,
|
|
36
|
+
MESSAGE_OPEN_SIDE_PANEL,
|
|
37
|
+
OBSERVABILITY_DEVTOOLS_SOURCE,
|
|
38
|
+
OBSERVABILITY_DEVTOOLS_STORAGE_KEY
|
|
31
39
|
});
|