@module-federation/devtools 0.0.0-next-20240425091022
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 +30 -0
- package/dist/es/App.js +31 -0
- package/dist/es/App.module.js +5 -0
- package/dist/es/App_module.css +19 -0
- package/dist/es/component/Form/index.js +283 -0
- package/dist/es/component/Form/index.module.js +5 -0
- package/dist/es/component/Form/index_module.css +43 -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 +56 -0
- package/dist/es/component/Layout/index.js +207 -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 +65 -0
- package/dist/es/template/index.js +1 -0
- package/dist/es/utils/chrome/fast-refresh-init.js +5 -0
- package/dist/es/utils/chrome/fast-refresh.js +113 -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-init.js +5 -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 +148 -0
- package/dist/es/utils/sdk/index.js +55 -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 +61 -0
- package/dist/lib/App.module.js +25 -0
- package/dist/lib/App_module.css +19 -0
- package/dist/lib/component/Form/index.js +295 -0
- package/dist/lib/component/Form/index.module.js +25 -0
- package/dist/lib/component/Form/index_module.css +43 -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 +56 -0
- package/dist/lib/component/Layout/index.js +214 -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 +95 -0
- package/dist/lib/template/index.js +22 -0
- package/dist/lib/utils/chrome/fast-refresh-init.js +6 -0
- package/dist/lib/utils/chrome/fast-refresh.js +114 -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-init.js +6 -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 +171 -0
- package/dist/lib/utils/sdk/index.js +89 -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 +18 -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 +7 -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 +23 -0
- package/dist/types/src/template/index.d.ts +1 -0
- package/dist/types/src/utils/chrome/fast-refresh-init.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-init.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 +44 -0
- package/dist/types/src/utils/sdk/index.d.ts +10 -0
- package/dist/types/src/utils/types/common.d.ts +15 -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 +8 -0
- package/package.json +85 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2020 ScriptedAlchemy LLC (Zack Jackson) Zhou Shaw (zhouxiao)
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
# Module Federation Chrome Devtools
|
|
2
|
+
|
|
3
|
+
## Ability
|
|
4
|
+
* Proxy online Module Federation remote module to local
|
|
5
|
+
* Let proxied remote module get hmr
|
|
6
|
+
|
|
7
|
+
## Setup
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
pnpm install
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
## Run
|
|
14
|
+
|
|
15
|
+
```bash
|
|
16
|
+
pnpm dev
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
## Build
|
|
20
|
+
|
|
21
|
+
```bash
|
|
22
|
+
pnpm run build
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
## Test
|
|
26
|
+
|
|
27
|
+
```bash
|
|
28
|
+
pnpm run test
|
|
29
|
+
```
|
|
30
|
+
|
package/dist/es/App.js
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { Fragment, jsx } from "react/jsx-runtime";
|
|
2
|
+
import { useState, useEffect } from "react";
|
|
3
|
+
import { Layout, Empty } from "@arco-design/web-react";
|
|
4
|
+
import "./init";
|
|
5
|
+
import ProxyLayout from "./component/Layout";
|
|
6
|
+
import { getGlobalModuleInfo } from "./utils";
|
|
7
|
+
import "@arco-design/web-react/dist/css/arco.css";
|
|
8
|
+
import styles from "./App.module";
|
|
9
|
+
const { Content } = Layout;
|
|
10
|
+
const App = (props) => {
|
|
11
|
+
var _a;
|
|
12
|
+
const { versionList, setVersionList, getVersion, handleSnapshot } = props;
|
|
13
|
+
const [module, setModule] = useState(((_a = window.__FEDERATION__) == null ? void 0 : _a.moduleInfo) || {});
|
|
14
|
+
useEffect(() => {
|
|
15
|
+
getGlobalModuleInfo(setModule);
|
|
16
|
+
}, []);
|
|
17
|
+
return /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsx(Layout, { className: styles.layout, children: /* @__PURE__ */ jsx(Content, { className: styles.content, children: Object.keys(module).length > 0 || process.env.NODE_ENV === "development" ? /* @__PURE__ */ jsx(
|
|
18
|
+
ProxyLayout,
|
|
19
|
+
{
|
|
20
|
+
moduleInfo: module,
|
|
21
|
+
versionList,
|
|
22
|
+
setVersionList,
|
|
23
|
+
getVersion,
|
|
24
|
+
handleSnapshot
|
|
25
|
+
}
|
|
26
|
+
) : /* @__PURE__ */ jsx(Empty, { description: "No ModuleInfo Detected" }) }) }) });
|
|
27
|
+
};
|
|
28
|
+
var App_default = App;
|
|
29
|
+
export {
|
|
30
|
+
App_default as default
|
|
31
|
+
};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
.arco-card-body {
|
|
2
|
+
padding: 0 !important;
|
|
3
|
+
}
|
|
4
|
+
.arco-form-layout-horizontal {
|
|
5
|
+
flex: 1 1;
|
|
6
|
+
margin: 0 1vw 0 0;
|
|
7
|
+
}
|
|
8
|
+
.arco-form-item-wrapper {
|
|
9
|
+
width: 100%;
|
|
10
|
+
flex: 1 1;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
.layout_ae2ee {
|
|
14
|
+
width: 100%;
|
|
15
|
+
height: 100vh;
|
|
16
|
+
}
|
|
17
|
+
.layout_ae2ee .content_ae2ee {
|
|
18
|
+
margin: 0 0.5vw 0 2vw;
|
|
19
|
+
}
|
|
@@ -0,0 +1,283 @@
|
|
|
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 } from "react";
|
|
23
|
+
import { flushSync } from "react-dom";
|
|
24
|
+
import {
|
|
25
|
+
Checkbox,
|
|
26
|
+
Button,
|
|
27
|
+
Empty,
|
|
28
|
+
Tooltip,
|
|
29
|
+
Badge,
|
|
30
|
+
Form,
|
|
31
|
+
Select,
|
|
32
|
+
Switch
|
|
33
|
+
} from "@arco-design/web-react";
|
|
34
|
+
import {
|
|
35
|
+
IconDelete,
|
|
36
|
+
IconPlus,
|
|
37
|
+
IconInfoCircle
|
|
38
|
+
} from "@arco-design/web-react/icon";
|
|
39
|
+
import { defaultDataItem, proxyFormField } from "../../template/constant";
|
|
40
|
+
import {
|
|
41
|
+
validateCustom,
|
|
42
|
+
validateSemver,
|
|
43
|
+
isObject,
|
|
44
|
+
separateType
|
|
45
|
+
} from "../../utils";
|
|
46
|
+
import styles from "./index.module";
|
|
47
|
+
const FormItem = Form.Item;
|
|
48
|
+
const FormList = Form.List;
|
|
49
|
+
const { Option } = Select;
|
|
50
|
+
const FormComponent = (props) => {
|
|
51
|
+
const {
|
|
52
|
+
form,
|
|
53
|
+
condition,
|
|
54
|
+
formStatus,
|
|
55
|
+
setFormStatus,
|
|
56
|
+
validateForm,
|
|
57
|
+
enableHMR,
|
|
58
|
+
onHMRChange,
|
|
59
|
+
versionList,
|
|
60
|
+
setVersionList,
|
|
61
|
+
getVersion
|
|
62
|
+
} = props;
|
|
63
|
+
const { moduleInfo } = window.__FEDERATION__;
|
|
64
|
+
let { producer } = separateType(moduleInfo);
|
|
65
|
+
const filterDupMap = /* @__PURE__ */ new Map();
|
|
66
|
+
producer = producer.filter((t) => {
|
|
67
|
+
const [typeOrName, name] = t.split(":");
|
|
68
|
+
const marked = filterDupMap.get(name || typeOrName);
|
|
69
|
+
filterDupMap.set(name || typeOrName, true);
|
|
70
|
+
return !marked;
|
|
71
|
+
});
|
|
72
|
+
const formatProducer = producer.map((id) => {
|
|
73
|
+
const hasType = id.includes(":");
|
|
74
|
+
if (hasType) {
|
|
75
|
+
return {
|
|
76
|
+
label: id.split(":")[1],
|
|
77
|
+
value: id
|
|
78
|
+
};
|
|
79
|
+
} else {
|
|
80
|
+
return {
|
|
81
|
+
label: id,
|
|
82
|
+
value: id
|
|
83
|
+
};
|
|
84
|
+
}
|
|
85
|
+
});
|
|
86
|
+
useEffect(() => {
|
|
87
|
+
producer.forEach((target) => __async(void 0, null, function* () {
|
|
88
|
+
const version = yield getVersion == null ? void 0 : getVersion(target);
|
|
89
|
+
const list = [...versionList || []];
|
|
90
|
+
if (version) {
|
|
91
|
+
list.push(version);
|
|
92
|
+
}
|
|
93
|
+
setVersionList == null ? void 0 : setVersionList(list);
|
|
94
|
+
}));
|
|
95
|
+
}, []);
|
|
96
|
+
const getCheckStatus = (index) => {
|
|
97
|
+
const formData = form.getFieldsValue();
|
|
98
|
+
return formData[proxyFormField][index].checked;
|
|
99
|
+
};
|
|
100
|
+
const validateKey = (key, callback, index) => {
|
|
101
|
+
const status = getCheckStatus(index);
|
|
102
|
+
if (!status) {
|
|
103
|
+
return callback();
|
|
104
|
+
}
|
|
105
|
+
const statusSet = [...formStatus];
|
|
106
|
+
if (!isObject(statusSet[index])) {
|
|
107
|
+
statusSet[index] = {
|
|
108
|
+
keyStatus: false,
|
|
109
|
+
valueStatus: false
|
|
110
|
+
};
|
|
111
|
+
}
|
|
112
|
+
if (key) {
|
|
113
|
+
statusSet[index].keyStatus = true;
|
|
114
|
+
flushSync(() => setFormStatus(statusSet));
|
|
115
|
+
return callback();
|
|
116
|
+
}
|
|
117
|
+
statusSet[index].keyStatus = false;
|
|
118
|
+
flushSync(() => setFormStatus(statusSet));
|
|
119
|
+
return callback("Module name can not be empty");
|
|
120
|
+
};
|
|
121
|
+
const validateValue = (value, callback, index) => {
|
|
122
|
+
const status = getCheckStatus(index);
|
|
123
|
+
if (!status) {
|
|
124
|
+
return callback();
|
|
125
|
+
}
|
|
126
|
+
const statusSet = [...formStatus];
|
|
127
|
+
if (!isObject(statusSet[index])) {
|
|
128
|
+
statusSet[index] = {
|
|
129
|
+
keyStatus: false,
|
|
130
|
+
valueStatus: false
|
|
131
|
+
};
|
|
132
|
+
}
|
|
133
|
+
if (validateCustom(value) || validateSemver(value)) {
|
|
134
|
+
statusSet[index].valueStatus = true;
|
|
135
|
+
flushSync(() => setFormStatus(statusSet));
|
|
136
|
+
return callback();
|
|
137
|
+
}
|
|
138
|
+
statusSet[index].valueStatus = false;
|
|
139
|
+
flushSync(() => setFormStatus(statusSet));
|
|
140
|
+
return callback(
|
|
141
|
+
"The module information format is incorrect, check the format in the upper left corner"
|
|
142
|
+
);
|
|
143
|
+
};
|
|
144
|
+
const onAdd = (add) => {
|
|
145
|
+
add(defaultDataItem);
|
|
146
|
+
setVersionList == null ? void 0 : setVersionList([...versionList || [], []]);
|
|
147
|
+
validateForm();
|
|
148
|
+
};
|
|
149
|
+
const onRemove = (remove, index) => {
|
|
150
|
+
if (Array.isArray(versionList)) {
|
|
151
|
+
versionList.splice(index, 1);
|
|
152
|
+
setVersionList == null ? void 0 : setVersionList(versionList);
|
|
153
|
+
}
|
|
154
|
+
remove(index);
|
|
155
|
+
};
|
|
156
|
+
const hmrChange = (on) => {
|
|
157
|
+
onHMRChange(on);
|
|
158
|
+
};
|
|
159
|
+
const onKeyChange = (key, index) => __async(void 0, null, function* () {
|
|
160
|
+
const version = yield getVersion == null ? void 0 : getVersion(key);
|
|
161
|
+
if (version) {
|
|
162
|
+
const list = [...versionList || []];
|
|
163
|
+
list.splice(index, 1, version);
|
|
164
|
+
setVersionList == null ? void 0 : setVersionList(list);
|
|
165
|
+
}
|
|
166
|
+
});
|
|
167
|
+
return /* @__PURE__ */ jsx(FormList, { field: proxyFormField, children: (fields, { add, remove }) => /* @__PURE__ */ jsxs("div", { children: [
|
|
168
|
+
/* @__PURE__ */ jsxs("div", { className: styles.header, children: [
|
|
169
|
+
/* @__PURE__ */ jsx(
|
|
170
|
+
Tooltip,
|
|
171
|
+
{
|
|
172
|
+
content: /* @__PURE__ */ jsx("div", { children: "Example: Customize the remote module address, which should end with 「.json」, for example key: @module-federation/button, value: http://localhost:3000/mf-manifest.json" }),
|
|
173
|
+
children: /* @__PURE__ */ jsx(IconInfoCircle, {})
|
|
174
|
+
}
|
|
175
|
+
),
|
|
176
|
+
/* @__PURE__ */ jsx("div", { className: styles.title, children: "Module Proxy" }),
|
|
177
|
+
/* @__PURE__ */ jsx(
|
|
178
|
+
Button,
|
|
179
|
+
{
|
|
180
|
+
icon: /* @__PURE__ */ jsx(IconPlus, {}),
|
|
181
|
+
shape: "circle",
|
|
182
|
+
className: styles.add,
|
|
183
|
+
onClick: () => onAdd(add),
|
|
184
|
+
"data-set-e2e": "e2eAdd"
|
|
185
|
+
}
|
|
186
|
+
),
|
|
187
|
+
/* @__PURE__ */ jsxs("div", { className: styles.status, children: [
|
|
188
|
+
/* @__PURE__ */ jsx(Badge, { color: condition.color, className: styles.badge }),
|
|
189
|
+
/* @__PURE__ */ jsx("span", { className: styles.message, children: condition.message }),
|
|
190
|
+
/* @__PURE__ */ jsx(
|
|
191
|
+
Switch,
|
|
192
|
+
{
|
|
193
|
+
checked: enableHMR === "enable",
|
|
194
|
+
checkedText: "Enable HMR",
|
|
195
|
+
uncheckedText: "Disable HMR",
|
|
196
|
+
onChange: hmrChange,
|
|
197
|
+
className: styles.switch
|
|
198
|
+
}
|
|
199
|
+
)
|
|
200
|
+
] })
|
|
201
|
+
] }),
|
|
202
|
+
fields.length ? /* @__PURE__ */ jsx(Fragment, { children: fields.map((item, index) => {
|
|
203
|
+
var _a, _b;
|
|
204
|
+
return /* @__PURE__ */ jsxs(
|
|
205
|
+
"div",
|
|
206
|
+
{
|
|
207
|
+
className: styles.container,
|
|
208
|
+
"data-set-e2e": "e2eProxyItem",
|
|
209
|
+
children: [
|
|
210
|
+
/* @__PURE__ */ jsx("div", { children: /* @__PURE__ */ jsx(
|
|
211
|
+
FormItem,
|
|
212
|
+
{
|
|
213
|
+
field: `${item.field}.checked`,
|
|
214
|
+
triggerPropName: "checked",
|
|
215
|
+
children: /* @__PURE__ */ jsx(Checkbox, { className: styles.checkBox })
|
|
216
|
+
}
|
|
217
|
+
) }),
|
|
218
|
+
/* @__PURE__ */ jsx("div", { className: styles.input, children: /* @__PURE__ */ jsx(
|
|
219
|
+
FormItem,
|
|
220
|
+
{
|
|
221
|
+
field: `${item.field}.key`,
|
|
222
|
+
rules: [
|
|
223
|
+
{
|
|
224
|
+
validator: (value, cb) => validateKey(value, cb, index)
|
|
225
|
+
}
|
|
226
|
+
],
|
|
227
|
+
children: /* @__PURE__ */ jsx(
|
|
228
|
+
Select,
|
|
229
|
+
{
|
|
230
|
+
"data-set-e2e": "e2eProxyKey",
|
|
231
|
+
placeholder: "Module Name",
|
|
232
|
+
onChange: (key) => onKeyChange(key, index),
|
|
233
|
+
allowClear: true,
|
|
234
|
+
showSearch: true,
|
|
235
|
+
children: formatProducer.map((item2) => /* @__PURE__ */ jsx(Option, { value: item2.value, children: item2.label }, item2.value))
|
|
236
|
+
}
|
|
237
|
+
)
|
|
238
|
+
}
|
|
239
|
+
) }),
|
|
240
|
+
/* @__PURE__ */ jsx("div", { className: styles.input, children: /* @__PURE__ */ jsx(
|
|
241
|
+
FormItem,
|
|
242
|
+
{
|
|
243
|
+
field: `${item.field}.value`,
|
|
244
|
+
rules: [
|
|
245
|
+
{
|
|
246
|
+
validator: (value, cb) => validateValue(value, cb, index)
|
|
247
|
+
}
|
|
248
|
+
],
|
|
249
|
+
children: /* @__PURE__ */ jsx(
|
|
250
|
+
Select,
|
|
251
|
+
{
|
|
252
|
+
"data-set-e2e": "e2eProxyValue",
|
|
253
|
+
placeholder: "Custom Manifest URL",
|
|
254
|
+
allowClear: true,
|
|
255
|
+
showSearch: true,
|
|
256
|
+
allowCreate: true,
|
|
257
|
+
children: (_b = (_a = versionList || []) == null ? void 0 : _a[index]) == null ? void 0 : _b.map((version) => /* @__PURE__ */ jsx(Option, { value: version, children: version }, version))
|
|
258
|
+
}
|
|
259
|
+
)
|
|
260
|
+
}
|
|
261
|
+
) }),
|
|
262
|
+
/* @__PURE__ */ jsx(
|
|
263
|
+
Button,
|
|
264
|
+
{
|
|
265
|
+
icon: /* @__PURE__ */ jsx(IconDelete, {}),
|
|
266
|
+
shape: "circle",
|
|
267
|
+
status: "danger",
|
|
268
|
+
className: styles.delete,
|
|
269
|
+
"data-set-e2e": "e2eDelete",
|
|
270
|
+
onClick: () => onRemove(remove, index)
|
|
271
|
+
}
|
|
272
|
+
)
|
|
273
|
+
]
|
|
274
|
+
},
|
|
275
|
+
item.field
|
|
276
|
+
);
|
|
277
|
+
}) }) : /* @__PURE__ */ jsx(Empty, {})
|
|
278
|
+
] }) });
|
|
279
|
+
};
|
|
280
|
+
var Form_default = FormComponent;
|
|
281
|
+
export {
|
|
282
|
+
Form_default as default
|
|
283
|
+
};
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import "./index_module.css";
|
|
2
|
+
var index_module_default = { "container": "container_20b79", "checkBox": "checkBox_20b79", "input": "input_20b79", "delete": "delete_20b79", "header": "header_20b79", "add": "add_20b79", "title": "title_20b79", "status": "status_20b79", "message": "message_20b79", "switch": "switch_20b79", "badge": "badge_20b79" };
|
|
3
|
+
export {
|
|
4
|
+
index_module_default as default
|
|
5
|
+
};
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
.container_20b79 {
|
|
2
|
+
display: flex;
|
|
3
|
+
justify-content: center;
|
|
4
|
+
}
|
|
5
|
+
.container_20b79 .checkBox_20b79 {
|
|
6
|
+
transform: scale(1.25);
|
|
7
|
+
}
|
|
8
|
+
.container_20b79 .input_20b79 {
|
|
9
|
+
margin: 0 1vw 0 0;
|
|
10
|
+
flex: 1 1;
|
|
11
|
+
}
|
|
12
|
+
.container_20b79 .delete_20b79 {
|
|
13
|
+
margin: 0 0 0 1vw;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
.header_20b79 {
|
|
17
|
+
display: flex;
|
|
18
|
+
align-items: center;
|
|
19
|
+
margin: 1vh 0;
|
|
20
|
+
}
|
|
21
|
+
.header_20b79 .add_20b79 {
|
|
22
|
+
margin: 0 0.5vw;
|
|
23
|
+
}
|
|
24
|
+
.header_20b79 .title_20b79 {
|
|
25
|
+
margin: 0 0.5vw;
|
|
26
|
+
}
|
|
27
|
+
.header_20b79 .status_20b79 {
|
|
28
|
+
display: flex;
|
|
29
|
+
flex: 1 1;
|
|
30
|
+
justify-content: flex-end;
|
|
31
|
+
align-items: center;
|
|
32
|
+
}
|
|
33
|
+
.header_20b79 .status_20b79 .message_20b79 {
|
|
34
|
+
flex: 1 1;
|
|
35
|
+
}
|
|
36
|
+
.header_20b79 .status_20b79 .switch_20b79 {
|
|
37
|
+
margin-left: 0.5vw;
|
|
38
|
+
}
|
|
39
|
+
.header_20b79 .badge_20b79 {
|
|
40
|
+
display: flex;
|
|
41
|
+
transform: scale(1.6);
|
|
42
|
+
margin: 0 0.6vw;
|
|
43
|
+
}
|
|
@@ -0,0 +1,127 @@
|
|
|
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
|
+
import { jsx } from "react/jsx-runtime";
|
|
21
|
+
import { useCallback, useEffect } from "react";
|
|
22
|
+
import ReactFlow, {
|
|
23
|
+
addEdge,
|
|
24
|
+
ConnectionLineType,
|
|
25
|
+
useNodesState,
|
|
26
|
+
useEdgesState,
|
|
27
|
+
Controls
|
|
28
|
+
} from "reactflow";
|
|
29
|
+
import dagre from "dagre";
|
|
30
|
+
import { DependencyGraph } from "../../utils/sdk/graph";
|
|
31
|
+
import GraphItem from "../GraphItem";
|
|
32
|
+
import { separateType } from "../../utils";
|
|
33
|
+
import styles from "./index.module";
|
|
34
|
+
import "reactflow/dist/style.css";
|
|
35
|
+
const nodeWidth = 400;
|
|
36
|
+
const nodeHeight = 300;
|
|
37
|
+
const nodeTypes = { graphItem: GraphItem };
|
|
38
|
+
const Graph = (props) => {
|
|
39
|
+
const [nodes, setNodes, onNodesChange] = useNodesState([]);
|
|
40
|
+
const [edges, setEdges, onEdgesChange] = useEdgesState([]);
|
|
41
|
+
const { snapshot } = props;
|
|
42
|
+
const { moduleInfo } = window.__FEDERATION__;
|
|
43
|
+
const { consumers } = separateType(moduleInfo);
|
|
44
|
+
useEffect(() => {
|
|
45
|
+
const dagreGraph = new dagre.graphlib.Graph();
|
|
46
|
+
dagreGraph.setDefaultEdgeLabel(() => ({}));
|
|
47
|
+
const getLayoutedElements = (nodes2, edges2, direction = "TB") => {
|
|
48
|
+
dagreGraph.setGraph({ rankdir: direction });
|
|
49
|
+
nodes2.forEach((node) => {
|
|
50
|
+
dagreGraph.setNode(node.id, { width: nodeWidth, height: nodeHeight });
|
|
51
|
+
});
|
|
52
|
+
edges2.forEach((edge) => {
|
|
53
|
+
dagreGraph.setEdge(edge.source, edge.target);
|
|
54
|
+
});
|
|
55
|
+
dagre.layout(dagreGraph);
|
|
56
|
+
nodes2.forEach((node) => {
|
|
57
|
+
const nodeWithPosition = dagreGraph.node(node.id);
|
|
58
|
+
node.position = {
|
|
59
|
+
x: nodeWithPosition.x - nodeWidth / 2,
|
|
60
|
+
y: nodeWithPosition.y - nodeHeight / 2
|
|
61
|
+
};
|
|
62
|
+
});
|
|
63
|
+
return { nodes: nodes2, edges: edges2 };
|
|
64
|
+
};
|
|
65
|
+
let nodeSet = [];
|
|
66
|
+
let edgeSet = [];
|
|
67
|
+
for (const consumer in consumers) {
|
|
68
|
+
const moduleGraph = new DependencyGraph(snapshot, consumer);
|
|
69
|
+
moduleGraph.createGraph();
|
|
70
|
+
moduleGraph.run(moduleGraph.graph, consumer, "graphItem");
|
|
71
|
+
nodeSet = [...nodeSet, ...moduleGraph.node];
|
|
72
|
+
edgeSet = [...edgeSet, ...moduleGraph.edge];
|
|
73
|
+
}
|
|
74
|
+
if (!nodeSet.length) {
|
|
75
|
+
nodeSet.push({
|
|
76
|
+
id: "1",
|
|
77
|
+
type: "graphItem",
|
|
78
|
+
position: {
|
|
79
|
+
x: 0,
|
|
80
|
+
y: 0
|
|
81
|
+
},
|
|
82
|
+
data: {
|
|
83
|
+
color: "lightgreen"
|
|
84
|
+
}
|
|
85
|
+
});
|
|
86
|
+
}
|
|
87
|
+
const { nodes: layoutedNodes, edges: layoutedEdges } = getLayoutedElements(
|
|
88
|
+
nodeSet,
|
|
89
|
+
edgeSet
|
|
90
|
+
);
|
|
91
|
+
setNodes(layoutedNodes);
|
|
92
|
+
setEdges(layoutedEdges);
|
|
93
|
+
setTimeout(() => {
|
|
94
|
+
const element = document.getElementsByClassName(
|
|
95
|
+
"react-flow__controls-fitview"
|
|
96
|
+
)[0];
|
|
97
|
+
element == null ? void 0 : element.click();
|
|
98
|
+
}, 50);
|
|
99
|
+
}, [snapshot]);
|
|
100
|
+
const onConnect = useCallback(
|
|
101
|
+
(params) => setEdges(
|
|
102
|
+
(eds) => addEdge(
|
|
103
|
+
__spreadProps(__spreadValues({}, params), { type: ConnectionLineType.SmoothStep, animated: true }),
|
|
104
|
+
eds
|
|
105
|
+
)
|
|
106
|
+
),
|
|
107
|
+
[]
|
|
108
|
+
);
|
|
109
|
+
return /* @__PURE__ */ jsx("div", { className: styles.depWrapper, children: /* @__PURE__ */ jsx(
|
|
110
|
+
ReactFlow,
|
|
111
|
+
{
|
|
112
|
+
className: styles.graph,
|
|
113
|
+
nodes,
|
|
114
|
+
edges,
|
|
115
|
+
onNodesChange,
|
|
116
|
+
onEdgesChange,
|
|
117
|
+
onConnect,
|
|
118
|
+
nodeTypes,
|
|
119
|
+
fitView: true,
|
|
120
|
+
children: /* @__PURE__ */ jsx(Controls, {})
|
|
121
|
+
}
|
|
122
|
+
) });
|
|
123
|
+
};
|
|
124
|
+
var Graph_default = Graph;
|
|
125
|
+
export {
|
|
126
|
+
Graph_default as default
|
|
127
|
+
};
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useState, useEffect } from "react";
|
|
3
|
+
import { Handle, Position } from "reactflow";
|
|
4
|
+
import styles from "./index.module";
|
|
5
|
+
import "reactflow/dist/style.css";
|
|
6
|
+
const GraphItem = (props) => {
|
|
7
|
+
const [shareds, setShareds] = useState([]);
|
|
8
|
+
const [exposes, setExposes] = useState([]);
|
|
9
|
+
let name;
|
|
10
|
+
let version;
|
|
11
|
+
const { info = "", color, remote } = props.data;
|
|
12
|
+
const infoArray = info.split(":");
|
|
13
|
+
if (info.endsWith(".json") || info.endsWith(".js")) {
|
|
14
|
+
name = infoArray.shift();
|
|
15
|
+
version = infoArray.join(":");
|
|
16
|
+
} else {
|
|
17
|
+
[name, version] = infoArray;
|
|
18
|
+
}
|
|
19
|
+
const isEntryType = (version == null ? void 0 : version.startsWith("http")) || (version == null ? void 0 : version.startsWith("//"));
|
|
20
|
+
useEffect(() => {
|
|
21
|
+
var _a, _b;
|
|
22
|
+
let exposes2;
|
|
23
|
+
let shareds2;
|
|
24
|
+
if (isEntryType) {
|
|
25
|
+
fetch(version).then((response) => response.json()).then((json) => {
|
|
26
|
+
exposes2 = json.exposes.map((expose) => expose.path) || [];
|
|
27
|
+
shareds2 = json.shared.map(
|
|
28
|
+
(share) => `${share.name}:${share.version}`
|
|
29
|
+
) || [];
|
|
30
|
+
setExposes(exposes2);
|
|
31
|
+
setShareds(shareds2);
|
|
32
|
+
});
|
|
33
|
+
} else {
|
|
34
|
+
exposes2 = ((_a = remote == null ? void 0 : remote.modules) == null ? void 0 : _a.map(
|
|
35
|
+
(item) => item.modulePath
|
|
36
|
+
)) || [];
|
|
37
|
+
shareds2 = ((_b = remote == null ? void 0 : remote.shared) == null ? void 0 : _b.map(
|
|
38
|
+
(item) => `${item.sharedName}:${item.version}`
|
|
39
|
+
)) || [];
|
|
40
|
+
setExposes(exposes2);
|
|
41
|
+
setShareds(shareds2);
|
|
42
|
+
}
|
|
43
|
+
}, []);
|
|
44
|
+
return /* @__PURE__ */ jsxs("div", { style: { background: color }, className: styles.Wrapper, children: [
|
|
45
|
+
/* @__PURE__ */ jsx(Handle, { type: "target", position: Position.Top }),
|
|
46
|
+
/* @__PURE__ */ jsxs("div", { className: styles.container, children: [
|
|
47
|
+
/* @__PURE__ */ jsx("div", { className: styles.group, children: /* @__PURE__ */ jsx("div", { className: styles.name, children: name }) }),
|
|
48
|
+
version && /* @__PURE__ */ jsxs("div", { className: styles.info, children: [
|
|
49
|
+
exposes.length > 0 ? /* @__PURE__ */ jsxs("div", { className: styles["expose-container"], children: [
|
|
50
|
+
/* @__PURE__ */ jsx("span", { className: styles.type, children: "Expose" }),
|
|
51
|
+
/* @__PURE__ */ jsx("div", { children: exposes.map((expose, index) => {
|
|
52
|
+
return /* @__PURE__ */ jsx("span", { className: styles.item, children: expose }, index);
|
|
53
|
+
}) })
|
|
54
|
+
] }) : null,
|
|
55
|
+
shareds.length > 0 ? /* @__PURE__ */ jsxs("div", { className: styles["expose-container"], children: [
|
|
56
|
+
/* @__PURE__ */ jsx("span", { className: styles.type, children: "Shared" }),
|
|
57
|
+
/* @__PURE__ */ jsx("div", { children: shareds.map((shared, index) => {
|
|
58
|
+
return /* @__PURE__ */ jsx("span", { className: styles.item, children: shared }, index);
|
|
59
|
+
}) })
|
|
60
|
+
] }) : null,
|
|
61
|
+
/* @__PURE__ */ jsxs("div", { children: [
|
|
62
|
+
/* @__PURE__ */ jsx("span", { className: styles.type, children: isEntryType ? "Entry" : "Version" }),
|
|
63
|
+
/* @__PURE__ */ jsx("span", { className: styles.item, children: version })
|
|
64
|
+
] })
|
|
65
|
+
] })
|
|
66
|
+
] }),
|
|
67
|
+
/* @__PURE__ */ jsx(Handle, { type: "source", position: Position.Bottom, id: "source" })
|
|
68
|
+
] });
|
|
69
|
+
};
|
|
70
|
+
var GraphItem_default = GraphItem;
|
|
71
|
+
export {
|
|
72
|
+
GraphItem_default as default
|
|
73
|
+
};
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import "./index_module.css";
|
|
2
|
+
var index_module_default = { "Wrapper": "Wrapper_2fa4f", "container": "container_2fa4f", "group": "group_2fa4f", "name": "name_2fa4f", "info": "info_2fa4f", "expose-container": "expose-container_2fa4f", "type": "type_2fa4f", "item": "item_2fa4f" };
|
|
3
|
+
export {
|
|
4
|
+
index_module_default as default
|
|
5
|
+
};
|