@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
|
@@ -0,0 +1,148 @@
|
|
|
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
|
+
import { MarkerType } from "reactflow";
|
|
18
|
+
const validateSemver = (schema) => {
|
|
19
|
+
const reg = /^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(\.(0|[1-9]\d*))?(?:-((?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\.(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\+([0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?$/gm;
|
|
20
|
+
return reg.test(schema);
|
|
21
|
+
};
|
|
22
|
+
const splitModuleId = (target) => {
|
|
23
|
+
const array = target.split(":");
|
|
24
|
+
const { length } = array;
|
|
25
|
+
if (length === 1) {
|
|
26
|
+
return target;
|
|
27
|
+
} else if (length >= 3) {
|
|
28
|
+
if (array[length - 1].endsWith(".json") || array[length - 1].endsWith(".js")) {
|
|
29
|
+
const idx = array.findIndex((t) => t.startsWith("http"));
|
|
30
|
+
return array[idx - 1];
|
|
31
|
+
} else {
|
|
32
|
+
return array[1];
|
|
33
|
+
}
|
|
34
|
+
} else {
|
|
35
|
+
const nameOrVersion = array[length - 1];
|
|
36
|
+
if (nameOrVersion === "*" || nameOrVersion === "latest" || validateSemver(nameOrVersion)) {
|
|
37
|
+
return array[0];
|
|
38
|
+
} else {
|
|
39
|
+
return nameOrVersion;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
};
|
|
43
|
+
class DependencyGraph {
|
|
44
|
+
constructor(snapshot, initTarget) {
|
|
45
|
+
this.snapshot = snapshot;
|
|
46
|
+
this.initTarget = initTarget;
|
|
47
|
+
this.node = [];
|
|
48
|
+
this.edge = [];
|
|
49
|
+
this.graph = {};
|
|
50
|
+
this.identifyMap = /* @__PURE__ */ new Map();
|
|
51
|
+
this.handledModuleMap = /* @__PURE__ */ new Map();
|
|
52
|
+
}
|
|
53
|
+
createGraph(target = this.initTarget) {
|
|
54
|
+
const { snapshot } = this;
|
|
55
|
+
let remotesInfo;
|
|
56
|
+
const snapshotWithoutType = snapshot[target];
|
|
57
|
+
const snapshotWithType = snapshot[target];
|
|
58
|
+
if (snapshotWithoutType && "remotesInfo" in snapshotWithoutType) {
|
|
59
|
+
remotesInfo = snapshotWithoutType == null ? void 0 : snapshotWithoutType.remotesInfo;
|
|
60
|
+
}
|
|
61
|
+
if (snapshotWithType && "remotesInfo" in snapshotWithType) {
|
|
62
|
+
remotesInfo = snapshotWithType == null ? void 0 : snapshotWithType.remotesInfo;
|
|
63
|
+
}
|
|
64
|
+
if (!remotesInfo) {
|
|
65
|
+
return;
|
|
66
|
+
}
|
|
67
|
+
Object.keys(remotesInfo).forEach((dep) => {
|
|
68
|
+
const { matchedVersion } = remotesInfo[dep];
|
|
69
|
+
let childId = dep;
|
|
70
|
+
if (matchedVersion && matchedVersion !== "") {
|
|
71
|
+
childId = `${childId}:${matchedVersion}`;
|
|
72
|
+
}
|
|
73
|
+
if (!this.graph[target]) {
|
|
74
|
+
this.graph[target] = {};
|
|
75
|
+
}
|
|
76
|
+
this.graph[childId] = {};
|
|
77
|
+
this.graph[target][childId] = this.graph[childId];
|
|
78
|
+
const handled = this.handledModuleMap.get(childId);
|
|
79
|
+
if (!handled) {
|
|
80
|
+
this.handledModuleMap.set(childId, true);
|
|
81
|
+
this.createGraph(childId);
|
|
82
|
+
}
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
|
+
addNode(id, type, x, y, nodeData) {
|
|
86
|
+
this.node.push({
|
|
87
|
+
id,
|
|
88
|
+
type,
|
|
89
|
+
position: {
|
|
90
|
+
x,
|
|
91
|
+
y
|
|
92
|
+
},
|
|
93
|
+
data: __spreadValues({}, nodeData)
|
|
94
|
+
});
|
|
95
|
+
}
|
|
96
|
+
addEdge(id, source, target, type = "default") {
|
|
97
|
+
this.edge.push({
|
|
98
|
+
id,
|
|
99
|
+
source,
|
|
100
|
+
target,
|
|
101
|
+
markerEnd: {
|
|
102
|
+
type: MarkerType.Arrow,
|
|
103
|
+
width: 30,
|
|
104
|
+
height: 30
|
|
105
|
+
},
|
|
106
|
+
type
|
|
107
|
+
});
|
|
108
|
+
}
|
|
109
|
+
run(targetGraph, target = this.initTarget, type, id = this.initTarget) {
|
|
110
|
+
var _a;
|
|
111
|
+
if (!targetGraph || !((_a = Object.keys(targetGraph)) == null ? void 0 : _a.length)) {
|
|
112
|
+
return;
|
|
113
|
+
}
|
|
114
|
+
const name = splitModuleId(target);
|
|
115
|
+
const targetWithoutType = name;
|
|
116
|
+
let info = name;
|
|
117
|
+
const remote = this.snapshot[target];
|
|
118
|
+
if (remote && ("version" in remote || "remoteEntry" in remote)) {
|
|
119
|
+
info += `:${remote.version || remote.remoteEntry}`;
|
|
120
|
+
}
|
|
121
|
+
if (!this.identifyMap.has(targetWithoutType)) {
|
|
122
|
+
this.identifyMap.set(targetWithoutType, this.identify());
|
|
123
|
+
}
|
|
124
|
+
this.addNode(id, type, 0, 0, {
|
|
125
|
+
info,
|
|
126
|
+
remote,
|
|
127
|
+
color: this.identifyMap.get(targetWithoutType)
|
|
128
|
+
});
|
|
129
|
+
const graphChilden = Object.keys(
|
|
130
|
+
targetGraph[targetWithoutType] || targetGraph[target] || {}
|
|
131
|
+
);
|
|
132
|
+
graphChilden.forEach((dep) => {
|
|
133
|
+
this.addEdge(id + dep, id, id + dep);
|
|
134
|
+
this.run(targetGraph[targetWithoutType], dep, type, id + dep);
|
|
135
|
+
});
|
|
136
|
+
}
|
|
137
|
+
identify() {
|
|
138
|
+
const r = Math.floor(Math.random() * 255);
|
|
139
|
+
const g = Math.floor(Math.random() * 255);
|
|
140
|
+
const b = Math.floor(Math.random() * 255);
|
|
141
|
+
const color = `rgba(${r},${g},${b},0.8)`;
|
|
142
|
+
return color;
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
export {
|
|
146
|
+
DependencyGraph,
|
|
147
|
+
validateSemver
|
|
148
|
+
};
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
export * from "./graph";
|
|
2
|
+
const setLocalStorage = (key, value) => {
|
|
3
|
+
localStorage.setItem(key, value);
|
|
4
|
+
};
|
|
5
|
+
const removeLocalStorage = (key) => {
|
|
6
|
+
const data = localStorage.getItem(key);
|
|
7
|
+
if (data) {
|
|
8
|
+
localStorage.removeItem(key);
|
|
9
|
+
}
|
|
10
|
+
};
|
|
11
|
+
const mergeLocalStorage = (target, key, value) => {
|
|
12
|
+
const str = localStorage.getItem(target);
|
|
13
|
+
const obj = JSON.parse(str || "{}");
|
|
14
|
+
obj[key] = value;
|
|
15
|
+
localStorage.setItem(target, JSON.stringify(obj));
|
|
16
|
+
};
|
|
17
|
+
const removeLocalStorageKey = (target, key) => {
|
|
18
|
+
const str = localStorage.getItem(target);
|
|
19
|
+
if (str) {
|
|
20
|
+
const obj = JSON.parse(str || "{}");
|
|
21
|
+
delete obj[key];
|
|
22
|
+
localStorage.setItem(target, JSON.stringify(obj));
|
|
23
|
+
}
|
|
24
|
+
};
|
|
25
|
+
const isObject = (target) => Object.prototype.toString.call(target) === "[object Object]";
|
|
26
|
+
const reloadPage = () => {
|
|
27
|
+
var _a;
|
|
28
|
+
(_a = globalThis == null ? void 0 : globalThis.location) == null ? void 0 : _a.reload();
|
|
29
|
+
};
|
|
30
|
+
const validateCustom = (schema) => schema == null ? void 0 : schema.endsWith(".json");
|
|
31
|
+
const getUnpkgUrl = (pkg, version) => {
|
|
32
|
+
if (pkg === "react") {
|
|
33
|
+
return `https://unpkg.com/react@${version}/umd/react.development.js`;
|
|
34
|
+
} else if (pkg === "react-dom") {
|
|
35
|
+
return `https://unpkg.com/react-dom@${version}/umd/react-dom.development.js`;
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
const definePropertyGlobalVal = (target, key, val) => {
|
|
39
|
+
Object.defineProperty(target, key, {
|
|
40
|
+
value: val,
|
|
41
|
+
configurable: false,
|
|
42
|
+
writable: true
|
|
43
|
+
});
|
|
44
|
+
};
|
|
45
|
+
export {
|
|
46
|
+
definePropertyGlobalVal,
|
|
47
|
+
getUnpkgUrl,
|
|
48
|
+
isObject,
|
|
49
|
+
mergeLocalStorage,
|
|
50
|
+
reloadPage,
|
|
51
|
+
removeLocalStorage,
|
|
52
|
+
removeLocalStorageKey,
|
|
53
|
+
setLocalStorage,
|
|
54
|
+
validateCustom
|
|
55
|
+
};
|
|
File without changes
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./common";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
console.log("Module Federation Worker");
|
package/dist/lib/App.js
ADDED
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
+
var App_exports = {};
|
|
30
|
+
__export(App_exports, {
|
|
31
|
+
default: () => App_default
|
|
32
|
+
});
|
|
33
|
+
module.exports = __toCommonJS(App_exports);
|
|
34
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
35
|
+
var import_react = require("react");
|
|
36
|
+
var import_web_react = require("@arco-design/web-react");
|
|
37
|
+
var import_init = require("./init");
|
|
38
|
+
var import_Layout = __toESM(require("./component/Layout"));
|
|
39
|
+
var import_utils = require("./utils");
|
|
40
|
+
var import_arco = require("@arco-design/web-react/dist/css/arco.css");
|
|
41
|
+
var import_App = __toESM(require("./App.module"));
|
|
42
|
+
const { Content } = import_web_react.Layout;
|
|
43
|
+
const App = (props) => {
|
|
44
|
+
var _a;
|
|
45
|
+
const { versionList, setVersionList, getVersion, handleSnapshot } = props;
|
|
46
|
+
const [module2, setModule] = (0, import_react.useState)(((_a = window.__FEDERATION__) == null ? void 0 : _a.moduleInfo) || {});
|
|
47
|
+
(0, import_react.useEffect)(() => {
|
|
48
|
+
(0, import_utils.getGlobalModuleInfo)(setModule);
|
|
49
|
+
}, []);
|
|
50
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_jsx_runtime.Fragment, { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_web_react.Layout, { className: import_App.default.layout, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Content, { className: import_App.default.content, children: Object.keys(module2).length > 0 || process.env.NODE_ENV === "development" ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
51
|
+
import_Layout.default,
|
|
52
|
+
{
|
|
53
|
+
moduleInfo: module2,
|
|
54
|
+
versionList,
|
|
55
|
+
setVersionList,
|
|
56
|
+
getVersion,
|
|
57
|
+
handleSnapshot
|
|
58
|
+
}
|
|
59
|
+
) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_web_react.Empty, { description: "No ModuleInfo Detected" }) }) }) });
|
|
60
|
+
};
|
|
61
|
+
var App_default = App;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var App_module_exports = {};
|
|
20
|
+
__export(App_module_exports, {
|
|
21
|
+
default: () => App_module_default
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(App_module_exports);
|
|
24
|
+
var import_App_module = require("./App_module.css");
|
|
25
|
+
var App_module_default = { "layout": "layout_ae2ee", "content": "content_ae2ee" };
|
|
@@ -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,295 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
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 Form_exports = {};
|
|
50
|
+
__export(Form_exports, {
|
|
51
|
+
default: () => Form_default
|
|
52
|
+
});
|
|
53
|
+
module.exports = __toCommonJS(Form_exports);
|
|
54
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
55
|
+
var import_react = require("react");
|
|
56
|
+
var import_react_dom = require("react-dom");
|
|
57
|
+
var import_web_react = require("@arco-design/web-react");
|
|
58
|
+
var import_icon = require("@arco-design/web-react/icon");
|
|
59
|
+
var import_constant = require("../../template/constant");
|
|
60
|
+
var import_utils = require("../../utils");
|
|
61
|
+
var import_index = __toESM(require("./index.module"));
|
|
62
|
+
const FormItem = import_web_react.Form.Item;
|
|
63
|
+
const FormList = import_web_react.Form.List;
|
|
64
|
+
const { Option } = import_web_react.Select;
|
|
65
|
+
const FormComponent = (props) => {
|
|
66
|
+
const {
|
|
67
|
+
form,
|
|
68
|
+
condition,
|
|
69
|
+
formStatus,
|
|
70
|
+
setFormStatus,
|
|
71
|
+
validateForm,
|
|
72
|
+
enableHMR,
|
|
73
|
+
onHMRChange,
|
|
74
|
+
versionList,
|
|
75
|
+
setVersionList,
|
|
76
|
+
getVersion
|
|
77
|
+
} = props;
|
|
78
|
+
const { moduleInfo } = window.__FEDERATION__;
|
|
79
|
+
let { producer } = (0, import_utils.separateType)(moduleInfo);
|
|
80
|
+
const filterDupMap = /* @__PURE__ */ new Map();
|
|
81
|
+
producer = producer.filter((t) => {
|
|
82
|
+
const [typeOrName, name] = t.split(":");
|
|
83
|
+
const marked = filterDupMap.get(name || typeOrName);
|
|
84
|
+
filterDupMap.set(name || typeOrName, true);
|
|
85
|
+
return !marked;
|
|
86
|
+
});
|
|
87
|
+
const formatProducer = producer.map((id) => {
|
|
88
|
+
const hasType = id.includes(":");
|
|
89
|
+
if (hasType) {
|
|
90
|
+
return {
|
|
91
|
+
label: id.split(":")[1],
|
|
92
|
+
value: id
|
|
93
|
+
};
|
|
94
|
+
} else {
|
|
95
|
+
return {
|
|
96
|
+
label: id,
|
|
97
|
+
value: id
|
|
98
|
+
};
|
|
99
|
+
}
|
|
100
|
+
});
|
|
101
|
+
(0, import_react.useEffect)(() => {
|
|
102
|
+
producer.forEach((target) => __async(void 0, null, function* () {
|
|
103
|
+
const version = yield getVersion == null ? void 0 : getVersion(target);
|
|
104
|
+
const list = [...versionList || []];
|
|
105
|
+
if (version) {
|
|
106
|
+
list.push(version);
|
|
107
|
+
}
|
|
108
|
+
setVersionList == null ? void 0 : setVersionList(list);
|
|
109
|
+
}));
|
|
110
|
+
}, []);
|
|
111
|
+
const getCheckStatus = (index) => {
|
|
112
|
+
const formData = form.getFieldsValue();
|
|
113
|
+
return formData[import_constant.proxyFormField][index].checked;
|
|
114
|
+
};
|
|
115
|
+
const validateKey = (key, callback, index) => {
|
|
116
|
+
const status = getCheckStatus(index);
|
|
117
|
+
if (!status) {
|
|
118
|
+
return callback();
|
|
119
|
+
}
|
|
120
|
+
const statusSet = [...formStatus];
|
|
121
|
+
if (!(0, import_utils.isObject)(statusSet[index])) {
|
|
122
|
+
statusSet[index] = {
|
|
123
|
+
keyStatus: false,
|
|
124
|
+
valueStatus: false
|
|
125
|
+
};
|
|
126
|
+
}
|
|
127
|
+
if (key) {
|
|
128
|
+
statusSet[index].keyStatus = true;
|
|
129
|
+
(0, import_react_dom.flushSync)(() => setFormStatus(statusSet));
|
|
130
|
+
return callback();
|
|
131
|
+
}
|
|
132
|
+
statusSet[index].keyStatus = false;
|
|
133
|
+
(0, import_react_dom.flushSync)(() => setFormStatus(statusSet));
|
|
134
|
+
return callback("Module name can not be empty");
|
|
135
|
+
};
|
|
136
|
+
const validateValue = (value, callback, index) => {
|
|
137
|
+
const status = getCheckStatus(index);
|
|
138
|
+
if (!status) {
|
|
139
|
+
return callback();
|
|
140
|
+
}
|
|
141
|
+
const statusSet = [...formStatus];
|
|
142
|
+
if (!(0, import_utils.isObject)(statusSet[index])) {
|
|
143
|
+
statusSet[index] = {
|
|
144
|
+
keyStatus: false,
|
|
145
|
+
valueStatus: false
|
|
146
|
+
};
|
|
147
|
+
}
|
|
148
|
+
if ((0, import_utils.validateCustom)(value) || (0, import_utils.validateSemver)(value)) {
|
|
149
|
+
statusSet[index].valueStatus = true;
|
|
150
|
+
(0, import_react_dom.flushSync)(() => setFormStatus(statusSet));
|
|
151
|
+
return callback();
|
|
152
|
+
}
|
|
153
|
+
statusSet[index].valueStatus = false;
|
|
154
|
+
(0, import_react_dom.flushSync)(() => setFormStatus(statusSet));
|
|
155
|
+
return callback(
|
|
156
|
+
"The module information format is incorrect, check the format in the upper left corner"
|
|
157
|
+
);
|
|
158
|
+
};
|
|
159
|
+
const onAdd = (add) => {
|
|
160
|
+
add(import_constant.defaultDataItem);
|
|
161
|
+
setVersionList == null ? void 0 : setVersionList([...versionList || [], []]);
|
|
162
|
+
validateForm();
|
|
163
|
+
};
|
|
164
|
+
const onRemove = (remove, index) => {
|
|
165
|
+
if (Array.isArray(versionList)) {
|
|
166
|
+
versionList.splice(index, 1);
|
|
167
|
+
setVersionList == null ? void 0 : setVersionList(versionList);
|
|
168
|
+
}
|
|
169
|
+
remove(index);
|
|
170
|
+
};
|
|
171
|
+
const hmrChange = (on) => {
|
|
172
|
+
onHMRChange(on);
|
|
173
|
+
};
|
|
174
|
+
const onKeyChange = (key, index) => __async(void 0, null, function* () {
|
|
175
|
+
const version = yield getVersion == null ? void 0 : getVersion(key);
|
|
176
|
+
if (version) {
|
|
177
|
+
const list = [...versionList || []];
|
|
178
|
+
list.splice(index, 1, version);
|
|
179
|
+
setVersionList == null ? void 0 : setVersionList(list);
|
|
180
|
+
}
|
|
181
|
+
});
|
|
182
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(FormList, { field: import_constant.proxyFormField, children: (fields, { add, remove }) => /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { children: [
|
|
183
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: import_index.default.header, children: [
|
|
184
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
185
|
+
import_web_react.Tooltip,
|
|
186
|
+
{
|
|
187
|
+
content: /* @__PURE__ */ (0, import_jsx_runtime.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" }),
|
|
188
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_icon.IconInfoCircle, {})
|
|
189
|
+
}
|
|
190
|
+
),
|
|
191
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: import_index.default.title, children: "Module Proxy" }),
|
|
192
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
193
|
+
import_web_react.Button,
|
|
194
|
+
{
|
|
195
|
+
icon: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_icon.IconPlus, {}),
|
|
196
|
+
shape: "circle",
|
|
197
|
+
className: import_index.default.add,
|
|
198
|
+
onClick: () => onAdd(add),
|
|
199
|
+
"data-set-e2e": "e2eAdd"
|
|
200
|
+
}
|
|
201
|
+
),
|
|
202
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: import_index.default.status, children: [
|
|
203
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_web_react.Badge, { color: condition.color, className: import_index.default.badge }),
|
|
204
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: import_index.default.message, children: condition.message }),
|
|
205
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
206
|
+
import_web_react.Switch,
|
|
207
|
+
{
|
|
208
|
+
checked: enableHMR === "enable",
|
|
209
|
+
checkedText: "Enable HMR",
|
|
210
|
+
uncheckedText: "Disable HMR",
|
|
211
|
+
onChange: hmrChange,
|
|
212
|
+
className: import_index.default.switch
|
|
213
|
+
}
|
|
214
|
+
)
|
|
215
|
+
] })
|
|
216
|
+
] }),
|
|
217
|
+
fields.length ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_jsx_runtime.Fragment, { children: fields.map((item, index) => {
|
|
218
|
+
var _a, _b;
|
|
219
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
220
|
+
"div",
|
|
221
|
+
{
|
|
222
|
+
className: import_index.default.container,
|
|
223
|
+
"data-set-e2e": "e2eProxyItem",
|
|
224
|
+
children: [
|
|
225
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
226
|
+
FormItem,
|
|
227
|
+
{
|
|
228
|
+
field: `${item.field}.checked`,
|
|
229
|
+
triggerPropName: "checked",
|
|
230
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_web_react.Checkbox, { className: import_index.default.checkBox })
|
|
231
|
+
}
|
|
232
|
+
) }),
|
|
233
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: import_index.default.input, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
234
|
+
FormItem,
|
|
235
|
+
{
|
|
236
|
+
field: `${item.field}.key`,
|
|
237
|
+
rules: [
|
|
238
|
+
{
|
|
239
|
+
validator: (value, cb) => validateKey(value, cb, index)
|
|
240
|
+
}
|
|
241
|
+
],
|
|
242
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
243
|
+
import_web_react.Select,
|
|
244
|
+
{
|
|
245
|
+
"data-set-e2e": "e2eProxyKey",
|
|
246
|
+
placeholder: "Module Name",
|
|
247
|
+
onChange: (key) => onKeyChange(key, index),
|
|
248
|
+
allowClear: true,
|
|
249
|
+
showSearch: true,
|
|
250
|
+
children: formatProducer.map((item2) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Option, { value: item2.value, children: item2.label }, item2.value))
|
|
251
|
+
}
|
|
252
|
+
)
|
|
253
|
+
}
|
|
254
|
+
) }),
|
|
255
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: import_index.default.input, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
256
|
+
FormItem,
|
|
257
|
+
{
|
|
258
|
+
field: `${item.field}.value`,
|
|
259
|
+
rules: [
|
|
260
|
+
{
|
|
261
|
+
validator: (value, cb) => validateValue(value, cb, index)
|
|
262
|
+
}
|
|
263
|
+
],
|
|
264
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
265
|
+
import_web_react.Select,
|
|
266
|
+
{
|
|
267
|
+
"data-set-e2e": "e2eProxyValue",
|
|
268
|
+
placeholder: "Custom Manifest URL",
|
|
269
|
+
allowClear: true,
|
|
270
|
+
showSearch: true,
|
|
271
|
+
allowCreate: true,
|
|
272
|
+
children: (_b = (_a = versionList || []) == null ? void 0 : _a[index]) == null ? void 0 : _b.map((version) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Option, { value: version, children: version }, version))
|
|
273
|
+
}
|
|
274
|
+
)
|
|
275
|
+
}
|
|
276
|
+
) }),
|
|
277
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
278
|
+
import_web_react.Button,
|
|
279
|
+
{
|
|
280
|
+
icon: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_icon.IconDelete, {}),
|
|
281
|
+
shape: "circle",
|
|
282
|
+
status: "danger",
|
|
283
|
+
className: import_index.default.delete,
|
|
284
|
+
"data-set-e2e": "e2eDelete",
|
|
285
|
+
onClick: () => onRemove(remove, index)
|
|
286
|
+
}
|
|
287
|
+
)
|
|
288
|
+
]
|
|
289
|
+
},
|
|
290
|
+
item.field
|
|
291
|
+
);
|
|
292
|
+
}) }) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_web_react.Empty, {})
|
|
293
|
+
] }) });
|
|
294
|
+
};
|
|
295
|
+
var Form_default = FormComponent;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var index_module_exports = {};
|
|
20
|
+
__export(index_module_exports, {
|
|
21
|
+
default: () => index_module_default
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(index_module_exports);
|
|
24
|
+
var import_index_module = require("./index_module.css");
|
|
25
|
+
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" };
|
|
@@ -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
|
+
}
|