@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,95 @@
|
|
|
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
|
+
__ENABLE_FAST_REFRESH__: () => __ENABLE_FAST_REFRESH__,
|
|
39
|
+
__FEDERATION_DEVTOOLS__: () => __FEDERATION_DEVTOOLS__,
|
|
40
|
+
defaultDataItem: () => defaultDataItem,
|
|
41
|
+
defaultModuleData: () => defaultModuleData,
|
|
42
|
+
proxyFormField: () => proxyFormField,
|
|
43
|
+
statusInfo: () => statusInfo
|
|
44
|
+
});
|
|
45
|
+
module.exports = __toCommonJS(constant_exports);
|
|
46
|
+
const FormID = "FormID";
|
|
47
|
+
const ENABLEHMR = "enableHMR";
|
|
48
|
+
const proxyFormField = "proxyFormField";
|
|
49
|
+
const defaultDataItem = {
|
|
50
|
+
key: "",
|
|
51
|
+
value: "",
|
|
52
|
+
checked: true
|
|
53
|
+
};
|
|
54
|
+
const defaultModuleData = {
|
|
55
|
+
proxyFormField: [
|
|
56
|
+
__spreadValues({}, defaultDataItem)
|
|
57
|
+
]
|
|
58
|
+
};
|
|
59
|
+
const statusInfo = {
|
|
60
|
+
noProxy: {
|
|
61
|
+
status: "noProxy",
|
|
62
|
+
message: "Modules are not currently proxied",
|
|
63
|
+
color: "#698cee"
|
|
64
|
+
},
|
|
65
|
+
processing: {
|
|
66
|
+
status: "processing",
|
|
67
|
+
message: "Obtaining remote module information",
|
|
68
|
+
color: "#FF7D00"
|
|
69
|
+
},
|
|
70
|
+
success: {
|
|
71
|
+
status: "success",
|
|
72
|
+
message: "The proxy configuration has taken effect and the corresponding page has been automatically refreshed.",
|
|
73
|
+
color: "#50b042"
|
|
74
|
+
},
|
|
75
|
+
error: {
|
|
76
|
+
status: "error",
|
|
77
|
+
message: "Calculating Snapshot failed, please confirm whether the package information is correct",
|
|
78
|
+
color: "#F53F3F"
|
|
79
|
+
}
|
|
80
|
+
};
|
|
81
|
+
const __ENABLE_FAST_REFRESH__ = "enableFastRefresh";
|
|
82
|
+
const BROWSER_ENV_KEY = "MF_ENV";
|
|
83
|
+
const __FEDERATION_DEVTOOLS__ = "__MF_DEVTOOLS__";
|
|
84
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
85
|
+
0 && (module.exports = {
|
|
86
|
+
BROWSER_ENV_KEY,
|
|
87
|
+
ENABLEHMR,
|
|
88
|
+
FormID,
|
|
89
|
+
__ENABLE_FAST_REFRESH__,
|
|
90
|
+
__FEDERATION_DEVTOOLS__,
|
|
91
|
+
defaultDataItem,
|
|
92
|
+
defaultModuleData,
|
|
93
|
+
proxyFormField,
|
|
94
|
+
statusInfo
|
|
95
|
+
});
|
|
@@ -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,6 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var import_index = require("./index");
|
|
3
|
+
const fastRefreshMessageUrl = (0, import_index.getUrl)("fast-refresh.js");
|
|
4
|
+
const script = document.createElement("script");
|
|
5
|
+
script.src = fastRefreshMessageUrl;
|
|
6
|
+
document.getElementsByTagName("html")[0].appendChild(script);
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __async = (__this, __arguments, generator) => {
|
|
3
|
+
return new Promise((resolve, reject) => {
|
|
4
|
+
var fulfilled = (value) => {
|
|
5
|
+
try {
|
|
6
|
+
step(generator.next(value));
|
|
7
|
+
} catch (e) {
|
|
8
|
+
reject(e);
|
|
9
|
+
}
|
|
10
|
+
};
|
|
11
|
+
var rejected = (value) => {
|
|
12
|
+
try {
|
|
13
|
+
step(generator.throw(value));
|
|
14
|
+
} catch (e) {
|
|
15
|
+
reject(e);
|
|
16
|
+
}
|
|
17
|
+
};
|
|
18
|
+
var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
|
|
19
|
+
step((generator = generator.apply(__this, __arguments)).next());
|
|
20
|
+
});
|
|
21
|
+
};
|
|
22
|
+
var import_sdk = require("@module-federation/sdk");
|
|
23
|
+
var import__ = require("../index");
|
|
24
|
+
var import_sdk2 = require("../sdk");
|
|
25
|
+
var import_template = require("../../template");
|
|
26
|
+
var _a;
|
|
27
|
+
const fastRefreshPlugin = () => {
|
|
28
|
+
return {
|
|
29
|
+
name: "mf-fast-refresh-plugin",
|
|
30
|
+
// @ts-expect-error
|
|
31
|
+
beforeInit({ origin, userOptions, options, shareInfo }) {
|
|
32
|
+
let enableFastRefresh;
|
|
33
|
+
let devtoolsMessage;
|
|
34
|
+
const devtoolsMessageStr = localStorage.getItem(import_template.__FEDERATION_DEVTOOLS__);
|
|
35
|
+
if (devtoolsMessageStr) {
|
|
36
|
+
try {
|
|
37
|
+
devtoolsMessage = JSON.parse(devtoolsMessageStr);
|
|
38
|
+
enableFastRefresh = devtoolsMessage == null ? void 0 : devtoolsMessage.enableFastRefresh;
|
|
39
|
+
} catch (e) {
|
|
40
|
+
console.debug("Fast Refresh Plugin Error: ", e);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
if ((0, import__.isObject)(shareInfo)) {
|
|
44
|
+
let orderResolve;
|
|
45
|
+
const orderPromise = new Promise((resolve) => {
|
|
46
|
+
orderResolve = resolve;
|
|
47
|
+
});
|
|
48
|
+
Object.keys(shareInfo).forEach((share) => __async(this, null, function* () {
|
|
49
|
+
const sharedArr = Array.isArray(shareInfo[share]) ? shareInfo[share] : [shareInfo[share]];
|
|
50
|
+
sharedArr.forEach((shared) => {
|
|
51
|
+
let get;
|
|
52
|
+
if (share === "react") {
|
|
53
|
+
get = () => (0, import_sdk.loadScript)((0, import__.getUnpkgUrl)(share, shared.version), {
|
|
54
|
+
attrs: { defer: true, async: false }
|
|
55
|
+
}).then(() => {
|
|
56
|
+
orderResolve();
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
if (share === "react-dom") {
|
|
60
|
+
get = () => orderPromise.then(
|
|
61
|
+
() => (0, import_sdk.loadScript)((0, import__.getUnpkgUrl)(share, shared.version), {
|
|
62
|
+
attrs: { defer: true, async: false }
|
|
63
|
+
})
|
|
64
|
+
);
|
|
65
|
+
}
|
|
66
|
+
if (enableFastRefresh && typeof get === "function") {
|
|
67
|
+
if (share === "react") {
|
|
68
|
+
shared.get = () => __async(this, null, function* () {
|
|
69
|
+
if (!window.React) {
|
|
70
|
+
yield get();
|
|
71
|
+
console.warn(
|
|
72
|
+
"[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"
|
|
73
|
+
);
|
|
74
|
+
}
|
|
75
|
+
shared.lib = () => window.React;
|
|
76
|
+
return () => window.React;
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
if (share === "react-dom") {
|
|
80
|
+
shared.get = () => __async(this, null, function* () {
|
|
81
|
+
if (!window.ReactDOM) {
|
|
82
|
+
yield get();
|
|
83
|
+
}
|
|
84
|
+
shared.lib = () => window.ReactDOM;
|
|
85
|
+
return () => window.ReactDOM;
|
|
86
|
+
});
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
});
|
|
90
|
+
}));
|
|
91
|
+
return {
|
|
92
|
+
origin,
|
|
93
|
+
userOptions,
|
|
94
|
+
options,
|
|
95
|
+
shareInfo
|
|
96
|
+
};
|
|
97
|
+
} else {
|
|
98
|
+
return {
|
|
99
|
+
origin,
|
|
100
|
+
userOptions,
|
|
101
|
+
options
|
|
102
|
+
};
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
};
|
|
106
|
+
};
|
|
107
|
+
if (!(window == null ? void 0 : window.__FEDERATION__)) {
|
|
108
|
+
(0, import_sdk2.definePropertyGlobalVal)(window, "__FEDERATION__", {});
|
|
109
|
+
(0, import_sdk2.definePropertyGlobalVal)(window, "__VMOK__", window.__FEDERATION__);
|
|
110
|
+
}
|
|
111
|
+
if (!(window == null ? void 0 : window.__FEDERATION__.__GLOBAL_PLUGIN__)) {
|
|
112
|
+
window.__FEDERATION__.__GLOBAL_PLUGIN__ = [];
|
|
113
|
+
}
|
|
114
|
+
(_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,83 @@
|
|
|
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 __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
7
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
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 __objRest = (source, exclude) => {
|
|
23
|
+
var target = {};
|
|
24
|
+
for (var prop in source)
|
|
25
|
+
if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
|
|
26
|
+
target[prop] = source[prop];
|
|
27
|
+
if (source != null && __getOwnPropSymbols)
|
|
28
|
+
for (var prop of __getOwnPropSymbols(source)) {
|
|
29
|
+
if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
|
|
30
|
+
target[prop] = source[prop];
|
|
31
|
+
}
|
|
32
|
+
return target;
|
|
33
|
+
};
|
|
34
|
+
var __copyProps = (to, from, except, desc) => {
|
|
35
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
36
|
+
for (let key of __getOwnPropNames(from))
|
|
37
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
38
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
39
|
+
}
|
|
40
|
+
return to;
|
|
41
|
+
};
|
|
42
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
43
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
44
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
45
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
46
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
47
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
48
|
+
mod
|
|
49
|
+
));
|
|
50
|
+
var import_helpers = __toESM(require("@module-federation/runtime/helpers"));
|
|
51
|
+
var import_sdk = require("../sdk");
|
|
52
|
+
var _a;
|
|
53
|
+
const getModuleInfo = () => {
|
|
54
|
+
return {
|
|
55
|
+
name: "mf-devtool-getModuleInfo-plugin",
|
|
56
|
+
loadRemoteSnapshot(_a2) {
|
|
57
|
+
var _b = _a2, { options, moduleInfo, remoteSnapshot } = _b, res = __objRest(_b, ["options", "moduleInfo", "remoteSnapshot"]);
|
|
58
|
+
const globalSnapshot = import_helpers.default.global.getGlobalSnapshot();
|
|
59
|
+
if (options.inBrowser) {
|
|
60
|
+
window.postMessage(
|
|
61
|
+
{
|
|
62
|
+
moduleInfo: globalSnapshot,
|
|
63
|
+
updateModule: moduleInfo
|
|
64
|
+
},
|
|
65
|
+
"*"
|
|
66
|
+
);
|
|
67
|
+
}
|
|
68
|
+
return __spreadValues({
|
|
69
|
+
options,
|
|
70
|
+
moduleInfo,
|
|
71
|
+
remoteSnapshot
|
|
72
|
+
}, res);
|
|
73
|
+
}
|
|
74
|
+
};
|
|
75
|
+
};
|
|
76
|
+
if (!(window == null ? void 0 : window.__FEDERATION__)) {
|
|
77
|
+
(0, import_sdk.definePropertyGlobalVal)(window, "__FEDERATION__", {});
|
|
78
|
+
(0, import_sdk.definePropertyGlobalVal)(window, "__VMOK__", window.__FEDERATION__);
|
|
79
|
+
}
|
|
80
|
+
if (!(window == null ? void 0 : window.__FEDERATION__.__GLOBAL_PLUGIN__)) {
|
|
81
|
+
window.__FEDERATION__.__GLOBAL_PLUGIN__ = [];
|
|
82
|
+
}
|
|
83
|
+
(_a = window.__FEDERATION__.__GLOBAL_PLUGIN__) == null ? void 0 : _a.push(getModuleInfo());
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var import_index = require("./index");
|
|
3
|
+
const fastRefreshMessageUrl = (0, import_index.getUrl)("snapshot-plugin.js");
|
|
4
|
+
const script = document.createElement("script");
|
|
5
|
+
script.src = fastRefreshMessageUrl;
|
|
6
|
+
document.getElementsByTagName("html")[0].appendChild(script);
|
|
@@ -0,0 +1,59 @@
|
|
|
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 __copyProps = (to, from, except, desc) => {
|
|
9
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
10
|
+
for (let key of __getOwnPropNames(from))
|
|
11
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
12
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
13
|
+
}
|
|
14
|
+
return to;
|
|
15
|
+
};
|
|
16
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
17
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
18
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
19
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
20
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
21
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
22
|
+
mod
|
|
23
|
+
));
|
|
24
|
+
var import_sdk = require("@module-federation/sdk");
|
|
25
|
+
var import_helpers = __toESM(require("@module-federation/runtime/helpers"));
|
|
26
|
+
var import_sdk2 = require("../sdk");
|
|
27
|
+
var _a;
|
|
28
|
+
const chromeDevtoolsPlugin = function() {
|
|
29
|
+
return {
|
|
30
|
+
name: "mf-chrome-devtools-inject-snapshot-plugin",
|
|
31
|
+
beforeLoadRemoteSnapshot({ options }) {
|
|
32
|
+
const { nativeGlobal } = import_helpers.default.global;
|
|
33
|
+
if (options.inBrowser) {
|
|
34
|
+
const realLocalStorage = nativeGlobal.localStorage || localStorage;
|
|
35
|
+
const debugModuleInfoStr = realLocalStorage.getItem(
|
|
36
|
+
import_sdk.MODULE_DEVTOOL_IDENTIFIER
|
|
37
|
+
);
|
|
38
|
+
if (debugModuleInfoStr && !nativeGlobal.__INIT_VMOK_CHROME_DEVTOOL_PLUGIN__) {
|
|
39
|
+
const chromeDevtoolSnapshot = JSON.parse(debugModuleInfoStr);
|
|
40
|
+
if (chromeDevtoolSnapshot) {
|
|
41
|
+
import_helpers.default.global.addGlobalSnapshot(chromeDevtoolSnapshot);
|
|
42
|
+
nativeGlobal.__INIT_VMOK_CHROME_DEVTOOL_PLUGIN__ = true;
|
|
43
|
+
console.warn(
|
|
44
|
+
"[Module Federation Devtools]: You are using the chrome devtool to proxy online module"
|
|
45
|
+
);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
};
|
|
51
|
+
};
|
|
52
|
+
if (!(window == null ? void 0 : window.__FEDERATION__)) {
|
|
53
|
+
(0, import_sdk2.definePropertyGlobalVal)(window, "__FEDERATION__", {});
|
|
54
|
+
(0, import_sdk2.definePropertyGlobalVal)(window, "__VMOK__", window.__FEDERATION__);
|
|
55
|
+
}
|
|
56
|
+
if (!(window == null ? void 0 : window.__FEDERATION__.__GLOBAL_PLUGIN__)) {
|
|
57
|
+
window.__FEDERATION__.__GLOBAL_PLUGIN__ = [];
|
|
58
|
+
}
|
|
59
|
+
(_a = window.__FEDERATION__.__GLOBAL_PLUGIN__) == null ? void 0 : _a.push(chromeDevtoolsPlugin());
|