@module-federation/devtools 0.22.0 → 0.22.1
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 +12 -0
- package/dist/es/App.js +330 -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 +300 -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 +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 +33 -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 +506 -0
- package/dist/es/component/SharedDepsExplorer/index.module.js +5 -0
- package/dist/es/component/SharedDepsExplorer/index_module.css +457 -0
- package/dist/es/component/SharedDepsExplorer/share-utils.js +206 -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 +12 -0
- package/dist/lib/App.js +321 -18
- 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 +294 -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 +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 +63 -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 +513 -0
- package/dist/lib/component/SharedDepsExplorer/index.module.js +25 -0
- package/dist/lib/component/SharedDepsExplorer/index_module.css +457 -0
- package/dist/lib/component/SharedDepsExplorer/share-utils.js +237 -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/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/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 +11 -9
- 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
|
@@ -55,12 +55,37 @@ const injectPostMessage = (postMessageUrl) => {
|
|
|
55
55
|
const TabInfo = {
|
|
56
56
|
currentTabId: 0
|
|
57
57
|
};
|
|
58
|
+
const setTargetTab = (tab) => {
|
|
59
|
+
if (!tab || typeof tab.id !== "number") {
|
|
60
|
+
return;
|
|
61
|
+
}
|
|
62
|
+
window.targetTab = tab;
|
|
63
|
+
TabInfo.currentTabId = tab.id;
|
|
64
|
+
};
|
|
65
|
+
const syncActiveTab = (tabId) => __async(void 0, null, function* () {
|
|
66
|
+
try {
|
|
67
|
+
if (typeof tabId === "number") {
|
|
68
|
+
const tab = yield chrome.tabs.get(tabId);
|
|
69
|
+
setTargetTab(tab);
|
|
70
|
+
return tab;
|
|
71
|
+
}
|
|
72
|
+
const [activeTab] = yield getTabs({
|
|
73
|
+
active: true,
|
|
74
|
+
lastFocusedWindow: true
|
|
75
|
+
});
|
|
76
|
+
setTargetTab(activeTab);
|
|
77
|
+
return activeTab;
|
|
78
|
+
} catch (error) {
|
|
79
|
+
console.warn("[Module Federation Devtools] syncActiveTab failed", error);
|
|
80
|
+
return void 0;
|
|
81
|
+
}
|
|
82
|
+
});
|
|
58
83
|
function getCurrentTabId() {
|
|
59
84
|
return TabInfo.currentTabId;
|
|
60
85
|
}
|
|
61
86
|
function getInspectWindowTabId() {
|
|
62
87
|
return new Promise((resolve, reject) => {
|
|
63
|
-
var _a;
|
|
88
|
+
var _a, _b;
|
|
64
89
|
if ((_a = chrome == null ? void 0 : chrome.devtools) == null ? void 0 : _a.inspectedWindow) {
|
|
65
90
|
if (chrome.isDevMode) {
|
|
66
91
|
resolve(0);
|
|
@@ -73,7 +98,7 @@ function getInspectWindowTabId() {
|
|
|
73
98
|
const target = tabs.find(
|
|
74
99
|
(tab) => tab.id === tabId
|
|
75
100
|
);
|
|
76
|
-
|
|
101
|
+
setTargetTab(target);
|
|
77
102
|
});
|
|
78
103
|
console.log(
|
|
79
104
|
"chrome.devtools.inspectedWindow.tabId",
|
|
@@ -87,7 +112,7 @@ function getInspectWindowTabId() {
|
|
|
87
112
|
}
|
|
88
113
|
);
|
|
89
114
|
} else {
|
|
90
|
-
if (window.targetTab
|
|
115
|
+
if ((_b = window.targetTab) == null ? void 0 : _b.id) {
|
|
91
116
|
const tabId = window.targetTab.id;
|
|
92
117
|
TabInfo.currentTabId = tabId;
|
|
93
118
|
resolve(tabId);
|
|
@@ -97,48 +122,67 @@ function getInspectWindowTabId() {
|
|
|
97
122
|
}
|
|
98
123
|
});
|
|
99
124
|
}
|
|
125
|
+
const refreshModuleInfo = () => __async(void 0, null, function* () {
|
|
126
|
+
var _a;
|
|
127
|
+
if (typeof window !== "undefined" && ((_a = window.__FEDERATION__) == null ? void 0 : _a.moduleInfo)) {
|
|
128
|
+
}
|
|
129
|
+
yield sleep(50);
|
|
130
|
+
const postMessageStartUrl = getUrl("post-message-start.js");
|
|
131
|
+
yield injectScript(injectPostMessage, false, postMessageStartUrl);
|
|
132
|
+
});
|
|
100
133
|
const getGlobalModuleInfo = (callback) => __async(void 0, null, function* () {
|
|
134
|
+
var _a, _b;
|
|
135
|
+
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
|
+
);
|
|
141
|
+
}
|
|
101
142
|
yield sleep(300);
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
143
|
+
const listener = (message) => {
|
|
144
|
+
const { data } = message;
|
|
145
|
+
if (!data || (data == null ? void 0 : data.appInfos)) {
|
|
146
|
+
return;
|
|
147
|
+
}
|
|
148
|
+
if (!(window == null ? void 0 : window.__FEDERATION__)) {
|
|
149
|
+
definePropertyGlobalVal(window, "__FEDERATION__", {});
|
|
150
|
+
definePropertyGlobalVal(window, "__VMOK__", window.__FEDERATION__);
|
|
151
|
+
}
|
|
152
|
+
window.__FEDERATION__.originModuleInfo = JSON.parse(
|
|
153
|
+
JSON.stringify(data == null ? void 0 : data.moduleInfo)
|
|
154
|
+
);
|
|
155
|
+
if (data == null ? void 0 : data.updateModule) {
|
|
156
|
+
const moduleIds = Object.keys(window.__FEDERATION__.originModuleInfo);
|
|
157
|
+
const shouldUpdate = !moduleIds.some(
|
|
158
|
+
(id) => id.includes(data.updateModule.name)
|
|
114
159
|
);
|
|
115
|
-
if (
|
|
116
|
-
const
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
const destination = data.updateModule.entry || data.updateModule.version;
|
|
122
|
-
window.__FEDERATION__.originModuleInfo[`${data.updateModule.name}:${destination}`] = {
|
|
123
|
-
remoteEntry: destination,
|
|
124
|
-
version: destination
|
|
125
|
-
};
|
|
126
|
-
}
|
|
160
|
+
if (shouldUpdate) {
|
|
161
|
+
const destination = data.updateModule.entry || data.updateModule.version;
|
|
162
|
+
window.__FEDERATION__.originModuleInfo[`${data.updateModule.name}:${destination}`] = {
|
|
163
|
+
remoteEntry: destination,
|
|
164
|
+
version: destination
|
|
165
|
+
};
|
|
127
166
|
}
|
|
128
|
-
window.__FEDERATION__.moduleInfo = JSON.parse(
|
|
129
|
-
JSON.stringify(window.__FEDERATION__.originModuleInfo)
|
|
130
|
-
);
|
|
131
|
-
callback(window.__FEDERATION__.moduleInfo);
|
|
132
167
|
}
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
168
|
+
if (data == null ? void 0 : data.share) {
|
|
169
|
+
window.__FEDERATION__.__SHARE__ = data.share;
|
|
170
|
+
}
|
|
171
|
+
window.__FEDERATION__.moduleInfo = JSON.parse(
|
|
172
|
+
JSON.stringify(window.__FEDERATION__.originModuleInfo)
|
|
173
|
+
);
|
|
174
|
+
console.log("getGlobalModuleInfo window", window.__FEDERATION__);
|
|
175
|
+
callback(window.__FEDERATION__.moduleInfo);
|
|
176
|
+
};
|
|
177
|
+
chrome.runtime.onMessage.addListener(listener);
|
|
178
|
+
yield refreshModuleInfo();
|
|
179
|
+
return () => chrome.runtime.onMessage.removeListener(listener);
|
|
136
180
|
});
|
|
137
181
|
const getTabs = (queryOptions = {}) => chrome.tabs.query(queryOptions);
|
|
138
182
|
const getScope = () => __async(void 0, null, function* () {
|
|
139
183
|
const activeTab = window.targetTab;
|
|
140
|
-
const
|
|
141
|
-
return
|
|
184
|
+
const tabId = activeTab == null ? void 0 : activeTab.id;
|
|
185
|
+
return tabId ? String(tabId) : "noScope";
|
|
142
186
|
});
|
|
143
187
|
const injectScript = (excuteScript, world = false, ...args) => __async(void 0, null, function* () {
|
|
144
188
|
yield getInspectWindowTabId();
|
|
@@ -149,10 +193,16 @@ const injectScript = (excuteScript, world = false, ...args) => __async(void 0, n
|
|
|
149
193
|
func: excuteScript,
|
|
150
194
|
world: world ? "MAIN" : "ISOLATED",
|
|
151
195
|
args
|
|
152
|
-
}).then(() => {
|
|
196
|
+
}).then((results) => {
|
|
197
|
+
var _a;
|
|
153
198
|
console.log("InjectScript success, excuteScript:", args);
|
|
199
|
+
if (Array.isArray(results) && results.length) {
|
|
200
|
+
return (_a = results[0]) == null ? void 0 : _a.result;
|
|
201
|
+
}
|
|
202
|
+
return void 0;
|
|
154
203
|
}).catch((e) => {
|
|
155
204
|
console.log(e, "InjectScript fail, excuteScript:", args);
|
|
205
|
+
return void 0;
|
|
156
206
|
});
|
|
157
207
|
});
|
|
158
208
|
const getUrl = (file) => {
|
|
@@ -207,5 +257,8 @@ export {
|
|
|
207
257
|
injectPostMessage,
|
|
208
258
|
injectScript,
|
|
209
259
|
injectToast,
|
|
210
|
-
|
|
260
|
+
refreshModuleInfo,
|
|
261
|
+
setChromeStorage,
|
|
262
|
+
setTargetTab,
|
|
263
|
+
syncActiveTab
|
|
211
264
|
};
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
var _a;
|
|
2
|
+
import runtimeHelpers from "@module-federation/runtime/helpers";
|
|
3
|
+
import { definePropertyGlobalVal } from "../sdk";
|
|
4
|
+
import { __FEDERATION_DEVTOOLS__ } from "../../template";
|
|
5
|
+
const chromeOverrideRemotesPlugin = function() {
|
|
6
|
+
return {
|
|
7
|
+
name: "mf-chrome-devtools-override-remotes-plugin",
|
|
8
|
+
beforeRegisterRemote(args) {
|
|
9
|
+
try {
|
|
10
|
+
const { remote } = args;
|
|
11
|
+
const overrideRemote = runtimeHelpers.global.nativeGlobal.localStorage.getItem(
|
|
12
|
+
__FEDERATION_DEVTOOLS__
|
|
13
|
+
);
|
|
14
|
+
if (!overrideRemote) {
|
|
15
|
+
return args;
|
|
16
|
+
}
|
|
17
|
+
const parsedOverrideRemote = JSON.parse(overrideRemote);
|
|
18
|
+
const overrideEntryOrVersion = parsedOverrideRemote[remote.name];
|
|
19
|
+
if (overrideEntryOrVersion) {
|
|
20
|
+
if (overrideEntryOrVersion.startsWith("http")) {
|
|
21
|
+
delete remote.version;
|
|
22
|
+
remote.entry = overrideEntryOrVersion;
|
|
23
|
+
} else {
|
|
24
|
+
delete remote.entry;
|
|
25
|
+
remote.version = overrideEntryOrVersion;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
} catch (e) {
|
|
29
|
+
console.error(e);
|
|
30
|
+
}
|
|
31
|
+
return args;
|
|
32
|
+
}
|
|
33
|
+
};
|
|
34
|
+
};
|
|
35
|
+
if (!(window == null ? void 0 : window.__FEDERATION__)) {
|
|
36
|
+
definePropertyGlobalVal(window, "__FEDERATION__", {});
|
|
37
|
+
definePropertyGlobalVal(window, "__VMOK__", window.__FEDERATION__);
|
|
38
|
+
}
|
|
39
|
+
if (!(window == null ? void 0 : window.__FEDERATION__.__GLOBAL_PLUGIN__)) {
|
|
40
|
+
window.__FEDERATION__.__GLOBAL_PLUGIN__ = [];
|
|
41
|
+
}
|
|
42
|
+
(_a = window.__FEDERATION__.__GLOBAL_PLUGIN__) == null ? void 0 : _a.push(chromeOverrideRemotesPlugin());
|
|
@@ -1,8 +1,16 @@
|
|
|
1
|
-
var _a;
|
|
1
|
+
var _a, _b;
|
|
2
2
|
const moduleInfo = (_a = window == null ? void 0 : window.__FEDERATION__) == null ? void 0 : _a.moduleInfo;
|
|
3
3
|
window.postMessage(
|
|
4
4
|
{
|
|
5
|
-
moduleInfo
|
|
5
|
+
moduleInfo,
|
|
6
|
+
share: JSON.parse(
|
|
7
|
+
JSON.stringify((_b = window == null ? void 0 : window.__FEDERATION__) == null ? void 0 : _b.__SHARE__, (_key, value) => {
|
|
8
|
+
if (typeof value === "function") {
|
|
9
|
+
return "Function";
|
|
10
|
+
}
|
|
11
|
+
return value;
|
|
12
|
+
})
|
|
13
|
+
)
|
|
6
14
|
},
|
|
7
15
|
"*"
|
|
8
16
|
);
|
|
@@ -22,7 +22,8 @@ import {
|
|
|
22
22
|
mergeLocalStorage,
|
|
23
23
|
removeLocalStorageKey,
|
|
24
24
|
removeLocalStorage,
|
|
25
|
-
setLocalStorage
|
|
25
|
+
setLocalStorage,
|
|
26
|
+
getLocalStorage
|
|
26
27
|
} from "../sdk";
|
|
27
28
|
import { injectScript } from "./index";
|
|
28
29
|
const mergeStorage = (...args) => __async(void 0, null, function* () {
|
|
@@ -37,7 +38,11 @@ const removeStorage = (...args) => __async(void 0, null, function* () {
|
|
|
37
38
|
const setStorage = (...args) => __async(void 0, null, function* () {
|
|
38
39
|
return injectScript(setLocalStorage, false, ...args);
|
|
39
40
|
});
|
|
41
|
+
const getStorageValue = (...args) => __async(void 0, null, function* () {
|
|
42
|
+
return injectScript(getLocalStorage, false, ...args);
|
|
43
|
+
});
|
|
40
44
|
export {
|
|
45
|
+
getStorageValue,
|
|
41
46
|
mergeStorage,
|
|
42
47
|
removeStorage,
|
|
43
48
|
removeStorageKey,
|
|
@@ -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.css
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
.loaded-status-tag {
|
|
2
|
+
color: white !important;
|
|
3
|
+
background-color: black !important;
|
|
4
|
+
}
|
|
5
|
+
.reused-status-tag {
|
|
6
|
+
background-color: greenyellow !important;
|
|
7
|
+
}
|
|
8
|
+
.common-tag {
|
|
9
|
+
color: rgb(113 113 122 / var(--tw-text-opacity)) !important;
|
|
10
|
+
background-color: #fff !important;
|
|
11
|
+
border-color: rgba(228, 228, 231, 0.5) !important;
|
|
12
|
+
}
|