@module-federation/devtools 0.0.0-next-20250926024003 → 0.0.0-perf-devtools-20260106124142
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.js +328 -22
- package/dist/es/App.module.js +1 -1
- package/dist/es/App_module.css +291 -5
- package/dist/es/component/DependencyGraph/index.js +205 -0
- package/dist/es/component/DependencyGraph/index.module.js +5 -0
- package/dist/es/component/DependencyGraph/index_module.css +97 -0
- package/dist/es/component/{GraphItem → DependencyGraphItem}/index.js +15 -6
- 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 +191 -109
- package/dist/es/component/Form/index.module.js +1 -1
- package/dist/es/component/Form/index_module.css +179 -25
- package/dist/es/component/Layout/index.js +288 -51
- 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 +289 -0
- package/dist/es/component/ModuleInfo/index.module.js +5 -0
- package/dist/es/component/ModuleInfo/index_module.css +183 -0
- package/dist/es/component/SharedDepsExplorer/FocusResultDisplay.js +39 -0
- package/dist/es/component/SharedDepsExplorer/index.js +505 -0
- package/dist/es/component/SharedDepsExplorer/share-utils.js +206 -0
- package/dist/es/index.css +15 -0
- package/dist/es/template/constant.js +5 -19
- package/dist/es/utils/chrome/fast-refresh.js +80 -7
- package/dist/es/utils/chrome/index.js +91 -38
- package/dist/es/utils/chrome/messages.js +6 -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.js +318 -17
- package/dist/lib/App.module.js +1 -1
- package/dist/lib/App_module.css +291 -5
- package/dist/lib/component/DependencyGraph/index.js +227 -0
- package/dist/lib/component/{GraphItem → DependencyGraph}/index.module.js +1 -1
- package/dist/lib/component/DependencyGraph/index_module.css +97 -0
- package/dist/lib/component/{GraphItem → DependencyGraphItem}/index.js +18 -9
- 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 +188 -107
- package/dist/lib/component/Form/index.module.js +1 -1
- package/dist/lib/component/Form/index_module.css +179 -25
- package/dist/lib/component/Layout/index.js +280 -48
- 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 +319 -0
- package/dist/lib/component/ModuleInfo/index.module.js +25 -0
- package/dist/lib/component/ModuleInfo/index_module.css +183 -0
- package/dist/lib/component/SharedDepsExplorer/FocusResultDisplay.js +59 -0
- package/dist/lib/component/SharedDepsExplorer/index.js +512 -0
- package/dist/lib/component/SharedDepsExplorer/share-utils.js +237 -0
- package/dist/lib/index.css +15 -0
- package/dist/lib/template/constant.js +7 -17
- package/dist/lib/utils/chrome/fast-refresh.js +77 -8
- package/dist/lib/utils/chrome/index.js +94 -38
- package/dist/lib/utils/chrome/messages.js +31 -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 +0 -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/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/index.d.ts +2 -1
- package/dist/types/src/init.d.ts +0 -1
- package/dist/types/src/template/constant.d.ts +3 -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/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
|
@@ -65,8 +65,8 @@ class DependencyGraph {
|
|
|
65
65
|
if (!remotesInfo) {
|
|
66
66
|
return;
|
|
67
67
|
}
|
|
68
|
-
Object.
|
|
69
|
-
const { matchedVersion } =
|
|
68
|
+
Object.entries(remotesInfo).forEach(([dep, remoteInfo]) => {
|
|
69
|
+
const { matchedVersion } = remoteInfo;
|
|
70
70
|
let childId = dep;
|
|
71
71
|
if (matchedVersion && matchedVersion !== "") {
|
|
72
72
|
childId = `${childId}:${matchedVersion}`;
|
|
@@ -107,7 +107,7 @@ class DependencyGraph {
|
|
|
107
107
|
type
|
|
108
108
|
});
|
|
109
109
|
}
|
|
110
|
-
run(targetGraph, target = this.initTarget, type, id = this.initTarget) {
|
|
110
|
+
run(targetGraph, target = this.initTarget, type, id = this.initTarget, depth = 0, maxDepth = Infinity) {
|
|
111
111
|
var _a;
|
|
112
112
|
if (!targetGraph || !((_a = Object.keys(targetGraph)) == null ? void 0 : _a.length)) {
|
|
113
113
|
return;
|
|
@@ -131,12 +131,17 @@ class DependencyGraph {
|
|
|
131
131
|
targetGraph[targetWithoutType] || targetGraph[target] || {}
|
|
132
132
|
);
|
|
133
133
|
graphChilden.forEach((dep) => {
|
|
134
|
+
if (depth + 1 > maxDepth) {
|
|
135
|
+
return;
|
|
136
|
+
}
|
|
134
137
|
this.addEdge(id + dep, id, id + dep);
|
|
135
138
|
this.run(
|
|
136
139
|
targetGraph[targetWithoutType] || targetGraph[target],
|
|
137
140
|
dep,
|
|
138
141
|
type,
|
|
139
|
-
id + dep
|
|
142
|
+
id + dep,
|
|
143
|
+
depth + 1,
|
|
144
|
+
maxDepth
|
|
140
145
|
);
|
|
141
146
|
});
|
|
142
147
|
}
|
|
@@ -147,6 +152,22 @@ class DependencyGraph {
|
|
|
147
152
|
const color = `rgba(${r},${g},${b},0.8)`;
|
|
148
153
|
return color;
|
|
149
154
|
}
|
|
155
|
+
calculateDepth(target = this.initTarget, visited = /* @__PURE__ */ new Set()) {
|
|
156
|
+
if (visited.has(target)) {
|
|
157
|
+
return 0;
|
|
158
|
+
}
|
|
159
|
+
visited.add(target);
|
|
160
|
+
const children = this.graph[target] ? Object.keys(this.graph[target]) : [];
|
|
161
|
+
if (children.length === 0) {
|
|
162
|
+
visited.delete(target);
|
|
163
|
+
return 0;
|
|
164
|
+
}
|
|
165
|
+
const maxChildDepth = Math.max(
|
|
166
|
+
...children.map((child) => this.calculateDepth(child, visited))
|
|
167
|
+
);
|
|
168
|
+
visited.delete(target);
|
|
169
|
+
return 1 + maxChildDepth;
|
|
170
|
+
}
|
|
150
171
|
}
|
|
151
172
|
export {
|
|
152
173
|
DependencyGraph,
|
|
@@ -2,6 +2,14 @@ export * from "./graph";
|
|
|
2
2
|
const setLocalStorage = (key, value) => {
|
|
3
3
|
localStorage.setItem(key, value);
|
|
4
4
|
};
|
|
5
|
+
const getLocalStorage = (key) => {
|
|
6
|
+
try {
|
|
7
|
+
return localStorage.getItem(key);
|
|
8
|
+
} catch (error) {
|
|
9
|
+
console.warn("[MF Devtools] getLocalStorage failed", error);
|
|
10
|
+
return null;
|
|
11
|
+
}
|
|
12
|
+
};
|
|
5
13
|
const removeLocalStorage = (key) => {
|
|
6
14
|
const data = localStorage.getItem(key);
|
|
7
15
|
if (data) {
|
|
@@ -50,6 +58,7 @@ const definePropertyGlobalVal = (target, key, val) => {
|
|
|
50
58
|
};
|
|
51
59
|
export {
|
|
52
60
|
definePropertyGlobalVal,
|
|
61
|
+
getLocalStorage,
|
|
53
62
|
getUnpkgUrl,
|
|
54
63
|
isObject,
|
|
55
64
|
mergeLocalStorage,
|
package/dist/es/worker/index.js
CHANGED
|
@@ -1 +1,168 @@
|
|
|
1
|
-
|
|
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;
|
|
4
|
+
};
|
|
5
|
+
var __async = (__this, __arguments, generator) => {
|
|
6
|
+
return new Promise((resolve, reject) => {
|
|
7
|
+
var fulfilled = (value) => {
|
|
8
|
+
try {
|
|
9
|
+
step(generator.next(value));
|
|
10
|
+
} catch (e) {
|
|
11
|
+
reject(e);
|
|
12
|
+
}
|
|
13
|
+
};
|
|
14
|
+
var rejected = (value) => {
|
|
15
|
+
try {
|
|
16
|
+
step(generator.throw(value));
|
|
17
|
+
} catch (e) {
|
|
18
|
+
reject(e);
|
|
19
|
+
}
|
|
20
|
+
};
|
|
21
|
+
var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
|
|
22
|
+
step((generator = generator.apply(__this, __arguments)).next());
|
|
23
|
+
});
|
|
24
|
+
};
|
|
25
|
+
import {
|
|
26
|
+
MESSAGE_ACTIVE_TAB_CHANGED,
|
|
27
|
+
MESSAGE_OPEN_SIDE_PANEL
|
|
28
|
+
} from "../utils/chrome/messages";
|
|
29
|
+
var require_worker = __commonJS({
|
|
30
|
+
"src/worker/index.ts"(exports) {
|
|
31
|
+
const SIDE_PANEL_PATH = "html/main/index.html";
|
|
32
|
+
const getSidePanel = () => chrome == null ? void 0 : chrome.sidePanel;
|
|
33
|
+
const resolveTabId = (tabId) => __async(exports, null, function* () {
|
|
34
|
+
if (typeof tabId === "number") {
|
|
35
|
+
return tabId;
|
|
36
|
+
}
|
|
37
|
+
const [activeTab] = yield chrome.tabs.query({
|
|
38
|
+
active: true,
|
|
39
|
+
lastFocusedWindow: true
|
|
40
|
+
});
|
|
41
|
+
return activeTab == null ? void 0 : activeTab.id;
|
|
42
|
+
});
|
|
43
|
+
const broadcastActiveTab = (tabId) => {
|
|
44
|
+
try {
|
|
45
|
+
chrome.runtime.sendMessage({
|
|
46
|
+
type: MESSAGE_ACTIVE_TAB_CHANGED,
|
|
47
|
+
tabId
|
|
48
|
+
});
|
|
49
|
+
} catch (error) {
|
|
50
|
+
console.warn(
|
|
51
|
+
"[Module Federation Devtools] Failed to broadcast active tab",
|
|
52
|
+
error
|
|
53
|
+
);
|
|
54
|
+
}
|
|
55
|
+
};
|
|
56
|
+
const openSidePanel = (tabId) => __async(exports, null, function* () {
|
|
57
|
+
const sidePanel = getSidePanel();
|
|
58
|
+
if (!sidePanel) {
|
|
59
|
+
throw new Error("sidePanel api not available");
|
|
60
|
+
}
|
|
61
|
+
const targetTabId = yield resolveTabId(tabId);
|
|
62
|
+
if (typeof targetTabId !== "number") {
|
|
63
|
+
throw new Error("No active tab available");
|
|
64
|
+
}
|
|
65
|
+
yield sidePanel.setOptions({
|
|
66
|
+
tabId: targetTabId,
|
|
67
|
+
path: SIDE_PANEL_PATH,
|
|
68
|
+
enabled: true
|
|
69
|
+
});
|
|
70
|
+
if (sidePanel.open) {
|
|
71
|
+
yield sidePanel.open({ tabId: targetTabId });
|
|
72
|
+
}
|
|
73
|
+
broadcastActiveTab(targetTabId);
|
|
74
|
+
if (sidePanel.getOptions) {
|
|
75
|
+
try {
|
|
76
|
+
const options = yield sidePanel.getOptions({ tabId: targetTabId });
|
|
77
|
+
broadcastActiveTab(targetTabId);
|
|
78
|
+
return options;
|
|
79
|
+
} catch (error) {
|
|
80
|
+
console.warn("[Module Federation Devtools] getOptions failed", error);
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
return {
|
|
84
|
+
path: SIDE_PANEL_PATH,
|
|
85
|
+
enabled: true
|
|
86
|
+
};
|
|
87
|
+
});
|
|
88
|
+
chrome.runtime.onInstalled.addListener(() => {
|
|
89
|
+
const sidePanel = getSidePanel();
|
|
90
|
+
if (sidePanel == null ? void 0 : sidePanel.setPanelBehavior) {
|
|
91
|
+
sidePanel.setPanelBehavior({ openPanelOnActionClick: true }).catch((error) => {
|
|
92
|
+
console.warn(
|
|
93
|
+
"[Module Federation Devtools] setPanelBehavior failed",
|
|
94
|
+
error
|
|
95
|
+
);
|
|
96
|
+
});
|
|
97
|
+
}
|
|
98
|
+
});
|
|
99
|
+
chrome.action.onClicked.addListener((tab) => __async(exports, null, function* () {
|
|
100
|
+
try {
|
|
101
|
+
yield openSidePanel(tab.id);
|
|
102
|
+
} catch (error) {
|
|
103
|
+
console.warn(
|
|
104
|
+
"[Module Federation Devtools] Failed to open side panel",
|
|
105
|
+
error
|
|
106
|
+
);
|
|
107
|
+
}
|
|
108
|
+
}));
|
|
109
|
+
chrome.runtime.onMessage.addListener((message, _sender, sendResponse) => {
|
|
110
|
+
if ((message == null ? void 0 : message.type) === MESSAGE_OPEN_SIDE_PANEL) {
|
|
111
|
+
openSidePanel(message.tabId).then((options) => sendResponse({ ok: true, options })).catch(
|
|
112
|
+
(error) => sendResponse({ ok: false, message: String(error) })
|
|
113
|
+
);
|
|
114
|
+
return true;
|
|
115
|
+
}
|
|
116
|
+
return void 0;
|
|
117
|
+
});
|
|
118
|
+
chrome.tabs.onActivated.addListener((activeInfo) => __async(exports, null, function* () {
|
|
119
|
+
const tabId = activeInfo == null ? void 0 : activeInfo.tabId;
|
|
120
|
+
if (typeof tabId !== "number") {
|
|
121
|
+
return;
|
|
122
|
+
}
|
|
123
|
+
try {
|
|
124
|
+
broadcastActiveTab(tabId);
|
|
125
|
+
} catch (error) {
|
|
126
|
+
console.warn(
|
|
127
|
+
"[Module Federation Devtools] Failed to handle tab activation",
|
|
128
|
+
error
|
|
129
|
+
);
|
|
130
|
+
}
|
|
131
|
+
}));
|
|
132
|
+
chrome.tabs.onUpdated.addListener((tabId, changeInfo, tab) => {
|
|
133
|
+
if (changeInfo.status !== "complete") {
|
|
134
|
+
return;
|
|
135
|
+
}
|
|
136
|
+
if (tab == null ? void 0 : tab.active) {
|
|
137
|
+
try {
|
|
138
|
+
broadcastActiveTab(tabId);
|
|
139
|
+
} catch (error) {
|
|
140
|
+
console.warn(
|
|
141
|
+
"[Module Federation Devtools] Failed to handle tab update",
|
|
142
|
+
error
|
|
143
|
+
);
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
});
|
|
147
|
+
chrome.tabs.onRemoved.addListener((tabId) => __async(exports, null, function* () {
|
|
148
|
+
try {
|
|
149
|
+
const FormID = "FormID";
|
|
150
|
+
const data = yield chrome.storage.sync.get(FormID);
|
|
151
|
+
const storeData = data[FormID];
|
|
152
|
+
if (storeData == null ? void 0 : storeData[String(tabId)]) {
|
|
153
|
+
delete storeData[String(tabId)];
|
|
154
|
+
yield chrome.storage.sync.set({
|
|
155
|
+
[FormID]: storeData
|
|
156
|
+
});
|
|
157
|
+
}
|
|
158
|
+
} catch (error) {
|
|
159
|
+
console.warn(
|
|
160
|
+
"[Module Federation Devtools] Failed to handle tab removal",
|
|
161
|
+
error
|
|
162
|
+
);
|
|
163
|
+
}
|
|
164
|
+
}));
|
|
165
|
+
console.log("Module Federation Worker ready");
|
|
166
|
+
}
|
|
167
|
+
});
|
|
168
|
+
export default require_worker();
|
package/dist/lib/App.js
CHANGED
|
@@ -26,6 +26,26 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
26
26
|
mod
|
|
27
27
|
));
|
|
28
28
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
+
var __async = (__this, __arguments, generator) => {
|
|
30
|
+
return new Promise((resolve, reject) => {
|
|
31
|
+
var fulfilled = (value) => {
|
|
32
|
+
try {
|
|
33
|
+
step(generator.next(value));
|
|
34
|
+
} catch (e) {
|
|
35
|
+
reject(e);
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
var rejected = (value) => {
|
|
39
|
+
try {
|
|
40
|
+
step(generator.throw(value));
|
|
41
|
+
} catch (e) {
|
|
42
|
+
reject(e);
|
|
43
|
+
}
|
|
44
|
+
};
|
|
45
|
+
var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
|
|
46
|
+
step((generator = generator.apply(__this, __arguments)).next());
|
|
47
|
+
});
|
|
48
|
+
};
|
|
29
49
|
var App_exports = {};
|
|
30
50
|
__export(App_exports, {
|
|
31
51
|
default: () => App_default
|
|
@@ -36,12 +56,75 @@ var import_react = require("react");
|
|
|
36
56
|
var import_web_react = require("@arco-design/web-react");
|
|
37
57
|
var import_init = require("./init");
|
|
38
58
|
var import_Layout = __toESM(require("./component/Layout"));
|
|
59
|
+
var import_DependencyGraph = __toESM(require("./component/DependencyGraph"));
|
|
60
|
+
var import_ModuleInfo = __toESM(require("./component/ModuleInfo"));
|
|
61
|
+
var import_SharedDepsExplorer = __toESM(require("./component/SharedDepsExplorer"));
|
|
39
62
|
var import_utils = require("./utils");
|
|
63
|
+
var import_messages = require("./utils/chrome/messages");
|
|
40
64
|
var import_arco = require("@arco-design/web-react/dist/css/arco.css");
|
|
41
65
|
var import_App = __toESM(require("./App.module"));
|
|
42
|
-
const
|
|
66
|
+
const cloneModuleInfo = (info) => {
|
|
67
|
+
try {
|
|
68
|
+
return JSON.parse(JSON.stringify(info || {}));
|
|
69
|
+
} catch (error) {
|
|
70
|
+
console.warn("[MF Devtools] cloneModuleInfo failed", error);
|
|
71
|
+
return info || {};
|
|
72
|
+
}
|
|
73
|
+
};
|
|
74
|
+
const normalizeShareValue = (target, seen = /* @__PURE__ */ new WeakSet()) => {
|
|
75
|
+
if (typeof target === "function") {
|
|
76
|
+
const name = target.name ? `: ${target.name}` : "";
|
|
77
|
+
return `[Function${name}]`;
|
|
78
|
+
}
|
|
79
|
+
if (!target || typeof target !== "object") {
|
|
80
|
+
return target;
|
|
81
|
+
}
|
|
82
|
+
if (seen.has(target)) {
|
|
83
|
+
return "[Circular]";
|
|
84
|
+
}
|
|
85
|
+
seen.add(target);
|
|
86
|
+
if (target instanceof Map) {
|
|
87
|
+
const mapped = {};
|
|
88
|
+
target.forEach((value, key) => {
|
|
89
|
+
mapped[String(key)] = normalizeShareValue(value, seen);
|
|
90
|
+
});
|
|
91
|
+
return mapped;
|
|
92
|
+
}
|
|
93
|
+
if (target instanceof Set) {
|
|
94
|
+
const setItems = [];
|
|
95
|
+
target.forEach((value) => {
|
|
96
|
+
setItems.push(normalizeShareValue(value, seen));
|
|
97
|
+
});
|
|
98
|
+
return setItems;
|
|
99
|
+
}
|
|
100
|
+
if (Array.isArray(target)) {
|
|
101
|
+
return target.map((item) => normalizeShareValue(item, seen));
|
|
102
|
+
}
|
|
103
|
+
return Object.keys(target).reduce((memo, key) => {
|
|
104
|
+
memo[key] = normalizeShareValue(target[key], seen);
|
|
105
|
+
return memo;
|
|
106
|
+
}, {});
|
|
107
|
+
};
|
|
108
|
+
const buildShareSnapshot = (share) => {
|
|
109
|
+
const normalize = (value) => {
|
|
110
|
+
try {
|
|
111
|
+
return normalizeShareValue(value);
|
|
112
|
+
} catch (error) {
|
|
113
|
+
console.warn("[MF Devtools] normalize share snapshot failed", error);
|
|
114
|
+
return normalizeShareValue(value);
|
|
115
|
+
}
|
|
116
|
+
};
|
|
117
|
+
const scopes = normalize(share || {});
|
|
118
|
+
return scopes;
|
|
119
|
+
};
|
|
120
|
+
const NAV_ITEMS = [
|
|
121
|
+
{ key: "moduleInfo", label: "Module info" },
|
|
122
|
+
{ key: "proxy", label: "Proxy" },
|
|
123
|
+
{ key: "dependency", label: "Dependency graph" },
|
|
124
|
+
{ key: "share", label: "Shared" },
|
|
125
|
+
{ key: "performance", label: "Performance" }
|
|
126
|
+
];
|
|
43
127
|
const App = (props) => {
|
|
44
|
-
var _a;
|
|
45
128
|
const {
|
|
46
129
|
versionList,
|
|
47
130
|
setVersionList,
|
|
@@ -51,22 +134,240 @@ const App = (props) => {
|
|
|
51
134
|
customValueValidate,
|
|
52
135
|
headerSlot
|
|
53
136
|
} = props;
|
|
54
|
-
const [
|
|
55
|
-
|
|
56
|
-
|
|
137
|
+
const [moduleInfo, setModuleInfo] = (0, import_react.useState)(
|
|
138
|
+
() => {
|
|
139
|
+
var _a;
|
|
140
|
+
return cloneModuleInfo(((_a = window.__FEDERATION__) == null ? void 0 : _a.moduleInfo) || {});
|
|
141
|
+
}
|
|
142
|
+
);
|
|
143
|
+
const [shareInfo, setShareInfo] = (0, import_react.useState)(
|
|
144
|
+
() => {
|
|
145
|
+
var _a;
|
|
146
|
+
return buildShareSnapshot((_a = window.__FEDERATION__) == null ? void 0 : _a.__SHARE__);
|
|
147
|
+
}
|
|
148
|
+
);
|
|
149
|
+
const [inspectedTab, setInspectedTab] = (0, import_react.useState)(
|
|
150
|
+
window.targetTab
|
|
151
|
+
);
|
|
152
|
+
const [activePanel, setActivePanel] = (0, import_react.useState)("proxy");
|
|
153
|
+
const [selectedModuleId, setSelectedModuleId] = (0, import_react.useState)(null);
|
|
154
|
+
const [refreshing, setRefreshing] = (0, import_react.useState)(false);
|
|
155
|
+
const panelSyncReadyRef = (0, import_react.useRef)(false);
|
|
156
|
+
const applyModuleUpdate = (0, import_react.useCallback)((info) => {
|
|
157
|
+
var _a;
|
|
158
|
+
setModuleInfo(cloneModuleInfo(info));
|
|
159
|
+
const shareSnapshot = buildShareSnapshot(
|
|
160
|
+
(_a = window.__FEDERATION__) == null ? void 0 : _a.__SHARE__
|
|
161
|
+
);
|
|
162
|
+
setShareInfo(shareSnapshot);
|
|
163
|
+
panelSyncReadyRef.current = true;
|
|
57
164
|
}, []);
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
165
|
+
const { producer, consumers } = (0, import_react.useMemo)(
|
|
166
|
+
() => (0, import_utils.separateType)(moduleInfo),
|
|
167
|
+
[moduleInfo]
|
|
168
|
+
);
|
|
169
|
+
const moduleKeys = (0, import_react.useMemo)(() => Object.keys(moduleInfo || {}), [moduleInfo]);
|
|
170
|
+
const moduleCount = moduleKeys.length;
|
|
171
|
+
const consumerCount = (0, import_react.useMemo)(
|
|
172
|
+
() => Object.keys(consumers || {}).length,
|
|
173
|
+
[consumers]
|
|
174
|
+
);
|
|
175
|
+
const hasModule = moduleCount > 0 || process.env.NODE_ENV === "development";
|
|
176
|
+
(0, import_react.useEffect)(() => {
|
|
177
|
+
if (!moduleKeys.length) {
|
|
178
|
+
setSelectedModuleId(null);
|
|
179
|
+
return;
|
|
180
|
+
}
|
|
181
|
+
if (!selectedModuleId || !moduleKeys.includes(selectedModuleId)) {
|
|
182
|
+
setSelectedModuleId(moduleKeys[0]);
|
|
183
|
+
}
|
|
184
|
+
}, [moduleKeys, selectedModuleId]);
|
|
185
|
+
(0, import_react.useEffect)(() => {
|
|
186
|
+
const bootstrap = () => __async(void 0, null, function* () {
|
|
187
|
+
const tab = yield (0, import_utils.syncActiveTab)();
|
|
188
|
+
setInspectedTab(tab || void 0);
|
|
189
|
+
const detach = yield (0, import_utils.getGlobalModuleInfo)(
|
|
190
|
+
(info) => applyModuleUpdate(info)
|
|
191
|
+
);
|
|
192
|
+
panelSyncReadyRef.current = true;
|
|
193
|
+
return detach;
|
|
194
|
+
});
|
|
195
|
+
const cleanupPromise = bootstrap();
|
|
196
|
+
return () => {
|
|
197
|
+
cleanupPromise.then((cleanup) => cleanup == null ? void 0 : cleanup());
|
|
198
|
+
};
|
|
199
|
+
}, [applyModuleUpdate]);
|
|
200
|
+
(0, import_react.useEffect)(() => {
|
|
201
|
+
const updateActiveTab = (tabId) => __async(void 0, null, function* () {
|
|
202
|
+
var _a, _b;
|
|
203
|
+
const tab = yield (0, import_utils.syncActiveTab)(tabId);
|
|
204
|
+
setInspectedTab(tab || void 0);
|
|
205
|
+
if ((_a = window.__FEDERATION__) == null ? void 0 : _a.moduleInfo) {
|
|
206
|
+
applyModuleUpdate(cloneModuleInfo((_b = window.__FEDERATION__) == null ? void 0 : _b.moduleInfo));
|
|
207
|
+
}
|
|
208
|
+
yield (0, import_utils.refreshModuleInfo)();
|
|
209
|
+
});
|
|
210
|
+
const onMessage = (message, _sender, _sendResponse) => {
|
|
211
|
+
if ((message == null ? void 0 : message.type) === import_messages.MESSAGE_ACTIVE_TAB_CHANGED) {
|
|
212
|
+
updateActiveTab(message.tabId);
|
|
213
|
+
}
|
|
214
|
+
};
|
|
215
|
+
chrome.runtime.onMessage.addListener(onMessage);
|
|
216
|
+
const onActivated = (activeInfo) => {
|
|
217
|
+
updateActiveTab(activeInfo.tabId);
|
|
218
|
+
};
|
|
219
|
+
chrome.tabs.onActivated.addListener(onActivated);
|
|
220
|
+
return () => {
|
|
221
|
+
chrome.runtime.onMessage.removeListener(onMessage);
|
|
222
|
+
chrome.tabs.onActivated.removeListener(onActivated);
|
|
223
|
+
};
|
|
224
|
+
}, [applyModuleUpdate]);
|
|
225
|
+
const handleRefresh = () => __async(void 0, null, function* () {
|
|
226
|
+
var _a, _b;
|
|
227
|
+
if (refreshing) {
|
|
228
|
+
return;
|
|
229
|
+
}
|
|
230
|
+
setRefreshing(true);
|
|
231
|
+
try {
|
|
232
|
+
yield (0, import_utils.refreshModuleInfo)();
|
|
233
|
+
if ((_a = window.__FEDERATION__) == null ? void 0 : _a.moduleInfo) {
|
|
234
|
+
applyModuleUpdate(cloneModuleInfo((_b = window.__FEDERATION__) == null ? void 0 : _b.moduleInfo));
|
|
235
|
+
}
|
|
236
|
+
} finally {
|
|
237
|
+
setRefreshing(false);
|
|
238
|
+
}
|
|
239
|
+
});
|
|
240
|
+
const resetModuleInfo = (0, import_react.useCallback)(() => {
|
|
241
|
+
var _a;
|
|
242
|
+
const origin = ((_a = window.__FEDERATION__) == null ? void 0 : _a.originModuleInfo) || {};
|
|
243
|
+
applyModuleUpdate(cloneModuleInfo(origin));
|
|
244
|
+
}, [applyModuleUpdate]);
|
|
245
|
+
(0, import_react.useEffect)(() => {
|
|
246
|
+
const shouldAutoSync = activePanel === "proxy" || activePanel === "dependency" || activePanel === "share";
|
|
247
|
+
if (!shouldAutoSync || !panelSyncReadyRef.current) {
|
|
248
|
+
return;
|
|
249
|
+
}
|
|
250
|
+
let cancelled = false;
|
|
251
|
+
const syncPanelData = () => __async(void 0, null, function* () {
|
|
252
|
+
var _a, _b;
|
|
253
|
+
yield (0, import_utils.refreshModuleInfo)();
|
|
254
|
+
if (cancelled) {
|
|
255
|
+
return;
|
|
256
|
+
}
|
|
257
|
+
if ((_a = window.__FEDERATION__) == null ? void 0 : _a.moduleInfo) {
|
|
258
|
+
applyModuleUpdate(cloneModuleInfo((_b = window.__FEDERATION__) == null ? void 0 : _b.moduleInfo));
|
|
259
|
+
}
|
|
260
|
+
});
|
|
261
|
+
void syncPanelData();
|
|
262
|
+
return () => {
|
|
263
|
+
cancelled = true;
|
|
264
|
+
};
|
|
265
|
+
}, [activePanel, applyModuleUpdate]);
|
|
266
|
+
const renderContent = () => {
|
|
267
|
+
var _a;
|
|
268
|
+
switch (activePanel) {
|
|
269
|
+
case "moduleInfo":
|
|
270
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
271
|
+
import_ModuleInfo.default,
|
|
272
|
+
{
|
|
273
|
+
moduleInfo,
|
|
274
|
+
selectedModuleId,
|
|
275
|
+
onSelectModule: (id) => setSelectedModuleId(id)
|
|
276
|
+
}
|
|
277
|
+
);
|
|
278
|
+
case "proxy":
|
|
279
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
280
|
+
import_Layout.default,
|
|
281
|
+
{
|
|
282
|
+
moduleInfo,
|
|
283
|
+
versionList,
|
|
284
|
+
setVersionList,
|
|
285
|
+
getVersion,
|
|
286
|
+
handleSnapshot,
|
|
287
|
+
handleProxyAddress,
|
|
288
|
+
customValueValidate,
|
|
289
|
+
headerSlot,
|
|
290
|
+
onModuleInfoChange: applyModuleUpdate,
|
|
291
|
+
onModuleInfoReset: resetModuleInfo,
|
|
292
|
+
tabId: inspectedTab == null ? void 0 : inspectedTab.id
|
|
293
|
+
}
|
|
294
|
+
);
|
|
295
|
+
case "dependency":
|
|
296
|
+
return hasModule ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_DependencyGraph.default, { snapshot: moduleInfo }) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: import_App.default.emptyState, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
297
|
+
import_web_react.Empty,
|
|
298
|
+
{
|
|
299
|
+
description: "No ModuleInfo Detected",
|
|
300
|
+
className: import_App.default.empty
|
|
301
|
+
}
|
|
302
|
+
) });
|
|
303
|
+
case "share":
|
|
304
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
305
|
+
import_SharedDepsExplorer.default,
|
|
306
|
+
{
|
|
307
|
+
shareData: JSON.parse(
|
|
308
|
+
JSON.stringify((_a = window.__FEDERATION__) == null ? void 0 : _a.__SHARE__)
|
|
309
|
+
)
|
|
310
|
+
}
|
|
311
|
+
);
|
|
312
|
+
case "performance":
|
|
313
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: import_App.default.placeholder, children: "WIP..." });
|
|
314
|
+
default:
|
|
315
|
+
return null;
|
|
69
316
|
}
|
|
70
|
-
|
|
317
|
+
};
|
|
318
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: `${import_App.default.shell} ${import_App.default.overrideArco}`, children: [
|
|
319
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("aside", { className: import_App.default.sidebar, children: NAV_ITEMS.map((item) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
320
|
+
"button",
|
|
321
|
+
{
|
|
322
|
+
type: "button",
|
|
323
|
+
className: `${import_App.default.tabItem} ${activePanel === item.key ? import_App.default.activeTab : ""}`,
|
|
324
|
+
onClick: () => setActivePanel(item.key),
|
|
325
|
+
children: item.label
|
|
326
|
+
},
|
|
327
|
+
item.key
|
|
328
|
+
)) }),
|
|
329
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("section", { className: import_App.default.panel, children: [
|
|
330
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("header", { className: import_App.default.header, children: [
|
|
331
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: import_App.default.headerTop, children: [
|
|
332
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: import_App.default.branding, children: [
|
|
333
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: import_App.default.logo, children: "Module Federation" }),
|
|
334
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: import_App.default.subtitle, children: "DevTools Companion" })
|
|
335
|
+
] }),
|
|
336
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_web_react.Tooltip, { content: "重新同步当前页面的 Federation 信息", children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
337
|
+
import_web_react.Button,
|
|
338
|
+
{
|
|
339
|
+
size: "mini",
|
|
340
|
+
type: "primary",
|
|
341
|
+
loading: refreshing,
|
|
342
|
+
onClick: handleRefresh,
|
|
343
|
+
className: import_App.default.refresh,
|
|
344
|
+
children: "Refresh"
|
|
345
|
+
}
|
|
346
|
+
) })
|
|
347
|
+
] }),
|
|
348
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: import_App.default.meta, children: [
|
|
349
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: import_App.default.scope, children: [
|
|
350
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: import_App.default.scopeLabel, children: "Focus Tab" }),
|
|
351
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_web_react.Tag, { className: "common-tag", children: (inspectedTab == null ? void 0 : inspectedTab.title) || "Waiting for target" })
|
|
352
|
+
] }),
|
|
353
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: import_App.default.stats, children: [
|
|
354
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: import_App.default.statBlock, children: [
|
|
355
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: import_App.default.statValue, children: moduleCount }),
|
|
356
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: import_App.default.statLabel, children: "Modules" })
|
|
357
|
+
] }),
|
|
358
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: import_App.default.statBlock, children: [
|
|
359
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: import_App.default.statValue, children: producer.length }),
|
|
360
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: import_App.default.statLabel, children: "Remotes" })
|
|
361
|
+
] }),
|
|
362
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: import_App.default.statBlock, children: [
|
|
363
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: import_App.default.statValue, children: consumerCount }),
|
|
364
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: import_App.default.statLabel, children: "Consumers" })
|
|
365
|
+
] })
|
|
366
|
+
] })
|
|
367
|
+
] })
|
|
368
|
+
] }),
|
|
369
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: import_App.default.body, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: import_App.default.content, children: renderContent() }) })
|
|
370
|
+
] })
|
|
371
|
+
] });
|
|
71
372
|
};
|
|
72
373
|
var App_default = App;
|
package/dist/lib/App.module.js
CHANGED
|
@@ -22,4 +22,4 @@ __export(App_module_exports, {
|
|
|
22
22
|
});
|
|
23
23
|
module.exports = __toCommonJS(App_module_exports);
|
|
24
24
|
var import_App_module = require("./App_module.css");
|
|
25
|
-
var App_module_default = { "
|
|
25
|
+
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", "refresh": "refresh_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" };
|