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