@module-federation/devtools 2.8.2 → 2.9.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 +125 -0
- package/dist/es/App.js +6 -1
- package/dist/es/App.module.js +1 -1
- package/dist/es/App_module.css +106 -0
- package/dist/es/component/Form/index_module.css +40 -0
- package/dist/es/component/Layout/index.js +38 -21
- package/dist/es/component/Layout/index_module.css +30 -0
- package/dist/es/component/SharedDepsExplorer/index.js +3 -6
- package/dist/es/utils/chrome/fast-refresh.js +84 -5
- package/dist/es/utils/chrome/index.js +4 -1
- package/dist/es/utils/chrome/observability.js +1 -0
- package/dist/es/utils/chrome/override-remote.js +6 -1
- package/dist/es/utils/chrome/resolve-basic-proxy-core.js +4 -0
- package/dist/es/utils/chrome/webmcp-entry.js +2 -0
- package/dist/es/utils/chrome/webmcp.js +468 -0
- package/dist/es/utils/sdk/index.js +6 -0
- package/dist/es/worker/index.js +1 -1
- package/dist/lib/App.js +6 -1
- package/dist/lib/App.module.js +1 -1
- package/dist/lib/App_module.css +106 -0
- package/dist/lib/component/Form/index_module.css +40 -0
- package/dist/lib/component/Layout/index.js +38 -21
- package/dist/lib/component/Layout/index_module.css +30 -0
- package/dist/lib/component/SharedDepsExplorer/index.js +3 -6
- package/dist/lib/utils/chrome/fast-refresh.js +83 -4
- package/dist/lib/utils/chrome/index.js +4 -1
- package/dist/lib/utils/chrome/observability.js +2 -0
- package/dist/lib/utils/chrome/override-remote.js +4 -1
- package/dist/lib/utils/chrome/resolve-basic-proxy-core.js +27 -0
- package/dist/lib/utils/chrome/webmcp-entry.js +2 -0
- package/dist/lib/utils/chrome/webmcp.js +484 -0
- package/dist/lib/utils/sdk/index.js +7 -0
- package/dist/lib/worker/index.js +1 -1
- package/dist/types/App.js +6 -1
- package/dist/types/App.module.js +1 -1
- package/dist/types/App_module.css +106 -0
- package/dist/types/component/Form/index_module.css +40 -0
- package/dist/types/component/Layout/index.js +38 -21
- package/dist/types/component/Layout/index_module.css +30 -0
- package/dist/types/component/SharedDepsExplorer/index.js +3 -6
- package/dist/types/src/utils/chrome/observability.d.ts +11 -0
- package/dist/types/src/utils/chrome/resolve-basic-proxy-core.d.ts +6 -0
- package/dist/types/src/utils/chrome/webmcp-entry.d.ts +1 -0
- package/dist/types/src/utils/chrome/webmcp.d.ts +25 -0
- package/dist/types/src/utils/sdk/index.d.ts +1 -0
- package/dist/types/utils/chrome/fast-refresh.js +83 -4
- package/dist/types/utils/chrome/index.js +4 -1
- package/dist/types/utils/chrome/observability.js +2 -0
- package/dist/types/utils/chrome/override-remote.js +4 -1
- package/dist/types/utils/chrome/resolve-basic-proxy-core.js +27 -0
- package/dist/types/utils/chrome/webmcp-entry.js +2 -0
- package/dist/types/utils/chrome/webmcp.js +484 -0
- package/dist/types/utils/sdk/index.js +7 -0
- package/dist/types/worker/index.js +1 -1
- package/package.json +5 -4
|
@@ -0,0 +1,468 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __defProps = Object.defineProperties;
|
|
3
|
+
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
4
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
7
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
8
|
+
var __spreadValues = (a, b) => {
|
|
9
|
+
for (var prop in b || (b = {}))
|
|
10
|
+
if (__hasOwnProp.call(b, prop))
|
|
11
|
+
__defNormalProp(a, prop, b[prop]);
|
|
12
|
+
if (__getOwnPropSymbols)
|
|
13
|
+
for (var prop of __getOwnPropSymbols(b)) {
|
|
14
|
+
if (__propIsEnum.call(b, prop))
|
|
15
|
+
__defNormalProp(a, prop, b[prop]);
|
|
16
|
+
}
|
|
17
|
+
return a;
|
|
18
|
+
};
|
|
19
|
+
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
20
|
+
var __async = (__this, __arguments, generator) => {
|
|
21
|
+
return new Promise((resolve, reject) => {
|
|
22
|
+
var fulfilled = (value) => {
|
|
23
|
+
try {
|
|
24
|
+
step(generator.next(value));
|
|
25
|
+
} catch (e) {
|
|
26
|
+
reject(e);
|
|
27
|
+
}
|
|
28
|
+
};
|
|
29
|
+
var rejected = (value) => {
|
|
30
|
+
try {
|
|
31
|
+
step(generator.throw(value));
|
|
32
|
+
} catch (e) {
|
|
33
|
+
reject(e);
|
|
34
|
+
}
|
|
35
|
+
};
|
|
36
|
+
var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
|
|
37
|
+
step((generator = generator.apply(__this, __arguments)).next());
|
|
38
|
+
});
|
|
39
|
+
};
|
|
40
|
+
import { MODULE_DEVTOOL_IDENTIFIER } from "@module-federation/sdk";
|
|
41
|
+
import {
|
|
42
|
+
BROWSER_ENV_KEY,
|
|
43
|
+
__FEDERATION_DEVTOOLS__,
|
|
44
|
+
__ENABLE_FAST_REFRESH__,
|
|
45
|
+
__EAGER_SHARE__
|
|
46
|
+
} from "../../template/constant";
|
|
47
|
+
import { sanitizePostMessagePayload } from "./safe-post-message";
|
|
48
|
+
import { normalizeObservabilityDevtoolsConfig } from "./observability-shared";
|
|
49
|
+
import {
|
|
50
|
+
OBSERVABILITY_DEVTOOLS_STORAGE_KEY,
|
|
51
|
+
OBSERVABILITY_DEVTOOLS_SOURCE
|
|
52
|
+
} from "./messages";
|
|
53
|
+
import { readSnapshotFromPage } from "./observability";
|
|
54
|
+
const coreModule = require("../../vendor/basic-proxy-core.js");
|
|
55
|
+
const core = coreModule.default || coreModule;
|
|
56
|
+
const isRecord = (value) => value !== null && typeof value === "object" && !Array.isArray(value);
|
|
57
|
+
const readConfig = () => {
|
|
58
|
+
const raw = localStorage.getItem(__FEDERATION_DEVTOOLS__);
|
|
59
|
+
const value = raw ? JSON.parse(raw) : {};
|
|
60
|
+
if (!isRecord(value))
|
|
61
|
+
throw new Error("Invalid devtools configuration in page storage.");
|
|
62
|
+
return value;
|
|
63
|
+
};
|
|
64
|
+
const persist = (values) => {
|
|
65
|
+
var _a;
|
|
66
|
+
const previous = Object.fromEntries(
|
|
67
|
+
Object.keys(values).map((key) => [key, localStorage.getItem(key)])
|
|
68
|
+
);
|
|
69
|
+
try {
|
|
70
|
+
for (const [key, value] of Object.entries(values)) {
|
|
71
|
+
if (value === null)
|
|
72
|
+
localStorage.removeItem(key);
|
|
73
|
+
else
|
|
74
|
+
localStorage.setItem(key, value);
|
|
75
|
+
}
|
|
76
|
+
} catch (error) {
|
|
77
|
+
for (const [key, value] of Object.entries(previous)) {
|
|
78
|
+
try {
|
|
79
|
+
if (value === null)
|
|
80
|
+
localStorage.removeItem(key);
|
|
81
|
+
else
|
|
82
|
+
localStorage.setItem(key, value);
|
|
83
|
+
} catch (e) {
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
throw error;
|
|
87
|
+
}
|
|
88
|
+
try {
|
|
89
|
+
window.postMessage(
|
|
90
|
+
sanitizePostMessagePayload({
|
|
91
|
+
moduleInfo: modules(),
|
|
92
|
+
share: ((_a = federation()) == null ? void 0 : _a.__SHARE__) || {}
|
|
93
|
+
}),
|
|
94
|
+
location.origin
|
|
95
|
+
);
|
|
96
|
+
} catch (e) {
|
|
97
|
+
}
|
|
98
|
+
};
|
|
99
|
+
const federation = () => window.__FEDERATION__ || window.__VMOK__;
|
|
100
|
+
const modules = () => {
|
|
101
|
+
var _a;
|
|
102
|
+
return ((_a = federation()) == null ? void 0 : _a.moduleInfo) || {};
|
|
103
|
+
};
|
|
104
|
+
const reloadResult = () => ({
|
|
105
|
+
saved: true,
|
|
106
|
+
reloadRequired: true,
|
|
107
|
+
instruction: "Reload this page using browser navigation, then call mf_get_state to verify. No navigation has been started by this tool."
|
|
108
|
+
});
|
|
109
|
+
const boolean = (value, name) => {
|
|
110
|
+
if (typeof value !== "boolean")
|
|
111
|
+
throw new Error(`${name} must be a boolean.`);
|
|
112
|
+
return value;
|
|
113
|
+
};
|
|
114
|
+
const validateRules = (value) => {
|
|
115
|
+
if (!Array.isArray(value) || value.length > 100)
|
|
116
|
+
throw new Error("rules must be an array of at most 100 rules.");
|
|
117
|
+
const names = /* @__PURE__ */ new Set();
|
|
118
|
+
return value.map((rule) => {
|
|
119
|
+
if (!isRecord(rule) || typeof rule.key !== "string" || !rule.key.trim() || typeof rule.value !== "string" || !rule.value.trim())
|
|
120
|
+
throw new Error("Each rule needs a nonempty key and value.");
|
|
121
|
+
const key = rule.key.trim();
|
|
122
|
+
const destination = rule.value.trim();
|
|
123
|
+
if (key.split(":").some(
|
|
124
|
+
(part) => ["__proto__", "constructor", "prototype"].includes(part)
|
|
125
|
+
) || names.has(key))
|
|
126
|
+
throw new Error(`Invalid or duplicate remote key: ${key}`);
|
|
127
|
+
names.add(key);
|
|
128
|
+
if (/^(?:[a-z][a-z\d+.-]*:|\/\/)/i.test(destination)) {
|
|
129
|
+
const url = new URL(destination, location.href);
|
|
130
|
+
if (!["http:", "https:"].includes(url.protocol) || url.username || url.password)
|
|
131
|
+
throw new Error(
|
|
132
|
+
"Remote URLs must use HTTP(S), without embedded credentials."
|
|
133
|
+
);
|
|
134
|
+
} else if (!/^[\w.*^~<>=|+ -]+$/.test(destination)) {
|
|
135
|
+
throw new Error("Use an absolute HTTP(S) URL or a registry version/tag.");
|
|
136
|
+
}
|
|
137
|
+
return {
|
|
138
|
+
key,
|
|
139
|
+
value: destination,
|
|
140
|
+
checked: rule.checked === void 0 ? true : boolean(rule.checked, "checked")
|
|
141
|
+
};
|
|
142
|
+
});
|
|
143
|
+
};
|
|
144
|
+
const writeProxy = (rules, clip) => {
|
|
145
|
+
const active = rules.filter((rule) => rule.checked);
|
|
146
|
+
const snapshot = core.getModuleInfo(active, modules());
|
|
147
|
+
if (clip) {
|
|
148
|
+
for (const entry of Object.values(snapshot.moduleInfo)) {
|
|
149
|
+
if (!isRecord(entry))
|
|
150
|
+
continue;
|
|
151
|
+
if (entry.modules)
|
|
152
|
+
entry.modules = [];
|
|
153
|
+
if (entry.shared)
|
|
154
|
+
entry.shared = [];
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
persist({
|
|
158
|
+
[MODULE_DEVTOOL_IDENTIFIER]: active.length ? JSON.stringify(snapshot.moduleInfo) : null,
|
|
159
|
+
[BROWSER_ENV_KEY]: active.length ? "true" : null,
|
|
160
|
+
[__FEDERATION_DEVTOOLS__]: JSON.stringify(__spreadProps(__spreadValues({}, readConfig()), {
|
|
161
|
+
overrides: snapshot.overrides,
|
|
162
|
+
proxyRules: rules,
|
|
163
|
+
enableClip: clip
|
|
164
|
+
}))
|
|
165
|
+
});
|
|
166
|
+
return __spreadProps(__spreadValues({}, reloadResult()), { rules, clip });
|
|
167
|
+
};
|
|
168
|
+
const state = () => {
|
|
169
|
+
var _a, _b;
|
|
170
|
+
return {
|
|
171
|
+
url: location.href,
|
|
172
|
+
moduleInfo: modules(),
|
|
173
|
+
shared: ((_a = federation()) == null ? void 0 : _a.__SHARE__) || {},
|
|
174
|
+
registeredPlugins: (((_b = federation()) == null ? void 0 : _b.__GLOBAL_PLUGIN__) || []).map(
|
|
175
|
+
(plugin) => plugin.name
|
|
176
|
+
),
|
|
177
|
+
config: readConfig(),
|
|
178
|
+
observability: readSnapshotFromPage(OBSERVABILITY_DEVTOOLS_STORAGE_KEY)
|
|
179
|
+
};
|
|
180
|
+
};
|
|
181
|
+
const schema = (properties = {}, required = []) => ({
|
|
182
|
+
type: "object",
|
|
183
|
+
properties,
|
|
184
|
+
required,
|
|
185
|
+
additionalProperties: false
|
|
186
|
+
});
|
|
187
|
+
const boolSchema = { type: "boolean" };
|
|
188
|
+
const ruleSchema = schema(
|
|
189
|
+
{
|
|
190
|
+
key: { type: "string", minLength: 1 },
|
|
191
|
+
value: { type: "string", minLength: 1 },
|
|
192
|
+
checked: boolSchema
|
|
193
|
+
},
|
|
194
|
+
["key", "value"]
|
|
195
|
+
);
|
|
196
|
+
const createDevtoolsTools = () => {
|
|
197
|
+
const tool = (name, description, inputSchema, readOnly, execute) => ({
|
|
198
|
+
name,
|
|
199
|
+
description,
|
|
200
|
+
inputSchema,
|
|
201
|
+
annotations: { readOnlyHint: readOnly },
|
|
202
|
+
execute: (..._0) => __async(void 0, [..._0], function* (input = {}) {
|
|
203
|
+
try {
|
|
204
|
+
if (!isRecord(input) || Object.keys(input).some(
|
|
205
|
+
(key) => !Object.hasOwn(inputSchema.properties, key)
|
|
206
|
+
))
|
|
207
|
+
throw new Error("Unexpected tool arguments.");
|
|
208
|
+
const result = yield execute(input);
|
|
209
|
+
return {
|
|
210
|
+
content: [
|
|
211
|
+
{
|
|
212
|
+
type: "text",
|
|
213
|
+
text: JSON.stringify(sanitizePostMessagePayload(result))
|
|
214
|
+
}
|
|
215
|
+
]
|
|
216
|
+
};
|
|
217
|
+
} catch (error) {
|
|
218
|
+
return {
|
|
219
|
+
isError: true,
|
|
220
|
+
content: [
|
|
221
|
+
{
|
|
222
|
+
type: "text",
|
|
223
|
+
text: error instanceof Error ? error.message : String(error)
|
|
224
|
+
}
|
|
225
|
+
]
|
|
226
|
+
};
|
|
227
|
+
}
|
|
228
|
+
})
|
|
229
|
+
});
|
|
230
|
+
return [
|
|
231
|
+
tool(
|
|
232
|
+
"mf_get_state",
|
|
233
|
+
"Read Module Federation runtime, proxy/HMR settings and loading reports for this page. Saved settings may require a page reload before taking effect.",
|
|
234
|
+
schema(),
|
|
235
|
+
true,
|
|
236
|
+
state
|
|
237
|
+
),
|
|
238
|
+
tool(
|
|
239
|
+
"mf_get_modules",
|
|
240
|
+
"Read all module snapshots, or one snapshot by its exact module ID.",
|
|
241
|
+
schema({ moduleId: { type: "string" } }),
|
|
242
|
+
true,
|
|
243
|
+
({ moduleId }) => {
|
|
244
|
+
if (moduleId === void 0)
|
|
245
|
+
return modules();
|
|
246
|
+
if (typeof moduleId !== "string" || !Object.hasOwn(modules(), moduleId))
|
|
247
|
+
throw new Error(
|
|
248
|
+
"Unknown module ID. Call mf_get_modules without arguments to list IDs."
|
|
249
|
+
);
|
|
250
|
+
return modules()[moduleId];
|
|
251
|
+
}
|
|
252
|
+
),
|
|
253
|
+
tool(
|
|
254
|
+
"mf_get_dependencies",
|
|
255
|
+
"Read dependency graph data: module snapshots, consumers and remote IDs.",
|
|
256
|
+
schema(),
|
|
257
|
+
true,
|
|
258
|
+
() => __spreadValues({ modules: modules() }, core.separateType(modules()))
|
|
259
|
+
),
|
|
260
|
+
tool(
|
|
261
|
+
"mf_get_shared",
|
|
262
|
+
"Read shared dependency scopes, versions and loaded state. Functions are returned as placeholders and are never invoked.",
|
|
263
|
+
schema(),
|
|
264
|
+
true,
|
|
265
|
+
() => {
|
|
266
|
+
var _a;
|
|
267
|
+
return ((_a = federation()) == null ? void 0 : _a.__SHARE__) || {};
|
|
268
|
+
}
|
|
269
|
+
),
|
|
270
|
+
tool(
|
|
271
|
+
"mf_set_proxy",
|
|
272
|
+
"Replace all proxy rules on this page. key is a remote name/ID; value is an HTTP(S) manifest/entry URL or registry version. checked=false disables a rule. clip removes module/shared snapshot lists. Returns reloadRequired; CSP/CORS still apply.",
|
|
273
|
+
schema(
|
|
274
|
+
{
|
|
275
|
+
rules: { type: "array", maxItems: 100, items: ruleSchema },
|
|
276
|
+
clip: boolSchema
|
|
277
|
+
},
|
|
278
|
+
["rules"]
|
|
279
|
+
),
|
|
280
|
+
false,
|
|
281
|
+
({ rules, clip }) => writeProxy(
|
|
282
|
+
validateRules(rules),
|
|
283
|
+
clip === void 0 ? Boolean(readConfig().enableClip) : boolean(clip, "clip")
|
|
284
|
+
)
|
|
285
|
+
),
|
|
286
|
+
tool(
|
|
287
|
+
"mf_clear_proxy",
|
|
288
|
+
"Clear all proxy rules and injected snapshot data for this page, preserving HMR and tracing settings. Reload afterwards.",
|
|
289
|
+
schema(),
|
|
290
|
+
false,
|
|
291
|
+
() => writeProxy([], Boolean(readConfig().enableClip))
|
|
292
|
+
),
|
|
293
|
+
tool(
|
|
294
|
+
"mf_set_hmr",
|
|
295
|
+
"Enable or disable the extension React Fast Refresh/shared development React replacement for this page. Save first, then reload so document_start scripts apply it before React loads. Eager shares may require an additional automatic reload.",
|
|
296
|
+
schema({ enabled: boolSchema }, ["enabled"]),
|
|
297
|
+
false,
|
|
298
|
+
({ enabled }) => {
|
|
299
|
+
const next = __spreadProps(__spreadValues({}, readConfig()), {
|
|
300
|
+
[__ENABLE_FAST_REFRESH__]: boolean(enabled, "enabled")
|
|
301
|
+
});
|
|
302
|
+
if (!enabled)
|
|
303
|
+
delete next[__EAGER_SHARE__];
|
|
304
|
+
persist({ [__FEDERATION_DEVTOOLS__]: JSON.stringify(next) });
|
|
305
|
+
return reloadResult();
|
|
306
|
+
}
|
|
307
|
+
),
|
|
308
|
+
tool(
|
|
309
|
+
"mf_configure_loading_trace",
|
|
310
|
+
"Configure the extension Loading Trace plugin on this page. enabled=false disables it on next reload. Does not disable user-installed observability plugins.",
|
|
311
|
+
schema(
|
|
312
|
+
{
|
|
313
|
+
enabled: boolSchema,
|
|
314
|
+
level: { type: "string", enum: ["error", "summary", "verbose"] },
|
|
315
|
+
maxEvents: { type: "integer", minimum: 10, maximum: 1e3 },
|
|
316
|
+
console: boolSchema,
|
|
317
|
+
browserEnabled: boolSchema,
|
|
318
|
+
scope: { type: "string", minLength: 1 },
|
|
319
|
+
mode: { type: "string", enum: ["development", "production"] },
|
|
320
|
+
printStart: boolSchema
|
|
321
|
+
},
|
|
322
|
+
["enabled"]
|
|
323
|
+
),
|
|
324
|
+
false,
|
|
325
|
+
(input) => {
|
|
326
|
+
var _a, _b, _c, _d;
|
|
327
|
+
const enabled = boolean(input.enabled, "enabled");
|
|
328
|
+
for (const key of ["console", "browserEnabled", "printStart"])
|
|
329
|
+
if (input[key] !== void 0)
|
|
330
|
+
boolean(input[key], key);
|
|
331
|
+
if (input.level !== void 0 && !["error", "summary", "verbose"].includes(String(input.level)))
|
|
332
|
+
throw new Error("Invalid trace level.");
|
|
333
|
+
if (input.mode !== void 0 && !["development", "production"].includes(String(input.mode)))
|
|
334
|
+
throw new Error("Invalid trace mode.");
|
|
335
|
+
if (input.scope !== void 0 && (typeof input.scope !== "string" || !input.scope.trim()))
|
|
336
|
+
throw new Error("Invalid trace scope.");
|
|
337
|
+
if (input.maxEvents !== void 0 && (typeof input.maxEvents !== "number" || !Number.isInteger(input.maxEvents) || input.maxEvents < 10 || input.maxEvents > 1e3))
|
|
338
|
+
throw new Error("maxEvents must be an integer between 10 and 1000.");
|
|
339
|
+
const raw = localStorage.getItem(OBSERVABILITY_DEVTOOLS_STORAGE_KEY);
|
|
340
|
+
const old = normalizeObservabilityDevtoolsConfig(
|
|
341
|
+
raw ? JSON.parse(raw) : void 0
|
|
342
|
+
);
|
|
343
|
+
const config = normalizeObservabilityDevtoolsConfig(__spreadProps(__spreadValues(__spreadValues({}, old), input), {
|
|
344
|
+
enabled,
|
|
345
|
+
browser: {
|
|
346
|
+
enabled: (_a = input.browserEnabled) != null ? _a : old.browser.enabled,
|
|
347
|
+
scope: (_b = input.scope) != null ? _b : old.browser.scope,
|
|
348
|
+
mode: (_c = input.mode) != null ? _c : old.browser.mode
|
|
349
|
+
},
|
|
350
|
+
trace: { printStart: (_d = input.printStart) != null ? _d : old.trace.printStart }
|
|
351
|
+
}));
|
|
352
|
+
persist({
|
|
353
|
+
[OBSERVABILITY_DEVTOOLS_STORAGE_KEY]: enabled ? JSON.stringify(config) : null
|
|
354
|
+
});
|
|
355
|
+
window.postMessage(
|
|
356
|
+
{
|
|
357
|
+
source: OBSERVABILITY_DEVTOOLS_SOURCE,
|
|
358
|
+
kind: "config-saved",
|
|
359
|
+
config
|
|
360
|
+
},
|
|
361
|
+
location.origin
|
|
362
|
+
);
|
|
363
|
+
return __spreadProps(__spreadValues({}, reloadResult()), { config });
|
|
364
|
+
}
|
|
365
|
+
),
|
|
366
|
+
tool(
|
|
367
|
+
"mf_get_loading_reports",
|
|
368
|
+
"Read current loading reports and trace configuration from all available observability scopes.",
|
|
369
|
+
schema(),
|
|
370
|
+
true,
|
|
371
|
+
() => readSnapshotFromPage(OBSERVABILITY_DEVTOOLS_STORAGE_KEY)
|
|
372
|
+
),
|
|
373
|
+
tool(
|
|
374
|
+
"mf_export_snapshot",
|
|
375
|
+
"Export a JSON snapshot of modules, shared dependencies, proxy/HMR configuration and loading reports. Returns data without initiating a download.",
|
|
376
|
+
schema(),
|
|
377
|
+
true,
|
|
378
|
+
() => __spreadValues({ exportedAt: (/* @__PURE__ */ new Date()).toISOString() }, state())
|
|
379
|
+
)
|
|
380
|
+
];
|
|
381
|
+
};
|
|
382
|
+
const getModelContext = () => [document.modelContext, navigator.modelContext].find(
|
|
383
|
+
(context) => typeof (context == null ? void 0 : context.registerTool) === "function"
|
|
384
|
+
);
|
|
385
|
+
const registerDevtoolsWebMCP = (..._0) => __async(void 0, [..._0], function* (context = getModelContext()) {
|
|
386
|
+
if (typeof (context == null ? void 0 : context.registerTool) !== "function")
|
|
387
|
+
return () => __async(void 0, null, function* () {
|
|
388
|
+
});
|
|
389
|
+
const registered = [];
|
|
390
|
+
const cleanup = () => __async(void 0, null, function* () {
|
|
391
|
+
for (const name of registered.splice(0)) {
|
|
392
|
+
try {
|
|
393
|
+
if (typeof context.unregisterTool === "function")
|
|
394
|
+
yield context.unregisterTool(name);
|
|
395
|
+
} catch (e) {
|
|
396
|
+
}
|
|
397
|
+
}
|
|
398
|
+
});
|
|
399
|
+
try {
|
|
400
|
+
for (const tool of createDevtoolsTools()) {
|
|
401
|
+
yield context.registerTool(tool);
|
|
402
|
+
registered.push(tool.name);
|
|
403
|
+
}
|
|
404
|
+
} catch (error) {
|
|
405
|
+
yield cleanup();
|
|
406
|
+
throw error;
|
|
407
|
+
}
|
|
408
|
+
return cleanup;
|
|
409
|
+
});
|
|
410
|
+
const startDevtoolsWebMCP = (retryMs = 250, maxAttempts = 120) => {
|
|
411
|
+
const diagnostic = {
|
|
412
|
+
status: "waiting",
|
|
413
|
+
attempts: 0,
|
|
414
|
+
tools: [],
|
|
415
|
+
error: void 0
|
|
416
|
+
};
|
|
417
|
+
window.__MF_DEVTOOLS_WEBMCP__ = diagnostic;
|
|
418
|
+
let timer;
|
|
419
|
+
let stopped = false;
|
|
420
|
+
let cleanup;
|
|
421
|
+
const attempt = () => __async(void 0, null, function* () {
|
|
422
|
+
if (stopped)
|
|
423
|
+
return;
|
|
424
|
+
diagnostic.attempts++;
|
|
425
|
+
const context = getModelContext();
|
|
426
|
+
if (!context) {
|
|
427
|
+
if (diagnostic.attempts < maxAttempts) {
|
|
428
|
+
timer = setTimeout(() => void attempt(), retryMs);
|
|
429
|
+
} else {
|
|
430
|
+
diagnostic.status = "unavailable";
|
|
431
|
+
console.warn(
|
|
432
|
+
"[Module Federation Devtools] WebMCP host API unavailable",
|
|
433
|
+
diagnostic
|
|
434
|
+
);
|
|
435
|
+
}
|
|
436
|
+
return;
|
|
437
|
+
}
|
|
438
|
+
diagnostic.status = "registering";
|
|
439
|
+
try {
|
|
440
|
+
cleanup = yield registerDevtoolsWebMCP(context);
|
|
441
|
+
if (stopped) {
|
|
442
|
+
yield cleanup();
|
|
443
|
+
return;
|
|
444
|
+
}
|
|
445
|
+
diagnostic.tools = createDevtoolsTools().map(({ name }) => name);
|
|
446
|
+
diagnostic.status = "registered";
|
|
447
|
+
} catch (error) {
|
|
448
|
+
diagnostic.status = "error";
|
|
449
|
+
diagnostic.error = error instanceof Error ? error.message : String(error);
|
|
450
|
+
console.warn(
|
|
451
|
+
"[Module Federation Devtools] WebMCP registration failed",
|
|
452
|
+
error
|
|
453
|
+
);
|
|
454
|
+
}
|
|
455
|
+
});
|
|
456
|
+
void attempt();
|
|
457
|
+
return () => __async(void 0, null, function* () {
|
|
458
|
+
stopped = true;
|
|
459
|
+
clearTimeout(timer);
|
|
460
|
+
yield cleanup == null ? void 0 : cleanup();
|
|
461
|
+
});
|
|
462
|
+
};
|
|
463
|
+
export {
|
|
464
|
+
createDevtoolsTools,
|
|
465
|
+
getModelContext,
|
|
466
|
+
registerDevtoolsWebMCP,
|
|
467
|
+
startDevtoolsWebMCP
|
|
468
|
+
};
|
|
@@ -36,7 +36,12 @@ const reloadPage = () => {
|
|
|
36
36
|
(_a = globalThis == null ? void 0 : globalThis.location) == null ? void 0 : _a.reload();
|
|
37
37
|
};
|
|
38
38
|
const validateCustom = (schema) => schema == null ? void 0 : schema.endsWith(".json");
|
|
39
|
+
const REACT_19_DEV_VERSION = "19.2.4";
|
|
39
40
|
const getUnpkgUrl = (pkg, version) => {
|
|
41
|
+
if (/^19\./.test(version) && ["react", "react-dom", "react-dom/client"].includes(pkg)) {
|
|
42
|
+
const name = pkg === "react" ? "react" : "react-dom";
|
|
43
|
+
return `https://unpkg.com/umd-react@${REACT_19_DEV_VERSION}/dist/${name}.development.js`;
|
|
44
|
+
}
|
|
40
45
|
if (pkg === "react") {
|
|
41
46
|
return `https://unpkg.com/react@${version}/umd/react.development.js`;
|
|
42
47
|
} else if (pkg === "react-dom") {
|
|
@@ -57,6 +62,7 @@ const definePropertyGlobalVal = (target, key, val) => {
|
|
|
57
62
|
});
|
|
58
63
|
};
|
|
59
64
|
export {
|
|
65
|
+
REACT_19_DEV_VERSION,
|
|
60
66
|
definePropertyGlobalVal,
|
|
61
67
|
getLocalStorage,
|
|
62
68
|
getUnpkgUrl,
|
package/dist/es/worker/index.js
CHANGED
|
@@ -45,7 +45,7 @@ import {
|
|
|
45
45
|
var require_worker = __commonJS({
|
|
46
46
|
"src/worker/index.ts"(exports) {
|
|
47
47
|
const SIDE_PANEL_PATH = "html/main/index.html";
|
|
48
|
-
const getSidePanel = () => chrome == null ? void 0 : chrome.sidePanel;
|
|
48
|
+
const getSidePanel = () => chrome.runtime.getManifest().side_panel ? chrome == null ? void 0 : chrome.sidePanel : void 0;
|
|
49
49
|
const resolveTabId = (tabId) => __async(exports, null, function* () {
|
|
50
50
|
if (typeof tabId === "number") {
|
|
51
51
|
return tabId;
|
package/dist/lib/App.js
CHANGED
|
@@ -274,6 +274,8 @@ const InnerApp = (props) => {
|
|
|
274
274
|
const bootstrap = () => __async(void 0, null, function* () {
|
|
275
275
|
const tab = yield (0, import_utils.syncActiveTab)();
|
|
276
276
|
setInspectedTab(tab || void 0);
|
|
277
|
+
if (typeof (tab == null ? void 0 : tab.id) !== "number")
|
|
278
|
+
return;
|
|
277
279
|
const detach = yield (0, import_utils.getGlobalModuleInfo)(
|
|
278
280
|
(info) => applyModuleUpdate(info)
|
|
279
281
|
);
|
|
@@ -385,6 +387,9 @@ const InnerApp = (props) => {
|
|
|
385
387
|
}, [activePanel, applyModuleUpdate]);
|
|
386
388
|
const renderContent = () => {
|
|
387
389
|
var _a;
|
|
390
|
+
if (typeof (inspectedTab == null ? void 0 : inspectedTab.id) !== "number") {
|
|
391
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_web_react.Empty, { description: t("app.header.scope.waiting") });
|
|
392
|
+
}
|
|
388
393
|
switch (activePanel) {
|
|
389
394
|
case "moduleInfo":
|
|
390
395
|
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
@@ -425,7 +430,7 @@ const InnerApp = (props) => {
|
|
|
425
430
|
import_SharedDepsExplorer.default,
|
|
426
431
|
{
|
|
427
432
|
shareData: JSON.parse(
|
|
428
|
-
JSON.stringify((_a = window.__FEDERATION__) == null ? void 0 : _a.__SHARE__)
|
|
433
|
+
JSON.stringify(((_a = window.__FEDERATION__) == null ? void 0 : _a.__SHARE__) || {})
|
|
429
434
|
)
|
|
430
435
|
}
|
|
431
436
|
);
|
package/dist/lib/App.module.js
CHANGED
|
@@ -21,4 +21,4 @@ __export(App_module_exports, {
|
|
|
21
21
|
});
|
|
22
22
|
module.exports = __toCommonJS(App_module_exports);
|
|
23
23
|
var import_App_module = require("./App_module.css");
|
|
24
|
-
var App_module_default = { "shell": "shell_ae2ee", "sidebar": "sidebar_ae2ee", "tabItem": "tabItem_ae2ee", "activeTab": "activeTab_ae2ee", "panel": "panel_ae2ee", "header": "header_ae2ee", "headerTop": "headerTop_ae2ee", "branding": "branding_ae2ee", "logo": "logo_ae2ee", "subtitle": "subtitle_ae2ee", "meta": "meta_ae2ee", "scope": "scope_ae2ee", "scopeLabel": "scopeLabel_ae2ee", "stats": "stats_ae2ee", "statBlock": "statBlock_ae2ee", "statValue": "statValue_ae2ee", "statLabel": "statLabel_ae2ee", "body": "body_ae2ee", "content": "content_ae2ee", "emptyState": "emptyState_ae2ee", "empty": "empty_ae2ee", "placeholder": "placeholder_ae2ee", "overrideArco": "overrideArco_ae2ee" };
|
|
24
|
+
var App_module_default = { "shell": "shell_ae2ee", "sidebar": "sidebar_ae2ee", "tabItem": "tabItem_ae2ee", "activeTab": "activeTab_ae2ee", "panel": "panel_ae2ee", "header": "header_ae2ee", "headerTop": "headerTop_ae2ee", "branding": "branding_ae2ee", "logo": "logo_ae2ee", "subtitle": "subtitle_ae2ee", "meta": "meta_ae2ee", "scope": "scope_ae2ee", "scopeLabel": "scopeLabel_ae2ee", "stats": "stats_ae2ee", "statBlock": "statBlock_ae2ee", "statValue": "statValue_ae2ee", "statLabel": "statLabel_ae2ee", "body": "body_ae2ee", "content": "content_ae2ee", "emptyState": "emptyState_ae2ee", "empty": "empty_ae2ee", "placeholder": "placeholder_ae2ee", "overrideArco": "overrideArco_ae2ee", "headerActions": "headerActions_ae2ee" };
|
package/dist/lib/App_module.css
CHANGED
|
@@ -304,4 +304,110 @@ body[arco-theme=dark] {
|
|
|
304
304
|
|
|
305
305
|
.shell_ae2ee.arco-theme-dark {
|
|
306
306
|
background: radial-gradient(circle at 10% 20%, rgba(15, 23, 42, 0.9) 0%, rgba(15, 23, 42, 0.98) 55%), linear-gradient(135deg, var(--color-bg-1, #020617) 0%, var(--color-bg-2, #020617) 100%);
|
|
307
|
+
}
|
|
308
|
+
|
|
309
|
+
html[data-devtools-view="popup"] {
|
|
310
|
+
overflow: hidden;
|
|
311
|
+
}
|
|
312
|
+
html[data-devtools-view="popup"] body {
|
|
313
|
+
margin: 0;
|
|
314
|
+
height: 100%;
|
|
315
|
+
overflow: hidden;
|
|
316
|
+
}
|
|
317
|
+
html[data-devtools-view="popup"] .shell_ae2ee {
|
|
318
|
+
height: 100vh;
|
|
319
|
+
min-height: 0;
|
|
320
|
+
padding: 10px;
|
|
321
|
+
gap: 8px;
|
|
322
|
+
flex-direction: column;
|
|
323
|
+
background: var(--color-bg-1, #fff);
|
|
324
|
+
}
|
|
325
|
+
html[data-devtools-view="popup"] .sidebar_ae2ee {
|
|
326
|
+
flex: 0 0 auto;
|
|
327
|
+
width: 100%;
|
|
328
|
+
min-width: 0;
|
|
329
|
+
padding: 4px;
|
|
330
|
+
gap: 2px;
|
|
331
|
+
border-radius: 8px;
|
|
332
|
+
box-shadow: none;
|
|
333
|
+
}
|
|
334
|
+
html[data-devtools-view="popup"] .tabItem_ae2ee {
|
|
335
|
+
padding: 7px 9px;
|
|
336
|
+
font-size: 12px;
|
|
337
|
+
border-radius: 5px;
|
|
338
|
+
letter-spacing: 0;
|
|
339
|
+
text-transform: none;
|
|
340
|
+
}
|
|
341
|
+
html[data-devtools-view="popup"] .tabItem_ae2ee:focus-visible {
|
|
342
|
+
outline: 2px solid var(--color-primary-6, #165dff);
|
|
343
|
+
outline-offset: -2px;
|
|
344
|
+
}
|
|
345
|
+
html[data-devtools-view="popup"] .panel_ae2ee {
|
|
346
|
+
flex: 1 1;
|
|
347
|
+
min-height: 0;
|
|
348
|
+
padding: 12px;
|
|
349
|
+
gap: 10px;
|
|
350
|
+
border-radius: 8px;
|
|
351
|
+
box-shadow: none;
|
|
352
|
+
overflow: hidden;
|
|
353
|
+
}
|
|
354
|
+
html[data-devtools-view="popup"] .header_ae2ee {
|
|
355
|
+
flex: 0 0 auto;
|
|
356
|
+
gap: 6px;
|
|
357
|
+
}
|
|
358
|
+
html[data-devtools-view="popup"] .logo_ae2ee {
|
|
359
|
+
font-size: 16px;
|
|
360
|
+
}
|
|
361
|
+
html[data-devtools-view="popup"] .subtitle_ae2ee,
|
|
362
|
+
html[data-devtools-view="popup"] .scopeLabel_ae2ee {
|
|
363
|
+
display: none;
|
|
364
|
+
}
|
|
365
|
+
html[data-devtools-view="popup"] .headerActions_ae2ee {
|
|
366
|
+
display: flex;
|
|
367
|
+
align-items: center;
|
|
368
|
+
gap: 6px;
|
|
369
|
+
}
|
|
370
|
+
html[data-devtools-view="popup"] .meta_ae2ee {
|
|
371
|
+
align-items: center;
|
|
372
|
+
gap: 8px;
|
|
373
|
+
flex-wrap: nowrap;
|
|
374
|
+
}
|
|
375
|
+
html[data-devtools-view="popup"] .scope_ae2ee {
|
|
376
|
+
min-width: 0;
|
|
377
|
+
flex: 1 1;
|
|
378
|
+
overflow: hidden;
|
|
379
|
+
}
|
|
380
|
+
html[data-devtools-view="popup"] .scope_ae2ee .arco-tag {
|
|
381
|
+
max-width: 100%;
|
|
382
|
+
overflow: hidden;
|
|
383
|
+
text-overflow: ellipsis;
|
|
384
|
+
}
|
|
385
|
+
html[data-devtools-view="popup"] .stats_ae2ee {
|
|
386
|
+
flex: 0 0 auto;
|
|
387
|
+
gap: 12px;
|
|
388
|
+
width: auto;
|
|
389
|
+
}
|
|
390
|
+
html[data-devtools-view="popup"] .statBlock_ae2ee {
|
|
391
|
+
padding: 0;
|
|
392
|
+
min-width: 0;
|
|
393
|
+
flex-direction: row;
|
|
394
|
+
align-items: baseline;
|
|
395
|
+
gap: 4px;
|
|
396
|
+
border: 0;
|
|
397
|
+
background: none;
|
|
398
|
+
box-shadow: none;
|
|
399
|
+
}
|
|
400
|
+
html[data-devtools-view="popup"] .statValue_ae2ee {
|
|
401
|
+
font-size: 14px;
|
|
402
|
+
}
|
|
403
|
+
html[data-devtools-view="popup"] .statLabel_ae2ee {
|
|
404
|
+
font-size: 10px;
|
|
405
|
+
text-transform: none;
|
|
406
|
+
}
|
|
407
|
+
html[data-devtools-view="popup"] .body_ae2ee {
|
|
408
|
+
flex: 1 1;
|
|
409
|
+
}
|
|
410
|
+
html[data-devtools-view="popup"] .content_ae2ee {
|
|
411
|
+
flex: 1 1;
|
|
412
|
+
overscroll-behavior: contain;
|
|
307
413
|
}
|
|
@@ -195,4 +195,44 @@
|
|
|
195
195
|
align-items: center;
|
|
196
196
|
justify-content: center;
|
|
197
197
|
display: flex;
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
html[data-devtools-view="popup"] .wrapper_20b79,
|
|
201
|
+
html[data-devtools-view="popup"] .rules_20b79 {
|
|
202
|
+
gap: 10px;
|
|
203
|
+
}
|
|
204
|
+
html[data-devtools-view="popup"] .sectionHeader_20b79 {
|
|
205
|
+
padding: 8px;
|
|
206
|
+
gap: 8px;
|
|
207
|
+
flex-wrap: wrap;
|
|
208
|
+
}
|
|
209
|
+
html[data-devtools-view="popup"] .titleRow_20b79 {
|
|
210
|
+
font-size: 13px;
|
|
211
|
+
flex-wrap: wrap;
|
|
212
|
+
gap: 6px;
|
|
213
|
+
}
|
|
214
|
+
html[data-devtools-view="popup"] .subtitle_20b79 {
|
|
215
|
+
display: none;
|
|
216
|
+
}
|
|
217
|
+
html[data-devtools-view="popup"] .ruleCard_20b79 {
|
|
218
|
+
padding: 10px;
|
|
219
|
+
gap: 6px;
|
|
220
|
+
border-radius: 6px;
|
|
221
|
+
box-shadow: none;
|
|
222
|
+
}
|
|
223
|
+
html[data-devtools-view="popup"] .inputs_20b79 {
|
|
224
|
+
gap: 8px;
|
|
225
|
+
}
|
|
226
|
+
html[data-devtools-view="popup"] .field_20b79 {
|
|
227
|
+
min-width: 0;
|
|
228
|
+
margin-bottom: 0;
|
|
229
|
+
}
|
|
230
|
+
html[data-devtools-view="popup"] .field_20b79 .arco-select-view {
|
|
231
|
+
min-height: 32px;
|
|
232
|
+
border-radius: 5px;
|
|
233
|
+
padding: 2px 8px;
|
|
234
|
+
}
|
|
235
|
+
html[data-devtools-view="popup"] .emptyWrapper_20b79 {
|
|
236
|
+
padding: 16px;
|
|
237
|
+
border-radius: 6px;
|
|
198
238
|
}
|