@module-federation/devtools 0.22.0 → 0.23.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/es/App.css +13 -0
- package/dist/es/App.js +461 -21
- package/dist/es/App.module.js +1 -1
- package/dist/es/App_module.css +293 -5
- package/dist/es/component/DependencyGraph/index.js +204 -0
- package/dist/es/component/DependencyGraph/index.module.js +5 -0
- package/dist/es/component/DependencyGraph/index_module.css +100 -0
- package/dist/es/component/{GraphItem → DependencyGraphItem}/index.js +20 -9
- package/dist/es/component/DependencyGraphItem/index.module.js +5 -0
- package/dist/es/component/DependencyGraphItem/index_module.css +95 -0
- package/dist/es/component/Form/index.js +192 -117
- package/dist/es/component/Form/index.module.js +1 -1
- package/dist/es/component/Form/index_module.css +176 -25
- package/dist/es/component/LanguageSwitch.js +50 -0
- package/dist/es/component/Layout/index.js +296 -49
- package/dist/es/component/Layout/index.module.js +1 -1
- package/dist/es/component/Layout/index_module.css +52 -32
- package/dist/es/component/ModuleInfo/index.js +313 -0
- package/dist/es/component/ModuleInfo/index.module.js +5 -0
- package/dist/es/component/ModuleInfo/index_module.css +184 -0
- package/dist/es/component/SharedDepsExplorer/FocusResultDisplay.js +35 -0
- package/dist/es/component/SharedDepsExplorer/FocusResultDisplay.module.js +5 -0
- package/dist/es/component/SharedDepsExplorer/FocusResultDisplay_module.css +45 -0
- package/dist/es/component/SharedDepsExplorer/index.js +495 -0
- package/dist/es/component/SharedDepsExplorer/index.module.js +5 -0
- package/dist/es/component/SharedDepsExplorer/index_module.css +467 -0
- package/dist/es/component/SharedDepsExplorer/share-utils.js +206 -0
- 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 +506 -0
- package/dist/es/template/constant.js +3 -19
- package/dist/es/utils/chrome/index.js +91 -38
- package/dist/es/utils/chrome/messages.js +6 -0
- package/dist/es/utils/chrome/override-remote.js +42 -0
- package/dist/es/utils/chrome/post-message-listener.js +2 -1
- package/dist/es/utils/chrome/post-message-start.js +10 -2
- package/dist/es/utils/chrome/storage.js +6 -1
- package/dist/es/utils/sdk/graph.js +25 -4
- package/dist/es/utils/sdk/index.js +9 -0
- package/dist/es/worker/index.js +168 -1
- package/dist/lib/App.css +13 -0
- package/dist/lib/App.js +451 -18
- package/dist/lib/App.module.js +1 -1
- package/dist/lib/App_module.css +293 -5
- package/dist/lib/component/DependencyGraph/index.js +226 -0
- package/dist/lib/component/{GraphItem → DependencyGraph}/index.module.js +1 -1
- package/dist/lib/component/DependencyGraph/index_module.css +100 -0
- package/dist/lib/component/{GraphItem → DependencyGraphItem}/index.js +23 -12
- package/dist/lib/component/{Graph → DependencyGraphItem}/index.module.js +1 -1
- package/dist/lib/component/DependencyGraphItem/index_module.css +95 -0
- package/dist/lib/component/Form/index.js +189 -115
- package/dist/lib/component/Form/index.module.js +1 -1
- package/dist/lib/component/Form/index_module.css +176 -25
- package/dist/lib/component/LanguageSwitch.js +80 -0
- package/dist/lib/component/Layout/index.js +290 -47
- package/dist/lib/component/Layout/index.module.js +1 -1
- package/dist/lib/component/Layout/index_module.css +52 -32
- package/dist/lib/component/ModuleInfo/index.js +343 -0
- package/dist/lib/component/ModuleInfo/index.module.js +25 -0
- package/dist/lib/component/ModuleInfo/index_module.css +184 -0
- package/dist/lib/component/SharedDepsExplorer/FocusResultDisplay.js +65 -0
- package/dist/lib/component/SharedDepsExplorer/FocusResultDisplay.module.js +25 -0
- package/dist/lib/component/SharedDepsExplorer/FocusResultDisplay_module.css +45 -0
- package/dist/lib/component/SharedDepsExplorer/index.js +502 -0
- package/dist/lib/component/SharedDepsExplorer/index.module.js +25 -0
- package/dist/lib/component/SharedDepsExplorer/index_module.css +467 -0
- package/dist/lib/component/SharedDepsExplorer/share-utils.js +237 -0
- package/dist/lib/component/ThemeToggle.js +49 -0
- package/dist/lib/component/ThemeToggle.module.js +25 -0
- package/dist/lib/component/ThemeToggle_module.css +12 -0
- package/dist/lib/hooks/useDevtoolsTheme.js +101 -0
- package/dist/lib/i18n/index.js +540 -0
- package/dist/lib/template/constant.js +4 -17
- package/dist/lib/utils/chrome/index.js +94 -38
- package/dist/lib/utils/chrome/messages.js +31 -0
- package/dist/lib/utils/chrome/override-remote.js +65 -0
- package/dist/lib/utils/chrome/post-message-listener.js +2 -1
- package/dist/lib/utils/chrome/post-message-start.js +10 -2
- package/dist/lib/utils/chrome/storage.js +5 -0
- package/dist/lib/utils/sdk/graph.js +25 -4
- package/dist/lib/utils/sdk/index.js +10 -0
- package/dist/lib/worker/index.js +156 -1
- package/dist/types/src/App.d.ts +2 -1
- package/dist/types/src/component/{Graph → DependencyGraph}/index.d.ts +0 -1
- package/dist/types/src/component/{GraphItem → DependencyGraphItem}/index.d.ts +0 -1
- package/dist/types/src/component/Form/index.d.ts +2 -0
- package/dist/types/src/component/LanguageSwitch.d.ts +2 -0
- package/dist/types/src/component/Layout/index.d.ts +0 -1
- package/dist/types/src/component/ModuleInfo/index.d.ts +8 -0
- package/dist/types/src/component/SharedDepsExplorer/FocusResultDisplay.d.ts +15 -0
- package/dist/types/src/component/SharedDepsExplorer/index.d.ts +6 -0
- package/dist/types/src/component/SharedDepsExplorer/share-utils.d.ts +44 -0
- 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/init.d.ts +0 -1
- package/dist/types/src/template/constant.d.ts +2 -5
- package/dist/types/src/utils/chrome/index.d.ts +5 -3
- package/dist/types/src/utils/chrome/messages.d.ts +2 -0
- package/dist/types/src/utils/chrome/override-remote.d.ts +1 -0
- package/dist/types/src/utils/chrome/storage.d.ts +5 -4
- package/dist/types/src/utils/sdk/graph.d.ts +2 -1
- package/dist/types/src/utils/sdk/index.d.ts +1 -0
- package/dist/types/src/utils/types/common.d.ts +4 -0
- package/dist/types/src/worker/index.d.ts +1 -0
- package/package.json +18 -14
- package/dist/es/component/Graph/index.js +0 -127
- package/dist/es/component/Graph/index.module.js +0 -5
- package/dist/es/component/Graph/index_module.css +0 -12
- package/dist/es/component/GraphItem/index.module.js +0 -5
- package/dist/es/component/GraphItem/index_module.css +0 -61
- package/dist/lib/component/Graph/index.js +0 -149
- package/dist/lib/component/Graph/index_module.css +0 -12
- package/dist/lib/component/GraphItem/index_module.css +0 -61
package/dist/es/App.css
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
.loaded-status-tag {
|
|
2
|
+
color: var(--color-bg-1, white) !important;
|
|
3
|
+
background-color: var(--color-neutral-10, black) !important;
|
|
4
|
+
}
|
|
5
|
+
.reused-status-tag {
|
|
6
|
+
background-color: greenyellow !important;
|
|
7
|
+
color: black !important;
|
|
8
|
+
}
|
|
9
|
+
.common-tag {
|
|
10
|
+
color: var(--color-text-2, #71717a) !important;
|
|
11
|
+
background-color: var(--color-bg-1, #ffffff) !important;
|
|
12
|
+
border-color: var(--color-border-2, rgba(228, 228, 231, 0.5)) !important;
|
|
13
|
+
}
|
package/dist/es/App.js
CHANGED
|
@@ -1,14 +1,128 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
3
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
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 __async = (__this, __arguments, generator) => {
|
|
18
|
+
return new Promise((resolve, reject) => {
|
|
19
|
+
var fulfilled = (value) => {
|
|
20
|
+
try {
|
|
21
|
+
step(generator.next(value));
|
|
22
|
+
} catch (e) {
|
|
23
|
+
reject(e);
|
|
24
|
+
}
|
|
25
|
+
};
|
|
26
|
+
var rejected = (value) => {
|
|
27
|
+
try {
|
|
28
|
+
step(generator.throw(value));
|
|
29
|
+
} catch (e) {
|
|
30
|
+
reject(e);
|
|
31
|
+
}
|
|
32
|
+
};
|
|
33
|
+
var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
|
|
34
|
+
step((generator = generator.apply(__this, __arguments)).next());
|
|
35
|
+
});
|
|
36
|
+
};
|
|
37
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
38
|
+
import { useState, useEffect, useMemo, useCallback, useRef } from "react";
|
|
39
|
+
import "@arco-design/web-react/es/_util/react-19-adapter";
|
|
40
|
+
import "./App.css";
|
|
41
|
+
import { Empty, Tag, Button, Tooltip } from "@arco-design/web-react";
|
|
42
|
+
import { I18nextProvider, useTranslation } from "react-i18next";
|
|
4
43
|
import "./init";
|
|
44
|
+
import { IconRefresh } from "@arco-design/web-react/icon";
|
|
5
45
|
import ProxyLayout from "./component/Layout";
|
|
6
|
-
import
|
|
46
|
+
import Dependency from "./component/DependencyGraph";
|
|
47
|
+
import ModuleInfo from "./component/ModuleInfo";
|
|
48
|
+
import SharedDepsExplorer from "./component/SharedDepsExplorer";
|
|
49
|
+
import LanguageSwitch from "./component/LanguageSwitch";
|
|
50
|
+
import ThemeToggle from "./component/ThemeToggle";
|
|
51
|
+
import {
|
|
52
|
+
getGlobalModuleInfo,
|
|
53
|
+
refreshModuleInfo,
|
|
54
|
+
separateType,
|
|
55
|
+
syncActiveTab
|
|
56
|
+
} from "./utils";
|
|
57
|
+
import { MESSAGE_ACTIVE_TAB_CHANGED } from "./utils/chrome/messages";
|
|
58
|
+
import { useDevtoolsTheme } from "./hooks/useDevtoolsTheme";
|
|
59
|
+
import i18n from "./i18n";
|
|
7
60
|
import "@arco-design/web-react/dist/css/arco.css";
|
|
8
61
|
import styles from "./App.module";
|
|
9
|
-
|
|
10
|
-
const
|
|
11
|
-
|
|
62
|
+
import btnStyles from "./component/ThemeToggle.module";
|
|
63
|
+
const cloneModuleInfo = (info) => {
|
|
64
|
+
try {
|
|
65
|
+
return JSON.parse(JSON.stringify(info || {}));
|
|
66
|
+
} catch (error) {
|
|
67
|
+
console.warn("[MF Devtools] cloneModuleInfo failed", error);
|
|
68
|
+
return info || {};
|
|
69
|
+
}
|
|
70
|
+
};
|
|
71
|
+
const normalizeShareValue = (target, seen = /* @__PURE__ */ new WeakSet()) => {
|
|
72
|
+
if (typeof target === "function") {
|
|
73
|
+
const name = target.name ? `: ${target.name}` : "";
|
|
74
|
+
return `[Function${name}]`;
|
|
75
|
+
}
|
|
76
|
+
if (!target || typeof target !== "object") {
|
|
77
|
+
return target;
|
|
78
|
+
}
|
|
79
|
+
if (seen.has(target)) {
|
|
80
|
+
return "[Circular]";
|
|
81
|
+
}
|
|
82
|
+
seen.add(target);
|
|
83
|
+
if (target instanceof Map) {
|
|
84
|
+
const mapped = {};
|
|
85
|
+
target.forEach((value, key) => {
|
|
86
|
+
mapped[String(key)] = normalizeShareValue(value, seen);
|
|
87
|
+
});
|
|
88
|
+
return mapped;
|
|
89
|
+
}
|
|
90
|
+
if (target instanceof Set) {
|
|
91
|
+
const setItems = [];
|
|
92
|
+
target.forEach((value) => {
|
|
93
|
+
setItems.push(normalizeShareValue(value, seen));
|
|
94
|
+
});
|
|
95
|
+
return setItems;
|
|
96
|
+
}
|
|
97
|
+
if (Array.isArray(target)) {
|
|
98
|
+
return target.map((item) => normalizeShareValue(item, seen));
|
|
99
|
+
}
|
|
100
|
+
return Object.keys(target).reduce((memo, key) => {
|
|
101
|
+
memo[key] = normalizeShareValue(target[key], seen);
|
|
102
|
+
return memo;
|
|
103
|
+
}, {});
|
|
104
|
+
};
|
|
105
|
+
const buildShareSnapshot = (share) => {
|
|
106
|
+
const normalize = (value) => {
|
|
107
|
+
try {
|
|
108
|
+
return normalizeShareValue(value);
|
|
109
|
+
} catch (error) {
|
|
110
|
+
console.warn("[MF Devtools] normalize share snapshot failed", error);
|
|
111
|
+
return normalizeShareValue(value);
|
|
112
|
+
}
|
|
113
|
+
};
|
|
114
|
+
const scopes = normalize(share || {});
|
|
115
|
+
return scopes;
|
|
116
|
+
};
|
|
117
|
+
const NAV_ITEMS = [
|
|
118
|
+
{ key: "moduleInfo", i18nKey: "app.nav.moduleInfo" },
|
|
119
|
+
{ key: "proxy", i18nKey: "app.nav.proxy" },
|
|
120
|
+
{ key: "dependency", i18nKey: "app.nav.dependency" },
|
|
121
|
+
{ key: "share", i18nKey: "app.nav.share" },
|
|
122
|
+
{ key: "performance", i18nKey: "app.nav.performance" }
|
|
123
|
+
];
|
|
124
|
+
const THEME_STORAGE_KEY = "mf-devtools-theme";
|
|
125
|
+
const InnerApp = (props) => {
|
|
12
126
|
const {
|
|
13
127
|
versionList,
|
|
14
128
|
setVersionList,
|
|
@@ -18,23 +132,349 @@ const App = (props) => {
|
|
|
18
132
|
customValueValidate,
|
|
19
133
|
headerSlot
|
|
20
134
|
} = props;
|
|
21
|
-
const
|
|
135
|
+
const autoTheme = useDevtoolsTheme();
|
|
136
|
+
const [userTheme, setUserTheme] = useState(null);
|
|
137
|
+
const effectiveTheme = userTheme != null ? userTheme : autoTheme;
|
|
138
|
+
const { t } = useTranslation();
|
|
139
|
+
const [moduleInfo, setModuleInfo] = useState(
|
|
140
|
+
() => {
|
|
141
|
+
var _a;
|
|
142
|
+
return cloneModuleInfo(((_a = window.__FEDERATION__) == null ? void 0 : _a.moduleInfo) || {});
|
|
143
|
+
}
|
|
144
|
+
);
|
|
145
|
+
const [shareInfo, setShareInfo] = useState(
|
|
146
|
+
() => {
|
|
147
|
+
var _a;
|
|
148
|
+
return buildShareSnapshot((_a = window.__FEDERATION__) == null ? void 0 : _a.__SHARE__);
|
|
149
|
+
}
|
|
150
|
+
);
|
|
151
|
+
const [inspectedTab, setInspectedTab] = useState(
|
|
152
|
+
window.targetTab
|
|
153
|
+
);
|
|
154
|
+
const [activePanel, setActivePanel] = useState("proxy");
|
|
155
|
+
const [selectedModuleId, setSelectedModuleId] = useState(null);
|
|
156
|
+
const [refreshing, setRefreshing] = useState(false);
|
|
157
|
+
const panelSyncReadyRef = useRef(false);
|
|
158
|
+
const applyModuleUpdate = useCallback((info) => {
|
|
159
|
+
var _a;
|
|
160
|
+
setModuleInfo(cloneModuleInfo(info));
|
|
161
|
+
const shareSnapshot = buildShareSnapshot(
|
|
162
|
+
(_a = window.__FEDERATION__) == null ? void 0 : _a.__SHARE__
|
|
163
|
+
);
|
|
164
|
+
setShareInfo(shareSnapshot);
|
|
165
|
+
panelSyncReadyRef.current = true;
|
|
166
|
+
}, []);
|
|
167
|
+
const { producer, consumers } = useMemo(
|
|
168
|
+
() => separateType(moduleInfo),
|
|
169
|
+
[moduleInfo]
|
|
170
|
+
);
|
|
171
|
+
const moduleKeys = useMemo(() => Object.keys(moduleInfo || {}), [moduleInfo]);
|
|
172
|
+
const moduleCount = moduleKeys.length;
|
|
173
|
+
const consumerCount = useMemo(
|
|
174
|
+
() => Object.keys(consumers || {}).length,
|
|
175
|
+
[consumers]
|
|
176
|
+
);
|
|
177
|
+
const hasModule = moduleCount > 0 || process.env.NODE_ENV === "development";
|
|
22
178
|
useEffect(() => {
|
|
23
|
-
|
|
179
|
+
var _a;
|
|
180
|
+
if (typeof window === "undefined") {
|
|
181
|
+
return;
|
|
182
|
+
}
|
|
183
|
+
let cancelled = false;
|
|
184
|
+
const applyTheme = (value) => {
|
|
185
|
+
if (cancelled) {
|
|
186
|
+
return;
|
|
187
|
+
}
|
|
188
|
+
if (value === "light" || value === "dark") {
|
|
189
|
+
setUserTheme(value);
|
|
190
|
+
}
|
|
191
|
+
};
|
|
192
|
+
try {
|
|
193
|
+
const stored = window.localStorage.getItem(THEME_STORAGE_KEY);
|
|
194
|
+
if (stored === "light" || stored === "dark") {
|
|
195
|
+
applyTheme(stored);
|
|
196
|
+
return;
|
|
197
|
+
}
|
|
198
|
+
} catch (error) {
|
|
199
|
+
console.warn("[MF Devtools] read theme from localStorage failed", error);
|
|
200
|
+
}
|
|
201
|
+
try {
|
|
202
|
+
const chromeObj = window.chrome;
|
|
203
|
+
const storage = (_a = chromeObj == null ? void 0 : chromeObj.storage) == null ? void 0 : _a.sync;
|
|
204
|
+
if (storage && typeof storage.get === "function") {
|
|
205
|
+
storage.get([THEME_STORAGE_KEY], (result) => {
|
|
206
|
+
applyTheme(result == null ? void 0 : result[THEME_STORAGE_KEY]);
|
|
207
|
+
});
|
|
208
|
+
}
|
|
209
|
+
} catch (error) {
|
|
210
|
+
console.warn(
|
|
211
|
+
"[MF Devtools] read theme from chrome.storage.sync failed",
|
|
212
|
+
error
|
|
213
|
+
);
|
|
214
|
+
}
|
|
215
|
+
return () => {
|
|
216
|
+
cancelled = true;
|
|
217
|
+
};
|
|
24
218
|
}, []);
|
|
25
|
-
|
|
26
|
-
|
|
219
|
+
useEffect(() => {
|
|
220
|
+
if (typeof document === "undefined") {
|
|
221
|
+
return;
|
|
222
|
+
}
|
|
223
|
+
const { body } = document;
|
|
224
|
+
if (!body) {
|
|
225
|
+
return;
|
|
226
|
+
}
|
|
227
|
+
if (effectiveTheme === "dark") {
|
|
228
|
+
body.setAttribute("arco-theme", "dark");
|
|
229
|
+
} else {
|
|
230
|
+
body.removeAttribute("arco-theme");
|
|
231
|
+
}
|
|
232
|
+
return () => {
|
|
233
|
+
body.removeAttribute("arco-theme");
|
|
234
|
+
};
|
|
235
|
+
}, [effectiveTheme]);
|
|
236
|
+
useEffect(() => {
|
|
237
|
+
if (!moduleKeys.length) {
|
|
238
|
+
setSelectedModuleId(null);
|
|
239
|
+
return;
|
|
240
|
+
}
|
|
241
|
+
if (!selectedModuleId || !moduleKeys.includes(selectedModuleId)) {
|
|
242
|
+
setSelectedModuleId(moduleKeys[0]);
|
|
243
|
+
}
|
|
244
|
+
}, [moduleKeys, selectedModuleId]);
|
|
245
|
+
useEffect(() => {
|
|
246
|
+
const bootstrap = () => __async(void 0, null, function* () {
|
|
247
|
+
const tab = yield syncActiveTab();
|
|
248
|
+
setInspectedTab(tab || void 0);
|
|
249
|
+
const detach = yield getGlobalModuleInfo(
|
|
250
|
+
(info) => applyModuleUpdate(info)
|
|
251
|
+
);
|
|
252
|
+
panelSyncReadyRef.current = true;
|
|
253
|
+
return detach;
|
|
254
|
+
});
|
|
255
|
+
const cleanupPromise = bootstrap();
|
|
256
|
+
return () => {
|
|
257
|
+
cleanupPromise.then((cleanup) => cleanup == null ? void 0 : cleanup());
|
|
258
|
+
};
|
|
259
|
+
}, [applyModuleUpdate]);
|
|
260
|
+
useEffect(() => {
|
|
261
|
+
const updateActiveTab = (tabId) => __async(void 0, null, function* () {
|
|
262
|
+
var _a, _b;
|
|
263
|
+
const tab = yield syncActiveTab(tabId);
|
|
264
|
+
setInspectedTab(tab || void 0);
|
|
265
|
+
if ((_a = window.__FEDERATION__) == null ? void 0 : _a.moduleInfo) {
|
|
266
|
+
applyModuleUpdate(cloneModuleInfo((_b = window.__FEDERATION__) == null ? void 0 : _b.moduleInfo));
|
|
267
|
+
}
|
|
268
|
+
yield refreshModuleInfo();
|
|
269
|
+
});
|
|
270
|
+
const onMessage = (message, _sender, _sendResponse) => {
|
|
271
|
+
if ((message == null ? void 0 : message.type) === MESSAGE_ACTIVE_TAB_CHANGED) {
|
|
272
|
+
updateActiveTab(message.tabId);
|
|
273
|
+
}
|
|
274
|
+
};
|
|
275
|
+
chrome.runtime.onMessage.addListener(onMessage);
|
|
276
|
+
const onActivated = (activeInfo) => {
|
|
277
|
+
updateActiveTab(activeInfo.tabId);
|
|
278
|
+
};
|
|
279
|
+
chrome.tabs.onActivated.addListener(onActivated);
|
|
280
|
+
return () => {
|
|
281
|
+
chrome.runtime.onMessage.removeListener(onMessage);
|
|
282
|
+
chrome.tabs.onActivated.removeListener(onActivated);
|
|
283
|
+
};
|
|
284
|
+
}, [applyModuleUpdate]);
|
|
285
|
+
const handleRefresh = () => __async(void 0, null, function* () {
|
|
286
|
+
var _a, _b;
|
|
287
|
+
if (refreshing) {
|
|
288
|
+
return;
|
|
289
|
+
}
|
|
290
|
+
setRefreshing(true);
|
|
291
|
+
try {
|
|
292
|
+
yield refreshModuleInfo();
|
|
293
|
+
if ((_a = window.__FEDERATION__) == null ? void 0 : _a.moduleInfo) {
|
|
294
|
+
applyModuleUpdate(cloneModuleInfo((_b = window.__FEDERATION__) == null ? void 0 : _b.moduleInfo));
|
|
295
|
+
}
|
|
296
|
+
} finally {
|
|
297
|
+
setRefreshing(false);
|
|
298
|
+
}
|
|
299
|
+
});
|
|
300
|
+
const handleThemeToggle = () => {
|
|
301
|
+
var _a;
|
|
302
|
+
const current = effectiveTheme;
|
|
303
|
+
const next = current === "dark" ? "light" : "dark";
|
|
304
|
+
setUserTheme(next);
|
|
305
|
+
if (typeof window !== "undefined") {
|
|
306
|
+
try {
|
|
307
|
+
window.localStorage.setItem(THEME_STORAGE_KEY, next);
|
|
308
|
+
} catch (error) {
|
|
309
|
+
console.warn(
|
|
310
|
+
"[MF Devtools] persist theme to localStorage failed",
|
|
311
|
+
error
|
|
312
|
+
);
|
|
313
|
+
}
|
|
314
|
+
try {
|
|
315
|
+
const chromeObj = window.chrome;
|
|
316
|
+
const storage = (_a = chromeObj == null ? void 0 : chromeObj.storage) == null ? void 0 : _a.sync;
|
|
317
|
+
if (storage && typeof storage.set === "function") {
|
|
318
|
+
storage.set({ [THEME_STORAGE_KEY]: next });
|
|
319
|
+
}
|
|
320
|
+
} catch (error) {
|
|
321
|
+
console.warn(
|
|
322
|
+
"[MF Devtools] persist theme to chrome.storage.sync failed",
|
|
323
|
+
error
|
|
324
|
+
);
|
|
325
|
+
}
|
|
326
|
+
}
|
|
327
|
+
};
|
|
328
|
+
const resetModuleInfo = useCallback(() => {
|
|
329
|
+
var _a;
|
|
330
|
+
const origin = ((_a = window.__FEDERATION__) == null ? void 0 : _a.originModuleInfo) || {};
|
|
331
|
+
applyModuleUpdate(cloneModuleInfo(origin));
|
|
332
|
+
}, [applyModuleUpdate]);
|
|
333
|
+
useEffect(() => {
|
|
334
|
+
const shouldAutoSync = activePanel === "proxy" || activePanel === "dependency" || activePanel === "share";
|
|
335
|
+
if (!shouldAutoSync || !panelSyncReadyRef.current) {
|
|
336
|
+
return;
|
|
337
|
+
}
|
|
338
|
+
let cancelled = false;
|
|
339
|
+
const syncPanelData = () => __async(void 0, null, function* () {
|
|
340
|
+
var _a, _b;
|
|
341
|
+
yield refreshModuleInfo();
|
|
342
|
+
if (cancelled) {
|
|
343
|
+
return;
|
|
344
|
+
}
|
|
345
|
+
if ((_a = window.__FEDERATION__) == null ? void 0 : _a.moduleInfo) {
|
|
346
|
+
applyModuleUpdate(cloneModuleInfo((_b = window.__FEDERATION__) == null ? void 0 : _b.moduleInfo));
|
|
347
|
+
}
|
|
348
|
+
});
|
|
349
|
+
void syncPanelData();
|
|
350
|
+
return () => {
|
|
351
|
+
cancelled = true;
|
|
352
|
+
};
|
|
353
|
+
}, [activePanel, applyModuleUpdate]);
|
|
354
|
+
const renderContent = () => {
|
|
355
|
+
var _a;
|
|
356
|
+
switch (activePanel) {
|
|
357
|
+
case "moduleInfo":
|
|
358
|
+
return /* @__PURE__ */ jsx(
|
|
359
|
+
ModuleInfo,
|
|
360
|
+
{
|
|
361
|
+
moduleInfo,
|
|
362
|
+
selectedModuleId,
|
|
363
|
+
onSelectModule: (id) => setSelectedModuleId(id)
|
|
364
|
+
}
|
|
365
|
+
);
|
|
366
|
+
case "proxy":
|
|
367
|
+
return /* @__PURE__ */ jsx(
|
|
368
|
+
ProxyLayout,
|
|
369
|
+
{
|
|
370
|
+
moduleInfo,
|
|
371
|
+
versionList,
|
|
372
|
+
setVersionList,
|
|
373
|
+
getVersion,
|
|
374
|
+
handleSnapshot,
|
|
375
|
+
handleProxyAddress,
|
|
376
|
+
customValueValidate,
|
|
377
|
+
headerSlot,
|
|
378
|
+
onModuleInfoChange: applyModuleUpdate,
|
|
379
|
+
onModuleInfoReset: resetModuleInfo,
|
|
380
|
+
tabId: inspectedTab == null ? void 0 : inspectedTab.id
|
|
381
|
+
}
|
|
382
|
+
);
|
|
383
|
+
case "dependency":
|
|
384
|
+
return hasModule ? /* @__PURE__ */ jsx(Dependency, { snapshot: moduleInfo }) : /* @__PURE__ */ jsx("div", { className: styles.emptyState, children: /* @__PURE__ */ jsx(
|
|
385
|
+
Empty,
|
|
386
|
+
{
|
|
387
|
+
description: t("common.empty.noModuleInfo"),
|
|
388
|
+
className: styles.empty
|
|
389
|
+
}
|
|
390
|
+
) });
|
|
391
|
+
case "share":
|
|
392
|
+
return /* @__PURE__ */ jsx(
|
|
393
|
+
SharedDepsExplorer,
|
|
394
|
+
{
|
|
395
|
+
shareData: JSON.parse(
|
|
396
|
+
JSON.stringify((_a = window.__FEDERATION__) == null ? void 0 : _a.__SHARE__)
|
|
397
|
+
)
|
|
398
|
+
}
|
|
399
|
+
);
|
|
400
|
+
case "performance":
|
|
401
|
+
return /* @__PURE__ */ jsx("div", { className: styles.placeholder, children: t("app.performance.placeholder") });
|
|
402
|
+
default:
|
|
403
|
+
return null;
|
|
404
|
+
}
|
|
405
|
+
};
|
|
406
|
+
return /* @__PURE__ */ jsxs(
|
|
407
|
+
"div",
|
|
27
408
|
{
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
409
|
+
className: `${styles.shell} ${styles.overrideArco} ${effectiveTheme === "dark" ? "arco-theme-dark" : ""}`,
|
|
410
|
+
children: [
|
|
411
|
+
/* @__PURE__ */ jsx("aside", { className: styles.sidebar, children: NAV_ITEMS.map((item) => /* @__PURE__ */ jsx(
|
|
412
|
+
"button",
|
|
413
|
+
{
|
|
414
|
+
type: "button",
|
|
415
|
+
className: `${styles.tabItem} ${activePanel === item.key ? styles.activeTab : ""}`,
|
|
416
|
+
onClick: () => setActivePanel(item.key),
|
|
417
|
+
children: t(item.i18nKey)
|
|
418
|
+
},
|
|
419
|
+
item.key
|
|
420
|
+
)) }),
|
|
421
|
+
/* @__PURE__ */ jsxs("section", { className: styles.panel, children: [
|
|
422
|
+
/* @__PURE__ */ jsxs("header", { className: styles.header, children: [
|
|
423
|
+
/* @__PURE__ */ jsxs("div", { className: styles.headerTop, children: [
|
|
424
|
+
/* @__PURE__ */ jsxs("div", { className: styles.branding, children: [
|
|
425
|
+
/* @__PURE__ */ jsx("span", { className: styles.logo, children: t("app.header.title") }),
|
|
426
|
+
/* @__PURE__ */ jsx("span", { className: styles.subtitle, children: t("app.header.subtitle") })
|
|
427
|
+
] }),
|
|
428
|
+
/* @__PURE__ */ jsxs("div", { className: styles.headerActions, children: [
|
|
429
|
+
/* @__PURE__ */ jsx(LanguageSwitch, {}),
|
|
430
|
+
/* @__PURE__ */ jsx(
|
|
431
|
+
ThemeToggle,
|
|
432
|
+
{
|
|
433
|
+
theme: effectiveTheme,
|
|
434
|
+
onToggle: handleThemeToggle
|
|
435
|
+
}
|
|
436
|
+
),
|
|
437
|
+
/* @__PURE__ */ jsx(Tooltip, { content: t("app.header.refresh.tooltip"), children: /* @__PURE__ */ jsx(
|
|
438
|
+
Button,
|
|
439
|
+
{
|
|
440
|
+
size: "default",
|
|
441
|
+
icon: /* @__PURE__ */ jsx(IconRefresh, {}),
|
|
442
|
+
loading: refreshing,
|
|
443
|
+
onClick: handleRefresh,
|
|
444
|
+
className: btnStyles.themeToggle
|
|
445
|
+
}
|
|
446
|
+
) })
|
|
447
|
+
] })
|
|
448
|
+
] }),
|
|
449
|
+
/* @__PURE__ */ jsxs("div", { className: styles.meta, children: [
|
|
450
|
+
/* @__PURE__ */ jsxs("div", { className: styles.scope, children: [
|
|
451
|
+
/* @__PURE__ */ jsx("span", { className: styles.scopeLabel, children: t("app.header.scope.label") }),
|
|
452
|
+
/* @__PURE__ */ jsx(Tag, { className: "common-tag", children: (inspectedTab == null ? void 0 : inspectedTab.title) || t("app.header.scope.waiting") })
|
|
453
|
+
] }),
|
|
454
|
+
/* @__PURE__ */ jsxs("div", { className: styles.stats, children: [
|
|
455
|
+
/* @__PURE__ */ jsxs("div", { className: styles.statBlock, children: [
|
|
456
|
+
/* @__PURE__ */ jsx("span", { className: styles.statValue, children: moduleCount }),
|
|
457
|
+
/* @__PURE__ */ jsx("span", { className: styles.statLabel, children: t("app.header.stats.modules") })
|
|
458
|
+
] }),
|
|
459
|
+
/* @__PURE__ */ jsxs("div", { className: styles.statBlock, children: [
|
|
460
|
+
/* @__PURE__ */ jsx("span", { className: styles.statValue, children: producer.length }),
|
|
461
|
+
/* @__PURE__ */ jsx("span", { className: styles.statLabel, children: t("app.header.stats.remotes") })
|
|
462
|
+
] }),
|
|
463
|
+
/* @__PURE__ */ jsxs("div", { className: styles.statBlock, children: [
|
|
464
|
+
/* @__PURE__ */ jsx("span", { className: styles.statValue, children: consumerCount }),
|
|
465
|
+
/* @__PURE__ */ jsx("span", { className: styles.statLabel, children: t("app.header.stats.consumers") })
|
|
466
|
+
] })
|
|
467
|
+
] })
|
|
468
|
+
] })
|
|
469
|
+
] }),
|
|
470
|
+
/* @__PURE__ */ jsx("div", { className: styles.body, children: /* @__PURE__ */ jsx("div", { className: styles.content, children: renderContent() }) })
|
|
471
|
+
] })
|
|
472
|
+
]
|
|
473
|
+
}
|
|
474
|
+
);
|
|
475
|
+
};
|
|
476
|
+
const App = (props) => {
|
|
477
|
+
return /* @__PURE__ */ jsx(I18nextProvider, { i18n, children: /* @__PURE__ */ jsx(InnerApp, __spreadValues({}, props)) });
|
|
38
478
|
};
|
|
39
479
|
var App_default = App;
|
|
40
480
|
export {
|
package/dist/es/App.module.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import "./App_module.css";
|
|
2
|
-
var App_module_default = { "
|
|
2
|
+
var App_module_default = { "shell": "shell_ae2ee", "sidebar": "sidebar_ae2ee", "tabItem": "tabItem_ae2ee", "activeTab": "activeTab_ae2ee", "panel": "panel_ae2ee", "header": "header_ae2ee", "headerTop": "headerTop_ae2ee", "branding": "branding_ae2ee", "logo": "logo_ae2ee", "subtitle": "subtitle_ae2ee", "meta": "meta_ae2ee", "scope": "scope_ae2ee", "scopeLabel": "scopeLabel_ae2ee", "stats": "stats_ae2ee", "statBlock": "statBlock_ae2ee", "statValue": "statValue_ae2ee", "statLabel": "statLabel_ae2ee", "body": "body_ae2ee", "content": "content_ae2ee", "emptyState": "emptyState_ae2ee", "empty": "empty_ae2ee", "placeholder": "placeholder_ae2ee", "overrideArco": "overrideArco_ae2ee" };
|
|
3
3
|
export {
|
|
4
4
|
App_module_default as default
|
|
5
5
|
};
|