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