@module-federation/devtools 0.21.6 → 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 +16 -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
|
@@ -2,21 +2,7 @@
|
|
|
2
2
|
var __defProp = Object.defineProperty;
|
|
3
3
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
4
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
6
5
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
-
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
8
|
-
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
9
|
-
var __spreadValues = (a, b) => {
|
|
10
|
-
for (var prop in b || (b = {}))
|
|
11
|
-
if (__hasOwnProp.call(b, prop))
|
|
12
|
-
__defNormalProp(a, prop, b[prop]);
|
|
13
|
-
if (__getOwnPropSymbols)
|
|
14
|
-
for (var prop of __getOwnPropSymbols(b)) {
|
|
15
|
-
if (__propIsEnum.call(b, prop))
|
|
16
|
-
__defNormalProp(a, prop, b[prop]);
|
|
17
|
-
}
|
|
18
|
-
return a;
|
|
19
|
-
};
|
|
20
6
|
var __export = (target, all) => {
|
|
21
7
|
for (var name in all)
|
|
22
8
|
__defProp(target, name, { get: all[name], enumerable: true });
|
|
@@ -34,6 +20,7 @@ var constant_exports = {};
|
|
|
34
20
|
__export(constant_exports, {
|
|
35
21
|
BROWSER_ENV_KEY: () => BROWSER_ENV_KEY,
|
|
36
22
|
ENABLEHMR: () => ENABLEHMR,
|
|
23
|
+
ENABLE_CLIP: () => ENABLE_CLIP,
|
|
37
24
|
FormID: () => FormID,
|
|
38
25
|
__EAGER_SHARE__: () => __EAGER_SHARE__,
|
|
39
26
|
__ENABLE_FAST_REFRESH__: () => __ENABLE_FAST_REFRESH__,
|
|
@@ -46,6 +33,7 @@ __export(constant_exports, {
|
|
|
46
33
|
module.exports = __toCommonJS(constant_exports);
|
|
47
34
|
const FormID = "FormID";
|
|
48
35
|
const ENABLEHMR = "enableHMR";
|
|
36
|
+
const ENABLE_CLIP = "enableClip";
|
|
49
37
|
const proxyFormField = "proxyFormField";
|
|
50
38
|
const defaultDataItem = {
|
|
51
39
|
key: "",
|
|
@@ -53,9 +41,7 @@ const defaultDataItem = {
|
|
|
53
41
|
checked: true
|
|
54
42
|
};
|
|
55
43
|
const defaultModuleData = {
|
|
56
|
-
proxyFormField: [
|
|
57
|
-
__spreadValues({}, defaultDataItem)
|
|
58
|
-
]
|
|
44
|
+
proxyFormField: []
|
|
59
45
|
};
|
|
60
46
|
const statusInfo = {
|
|
61
47
|
noProxy: {
|
|
@@ -87,6 +73,7 @@ const __FEDERATION_DEVTOOLS__ = "__MF_DEVTOOLS__";
|
|
|
87
73
|
0 && (module.exports = {
|
|
88
74
|
BROWSER_ENV_KEY,
|
|
89
75
|
ENABLEHMR,
|
|
76
|
+
ENABLE_CLIP,
|
|
90
77
|
FormID,
|
|
91
78
|
__EAGER_SHARE__,
|
|
92
79
|
__ENABLE_FAST_REFRESH__,
|
|
@@ -66,7 +66,10 @@ __export(chrome_exports, {
|
|
|
66
66
|
injectPostMessage: () => injectPostMessage,
|
|
67
67
|
injectScript: () => injectScript,
|
|
68
68
|
injectToast: () => injectToast,
|
|
69
|
-
|
|
69
|
+
refreshModuleInfo: () => refreshModuleInfo,
|
|
70
|
+
setChromeStorage: () => setChromeStorage,
|
|
71
|
+
setTargetTab: () => setTargetTab,
|
|
72
|
+
syncActiveTab: () => syncActiveTab
|
|
70
73
|
});
|
|
71
74
|
module.exports = __toCommonJS(chrome_exports);
|
|
72
75
|
var import_constant = require("../../template/constant");
|
|
@@ -87,12 +90,37 @@ const injectPostMessage = (postMessageUrl) => {
|
|
|
87
90
|
const TabInfo = {
|
|
88
91
|
currentTabId: 0
|
|
89
92
|
};
|
|
93
|
+
const setTargetTab = (tab) => {
|
|
94
|
+
if (!tab || typeof tab.id !== "number") {
|
|
95
|
+
return;
|
|
96
|
+
}
|
|
97
|
+
window.targetTab = tab;
|
|
98
|
+
TabInfo.currentTabId = tab.id;
|
|
99
|
+
};
|
|
100
|
+
const syncActiveTab = (tabId) => __async(void 0, null, function* () {
|
|
101
|
+
try {
|
|
102
|
+
if (typeof tabId === "number") {
|
|
103
|
+
const tab = yield chrome.tabs.get(tabId);
|
|
104
|
+
setTargetTab(tab);
|
|
105
|
+
return tab;
|
|
106
|
+
}
|
|
107
|
+
const [activeTab] = yield getTabs({
|
|
108
|
+
active: true,
|
|
109
|
+
lastFocusedWindow: true
|
|
110
|
+
});
|
|
111
|
+
setTargetTab(activeTab);
|
|
112
|
+
return activeTab;
|
|
113
|
+
} catch (error) {
|
|
114
|
+
console.warn("[Module Federation Devtools] syncActiveTab failed", error);
|
|
115
|
+
return void 0;
|
|
116
|
+
}
|
|
117
|
+
});
|
|
90
118
|
function getCurrentTabId() {
|
|
91
119
|
return TabInfo.currentTabId;
|
|
92
120
|
}
|
|
93
121
|
function getInspectWindowTabId() {
|
|
94
122
|
return new Promise((resolve, reject) => {
|
|
95
|
-
var _a;
|
|
123
|
+
var _a, _b;
|
|
96
124
|
if ((_a = chrome == null ? void 0 : chrome.devtools) == null ? void 0 : _a.inspectedWindow) {
|
|
97
125
|
if (chrome.isDevMode) {
|
|
98
126
|
resolve(0);
|
|
@@ -105,7 +133,7 @@ function getInspectWindowTabId() {
|
|
|
105
133
|
const target = tabs.find(
|
|
106
134
|
(tab) => tab.id === tabId
|
|
107
135
|
);
|
|
108
|
-
|
|
136
|
+
setTargetTab(target);
|
|
109
137
|
});
|
|
110
138
|
console.log(
|
|
111
139
|
"chrome.devtools.inspectedWindow.tabId",
|
|
@@ -119,7 +147,7 @@ function getInspectWindowTabId() {
|
|
|
119
147
|
}
|
|
120
148
|
);
|
|
121
149
|
} else {
|
|
122
|
-
if (window.targetTab
|
|
150
|
+
if ((_b = window.targetTab) == null ? void 0 : _b.id) {
|
|
123
151
|
const tabId = window.targetTab.id;
|
|
124
152
|
TabInfo.currentTabId = tabId;
|
|
125
153
|
resolve(tabId);
|
|
@@ -129,48 +157,67 @@ function getInspectWindowTabId() {
|
|
|
129
157
|
}
|
|
130
158
|
});
|
|
131
159
|
}
|
|
160
|
+
const refreshModuleInfo = () => __async(void 0, null, function* () {
|
|
161
|
+
var _a;
|
|
162
|
+
if (typeof window !== "undefined" && ((_a = window.__FEDERATION__) == null ? void 0 : _a.moduleInfo)) {
|
|
163
|
+
}
|
|
164
|
+
yield sleep(50);
|
|
165
|
+
const postMessageStartUrl = getUrl("post-message-start.js");
|
|
166
|
+
yield injectScript(injectPostMessage, false, postMessageStartUrl);
|
|
167
|
+
});
|
|
132
168
|
const getGlobalModuleInfo = (callback) => __async(void 0, null, function* () {
|
|
169
|
+
var _a, _b;
|
|
170
|
+
if (typeof window !== "undefined" && ((_a = window.__FEDERATION__) == null ? void 0 : _a.moduleInfo)) {
|
|
171
|
+
callback(
|
|
172
|
+
JSON.parse(
|
|
173
|
+
JSON.stringify((_b = window.__FEDERATION__) == null ? void 0 : _b.moduleInfo)
|
|
174
|
+
)
|
|
175
|
+
);
|
|
176
|
+
}
|
|
133
177
|
yield sleep(300);
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
178
|
+
const listener = (message) => {
|
|
179
|
+
const { data } = message;
|
|
180
|
+
if (!data || (data == null ? void 0 : data.appInfos)) {
|
|
181
|
+
return;
|
|
182
|
+
}
|
|
183
|
+
if (!(window == null ? void 0 : window.__FEDERATION__)) {
|
|
184
|
+
(0, import_sdk2.definePropertyGlobalVal)(window, "__FEDERATION__", {});
|
|
185
|
+
(0, import_sdk2.definePropertyGlobalVal)(window, "__VMOK__", window.__FEDERATION__);
|
|
186
|
+
}
|
|
187
|
+
window.__FEDERATION__.originModuleInfo = JSON.parse(
|
|
188
|
+
JSON.stringify(data == null ? void 0 : data.moduleInfo)
|
|
189
|
+
);
|
|
190
|
+
if (data == null ? void 0 : data.updateModule) {
|
|
191
|
+
const moduleIds = Object.keys(window.__FEDERATION__.originModuleInfo);
|
|
192
|
+
const shouldUpdate = !moduleIds.some(
|
|
193
|
+
(id) => id.includes(data.updateModule.name)
|
|
146
194
|
);
|
|
147
|
-
if (
|
|
148
|
-
const
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
const destination = data.updateModule.entry || data.updateModule.version;
|
|
154
|
-
window.__FEDERATION__.originModuleInfo[`${data.updateModule.name}:${destination}`] = {
|
|
155
|
-
remoteEntry: destination,
|
|
156
|
-
version: destination
|
|
157
|
-
};
|
|
158
|
-
}
|
|
195
|
+
if (shouldUpdate) {
|
|
196
|
+
const destination = data.updateModule.entry || data.updateModule.version;
|
|
197
|
+
window.__FEDERATION__.originModuleInfo[`${data.updateModule.name}:${destination}`] = {
|
|
198
|
+
remoteEntry: destination,
|
|
199
|
+
version: destination
|
|
200
|
+
};
|
|
159
201
|
}
|
|
160
|
-
window.__FEDERATION__.moduleInfo = JSON.parse(
|
|
161
|
-
JSON.stringify(window.__FEDERATION__.originModuleInfo)
|
|
162
|
-
);
|
|
163
|
-
callback(window.__FEDERATION__.moduleInfo);
|
|
164
202
|
}
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
203
|
+
if (data == null ? void 0 : data.share) {
|
|
204
|
+
window.__FEDERATION__.__SHARE__ = data.share;
|
|
205
|
+
}
|
|
206
|
+
window.__FEDERATION__.moduleInfo = JSON.parse(
|
|
207
|
+
JSON.stringify(window.__FEDERATION__.originModuleInfo)
|
|
208
|
+
);
|
|
209
|
+
console.log("getGlobalModuleInfo window", window.__FEDERATION__);
|
|
210
|
+
callback(window.__FEDERATION__.moduleInfo);
|
|
211
|
+
};
|
|
212
|
+
chrome.runtime.onMessage.addListener(listener);
|
|
213
|
+
yield refreshModuleInfo();
|
|
214
|
+
return () => chrome.runtime.onMessage.removeListener(listener);
|
|
168
215
|
});
|
|
169
216
|
const getTabs = (queryOptions = {}) => chrome.tabs.query(queryOptions);
|
|
170
217
|
const getScope = () => __async(void 0, null, function* () {
|
|
171
218
|
const activeTab = window.targetTab;
|
|
172
|
-
const
|
|
173
|
-
return
|
|
219
|
+
const tabId = activeTab == null ? void 0 : activeTab.id;
|
|
220
|
+
return tabId ? String(tabId) : "noScope";
|
|
174
221
|
});
|
|
175
222
|
const injectScript = (excuteScript, world = false, ...args) => __async(void 0, null, function* () {
|
|
176
223
|
yield getInspectWindowTabId();
|
|
@@ -181,10 +228,16 @@ const injectScript = (excuteScript, world = false, ...args) => __async(void 0, n
|
|
|
181
228
|
func: excuteScript,
|
|
182
229
|
world: world ? "MAIN" : "ISOLATED",
|
|
183
230
|
args
|
|
184
|
-
}).then(() => {
|
|
231
|
+
}).then((results) => {
|
|
232
|
+
var _a;
|
|
185
233
|
console.log("InjectScript success, excuteScript:", args);
|
|
234
|
+
if (Array.isArray(results) && results.length) {
|
|
235
|
+
return (_a = results[0]) == null ? void 0 : _a.result;
|
|
236
|
+
}
|
|
237
|
+
return void 0;
|
|
186
238
|
}).catch((e) => {
|
|
187
239
|
console.log(e, "InjectScript fail, excuteScript:", args);
|
|
240
|
+
return void 0;
|
|
188
241
|
});
|
|
189
242
|
});
|
|
190
243
|
const getUrl = (file) => {
|
|
@@ -240,6 +293,9 @@ const setChromeStorage = (formData) => {
|
|
|
240
293
|
injectPostMessage,
|
|
241
294
|
injectScript,
|
|
242
295
|
injectToast,
|
|
296
|
+
refreshModuleInfo,
|
|
243
297
|
setChromeStorage,
|
|
298
|
+
setTargetTab,
|
|
299
|
+
syncActiveTab,
|
|
244
300
|
...require("./storage")
|
|
245
301
|
});
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var messages_exports = {};
|
|
20
|
+
__export(messages_exports, {
|
|
21
|
+
MESSAGE_ACTIVE_TAB_CHANGED: () => MESSAGE_ACTIVE_TAB_CHANGED,
|
|
22
|
+
MESSAGE_OPEN_SIDE_PANEL: () => MESSAGE_OPEN_SIDE_PANEL
|
|
23
|
+
});
|
|
24
|
+
module.exports = __toCommonJS(messages_exports);
|
|
25
|
+
const MESSAGE_OPEN_SIDE_PANEL = "mf-devtools/open-side-panel";
|
|
26
|
+
const MESSAGE_ACTIVE_TAB_CHANGED = "mf-devtools/active-tab-changed";
|
|
27
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
28
|
+
0 && (module.exports = {
|
|
29
|
+
MESSAGE_ACTIVE_TAB_CHANGED,
|
|
30
|
+
MESSAGE_OPEN_SIDE_PANEL
|
|
31
|
+
});
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __copyProps = (to, from, except, desc) => {
|
|
9
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
10
|
+
for (let key of __getOwnPropNames(from))
|
|
11
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
12
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
13
|
+
}
|
|
14
|
+
return to;
|
|
15
|
+
};
|
|
16
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
17
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
18
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
19
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
20
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
21
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
22
|
+
mod
|
|
23
|
+
));
|
|
24
|
+
var import_helpers = __toESM(require("@module-federation/runtime/helpers"));
|
|
25
|
+
var import_sdk = require("../sdk");
|
|
26
|
+
var import_template = require("../../template");
|
|
27
|
+
var _a;
|
|
28
|
+
const chromeOverrideRemotesPlugin = function() {
|
|
29
|
+
return {
|
|
30
|
+
name: "mf-chrome-devtools-override-remotes-plugin",
|
|
31
|
+
beforeRegisterRemote(args) {
|
|
32
|
+
try {
|
|
33
|
+
const { remote } = args;
|
|
34
|
+
const overrideRemote = import_helpers.default.global.nativeGlobal.localStorage.getItem(
|
|
35
|
+
import_template.__FEDERATION_DEVTOOLS__
|
|
36
|
+
);
|
|
37
|
+
if (!overrideRemote) {
|
|
38
|
+
return args;
|
|
39
|
+
}
|
|
40
|
+
const parsedOverrideRemote = JSON.parse(overrideRemote);
|
|
41
|
+
const overrideEntryOrVersion = parsedOverrideRemote[remote.name];
|
|
42
|
+
if (overrideEntryOrVersion) {
|
|
43
|
+
if (overrideEntryOrVersion.startsWith("http")) {
|
|
44
|
+
delete remote.version;
|
|
45
|
+
remote.entry = overrideEntryOrVersion;
|
|
46
|
+
} else {
|
|
47
|
+
delete remote.entry;
|
|
48
|
+
remote.version = overrideEntryOrVersion;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
} catch (e) {
|
|
52
|
+
console.error(e);
|
|
53
|
+
}
|
|
54
|
+
return args;
|
|
55
|
+
}
|
|
56
|
+
};
|
|
57
|
+
};
|
|
58
|
+
if (!(window == null ? void 0 : window.__FEDERATION__)) {
|
|
59
|
+
(0, import_sdk.definePropertyGlobalVal)(window, "__FEDERATION__", {});
|
|
60
|
+
(0, import_sdk.definePropertyGlobalVal)(window, "__VMOK__", window.__FEDERATION__);
|
|
61
|
+
}
|
|
62
|
+
if (!(window == null ? void 0 : window.__FEDERATION__.__GLOBAL_PLUGIN__)) {
|
|
63
|
+
window.__FEDERATION__.__GLOBAL_PLUGIN__ = [];
|
|
64
|
+
}
|
|
65
|
+
(_a = window.__FEDERATION__.__GLOBAL_PLUGIN__) == null ? void 0 : _a.push(chromeOverrideRemotesPlugin());
|
|
@@ -1,9 +1,17 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var _a;
|
|
2
|
+
var _a, _b;
|
|
3
3
|
const moduleInfo = (_a = window == null ? void 0 : window.__FEDERATION__) == null ? void 0 : _a.moduleInfo;
|
|
4
4
|
window.postMessage(
|
|
5
5
|
{
|
|
6
|
-
moduleInfo
|
|
6
|
+
moduleInfo,
|
|
7
|
+
share: JSON.parse(
|
|
8
|
+
JSON.stringify((_b = window == null ? void 0 : window.__FEDERATION__) == null ? void 0 : _b.__SHARE__, (_key, value) => {
|
|
9
|
+
if (typeof value === "function") {
|
|
10
|
+
return "Function";
|
|
11
|
+
}
|
|
12
|
+
return value;
|
|
13
|
+
})
|
|
14
|
+
)
|
|
7
15
|
},
|
|
8
16
|
"*"
|
|
9
17
|
);
|
|
@@ -38,6 +38,7 @@ var __async = (__this, __arguments, generator) => {
|
|
|
38
38
|
};
|
|
39
39
|
var storage_exports = {};
|
|
40
40
|
__export(storage_exports, {
|
|
41
|
+
getStorageValue: () => getStorageValue,
|
|
41
42
|
mergeStorage: () => mergeStorage,
|
|
42
43
|
removeStorage: () => removeStorage,
|
|
43
44
|
removeStorageKey: () => removeStorageKey,
|
|
@@ -58,8 +59,12 @@ const removeStorage = (...args) => __async(void 0, null, function* () {
|
|
|
58
59
|
const setStorage = (...args) => __async(void 0, null, function* () {
|
|
59
60
|
return (0, import_index.injectScript)(import_sdk.setLocalStorage, false, ...args);
|
|
60
61
|
});
|
|
62
|
+
const getStorageValue = (...args) => __async(void 0, null, function* () {
|
|
63
|
+
return (0, import_index.injectScript)(import_sdk.getLocalStorage, false, ...args);
|
|
64
|
+
});
|
|
61
65
|
// Annotate the CommonJS export names for ESM import in node:
|
|
62
66
|
0 && (module.exports = {
|
|
67
|
+
getStorageValue,
|
|
63
68
|
mergeStorage,
|
|
64
69
|
removeStorage,
|
|
65
70
|
removeStorageKey,
|
|
@@ -88,8 +88,8 @@ class DependencyGraph {
|
|
|
88
88
|
if (!remotesInfo) {
|
|
89
89
|
return;
|
|
90
90
|
}
|
|
91
|
-
Object.
|
|
92
|
-
const { matchedVersion } =
|
|
91
|
+
Object.entries(remotesInfo).forEach(([dep, remoteInfo]) => {
|
|
92
|
+
const { matchedVersion } = remoteInfo;
|
|
93
93
|
let childId = dep;
|
|
94
94
|
if (matchedVersion && matchedVersion !== "") {
|
|
95
95
|
childId = `${childId}:${matchedVersion}`;
|
|
@@ -130,7 +130,7 @@ class DependencyGraph {
|
|
|
130
130
|
type
|
|
131
131
|
});
|
|
132
132
|
}
|
|
133
|
-
run(targetGraph, target = this.initTarget, type, id = this.initTarget) {
|
|
133
|
+
run(targetGraph, target = this.initTarget, type, id = this.initTarget, depth = 0, maxDepth = Infinity) {
|
|
134
134
|
var _a;
|
|
135
135
|
if (!targetGraph || !((_a = Object.keys(targetGraph)) == null ? void 0 : _a.length)) {
|
|
136
136
|
return;
|
|
@@ -154,12 +154,17 @@ class DependencyGraph {
|
|
|
154
154
|
targetGraph[targetWithoutType] || targetGraph[target] || {}
|
|
155
155
|
);
|
|
156
156
|
graphChilden.forEach((dep) => {
|
|
157
|
+
if (depth + 1 > maxDepth) {
|
|
158
|
+
return;
|
|
159
|
+
}
|
|
157
160
|
this.addEdge(id + dep, id, id + dep);
|
|
158
161
|
this.run(
|
|
159
162
|
targetGraph[targetWithoutType] || targetGraph[target],
|
|
160
163
|
dep,
|
|
161
164
|
type,
|
|
162
|
-
id + dep
|
|
165
|
+
id + dep,
|
|
166
|
+
depth + 1,
|
|
167
|
+
maxDepth
|
|
163
168
|
);
|
|
164
169
|
});
|
|
165
170
|
}
|
|
@@ -170,6 +175,22 @@ class DependencyGraph {
|
|
|
170
175
|
const color = `rgba(${r},${g},${b},0.8)`;
|
|
171
176
|
return color;
|
|
172
177
|
}
|
|
178
|
+
calculateDepth(target = this.initTarget, visited = /* @__PURE__ */ new Set()) {
|
|
179
|
+
if (visited.has(target)) {
|
|
180
|
+
return 0;
|
|
181
|
+
}
|
|
182
|
+
visited.add(target);
|
|
183
|
+
const children = this.graph[target] ? Object.keys(this.graph[target]) : [];
|
|
184
|
+
if (children.length === 0) {
|
|
185
|
+
visited.delete(target);
|
|
186
|
+
return 0;
|
|
187
|
+
}
|
|
188
|
+
const maxChildDepth = Math.max(
|
|
189
|
+
...children.map((child) => this.calculateDepth(child, visited))
|
|
190
|
+
);
|
|
191
|
+
visited.delete(target);
|
|
192
|
+
return 1 + maxChildDepth;
|
|
193
|
+
}
|
|
173
194
|
}
|
|
174
195
|
// Annotate the CommonJS export names for ESM import in node:
|
|
175
196
|
0 && (module.exports = {
|
|
@@ -20,6 +20,7 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
20
20
|
var sdk_exports = {};
|
|
21
21
|
__export(sdk_exports, {
|
|
22
22
|
definePropertyGlobalVal: () => definePropertyGlobalVal,
|
|
23
|
+
getLocalStorage: () => getLocalStorage,
|
|
23
24
|
getUnpkgUrl: () => getUnpkgUrl,
|
|
24
25
|
isObject: () => isObject,
|
|
25
26
|
mergeLocalStorage: () => mergeLocalStorage,
|
|
@@ -34,6 +35,14 @@ __reExport(sdk_exports, require("./graph"), module.exports);
|
|
|
34
35
|
const setLocalStorage = (key, value) => {
|
|
35
36
|
localStorage.setItem(key, value);
|
|
36
37
|
};
|
|
38
|
+
const getLocalStorage = (key) => {
|
|
39
|
+
try {
|
|
40
|
+
return localStorage.getItem(key);
|
|
41
|
+
} catch (error) {
|
|
42
|
+
console.warn("[MF Devtools] getLocalStorage failed", error);
|
|
43
|
+
return null;
|
|
44
|
+
}
|
|
45
|
+
};
|
|
37
46
|
const removeLocalStorage = (key) => {
|
|
38
47
|
const data = localStorage.getItem(key);
|
|
39
48
|
if (data) {
|
|
@@ -83,6 +92,7 @@ const definePropertyGlobalVal = (target, key, val) => {
|
|
|
83
92
|
// Annotate the CommonJS export names for ESM import in node:
|
|
84
93
|
0 && (module.exports = {
|
|
85
94
|
definePropertyGlobalVal,
|
|
95
|
+
getLocalStorage,
|
|
86
96
|
getUnpkgUrl,
|
|
87
97
|
isObject,
|
|
88
98
|
mergeLocalStorage,
|
package/dist/lib/worker/index.js
CHANGED
|
@@ -1,2 +1,157 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
2
|
+
var __async = (__this, __arguments, generator) => {
|
|
3
|
+
return new Promise((resolve, reject) => {
|
|
4
|
+
var fulfilled = (value) => {
|
|
5
|
+
try {
|
|
6
|
+
step(generator.next(value));
|
|
7
|
+
} catch (e) {
|
|
8
|
+
reject(e);
|
|
9
|
+
}
|
|
10
|
+
};
|
|
11
|
+
var rejected = (value) => {
|
|
12
|
+
try {
|
|
13
|
+
step(generator.throw(value));
|
|
14
|
+
} catch (e) {
|
|
15
|
+
reject(e);
|
|
16
|
+
}
|
|
17
|
+
};
|
|
18
|
+
var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
|
|
19
|
+
step((generator = generator.apply(__this, __arguments)).next());
|
|
20
|
+
});
|
|
21
|
+
};
|
|
22
|
+
var import_messages = require("../utils/chrome/messages");
|
|
23
|
+
const SIDE_PANEL_PATH = "html/main/index.html";
|
|
24
|
+
const getSidePanel = () => chrome == null ? void 0 : chrome.sidePanel;
|
|
25
|
+
const resolveTabId = (tabId) => __async(exports, null, function* () {
|
|
26
|
+
if (typeof tabId === "number") {
|
|
27
|
+
return tabId;
|
|
28
|
+
}
|
|
29
|
+
const [activeTab] = yield chrome.tabs.query({
|
|
30
|
+
active: true,
|
|
31
|
+
lastFocusedWindow: true
|
|
32
|
+
});
|
|
33
|
+
return activeTab == null ? void 0 : activeTab.id;
|
|
34
|
+
});
|
|
35
|
+
const broadcastActiveTab = (tabId) => {
|
|
36
|
+
try {
|
|
37
|
+
chrome.runtime.sendMessage({
|
|
38
|
+
type: import_messages.MESSAGE_ACTIVE_TAB_CHANGED,
|
|
39
|
+
tabId
|
|
40
|
+
});
|
|
41
|
+
} catch (error) {
|
|
42
|
+
console.warn(
|
|
43
|
+
"[Module Federation Devtools] Failed to broadcast active tab",
|
|
44
|
+
error
|
|
45
|
+
);
|
|
46
|
+
}
|
|
47
|
+
};
|
|
48
|
+
const openSidePanel = (tabId) => __async(exports, null, function* () {
|
|
49
|
+
const sidePanel = getSidePanel();
|
|
50
|
+
if (!sidePanel) {
|
|
51
|
+
throw new Error("sidePanel api not available");
|
|
52
|
+
}
|
|
53
|
+
const targetTabId = yield resolveTabId(tabId);
|
|
54
|
+
if (typeof targetTabId !== "number") {
|
|
55
|
+
throw new Error("No active tab available");
|
|
56
|
+
}
|
|
57
|
+
yield sidePanel.setOptions({
|
|
58
|
+
tabId: targetTabId,
|
|
59
|
+
path: SIDE_PANEL_PATH,
|
|
60
|
+
enabled: true
|
|
61
|
+
});
|
|
62
|
+
if (sidePanel.open) {
|
|
63
|
+
yield sidePanel.open({ tabId: targetTabId });
|
|
64
|
+
}
|
|
65
|
+
broadcastActiveTab(targetTabId);
|
|
66
|
+
if (sidePanel.getOptions) {
|
|
67
|
+
try {
|
|
68
|
+
const options = yield sidePanel.getOptions({ tabId: targetTabId });
|
|
69
|
+
broadcastActiveTab(targetTabId);
|
|
70
|
+
return options;
|
|
71
|
+
} catch (error) {
|
|
72
|
+
console.warn("[Module Federation Devtools] getOptions failed", error);
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
return {
|
|
76
|
+
path: SIDE_PANEL_PATH,
|
|
77
|
+
enabled: true
|
|
78
|
+
};
|
|
79
|
+
});
|
|
80
|
+
chrome.runtime.onInstalled.addListener(() => {
|
|
81
|
+
const sidePanel = getSidePanel();
|
|
82
|
+
if (sidePanel == null ? void 0 : sidePanel.setPanelBehavior) {
|
|
83
|
+
sidePanel.setPanelBehavior({ openPanelOnActionClick: true }).catch((error) => {
|
|
84
|
+
console.warn(
|
|
85
|
+
"[Module Federation Devtools] setPanelBehavior failed",
|
|
86
|
+
error
|
|
87
|
+
);
|
|
88
|
+
});
|
|
89
|
+
}
|
|
90
|
+
});
|
|
91
|
+
chrome.action.onClicked.addListener((tab) => __async(exports, null, function* () {
|
|
92
|
+
try {
|
|
93
|
+
yield openSidePanel(tab.id);
|
|
94
|
+
} catch (error) {
|
|
95
|
+
console.warn(
|
|
96
|
+
"[Module Federation Devtools] Failed to open side panel",
|
|
97
|
+
error
|
|
98
|
+
);
|
|
99
|
+
}
|
|
100
|
+
}));
|
|
101
|
+
chrome.runtime.onMessage.addListener((message, _sender, sendResponse) => {
|
|
102
|
+
if ((message == null ? void 0 : message.type) === import_messages.MESSAGE_OPEN_SIDE_PANEL) {
|
|
103
|
+
openSidePanel(message.tabId).then((options) => sendResponse({ ok: true, options })).catch(
|
|
104
|
+
(error) => sendResponse({ ok: false, message: String(error) })
|
|
105
|
+
);
|
|
106
|
+
return true;
|
|
107
|
+
}
|
|
108
|
+
return void 0;
|
|
109
|
+
});
|
|
110
|
+
chrome.tabs.onActivated.addListener((activeInfo) => __async(exports, null, function* () {
|
|
111
|
+
const tabId = activeInfo == null ? void 0 : activeInfo.tabId;
|
|
112
|
+
if (typeof tabId !== "number") {
|
|
113
|
+
return;
|
|
114
|
+
}
|
|
115
|
+
try {
|
|
116
|
+
broadcastActiveTab(tabId);
|
|
117
|
+
} catch (error) {
|
|
118
|
+
console.warn(
|
|
119
|
+
"[Module Federation Devtools] Failed to handle tab activation",
|
|
120
|
+
error
|
|
121
|
+
);
|
|
122
|
+
}
|
|
123
|
+
}));
|
|
124
|
+
chrome.tabs.onUpdated.addListener((tabId, changeInfo, tab) => {
|
|
125
|
+
if (changeInfo.status !== "complete") {
|
|
126
|
+
return;
|
|
127
|
+
}
|
|
128
|
+
if (tab == null ? void 0 : tab.active) {
|
|
129
|
+
try {
|
|
130
|
+
broadcastActiveTab(tabId);
|
|
131
|
+
} catch (error) {
|
|
132
|
+
console.warn(
|
|
133
|
+
"[Module Federation Devtools] Failed to handle tab update",
|
|
134
|
+
error
|
|
135
|
+
);
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
});
|
|
139
|
+
chrome.tabs.onRemoved.addListener((tabId) => __async(exports, null, function* () {
|
|
140
|
+
try {
|
|
141
|
+
const FormID = "FormID";
|
|
142
|
+
const data = yield chrome.storage.sync.get(FormID);
|
|
143
|
+
const storeData = data[FormID];
|
|
144
|
+
if (storeData == null ? void 0 : storeData[String(tabId)]) {
|
|
145
|
+
delete storeData[String(tabId)];
|
|
146
|
+
yield chrome.storage.sync.set({
|
|
147
|
+
[FormID]: storeData
|
|
148
|
+
});
|
|
149
|
+
}
|
|
150
|
+
} catch (error) {
|
|
151
|
+
console.warn(
|
|
152
|
+
"[Module Federation Devtools] Failed to handle tab removal",
|
|
153
|
+
error
|
|
154
|
+
);
|
|
155
|
+
}
|
|
156
|
+
}));
|
|
157
|
+
console.log("Module Federation Worker ready");
|
package/dist/types/src/App.d.ts
CHANGED
|
@@ -13,6 +13,8 @@ interface FormProps {
|
|
|
13
13
|
validateForm: any;
|
|
14
14
|
enableHMR: string;
|
|
15
15
|
onHMRChange: (on: boolean) => void;
|
|
16
|
+
enableClip: boolean;
|
|
17
|
+
onClipChange: (on: boolean) => void;
|
|
16
18
|
headerSlot?: ReactNode;
|
|
17
19
|
}
|
|
18
20
|
declare const FormComponent: (props: FormProps & RootComponentProps) => import("react").JSX.Element;
|