@module-federation/devtools 2.6.0 → 2.8.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (132) hide show
  1. package/dist/es/App.js +3 -2
  2. package/dist/es/component/DependencyGraphItem/index.js +18 -7
  3. package/dist/es/utils/chrome/index.js +37 -17
  4. package/dist/es/utils/chrome/post-message-listener.js +5 -2
  5. package/dist/es/utils/sdk/graph.js +25 -11
  6. package/dist/lib/App.js +2 -3
  7. package/dist/lib/App.module.js +0 -1
  8. package/dist/lib/component/DependencyGraph/index.js +0 -1
  9. package/dist/lib/component/DependencyGraph/index.module.js +0 -1
  10. package/dist/lib/component/DependencyGraphItem/index.js +18 -8
  11. package/dist/lib/component/DependencyGraphItem/index.module.js +0 -1
  12. package/dist/lib/component/Form/index.js +0 -1
  13. package/dist/lib/component/Form/index.module.js +0 -1
  14. package/dist/lib/component/LanguageSwitch.js +0 -1
  15. package/dist/lib/component/Layout/index.js +0 -1
  16. package/dist/lib/component/Layout/index.module.js +0 -1
  17. package/dist/lib/component/LoadingTrace/index.js +0 -1
  18. package/dist/lib/component/LoadingTrace/index.module.js +0 -1
  19. package/dist/lib/component/ModuleInfo/index.js +0 -1
  20. package/dist/lib/component/ModuleInfo/index.module.js +0 -1
  21. package/dist/lib/component/SharedDepsExplorer/FocusResultDisplay.js +0 -1
  22. package/dist/lib/component/SharedDepsExplorer/FocusResultDisplay.module.js +0 -1
  23. package/dist/lib/component/SharedDepsExplorer/index.js +0 -1
  24. package/dist/lib/component/SharedDepsExplorer/index.module.js +0 -1
  25. package/dist/lib/component/SharedDepsExplorer/share-utils.js +0 -1
  26. package/dist/lib/component/ThemeToggle.js +0 -1
  27. package/dist/lib/component/ThemeToggle.module.js +0 -1
  28. package/dist/lib/hooks/useDevtoolsTheme.js +0 -1
  29. package/dist/lib/i18n/index.js +0 -1
  30. package/dist/lib/init.js +0 -1
  31. package/dist/lib/template/constant.js +0 -1
  32. package/dist/lib/template/index.js +0 -1
  33. package/dist/lib/utils/chrome/fast-refresh.js +0 -1
  34. package/dist/lib/utils/chrome/index.js +38 -18
  35. package/dist/lib/utils/chrome/messages.js +0 -1
  36. package/dist/lib/utils/chrome/observability-plugin.js +0 -1
  37. package/dist/lib/utils/chrome/observability-shared.js +0 -1
  38. package/dist/lib/utils/chrome/observability.js +0 -1
  39. package/dist/lib/utils/chrome/override-remote.js +0 -1
  40. package/dist/lib/utils/chrome/post-message-init.js +0 -1
  41. package/dist/lib/utils/chrome/post-message-listener.js +5 -3
  42. package/dist/lib/utils/chrome/post-message-start.js +0 -1
  43. package/dist/lib/utils/chrome/post-message.js +0 -1
  44. package/dist/lib/utils/chrome/safe-post-message.js +0 -1
  45. package/dist/lib/utils/chrome/snapshot-plugin.js +0 -1
  46. package/dist/lib/utils/chrome/storage.js +0 -1
  47. package/dist/lib/utils/data/index.js +0 -1
  48. package/dist/lib/utils/index.js +0 -1
  49. package/dist/lib/utils/sdk/graph.js +25 -12
  50. package/dist/lib/utils/sdk/index.js +0 -1
  51. package/dist/lib/utils/types/common.js +0 -1
  52. package/dist/lib/utils/types/index.js +0 -1
  53. package/dist/lib/worker/index.js +0 -1
  54. package/dist/types/App.css +13 -0
  55. package/dist/types/App.js +519 -0
  56. package/dist/types/App.module.js +24 -0
  57. package/dist/types/App_module.css +307 -0
  58. package/dist/types/component/DependencyGraph/index.js +225 -0
  59. package/dist/types/component/DependencyGraph/index.module.js +24 -0
  60. package/dist/types/component/DependencyGraph/index_module.css +100 -0
  61. package/dist/types/component/DependencyGraphItem/index.js +124 -0
  62. package/dist/types/component/DependencyGraphItem/index.module.js +24 -0
  63. package/dist/types/component/DependencyGraphItem/index_module.css +95 -0
  64. package/dist/types/component/Form/index.js +372 -0
  65. package/dist/types/component/Form/index.module.js +24 -0
  66. package/dist/types/component/Form/index_module.css +198 -0
  67. package/dist/types/component/LanguageSwitch.js +79 -0
  68. package/dist/types/component/Layout/index.js +471 -0
  69. package/dist/types/component/Layout/index.module.js +24 -0
  70. package/dist/types/component/Layout/index_module.css +68 -0
  71. package/dist/types/component/LoadingTrace/index.js +953 -0
  72. package/dist/types/component/LoadingTrace/index.module.js +24 -0
  73. package/dist/types/component/LoadingTrace/index_module.css +876 -0
  74. package/dist/types/component/ModuleInfo/index.js +342 -0
  75. package/dist/types/component/ModuleInfo/index.module.js +24 -0
  76. package/dist/types/component/ModuleInfo/index_module.css +184 -0
  77. package/dist/types/component/SharedDepsExplorer/FocusResultDisplay.js +64 -0
  78. package/dist/types/component/SharedDepsExplorer/FocusResultDisplay.module.js +24 -0
  79. package/dist/types/component/SharedDepsExplorer/FocusResultDisplay_module.css +45 -0
  80. package/dist/types/component/SharedDepsExplorer/index.js +638 -0
  81. package/dist/types/component/SharedDepsExplorer/index.module.js +24 -0
  82. package/dist/types/component/SharedDepsExplorer/index_module.css +467 -0
  83. package/dist/types/component/SharedDepsExplorer/share-utils.js +252 -0
  84. package/dist/types/component/ThemeToggle.js +48 -0
  85. package/dist/types/component/ThemeToggle.module.js +24 -0
  86. package/dist/types/component/ThemeToggle_module.css +12 -0
  87. package/dist/types/hooks/useDevtoolsTheme.js +100 -0
  88. package/dist/types/i18n/index.js +721 -0
  89. package/dist/types/init.js +8 -0
  90. package/dist/types/src/App.d.ts +1 -1
  91. package/dist/types/src/component/DependencyGraph/index.d.ts +1 -1
  92. package/dist/types/src/component/DependencyGraphItem/index.d.ts +1 -1
  93. package/dist/types/src/component/Form/index.d.ts +1 -1
  94. package/dist/types/src/component/LanguageSwitch.d.ts +1 -1
  95. package/dist/types/src/component/Layout/index.d.ts +1 -1
  96. package/dist/types/src/component/LoadingTrace/index.d.ts +1 -1
  97. package/dist/types/src/component/ModuleInfo/index.d.ts +1 -1
  98. package/dist/types/src/component/SharedDepsExplorer/index.d.ts +1 -1
  99. package/dist/types/src/component/SharedDepsExplorer/share-utils.d.ts +1 -1
  100. package/dist/types/src/i18n/index.d.ts +1 -1
  101. package/dist/types/src/template/constant.d.ts +1 -1
  102. package/dist/types/src/utils/chrome/index.d.ts +2 -1
  103. package/dist/types/src/utils/chrome/observability.d.ts +1 -1
  104. package/dist/types/src/utils/data/index.d.ts +1 -1
  105. package/dist/types/src/utils/sdk/graph.d.ts +1 -1
  106. package/dist/types/src/utils/sdk/index.d.ts +2 -2
  107. package/dist/types/stories/index.stories.d.ts +2 -1
  108. package/dist/types/template/constant.js +84 -0
  109. package/dist/types/template/index.js +21 -0
  110. package/dist/types/utils/chrome/fast-refresh.js +329 -0
  111. package/dist/types/utils/chrome/index.js +321 -0
  112. package/dist/types/utils/chrome/messages.js +39 -0
  113. package/dist/types/utils/chrome/observability-plugin.js +85 -0
  114. package/dist/types/utils/chrome/observability-shared.js +125 -0
  115. package/dist/types/utils/chrome/observability.js +233 -0
  116. package/dist/types/utils/chrome/override-remote.js +17 -0
  117. package/dist/types/utils/chrome/post-message-init.js +5 -0
  118. package/dist/types/utils/chrome/post-message-listener.js +36 -0
  119. package/dist/types/utils/chrome/post-message-start.js +10 -0
  120. package/dist/types/utils/chrome/post-message.js +91 -0
  121. package/dist/types/utils/chrome/safe-post-message.js +147 -0
  122. package/dist/types/utils/chrome/snapshot-plugin.js +17 -0
  123. package/dist/types/utils/chrome/storage.js +71 -0
  124. package/dist/types/utils/data/index.js +83 -0
  125. package/dist/types/utils/index.js +27 -0
  126. package/dist/types/utils/sdk/graph.js +213 -0
  127. package/dist/types/utils/sdk/index.js +104 -0
  128. package/dist/types/utils/types/common.js +15 -0
  129. package/dist/types/utils/types/index.js +21 -0
  130. package/dist/types/vendor/basic-proxy-core.js +147 -0
  131. package/dist/types/worker/index.js +175 -0
  132. package/package.json +8 -9
@@ -0,0 +1,124 @@
1
+ var __create = Object.create;
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __getProtoOf = Object.getPrototypeOf;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __export = (target, all) => {
8
+ for (var name in all)
9
+ __defProp(target, name, { get: all[name], enumerable: true });
10
+ };
11
+ var __copyProps = (to, from, except, desc) => {
12
+ if (from && typeof from === "object" || typeof from === "function") {
13
+ for (let key of __getOwnPropNames(from))
14
+ if (!__hasOwnProp.call(to, key) && key !== except)
15
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
16
+ }
17
+ return to;
18
+ };
19
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
20
+ // If the importer is in node compatibility mode or this is not an ESM
21
+ // file that has been converted to a CommonJS file using a Babel-
22
+ // compatible transform (i.e. "__esModule" has not been set), then set
23
+ // "default" to the CommonJS "module.exports" for node compatibility.
24
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
25
+ mod
26
+ ));
27
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
28
+ var DependencyGraphItem_exports = {};
29
+ __export(DependencyGraphItem_exports, {
30
+ default: () => DependencyGraphItem_default
31
+ });
32
+ module.exports = __toCommonJS(DependencyGraphItem_exports);
33
+ var import_jsx_runtime = require("react/jsx-runtime");
34
+ var import_react = require("react");
35
+ var import_reactflow = require("reactflow");
36
+ var import_react_i18next = require("react-i18next");
37
+ var import_index = __toESM(require("./index.module"));
38
+ var import_style = require("reactflow/dist/style.css");
39
+ const parseInfo = (info) => {
40
+ const array = info.split(":");
41
+ const [fallbackName, fallbackVersion = ""] = array;
42
+ const idx = array.findIndex((item, index) => {
43
+ return index > 0 && (item.startsWith("http") || item.startsWith("//"));
44
+ });
45
+ if (idx > 0) {
46
+ return {
47
+ name: array.slice(0, idx).join(":"),
48
+ version: array.slice(idx).join(":")
49
+ };
50
+ }
51
+ return {
52
+ name: fallbackName,
53
+ version: fallbackVersion
54
+ };
55
+ };
56
+ const GraphItem = (props) => {
57
+ const [shareds, setShareds] = (0, import_react.useState)([]);
58
+ const [exposes, setExposes] = (0, import_react.useState)([]);
59
+ const { t } = (0, import_react_i18next.useTranslation)();
60
+ let name;
61
+ let version;
62
+ const { info = "", color, remote } = props.data;
63
+ ({ name, version } = parseInfo(info));
64
+ const isEntryType = (version == null ? void 0 : version.startsWith("http")) || (version == null ? void 0 : version.startsWith("//"));
65
+ (0, import_react.useEffect)(() => {
66
+ var _a, _b;
67
+ let exposes2;
68
+ let shareds2;
69
+ if (isEntryType) {
70
+ fetch(version).then((response) => response.json()).then((json) => {
71
+ const exposeList = Array.isArray(json == null ? void 0 : json.exposes) ? json.exposes : [];
72
+ const sharedList = Array.isArray(json == null ? void 0 : json.shared) ? json.shared : [];
73
+ exposes2 = exposeList.map((expose) => expose.path) || [];
74
+ shareds2 = sharedList.map(
75
+ (share) => `${share.name}:${share.version}`
76
+ ) || [];
77
+ setExposes(exposes2);
78
+ setShareds(shareds2);
79
+ }).catch(() => {
80
+ setExposes([]);
81
+ setShareds([]);
82
+ });
83
+ } else {
84
+ exposes2 = ((_a = remote == null ? void 0 : remote.modules) == null ? void 0 : _a.map(
85
+ (item) => item.modulePath
86
+ )) || [];
87
+ shareds2 = ((_b = remote == null ? void 0 : remote.shared) == null ? void 0 : _b.map(
88
+ (item) => `${item.sharedName}:${item.version}`
89
+ )) || [];
90
+ setExposes(exposes2);
91
+ setShareds(shareds2);
92
+ }
93
+ }, [isEntryType, remote, version]);
94
+ const accentColor = color || "rgba(99, 102, 241, 0.45)";
95
+ const style = {
96
+ ["--mf-accent"]: accentColor
97
+ };
98
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { style, className: import_index.default.Wrapper, children: [
99
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_reactflow.Handle, { type: "target", position: import_reactflow.Position.Top }),
100
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: import_index.default.container, children: [
101
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: import_index.default.group, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: import_index.default.name, children: name }) }),
102
+ version && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: import_index.default.info, children: [
103
+ exposes.length > 0 ? /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: import_index.default["expose-container"], children: [
104
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: import_index.default.type, children: t("graphItem.expose") }),
105
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { children: exposes.map((expose, index) => {
106
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: import_index.default.item, children: expose }, index);
107
+ }) })
108
+ ] }) : null,
109
+ shareds.length > 0 ? /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: import_index.default["expose-container"], children: [
110
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: import_index.default.type, children: t("graphItem.shared") }),
111
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { children: shareds.map((shared, index) => {
112
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: import_index.default.item, children: shared }, index);
113
+ }) })
114
+ ] }) : null,
115
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: import_index.default.message, children: [
116
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: import_index.default.type, children: isEntryType ? t("graphItem.entry") : t("graphItem.version") }),
117
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: import_index.default.item, children: version })
118
+ ] })
119
+ ] })
120
+ ] }),
121
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_reactflow.Handle, { type: "source", position: import_reactflow.Position.Bottom, id: "source" })
122
+ ] });
123
+ };
124
+ var DependencyGraphItem_default = GraphItem;
@@ -0,0 +1,24 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __export = (target, all) => {
6
+ for (var name in all)
7
+ __defProp(target, name, { get: all[name], enumerable: true });
8
+ };
9
+ var __copyProps = (to, from, except, desc) => {
10
+ if (from && typeof from === "object" || typeof from === "function") {
11
+ for (let key of __getOwnPropNames(from))
12
+ if (!__hasOwnProp.call(to, key) && key !== except)
13
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
+ }
15
+ return to;
16
+ };
17
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
+ var index_module_exports = {};
19
+ __export(index_module_exports, {
20
+ default: () => index_module_default
21
+ });
22
+ module.exports = __toCommonJS(index_module_exports);
23
+ var import_index_module = require("./index_module.css");
24
+ var index_module_default = { "Wrapper": "Wrapper_d8079", "container": "container_d8079", "group": "group_d8079", "name": "name_d8079", "info": "info_d8079", "expose-container": "expose-container_d8079", "type": "type_d8079", "item": "item_d8079", "message": "message_d8079" };
@@ -0,0 +1,95 @@
1
+ .Wrapper_d8079 {
2
+ display: flex;
3
+ width: 320px;
4
+ border-radius: 18px;
5
+ border: 1px solid var(--color-border-1, rgba(96, 165, 250, 0.3));
6
+ overflow: hidden;
7
+ box-shadow: 0 18px 32px rgba(8, 11, 25, 0.35);
8
+ background: linear-gradient(140deg, var(--mf-accent, rgba(243, 244, 246, 0.9)) 0%, rgba(229, 231, 235, 0.7) 45%, rgba(255, 255, 255, 0.95) 100%), var(--color-bg-2, rgba(255, 255, 255, 0.9));
9
+ color: var(--color-text-1, #1f2937);
10
+ backdrop-filter: blur(4px);
11
+ }
12
+ .Wrapper_d8079 .react-flow__handle {
13
+ width: 10px;
14
+ height: 10px;
15
+ border-radius: 50%;
16
+ border: 2px solid rgba(96, 165, 250, 0.3);
17
+ background: rgba(243, 244, 246, 0.9);
18
+ box-shadow: 0 0 0 4px rgba(96, 165, 250, 0.2);
19
+ }
20
+ .Wrapper_d8079 .container_d8079 {
21
+ display: flex;
22
+ flex-direction: column;
23
+ width: 100%;
24
+ padding-bottom: 8px;
25
+ }
26
+ .Wrapper_d8079 .group_d8079 {
27
+ display: flex;
28
+ align-items: center;
29
+ justify-content: center;
30
+ padding: 12px;
31
+ background: var(--mf-accent, rgba(243, 244, 246, 0.9));
32
+ }
33
+ .Wrapper_d8079 .name_d8079 {
34
+ font-size: 15px;
35
+ font-weight: 600;
36
+ letter-spacing: 0.02em;
37
+ color: white;
38
+ }
39
+ .Wrapper_d8079 .info_d8079 {
40
+ display: flex;
41
+ flex-direction: column;
42
+ gap: 10px;
43
+ margin: 0 12px;
44
+ padding: 12px;
45
+ border-radius: 14px;
46
+ background: rgba(243, 244, 246, 0.4);
47
+ border: 1px solid rgba(96, 165, 250, 0.3);
48
+ font-size: 11px;
49
+ }
50
+ .Wrapper_d8079 .expose-container_d8079 {
51
+ display: flex;
52
+ flex-direction: column;
53
+ gap: 6px;
54
+ }
55
+ .Wrapper_d8079 .expose-container_d8079 div {
56
+ display: flex;
57
+ flex-wrap: wrap;
58
+ gap: 6px;
59
+ }
60
+ .Wrapper_d8079 .type_d8079 {
61
+ font-size: 12px;
62
+ font-weight: 600;
63
+ text-transform: uppercase;
64
+ letter-spacing: 0.04em;
65
+ color: var(--color-text-2, #4b5563);
66
+ }
67
+ .Wrapper_d8079 .item_d8079 {
68
+ display: inline-flex;
69
+ align-items: center;
70
+ padding: 4px 8px;
71
+ border-radius: 999px;
72
+ background: rgba(243, 244, 246, 0.6);
73
+ color: var(--color-text-1, #1f2937);
74
+ font-size: 10px;
75
+ font-weight: 500;
76
+ margin-right: 6px;
77
+ max-width: 100%;
78
+ white-space: nowrap;
79
+ text-overflow: ellipsis;
80
+ overflow: hidden;
81
+ box-shadow: 0 4px 10px rgba(8, 11, 25, 0.45);
82
+ }
83
+ .Wrapper_d8079 .message_d8079 {
84
+ display: flex;
85
+ align-items: center;
86
+ gap: 6px;
87
+ font-size: 11px;
88
+ color: var(--color-text-2, #4b5563);
89
+ }
90
+ .Wrapper_d8079 .message_d8079 .item_d8079 {
91
+ margin-right: 0;
92
+ padding: 4px 10px;
93
+ background: rgba(243, 244, 246, 0.6);
94
+ color: var(--color-text-1, #1f2937);
95
+ }
@@ -0,0 +1,372 @@
1
+ var __create = Object.create;
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __getProtoOf = Object.getPrototypeOf;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __export = (target, all) => {
8
+ for (var name in all)
9
+ __defProp(target, name, { get: all[name], enumerable: true });
10
+ };
11
+ var __copyProps = (to, from, except, desc) => {
12
+ if (from && typeof from === "object" || typeof from === "function") {
13
+ for (let key of __getOwnPropNames(from))
14
+ if (!__hasOwnProp.call(to, key) && key !== except)
15
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
16
+ }
17
+ return to;
18
+ };
19
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
20
+ // If the importer is in node compatibility mode or this is not an ESM
21
+ // file that has been converted to a CommonJS file using a Babel-
22
+ // compatible transform (i.e. "__esModule" has not been set), then set
23
+ // "default" to the CommonJS "module.exports" for node compatibility.
24
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
25
+ mod
26
+ ));
27
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
28
+ var __async = (__this, __arguments, generator) => {
29
+ return new Promise((resolve, reject) => {
30
+ var fulfilled = (value) => {
31
+ try {
32
+ step(generator.next(value));
33
+ } catch (e) {
34
+ reject(e);
35
+ }
36
+ };
37
+ var rejected = (value) => {
38
+ try {
39
+ step(generator.throw(value));
40
+ } catch (e) {
41
+ reject(e);
42
+ }
43
+ };
44
+ var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
45
+ step((generator = generator.apply(__this, __arguments)).next());
46
+ });
47
+ };
48
+ var Form_exports = {};
49
+ __export(Form_exports, {
50
+ default: () => Form_default
51
+ });
52
+ module.exports = __toCommonJS(Form_exports);
53
+ var import_jsx_runtime = require("react/jsx-runtime");
54
+ var import_react = require("react");
55
+ var import_web_react = require("@arco-design/web-react");
56
+ var import_react_i18next = require("react-i18next");
57
+ var import_icon = require("@arco-design/web-react/icon");
58
+ var import_constant = require("../../template/constant");
59
+ var import_utils = require("../../utils");
60
+ var import_index = __toESM(require("./index.module"));
61
+ const FormItem = import_web_react.Form.Item;
62
+ const FormList = import_web_react.Form.List;
63
+ const { Option } = import_web_react.Select;
64
+ const FormComponent = (props) => {
65
+ const {
66
+ form,
67
+ condition,
68
+ formStatus,
69
+ setFormStatus,
70
+ validateForm,
71
+ enableHMR,
72
+ onHMRChange,
73
+ versionList,
74
+ setVersionList,
75
+ getVersion,
76
+ customValueValidate,
77
+ enableClip,
78
+ onClipChange
79
+ } = props;
80
+ const { t } = (0, import_react_i18next.useTranslation)();
81
+ const federation = window.__FEDERATION__ || {
82
+ moduleInfo: {},
83
+ originModuleInfo: {}
84
+ };
85
+ const { moduleInfo } = federation;
86
+ let { producer } = (0, import_utils.separateType)(moduleInfo);
87
+ const filterDupMap = /* @__PURE__ */ new Map();
88
+ producer = producer.filter((tItem) => {
89
+ const [typeOrName, name] = tItem.split(":");
90
+ const marked = filterDupMap.get(name || typeOrName);
91
+ filterDupMap.set(name || typeOrName, true);
92
+ return !marked;
93
+ });
94
+ const formatProducer = producer.map((id) => {
95
+ const hasType = id.includes(":");
96
+ if (hasType) {
97
+ return {
98
+ label: id.split(":")[1],
99
+ value: id
100
+ };
101
+ } else {
102
+ return {
103
+ label: id,
104
+ value: id
105
+ };
106
+ }
107
+ });
108
+ (0, import_react.useEffect)(() => {
109
+ producer.forEach((target) => __async(void 0, null, function* () {
110
+ const version = yield getVersion == null ? void 0 : getVersion(target);
111
+ const list = [...versionList || []];
112
+ if (version) {
113
+ list.push(version);
114
+ }
115
+ setVersionList == null ? void 0 : setVersionList(list);
116
+ }));
117
+ }, []);
118
+ const getCheckStatus = (index) => {
119
+ const formData = form.getFieldsValue();
120
+ return formData[import_constant.proxyFormField][index].checked;
121
+ };
122
+ const validateKey = (key, callback, index) => {
123
+ const status = getCheckStatus(index);
124
+ if (!status) {
125
+ return callback();
126
+ }
127
+ const statusSet = [...formStatus];
128
+ if (!(0, import_utils.isObject)(statusSet[index])) {
129
+ statusSet[index] = {
130
+ keyStatus: false,
131
+ valueStatus: false
132
+ };
133
+ }
134
+ if (key) {
135
+ statusSet[index].keyStatus = true;
136
+ setTimeout(() => {
137
+ setFormStatus(statusSet);
138
+ callback();
139
+ }, 0);
140
+ return;
141
+ }
142
+ statusSet[index].keyStatus = false;
143
+ setTimeout(() => {
144
+ setFormStatus(statusSet);
145
+ }, 0);
146
+ return callback(t("form.validation.moduleNameRequired"));
147
+ };
148
+ const validateValue = (value, callback, index) => {
149
+ const status = getCheckStatus(index);
150
+ if (!status) {
151
+ return callback();
152
+ }
153
+ const statusSet = [...formStatus];
154
+ if (!(0, import_utils.isObject)(statusSet[index])) {
155
+ statusSet[index] = {
156
+ keyStatus: false,
157
+ valueStatus: false
158
+ };
159
+ }
160
+ if ((0, import_utils.validateCustom)(value) || (0, import_utils.validateSemver)(value) || (0, import_utils.validatePort)(value) || (customValueValidate == null ? void 0 : customValueValidate(value))) {
161
+ statusSet[index].valueStatus = true;
162
+ setTimeout(() => {
163
+ setFormStatus(statusSet);
164
+ callback();
165
+ }, 0);
166
+ return;
167
+ }
168
+ statusSet[index].valueStatus = false;
169
+ setTimeout(() => {
170
+ setFormStatus(statusSet);
171
+ }, 0);
172
+ return callback(t("form.validation.moduleInfoInvalid"));
173
+ };
174
+ const onAdd = (add) => {
175
+ add(import_constant.defaultDataItem);
176
+ setVersionList == null ? void 0 : setVersionList([...versionList || [], []]);
177
+ validateForm();
178
+ };
179
+ const onRemove = (remove, index) => {
180
+ if (Array.isArray(versionList)) {
181
+ versionList.splice(index, 1);
182
+ setVersionList == null ? void 0 : setVersionList(versionList);
183
+ }
184
+ remove(index);
185
+ };
186
+ const hmrChange = (on) => {
187
+ onHMRChange(on);
188
+ };
189
+ const handleSwitchChange = (on) => {
190
+ onClipChange(on);
191
+ };
192
+ const onKeyChange = (key, index) => __async(void 0, null, function* () {
193
+ const version = yield getVersion == null ? void 0 : getVersion(key);
194
+ if (version) {
195
+ const list = [...versionList || []];
196
+ list.splice(index, 1, version);
197
+ setVersionList == null ? void 0 : setVersionList(list);
198
+ }
199
+ });
200
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(FormList, { field: import_constant.proxyFormField, children: (fields, { add, remove }) => /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: import_index.default.wrapper, children: [
201
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: import_index.default.sectionHeader, children: [
202
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: import_index.default.heading, children: [
203
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: import_index.default.titleRow, children: [
204
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_web_react.Tooltip, { content: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { children: t("form.tooltip.proxyExample") }), children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_icon.IconInfoCircle, {}) }),
205
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: import_index.default.title, children: t("form.title") }),
206
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
207
+ "span",
208
+ {
209
+ className: import_index.default.statusMessage,
210
+ style: { marginLeft: 8 },
211
+ children: [
212
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_web_react.Badge, { color: condition.color, className: import_index.default.badge }),
213
+ condition.message
214
+ ]
215
+ }
216
+ )
217
+ ] }),
218
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: import_index.default.subtitle, children: t("form.subtitle") })
219
+ ] }),
220
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: import_index.default.headerActions, children: [
221
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("span", { className: import_index.default.hmrArea, children: [
222
+ props.headerSlot,
223
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
224
+ import_web_react.Switch,
225
+ {
226
+ checked: enableClip,
227
+ checkedText: t("form.clip.enable"),
228
+ uncheckedText: t("form.clip.disable"),
229
+ onChange: handleSwitchChange,
230
+ className: import_index.default.switch
231
+ }
232
+ ),
233
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_web_react.Tooltip, { content: t("form.clip.tooltip"), children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
234
+ import_icon.IconQuestionCircle,
235
+ {
236
+ style: { marginLeft: 5, cursor: "pointer" }
237
+ }
238
+ ) }),
239
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: import_index.default.divider }),
240
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
241
+ import_web_react.Switch,
242
+ {
243
+ checked: enableHMR === "enable",
244
+ checkedText: t("form.hmr.enable"),
245
+ uncheckedText: t("form.hmr.disable"),
246
+ onChange: hmrChange,
247
+ className: import_index.default.switch
248
+ }
249
+ )
250
+ ] }),
251
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
252
+ import_web_react.Button,
253
+ {
254
+ icon: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_icon.IconPlus, {}),
255
+ shape: "circle",
256
+ className: import_index.default.add,
257
+ onClick: () => onAdd(add),
258
+ "data-set-e2e": "e2eAdd"
259
+ }
260
+ )
261
+ ] })
262
+ ] }),
263
+ fields.length ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: import_index.default.rules, children: fields.map((item, index) => {
264
+ var _a, _b;
265
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: import_index.default.ruleCard, children: [
266
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: import_index.default.ruleHeader, children: [
267
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
268
+ FormItem,
269
+ {
270
+ field: `${item.field}.checked`,
271
+ triggerPropName: "checked",
272
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_web_react.Checkbox, { className: import_index.default.toggle })
273
+ }
274
+ ),
275
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
276
+ import_web_react.Button,
277
+ {
278
+ icon: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_icon.IconDelete, {}),
279
+ shape: "circle",
280
+ status: "danger",
281
+ className: import_index.default.delete,
282
+ "data-set-e2e": "e2eDelete",
283
+ onClick: () => onRemove(remove, index)
284
+ }
285
+ )
286
+ ] }),
287
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: import_index.default.inputs, "data-set-e2e": "e2eProxyItem", children: [
288
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
289
+ FormItem,
290
+ {
291
+ field: `${item.field}.key`,
292
+ rules: [
293
+ {
294
+ validator: (value, cb) => {
295
+ const isValid = Boolean(value);
296
+ if (isValid) {
297
+ cb();
298
+ validateKey(value, () => {
299
+ }, index);
300
+ } else {
301
+ cb(t("form.validation.moduleNameRequired"));
302
+ validateKey(value, () => {
303
+ }, index);
304
+ }
305
+ }
306
+ }
307
+ ],
308
+ className: import_index.default.field,
309
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
310
+ import_web_react.Select,
311
+ {
312
+ "data-set-e2e": "e2eProxyKey",
313
+ placeholder: t("form.fields.moduleName.placeholder"),
314
+ onChange: (key) => onKeyChange(key, index),
315
+ allowClear: true,
316
+ showSearch: true,
317
+ dropdownMenuClassName: import_index.default.dropdown,
318
+ children: formatProducer.map((option) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Option, { value: option.value, children: option.label }, option.value))
319
+ }
320
+ )
321
+ }
322
+ ),
323
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
324
+ FormItem,
325
+ {
326
+ field: `${item.field}.value`,
327
+ rules: [
328
+ {
329
+ validator: (value, cb) => {
330
+ const isValid = (0, import_utils.validateCustom)(value) || (0, import_utils.validateSemver)(value) || (0, import_utils.validatePort)(value) || (customValueValidate == null ? void 0 : customValueValidate(value));
331
+ if (isValid) {
332
+ cb();
333
+ validateValue(value, () => {
334
+ }, index);
335
+ } else {
336
+ cb(t("form.validation.moduleInfoInvalid"));
337
+ validateValue(value, () => {
338
+ }, index);
339
+ }
340
+ }
341
+ }
342
+ ],
343
+ className: import_index.default.field,
344
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
345
+ import_web_react.Select,
346
+ {
347
+ "data-set-e2e": "e2eProxyValue",
348
+ placeholder: t(
349
+ "form.fields.customManifest.placeholder"
350
+ ),
351
+ allowClear: true,
352
+ showSearch: true,
353
+ allowCreate: true,
354
+ dropdownMenuClassName: import_index.default.dropdown,
355
+ 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))
356
+ }
357
+ )
358
+ }
359
+ )
360
+ ] })
361
+ ] }, item.field);
362
+ }) }) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: import_index.default.emptyWrapper, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
363
+ import_web_react.Empty,
364
+ {
365
+ description: t("form.empty.description"),
366
+ className: import_index.default.empty
367
+ }
368
+ ) }),
369
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: import_index.default.footerHint, children: t("form.footer.hint") })
370
+ ] }) });
371
+ };
372
+ var Form_default = FormComponent;
@@ -0,0 +1,24 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __export = (target, all) => {
6
+ for (var name in all)
7
+ __defProp(target, name, { get: all[name], enumerable: true });
8
+ };
9
+ var __copyProps = (to, from, except, desc) => {
10
+ if (from && typeof from === "object" || typeof from === "function") {
11
+ for (let key of __getOwnPropNames(from))
12
+ if (!__hasOwnProp.call(to, key) && key !== except)
13
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
+ }
15
+ return to;
16
+ };
17
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
+ var index_module_exports = {};
19
+ __export(index_module_exports, {
20
+ default: () => index_module_default
21
+ });
22
+ module.exports = __toCommonJS(index_module_exports);
23
+ var import_index_module = require("./index_module.css");
24
+ var index_module_default = { "wrapper": "wrapper_20b79", "sectionHeader": "sectionHeader_20b79", "heading": "heading_20b79", "titleRow": "titleRow_20b79", "title": "title_20b79", "subtitle": "subtitle_20b79", "headerActions": "headerActions_20b79", "badge": "badge_20b79", "statusMessage": "statusMessage_20b79", "divider": "divider_20b79", "hmrArea": "hmrArea_20b79", "switch": "switch_20b79", "rules": "rules_20b79", "ruleCard": "ruleCard_20b79", "ruleHeader": "ruleHeader_20b79", "toggle": "toggle_20b79", "inputs": "inputs_20b79", "field": "field_20b79", "dropdown": "dropdown_20b79", "delete": "delete_20b79", "emptyWrapper": "emptyWrapper_20b79", "empty": "empty_20b79", "footerHint": "footerHint_20b79" };