@module-federation/devtools 0.0.0-docs-remove-invalid-lark-link-20251205062649
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 +8 -0
- package/dist/es/App.js +42 -0
- package/dist/es/App.module.js +5 -0
- package/dist/es/App_module.css +19 -0
- package/dist/es/component/Form/index.js +288 -0
- package/dist/es/component/Form/index.module.js +5 -0
- package/dist/es/component/Form/index_module.css +47 -0
- package/dist/es/component/Graph/index.js +127 -0
- package/dist/es/component/Graph/index.module.js +5 -0
- package/dist/es/component/Graph/index_module.css +12 -0
- package/dist/es/component/GraphItem/index.js +73 -0
- package/dist/es/component/GraphItem/index.module.js +5 -0
- package/dist/es/component/GraphItem/index_module.css +61 -0
- package/dist/es/component/Layout/index.js +218 -0
- package/dist/es/component/Layout/index.module.js +5 -0
- package/dist/es/component/Layout/index_module.css +48 -0
- package/dist/es/init.js +8 -0
- package/dist/es/template/constant.js +67 -0
- package/dist/es/template/index.js +1 -0
- package/dist/es/utils/chrome/fast-refresh.js +218 -0
- package/dist/es/utils/chrome/index.js +211 -0
- package/dist/es/utils/chrome/post-message-init.js +5 -0
- package/dist/es/utils/chrome/post-message-listener.js +20 -0
- package/dist/es/utils/chrome/post-message-start.js +8 -0
- package/dist/es/utils/chrome/post-message.js +62 -0
- package/dist/es/utils/chrome/snapshot-plugin.js +36 -0
- package/dist/es/utils/chrome/storage.js +45 -0
- package/dist/es/utils/data/index.js +79 -0
- package/dist/es/utils/data/snapshot.js +82 -0
- package/dist/es/utils/index.js +4 -0
- package/dist/es/utils/sdk/graph.js +155 -0
- package/dist/es/utils/sdk/index.js +61 -0
- package/dist/es/utils/types/common.js +0 -0
- package/dist/es/utils/types/index.js +1 -0
- package/dist/es/worker/index.js +1 -0
- package/dist/lib/App.js +72 -0
- package/dist/lib/App.module.js +25 -0
- package/dist/lib/App_module.css +19 -0
- package/dist/lib/component/Form/index.js +299 -0
- package/dist/lib/component/Form/index.module.js +25 -0
- package/dist/lib/component/Form/index_module.css +47 -0
- package/dist/lib/component/Graph/index.js +149 -0
- package/dist/lib/component/Graph/index.module.js +25 -0
- package/dist/lib/component/Graph/index_module.css +12 -0
- package/dist/lib/component/GraphItem/index.js +103 -0
- package/dist/lib/component/GraphItem/index.module.js +25 -0
- package/dist/lib/component/GraphItem/index_module.css +61 -0
- package/dist/lib/component/Layout/index.js +224 -0
- package/dist/lib/component/Layout/index.module.js +25 -0
- package/dist/lib/component/Layout/index_module.css +48 -0
- package/dist/lib/init.js +9 -0
- package/dist/lib/template/constant.js +98 -0
- package/dist/lib/template/index.js +22 -0
- package/dist/lib/utils/chrome/fast-refresh.js +215 -0
- package/dist/lib/utils/chrome/index.js +245 -0
- package/dist/lib/utils/chrome/post-message-init.js +6 -0
- package/dist/lib/utils/chrome/post-message-listener.js +21 -0
- package/dist/lib/utils/chrome/post-message-start.js +9 -0
- package/dist/lib/utils/chrome/post-message.js +83 -0
- package/dist/lib/utils/chrome/snapshot-plugin.js +59 -0
- package/dist/lib/utils/chrome/storage.js +67 -0
- package/dist/lib/utils/data/index.js +106 -0
- package/dist/lib/utils/data/snapshot.js +107 -0
- package/dist/lib/utils/index.js +28 -0
- package/dist/lib/utils/sdk/graph.js +179 -0
- package/dist/lib/utils/sdk/index.js +95 -0
- package/dist/lib/utils/types/common.js +16 -0
- package/dist/lib/utils/types/index.js +22 -0
- package/dist/lib/worker/index.js +2 -0
- package/dist/types/src/App.d.ts +6 -0
- package/dist/types/src/component/Form/index.d.ts +19 -0
- package/dist/types/src/component/Graph/index.d.ts +7 -0
- package/dist/types/src/component/GraphItem/index.d.ts +10 -0
- package/dist/types/src/component/Layout/index.d.ts +16 -0
- package/dist/types/src/index.d.ts +1 -0
- package/dist/types/src/init.d.ts +13 -0
- package/dist/types/src/template/constant.d.ts +24 -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 +16 -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 +0 -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/snapshot-plugin.d.ts +4 -0
- package/dist/types/src/utils/chrome/storage.d.ts +4 -0
- package/dist/types/src/utils/data/index.d.ts +11 -0
- package/dist/types/src/utils/data/snapshot.d.ts +3 -0
- package/dist/types/src/utils/index.d.ts +4 -0
- package/dist/types/src/utils/sdk/graph.d.ts +45 -0
- package/dist/types/src/utils/sdk/index.d.ts +10 -0
- package/dist/types/src/utils/types/common.d.ts +18 -0
- package/dist/types/src/utils/types/index.d.ts +1 -0
- package/dist/types/src/worker/index.d.ts +0 -0
- package/dist/types/stories/index.stories.d.ts +9 -0
- package/install-deps.bash +19 -0
- package/package.json +87 -0
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
.Wrapper_2fa4f {
|
|
2
|
+
display: flex;
|
|
3
|
+
box-sizing: border-box;
|
|
4
|
+
border-radius: 10px;
|
|
5
|
+
margin: 0;
|
|
6
|
+
padding: 0;
|
|
7
|
+
width: 300px;
|
|
8
|
+
overflow: hidden;
|
|
9
|
+
}
|
|
10
|
+
.Wrapper_2fa4f .container_2fa4f {
|
|
11
|
+
display: flex;
|
|
12
|
+
flex-direction: column;
|
|
13
|
+
width: 100%;
|
|
14
|
+
height: 100%;
|
|
15
|
+
margin: 0;
|
|
16
|
+
padding: 0;
|
|
17
|
+
}
|
|
18
|
+
.Wrapper_2fa4f .container_2fa4f .group_2fa4f {
|
|
19
|
+
display: flex;
|
|
20
|
+
align-items: center;
|
|
21
|
+
margin-bottom: 3px;
|
|
22
|
+
width: 100%;
|
|
23
|
+
padding: 5px 0;
|
|
24
|
+
}
|
|
25
|
+
.Wrapper_2fa4f .container_2fa4f .group_2fa4f .name_2fa4f {
|
|
26
|
+
color: white;
|
|
27
|
+
text-align: center;
|
|
28
|
+
margin: 0 auto;
|
|
29
|
+
}
|
|
30
|
+
.Wrapper_2fa4f .container_2fa4f .info_2fa4f {
|
|
31
|
+
display: flex;
|
|
32
|
+
flex-direction: column;
|
|
33
|
+
background-color: white;
|
|
34
|
+
margin: 0 4px 4px 4px;
|
|
35
|
+
padding: 10px;
|
|
36
|
+
border-radius: 0 0 5px 5px;
|
|
37
|
+
font-size: 12px;
|
|
38
|
+
}
|
|
39
|
+
.Wrapper_2fa4f .container_2fa4f .info_2fa4f .expose-container_2fa4f {
|
|
40
|
+
display: flex;
|
|
41
|
+
margin-bottom: 5px;
|
|
42
|
+
}
|
|
43
|
+
.Wrapper_2fa4f .container_2fa4f .info_2fa4f .type_2fa4f {
|
|
44
|
+
font-weight: bold;
|
|
45
|
+
margin-right: 10px;
|
|
46
|
+
}
|
|
47
|
+
.Wrapper_2fa4f .container_2fa4f .info_2fa4f .item_2fa4f {
|
|
48
|
+
display: inline-block;
|
|
49
|
+
padding: 5px;
|
|
50
|
+
background: lightgray;
|
|
51
|
+
border-radius: 15px;
|
|
52
|
+
font-size: 8px;
|
|
53
|
+
margin-right: 5px;
|
|
54
|
+
margin-bottom: 5px;
|
|
55
|
+
font-weight: 300;
|
|
56
|
+
text-overflow: ellipsis;
|
|
57
|
+
overflow: hidden;
|
|
58
|
+
}
|
|
59
|
+
.Wrapper_2fa4f .container_2fa4f .message_2fa4f {
|
|
60
|
+
display: flex;
|
|
61
|
+
}
|
|
@@ -0,0 +1,218 @@
|
|
|
1
|
+
var __async = (__this, __arguments, generator) => {
|
|
2
|
+
return new Promise((resolve, reject) => {
|
|
3
|
+
var fulfilled = (value) => {
|
|
4
|
+
try {
|
|
5
|
+
step(generator.next(value));
|
|
6
|
+
} catch (e) {
|
|
7
|
+
reject(e);
|
|
8
|
+
}
|
|
9
|
+
};
|
|
10
|
+
var rejected = (value) => {
|
|
11
|
+
try {
|
|
12
|
+
step(generator.throw(value));
|
|
13
|
+
} catch (e) {
|
|
14
|
+
reject(e);
|
|
15
|
+
}
|
|
16
|
+
};
|
|
17
|
+
var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
|
|
18
|
+
step((generator = generator.apply(__this, __arguments)).next());
|
|
19
|
+
});
|
|
20
|
+
};
|
|
21
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
22
|
+
import { useEffect, useState } from "react";
|
|
23
|
+
import { useDebounceFn, useUpdateEffect } from "ahooks";
|
|
24
|
+
import { Form } from "@arco-design/web-react";
|
|
25
|
+
import {
|
|
26
|
+
MODULE_DEVTOOL_IDENTIFIER
|
|
27
|
+
} from "@module-federation/sdk";
|
|
28
|
+
import FormComponent from "../Form";
|
|
29
|
+
import Dependency from "../Graph";
|
|
30
|
+
import {
|
|
31
|
+
getModuleInfo,
|
|
32
|
+
getScope,
|
|
33
|
+
injectScript,
|
|
34
|
+
isObject,
|
|
35
|
+
separateType,
|
|
36
|
+
reloadPage,
|
|
37
|
+
setChromeStorage,
|
|
38
|
+
mergeStorage,
|
|
39
|
+
removeStorageKey,
|
|
40
|
+
removeStorage,
|
|
41
|
+
setStorage
|
|
42
|
+
} from "../../utils";
|
|
43
|
+
import {
|
|
44
|
+
defaultModuleData,
|
|
45
|
+
proxyFormField,
|
|
46
|
+
FormID,
|
|
47
|
+
statusInfo,
|
|
48
|
+
ENABLEHMR,
|
|
49
|
+
__ENABLE_FAST_REFRESH__,
|
|
50
|
+
BROWSER_ENV_KEY,
|
|
51
|
+
__FEDERATION_DEVTOOLS__,
|
|
52
|
+
__EAGER_SHARE__
|
|
53
|
+
} from "../../template/constant";
|
|
54
|
+
const Layout = (props) => {
|
|
55
|
+
const {
|
|
56
|
+
moduleInfo,
|
|
57
|
+
handleSnapshot,
|
|
58
|
+
versionList,
|
|
59
|
+
setVersionList,
|
|
60
|
+
getVersion,
|
|
61
|
+
handleProxyAddress,
|
|
62
|
+
customValueValidate,
|
|
63
|
+
headerSlot
|
|
64
|
+
} = props;
|
|
65
|
+
const { producer } = separateType(moduleInfo);
|
|
66
|
+
const [condition, setCondition] = useState(statusInfo.processing);
|
|
67
|
+
const [formStatus, setFormStatus] = useState([]);
|
|
68
|
+
const [snapshot, setSnapshot] = useState(moduleInfo);
|
|
69
|
+
const [form] = Form.useForm();
|
|
70
|
+
const [enableHMR, setEnalbeHMR] = useState("disable");
|
|
71
|
+
const { run } = useDebounceFn(
|
|
72
|
+
(formData) => __async(void 0, null, function* () {
|
|
73
|
+
window.__FEDERATION__.moduleInfo = JSON.parse(
|
|
74
|
+
JSON.stringify(window.__FEDERATION__.originModuleInfo)
|
|
75
|
+
);
|
|
76
|
+
const filterFormData = formData[proxyFormField].reduce(
|
|
77
|
+
(memo, current, idx) => {
|
|
78
|
+
if (!formStatus[idx]) {
|
|
79
|
+
return memo;
|
|
80
|
+
}
|
|
81
|
+
const { keyStatus, valueStatus } = formStatus[idx];
|
|
82
|
+
if (!keyStatus || !valueStatus || !current.checked) {
|
|
83
|
+
return memo;
|
|
84
|
+
}
|
|
85
|
+
const duplicate = JSON.parse(JSON.stringify(current));
|
|
86
|
+
if (handleProxyAddress) {
|
|
87
|
+
const value = handleProxyAddress(duplicate.value);
|
|
88
|
+
duplicate.value = value;
|
|
89
|
+
}
|
|
90
|
+
return [...memo, duplicate];
|
|
91
|
+
},
|
|
92
|
+
[]
|
|
93
|
+
);
|
|
94
|
+
try {
|
|
95
|
+
setCondition(statusInfo.processing);
|
|
96
|
+
if (!filterFormData.length) {
|
|
97
|
+
yield removeStorage(MODULE_DEVTOOL_IDENTIFIER);
|
|
98
|
+
yield removeStorage(BROWSER_ENV_KEY);
|
|
99
|
+
yield removeStorageKey(__FEDERATION_DEVTOOLS__, "overrides");
|
|
100
|
+
yield injectScript(reloadPage, false);
|
|
101
|
+
setCondition(statusInfo.noProxy);
|
|
102
|
+
setSnapshot(window.__FEDERATION__.originModuleInfo);
|
|
103
|
+
return;
|
|
104
|
+
}
|
|
105
|
+
const { moduleInfo: moduleInfo2, status, overrides } = handleSnapshot ? yield handleSnapshot(filterFormData) : yield getModuleInfo(filterFormData);
|
|
106
|
+
const snapshotJson = JSON.stringify(moduleInfo2);
|
|
107
|
+
yield setStorage(MODULE_DEVTOOL_IDENTIFIER, snapshotJson);
|
|
108
|
+
yield setStorage(BROWSER_ENV_KEY);
|
|
109
|
+
yield mergeStorage(__FEDERATION_DEVTOOLS__, "overrides", overrides);
|
|
110
|
+
yield injectScript(reloadPage, false);
|
|
111
|
+
window.__FEDERATION__.moduleInfo = moduleInfo2;
|
|
112
|
+
setSnapshot(moduleInfo2);
|
|
113
|
+
setCondition(statusInfo[status]);
|
|
114
|
+
} catch (e) {
|
|
115
|
+
console.log(e);
|
|
116
|
+
setCondition(statusInfo.error);
|
|
117
|
+
}
|
|
118
|
+
}),
|
|
119
|
+
{
|
|
120
|
+
wait: 700
|
|
121
|
+
}
|
|
122
|
+
);
|
|
123
|
+
useEffect(() => {
|
|
124
|
+
setSnapshot(moduleInfo);
|
|
125
|
+
}, [moduleInfo]);
|
|
126
|
+
useEffect(() => {
|
|
127
|
+
getScope().then((scope) => __async(void 0, null, function* () {
|
|
128
|
+
var _a, _b, _c;
|
|
129
|
+
const data = yield chrome.storage.sync.get([FormID]);
|
|
130
|
+
const config = (_a = data == null ? void 0 : data[FormID]) == null ? void 0 : _a[scope];
|
|
131
|
+
let storeData;
|
|
132
|
+
if (isObject(config)) {
|
|
133
|
+
storeData = JSON.parse(JSON.stringify(config));
|
|
134
|
+
storeData[proxyFormField] = (_b = storeData[proxyFormField]) == null ? void 0 : _b.filter(
|
|
135
|
+
(item) => producer.includes(item.key)
|
|
136
|
+
);
|
|
137
|
+
if (!((_c = storeData[proxyFormField]) == null ? void 0 : _c.length)) {
|
|
138
|
+
storeData = defaultModuleData;
|
|
139
|
+
}
|
|
140
|
+
} else {
|
|
141
|
+
storeData = defaultModuleData;
|
|
142
|
+
}
|
|
143
|
+
form.setFieldsValue(storeData);
|
|
144
|
+
}));
|
|
145
|
+
}, []);
|
|
146
|
+
useEffect(() => {
|
|
147
|
+
chrome.storage.sync.get([ENABLEHMR]).then((data) => {
|
|
148
|
+
const enable = data[ENABLEHMR];
|
|
149
|
+
if (typeof enable === "boolean") {
|
|
150
|
+
onHMRChange(enable);
|
|
151
|
+
}
|
|
152
|
+
});
|
|
153
|
+
}, []);
|
|
154
|
+
useEffect(() => {
|
|
155
|
+
validateForm(form);
|
|
156
|
+
}, []);
|
|
157
|
+
useUpdateEffect(() => {
|
|
158
|
+
const formData = form.getFieldsValue();
|
|
159
|
+
run(formData);
|
|
160
|
+
}, []);
|
|
161
|
+
const validateForm = (form2) => {
|
|
162
|
+
setTimeout(() => {
|
|
163
|
+
form2.validate().catch(() => {
|
|
164
|
+
console.log("Invalid proxy rules");
|
|
165
|
+
});
|
|
166
|
+
}, 50);
|
|
167
|
+
};
|
|
168
|
+
const onValuesChange = (target, formData) => {
|
|
169
|
+
validateForm(form);
|
|
170
|
+
setChromeStorage(formData);
|
|
171
|
+
run(formData);
|
|
172
|
+
};
|
|
173
|
+
const onHMRChange = (on) => {
|
|
174
|
+
setEnalbeHMR(on ? "enable" : "disable");
|
|
175
|
+
chrome.storage.sync.set({
|
|
176
|
+
[ENABLEHMR]: on
|
|
177
|
+
});
|
|
178
|
+
if (on) {
|
|
179
|
+
mergeStorage(__FEDERATION_DEVTOOLS__, __ENABLE_FAST_REFRESH__, on);
|
|
180
|
+
} else {
|
|
181
|
+
removeStorageKey(__FEDERATION_DEVTOOLS__, __ENABLE_FAST_REFRESH__);
|
|
182
|
+
removeStorageKey(__FEDERATION_DEVTOOLS__, __EAGER_SHARE__);
|
|
183
|
+
}
|
|
184
|
+
injectScript(reloadPage, false);
|
|
185
|
+
};
|
|
186
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
187
|
+
/* @__PURE__ */ jsx(
|
|
188
|
+
Form,
|
|
189
|
+
{
|
|
190
|
+
form,
|
|
191
|
+
onValuesChange: (value, formData) => onValuesChange(value, formData),
|
|
192
|
+
initialValues: defaultModuleData,
|
|
193
|
+
children: /* @__PURE__ */ jsx(
|
|
194
|
+
FormComponent,
|
|
195
|
+
{
|
|
196
|
+
form,
|
|
197
|
+
condition,
|
|
198
|
+
formStatus,
|
|
199
|
+
setFormStatus,
|
|
200
|
+
validateForm: () => validateForm(form),
|
|
201
|
+
enableHMR,
|
|
202
|
+
onHMRChange,
|
|
203
|
+
versionList,
|
|
204
|
+
setVersionList,
|
|
205
|
+
getVersion,
|
|
206
|
+
customValueValidate,
|
|
207
|
+
headerSlot
|
|
208
|
+
}
|
|
209
|
+
)
|
|
210
|
+
}
|
|
211
|
+
),
|
|
212
|
+
/* @__PURE__ */ jsx(Dependency, { snapshot })
|
|
213
|
+
] });
|
|
214
|
+
};
|
|
215
|
+
var Layout_default = Layout;
|
|
216
|
+
export {
|
|
217
|
+
Layout_default as default
|
|
218
|
+
};
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import "./index_module.css";
|
|
2
|
+
var index_module_default = { "select": "select_084ab", "card": "card_084ab", "appName": "appName_084ab", "tagContainer": "tagContainer_084ab", "tag": "tag_084ab", "header": "header_084ab", "add": "add_084ab", "title": "title_084ab", "status": "status_084ab", "switch": "switch_084ab", "badge": "badge_084ab" };
|
|
3
|
+
export {
|
|
4
|
+
index_module_default as default
|
|
5
|
+
};
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
.select_084ab {
|
|
2
|
+
margin-top: 1vh;
|
|
3
|
+
}
|
|
4
|
+
|
|
5
|
+
.card_084ab {
|
|
6
|
+
display: flex;
|
|
7
|
+
height: 4vh;
|
|
8
|
+
align-items: center;
|
|
9
|
+
}
|
|
10
|
+
.card_084ab .appName_084ab {
|
|
11
|
+
margin: 1vh 0;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
.tagContainer_084ab {
|
|
15
|
+
display: flex;
|
|
16
|
+
align-items: center;
|
|
17
|
+
margin-bottom: 1vh;
|
|
18
|
+
color: rgb(78, 89, 105);
|
|
19
|
+
}
|
|
20
|
+
.tagContainer_084ab .tag_084ab {
|
|
21
|
+
margin-left: 1vw;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
.header_084ab {
|
|
25
|
+
display: flex;
|
|
26
|
+
align-items: center;
|
|
27
|
+
margin: 1vh 0;
|
|
28
|
+
}
|
|
29
|
+
.header_084ab .add_084ab {
|
|
30
|
+
margin: 0 0.5vw;
|
|
31
|
+
}
|
|
32
|
+
.header_084ab .title_084ab {
|
|
33
|
+
margin: 0 0.5vw;
|
|
34
|
+
}
|
|
35
|
+
.header_084ab .status_084ab {
|
|
36
|
+
display: flex;
|
|
37
|
+
flex: 1 1;
|
|
38
|
+
justify-content: flex-end;
|
|
39
|
+
align-items: center;
|
|
40
|
+
}
|
|
41
|
+
.header_084ab .status_084ab .switch_084ab {
|
|
42
|
+
margin-left: 0.5vw;
|
|
43
|
+
}
|
|
44
|
+
.header_084ab .badge_084ab {
|
|
45
|
+
display: flex;
|
|
46
|
+
transform: scale(1.6);
|
|
47
|
+
margin: 0 0.6vw;
|
|
48
|
+
}
|
package/dist/es/init.js
ADDED
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
3
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
4
|
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
5
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
6
|
+
var __spreadValues = (a, b) => {
|
|
7
|
+
for (var prop in b || (b = {}))
|
|
8
|
+
if (__hasOwnProp.call(b, prop))
|
|
9
|
+
__defNormalProp(a, prop, b[prop]);
|
|
10
|
+
if (__getOwnPropSymbols)
|
|
11
|
+
for (var prop of __getOwnPropSymbols(b)) {
|
|
12
|
+
if (__propIsEnum.call(b, prop))
|
|
13
|
+
__defNormalProp(a, prop, b[prop]);
|
|
14
|
+
}
|
|
15
|
+
return a;
|
|
16
|
+
};
|
|
17
|
+
const FormID = "FormID";
|
|
18
|
+
const ENABLEHMR = "enableHMR";
|
|
19
|
+
const proxyFormField = "proxyFormField";
|
|
20
|
+
const defaultDataItem = {
|
|
21
|
+
key: "",
|
|
22
|
+
value: "",
|
|
23
|
+
checked: true
|
|
24
|
+
};
|
|
25
|
+
const defaultModuleData = {
|
|
26
|
+
proxyFormField: [
|
|
27
|
+
__spreadValues({}, defaultDataItem)
|
|
28
|
+
]
|
|
29
|
+
};
|
|
30
|
+
const statusInfo = {
|
|
31
|
+
noProxy: {
|
|
32
|
+
status: "noProxy",
|
|
33
|
+
message: "Modules are not currently proxied",
|
|
34
|
+
color: "#698cee"
|
|
35
|
+
},
|
|
36
|
+
processing: {
|
|
37
|
+
status: "processing",
|
|
38
|
+
message: "Obtaining remote module information",
|
|
39
|
+
color: "#FF7D00"
|
|
40
|
+
},
|
|
41
|
+
success: {
|
|
42
|
+
status: "success",
|
|
43
|
+
message: "The proxy configuration has taken effect and the corresponding page has been automatically refreshed.",
|
|
44
|
+
color: "#50b042"
|
|
45
|
+
},
|
|
46
|
+
error: {
|
|
47
|
+
status: "error",
|
|
48
|
+
message: "Calculating Snapshot failed, please confirm whether the package information is correct",
|
|
49
|
+
color: "#F53F3F"
|
|
50
|
+
}
|
|
51
|
+
};
|
|
52
|
+
const __ENABLE_FAST_REFRESH__ = "enableFastRefresh";
|
|
53
|
+
const __EAGER_SHARE__ = "eagerShare";
|
|
54
|
+
const BROWSER_ENV_KEY = "MF_ENV";
|
|
55
|
+
const __FEDERATION_DEVTOOLS__ = "__MF_DEVTOOLS__";
|
|
56
|
+
export {
|
|
57
|
+
BROWSER_ENV_KEY,
|
|
58
|
+
ENABLEHMR,
|
|
59
|
+
FormID,
|
|
60
|
+
__EAGER_SHARE__,
|
|
61
|
+
__ENABLE_FAST_REFRESH__,
|
|
62
|
+
__FEDERATION_DEVTOOLS__,
|
|
63
|
+
defaultDataItem,
|
|
64
|
+
defaultModuleData,
|
|
65
|
+
proxyFormField,
|
|
66
|
+
statusInfo
|
|
67
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./constant";
|
|
@@ -0,0 +1,218 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
3
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
4
|
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
5
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
6
|
+
var __spreadValues = (a, b) => {
|
|
7
|
+
for (var prop in b || (b = {}))
|
|
8
|
+
if (__hasOwnProp.call(b, prop))
|
|
9
|
+
__defNormalProp(a, prop, b[prop]);
|
|
10
|
+
if (__getOwnPropSymbols)
|
|
11
|
+
for (var prop of __getOwnPropSymbols(b)) {
|
|
12
|
+
if (__propIsEnum.call(b, prop))
|
|
13
|
+
__defNormalProp(a, prop, b[prop]);
|
|
14
|
+
}
|
|
15
|
+
return a;
|
|
16
|
+
};
|
|
17
|
+
var __objRest = (source, exclude) => {
|
|
18
|
+
var target = {};
|
|
19
|
+
for (var prop in source)
|
|
20
|
+
if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
|
|
21
|
+
target[prop] = source[prop];
|
|
22
|
+
if (source != null && __getOwnPropSymbols)
|
|
23
|
+
for (var prop of __getOwnPropSymbols(source)) {
|
|
24
|
+
if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
|
|
25
|
+
target[prop] = source[prop];
|
|
26
|
+
}
|
|
27
|
+
return target;
|
|
28
|
+
};
|
|
29
|
+
var __async = (__this, __arguments, generator) => {
|
|
30
|
+
return new Promise((resolve, reject) => {
|
|
31
|
+
var fulfilled = (value) => {
|
|
32
|
+
try {
|
|
33
|
+
step(generator.next(value));
|
|
34
|
+
} catch (e) {
|
|
35
|
+
reject(e);
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
var rejected = (value) => {
|
|
39
|
+
try {
|
|
40
|
+
step(generator.throw(value));
|
|
41
|
+
} catch (e) {
|
|
42
|
+
reject(e);
|
|
43
|
+
}
|
|
44
|
+
};
|
|
45
|
+
var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
|
|
46
|
+
step((generator = generator.apply(__this, __arguments)).next());
|
|
47
|
+
});
|
|
48
|
+
};
|
|
49
|
+
var _a;
|
|
50
|
+
import { loadScript } from "@module-federation/sdk";
|
|
51
|
+
import { isObject, getUnpkgUrl } from "../index";
|
|
52
|
+
import { definePropertyGlobalVal } from "../sdk";
|
|
53
|
+
import {
|
|
54
|
+
__FEDERATION_DEVTOOLS__,
|
|
55
|
+
__EAGER_SHARE__,
|
|
56
|
+
__ENABLE_FAST_REFRESH__
|
|
57
|
+
} from "../../template/constant";
|
|
58
|
+
const SUPPORT_PKGS = ["react", "react-dom"];
|
|
59
|
+
const fetchAndExecuteUmdSync = (url) => {
|
|
60
|
+
try {
|
|
61
|
+
const response = new XMLHttpRequest();
|
|
62
|
+
response.open("GET", url, false);
|
|
63
|
+
response.overrideMimeType("text/plain");
|
|
64
|
+
response.send();
|
|
65
|
+
if (response.status === 200) {
|
|
66
|
+
const scriptContent = response.responseText;
|
|
67
|
+
const moduleFunction = new Function(scriptContent);
|
|
68
|
+
return moduleFunction(window);
|
|
69
|
+
} else {
|
|
70
|
+
throw new Error(
|
|
71
|
+
`Failed to load module from ${url}: HTTP ${response.status}`
|
|
72
|
+
);
|
|
73
|
+
}
|
|
74
|
+
} catch (error) {
|
|
75
|
+
throw new Error(`Failed to fetch module from ${url}: ${error.message}`);
|
|
76
|
+
}
|
|
77
|
+
};
|
|
78
|
+
const getDevtoolsMessage = () => {
|
|
79
|
+
const devtoolsMessageStr = localStorage.getItem(__FEDERATION_DEVTOOLS__);
|
|
80
|
+
if (devtoolsMessageStr) {
|
|
81
|
+
try {
|
|
82
|
+
return JSON.parse(devtoolsMessageStr);
|
|
83
|
+
} catch (e) {
|
|
84
|
+
console.debug("Fast Refresh Plugin Error: ", e);
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
return null;
|
|
88
|
+
};
|
|
89
|
+
const devtoolsMessage = getDevtoolsMessage();
|
|
90
|
+
if ((devtoolsMessage == null ? void 0 : devtoolsMessage[__ENABLE_FAST_REFRESH__]) && (devtoolsMessage == null ? void 0 : devtoolsMessage[__EAGER_SHARE__])) {
|
|
91
|
+
const [_name, version] = devtoolsMessage[__EAGER_SHARE__];
|
|
92
|
+
fetchAndExecuteUmdSync(getUnpkgUrl("react", version));
|
|
93
|
+
fetchAndExecuteUmdSync(getUnpkgUrl("react-dom", version));
|
|
94
|
+
}
|
|
95
|
+
const fastRefreshPlugin = () => {
|
|
96
|
+
return {
|
|
97
|
+
name: "mf-fast-refresh-plugin",
|
|
98
|
+
beforeInit(_a2) {
|
|
99
|
+
var _b = _a2, { userOptions } = _b, args = __objRest(_b, ["userOptions"]);
|
|
100
|
+
const shareInfo = userOptions.shared;
|
|
101
|
+
const twinsShareInfo = args.shareInfo;
|
|
102
|
+
let enableFastRefresh = false;
|
|
103
|
+
let devtoolsMessage2 = {};
|
|
104
|
+
const devtoolsMessageStr = localStorage.getItem(__FEDERATION_DEVTOOLS__);
|
|
105
|
+
if (devtoolsMessageStr) {
|
|
106
|
+
try {
|
|
107
|
+
devtoolsMessage2 = JSON.parse(devtoolsMessageStr);
|
|
108
|
+
enableFastRefresh = devtoolsMessage2 == null ? void 0 : devtoolsMessage2[__ENABLE_FAST_REFRESH__];
|
|
109
|
+
} catch (e) {
|
|
110
|
+
console.debug("Fast Refresh Plugin Error: ", e);
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
if (!enableFastRefresh) {
|
|
114
|
+
return __spreadValues({
|
|
115
|
+
userOptions
|
|
116
|
+
}, args);
|
|
117
|
+
}
|
|
118
|
+
if (shareInfo && isObject(shareInfo)) {
|
|
119
|
+
let orderResolve;
|
|
120
|
+
const orderPromise = new Promise((resolve) => {
|
|
121
|
+
orderResolve = resolve;
|
|
122
|
+
});
|
|
123
|
+
Object.keys(shareInfo).forEach((share) => __async(this, null, function* () {
|
|
124
|
+
const sharedArr = Array.isArray(shareInfo[share]) ? shareInfo[share] : [shareInfo[share]];
|
|
125
|
+
let twinsSharedArr;
|
|
126
|
+
if (twinsShareInfo) {
|
|
127
|
+
twinsSharedArr = Array.isArray(twinsShareInfo[share]) ? twinsShareInfo[share] : [twinsShareInfo[share]];
|
|
128
|
+
}
|
|
129
|
+
sharedArr.forEach((shared, idx) => {
|
|
130
|
+
var _a3;
|
|
131
|
+
if (!SUPPORT_PKGS.includes(share)) {
|
|
132
|
+
return;
|
|
133
|
+
}
|
|
134
|
+
if ((_a3 = shared.shareConfig) == null ? void 0 : _a3.eager) {
|
|
135
|
+
if (!(devtoolsMessage2 == null ? void 0 : devtoolsMessage2[__EAGER_SHARE__])) {
|
|
136
|
+
const eagerShare = [];
|
|
137
|
+
eagerShare.push(share, shared.version);
|
|
138
|
+
devtoolsMessage2[__EAGER_SHARE__] = eagerShare;
|
|
139
|
+
localStorage.setItem(
|
|
140
|
+
__FEDERATION_DEVTOOLS__,
|
|
141
|
+
JSON.stringify(devtoolsMessage2)
|
|
142
|
+
);
|
|
143
|
+
window.location.reload();
|
|
144
|
+
}
|
|
145
|
+
if (share === "react-dom") {
|
|
146
|
+
shared.lib = () => window.ReactDOM;
|
|
147
|
+
}
|
|
148
|
+
if (share === "react") {
|
|
149
|
+
shared.lib = () => window.React;
|
|
150
|
+
}
|
|
151
|
+
return;
|
|
152
|
+
}
|
|
153
|
+
let get;
|
|
154
|
+
if (share === "react") {
|
|
155
|
+
get = () => loadScript(getUnpkgUrl(share, shared.version), {
|
|
156
|
+
attrs: {
|
|
157
|
+
defer: false,
|
|
158
|
+
async: false,
|
|
159
|
+
"data-mf-injected": "true"
|
|
160
|
+
}
|
|
161
|
+
}).then(() => {
|
|
162
|
+
orderResolve();
|
|
163
|
+
});
|
|
164
|
+
}
|
|
165
|
+
if (share === "react-dom") {
|
|
166
|
+
get = () => orderPromise.then(
|
|
167
|
+
() => loadScript(getUnpkgUrl(share, shared.version), {
|
|
168
|
+
attrs: { defer: true, async: false }
|
|
169
|
+
})
|
|
170
|
+
);
|
|
171
|
+
}
|
|
172
|
+
if (typeof get === "function") {
|
|
173
|
+
if (share === "react") {
|
|
174
|
+
shared.get = () => __async(this, null, function* () {
|
|
175
|
+
if (!window.React) {
|
|
176
|
+
yield get();
|
|
177
|
+
console.warn(
|
|
178
|
+
"[Module Federation HMR]: You are using Module Federation Devtools to debug online host, it will cause your project load Dev mode React and ReactDOM. If not in this mode, please disable it in Module Federation Devtools"
|
|
179
|
+
);
|
|
180
|
+
}
|
|
181
|
+
shared.lib = () => window.React;
|
|
182
|
+
return () => window.React;
|
|
183
|
+
});
|
|
184
|
+
}
|
|
185
|
+
if (share === "react-dom") {
|
|
186
|
+
shared.get = () => __async(this, null, function* () {
|
|
187
|
+
if (!window.ReactDOM) {
|
|
188
|
+
yield get();
|
|
189
|
+
}
|
|
190
|
+
shared.lib = () => window.ReactDOM;
|
|
191
|
+
return () => window.ReactDOM;
|
|
192
|
+
});
|
|
193
|
+
}
|
|
194
|
+
if (twinsShareInfo) {
|
|
195
|
+
twinsSharedArr[idx].get = shared.get;
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
});
|
|
199
|
+
}));
|
|
200
|
+
return __spreadValues({
|
|
201
|
+
userOptions
|
|
202
|
+
}, args);
|
|
203
|
+
} else {
|
|
204
|
+
return __spreadValues({
|
|
205
|
+
userOptions
|
|
206
|
+
}, args);
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
};
|
|
210
|
+
};
|
|
211
|
+
if (!(window == null ? void 0 : window.__FEDERATION__)) {
|
|
212
|
+
definePropertyGlobalVal(window, "__FEDERATION__", {});
|
|
213
|
+
definePropertyGlobalVal(window, "__VMOK__", window.__FEDERATION__);
|
|
214
|
+
}
|
|
215
|
+
if (!(window == null ? void 0 : window.__FEDERATION__.__GLOBAL_PLUGIN__)) {
|
|
216
|
+
window.__FEDERATION__.__GLOBAL_PLUGIN__ = [];
|
|
217
|
+
}
|
|
218
|
+
(_a = window.__FEDERATION__.__GLOBAL_PLUGIN__) == null ? void 0 : _a.push(fastRefreshPlugin());
|