@module-federation/devtools 0.0.0-docs-remove-invalid-lark-link-20251205062649

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (98) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +8 -0
  3. package/dist/es/App.js +42 -0
  4. package/dist/es/App.module.js +5 -0
  5. package/dist/es/App_module.css +19 -0
  6. package/dist/es/component/Form/index.js +288 -0
  7. package/dist/es/component/Form/index.module.js +5 -0
  8. package/dist/es/component/Form/index_module.css +47 -0
  9. package/dist/es/component/Graph/index.js +127 -0
  10. package/dist/es/component/Graph/index.module.js +5 -0
  11. package/dist/es/component/Graph/index_module.css +12 -0
  12. package/dist/es/component/GraphItem/index.js +73 -0
  13. package/dist/es/component/GraphItem/index.module.js +5 -0
  14. package/dist/es/component/GraphItem/index_module.css +61 -0
  15. package/dist/es/component/Layout/index.js +218 -0
  16. package/dist/es/component/Layout/index.module.js +5 -0
  17. package/dist/es/component/Layout/index_module.css +48 -0
  18. package/dist/es/init.js +8 -0
  19. package/dist/es/template/constant.js +67 -0
  20. package/dist/es/template/index.js +1 -0
  21. package/dist/es/utils/chrome/fast-refresh.js +218 -0
  22. package/dist/es/utils/chrome/index.js +211 -0
  23. package/dist/es/utils/chrome/post-message-init.js +5 -0
  24. package/dist/es/utils/chrome/post-message-listener.js +20 -0
  25. package/dist/es/utils/chrome/post-message-start.js +8 -0
  26. package/dist/es/utils/chrome/post-message.js +62 -0
  27. package/dist/es/utils/chrome/snapshot-plugin.js +36 -0
  28. package/dist/es/utils/chrome/storage.js +45 -0
  29. package/dist/es/utils/data/index.js +79 -0
  30. package/dist/es/utils/data/snapshot.js +82 -0
  31. package/dist/es/utils/index.js +4 -0
  32. package/dist/es/utils/sdk/graph.js +155 -0
  33. package/dist/es/utils/sdk/index.js +61 -0
  34. package/dist/es/utils/types/common.js +0 -0
  35. package/dist/es/utils/types/index.js +1 -0
  36. package/dist/es/worker/index.js +1 -0
  37. package/dist/lib/App.js +72 -0
  38. package/dist/lib/App.module.js +25 -0
  39. package/dist/lib/App_module.css +19 -0
  40. package/dist/lib/component/Form/index.js +299 -0
  41. package/dist/lib/component/Form/index.module.js +25 -0
  42. package/dist/lib/component/Form/index_module.css +47 -0
  43. package/dist/lib/component/Graph/index.js +149 -0
  44. package/dist/lib/component/Graph/index.module.js +25 -0
  45. package/dist/lib/component/Graph/index_module.css +12 -0
  46. package/dist/lib/component/GraphItem/index.js +103 -0
  47. package/dist/lib/component/GraphItem/index.module.js +25 -0
  48. package/dist/lib/component/GraphItem/index_module.css +61 -0
  49. package/dist/lib/component/Layout/index.js +224 -0
  50. package/dist/lib/component/Layout/index.module.js +25 -0
  51. package/dist/lib/component/Layout/index_module.css +48 -0
  52. package/dist/lib/init.js +9 -0
  53. package/dist/lib/template/constant.js +98 -0
  54. package/dist/lib/template/index.js +22 -0
  55. package/dist/lib/utils/chrome/fast-refresh.js +215 -0
  56. package/dist/lib/utils/chrome/index.js +245 -0
  57. package/dist/lib/utils/chrome/post-message-init.js +6 -0
  58. package/dist/lib/utils/chrome/post-message-listener.js +21 -0
  59. package/dist/lib/utils/chrome/post-message-start.js +9 -0
  60. package/dist/lib/utils/chrome/post-message.js +83 -0
  61. package/dist/lib/utils/chrome/snapshot-plugin.js +59 -0
  62. package/dist/lib/utils/chrome/storage.js +67 -0
  63. package/dist/lib/utils/data/index.js +106 -0
  64. package/dist/lib/utils/data/snapshot.js +107 -0
  65. package/dist/lib/utils/index.js +28 -0
  66. package/dist/lib/utils/sdk/graph.js +179 -0
  67. package/dist/lib/utils/sdk/index.js +95 -0
  68. package/dist/lib/utils/types/common.js +16 -0
  69. package/dist/lib/utils/types/index.js +22 -0
  70. package/dist/lib/worker/index.js +2 -0
  71. package/dist/types/src/App.d.ts +6 -0
  72. package/dist/types/src/component/Form/index.d.ts +19 -0
  73. package/dist/types/src/component/Graph/index.d.ts +7 -0
  74. package/dist/types/src/component/GraphItem/index.d.ts +10 -0
  75. package/dist/types/src/component/Layout/index.d.ts +16 -0
  76. package/dist/types/src/index.d.ts +1 -0
  77. package/dist/types/src/init.d.ts +13 -0
  78. package/dist/types/src/template/constant.d.ts +24 -0
  79. package/dist/types/src/template/index.d.ts +1 -0
  80. package/dist/types/src/utils/chrome/fast-refresh.d.ts +1 -0
  81. package/dist/types/src/utils/chrome/index.d.ts +16 -0
  82. package/dist/types/src/utils/chrome/post-message-init.d.ts +1 -0
  83. package/dist/types/src/utils/chrome/post-message-listener.d.ts +0 -0
  84. package/dist/types/src/utils/chrome/post-message-start.d.ts +1 -0
  85. package/dist/types/src/utils/chrome/post-message.d.ts +1 -0
  86. package/dist/types/src/utils/chrome/snapshot-plugin.d.ts +4 -0
  87. package/dist/types/src/utils/chrome/storage.d.ts +4 -0
  88. package/dist/types/src/utils/data/index.d.ts +11 -0
  89. package/dist/types/src/utils/data/snapshot.d.ts +3 -0
  90. package/dist/types/src/utils/index.d.ts +4 -0
  91. package/dist/types/src/utils/sdk/graph.d.ts +45 -0
  92. package/dist/types/src/utils/sdk/index.d.ts +10 -0
  93. package/dist/types/src/utils/types/common.d.ts +18 -0
  94. package/dist/types/src/utils/types/index.d.ts +1 -0
  95. package/dist/types/src/worker/index.d.ts +0 -0
  96. package/dist/types/stories/index.stories.d.ts +9 -0
  97. package/install-deps.bash +19 -0
  98. package/package.json +87 -0
@@ -0,0 +1,48 @@
1
+ .select_084ab {
2
+ margin-top: 1vh;
3
+ }
4
+
5
+ .card_084ab {
6
+ display: flex;
7
+ height: 4vh;
8
+ align-items: center;
9
+ }
10
+ .card_084ab .appName_084ab {
11
+ margin: 1vh 0;
12
+ }
13
+
14
+ .tagContainer_084ab {
15
+ display: flex;
16
+ align-items: center;
17
+ margin-bottom: 1vh;
18
+ color: rgb(78, 89, 105);
19
+ }
20
+ .tagContainer_084ab .tag_084ab {
21
+ margin-left: 1vw;
22
+ }
23
+
24
+ .header_084ab {
25
+ display: flex;
26
+ align-items: center;
27
+ margin: 1vh 0;
28
+ }
29
+ .header_084ab .add_084ab {
30
+ margin: 0 0.5vw;
31
+ }
32
+ .header_084ab .title_084ab {
33
+ margin: 0 0.5vw;
34
+ }
35
+ .header_084ab .status_084ab {
36
+ display: flex;
37
+ flex: 1 1;
38
+ justify-content: flex-end;
39
+ align-items: center;
40
+ }
41
+ .header_084ab .status_084ab .switch_084ab {
42
+ margin-left: 0.5vw;
43
+ }
44
+ .header_084ab .badge_084ab {
45
+ display: flex;
46
+ transform: scale(1.6);
47
+ margin: 0 0.6vw;
48
+ }
@@ -0,0 +1,9 @@
1
+ "use strict";
2
+ if (process.env.NODE_ENV === "development") {
3
+ const createProxy = () => new Proxy(() => Promise.resolve({}), {
4
+ get: () => {
5
+ return createProxy();
6
+ }
7
+ });
8
+ window.chrome = createProxy();
9
+ }
@@ -0,0 +1,98 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __getOwnPropSymbols = Object.getOwnPropertySymbols;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __propIsEnum = Object.prototype.propertyIsEnumerable;
8
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
9
+ var __spreadValues = (a, b) => {
10
+ for (var prop in b || (b = {}))
11
+ if (__hasOwnProp.call(b, prop))
12
+ __defNormalProp(a, prop, b[prop]);
13
+ if (__getOwnPropSymbols)
14
+ for (var prop of __getOwnPropSymbols(b)) {
15
+ if (__propIsEnum.call(b, prop))
16
+ __defNormalProp(a, prop, b[prop]);
17
+ }
18
+ return a;
19
+ };
20
+ var __export = (target, all) => {
21
+ for (var name in all)
22
+ __defProp(target, name, { get: all[name], enumerable: true });
23
+ };
24
+ var __copyProps = (to, from, except, desc) => {
25
+ if (from && typeof from === "object" || typeof from === "function") {
26
+ for (let key of __getOwnPropNames(from))
27
+ if (!__hasOwnProp.call(to, key) && key !== except)
28
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
29
+ }
30
+ return to;
31
+ };
32
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
33
+ var constant_exports = {};
34
+ __export(constant_exports, {
35
+ BROWSER_ENV_KEY: () => BROWSER_ENV_KEY,
36
+ ENABLEHMR: () => ENABLEHMR,
37
+ FormID: () => FormID,
38
+ __EAGER_SHARE__: () => __EAGER_SHARE__,
39
+ __ENABLE_FAST_REFRESH__: () => __ENABLE_FAST_REFRESH__,
40
+ __FEDERATION_DEVTOOLS__: () => __FEDERATION_DEVTOOLS__,
41
+ defaultDataItem: () => defaultDataItem,
42
+ defaultModuleData: () => defaultModuleData,
43
+ proxyFormField: () => proxyFormField,
44
+ statusInfo: () => statusInfo
45
+ });
46
+ module.exports = __toCommonJS(constant_exports);
47
+ const FormID = "FormID";
48
+ const ENABLEHMR = "enableHMR";
49
+ const proxyFormField = "proxyFormField";
50
+ const defaultDataItem = {
51
+ key: "",
52
+ value: "",
53
+ checked: true
54
+ };
55
+ const defaultModuleData = {
56
+ proxyFormField: [
57
+ __spreadValues({}, defaultDataItem)
58
+ ]
59
+ };
60
+ const statusInfo = {
61
+ noProxy: {
62
+ status: "noProxy",
63
+ message: "Modules are not currently proxied",
64
+ color: "#698cee"
65
+ },
66
+ processing: {
67
+ status: "processing",
68
+ message: "Obtaining remote module information",
69
+ color: "#FF7D00"
70
+ },
71
+ success: {
72
+ status: "success",
73
+ message: "The proxy configuration has taken effect and the corresponding page has been automatically refreshed.",
74
+ color: "#50b042"
75
+ },
76
+ error: {
77
+ status: "error",
78
+ message: "Calculating Snapshot failed, please confirm whether the package information is correct",
79
+ color: "#F53F3F"
80
+ }
81
+ };
82
+ const __ENABLE_FAST_REFRESH__ = "enableFastRefresh";
83
+ const __EAGER_SHARE__ = "eagerShare";
84
+ const BROWSER_ENV_KEY = "MF_ENV";
85
+ const __FEDERATION_DEVTOOLS__ = "__MF_DEVTOOLS__";
86
+ // Annotate the CommonJS export names for ESM import in node:
87
+ 0 && (module.exports = {
88
+ BROWSER_ENV_KEY,
89
+ ENABLEHMR,
90
+ FormID,
91
+ __EAGER_SHARE__,
92
+ __ENABLE_FAST_REFRESH__,
93
+ __FEDERATION_DEVTOOLS__,
94
+ defaultDataItem,
95
+ defaultModuleData,
96
+ proxyFormField,
97
+ statusInfo
98
+ });
@@ -0,0 +1,22 @@
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 __copyProps = (to, from, except, desc) => {
7
+ if (from && typeof from === "object" || typeof from === "function") {
8
+ for (let key of __getOwnPropNames(from))
9
+ if (!__hasOwnProp.call(to, key) && key !== except)
10
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
11
+ }
12
+ return to;
13
+ };
14
+ var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
15
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
16
+ var template_exports = {};
17
+ module.exports = __toCommonJS(template_exports);
18
+ __reExport(template_exports, require("./constant"), module.exports);
19
+ // Annotate the CommonJS export names for ESM import in node:
20
+ 0 && (module.exports = {
21
+ ...require("./constant")
22
+ });
@@ -0,0 +1,215 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropSymbols = Object.getOwnPropertySymbols;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __propIsEnum = Object.prototype.propertyIsEnumerable;
6
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
7
+ var __spreadValues = (a, b) => {
8
+ for (var prop in b || (b = {}))
9
+ if (__hasOwnProp.call(b, prop))
10
+ __defNormalProp(a, prop, b[prop]);
11
+ if (__getOwnPropSymbols)
12
+ for (var prop of __getOwnPropSymbols(b)) {
13
+ if (__propIsEnum.call(b, prop))
14
+ __defNormalProp(a, prop, b[prop]);
15
+ }
16
+ return a;
17
+ };
18
+ var __objRest = (source, exclude) => {
19
+ var target = {};
20
+ for (var prop in source)
21
+ if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
22
+ target[prop] = source[prop];
23
+ if (source != null && __getOwnPropSymbols)
24
+ for (var prop of __getOwnPropSymbols(source)) {
25
+ if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
26
+ target[prop] = source[prop];
27
+ }
28
+ return target;
29
+ };
30
+ var __async = (__this, __arguments, generator) => {
31
+ return new Promise((resolve, reject) => {
32
+ var fulfilled = (value) => {
33
+ try {
34
+ step(generator.next(value));
35
+ } catch (e) {
36
+ reject(e);
37
+ }
38
+ };
39
+ var rejected = (value) => {
40
+ try {
41
+ step(generator.throw(value));
42
+ } catch (e) {
43
+ reject(e);
44
+ }
45
+ };
46
+ var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
47
+ step((generator = generator.apply(__this, __arguments)).next());
48
+ });
49
+ };
50
+ var import_sdk = require("@module-federation/sdk");
51
+ var import__ = require("../index");
52
+ var import_sdk2 = require("../sdk");
53
+ var import_constant = require("../../template/constant");
54
+ var _a;
55
+ const SUPPORT_PKGS = ["react", "react-dom"];
56
+ const fetchAndExecuteUmdSync = (url) => {
57
+ try {
58
+ const response = new XMLHttpRequest();
59
+ response.open("GET", url, false);
60
+ response.overrideMimeType("text/plain");
61
+ response.send();
62
+ if (response.status === 200) {
63
+ const scriptContent = response.responseText;
64
+ const moduleFunction = new Function(scriptContent);
65
+ return moduleFunction(window);
66
+ } else {
67
+ throw new Error(
68
+ `Failed to load module from ${url}: HTTP ${response.status}`
69
+ );
70
+ }
71
+ } catch (error) {
72
+ throw new Error(`Failed to fetch module from ${url}: ${error.message}`);
73
+ }
74
+ };
75
+ const getDevtoolsMessage = () => {
76
+ const devtoolsMessageStr = localStorage.getItem(import_constant.__FEDERATION_DEVTOOLS__);
77
+ if (devtoolsMessageStr) {
78
+ try {
79
+ return JSON.parse(devtoolsMessageStr);
80
+ } catch (e) {
81
+ console.debug("Fast Refresh Plugin Error: ", e);
82
+ }
83
+ }
84
+ return null;
85
+ };
86
+ const devtoolsMessage = getDevtoolsMessage();
87
+ if ((devtoolsMessage == null ? void 0 : devtoolsMessage[import_constant.__ENABLE_FAST_REFRESH__]) && (devtoolsMessage == null ? void 0 : devtoolsMessage[import_constant.__EAGER_SHARE__])) {
88
+ const [_name, version] = devtoolsMessage[import_constant.__EAGER_SHARE__];
89
+ fetchAndExecuteUmdSync((0, import__.getUnpkgUrl)("react", version));
90
+ fetchAndExecuteUmdSync((0, import__.getUnpkgUrl)("react-dom", version));
91
+ }
92
+ const fastRefreshPlugin = () => {
93
+ return {
94
+ name: "mf-fast-refresh-plugin",
95
+ beforeInit(_a2) {
96
+ var _b = _a2, { userOptions } = _b, args = __objRest(_b, ["userOptions"]);
97
+ const shareInfo = userOptions.shared;
98
+ const twinsShareInfo = args.shareInfo;
99
+ let enableFastRefresh = false;
100
+ let devtoolsMessage2 = {};
101
+ const devtoolsMessageStr = localStorage.getItem(import_constant.__FEDERATION_DEVTOOLS__);
102
+ if (devtoolsMessageStr) {
103
+ try {
104
+ devtoolsMessage2 = JSON.parse(devtoolsMessageStr);
105
+ enableFastRefresh = devtoolsMessage2 == null ? void 0 : devtoolsMessage2[import_constant.__ENABLE_FAST_REFRESH__];
106
+ } catch (e) {
107
+ console.debug("Fast Refresh Plugin Error: ", e);
108
+ }
109
+ }
110
+ if (!enableFastRefresh) {
111
+ return __spreadValues({
112
+ userOptions
113
+ }, args);
114
+ }
115
+ if (shareInfo && (0, import__.isObject)(shareInfo)) {
116
+ let orderResolve;
117
+ const orderPromise = new Promise((resolve) => {
118
+ orderResolve = resolve;
119
+ });
120
+ Object.keys(shareInfo).forEach((share) => __async(this, null, function* () {
121
+ const sharedArr = Array.isArray(shareInfo[share]) ? shareInfo[share] : [shareInfo[share]];
122
+ let twinsSharedArr;
123
+ if (twinsShareInfo) {
124
+ twinsSharedArr = Array.isArray(twinsShareInfo[share]) ? twinsShareInfo[share] : [twinsShareInfo[share]];
125
+ }
126
+ sharedArr.forEach((shared, idx) => {
127
+ var _a3;
128
+ if (!SUPPORT_PKGS.includes(share)) {
129
+ return;
130
+ }
131
+ if ((_a3 = shared.shareConfig) == null ? void 0 : _a3.eager) {
132
+ if (!(devtoolsMessage2 == null ? void 0 : devtoolsMessage2[import_constant.__EAGER_SHARE__])) {
133
+ const eagerShare = [];
134
+ eagerShare.push(share, shared.version);
135
+ devtoolsMessage2[import_constant.__EAGER_SHARE__] = eagerShare;
136
+ localStorage.setItem(
137
+ import_constant.__FEDERATION_DEVTOOLS__,
138
+ JSON.stringify(devtoolsMessage2)
139
+ );
140
+ window.location.reload();
141
+ }
142
+ if (share === "react-dom") {
143
+ shared.lib = () => window.ReactDOM;
144
+ }
145
+ if (share === "react") {
146
+ shared.lib = () => window.React;
147
+ }
148
+ return;
149
+ }
150
+ let get;
151
+ if (share === "react") {
152
+ get = () => (0, import_sdk.loadScript)((0, import__.getUnpkgUrl)(share, shared.version), {
153
+ attrs: {
154
+ defer: false,
155
+ async: false,
156
+ "data-mf-injected": "true"
157
+ }
158
+ }).then(() => {
159
+ orderResolve();
160
+ });
161
+ }
162
+ if (share === "react-dom") {
163
+ get = () => orderPromise.then(
164
+ () => (0, import_sdk.loadScript)((0, import__.getUnpkgUrl)(share, shared.version), {
165
+ attrs: { defer: true, async: false }
166
+ })
167
+ );
168
+ }
169
+ if (typeof get === "function") {
170
+ if (share === "react") {
171
+ shared.get = () => __async(this, null, function* () {
172
+ if (!window.React) {
173
+ yield get();
174
+ console.warn(
175
+ "[Module Federation HMR]: You are using Module Federation Devtools to debug online host, it will cause your project load Dev mode React and ReactDOM. If not in this mode, please disable it in Module Federation Devtools"
176
+ );
177
+ }
178
+ shared.lib = () => window.React;
179
+ return () => window.React;
180
+ });
181
+ }
182
+ if (share === "react-dom") {
183
+ shared.get = () => __async(this, null, function* () {
184
+ if (!window.ReactDOM) {
185
+ yield get();
186
+ }
187
+ shared.lib = () => window.ReactDOM;
188
+ return () => window.ReactDOM;
189
+ });
190
+ }
191
+ if (twinsShareInfo) {
192
+ twinsSharedArr[idx].get = shared.get;
193
+ }
194
+ }
195
+ });
196
+ }));
197
+ return __spreadValues({
198
+ userOptions
199
+ }, args);
200
+ } else {
201
+ return __spreadValues({
202
+ userOptions
203
+ }, args);
204
+ }
205
+ }
206
+ };
207
+ };
208
+ if (!(window == null ? void 0 : window.__FEDERATION__)) {
209
+ (0, import_sdk2.definePropertyGlobalVal)(window, "__FEDERATION__", {});
210
+ (0, import_sdk2.definePropertyGlobalVal)(window, "__VMOK__", window.__FEDERATION__);
211
+ }
212
+ if (!(window == null ? void 0 : window.__FEDERATION__.__GLOBAL_PLUGIN__)) {
213
+ window.__FEDERATION__.__GLOBAL_PLUGIN__ = [];
214
+ }
215
+ (_a = window.__FEDERATION__.__GLOBAL_PLUGIN__) == null ? void 0 : _a.push(fastRefreshPlugin());
@@ -0,0 +1,245 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __defProps = Object.defineProperties;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
6
+ var __getOwnPropNames = Object.getOwnPropertyNames;
7
+ var __getOwnPropSymbols = Object.getOwnPropertySymbols;
8
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
9
+ var __propIsEnum = Object.prototype.propertyIsEnumerable;
10
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
11
+ var __spreadValues = (a, b) => {
12
+ for (var prop in b || (b = {}))
13
+ if (__hasOwnProp.call(b, prop))
14
+ __defNormalProp(a, prop, b[prop]);
15
+ if (__getOwnPropSymbols)
16
+ for (var prop of __getOwnPropSymbols(b)) {
17
+ if (__propIsEnum.call(b, prop))
18
+ __defNormalProp(a, prop, b[prop]);
19
+ }
20
+ return a;
21
+ };
22
+ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
23
+ var __export = (target, all) => {
24
+ for (var name in all)
25
+ __defProp(target, name, { get: all[name], enumerable: true });
26
+ };
27
+ var __copyProps = (to, from, except, desc) => {
28
+ if (from && typeof from === "object" || typeof from === "function") {
29
+ for (let key of __getOwnPropNames(from))
30
+ if (!__hasOwnProp.call(to, key) && key !== except)
31
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
32
+ }
33
+ return to;
34
+ };
35
+ var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
36
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
37
+ var __async = (__this, __arguments, generator) => {
38
+ return new Promise((resolve, reject) => {
39
+ var fulfilled = (value) => {
40
+ try {
41
+ step(generator.next(value));
42
+ } catch (e) {
43
+ reject(e);
44
+ }
45
+ };
46
+ var rejected = (value) => {
47
+ try {
48
+ step(generator.throw(value));
49
+ } catch (e) {
50
+ reject(e);
51
+ }
52
+ };
53
+ var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
54
+ step((generator = generator.apply(__this, __arguments)).next());
55
+ });
56
+ };
57
+ var chrome_exports = {};
58
+ __export(chrome_exports, {
59
+ TabInfo: () => TabInfo,
60
+ getCurrentTabId: () => getCurrentTabId,
61
+ getGlobalModuleInfo: () => getGlobalModuleInfo,
62
+ getInspectWindowTabId: () => getInspectWindowTabId,
63
+ getScope: () => getScope,
64
+ getTabs: () => getTabs,
65
+ getUrl: () => getUrl,
66
+ injectPostMessage: () => injectPostMessage,
67
+ injectScript: () => injectScript,
68
+ injectToast: () => injectToast,
69
+ setChromeStorage: () => setChromeStorage
70
+ });
71
+ module.exports = __toCommonJS(chrome_exports);
72
+ var import_constant = require("../../template/constant");
73
+ var import_sdk2 = require("../sdk");
74
+ __reExport(chrome_exports, require("./storage"), module.exports);
75
+ const sleep = (num) => {
76
+ return new Promise((resolve) => {
77
+ setTimeout(() => {
78
+ resolve();
79
+ }, num);
80
+ });
81
+ };
82
+ const injectPostMessage = (postMessageUrl) => {
83
+ const script = document.createElement("script");
84
+ script.src = postMessageUrl;
85
+ document.getElementsByTagName("head")[0].appendChild(script);
86
+ };
87
+ const TabInfo = {
88
+ currentTabId: 0
89
+ };
90
+ function getCurrentTabId() {
91
+ return TabInfo.currentTabId;
92
+ }
93
+ function getInspectWindowTabId() {
94
+ return new Promise((resolve, reject) => {
95
+ var _a;
96
+ if ((_a = chrome == null ? void 0 : chrome.devtools) == null ? void 0 : _a.inspectedWindow) {
97
+ if (chrome.isDevMode) {
98
+ resolve(0);
99
+ }
100
+ chrome.devtools.inspectedWindow.eval(
101
+ 'typeof window.__FEDERATION__ !== "undefined" || typeof window.__VMOK__ !== "undefined"',
102
+ function(info, error) {
103
+ const { tabId } = chrome.devtools.inspectedWindow;
104
+ getTabs().then((tabs) => {
105
+ const target = tabs.find(
106
+ (tab) => tab.id === tabId
107
+ );
108
+ window.targetTab = target;
109
+ });
110
+ console.log(
111
+ "chrome.devtools.inspectedWindow.tabId",
112
+ chrome.devtools.inspectedWindow.tabId
113
+ );
114
+ TabInfo.currentTabId = tabId;
115
+ resolve(tabId);
116
+ if (error) {
117
+ reject(error);
118
+ }
119
+ }
120
+ );
121
+ } else {
122
+ if (window.targetTab && window.targetTab.id) {
123
+ const tabId = window.targetTab.id;
124
+ TabInfo.currentTabId = tabId;
125
+ resolve(tabId);
126
+ } else {
127
+ throw Error(`can't get active tab`);
128
+ }
129
+ }
130
+ });
131
+ }
132
+ const getGlobalModuleInfo = (callback) => __async(void 0, null, function* () {
133
+ yield sleep(300);
134
+ chrome.runtime.onMessage.addListener(
135
+ (message) => {
136
+ const { origin, data } = message;
137
+ if (!data || (data == null ? void 0 : data.appInfos)) {
138
+ return;
139
+ }
140
+ if (!(window == null ? void 0 : window.__FEDERATION__)) {
141
+ (0, import_sdk2.definePropertyGlobalVal)(window, "__FEDERATION__", {});
142
+ (0, import_sdk2.definePropertyGlobalVal)(window, "__VMOK__", window.__FEDERATION__);
143
+ }
144
+ window.__FEDERATION__.originModuleInfo = JSON.parse(
145
+ JSON.stringify(data == null ? void 0 : data.moduleInfo)
146
+ );
147
+ if (data == null ? void 0 : data.updateModule) {
148
+ const moduleIds = Object.keys(window.__FEDERATION__.originModuleInfo);
149
+ const shouldUpdate = !moduleIds.some(
150
+ (id) => id.includes(data.updateModule.name)
151
+ );
152
+ if (shouldUpdate) {
153
+ const destination = data.updateModule.entry || data.updateModule.version;
154
+ window.__FEDERATION__.originModuleInfo[`${data.updateModule.name}:${destination}`] = {
155
+ remoteEntry: destination,
156
+ version: destination
157
+ };
158
+ }
159
+ }
160
+ window.__FEDERATION__.moduleInfo = JSON.parse(
161
+ JSON.stringify(window.__FEDERATION__.originModuleInfo)
162
+ );
163
+ callback(window.__FEDERATION__.moduleInfo);
164
+ }
165
+ );
166
+ const postMessageStartUrl = getUrl("post-message-start.js");
167
+ yield injectScript(injectPostMessage, false, postMessageStartUrl);
168
+ });
169
+ const getTabs = (queryOptions = {}) => chrome.tabs.query(queryOptions);
170
+ const getScope = () => __async(void 0, null, function* () {
171
+ const activeTab = window.targetTab;
172
+ const favIconUrl = activeTab == null ? void 0 : activeTab.favIconUrl;
173
+ return favIconUrl || "noScope";
174
+ });
175
+ const injectScript = (excuteScript, world = false, ...args) => __async(void 0, null, function* () {
176
+ yield getInspectWindowTabId();
177
+ return chrome.scripting.executeScript({
178
+ target: {
179
+ tabId: getCurrentTabId()
180
+ },
181
+ func: excuteScript,
182
+ world: world ? "MAIN" : "ISOLATED",
183
+ args
184
+ }).then(() => {
185
+ console.log("InjectScript success, excuteScript:", args);
186
+ }).catch((e) => {
187
+ console.log(e, "InjectScript fail, excuteScript:", args);
188
+ });
189
+ });
190
+ const getUrl = (file) => {
191
+ try {
192
+ const pathSet = chrome.runtime.getURL(file).split("/");
193
+ const fileName = pathSet.pop();
194
+ pathSet.push("static", "js", fileName);
195
+ return pathSet.join("/");
196
+ } catch (e) {
197
+ return "";
198
+ }
199
+ };
200
+ const injectToast = (toastUtilUrl, e2eFlag) => {
201
+ const ele = document.querySelector(`[data-e2e=${e2eFlag}]`);
202
+ if (ele) {
203
+ return;
204
+ }
205
+ const scriptToast = document.createElement("script");
206
+ scriptToast.src = toastUtilUrl;
207
+ scriptToast.dataset.e2e = e2eFlag;
208
+ document.getElementsByTagName("head")[0].appendChild(scriptToast);
209
+ };
210
+ const setChromeStorage = (formData) => {
211
+ getScope().then((scope) => __async(void 0, null, function* () {
212
+ const data = yield chrome.storage.sync.get("FormID");
213
+ const storeData = data[import_constant.FormID];
214
+ const scopes = Object.keys(storeData || {});
215
+ let filterOutDatedData = storeData || {};
216
+ const { length } = scopes;
217
+ if (length >= 10) {
218
+ filterOutDatedData = scopes.slice(0, length - 3).reduce((memo, cur) => {
219
+ memo[cur] = storeData[cur];
220
+ return memo;
221
+ }, {});
222
+ }
223
+ const existRules = storeData == null ? void 0 : storeData[scope];
224
+ chrome.storage.sync.set({
225
+ [import_constant.FormID]: __spreadProps(__spreadValues({}, filterOutDatedData), {
226
+ [scope]: __spreadValues(__spreadValues({}, existRules), formData)
227
+ })
228
+ });
229
+ }));
230
+ };
231
+ // Annotate the CommonJS export names for ESM import in node:
232
+ 0 && (module.exports = {
233
+ TabInfo,
234
+ getCurrentTabId,
235
+ getGlobalModuleInfo,
236
+ getInspectWindowTabId,
237
+ getScope,
238
+ getTabs,
239
+ getUrl,
240
+ injectPostMessage,
241
+ injectScript,
242
+ injectToast,
243
+ setChromeStorage,
244
+ ...require("./storage")
245
+ });
@@ -0,0 +1,6 @@
1
+ "use strict";
2
+ var import_index = require("./index");
3
+ const postMessageUrl = (0, import_index.getUrl)("post-message.js");
4
+ const script = document.createElement("script");
5
+ script.src = postMessageUrl;
6
+ document.getElementsByTagName("html")[0].appendChild(script);
@@ -0,0 +1,21 @@
1
+ "use strict";
2
+ if (window.moduleHandler) {
3
+ window.removeEventListener("message", window.moduleHandler);
4
+ } else {
5
+ window.moduleHandler = (event) => {
6
+ const { origin, data } = event;
7
+ if (!data.moduleInfo) {
8
+ return;
9
+ }
10
+ chrome.runtime.sendMessage({
11
+ origin,
12
+ data: {
13
+ moduleInfo: data.moduleInfo,
14
+ updateModule: data.updateModule
15
+ }
16
+ }).catch(() => {
17
+ return false;
18
+ });
19
+ };
20
+ }
21
+ window.addEventListener("message", window.moduleHandler);
@@ -0,0 +1,9 @@
1
+ "use strict";
2
+ var _a;
3
+ const moduleInfo = (_a = window == null ? void 0 : window.__FEDERATION__) == null ? void 0 : _a.moduleInfo;
4
+ window.postMessage(
5
+ {
6
+ moduleInfo
7
+ },
8
+ "*"
9
+ );