@module-federation/devtools 0.0.0-chore-bump-node-22-20260710161714
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/LICENSE +21 -0
- package/README.md +11 -0
- package/dist/es/App.css +13 -0
- package/dist/es/App.js +498 -0
- package/dist/es/App.module.js +5 -0
- package/dist/es/App_module.css +307 -0
- 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/DependencyGraphItem/index.js +95 -0
- 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 +363 -0
- package/dist/es/component/Form/index.module.js +5 -0
- package/dist/es/component/Form/index_module.css +198 -0
- package/dist/es/component/LanguageSwitch.js +50 -0
- package/dist/es/component/Layout/index.js +470 -0
- package/dist/es/component/Layout/index.module.js +5 -0
- package/dist/es/component/Layout/index_module.css +68 -0
- package/dist/es/component/LoadingTrace/index.js +944 -0
- package/dist/es/component/LoadingTrace/index.module.js +5 -0
- package/dist/es/component/LoadingTrace/index_module.css +876 -0
- 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 +636 -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 +222 -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 +688 -0
- package/dist/es/init.js +8 -0
- package/dist/es/template/constant.js +51 -0
- package/dist/es/template/index.js +1 -0
- package/dist/es/utils/chrome/fast-refresh.js +342 -0
- package/dist/es/utils/chrome/index.js +284 -0
- package/dist/es/utils/chrome/messages.js +12 -0
- package/dist/es/utils/chrome/observability-plugin.js +93 -0
- package/dist/es/utils/chrome/observability-shared.js +99 -0
- package/dist/es/utils/chrome/observability.js +208 -0
- package/dist/es/utils/chrome/override-remote.js +2 -0
- package/dist/es/utils/chrome/post-message-init.js +5 -0
- package/dist/es/utils/chrome/post-message-listener.js +39 -0
- package/dist/es/utils/chrome/post-message-start.js +10 -0
- package/dist/es/utils/chrome/post-message.js +71 -0
- package/dist/es/utils/chrome/safe-post-message.js +124 -0
- package/dist/es/utils/chrome/snapshot-plugin.js +2 -0
- package/dist/es/utils/chrome/storage.js +50 -0
- package/dist/es/utils/data/index.js +59 -0
- package/dist/es/utils/index.js +4 -0
- package/dist/es/utils/sdk/graph.js +190 -0
- package/dist/es/utils/sdk/index.js +70 -0
- package/dist/es/utils/types/common.js +0 -0
- package/dist/es/utils/types/index.js +1 -0
- package/dist/es/vendor/basic-proxy-core.js +155 -0
- package/dist/es/worker/index.js +187 -0
- package/dist/lib/App.css +13 -0
- package/dist/lib/App.js +519 -0
- package/dist/lib/App.module.js +24 -0
- package/dist/lib/App_module.css +307 -0
- package/dist/lib/component/DependencyGraph/index.js +225 -0
- package/dist/lib/component/DependencyGraph/index.module.js +24 -0
- package/dist/lib/component/DependencyGraph/index_module.css +100 -0
- package/dist/lib/component/DependencyGraphItem/index.js +124 -0
- package/dist/lib/component/DependencyGraphItem/index.module.js +24 -0
- package/dist/lib/component/DependencyGraphItem/index_module.css +95 -0
- package/dist/lib/component/Form/index.js +372 -0
- package/dist/lib/component/Form/index.module.js +24 -0
- package/dist/lib/component/Form/index_module.css +198 -0
- package/dist/lib/component/LanguageSwitch.js +79 -0
- package/dist/lib/component/Layout/index.js +471 -0
- package/dist/lib/component/Layout/index.module.js +24 -0
- package/dist/lib/component/Layout/index_module.css +68 -0
- package/dist/lib/component/LoadingTrace/index.js +953 -0
- package/dist/lib/component/LoadingTrace/index.module.js +24 -0
- package/dist/lib/component/LoadingTrace/index_module.css +876 -0
- package/dist/lib/component/ModuleInfo/index.js +342 -0
- package/dist/lib/component/ModuleInfo/index.module.js +24 -0
- package/dist/lib/component/ModuleInfo/index_module.css +184 -0
- package/dist/lib/component/SharedDepsExplorer/FocusResultDisplay.js +64 -0
- package/dist/lib/component/SharedDepsExplorer/FocusResultDisplay.module.js +24 -0
- package/dist/lib/component/SharedDepsExplorer/FocusResultDisplay_module.css +45 -0
- package/dist/lib/component/SharedDepsExplorer/index.js +638 -0
- package/dist/lib/component/SharedDepsExplorer/index.module.js +24 -0
- package/dist/lib/component/SharedDepsExplorer/index_module.css +467 -0
- package/dist/lib/component/SharedDepsExplorer/share-utils.js +252 -0
- package/dist/lib/component/ThemeToggle.js +48 -0
- package/dist/lib/component/ThemeToggle.module.js +24 -0
- package/dist/lib/component/ThemeToggle_module.css +12 -0
- package/dist/lib/hooks/useDevtoolsTheme.js +100 -0
- package/dist/lib/i18n/index.js +721 -0
- package/dist/lib/init.js +8 -0
- package/dist/lib/template/constant.js +84 -0
- package/dist/lib/template/index.js +21 -0
- package/dist/lib/utils/chrome/fast-refresh.js +329 -0
- package/dist/lib/utils/chrome/index.js +321 -0
- package/dist/lib/utils/chrome/messages.js +39 -0
- package/dist/lib/utils/chrome/observability-plugin.js +85 -0
- package/dist/lib/utils/chrome/observability-shared.js +125 -0
- package/dist/lib/utils/chrome/observability.js +233 -0
- package/dist/lib/utils/chrome/override-remote.js +17 -0
- package/dist/lib/utils/chrome/post-message-init.js +5 -0
- package/dist/lib/utils/chrome/post-message-listener.js +36 -0
- package/dist/lib/utils/chrome/post-message-start.js +10 -0
- package/dist/lib/utils/chrome/post-message.js +91 -0
- package/dist/lib/utils/chrome/safe-post-message.js +147 -0
- package/dist/lib/utils/chrome/snapshot-plugin.js +17 -0
- package/dist/lib/utils/chrome/storage.js +71 -0
- package/dist/lib/utils/data/index.js +83 -0
- package/dist/lib/utils/index.js +27 -0
- package/dist/lib/utils/sdk/graph.js +213 -0
- package/dist/lib/utils/sdk/index.js +104 -0
- package/dist/lib/utils/types/common.js +15 -0
- package/dist/lib/utils/types/index.js +21 -0
- package/dist/lib/vendor/basic-proxy-core.js +147 -0
- package/dist/lib/worker/index.js +175 -0
- package/dist/types/src/App.d.ts +7 -0
- package/dist/types/src/component/DependencyGraph/index.d.ts +6 -0
- package/dist/types/src/component/DependencyGraphItem/index.d.ts +9 -0
- package/dist/types/src/component/Form/index.d.ts +21 -0
- package/dist/types/src/component/LanguageSwitch.d.ts +2 -0
- package/dist/types/src/component/Layout/index.d.ts +15 -0
- package/dist/types/src/component/LoadingTrace/index.d.ts +6 -0
- 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 +45 -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/index.d.ts +1 -0
- package/dist/types/src/init.d.ts +12 -0
- package/dist/types/src/template/constant.d.ts +21 -0
- package/dist/types/src/template/index.d.ts +1 -0
- package/dist/types/src/utils/chrome/fast-refresh.d.ts +1 -0
- package/dist/types/src/utils/chrome/index.d.ts +19 -0
- package/dist/types/src/utils/chrome/messages.d.ts +5 -0
- package/dist/types/src/utils/chrome/observability-plugin.d.ts +1 -0
- package/dist/types/src/utils/chrome/observability-shared.d.ts +41 -0
- package/dist/types/src/utils/chrome/observability.d.ts +110 -0
- package/dist/types/src/utils/chrome/override-remote.d.ts +1 -0
- package/dist/types/src/utils/chrome/post-message-init.d.ts +1 -0
- package/dist/types/src/utils/chrome/post-message-listener.d.ts +1 -0
- package/dist/types/src/utils/chrome/post-message-start.d.ts +1 -0
- package/dist/types/src/utils/chrome/post-message.d.ts +1 -0
- package/dist/types/src/utils/chrome/safe-post-message.d.ts +1 -0
- package/dist/types/src/utils/chrome/snapshot-plugin.d.ts +1 -0
- package/dist/types/src/utils/chrome/storage.d.ts +5 -0
- package/dist/types/src/utils/data/index.d.ts +10 -0
- package/dist/types/src/utils/index.d.ts +4 -0
- package/dist/types/src/utils/sdk/graph.d.ts +46 -0
- package/dist/types/src/utils/sdk/index.d.ts +11 -0
- package/dist/types/src/utils/types/common.d.ts +22 -0
- package/dist/types/src/utils/types/index.d.ts +1 -0
- package/dist/types/src/worker/index.d.ts +1 -0
- package/dist/types/stories/index.stories.d.ts +9 -0
- package/install-deps.bash +23 -0
- package/package.json +108 -0
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import { Button, Dropdown, Menu } from "@arco-design/web-react";
|
|
3
|
+
import { IconLanguage } from "@arco-design/web-react/icon";
|
|
4
|
+
import { useTranslation } from "react-i18next";
|
|
5
|
+
import { LANGUAGE_STORAGE_KEY } from "../i18n";
|
|
6
|
+
import styles from "./ThemeToggle.module";
|
|
7
|
+
const LANGUAGE_OPTIONS = [
|
|
8
|
+
{ value: "zh-CN", label: "中文" },
|
|
9
|
+
{ value: "en", label: "English" }
|
|
10
|
+
];
|
|
11
|
+
const persistLanguage = (lang) => {
|
|
12
|
+
var _a;
|
|
13
|
+
if (typeof window !== "undefined") {
|
|
14
|
+
try {
|
|
15
|
+
window.localStorage.setItem(LANGUAGE_STORAGE_KEY, lang);
|
|
16
|
+
} catch (e) {
|
|
17
|
+
}
|
|
18
|
+
const { chrome } = window;
|
|
19
|
+
const storage = (_a = chrome == null ? void 0 : chrome.storage) == null ? void 0 : _a.local;
|
|
20
|
+
if (storage && typeof storage.set === "function") {
|
|
21
|
+
try {
|
|
22
|
+
storage.set({ [LANGUAGE_STORAGE_KEY]: lang });
|
|
23
|
+
} catch (e) {
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
};
|
|
28
|
+
const LanguageSwitch = () => {
|
|
29
|
+
var _a;
|
|
30
|
+
const { i18n } = useTranslation();
|
|
31
|
+
const current = ((_a = i18n.language) == null ? void 0 : _a.toLowerCase()) || "zh-cn";
|
|
32
|
+
const value = current.startsWith("en") ? "en" : "zh-CN";
|
|
33
|
+
const handleChange = (next) => {
|
|
34
|
+
i18n.changeLanguage(next);
|
|
35
|
+
persistLanguage(next);
|
|
36
|
+
};
|
|
37
|
+
const droplist = /* @__PURE__ */ jsx(Menu, { onClickMenuItem: handleChange, selectedKeys: [value], children: LANGUAGE_OPTIONS.map((option) => /* @__PURE__ */ jsx(Menu.Item, { children: option.label }, option.value)) });
|
|
38
|
+
return /* @__PURE__ */ jsx(Dropdown, { droplist, trigger: "click", position: "br", children: /* @__PURE__ */ jsx(
|
|
39
|
+
Button,
|
|
40
|
+
{
|
|
41
|
+
icon: /* @__PURE__ */ jsx(IconLanguage, {}),
|
|
42
|
+
size: "default",
|
|
43
|
+
className: styles.themeToggle
|
|
44
|
+
}
|
|
45
|
+
) });
|
|
46
|
+
};
|
|
47
|
+
var LanguageSwitch_default = LanguageSwitch;
|
|
48
|
+
export {
|
|
49
|
+
LanguageSwitch_default as default
|
|
50
|
+
};
|
|
@@ -0,0 +1,470 @@
|
|
|
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));
|
|
20
|
+
var __async = (__this, __arguments, generator) => {
|
|
21
|
+
return new Promise((resolve, reject) => {
|
|
22
|
+
var fulfilled = (value) => {
|
|
23
|
+
try {
|
|
24
|
+
step(generator.next(value));
|
|
25
|
+
} catch (e) {
|
|
26
|
+
reject(e);
|
|
27
|
+
}
|
|
28
|
+
};
|
|
29
|
+
var rejected = (value) => {
|
|
30
|
+
try {
|
|
31
|
+
step(generator.throw(value));
|
|
32
|
+
} catch (e) {
|
|
33
|
+
reject(e);
|
|
34
|
+
}
|
|
35
|
+
};
|
|
36
|
+
var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
|
|
37
|
+
step((generator = generator.apply(__this, __arguments)).next());
|
|
38
|
+
});
|
|
39
|
+
};
|
|
40
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
41
|
+
import { useEffect, useMemo, useState, useRef } from "react";
|
|
42
|
+
import { useDebounceFn, useUpdateEffect } from "ahooks";
|
|
43
|
+
import { Form } from "@arco-design/web-react";
|
|
44
|
+
import { useTranslation } from "react-i18next";
|
|
45
|
+
import {
|
|
46
|
+
MODULE_DEVTOOL_IDENTIFIER
|
|
47
|
+
} from "@module-federation/sdk";
|
|
48
|
+
import FormComponent from "../Form";
|
|
49
|
+
import {
|
|
50
|
+
getModuleInfo,
|
|
51
|
+
getScope,
|
|
52
|
+
injectScript,
|
|
53
|
+
isObject,
|
|
54
|
+
separateType,
|
|
55
|
+
reloadPage,
|
|
56
|
+
setChromeStorage,
|
|
57
|
+
getStorageValue,
|
|
58
|
+
mergeStorage,
|
|
59
|
+
removeStorageKey,
|
|
60
|
+
removeStorage,
|
|
61
|
+
setStorage
|
|
62
|
+
} from "../../utils";
|
|
63
|
+
import {
|
|
64
|
+
defaultModuleData,
|
|
65
|
+
proxyFormField,
|
|
66
|
+
FormID,
|
|
67
|
+
statusInfo,
|
|
68
|
+
ENABLEHMR,
|
|
69
|
+
ENABLE_CLIP,
|
|
70
|
+
__ENABLE_FAST_REFRESH__,
|
|
71
|
+
BROWSER_ENV_KEY,
|
|
72
|
+
__FEDERATION_DEVTOOLS__,
|
|
73
|
+
__EAGER_SHARE__
|
|
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)) : "";
|
|
88
|
+
const Layout = (props) => {
|
|
89
|
+
const {
|
|
90
|
+
moduleInfo,
|
|
91
|
+
handleSnapshot,
|
|
92
|
+
versionList,
|
|
93
|
+
setVersionList,
|
|
94
|
+
getVersion,
|
|
95
|
+
handleProxyAddress,
|
|
96
|
+
customValueValidate,
|
|
97
|
+
headerSlot,
|
|
98
|
+
onModuleInfoChange,
|
|
99
|
+
onModuleInfoReset,
|
|
100
|
+
tabId
|
|
101
|
+
} = props;
|
|
102
|
+
const { t } = useTranslation();
|
|
103
|
+
const { producer } = separateType(moduleInfo);
|
|
104
|
+
const producerKey = useMemo(() => producer.join("|"), [producer]);
|
|
105
|
+
const [condition, setCondition] = useState(statusInfo.processing);
|
|
106
|
+
const [formStatus, setFormStatus] = useState([]);
|
|
107
|
+
const [form] = Form.useForm();
|
|
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
|
+
__GLOBAL_PLUGIN__: [],
|
|
127
|
+
__INSTANCES__: [],
|
|
128
|
+
__SHARE__: {},
|
|
129
|
+
__MANIFEST_LOADING__: {},
|
|
130
|
+
__PRELOADED_MAP__: /* @__PURE__ */ new Map(),
|
|
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
|
+
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(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
|
+
};
|
|
184
|
+
const { run } = useDebounceFn(
|
|
185
|
+
(formData) => __async(void 0, null, function* () {
|
|
186
|
+
ensureFederationContext();
|
|
187
|
+
window.__FEDERATION__.moduleInfo = JSON.parse(
|
|
188
|
+
JSON.stringify(window.__FEDERATION__.originModuleInfo)
|
|
189
|
+
);
|
|
190
|
+
const rawRules = formData[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;
|
|
201
|
+
try {
|
|
202
|
+
setCondition(statusInfo.processing);
|
|
203
|
+
if (!effectiveRules.length) {
|
|
204
|
+
if (pendingRule) {
|
|
205
|
+
return;
|
|
206
|
+
}
|
|
207
|
+
if (hadPreviousEffective) {
|
|
208
|
+
yield removeStorage(MODULE_DEVTOOL_IDENTIFIER);
|
|
209
|
+
yield removeStorage(BROWSER_ENV_KEY);
|
|
210
|
+
yield removeStorageKey(__FEDERATION_DEVTOOLS__, "overrides");
|
|
211
|
+
yield injectScript(reloadPage, false);
|
|
212
|
+
setCondition(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(statusInfo.noProxy);
|
|
221
|
+
}
|
|
222
|
+
setCondition(statusInfo.noProxy);
|
|
223
|
+
return;
|
|
224
|
+
}
|
|
225
|
+
if (!clipChanged && effectiveSignature === lastEffectiveRulesRef.current) {
|
|
226
|
+
if (hadPreviousEffective) {
|
|
227
|
+
setCondition(statusInfo.success);
|
|
228
|
+
} else {
|
|
229
|
+
setCondition(statusInfo.noProxy);
|
|
230
|
+
}
|
|
231
|
+
return;
|
|
232
|
+
}
|
|
233
|
+
if (rawRules.every((rule) => !rule.value)) {
|
|
234
|
+
if (hadPreviousEffective) {
|
|
235
|
+
setCondition(statusInfo.success);
|
|
236
|
+
} else {
|
|
237
|
+
setCondition(statusInfo.noProxy);
|
|
238
|
+
}
|
|
239
|
+
return;
|
|
240
|
+
}
|
|
241
|
+
const { moduleInfo: moduleInfo2, status, overrides } = handleSnapshot ? yield handleSnapshot(effectiveRules) : yield 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
|
+
}
|
|
252
|
+
const snapshotJson = JSON.stringify(moduleInfo2);
|
|
253
|
+
yield setStorage(MODULE_DEVTOOL_IDENTIFIER, snapshotJson);
|
|
254
|
+
yield setStorage(BROWSER_ENV_KEY);
|
|
255
|
+
yield mergeStorage(__FEDERATION_DEVTOOLS__, "overrides", overrides);
|
|
256
|
+
yield injectScript(reloadPage, false);
|
|
257
|
+
window.__FEDERATION__.moduleInfo = moduleInfo2;
|
|
258
|
+
onModuleInfoChange == null ? void 0 : onModuleInfoChange(moduleInfo2);
|
|
259
|
+
setCondition(statusInfo[status]);
|
|
260
|
+
lastEffectiveRulesRef.current = effectiveSignature;
|
|
261
|
+
} catch (e) {
|
|
262
|
+
console.log(e);
|
|
263
|
+
setCondition(statusInfo.error);
|
|
264
|
+
}
|
|
265
|
+
}),
|
|
266
|
+
{
|
|
267
|
+
wait: 700
|
|
268
|
+
}
|
|
269
|
+
);
|
|
270
|
+
useEffect(() => {
|
|
271
|
+
ensureFederationContext();
|
|
272
|
+
let cancelled = false;
|
|
273
|
+
const hydrateForm = () => __async(void 0, null, function* () {
|
|
274
|
+
var _a, _b, _c;
|
|
275
|
+
const scope = yield getScope();
|
|
276
|
+
const data = yield chrome.storage.sync.get([FormID]);
|
|
277
|
+
const config = (_a = data == null ? void 0 : data[FormID]) == null ? void 0 : _a[scope];
|
|
278
|
+
let storeData;
|
|
279
|
+
if (isObject(config)) {
|
|
280
|
+
storeData = JSON.parse(JSON.stringify(config));
|
|
281
|
+
if (producer.length) {
|
|
282
|
+
storeData[proxyFormField] = (_b = storeData[proxyFormField]) == null ? void 0 : _b.filter(
|
|
283
|
+
(item) => producer.includes(item.key)
|
|
284
|
+
);
|
|
285
|
+
if (!((_c = storeData[proxyFormField]) == null ? void 0 : _c.length)) {
|
|
286
|
+
storeData = JSON.parse(JSON.stringify(defaultModuleData));
|
|
287
|
+
}
|
|
288
|
+
}
|
|
289
|
+
} else {
|
|
290
|
+
storeData = JSON.parse(JSON.stringify(defaultModuleData));
|
|
291
|
+
}
|
|
292
|
+
let overridesApplied = false;
|
|
293
|
+
try {
|
|
294
|
+
const overridesState = yield getStorageValue(__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 (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
|
+
[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[proxyFormField]
|
|
326
|
+
) ? storeData[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
|
+
setChromeStorage(storeData);
|
|
338
|
+
}
|
|
339
|
+
if (effectiveRules.length) {
|
|
340
|
+
setCondition(statusInfo.success);
|
|
341
|
+
} else {
|
|
342
|
+
setCondition(statusInfo.noProxy);
|
|
343
|
+
}
|
|
344
|
+
}
|
|
345
|
+
});
|
|
346
|
+
hydrateForm();
|
|
347
|
+
return () => {
|
|
348
|
+
cancelled = true;
|
|
349
|
+
};
|
|
350
|
+
}, [moduleInfo, producerKey, form]);
|
|
351
|
+
useEffect(() => {
|
|
352
|
+
chrome.storage.sync.get([ENABLEHMR]).then((data) => {
|
|
353
|
+
const enable = data[ENABLEHMR];
|
|
354
|
+
if (typeof enable === "boolean") {
|
|
355
|
+
onHMRChange(enable);
|
|
356
|
+
}
|
|
357
|
+
});
|
|
358
|
+
}, []);
|
|
359
|
+
useEffect(() => {
|
|
360
|
+
validateForm(form);
|
|
361
|
+
}, []);
|
|
362
|
+
useUpdateEffect(() => {
|
|
363
|
+
if (!producer.length) {
|
|
364
|
+
return;
|
|
365
|
+
}
|
|
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[proxyFormField] || [],
|
|
374
|
+
formStatus
|
|
375
|
+
);
|
|
376
|
+
const effectiveSignature = getEffectiveSignature(effectiveRules);
|
|
377
|
+
if (effectiveSignature === lastEffectiveRulesRef.current) {
|
|
378
|
+
return;
|
|
379
|
+
}
|
|
380
|
+
run(formData);
|
|
381
|
+
}, [producerKey, formStatus]);
|
|
382
|
+
const validateForm = (form2) => {
|
|
383
|
+
setTimeout(() => {
|
|
384
|
+
form2.validate().catch(() => {
|
|
385
|
+
console.log("Invalid proxy rules");
|
|
386
|
+
});
|
|
387
|
+
}, 50);
|
|
388
|
+
};
|
|
389
|
+
const onValuesChange = (target, formData) => {
|
|
390
|
+
validateForm(form);
|
|
391
|
+
const signature = JSON.stringify(formData);
|
|
392
|
+
if (signature === lastFormSignatureRef.current) {
|
|
393
|
+
return;
|
|
394
|
+
}
|
|
395
|
+
lastFormSignatureRef.current = signature;
|
|
396
|
+
setChromeStorage(formData);
|
|
397
|
+
run(formData);
|
|
398
|
+
};
|
|
399
|
+
const onHMRChange = (on) => {
|
|
400
|
+
setEnalbeHMR(on ? "enable" : "disable");
|
|
401
|
+
chrome.storage.sync.set({
|
|
402
|
+
[ENABLEHMR]: on
|
|
403
|
+
});
|
|
404
|
+
if (on) {
|
|
405
|
+
mergeStorage(__FEDERATION_DEVTOOLS__, __ENABLE_FAST_REFRESH__, on);
|
|
406
|
+
} else {
|
|
407
|
+
removeStorageKey(__FEDERATION_DEVTOOLS__, __ENABLE_FAST_REFRESH__);
|
|
408
|
+
removeStorageKey(__FEDERATION_DEVTOOLS__, __EAGER_SHARE__);
|
|
409
|
+
}
|
|
410
|
+
injectScript(reloadPage, false);
|
|
411
|
+
};
|
|
412
|
+
const onClipChange = (on) => {
|
|
413
|
+
setEnableClip(on);
|
|
414
|
+
try {
|
|
415
|
+
if (tabId) {
|
|
416
|
+
localStorage.setItem(`${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__ */ jsxs("div", { className: styles.wrapper, children: [
|
|
430
|
+
/* @__PURE__ */ jsxs("div", { className: styles.summaryCard, children: [
|
|
431
|
+
/* @__PURE__ */ jsxs("div", { className: styles.summaryHeader, children: [
|
|
432
|
+
/* @__PURE__ */ jsx("span", { className: styles.summaryTitle, children: t("layout.summary.title") }),
|
|
433
|
+
/* @__PURE__ */ jsx("span", { className: styles.summaryHint, children: t("layout.summary.hint") })
|
|
434
|
+
] }),
|
|
435
|
+
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") }),
|
|
436
|
+
extraCount > 0 && /* @__PURE__ */ jsx("span", { className: styles.moreChip, children: t("layout.summary.more", { count: extraCount }) })
|
|
437
|
+
] }),
|
|
438
|
+
/* @__PURE__ */ jsx("section", { className: styles.formSection, children: /* @__PURE__ */ jsx(
|
|
439
|
+
Form,
|
|
440
|
+
{
|
|
441
|
+
form,
|
|
442
|
+
onValuesChange: (value, formData) => onValuesChange(value, formData),
|
|
443
|
+
initialValues: defaultModuleData,
|
|
444
|
+
children: /* @__PURE__ */ jsx(
|
|
445
|
+
FormComponent,
|
|
446
|
+
{
|
|
447
|
+
form,
|
|
448
|
+
condition,
|
|
449
|
+
formStatus,
|
|
450
|
+
setFormStatus,
|
|
451
|
+
validateForm: () => validateForm(form),
|
|
452
|
+
enableHMR,
|
|
453
|
+
onHMRChange,
|
|
454
|
+
enableClip,
|
|
455
|
+
onClipChange,
|
|
456
|
+
versionList,
|
|
457
|
+
setVersionList,
|
|
458
|
+
getVersion,
|
|
459
|
+
customValueValidate,
|
|
460
|
+
headerSlot
|
|
461
|
+
}
|
|
462
|
+
)
|
|
463
|
+
}
|
|
464
|
+
) })
|
|
465
|
+
] });
|
|
466
|
+
};
|
|
467
|
+
var Layout_default = Layout;
|
|
468
|
+
export {
|
|
469
|
+
Layout_default as default
|
|
470
|
+
};
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import "./index_module.css";
|
|
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
|
+
export {
|
|
4
|
+
index_module_default as default
|
|
5
|
+
};
|
|
@@ -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
|
+
}
|