@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,3 +1,22 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __defProps = Object.defineProperties;
|
|
3
|
+
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
4
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
7
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
8
|
+
var __spreadValues = (a, b) => {
|
|
9
|
+
for (var prop in b || (b = {}))
|
|
10
|
+
if (__hasOwnProp.call(b, prop))
|
|
11
|
+
__defNormalProp(a, prop, b[prop]);
|
|
12
|
+
if (__getOwnPropSymbols)
|
|
13
|
+
for (var prop of __getOwnPropSymbols(b)) {
|
|
14
|
+
if (__propIsEnum.call(b, prop))
|
|
15
|
+
__defNormalProp(a, prop, b[prop]);
|
|
16
|
+
}
|
|
17
|
+
return a;
|
|
18
|
+
};
|
|
19
|
+
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
1
20
|
var __async = (__this, __arguments, generator) => {
|
|
2
21
|
return new Promise((resolve, reject) => {
|
|
3
22
|
var fulfilled = (value) => {
|
|
@@ -18,15 +37,15 @@ var __async = (__this, __arguments, generator) => {
|
|
|
18
37
|
step((generator = generator.apply(__this, __arguments)).next());
|
|
19
38
|
});
|
|
20
39
|
};
|
|
21
|
-
import {
|
|
22
|
-
import { useEffect, useState } from "react";
|
|
40
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
41
|
+
import { useEffect, useMemo, useState, useRef } from "react";
|
|
23
42
|
import { useDebounceFn, useUpdateEffect } from "ahooks";
|
|
24
43
|
import { Form } from "@arco-design/web-react";
|
|
44
|
+
import { useTranslation } from "react-i18next";
|
|
25
45
|
import {
|
|
26
46
|
MODULE_DEVTOOL_IDENTIFIER
|
|
27
47
|
} from "@module-federation/sdk";
|
|
28
48
|
import FormComponent from "../Form";
|
|
29
|
-
import Dependency from "../Graph";
|
|
30
49
|
import {
|
|
31
50
|
getModuleInfo,
|
|
32
51
|
getScope,
|
|
@@ -35,6 +54,7 @@ import {
|
|
|
35
54
|
separateType,
|
|
36
55
|
reloadPage,
|
|
37
56
|
setChromeStorage,
|
|
57
|
+
getStorageValue,
|
|
38
58
|
mergeStorage,
|
|
39
59
|
removeStorageKey,
|
|
40
60
|
removeStorage,
|
|
@@ -46,11 +66,25 @@ import {
|
|
|
46
66
|
FormID,
|
|
47
67
|
statusInfo,
|
|
48
68
|
ENABLEHMR,
|
|
69
|
+
ENABLE_CLIP,
|
|
49
70
|
__ENABLE_FAST_REFRESH__,
|
|
50
71
|
BROWSER_ENV_KEY,
|
|
51
72
|
__FEDERATION_DEVTOOLS__,
|
|
52
73
|
__EAGER_SHARE__
|
|
53
74
|
} from "../../template/constant";
|
|
75
|
+
import styles from "./index.module";
|
|
76
|
+
const sortRulesForSignature = (rules) => [...rules].sort((a, b) => {
|
|
77
|
+
const keyCompare = (a.key || "").localeCompare(b.key || "");
|
|
78
|
+
if (keyCompare !== 0) {
|
|
79
|
+
return keyCompare;
|
|
80
|
+
}
|
|
81
|
+
return (a.value || "").localeCompare(b.value || "");
|
|
82
|
+
}).map((rule) => ({
|
|
83
|
+
key: rule.key || "",
|
|
84
|
+
value: rule.value || "",
|
|
85
|
+
checked: Boolean(rule.checked)
|
|
86
|
+
}));
|
|
87
|
+
const getEffectiveSignature = (rules) => rules.length ? JSON.stringify(sortRulesForSignature(rules)) : "";
|
|
54
88
|
const Layout = (props) => {
|
|
55
89
|
const {
|
|
56
90
|
moduleInfo,
|
|
@@ -60,57 +94,165 @@ const Layout = (props) => {
|
|
|
60
94
|
getVersion,
|
|
61
95
|
handleProxyAddress,
|
|
62
96
|
customValueValidate,
|
|
63
|
-
headerSlot
|
|
97
|
+
headerSlot,
|
|
98
|
+
onModuleInfoChange,
|
|
99
|
+
onModuleInfoReset,
|
|
100
|
+
tabId
|
|
64
101
|
} = props;
|
|
102
|
+
const { t } = useTranslation();
|
|
65
103
|
const { producer } = separateType(moduleInfo);
|
|
104
|
+
const producerKey = useMemo(() => producer.join("|"), [producer]);
|
|
66
105
|
const [condition, setCondition] = useState(statusInfo.processing);
|
|
67
106
|
const [formStatus, setFormStatus] = useState([]);
|
|
68
|
-
const [snapshot, setSnapshot] = useState(moduleInfo);
|
|
69
107
|
const [form] = Form.useForm();
|
|
70
108
|
const [enableHMR, setEnalbeHMR] = useState("disable");
|
|
109
|
+
const [enableClip, setEnableClip] = useState(() => {
|
|
110
|
+
try {
|
|
111
|
+
if (tabId) {
|
|
112
|
+
return localStorage.getItem(`${ENABLE_CLIP}_${tabId}`) === "true";
|
|
113
|
+
}
|
|
114
|
+
return false;
|
|
115
|
+
} catch (e) {
|
|
116
|
+
return false;
|
|
117
|
+
}
|
|
118
|
+
});
|
|
119
|
+
const lastFormSignatureRef = useRef("");
|
|
120
|
+
const lastEffectiveRulesRef = useRef("");
|
|
121
|
+
const lastRawRulesRef = useRef([]);
|
|
122
|
+
const lastEnableClipRef = useRef(enableClip);
|
|
123
|
+
const ensureFederationContext = () => {
|
|
124
|
+
if (!window.__FEDERATION__) {
|
|
125
|
+
window.__FEDERATION__ = {
|
|
126
|
+
originModuleInfo: moduleInfo || {},
|
|
127
|
+
moduleInfo: moduleInfo || {}
|
|
128
|
+
};
|
|
129
|
+
}
|
|
130
|
+
if (!window.__FEDERATION__.originModuleInfo) {
|
|
131
|
+
window.__FEDERATION__.originModuleInfo = moduleInfo || {};
|
|
132
|
+
}
|
|
133
|
+
if (!window.__FEDERATION__.moduleInfo) {
|
|
134
|
+
window.__FEDERATION__.moduleInfo = moduleInfo || {};
|
|
135
|
+
}
|
|
136
|
+
};
|
|
137
|
+
useEffect(() => {
|
|
138
|
+
ensureFederationContext();
|
|
139
|
+
window.__FEDERATION__.moduleInfo = JSON.parse(
|
|
140
|
+
JSON.stringify(moduleInfo || {})
|
|
141
|
+
);
|
|
142
|
+
window.__FEDERATION__.originModuleInfo = JSON.parse(
|
|
143
|
+
JSON.stringify(moduleInfo || {})
|
|
144
|
+
);
|
|
145
|
+
const rawRules = form.getFieldValue(proxyFormField) || [];
|
|
146
|
+
lastRawRulesRef.current = JSON.parse(JSON.stringify(rawRules));
|
|
147
|
+
}, [moduleInfo, form]);
|
|
148
|
+
const collectEffectiveRules = (rules, statusList) => {
|
|
149
|
+
return rules.reduce((memo, current, idx) => {
|
|
150
|
+
if (!(current == null ? void 0 : current.checked)) {
|
|
151
|
+
return memo;
|
|
152
|
+
}
|
|
153
|
+
const status = statusList[idx];
|
|
154
|
+
const keyValid = status ? status.keyStatus : Boolean(current.key);
|
|
155
|
+
const valueValid = status ? status.valueStatus : Boolean(current.value);
|
|
156
|
+
if (!keyValid || !valueValid) {
|
|
157
|
+
return memo;
|
|
158
|
+
}
|
|
159
|
+
const duplicate = JSON.parse(JSON.stringify(current));
|
|
160
|
+
if (handleProxyAddress) {
|
|
161
|
+
duplicate.value = handleProxyAddress(duplicate.value);
|
|
162
|
+
}
|
|
163
|
+
memo.push(duplicate);
|
|
164
|
+
return memo;
|
|
165
|
+
}, []);
|
|
166
|
+
};
|
|
167
|
+
const hasPendingRule = (rules, statusList) => {
|
|
168
|
+
return rules.some((rule, idx) => {
|
|
169
|
+
if (!(rule == null ? void 0 : rule.checked)) {
|
|
170
|
+
return false;
|
|
171
|
+
}
|
|
172
|
+
const status = statusList[idx];
|
|
173
|
+
if (!status) {
|
|
174
|
+
return Boolean(rule.key) && !rule.value;
|
|
175
|
+
}
|
|
176
|
+
return Boolean(status.keyStatus) && !status.valueStatus;
|
|
177
|
+
});
|
|
178
|
+
};
|
|
71
179
|
const { run } = useDebounceFn(
|
|
72
180
|
(formData) => __async(void 0, null, function* () {
|
|
181
|
+
ensureFederationContext();
|
|
73
182
|
window.__FEDERATION__.moduleInfo = JSON.parse(
|
|
74
183
|
JSON.stringify(window.__FEDERATION__.originModuleInfo)
|
|
75
184
|
);
|
|
76
|
-
const
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
const value = handleProxyAddress(duplicate.value);
|
|
88
|
-
duplicate.value = value;
|
|
89
|
-
}
|
|
90
|
-
return [...memo, duplicate];
|
|
91
|
-
},
|
|
92
|
-
[]
|
|
93
|
-
);
|
|
185
|
+
const rawRules = formData[proxyFormField] || [];
|
|
186
|
+
const rawSignature = JSON.stringify(rawRules);
|
|
187
|
+
if (rawSignature === lastFormSignatureRef.current) {
|
|
188
|
+
return;
|
|
189
|
+
}
|
|
190
|
+
const effectiveRules = collectEffectiveRules(rawRules, formStatus);
|
|
191
|
+
const effectiveSignature = getEffectiveSignature(effectiveRules);
|
|
192
|
+
const pendingRule = hasPendingRule(rawRules, formStatus);
|
|
193
|
+
const hadPreviousEffective = lastEffectiveRulesRef.current !== "" && lastEffectiveRulesRef.current !== "[]";
|
|
194
|
+
const clipChanged = enableClip !== lastEnableClipRef.current;
|
|
195
|
+
lastEnableClipRef.current = enableClip;
|
|
94
196
|
try {
|
|
95
197
|
setCondition(statusInfo.processing);
|
|
96
|
-
if (!
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
198
|
+
if (!effectiveRules.length) {
|
|
199
|
+
if (pendingRule) {
|
|
200
|
+
return;
|
|
201
|
+
}
|
|
202
|
+
if (hadPreviousEffective) {
|
|
203
|
+
yield removeStorage(MODULE_DEVTOOL_IDENTIFIER);
|
|
204
|
+
yield removeStorage(BROWSER_ENV_KEY);
|
|
205
|
+
yield removeStorageKey(__FEDERATION_DEVTOOLS__, "overrides");
|
|
206
|
+
yield injectScript(reloadPage, false);
|
|
207
|
+
setCondition(statusInfo.noProxy);
|
|
208
|
+
lastEffectiveRulesRef.current = "";
|
|
209
|
+
if (typeof onModuleInfoReset === "function") {
|
|
210
|
+
onModuleInfoReset();
|
|
211
|
+
} else {
|
|
212
|
+
onModuleInfoChange == null ? void 0 : onModuleInfoChange(window.__FEDERATION__.originModuleInfo);
|
|
213
|
+
}
|
|
214
|
+
} else {
|
|
215
|
+
setCondition(statusInfo.noProxy);
|
|
216
|
+
}
|
|
101
217
|
setCondition(statusInfo.noProxy);
|
|
102
|
-
setSnapshot(window.__FEDERATION__.originModuleInfo);
|
|
103
218
|
return;
|
|
104
219
|
}
|
|
105
|
-
|
|
220
|
+
if (!clipChanged && effectiveSignature === lastEffectiveRulesRef.current) {
|
|
221
|
+
if (hadPreviousEffective) {
|
|
222
|
+
setCondition(statusInfo.success);
|
|
223
|
+
} else {
|
|
224
|
+
setCondition(statusInfo.noProxy);
|
|
225
|
+
}
|
|
226
|
+
return;
|
|
227
|
+
}
|
|
228
|
+
if (rawRules.every((rule) => !rule.value)) {
|
|
229
|
+
if (hadPreviousEffective) {
|
|
230
|
+
setCondition(statusInfo.success);
|
|
231
|
+
} else {
|
|
232
|
+
setCondition(statusInfo.noProxy);
|
|
233
|
+
}
|
|
234
|
+
return;
|
|
235
|
+
}
|
|
236
|
+
const { moduleInfo: moduleInfo2, status, overrides } = handleSnapshot ? yield handleSnapshot(effectiveRules) : yield getModuleInfo(effectiveRules);
|
|
237
|
+
if (enableClip) {
|
|
238
|
+
Object.values(moduleInfo2).forEach((val) => {
|
|
239
|
+
if (val.modules) {
|
|
240
|
+
val.modules = [];
|
|
241
|
+
}
|
|
242
|
+
if (val.shared) {
|
|
243
|
+
val.shared = [];
|
|
244
|
+
}
|
|
245
|
+
});
|
|
246
|
+
}
|
|
106
247
|
const snapshotJson = JSON.stringify(moduleInfo2);
|
|
107
248
|
yield setStorage(MODULE_DEVTOOL_IDENTIFIER, snapshotJson);
|
|
108
249
|
yield setStorage(BROWSER_ENV_KEY);
|
|
109
250
|
yield mergeStorage(__FEDERATION_DEVTOOLS__, "overrides", overrides);
|
|
110
251
|
yield injectScript(reloadPage, false);
|
|
111
252
|
window.__FEDERATION__.moduleInfo = moduleInfo2;
|
|
112
|
-
|
|
253
|
+
onModuleInfoChange == null ? void 0 : onModuleInfoChange(moduleInfo2);
|
|
113
254
|
setCondition(statusInfo[status]);
|
|
255
|
+
lastEffectiveRulesRef.current = effectiveSignature;
|
|
114
256
|
} catch (e) {
|
|
115
257
|
console.log(e);
|
|
116
258
|
setCondition(statusInfo.error);
|
|
@@ -121,28 +263,86 @@ const Layout = (props) => {
|
|
|
121
263
|
}
|
|
122
264
|
);
|
|
123
265
|
useEffect(() => {
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
getScope().then((scope) => __async(void 0, null, function* () {
|
|
266
|
+
ensureFederationContext();
|
|
267
|
+
let cancelled = false;
|
|
268
|
+
const hydrateForm = () => __async(void 0, null, function* () {
|
|
128
269
|
var _a, _b, _c;
|
|
270
|
+
const scope = yield getScope();
|
|
129
271
|
const data = yield chrome.storage.sync.get([FormID]);
|
|
130
272
|
const config = (_a = data == null ? void 0 : data[FormID]) == null ? void 0 : _a[scope];
|
|
131
273
|
let storeData;
|
|
132
274
|
if (isObject(config)) {
|
|
133
275
|
storeData = JSON.parse(JSON.stringify(config));
|
|
134
|
-
|
|
135
|
-
(
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
276
|
+
if (producer.length) {
|
|
277
|
+
storeData[proxyFormField] = (_b = storeData[proxyFormField]) == null ? void 0 : _b.filter(
|
|
278
|
+
(item) => producer.includes(item.key)
|
|
279
|
+
);
|
|
280
|
+
if (!((_c = storeData[proxyFormField]) == null ? void 0 : _c.length)) {
|
|
281
|
+
storeData = JSON.parse(JSON.stringify(defaultModuleData));
|
|
282
|
+
}
|
|
139
283
|
}
|
|
140
284
|
} else {
|
|
141
|
-
storeData = defaultModuleData;
|
|
285
|
+
storeData = JSON.parse(JSON.stringify(defaultModuleData));
|
|
142
286
|
}
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
287
|
+
let overridesApplied = false;
|
|
288
|
+
try {
|
|
289
|
+
const overridesState = yield getStorageValue(__FEDERATION_DEVTOOLS__);
|
|
290
|
+
if (typeof overridesState === "string" && overridesState) {
|
|
291
|
+
const parsedState = JSON.parse(overridesState);
|
|
292
|
+
const overrides = parsedState == null ? void 0 : parsedState.overrides;
|
|
293
|
+
if (isObject(overrides)) {
|
|
294
|
+
const overrideRules = Object.entries(overrides).map(([key, value]) => ({
|
|
295
|
+
key,
|
|
296
|
+
value: typeof value === "string" ? value : "",
|
|
297
|
+
checked: true
|
|
298
|
+
})).filter(
|
|
299
|
+
(rule) => Boolean(rule.key) && Boolean(rule.value)
|
|
300
|
+
);
|
|
301
|
+
const filteredRules = producer.length ? overrideRules.filter((rule) => producer.includes(rule.key)) : overrideRules;
|
|
302
|
+
if (filteredRules.length) {
|
|
303
|
+
storeData = __spreadProps(__spreadValues({}, storeData), {
|
|
304
|
+
[proxyFormField]: filteredRules
|
|
305
|
+
});
|
|
306
|
+
overridesApplied = true;
|
|
307
|
+
}
|
|
308
|
+
}
|
|
309
|
+
}
|
|
310
|
+
} catch (error) {
|
|
311
|
+
console.warn(
|
|
312
|
+
"[MF Devtools] hydrate overrides from localStorage failed",
|
|
313
|
+
error
|
|
314
|
+
);
|
|
315
|
+
}
|
|
316
|
+
if (!cancelled) {
|
|
317
|
+
form.setFieldsValue(storeData);
|
|
318
|
+
lastFormSignatureRef.current = JSON.stringify(storeData);
|
|
319
|
+
const rules = Array.isArray(
|
|
320
|
+
storeData[proxyFormField]
|
|
321
|
+
) ? storeData[proxyFormField] : [];
|
|
322
|
+
const effectiveRules = collectEffectiveRules(rules, []);
|
|
323
|
+
lastEffectiveRulesRef.current = getEffectiveSignature(effectiveRules);
|
|
324
|
+
lastRawRulesRef.current = JSON.parse(JSON.stringify(rules));
|
|
325
|
+
setFormStatus(
|
|
326
|
+
rules.map((rule) => ({
|
|
327
|
+
keyStatus: Boolean(rule == null ? void 0 : rule.key),
|
|
328
|
+
valueStatus: Boolean(rule == null ? void 0 : rule.value)
|
|
329
|
+
}))
|
|
330
|
+
);
|
|
331
|
+
if (overridesApplied) {
|
|
332
|
+
setChromeStorage(storeData);
|
|
333
|
+
}
|
|
334
|
+
if (effectiveRules.length) {
|
|
335
|
+
setCondition(statusInfo.success);
|
|
336
|
+
} else {
|
|
337
|
+
setCondition(statusInfo.noProxy);
|
|
338
|
+
}
|
|
339
|
+
}
|
|
340
|
+
});
|
|
341
|
+
hydrateForm();
|
|
342
|
+
return () => {
|
|
343
|
+
cancelled = true;
|
|
344
|
+
};
|
|
345
|
+
}, [moduleInfo, producerKey, form]);
|
|
146
346
|
useEffect(() => {
|
|
147
347
|
chrome.storage.sync.get([ENABLEHMR]).then((data) => {
|
|
148
348
|
const enable = data[ENABLEHMR];
|
|
@@ -155,9 +355,25 @@ const Layout = (props) => {
|
|
|
155
355
|
validateForm(form);
|
|
156
356
|
}, []);
|
|
157
357
|
useUpdateEffect(() => {
|
|
358
|
+
if (!producer.length) {
|
|
359
|
+
return;
|
|
360
|
+
}
|
|
158
361
|
const formData = form.getFieldsValue();
|
|
362
|
+
const signature = JSON.stringify(formData);
|
|
363
|
+
if (signature === lastFormSignatureRef.current) {
|
|
364
|
+
return;
|
|
365
|
+
}
|
|
366
|
+
lastFormSignatureRef.current = signature;
|
|
367
|
+
const effectiveRules = collectEffectiveRules(
|
|
368
|
+
formData[proxyFormField] || [],
|
|
369
|
+
formStatus
|
|
370
|
+
);
|
|
371
|
+
const effectiveSignature = getEffectiveSignature(effectiveRules);
|
|
372
|
+
if (effectiveSignature === lastEffectiveRulesRef.current) {
|
|
373
|
+
return;
|
|
374
|
+
}
|
|
159
375
|
run(formData);
|
|
160
|
-
}, []);
|
|
376
|
+
}, [producerKey, formStatus]);
|
|
161
377
|
const validateForm = (form2) => {
|
|
162
378
|
setTimeout(() => {
|
|
163
379
|
form2.validate().catch(() => {
|
|
@@ -167,6 +383,11 @@ const Layout = (props) => {
|
|
|
167
383
|
};
|
|
168
384
|
const onValuesChange = (target, formData) => {
|
|
169
385
|
validateForm(form);
|
|
386
|
+
const signature = JSON.stringify(formData);
|
|
387
|
+
if (signature === lastFormSignatureRef.current) {
|
|
388
|
+
return;
|
|
389
|
+
}
|
|
390
|
+
lastFormSignatureRef.current = signature;
|
|
170
391
|
setChromeStorage(formData);
|
|
171
392
|
run(formData);
|
|
172
393
|
};
|
|
@@ -183,8 +404,33 @@ const Layout = (props) => {
|
|
|
183
404
|
}
|
|
184
405
|
injectScript(reloadPage, false);
|
|
185
406
|
};
|
|
186
|
-
|
|
187
|
-
|
|
407
|
+
const onClipChange = (on) => {
|
|
408
|
+
setEnableClip(on);
|
|
409
|
+
try {
|
|
410
|
+
if (tabId) {
|
|
411
|
+
localStorage.setItem(`${ENABLE_CLIP}_${tabId}`, String(on));
|
|
412
|
+
}
|
|
413
|
+
} catch (e) {
|
|
414
|
+
console.error(e);
|
|
415
|
+
}
|
|
416
|
+
run(form.getFieldsValue());
|
|
417
|
+
};
|
|
418
|
+
const remotePreview = producer.map((id) => {
|
|
419
|
+
const [, name] = id.split(":");
|
|
420
|
+
return name || id;
|
|
421
|
+
}).filter(Boolean);
|
|
422
|
+
const previewList = remotePreview.slice(0, 4);
|
|
423
|
+
const extraCount = remotePreview.length > previewList.length ? remotePreview.length - previewList.length : 0;
|
|
424
|
+
return /* @__PURE__ */ jsxs("div", { className: styles.wrapper, children: [
|
|
425
|
+
/* @__PURE__ */ jsxs("div", { className: styles.summaryCard, children: [
|
|
426
|
+
/* @__PURE__ */ jsxs("div", { className: styles.summaryHeader, children: [
|
|
427
|
+
/* @__PURE__ */ jsx("span", { className: styles.summaryTitle, children: t("layout.summary.title") }),
|
|
428
|
+
/* @__PURE__ */ jsx("span", { className: styles.summaryHint, children: t("layout.summary.hint") })
|
|
429
|
+
] }),
|
|
430
|
+
previewList.length ? previewList.map((name) => /* @__PURE__ */ jsx("span", { className: styles.chip, children: name }, name)) : /* @__PURE__ */ jsx("span", { className: styles.chipPlaceholder, children: t("layout.summary.placeholder") }),
|
|
431
|
+
extraCount > 0 && /* @__PURE__ */ jsx("span", { className: styles.moreChip, children: t("layout.summary.more", { count: extraCount }) })
|
|
432
|
+
] }),
|
|
433
|
+
/* @__PURE__ */ jsx("section", { className: styles.formSection, children: /* @__PURE__ */ jsx(
|
|
188
434
|
Form,
|
|
189
435
|
{
|
|
190
436
|
form,
|
|
@@ -200,6 +446,8 @@ const Layout = (props) => {
|
|
|
200
446
|
validateForm: () => validateForm(form),
|
|
201
447
|
enableHMR,
|
|
202
448
|
onHMRChange,
|
|
449
|
+
enableClip,
|
|
450
|
+
onClipChange,
|
|
203
451
|
versionList,
|
|
204
452
|
setVersionList,
|
|
205
453
|
getVersion,
|
|
@@ -208,8 +456,7 @@ const Layout = (props) => {
|
|
|
208
456
|
}
|
|
209
457
|
)
|
|
210
458
|
}
|
|
211
|
-
)
|
|
212
|
-
/* @__PURE__ */ jsx(Dependency, { snapshot })
|
|
459
|
+
) })
|
|
213
460
|
] });
|
|
214
461
|
};
|
|
215
462
|
var Layout_default = Layout;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import "./index_module.css";
|
|
2
|
-
var index_module_default = { "
|
|
2
|
+
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" };
|
|
3
3
|
export {
|
|
4
4
|
index_module_default as default
|
|
5
5
|
};
|
|
@@ -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
|
}
|