@module-federation/devtools 2.4.0 → 2.5.1
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/README.md +3 -0
- package/dist/es/App.js +17 -2
- package/dist/es/App_module.css +3 -3
- package/dist/es/component/LoadingTrace/index.js +944 -0
- package/dist/es/component/LoadingTrace/index.module.js +5 -0
- package/dist/es/component/LoadingTrace/index_module.css +876 -0
- package/dist/es/i18n/index.js +178 -0
- package/dist/es/utils/chrome/index.js +3 -4
- package/dist/es/utils/chrome/messages.js +7 -1
- package/dist/es/utils/chrome/observability-plugin.js +93 -0
- package/dist/es/utils/chrome/observability-shared.js +99 -0
- package/dist/es/utils/chrome/observability.js +208 -0
- package/dist/es/utils/chrome/override-remote.js +2 -42
- package/dist/es/utils/chrome/post-message-listener.js +14 -0
- package/dist/es/utils/chrome/snapshot-plugin.js +2 -36
- package/dist/es/utils/data/index.js +5 -25
- package/dist/es/vendor/basic-proxy-core.js +155 -0
- package/dist/es/worker/index.js +27 -8
- package/dist/lib/App.js +17 -2
- package/dist/lib/App_module.css +3 -3
- package/dist/lib/component/LoadingTrace/index.js +954 -0
- package/dist/lib/component/LoadingTrace/index.module.js +25 -0
- package/dist/lib/component/LoadingTrace/index_module.css +876 -0
- package/dist/lib/i18n/index.js +178 -0
- package/dist/lib/utils/chrome/index.js +3 -4
- package/dist/lib/utils/chrome/messages.js +11 -2
- package/dist/lib/utils/chrome/observability-plugin.js +86 -0
- package/dist/lib/utils/chrome/observability-shared.js +126 -0
- package/dist/lib/utils/chrome/observability.js +234 -0
- package/dist/lib/utils/chrome/override-remote.js +5 -52
- package/dist/lib/utils/chrome/post-message-listener.js +11 -0
- package/dist/lib/utils/chrome/snapshot-plugin.js +5 -46
- package/dist/lib/utils/data/index.js +6 -28
- package/dist/lib/vendor/basic-proxy-core.js +147 -0
- package/dist/lib/worker/index.js +27 -8
- package/dist/types/src/component/LoadingTrace/index.d.ts +6 -0
- package/dist/types/src/utils/chrome/messages.d.ts +3 -0
- package/dist/types/src/utils/chrome/observability-plugin.d.ts +1 -0
- package/dist/types/src/utils/chrome/observability-shared.d.ts +41 -0
- package/dist/types/src/utils/chrome/observability.d.ts +110 -0
- package/dist/types/src/utils/chrome/snapshot-plugin.d.ts +0 -3
- package/dist/types/src/utils/data/index.d.ts +0 -1
- package/package.json +4 -3
- package/dist/es/utils/data/snapshot.js +0 -82
- package/dist/lib/utils/data/snapshot.js +0 -107
- package/dist/types/src/utils/data/snapshot.d.ts +0 -3
|
@@ -0,0 +1,234 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var __async = (__this, __arguments, generator) => {
|
|
20
|
+
return new Promise((resolve, reject) => {
|
|
21
|
+
var fulfilled = (value) => {
|
|
22
|
+
try {
|
|
23
|
+
step(generator.next(value));
|
|
24
|
+
} catch (e) {
|
|
25
|
+
reject(e);
|
|
26
|
+
}
|
|
27
|
+
};
|
|
28
|
+
var rejected = (value) => {
|
|
29
|
+
try {
|
|
30
|
+
step(generator.throw(value));
|
|
31
|
+
} catch (e) {
|
|
32
|
+
reject(e);
|
|
33
|
+
}
|
|
34
|
+
};
|
|
35
|
+
var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
|
|
36
|
+
step((generator = generator.apply(__this, __arguments)).next());
|
|
37
|
+
});
|
|
38
|
+
};
|
|
39
|
+
var observability_exports = {};
|
|
40
|
+
__export(observability_exports, {
|
|
41
|
+
applyObservabilityConfig: () => applyObservabilityConfig,
|
|
42
|
+
disableObservabilityConfig: () => disableObservabilityConfig,
|
|
43
|
+
getObservabilityReportScopeLabel: () => getObservabilityReportScopeLabel,
|
|
44
|
+
mergeObservabilityReports: () => mergeObservabilityReports,
|
|
45
|
+
readObservabilityConfig: () => readObservabilityConfig,
|
|
46
|
+
readObservabilitySnapshot: () => readObservabilitySnapshot,
|
|
47
|
+
reloadInspectedPage: () => reloadInspectedPage
|
|
48
|
+
});
|
|
49
|
+
module.exports = __toCommonJS(observability_exports);
|
|
50
|
+
var import_index = require("./index");
|
|
51
|
+
var import_messages = require("./messages");
|
|
52
|
+
var import_observability_shared = require("./observability-shared");
|
|
53
|
+
const USER_OBSERVABILITY_PLUGIN_NAME = "observability-plugin";
|
|
54
|
+
const CHROME_OBSERVABILITY_PLUGIN_NAME = "observability-plugin:chrome-extension";
|
|
55
|
+
const LEGACY_CHROME_OBSERVABILITY_PLUGIN_NAME = "observability-plugin-devtools";
|
|
56
|
+
const OBSERVABILITY_SNAPSHOT_CONTEXT = {
|
|
57
|
+
chromeScope: import_observability_shared.CHROME_OBSERVABILITY_SCOPE,
|
|
58
|
+
userPluginName: USER_OBSERVABILITY_PLUGIN_NAME,
|
|
59
|
+
chromePluginNames: [
|
|
60
|
+
CHROME_OBSERVABILITY_PLUGIN_NAME,
|
|
61
|
+
LEGACY_CHROME_OBSERVABILITY_PLUGIN_NAME
|
|
62
|
+
]
|
|
63
|
+
};
|
|
64
|
+
const readConfigFromPage = (storageKey) => {
|
|
65
|
+
var _a;
|
|
66
|
+
try {
|
|
67
|
+
const raw = (_a = window.localStorage) == null ? void 0 : _a.getItem(storageKey);
|
|
68
|
+
return raw ? JSON.parse(raw) : null;
|
|
69
|
+
} catch (e) {
|
|
70
|
+
return null;
|
|
71
|
+
}
|
|
72
|
+
};
|
|
73
|
+
const writeConfigToPage = (storageKey, config) => {
|
|
74
|
+
var _a;
|
|
75
|
+
(_a = window.localStorage) == null ? void 0 : _a.setItem(storageKey, JSON.stringify(config));
|
|
76
|
+
return config;
|
|
77
|
+
};
|
|
78
|
+
const removeConfigFromPage = (storageKey) => {
|
|
79
|
+
var _a;
|
|
80
|
+
(_a = window.localStorage) == null ? void 0 : _a.removeItem(storageKey);
|
|
81
|
+
return true;
|
|
82
|
+
};
|
|
83
|
+
const reloadPage = () => {
|
|
84
|
+
var _a;
|
|
85
|
+
(_a = globalThis.location) == null ? void 0 : _a.reload();
|
|
86
|
+
};
|
|
87
|
+
const readSnapshotFromPage = (storageKey, context) => {
|
|
88
|
+
const chromeScope = typeof (context == null ? void 0 : context.chromeScope) === "string" ? context.chromeScope : "chrome_extension";
|
|
89
|
+
const userPluginName = typeof (context == null ? void 0 : context.userPluginName) === "string" ? context.userPluginName : "observability-plugin";
|
|
90
|
+
const chromePluginNames = Array.isArray(context == null ? void 0 : context.chromePluginNames) ? context.chromePluginNames : [
|
|
91
|
+
"observability-plugin:chrome-extension",
|
|
92
|
+
"observability-plugin-devtools"
|
|
93
|
+
];
|
|
94
|
+
const safeCopy = (value) => {
|
|
95
|
+
try {
|
|
96
|
+
return JSON.parse(JSON.stringify(value));
|
|
97
|
+
} catch (e) {
|
|
98
|
+
return void 0;
|
|
99
|
+
}
|
|
100
|
+
};
|
|
101
|
+
const rawConfig = (() => {
|
|
102
|
+
var _a;
|
|
103
|
+
try {
|
|
104
|
+
const raw = (_a = window.localStorage) == null ? void 0 : _a.getItem(storageKey);
|
|
105
|
+
return raw ? JSON.parse(raw) : null;
|
|
106
|
+
} catch (e) {
|
|
107
|
+
return null;
|
|
108
|
+
}
|
|
109
|
+
})();
|
|
110
|
+
const federation = window.__FEDERATION__ || window.__VMOK__;
|
|
111
|
+
const readers = (federation == null ? void 0 : federation.__OBSERVABILITY__) || {};
|
|
112
|
+
const reports = [];
|
|
113
|
+
const scopes = Object.keys(readers);
|
|
114
|
+
const isChromeObservabilityPluginName = (name) => chromePluginNames.includes(String(name));
|
|
115
|
+
const hasUserObservabilityPluginFromInstances = Array.isArray(
|
|
116
|
+
federation == null ? void 0 : federation.__INSTANCES__
|
|
117
|
+
) ? federation.__INSTANCES__.some((instance) => {
|
|
118
|
+
var _a;
|
|
119
|
+
const plugins = (_a = instance == null ? void 0 : instance.options) == null ? void 0 : _a.plugins;
|
|
120
|
+
if (!Array.isArray(plugins)) {
|
|
121
|
+
return false;
|
|
122
|
+
}
|
|
123
|
+
return plugins.some(
|
|
124
|
+
(plugin) => (plugin == null ? void 0 : plugin.name) === userPluginName && !isChromeObservabilityPluginName(plugin == null ? void 0 : plugin.name)
|
|
125
|
+
);
|
|
126
|
+
}) : false;
|
|
127
|
+
const hasUserObservabilityPluginFromReaders = scopes.some(
|
|
128
|
+
(scope) => scope !== chromeScope
|
|
129
|
+
);
|
|
130
|
+
scopes.forEach((scope) => {
|
|
131
|
+
const reader = readers[scope];
|
|
132
|
+
if (!reader || typeof reader.getReports !== "function") {
|
|
133
|
+
return;
|
|
134
|
+
}
|
|
135
|
+
try {
|
|
136
|
+
const scopeReports = reader.getReports({ limit: 100 });
|
|
137
|
+
if (!Array.isArray(scopeReports)) {
|
|
138
|
+
return;
|
|
139
|
+
}
|
|
140
|
+
scopeReports.forEach((report) => {
|
|
141
|
+
const copied = safeCopy(report);
|
|
142
|
+
if (copied == null ? void 0 : copied.traceId) {
|
|
143
|
+
copied.__scope = scope;
|
|
144
|
+
reports.push(copied);
|
|
145
|
+
}
|
|
146
|
+
});
|
|
147
|
+
} catch (e) {
|
|
148
|
+
}
|
|
149
|
+
});
|
|
150
|
+
return {
|
|
151
|
+
config: rawConfig,
|
|
152
|
+
stored: Boolean(rawConfig),
|
|
153
|
+
scopes,
|
|
154
|
+
reports,
|
|
155
|
+
hasUserObservabilityPlugin: hasUserObservabilityPluginFromInstances || hasUserObservabilityPluginFromReaders
|
|
156
|
+
};
|
|
157
|
+
};
|
|
158
|
+
const readObservabilityConfig = () => __async(void 0, null, function* () {
|
|
159
|
+
const config = yield (0, import_index.injectScript)(
|
|
160
|
+
readConfigFromPage,
|
|
161
|
+
false,
|
|
162
|
+
import_messages.OBSERVABILITY_DEVTOOLS_STORAGE_KEY
|
|
163
|
+
);
|
|
164
|
+
return (0, import_observability_shared.normalizeObservabilityDevtoolsConfig)(
|
|
165
|
+
config || import_observability_shared.DEFAULT_OBSERVABILITY_DEVTOOLS_CONFIG
|
|
166
|
+
);
|
|
167
|
+
});
|
|
168
|
+
const applyObservabilityConfig = (config) => __async(void 0, null, function* () {
|
|
169
|
+
return (0, import_index.injectScript)(
|
|
170
|
+
writeConfigToPage,
|
|
171
|
+
false,
|
|
172
|
+
import_messages.OBSERVABILITY_DEVTOOLS_STORAGE_KEY,
|
|
173
|
+
(0, import_observability_shared.normalizeObservabilityDevtoolsConfig)(config)
|
|
174
|
+
);
|
|
175
|
+
});
|
|
176
|
+
const disableObservabilityConfig = () => __async(void 0, null, function* () {
|
|
177
|
+
return (0, import_index.injectScript)(removeConfigFromPage, false, import_messages.OBSERVABILITY_DEVTOOLS_STORAGE_KEY);
|
|
178
|
+
});
|
|
179
|
+
const reloadInspectedPage = () => __async(void 0, null, function* () {
|
|
180
|
+
return (0, import_index.injectScript)(reloadPage, false);
|
|
181
|
+
});
|
|
182
|
+
const readObservabilitySnapshot = () => __async(void 0, null, function* () {
|
|
183
|
+
const snapshot = yield (0, import_index.injectScript)(
|
|
184
|
+
readSnapshotFromPage,
|
|
185
|
+
true,
|
|
186
|
+
import_messages.OBSERVABILITY_DEVTOOLS_STORAGE_KEY,
|
|
187
|
+
OBSERVABILITY_SNAPSHOT_CONTEXT
|
|
188
|
+
);
|
|
189
|
+
return {
|
|
190
|
+
config: (0, import_observability_shared.normalizeObservabilityDevtoolsConfig)(
|
|
191
|
+
(snapshot == null ? void 0 : snapshot.config) || import_observability_shared.DEFAULT_OBSERVABILITY_DEVTOOLS_CONFIG
|
|
192
|
+
),
|
|
193
|
+
stored: Boolean(snapshot == null ? void 0 : snapshot.stored),
|
|
194
|
+
scopes: Array.isArray(snapshot == null ? void 0 : snapshot.scopes) ? snapshot.scopes : [],
|
|
195
|
+
reports: Array.isArray(snapshot == null ? void 0 : snapshot.reports) ? snapshot.reports : [],
|
|
196
|
+
hasUserObservabilityPlugin: Boolean(snapshot == null ? void 0 : snapshot.hasUserObservabilityPlugin)
|
|
197
|
+
};
|
|
198
|
+
});
|
|
199
|
+
const mergeObservabilityReports = (currentReports, incomingReports) => {
|
|
200
|
+
const merged = /* @__PURE__ */ new Map();
|
|
201
|
+
currentReports.forEach((report) => {
|
|
202
|
+
if (report.traceId) {
|
|
203
|
+
merged.set(report.traceId, report);
|
|
204
|
+
}
|
|
205
|
+
});
|
|
206
|
+
incomingReports.forEach((report) => {
|
|
207
|
+
if (report.traceId) {
|
|
208
|
+
merged.set(report.traceId, report);
|
|
209
|
+
}
|
|
210
|
+
});
|
|
211
|
+
return Array.from(merged.values()).sort((left, right) => {
|
|
212
|
+
if ((right.updatedAt || 0) !== (left.updatedAt || 0)) {
|
|
213
|
+
return (right.updatedAt || 0) - (left.updatedAt || 0);
|
|
214
|
+
}
|
|
215
|
+
return (right.startedAt || 0) - (left.startedAt || 0);
|
|
216
|
+
});
|
|
217
|
+
};
|
|
218
|
+
const getObservabilityReportScopeLabel = (report) => {
|
|
219
|
+
const scope = report.__scope;
|
|
220
|
+
if (!scope || scope === import_observability_shared.CHROME_OBSERVABILITY_SCOPE) {
|
|
221
|
+
return void 0;
|
|
222
|
+
}
|
|
223
|
+
return `custom: ${scope}`;
|
|
224
|
+
};
|
|
225
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
226
|
+
0 && (module.exports = {
|
|
227
|
+
applyObservabilityConfig,
|
|
228
|
+
disableObservabilityConfig,
|
|
229
|
+
getObservabilityReportScopeLabel,
|
|
230
|
+
mergeObservabilityReports,
|
|
231
|
+
readObservabilityConfig,
|
|
232
|
+
readObservabilitySnapshot,
|
|
233
|
+
reloadInspectedPage
|
|
234
|
+
});
|
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __create = Object.create;
|
|
3
2
|
var __defProp = Object.defineProperty;
|
|
4
3
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
4
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
7
5
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
6
|
var __copyProps = (to, from, except, desc) => {
|
|
9
7
|
if (from && typeof from === "object" || typeof from === "function") {
|
|
@@ -13,53 +11,8 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
13
11
|
}
|
|
14
12
|
return to;
|
|
15
13
|
};
|
|
16
|
-
var
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
22
|
-
mod
|
|
23
|
-
));
|
|
24
|
-
var import_helpers = __toESM(require("@module-federation/runtime/helpers"));
|
|
25
|
-
var import_sdk = require("@module-federation/sdk");
|
|
26
|
-
var import_sdk2 = require("../sdk");
|
|
27
|
-
var _a;
|
|
28
|
-
const chromeOverrideRemotesPlugin = function() {
|
|
29
|
-
return {
|
|
30
|
-
name: "mf-chrome-devtools-override-remotes-plugin",
|
|
31
|
-
beforeRegisterRemote(args) {
|
|
32
|
-
try {
|
|
33
|
-
const { remote } = args;
|
|
34
|
-
const overrideRemote = import_helpers.default.global.nativeGlobal.localStorage.getItem(
|
|
35
|
-
import_sdk.MODULE_DEVTOOL_IDENTIFIER
|
|
36
|
-
);
|
|
37
|
-
if (!overrideRemote) {
|
|
38
|
-
return args;
|
|
39
|
-
}
|
|
40
|
-
const parsedOverrideRemote = JSON.parse(overrideRemote);
|
|
41
|
-
const overrideEntryOrVersion = parsedOverrideRemote[remote.name];
|
|
42
|
-
if (overrideEntryOrVersion) {
|
|
43
|
-
if (overrideEntryOrVersion.startsWith("http")) {
|
|
44
|
-
delete remote.version;
|
|
45
|
-
remote.entry = overrideEntryOrVersion;
|
|
46
|
-
} else {
|
|
47
|
-
delete remote.entry;
|
|
48
|
-
remote.version = overrideEntryOrVersion;
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
} catch (e) {
|
|
52
|
-
console.error(e);
|
|
53
|
-
}
|
|
54
|
-
return args;
|
|
55
|
-
}
|
|
56
|
-
};
|
|
57
|
-
};
|
|
58
|
-
if (!(window == null ? void 0 : window.__FEDERATION__)) {
|
|
59
|
-
(0, import_sdk2.definePropertyGlobalVal)(window, "__FEDERATION__", {});
|
|
60
|
-
(0, import_sdk2.definePropertyGlobalVal)(window, "__VMOK__", window.__FEDERATION__);
|
|
61
|
-
}
|
|
62
|
-
if (!(window == null ? void 0 : window.__FEDERATION__.__GLOBAL_PLUGIN__)) {
|
|
63
|
-
window.__FEDERATION__.__GLOBAL_PLUGIN__ = [];
|
|
64
|
-
}
|
|
65
|
-
(_a = window.__FEDERATION__.__GLOBAL_PLUGIN__) == null ? void 0 : _a.push(chromeOverrideRemotesPlugin());
|
|
14
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
15
|
+
var override_remote_exports = {};
|
|
16
|
+
module.exports = __toCommonJS(override_remote_exports);
|
|
17
|
+
const basicProxyCore = require("../../vendor/basic-proxy-core.js");
|
|
18
|
+
basicProxyCore.registerOverridePlugin(globalThis);
|
|
@@ -1,10 +1,21 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
var import_safe_post_message = require("./safe-post-message");
|
|
3
|
+
var import_messages = require("./messages");
|
|
3
4
|
if (window.moduleHandler) {
|
|
4
5
|
window.removeEventListener("message", window.moduleHandler);
|
|
5
6
|
} else {
|
|
6
7
|
window.moduleHandler = (event) => {
|
|
7
8
|
const { origin, data } = event;
|
|
9
|
+
if ((data == null ? void 0 : data.source) === import_messages.OBSERVABILITY_DEVTOOLS_SOURCE) {
|
|
10
|
+
chrome.runtime.sendMessage({
|
|
11
|
+
type: import_messages.MESSAGE_OBSERVABILITY_DEVTOOLS_EVENT,
|
|
12
|
+
origin,
|
|
13
|
+
data: (0, import_safe_post_message.sanitizePostMessagePayload)(data)
|
|
14
|
+
}).catch(() => {
|
|
15
|
+
return false;
|
|
16
|
+
});
|
|
17
|
+
return;
|
|
18
|
+
}
|
|
8
19
|
if (!data.moduleInfo) {
|
|
9
20
|
return;
|
|
10
21
|
}
|
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __create = Object.create;
|
|
3
2
|
var __defProp = Object.defineProperty;
|
|
4
3
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
4
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
7
5
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
6
|
var __copyProps = (to, from, except, desc) => {
|
|
9
7
|
if (from && typeof from === "object" || typeof from === "function") {
|
|
@@ -13,47 +11,8 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
13
11
|
}
|
|
14
12
|
return to;
|
|
15
13
|
};
|
|
16
|
-
var
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
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 || 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());
|
|
14
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
15
|
+
var snapshot_plugin_exports = {};
|
|
16
|
+
module.exports = __toCommonJS(snapshot_plugin_exports);
|
|
17
|
+
const basicProxyCore = require("../../vendor/basic-proxy-core.js");
|
|
18
|
+
basicProxyCore.registerSnapshotPlugin(globalThis);
|
|
@@ -15,7 +15,6 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
15
15
|
}
|
|
16
16
|
return to;
|
|
17
17
|
};
|
|
18
|
-
var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
|
19
18
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
20
19
|
var __async = (__this, __arguments, generator) => {
|
|
21
20
|
return new Promise((resolve, reject) => {
|
|
@@ -43,8 +42,7 @@ __export(data_exports, {
|
|
|
43
42
|
separateType: () => separateType
|
|
44
43
|
});
|
|
45
44
|
module.exports = __toCommonJS(data_exports);
|
|
46
|
-
|
|
47
|
-
__reExport(data_exports, require("./snapshot"), module.exports);
|
|
45
|
+
const basicProxyCore = require("../../vendor/basic-proxy-core.js");
|
|
48
46
|
const separateType = (moduleInfo) => {
|
|
49
47
|
const consumers = {};
|
|
50
48
|
const producer = [];
|
|
@@ -74,33 +72,13 @@ const separateType = (moduleInfo) => {
|
|
|
74
72
|
};
|
|
75
73
|
};
|
|
76
74
|
const getModuleInfo = (proxyRules) => __async(void 0, null, function* () {
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
const isMicroMode = Object.keys(consumers).some((moduleId) => {
|
|
82
|
-
const subApps = consumers[moduleId].consumerList;
|
|
83
|
-
return Array.isArray(subApps) && subApps.length;
|
|
84
|
-
});
|
|
85
|
-
proxyRules.forEach((rule) => {
|
|
86
|
-
const { key, value } = rule;
|
|
87
|
-
overrides[key] = value;
|
|
88
|
-
});
|
|
89
|
-
if (isMicroMode) {
|
|
90
|
-
freshModuleInfo = (0, import_snapshot.calculateMicroAppSnapshot)(moduleInfo, overrides);
|
|
91
|
-
} else {
|
|
92
|
-
freshModuleInfo = (0, import_snapshot.calculateSnapshot)(moduleInfo, overrides);
|
|
93
|
-
}
|
|
94
|
-
console.debug("New Snapshot: ", freshModuleInfo);
|
|
95
|
-
return {
|
|
96
|
-
status: "success",
|
|
97
|
-
moduleInfo: freshModuleInfo,
|
|
98
|
-
overrides
|
|
99
|
-
};
|
|
75
|
+
return basicProxyCore.getModuleInfo(
|
|
76
|
+
proxyRules,
|
|
77
|
+
window.__FEDERATION__.moduleInfo
|
|
78
|
+
);
|
|
100
79
|
});
|
|
101
80
|
// Annotate the CommonJS export names for ESM import in node:
|
|
102
81
|
0 && (module.exports = {
|
|
103
82
|
getModuleInfo,
|
|
104
|
-
separateType
|
|
105
|
-
...require("./snapshot")
|
|
83
|
+
separateType
|
|
106
84
|
});
|
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var P = "__MF_DEVTOOLS_MODULE_INFO__", f = "__MF_DEVTOOLS__", G = "MF_ENV", h = "mf-chrome-devtools-inject-snapshot-plugin", L = "mf-chrome-devtools-override-remotes-plugin", l = () => globalThis, y = (e) => Object.prototype.toString.call(e) === "[object Object]", O = (e) => JSON.parse(JSON.stringify(e || {})), d = (e, t, o) => {
|
|
3
|
+
if (Object.prototype.hasOwnProperty.call(e, t)) {
|
|
4
|
+
e[t] = o;
|
|
5
|
+
return;
|
|
6
|
+
}
|
|
7
|
+
Object.defineProperty(e, t, { value: o, configurable: false, writable: true });
|
|
8
|
+
}, g = (e = l()) => {
|
|
9
|
+
!e.__FEDERATION__ && e.__VMOK__ && d(e, "__FEDERATION__", e.__VMOK__), e.__FEDERATION__ || d(e, "__FEDERATION__", {}), e.__VMOK__ || d(e, "__VMOK__", e.__FEDERATION__);
|
|
10
|
+
let t = e.__FEDERATION__;
|
|
11
|
+
return Array.isArray(t.__GLOBAL_PLUGIN__) || (t.__GLOBAL_PLUGIN__ = []), y(t.moduleInfo) || (t.moduleInfo = {}), t;
|
|
12
|
+
}, p = (e, t) => {
|
|
13
|
+
if (!e)
|
|
14
|
+
return t;
|
|
15
|
+
try {
|
|
16
|
+
return JSON.parse(e);
|
|
17
|
+
} catch (o) {
|
|
18
|
+
return t;
|
|
19
|
+
}
|
|
20
|
+
}, x = (e = l()) => {
|
|
21
|
+
var t;
|
|
22
|
+
return e.localStorage || ((t = e.window) == null ? void 0 : t.localStorage);
|
|
23
|
+
}, M = (e = l()) => {
|
|
24
|
+
let t = x(e);
|
|
25
|
+
return t ? p(t.getItem(P), null) : null;
|
|
26
|
+
}, I = (e) => {
|
|
27
|
+
let t = {};
|
|
28
|
+
return y(e) && Object.keys(e).forEach((o) => {
|
|
29
|
+
typeof e[o] == "string" && e[o] && (t[o] = e[o]);
|
|
30
|
+
}), t;
|
|
31
|
+
}, N = (e = l()) => {
|
|
32
|
+
let t = x(e);
|
|
33
|
+
if (!t)
|
|
34
|
+
return {};
|
|
35
|
+
let o = p(t.getItem(f), {});
|
|
36
|
+
return y(o.overrides) ? I(o.overrides) : I(o);
|
|
37
|
+
}, S = (e) => e.indexOf("http://") === 0 || e.indexOf("https://") === 0 || e.indexOf("//") === 0, m = (e, t) => {
|
|
38
|
+
Reflect.deleteProperty(e, t);
|
|
39
|
+
}, T = (e) => {
|
|
40
|
+
let t = {}, o = [];
|
|
41
|
+
return Object.keys(e || {}).forEach((s) => {
|
|
42
|
+
var r;
|
|
43
|
+
let i = (r = e[s]) == null ? void 0 : r.remotesInfo;
|
|
44
|
+
if (i) {
|
|
45
|
+
let n = Object.keys(i);
|
|
46
|
+
n.length && (n.forEach((c) => {
|
|
47
|
+
let a = c;
|
|
48
|
+
c.indexOf(":") !== -1 && (a = c.split(":").pop()), o.indexOf(a) === -1 && o.push(c);
|
|
49
|
+
}), t[s] = e[s]);
|
|
50
|
+
}
|
|
51
|
+
}), { consumers: t, producer: o };
|
|
52
|
+
}, R = (e, t) => {
|
|
53
|
+
let o = Object.keys(t || {}).reduce((i, r) => (r.indexOf(":") !== -1 && (i[r.split(":")[1]] = t[r]), i), {}), s = O(e);
|
|
54
|
+
return Object.keys(e || {}).forEach((i) => {
|
|
55
|
+
let r = e[i];
|
|
56
|
+
r != null && r.remotesInfo && Object.keys(r.remotesInfo).forEach((n) => {
|
|
57
|
+
let c = n.split(":")[1], a = t[n] || o[n] || t[c] || o[c];
|
|
58
|
+
a && (s[i].remotesInfo[n].matchedVersion = a, s[`${n}:${a}`] = { remoteEntry: a, version: a });
|
|
59
|
+
});
|
|
60
|
+
}), s;
|
|
61
|
+
}, v = (e, t) => {
|
|
62
|
+
let o = null, s = O(e);
|
|
63
|
+
if (Object.keys(e || {}).forEach((r) => {
|
|
64
|
+
let n = s[r];
|
|
65
|
+
n && Array.isArray(n.consumerList) && n.consumerList.length > 0 && (o = n);
|
|
66
|
+
}), !o)
|
|
67
|
+
return s;
|
|
68
|
+
let i = o.consumerList;
|
|
69
|
+
for (let r = 0; r < i.length; r++) {
|
|
70
|
+
let n = "", c = i[r];
|
|
71
|
+
if (Object.keys(t || {}).find((_) => {
|
|
72
|
+
let u = _;
|
|
73
|
+
return _.indexOf(":") !== -1 && (u = _.split(":")[1]), c.indexOf(u) !== -1 ? (n = _, true) : false;
|
|
74
|
+
})) {
|
|
75
|
+
let _ = t[n], u = c.split(":");
|
|
76
|
+
u[u.length - 1] = _, i[r] = u.join(":"), s[`${n}:${_}`] = { remoteEntry: _, version: _ };
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
return R(s, t);
|
|
80
|
+
}, F = (e = [], t) => {
|
|
81
|
+
var n;
|
|
82
|
+
let o = t || ((n = l().__FEDERATION__) == null ? void 0 : n.moduleInfo) || {}, s = {}, { consumers: i } = T(o), r = Object.keys(i).some((c) => {
|
|
83
|
+
var _;
|
|
84
|
+
let a = (_ = i[c]) == null ? void 0 : _.consumerList;
|
|
85
|
+
return Array.isArray(a) && a.length > 0;
|
|
86
|
+
});
|
|
87
|
+
return e.forEach((c) => {
|
|
88
|
+
c != null && c.key && (c != null && c.value) && (s[c.key] = c.value);
|
|
89
|
+
}), { status: "success", moduleInfo: r ? v(o, s) : R(o, s), overrides: s };
|
|
90
|
+
}, E = (e = l()) => {
|
|
91
|
+
let t = e, o = false;
|
|
92
|
+
return { name: h, beforeLoadRemoteSnapshot: (s) => {
|
|
93
|
+
var c;
|
|
94
|
+
let i = s == null ? void 0 : s.options;
|
|
95
|
+
if (i && i.inBrowser === false)
|
|
96
|
+
return;
|
|
97
|
+
let r = M(t);
|
|
98
|
+
if (!r || o)
|
|
99
|
+
return;
|
|
100
|
+
let n = g(t);
|
|
101
|
+
n.moduleInfo = Object.assign({}, n.moduleInfo || {}, r), o = true, (c = t.console) == null || c.warn("[Module Federation Devtools]: You are using the chrome devtool to proxy online module");
|
|
102
|
+
} };
|
|
103
|
+
}, B = (e = l()) => {
|
|
104
|
+
let t = e;
|
|
105
|
+
return { name: L, beforeRegisterRemote: (o) => {
|
|
106
|
+
var s;
|
|
107
|
+
try {
|
|
108
|
+
let i = o == null ? void 0 : o.remote;
|
|
109
|
+
if (!i)
|
|
110
|
+
return o;
|
|
111
|
+
let r = N(t), n = r[i.name] || r[i.alias || ""];
|
|
112
|
+
if (!n)
|
|
113
|
+
return o;
|
|
114
|
+
S(n) ? (m(i, "version"), i.entry = n) : (m(i, "entry"), i.version = n);
|
|
115
|
+
} catch (i) {
|
|
116
|
+
(s = t.console) == null || s.error(i);
|
|
117
|
+
}
|
|
118
|
+
return o;
|
|
119
|
+
} };
|
|
120
|
+
}, b = (e = l()) => {
|
|
121
|
+
let t = g(e);
|
|
122
|
+
return [B(e), E(e)].forEach((s) => {
|
|
123
|
+
var r, n;
|
|
124
|
+
((r = t.__GLOBAL_PLUGIN__) == null ? void 0 : r.some((c) => c.name === s.name)) || (n = t.__GLOBAL_PLUGIN__) == null || n.push(s);
|
|
125
|
+
}), t.__GLOBAL_PLUGIN__ || [];
|
|
126
|
+
}, A = (e, t) => {
|
|
127
|
+
var r, n;
|
|
128
|
+
let o = g(e), s = t(e);
|
|
129
|
+
return ((r = o.__GLOBAL_PLUGIN__) == null ? void 0 : r.some((c) => c.name === s.name)) || (n = o.__GLOBAL_PLUGIN__) == null || n.push(s), s;
|
|
130
|
+
}, k = (e = l()) => A(e, B), D = (e = l()) => A(e, E), V = (e = l()) => {
|
|
131
|
+
let t = x(e);
|
|
132
|
+
if (!t)
|
|
133
|
+
return;
|
|
134
|
+
t.removeItem(P), t.removeItem(G);
|
|
135
|
+
let o = p(t.getItem(f), {});
|
|
136
|
+
y(o) && (m(o, "overrides"), Object.keys(o).length ? t.setItem(f, JSON.stringify(o)) : t.removeItem(f));
|
|
137
|
+
};
|
|
138
|
+
exports.calculateMicroAppSnapshot = v;
|
|
139
|
+
exports.calculateSnapshot = R;
|
|
140
|
+
exports.createOverridePlugin = B;
|
|
141
|
+
exports.createSnapshotPlugin = E;
|
|
142
|
+
exports.getModuleInfo = F;
|
|
143
|
+
exports.registerOverridePlugin = k;
|
|
144
|
+
exports.registerRuntimePlugins = b;
|
|
145
|
+
exports.registerSnapshotPlugin = D;
|
|
146
|
+
exports.resetProxyStorage = V;
|
|
147
|
+
exports.separateType = T;
|
package/dist/lib/worker/index.js
CHANGED
|
@@ -1,4 +1,20 @@
|
|
|
1
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
|
+
};
|
|
2
18
|
var __async = (__this, __arguments, generator) => {
|
|
3
19
|
return new Promise((resolve, reject) => {
|
|
4
20
|
var fulfilled = (value) => {
|
|
@@ -32,12 +48,12 @@ const resolveTabId = (tabId) => __async(exports, null, function* () {
|
|
|
32
48
|
});
|
|
33
49
|
return activeTab == null ? void 0 : activeTab.id;
|
|
34
50
|
});
|
|
35
|
-
const broadcastActiveTab = (tabId) => {
|
|
51
|
+
const broadcastActiveTab = (tabId, payload) => {
|
|
36
52
|
try {
|
|
37
|
-
chrome.runtime.sendMessage({
|
|
53
|
+
chrome.runtime.sendMessage(__spreadValues({
|
|
38
54
|
type: import_messages.MESSAGE_ACTIVE_TAB_CHANGED,
|
|
39
55
|
tabId
|
|
40
|
-
});
|
|
56
|
+
}, payload));
|
|
41
57
|
} catch (error) {
|
|
42
58
|
console.warn(
|
|
43
59
|
"[Module Federation Devtools] Failed to broadcast active tab",
|
|
@@ -62,11 +78,11 @@ const openSidePanel = (tabId) => __async(exports, null, function* () {
|
|
|
62
78
|
if (sidePanel.open) {
|
|
63
79
|
yield sidePanel.open({ tabId: targetTabId });
|
|
64
80
|
}
|
|
65
|
-
broadcastActiveTab(targetTabId);
|
|
81
|
+
broadcastActiveTab(targetTabId, { reason: "side-panel" });
|
|
66
82
|
if (sidePanel.getOptions) {
|
|
67
83
|
try {
|
|
68
84
|
const options = yield sidePanel.getOptions({ tabId: targetTabId });
|
|
69
|
-
broadcastActiveTab(targetTabId);
|
|
85
|
+
broadcastActiveTab(targetTabId, { reason: "side-panel" });
|
|
70
86
|
return options;
|
|
71
87
|
} catch (error) {
|
|
72
88
|
console.warn("[Module Federation Devtools] getOptions failed", error);
|
|
@@ -113,7 +129,7 @@ chrome.tabs.onActivated.addListener((activeInfo) => __async(exports, null, funct
|
|
|
113
129
|
return;
|
|
114
130
|
}
|
|
115
131
|
try {
|
|
116
|
-
broadcastActiveTab(tabId);
|
|
132
|
+
broadcastActiveTab(tabId, { reason: "activated" });
|
|
117
133
|
} catch (error) {
|
|
118
134
|
console.warn(
|
|
119
135
|
"[Module Federation Devtools] Failed to handle tab activation",
|
|
@@ -122,12 +138,15 @@ chrome.tabs.onActivated.addListener((activeInfo) => __async(exports, null, funct
|
|
|
122
138
|
}
|
|
123
139
|
}));
|
|
124
140
|
chrome.tabs.onUpdated.addListener((tabId, changeInfo, tab) => {
|
|
125
|
-
if (changeInfo.status !== "complete") {
|
|
141
|
+
if (changeInfo.status !== "loading" && changeInfo.status !== "complete") {
|
|
126
142
|
return;
|
|
127
143
|
}
|
|
128
144
|
if (tab == null ? void 0 : tab.active) {
|
|
129
145
|
try {
|
|
130
|
-
broadcastActiveTab(tabId
|
|
146
|
+
broadcastActiveTab(tabId, {
|
|
147
|
+
reason: "updated",
|
|
148
|
+
status: changeInfo.status
|
|
149
|
+
});
|
|
131
150
|
} catch (error) {
|
|
132
151
|
console.warn(
|
|
133
152
|
"[Module Federation Devtools] Failed to handle tab update",
|
|
@@ -1,2 +1,5 @@
|
|
|
1
1
|
export declare const MESSAGE_OPEN_SIDE_PANEL = "mf-devtools/open-side-panel";
|
|
2
2
|
export declare const MESSAGE_ACTIVE_TAB_CHANGED = "mf-devtools/active-tab-changed";
|
|
3
|
+
export declare const MESSAGE_OBSERVABILITY_DEVTOOLS_EVENT = "mf-devtools/observability-event";
|
|
4
|
+
export declare const OBSERVABILITY_DEVTOOLS_SOURCE = "module-federation/observability";
|
|
5
|
+
export declare const OBSERVABILITY_DEVTOOLS_STORAGE_KEY = "__MF_DEVTOOLS_OBSERVABILITY_CONFIG__";
|