@module-federation/devtools 0.22.0 → 0.23.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/es/App.css +13 -0
- package/dist/es/App.js +461 -21
- package/dist/es/App.module.js +1 -1
- package/dist/es/App_module.css +293 -5
- package/dist/es/component/DependencyGraph/index.js +204 -0
- package/dist/es/component/DependencyGraph/index.module.js +5 -0
- package/dist/es/component/DependencyGraph/index_module.css +100 -0
- package/dist/es/component/{GraphItem → DependencyGraphItem}/index.js +20 -9
- package/dist/es/component/DependencyGraphItem/index.module.js +5 -0
- package/dist/es/component/DependencyGraphItem/index_module.css +95 -0
- package/dist/es/component/Form/index.js +192 -117
- package/dist/es/component/Form/index.module.js +1 -1
- package/dist/es/component/Form/index_module.css +176 -25
- package/dist/es/component/LanguageSwitch.js +50 -0
- package/dist/es/component/Layout/index.js +296 -49
- package/dist/es/component/Layout/index.module.js +1 -1
- package/dist/es/component/Layout/index_module.css +52 -32
- package/dist/es/component/ModuleInfo/index.js +313 -0
- package/dist/es/component/ModuleInfo/index.module.js +5 -0
- package/dist/es/component/ModuleInfo/index_module.css +184 -0
- package/dist/es/component/SharedDepsExplorer/FocusResultDisplay.js +35 -0
- package/dist/es/component/SharedDepsExplorer/FocusResultDisplay.module.js +5 -0
- package/dist/es/component/SharedDepsExplorer/FocusResultDisplay_module.css +45 -0
- package/dist/es/component/SharedDepsExplorer/index.js +495 -0
- package/dist/es/component/SharedDepsExplorer/index.module.js +5 -0
- package/dist/es/component/SharedDepsExplorer/index_module.css +467 -0
- package/dist/es/component/SharedDepsExplorer/share-utils.js +206 -0
- package/dist/es/component/ThemeToggle.js +19 -0
- package/dist/es/component/ThemeToggle.module.js +5 -0
- package/dist/es/component/ThemeToggle_module.css +12 -0
- package/dist/es/hooks/useDevtoolsTheme.js +77 -0
- package/dist/es/i18n/index.js +506 -0
- package/dist/es/template/constant.js +3 -19
- package/dist/es/utils/chrome/index.js +91 -38
- package/dist/es/utils/chrome/messages.js +6 -0
- package/dist/es/utils/chrome/override-remote.js +42 -0
- package/dist/es/utils/chrome/post-message-listener.js +2 -1
- package/dist/es/utils/chrome/post-message-start.js +10 -2
- package/dist/es/utils/chrome/storage.js +6 -1
- package/dist/es/utils/sdk/graph.js +25 -4
- package/dist/es/utils/sdk/index.js +9 -0
- package/dist/es/worker/index.js +168 -1
- package/dist/lib/App.css +13 -0
- package/dist/lib/App.js +451 -18
- package/dist/lib/App.module.js +1 -1
- package/dist/lib/App_module.css +293 -5
- package/dist/lib/component/DependencyGraph/index.js +226 -0
- package/dist/lib/component/{GraphItem → DependencyGraph}/index.module.js +1 -1
- package/dist/lib/component/DependencyGraph/index_module.css +100 -0
- package/dist/lib/component/{GraphItem → DependencyGraphItem}/index.js +23 -12
- package/dist/lib/component/{Graph → DependencyGraphItem}/index.module.js +1 -1
- package/dist/lib/component/DependencyGraphItem/index_module.css +95 -0
- package/dist/lib/component/Form/index.js +189 -115
- package/dist/lib/component/Form/index.module.js +1 -1
- package/dist/lib/component/Form/index_module.css +176 -25
- package/dist/lib/component/LanguageSwitch.js +80 -0
- package/dist/lib/component/Layout/index.js +290 -47
- package/dist/lib/component/Layout/index.module.js +1 -1
- package/dist/lib/component/Layout/index_module.css +52 -32
- package/dist/lib/component/ModuleInfo/index.js +343 -0
- package/dist/lib/component/ModuleInfo/index.module.js +25 -0
- package/dist/lib/component/ModuleInfo/index_module.css +184 -0
- package/dist/lib/component/SharedDepsExplorer/FocusResultDisplay.js +65 -0
- package/dist/lib/component/SharedDepsExplorer/FocusResultDisplay.module.js +25 -0
- package/dist/lib/component/SharedDepsExplorer/FocusResultDisplay_module.css +45 -0
- package/dist/lib/component/SharedDepsExplorer/index.js +502 -0
- package/dist/lib/component/SharedDepsExplorer/index.module.js +25 -0
- package/dist/lib/component/SharedDepsExplorer/index_module.css +467 -0
- package/dist/lib/component/SharedDepsExplorer/share-utils.js +237 -0
- package/dist/lib/component/ThemeToggle.js +49 -0
- package/dist/lib/component/ThemeToggle.module.js +25 -0
- package/dist/lib/component/ThemeToggle_module.css +12 -0
- package/dist/lib/hooks/useDevtoolsTheme.js +101 -0
- package/dist/lib/i18n/index.js +540 -0
- package/dist/lib/template/constant.js +4 -17
- package/dist/lib/utils/chrome/index.js +94 -38
- package/dist/lib/utils/chrome/messages.js +31 -0
- package/dist/lib/utils/chrome/override-remote.js +65 -0
- package/dist/lib/utils/chrome/post-message-listener.js +2 -1
- package/dist/lib/utils/chrome/post-message-start.js +10 -2
- package/dist/lib/utils/chrome/storage.js +5 -0
- package/dist/lib/utils/sdk/graph.js +25 -4
- package/dist/lib/utils/sdk/index.js +10 -0
- package/dist/lib/worker/index.js +156 -1
- package/dist/types/src/App.d.ts +2 -1
- package/dist/types/src/component/{Graph → DependencyGraph}/index.d.ts +0 -1
- package/dist/types/src/component/{GraphItem → DependencyGraphItem}/index.d.ts +0 -1
- package/dist/types/src/component/Form/index.d.ts +2 -0
- package/dist/types/src/component/LanguageSwitch.d.ts +2 -0
- package/dist/types/src/component/Layout/index.d.ts +0 -1
- package/dist/types/src/component/ModuleInfo/index.d.ts +8 -0
- package/dist/types/src/component/SharedDepsExplorer/FocusResultDisplay.d.ts +15 -0
- package/dist/types/src/component/SharedDepsExplorer/index.d.ts +6 -0
- package/dist/types/src/component/SharedDepsExplorer/share-utils.d.ts +44 -0
- package/dist/types/src/component/ThemeToggle.d.ts +8 -0
- package/dist/types/src/hooks/useDevtoolsTheme.d.ts +2 -0
- package/dist/types/src/i18n/index.d.ts +5 -0
- package/dist/types/src/init.d.ts +0 -1
- package/dist/types/src/template/constant.d.ts +2 -5
- package/dist/types/src/utils/chrome/index.d.ts +5 -3
- package/dist/types/src/utils/chrome/messages.d.ts +2 -0
- package/dist/types/src/utils/chrome/override-remote.d.ts +1 -0
- package/dist/types/src/utils/chrome/storage.d.ts +5 -4
- package/dist/types/src/utils/sdk/graph.d.ts +2 -1
- package/dist/types/src/utils/sdk/index.d.ts +1 -0
- package/dist/types/src/utils/types/common.d.ts +4 -0
- package/dist/types/src/worker/index.d.ts +1 -0
- package/package.json +18 -14
- package/dist/es/component/Graph/index.js +0 -127
- package/dist/es/component/Graph/index.module.js +0 -5
- package/dist/es/component/Graph/index_module.css +0 -12
- package/dist/es/component/GraphItem/index.module.js +0 -5
- package/dist/es/component/GraphItem/index_module.css +0 -61
- package/dist/lib/component/Graph/index.js +0 -149
- package/dist/lib/component/Graph/index_module.css +0 -12
- package/dist/lib/component/GraphItem/index_module.css +0 -61
|
@@ -1,10 +1,27 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
var __create = Object.create;
|
|
3
3
|
var __defProp = Object.defineProperty;
|
|
4
|
+
var __defProps = Object.defineProperties;
|
|
4
5
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
6
|
+
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
5
7
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
8
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
6
9
|
var __getProtoOf = Object.getPrototypeOf;
|
|
7
10
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
11
|
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
12
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
13
|
+
var __spreadValues = (a, b) => {
|
|
14
|
+
for (var prop in b || (b = {}))
|
|
15
|
+
if (__hasOwnProp.call(b, prop))
|
|
16
|
+
__defNormalProp(a, prop, b[prop]);
|
|
17
|
+
if (__getOwnPropSymbols)
|
|
18
|
+
for (var prop of __getOwnPropSymbols(b)) {
|
|
19
|
+
if (__propIsEnum.call(b, prop))
|
|
20
|
+
__defNormalProp(a, prop, b[prop]);
|
|
21
|
+
}
|
|
22
|
+
return a;
|
|
23
|
+
};
|
|
24
|
+
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
8
25
|
var __export = (target, all) => {
|
|
9
26
|
for (var name in all)
|
|
10
27
|
__defProp(target, name, { get: all[name], enumerable: true });
|
|
@@ -55,11 +72,24 @@ var import_jsx_runtime = require("react/jsx-runtime");
|
|
|
55
72
|
var import_react = require("react");
|
|
56
73
|
var import_ahooks = require("ahooks");
|
|
57
74
|
var import_web_react = require("@arco-design/web-react");
|
|
75
|
+
var import_react_i18next = require("react-i18next");
|
|
58
76
|
var import_sdk = require("@module-federation/sdk");
|
|
59
77
|
var import_Form = __toESM(require("../Form"));
|
|
60
|
-
var import_Graph = __toESM(require("../Graph"));
|
|
61
78
|
var import_utils = require("../../utils");
|
|
62
79
|
var import_constant = require("../../template/constant");
|
|
80
|
+
var import_index = __toESM(require("./index.module"));
|
|
81
|
+
const sortRulesForSignature = (rules) => [...rules].sort((a, b) => {
|
|
82
|
+
const keyCompare = (a.key || "").localeCompare(b.key || "");
|
|
83
|
+
if (keyCompare !== 0) {
|
|
84
|
+
return keyCompare;
|
|
85
|
+
}
|
|
86
|
+
return (a.value || "").localeCompare(b.value || "");
|
|
87
|
+
}).map((rule) => ({
|
|
88
|
+
key: rule.key || "",
|
|
89
|
+
value: rule.value || "",
|
|
90
|
+
checked: Boolean(rule.checked)
|
|
91
|
+
}));
|
|
92
|
+
const getEffectiveSignature = (rules) => rules.length ? JSON.stringify(sortRulesForSignature(rules)) : "";
|
|
63
93
|
const Layout = (props) => {
|
|
64
94
|
const {
|
|
65
95
|
moduleInfo,
|
|
@@ -69,57 +99,165 @@ const Layout = (props) => {
|
|
|
69
99
|
getVersion,
|
|
70
100
|
handleProxyAddress,
|
|
71
101
|
customValueValidate,
|
|
72
|
-
headerSlot
|
|
102
|
+
headerSlot,
|
|
103
|
+
onModuleInfoChange,
|
|
104
|
+
onModuleInfoReset,
|
|
105
|
+
tabId
|
|
73
106
|
} = props;
|
|
107
|
+
const { t } = (0, import_react_i18next.useTranslation)();
|
|
74
108
|
const { producer } = (0, import_utils.separateType)(moduleInfo);
|
|
109
|
+
const producerKey = (0, import_react.useMemo)(() => producer.join("|"), [producer]);
|
|
75
110
|
const [condition, setCondition] = (0, import_react.useState)(import_constant.statusInfo.processing);
|
|
76
111
|
const [formStatus, setFormStatus] = (0, import_react.useState)([]);
|
|
77
|
-
const [snapshot, setSnapshot] = (0, import_react.useState)(moduleInfo);
|
|
78
112
|
const [form] = import_web_react.Form.useForm();
|
|
79
113
|
const [enableHMR, setEnalbeHMR] = (0, import_react.useState)("disable");
|
|
114
|
+
const [enableClip, setEnableClip] = (0, import_react.useState)(() => {
|
|
115
|
+
try {
|
|
116
|
+
if (tabId) {
|
|
117
|
+
return localStorage.getItem(`${import_constant.ENABLE_CLIP}_${tabId}`) === "true";
|
|
118
|
+
}
|
|
119
|
+
return false;
|
|
120
|
+
} catch (e) {
|
|
121
|
+
return false;
|
|
122
|
+
}
|
|
123
|
+
});
|
|
124
|
+
const lastFormSignatureRef = (0, import_react.useRef)("");
|
|
125
|
+
const lastEffectiveRulesRef = (0, import_react.useRef)("");
|
|
126
|
+
const lastRawRulesRef = (0, import_react.useRef)([]);
|
|
127
|
+
const lastEnableClipRef = (0, import_react.useRef)(enableClip);
|
|
128
|
+
const ensureFederationContext = () => {
|
|
129
|
+
if (!window.__FEDERATION__) {
|
|
130
|
+
window.__FEDERATION__ = {
|
|
131
|
+
originModuleInfo: moduleInfo || {},
|
|
132
|
+
moduleInfo: moduleInfo || {}
|
|
133
|
+
};
|
|
134
|
+
}
|
|
135
|
+
if (!window.__FEDERATION__.originModuleInfo) {
|
|
136
|
+
window.__FEDERATION__.originModuleInfo = moduleInfo || {};
|
|
137
|
+
}
|
|
138
|
+
if (!window.__FEDERATION__.moduleInfo) {
|
|
139
|
+
window.__FEDERATION__.moduleInfo = moduleInfo || {};
|
|
140
|
+
}
|
|
141
|
+
};
|
|
142
|
+
(0, import_react.useEffect)(() => {
|
|
143
|
+
ensureFederationContext();
|
|
144
|
+
window.__FEDERATION__.moduleInfo = JSON.parse(
|
|
145
|
+
JSON.stringify(moduleInfo || {})
|
|
146
|
+
);
|
|
147
|
+
window.__FEDERATION__.originModuleInfo = JSON.parse(
|
|
148
|
+
JSON.stringify(moduleInfo || {})
|
|
149
|
+
);
|
|
150
|
+
const rawRules = form.getFieldValue(import_constant.proxyFormField) || [];
|
|
151
|
+
lastRawRulesRef.current = JSON.parse(JSON.stringify(rawRules));
|
|
152
|
+
}, [moduleInfo, form]);
|
|
153
|
+
const collectEffectiveRules = (rules, statusList) => {
|
|
154
|
+
return rules.reduce((memo, current, idx) => {
|
|
155
|
+
if (!(current == null ? void 0 : current.checked)) {
|
|
156
|
+
return memo;
|
|
157
|
+
}
|
|
158
|
+
const status = statusList[idx];
|
|
159
|
+
const keyValid = status ? status.keyStatus : Boolean(current.key);
|
|
160
|
+
const valueValid = status ? status.valueStatus : Boolean(current.value);
|
|
161
|
+
if (!keyValid || !valueValid) {
|
|
162
|
+
return memo;
|
|
163
|
+
}
|
|
164
|
+
const duplicate = JSON.parse(JSON.stringify(current));
|
|
165
|
+
if (handleProxyAddress) {
|
|
166
|
+
duplicate.value = handleProxyAddress(duplicate.value);
|
|
167
|
+
}
|
|
168
|
+
memo.push(duplicate);
|
|
169
|
+
return memo;
|
|
170
|
+
}, []);
|
|
171
|
+
};
|
|
172
|
+
const hasPendingRule = (rules, statusList) => {
|
|
173
|
+
return rules.some((rule, idx) => {
|
|
174
|
+
if (!(rule == null ? void 0 : rule.checked)) {
|
|
175
|
+
return false;
|
|
176
|
+
}
|
|
177
|
+
const status = statusList[idx];
|
|
178
|
+
if (!status) {
|
|
179
|
+
return Boolean(rule.key) && !rule.value;
|
|
180
|
+
}
|
|
181
|
+
return Boolean(status.keyStatus) && !status.valueStatus;
|
|
182
|
+
});
|
|
183
|
+
};
|
|
80
184
|
const { run } = (0, import_ahooks.useDebounceFn)(
|
|
81
185
|
(formData) => __async(void 0, null, function* () {
|
|
186
|
+
ensureFederationContext();
|
|
82
187
|
window.__FEDERATION__.moduleInfo = JSON.parse(
|
|
83
188
|
JSON.stringify(window.__FEDERATION__.originModuleInfo)
|
|
84
189
|
);
|
|
85
|
-
const
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
const value = handleProxyAddress(duplicate.value);
|
|
97
|
-
duplicate.value = value;
|
|
98
|
-
}
|
|
99
|
-
return [...memo, duplicate];
|
|
100
|
-
},
|
|
101
|
-
[]
|
|
102
|
-
);
|
|
190
|
+
const rawRules = formData[import_constant.proxyFormField] || [];
|
|
191
|
+
const rawSignature = JSON.stringify(rawRules);
|
|
192
|
+
if (rawSignature === lastFormSignatureRef.current) {
|
|
193
|
+
return;
|
|
194
|
+
}
|
|
195
|
+
const effectiveRules = collectEffectiveRules(rawRules, formStatus);
|
|
196
|
+
const effectiveSignature = getEffectiveSignature(effectiveRules);
|
|
197
|
+
const pendingRule = hasPendingRule(rawRules, formStatus);
|
|
198
|
+
const hadPreviousEffective = lastEffectiveRulesRef.current !== "" && lastEffectiveRulesRef.current !== "[]";
|
|
199
|
+
const clipChanged = enableClip !== lastEnableClipRef.current;
|
|
200
|
+
lastEnableClipRef.current = enableClip;
|
|
103
201
|
try {
|
|
104
202
|
setCondition(import_constant.statusInfo.processing);
|
|
105
|
-
if (!
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
203
|
+
if (!effectiveRules.length) {
|
|
204
|
+
if (pendingRule) {
|
|
205
|
+
return;
|
|
206
|
+
}
|
|
207
|
+
if (hadPreviousEffective) {
|
|
208
|
+
yield (0, import_utils.removeStorage)(import_sdk.MODULE_DEVTOOL_IDENTIFIER);
|
|
209
|
+
yield (0, import_utils.removeStorage)(import_constant.BROWSER_ENV_KEY);
|
|
210
|
+
yield (0, import_utils.removeStorageKey)(import_constant.__FEDERATION_DEVTOOLS__, "overrides");
|
|
211
|
+
yield (0, import_utils.injectScript)(import_utils.reloadPage, false);
|
|
212
|
+
setCondition(import_constant.statusInfo.noProxy);
|
|
213
|
+
lastEffectiveRulesRef.current = "";
|
|
214
|
+
if (typeof onModuleInfoReset === "function") {
|
|
215
|
+
onModuleInfoReset();
|
|
216
|
+
} else {
|
|
217
|
+
onModuleInfoChange == null ? void 0 : onModuleInfoChange(window.__FEDERATION__.originModuleInfo);
|
|
218
|
+
}
|
|
219
|
+
} else {
|
|
220
|
+
setCondition(import_constant.statusInfo.noProxy);
|
|
221
|
+
}
|
|
110
222
|
setCondition(import_constant.statusInfo.noProxy);
|
|
111
|
-
setSnapshot(window.__FEDERATION__.originModuleInfo);
|
|
112
223
|
return;
|
|
113
224
|
}
|
|
114
|
-
|
|
225
|
+
if (!clipChanged && effectiveSignature === lastEffectiveRulesRef.current) {
|
|
226
|
+
if (hadPreviousEffective) {
|
|
227
|
+
setCondition(import_constant.statusInfo.success);
|
|
228
|
+
} else {
|
|
229
|
+
setCondition(import_constant.statusInfo.noProxy);
|
|
230
|
+
}
|
|
231
|
+
return;
|
|
232
|
+
}
|
|
233
|
+
if (rawRules.every((rule) => !rule.value)) {
|
|
234
|
+
if (hadPreviousEffective) {
|
|
235
|
+
setCondition(import_constant.statusInfo.success);
|
|
236
|
+
} else {
|
|
237
|
+
setCondition(import_constant.statusInfo.noProxy);
|
|
238
|
+
}
|
|
239
|
+
return;
|
|
240
|
+
}
|
|
241
|
+
const { moduleInfo: moduleInfo2, status, overrides } = handleSnapshot ? yield handleSnapshot(effectiveRules) : yield (0, import_utils.getModuleInfo)(effectiveRules);
|
|
242
|
+
if (enableClip) {
|
|
243
|
+
Object.values(moduleInfo2).forEach((val) => {
|
|
244
|
+
if (val.modules) {
|
|
245
|
+
val.modules = [];
|
|
246
|
+
}
|
|
247
|
+
if (val.shared) {
|
|
248
|
+
val.shared = [];
|
|
249
|
+
}
|
|
250
|
+
});
|
|
251
|
+
}
|
|
115
252
|
const snapshotJson = JSON.stringify(moduleInfo2);
|
|
116
253
|
yield (0, import_utils.setStorage)(import_sdk.MODULE_DEVTOOL_IDENTIFIER, snapshotJson);
|
|
117
254
|
yield (0, import_utils.setStorage)(import_constant.BROWSER_ENV_KEY);
|
|
118
255
|
yield (0, import_utils.mergeStorage)(import_constant.__FEDERATION_DEVTOOLS__, "overrides", overrides);
|
|
119
256
|
yield (0, import_utils.injectScript)(import_utils.reloadPage, false);
|
|
120
257
|
window.__FEDERATION__.moduleInfo = moduleInfo2;
|
|
121
|
-
|
|
258
|
+
onModuleInfoChange == null ? void 0 : onModuleInfoChange(moduleInfo2);
|
|
122
259
|
setCondition(import_constant.statusInfo[status]);
|
|
260
|
+
lastEffectiveRulesRef.current = effectiveSignature;
|
|
123
261
|
} catch (e) {
|
|
124
262
|
console.log(e);
|
|
125
263
|
setCondition(import_constant.statusInfo.error);
|
|
@@ -130,28 +268,86 @@ const Layout = (props) => {
|
|
|
130
268
|
}
|
|
131
269
|
);
|
|
132
270
|
(0, import_react.useEffect)(() => {
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
(0, import_utils.getScope)().then((scope) => __async(void 0, null, function* () {
|
|
271
|
+
ensureFederationContext();
|
|
272
|
+
let cancelled = false;
|
|
273
|
+
const hydrateForm = () => __async(void 0, null, function* () {
|
|
137
274
|
var _a, _b, _c;
|
|
275
|
+
const scope = yield (0, import_utils.getScope)();
|
|
138
276
|
const data = yield chrome.storage.sync.get([import_constant.FormID]);
|
|
139
277
|
const config = (_a = data == null ? void 0 : data[import_constant.FormID]) == null ? void 0 : _a[scope];
|
|
140
278
|
let storeData;
|
|
141
279
|
if ((0, import_utils.isObject)(config)) {
|
|
142
280
|
storeData = JSON.parse(JSON.stringify(config));
|
|
143
|
-
|
|
144
|
-
(
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
281
|
+
if (producer.length) {
|
|
282
|
+
storeData[import_constant.proxyFormField] = (_b = storeData[import_constant.proxyFormField]) == null ? void 0 : _b.filter(
|
|
283
|
+
(item) => producer.includes(item.key)
|
|
284
|
+
);
|
|
285
|
+
if (!((_c = storeData[import_constant.proxyFormField]) == null ? void 0 : _c.length)) {
|
|
286
|
+
storeData = JSON.parse(JSON.stringify(import_constant.defaultModuleData));
|
|
287
|
+
}
|
|
148
288
|
}
|
|
149
289
|
} else {
|
|
150
|
-
storeData = import_constant.defaultModuleData;
|
|
290
|
+
storeData = JSON.parse(JSON.stringify(import_constant.defaultModuleData));
|
|
151
291
|
}
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
292
|
+
let overridesApplied = false;
|
|
293
|
+
try {
|
|
294
|
+
const overridesState = yield (0, import_utils.getStorageValue)(import_constant.__FEDERATION_DEVTOOLS__);
|
|
295
|
+
if (typeof overridesState === "string" && overridesState) {
|
|
296
|
+
const parsedState = JSON.parse(overridesState);
|
|
297
|
+
const overrides = parsedState == null ? void 0 : parsedState.overrides;
|
|
298
|
+
if ((0, import_utils.isObject)(overrides)) {
|
|
299
|
+
const overrideRules = Object.entries(overrides).map(([key, value]) => ({
|
|
300
|
+
key,
|
|
301
|
+
value: typeof value === "string" ? value : "",
|
|
302
|
+
checked: true
|
|
303
|
+
})).filter(
|
|
304
|
+
(rule) => Boolean(rule.key) && Boolean(rule.value)
|
|
305
|
+
);
|
|
306
|
+
const filteredRules = producer.length ? overrideRules.filter((rule) => producer.includes(rule.key)) : overrideRules;
|
|
307
|
+
if (filteredRules.length) {
|
|
308
|
+
storeData = __spreadProps(__spreadValues({}, storeData), {
|
|
309
|
+
[import_constant.proxyFormField]: filteredRules
|
|
310
|
+
});
|
|
311
|
+
overridesApplied = true;
|
|
312
|
+
}
|
|
313
|
+
}
|
|
314
|
+
}
|
|
315
|
+
} catch (error) {
|
|
316
|
+
console.warn(
|
|
317
|
+
"[MF Devtools] hydrate overrides from localStorage failed",
|
|
318
|
+
error
|
|
319
|
+
);
|
|
320
|
+
}
|
|
321
|
+
if (!cancelled) {
|
|
322
|
+
form.setFieldsValue(storeData);
|
|
323
|
+
lastFormSignatureRef.current = JSON.stringify(storeData);
|
|
324
|
+
const rules = Array.isArray(
|
|
325
|
+
storeData[import_constant.proxyFormField]
|
|
326
|
+
) ? storeData[import_constant.proxyFormField] : [];
|
|
327
|
+
const effectiveRules = collectEffectiveRules(rules, []);
|
|
328
|
+
lastEffectiveRulesRef.current = getEffectiveSignature(effectiveRules);
|
|
329
|
+
lastRawRulesRef.current = JSON.parse(JSON.stringify(rules));
|
|
330
|
+
setFormStatus(
|
|
331
|
+
rules.map((rule) => ({
|
|
332
|
+
keyStatus: Boolean(rule == null ? void 0 : rule.key),
|
|
333
|
+
valueStatus: Boolean(rule == null ? void 0 : rule.value)
|
|
334
|
+
}))
|
|
335
|
+
);
|
|
336
|
+
if (overridesApplied) {
|
|
337
|
+
(0, import_utils.setChromeStorage)(storeData);
|
|
338
|
+
}
|
|
339
|
+
if (effectiveRules.length) {
|
|
340
|
+
setCondition(import_constant.statusInfo.success);
|
|
341
|
+
} else {
|
|
342
|
+
setCondition(import_constant.statusInfo.noProxy);
|
|
343
|
+
}
|
|
344
|
+
}
|
|
345
|
+
});
|
|
346
|
+
hydrateForm();
|
|
347
|
+
return () => {
|
|
348
|
+
cancelled = true;
|
|
349
|
+
};
|
|
350
|
+
}, [moduleInfo, producerKey, form]);
|
|
155
351
|
(0, import_react.useEffect)(() => {
|
|
156
352
|
chrome.storage.sync.get([import_constant.ENABLEHMR]).then((data) => {
|
|
157
353
|
const enable = data[import_constant.ENABLEHMR];
|
|
@@ -164,9 +360,25 @@ const Layout = (props) => {
|
|
|
164
360
|
validateForm(form);
|
|
165
361
|
}, []);
|
|
166
362
|
(0, import_ahooks.useUpdateEffect)(() => {
|
|
363
|
+
if (!producer.length) {
|
|
364
|
+
return;
|
|
365
|
+
}
|
|
167
366
|
const formData = form.getFieldsValue();
|
|
367
|
+
const signature = JSON.stringify(formData);
|
|
368
|
+
if (signature === lastFormSignatureRef.current) {
|
|
369
|
+
return;
|
|
370
|
+
}
|
|
371
|
+
lastFormSignatureRef.current = signature;
|
|
372
|
+
const effectiveRules = collectEffectiveRules(
|
|
373
|
+
formData[import_constant.proxyFormField] || [],
|
|
374
|
+
formStatus
|
|
375
|
+
);
|
|
376
|
+
const effectiveSignature = getEffectiveSignature(effectiveRules);
|
|
377
|
+
if (effectiveSignature === lastEffectiveRulesRef.current) {
|
|
378
|
+
return;
|
|
379
|
+
}
|
|
168
380
|
run(formData);
|
|
169
|
-
}, []);
|
|
381
|
+
}, [producerKey, formStatus]);
|
|
170
382
|
const validateForm = (form2) => {
|
|
171
383
|
setTimeout(() => {
|
|
172
384
|
form2.validate().catch(() => {
|
|
@@ -176,6 +388,11 @@ const Layout = (props) => {
|
|
|
176
388
|
};
|
|
177
389
|
const onValuesChange = (target, formData) => {
|
|
178
390
|
validateForm(form);
|
|
391
|
+
const signature = JSON.stringify(formData);
|
|
392
|
+
if (signature === lastFormSignatureRef.current) {
|
|
393
|
+
return;
|
|
394
|
+
}
|
|
395
|
+
lastFormSignatureRef.current = signature;
|
|
179
396
|
(0, import_utils.setChromeStorage)(formData);
|
|
180
397
|
run(formData);
|
|
181
398
|
};
|
|
@@ -192,8 +409,33 @@ const Layout = (props) => {
|
|
|
192
409
|
}
|
|
193
410
|
(0, import_utils.injectScript)(import_utils.reloadPage, false);
|
|
194
411
|
};
|
|
195
|
-
|
|
196
|
-
|
|
412
|
+
const onClipChange = (on) => {
|
|
413
|
+
setEnableClip(on);
|
|
414
|
+
try {
|
|
415
|
+
if (tabId) {
|
|
416
|
+
localStorage.setItem(`${import_constant.ENABLE_CLIP}_${tabId}`, String(on));
|
|
417
|
+
}
|
|
418
|
+
} catch (e) {
|
|
419
|
+
console.error(e);
|
|
420
|
+
}
|
|
421
|
+
run(form.getFieldsValue());
|
|
422
|
+
};
|
|
423
|
+
const remotePreview = producer.map((id) => {
|
|
424
|
+
const [, name] = id.split(":");
|
|
425
|
+
return name || id;
|
|
426
|
+
}).filter(Boolean);
|
|
427
|
+
const previewList = remotePreview.slice(0, 4);
|
|
428
|
+
const extraCount = remotePreview.length > previewList.length ? remotePreview.length - previewList.length : 0;
|
|
429
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: import_index.default.wrapper, children: [
|
|
430
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: import_index.default.summaryCard, children: [
|
|
431
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: import_index.default.summaryHeader, children: [
|
|
432
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: import_index.default.summaryTitle, children: t("layout.summary.title") }),
|
|
433
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: import_index.default.summaryHint, children: t("layout.summary.hint") })
|
|
434
|
+
] }),
|
|
435
|
+
previewList.length ? previewList.map((name) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: import_index.default.chip, children: name }, name)) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: import_index.default.chipPlaceholder, children: t("layout.summary.placeholder") }),
|
|
436
|
+
extraCount > 0 && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: import_index.default.moreChip, children: t("layout.summary.more", { count: extraCount }) })
|
|
437
|
+
] }),
|
|
438
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("section", { className: import_index.default.formSection, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
197
439
|
import_web_react.Form,
|
|
198
440
|
{
|
|
199
441
|
form,
|
|
@@ -209,6 +451,8 @@ const Layout = (props) => {
|
|
|
209
451
|
validateForm: () => validateForm(form),
|
|
210
452
|
enableHMR,
|
|
211
453
|
onHMRChange,
|
|
454
|
+
enableClip,
|
|
455
|
+
onClipChange,
|
|
212
456
|
versionList,
|
|
213
457
|
setVersionList,
|
|
214
458
|
getVersion,
|
|
@@ -217,8 +461,7 @@ const Layout = (props) => {
|
|
|
217
461
|
}
|
|
218
462
|
)
|
|
219
463
|
}
|
|
220
|
-
)
|
|
221
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_Graph.default, { snapshot })
|
|
464
|
+
) })
|
|
222
465
|
] });
|
|
223
466
|
};
|
|
224
467
|
var Layout_default = Layout;
|
|
@@ -22,4 +22,4 @@ __export(index_module_exports, {
|
|
|
22
22
|
});
|
|
23
23
|
module.exports = __toCommonJS(index_module_exports);
|
|
24
24
|
var import_index_module = require("./index_module.css");
|
|
25
|
-
var index_module_default = { "
|
|
25
|
+
var index_module_default = { "wrapper": "wrapper_084ab", "summaryCard": "summaryCard_084ab", "summaryHeader": "summaryHeader_084ab", "summaryTitle": "summaryTitle_084ab", "summaryHint": "summaryHint_084ab", "chipGroup": "chipGroup_084ab", "chip": "chip_084ab", "moreChip": "moreChip_084ab", "chipPlaceholder": "chipPlaceholder_084ab", "formSection": "formSection_084ab" };
|
|
@@ -1,48 +1,68 @@
|
|
|
1
|
-
.
|
|
2
|
-
|
|
1
|
+
.wrapper_084ab {
|
|
2
|
+
display: flex;
|
|
3
|
+
flex-direction: column;
|
|
4
|
+
gap: 24px;
|
|
5
|
+
flex: 1 1;
|
|
3
6
|
}
|
|
4
7
|
|
|
5
|
-
.
|
|
8
|
+
.summaryCard_084ab {
|
|
9
|
+
padding: 18px 20px;
|
|
10
|
+
border: 1px solid rgba(228, 228, 231, 0.5);
|
|
6
11
|
display: flex;
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
.card_084ab .appName_084ab {
|
|
11
|
-
margin: 1vh 0;
|
|
12
|
+
flex-direction: column;
|
|
13
|
+
gap: 16px;
|
|
14
|
+
min-height: 110px;
|
|
12
15
|
}
|
|
13
16
|
|
|
14
|
-
.
|
|
17
|
+
.summaryHeader_084ab {
|
|
15
18
|
display: flex;
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
color: rgb(78, 89, 105);
|
|
19
|
+
flex-direction: column;
|
|
20
|
+
gap: 6px;
|
|
19
21
|
}
|
|
20
|
-
|
|
21
|
-
|
|
22
|
+
|
|
23
|
+
.summaryTitle_084ab {
|
|
24
|
+
font-size: 16px;
|
|
25
|
+
font-weight: 600;
|
|
26
|
+
color: var(--color-text-1, #1f2937);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
.summaryHint_084ab {
|
|
30
|
+
font-size: 12px;
|
|
31
|
+
color: var(--color-text-2, #4b5563);
|
|
22
32
|
}
|
|
23
33
|
|
|
24
|
-
.
|
|
34
|
+
.chipGroup_084ab {
|
|
25
35
|
display: flex;
|
|
26
36
|
align-items: center;
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
.header_084ab .add_084ab {
|
|
30
|
-
margin: 0 0.5vw;
|
|
37
|
+
flex-wrap: wrap;
|
|
38
|
+
gap: 8px;
|
|
31
39
|
}
|
|
32
|
-
|
|
33
|
-
|
|
40
|
+
|
|
41
|
+
.chip_084ab,
|
|
42
|
+
.moreChip_084ab,
|
|
43
|
+
.chipPlaceholder_084ab {
|
|
44
|
+
padding: 6px 10px;
|
|
45
|
+
border-radius: 12px;
|
|
46
|
+
border: 1px solid rgba(228, 228, 231, 0.5);
|
|
47
|
+
background: var(--color-bg-1, rgba(255, 255, 255, 0.9));
|
|
48
|
+
font-size: 12px;
|
|
49
|
+
color: var(--color-text-1, #1f2937);
|
|
50
|
+
letter-spacing: 0.02em;
|
|
34
51
|
}
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
52
|
+
|
|
53
|
+
.chipPlaceholder_084ab {
|
|
54
|
+
border-style: dashed;
|
|
55
|
+
color: var(--color-text-2, #4b5563);
|
|
56
|
+
background: var(--color-bg-1, rgba(255, 255, 255, 0.9));
|
|
40
57
|
}
|
|
41
|
-
|
|
42
|
-
|
|
58
|
+
|
|
59
|
+
.moreChip_084ab {
|
|
60
|
+
background: rgba(243, 244, 246, 0.4);
|
|
61
|
+
border-color: rgba(228, 228, 231, 0.5);
|
|
43
62
|
}
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
63
|
+
|
|
64
|
+
.formSection_084ab {
|
|
65
|
+
padding: 22px 24px;
|
|
66
|
+
border: 1px solid rgba(228, 228, 231, 0.5);
|
|
67
|
+
background: var(--color-bg-1, rgba(255, 255, 255, 0.9));
|
|
48
68
|
}
|