@module-federation/devtools 2.9.0 → 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.
Files changed (45) hide show
  1. package/README.md +125 -0
  2. package/dist/es/App.js +6 -1
  3. package/dist/es/App.module.js +1 -1
  4. package/dist/es/App_module.css +106 -0
  5. package/dist/es/component/Form/index_module.css +40 -0
  6. package/dist/es/component/Layout/index.js +38 -21
  7. package/dist/es/component/Layout/index_module.css +30 -0
  8. package/dist/es/utils/chrome/fast-refresh.js +84 -5
  9. package/dist/es/utils/chrome/index.js +4 -1
  10. package/dist/es/utils/chrome/observability.js +1 -0
  11. package/dist/es/utils/chrome/webmcp-entry.js +2 -0
  12. package/dist/es/utils/chrome/webmcp.js +468 -0
  13. package/dist/es/utils/sdk/index.js +6 -0
  14. package/dist/es/worker/index.js +1 -1
  15. package/dist/lib/App.js +6 -1
  16. package/dist/lib/App.module.js +1 -1
  17. package/dist/lib/App_module.css +106 -0
  18. package/dist/lib/component/Form/index_module.css +40 -0
  19. package/dist/lib/component/Layout/index.js +38 -21
  20. package/dist/lib/component/Layout/index_module.css +30 -0
  21. package/dist/lib/utils/chrome/fast-refresh.js +83 -4
  22. package/dist/lib/utils/chrome/index.js +4 -1
  23. package/dist/lib/utils/chrome/observability.js +2 -0
  24. package/dist/lib/utils/chrome/webmcp-entry.js +2 -0
  25. package/dist/lib/utils/chrome/webmcp.js +484 -0
  26. package/dist/lib/utils/sdk/index.js +7 -0
  27. package/dist/lib/worker/index.js +1 -1
  28. package/dist/types/App.js +6 -1
  29. package/dist/types/App.module.js +1 -1
  30. package/dist/types/App_module.css +106 -0
  31. package/dist/types/component/Form/index_module.css +40 -0
  32. package/dist/types/component/Layout/index.js +38 -21
  33. package/dist/types/component/Layout/index_module.css +30 -0
  34. package/dist/types/src/utils/chrome/observability.d.ts +11 -0
  35. package/dist/types/src/utils/chrome/webmcp-entry.d.ts +1 -0
  36. package/dist/types/src/utils/chrome/webmcp.d.ts +25 -0
  37. package/dist/types/src/utils/sdk/index.d.ts +1 -0
  38. package/dist/types/utils/chrome/fast-refresh.js +83 -4
  39. package/dist/types/utils/chrome/index.js +4 -1
  40. package/dist/types/utils/chrome/observability.js +2 -0
  41. package/dist/types/utils/chrome/webmcp-entry.js +2 -0
  42. package/dist/types/utils/chrome/webmcp.js +484 -0
  43. package/dist/types/utils/sdk/index.js +7 -0
  44. package/dist/types/worker/index.js +1 -1
  45. package/package.json +5 -4
@@ -211,7 +211,8 @@ const Layout = (props) => {
211
211
  if (hadPreviousEffective) {
212
212
  yield (0, import_utils.removeStorage)(import_sdk.MODULE_DEVTOOL_IDENTIFIER);
213
213
  yield (0, import_utils.removeStorage)(import_constant.BROWSER_ENV_KEY);
214
- yield (0, import_utils.removeStorageKey)(import_constant.__FEDERATION_DEVTOOLS__, "overrides");
214
+ yield (0, import_utils.mergeStorage)(import_constant.__FEDERATION_DEVTOOLS__, "overrides", {});
215
+ yield (0, import_utils.mergeStorage)(import_constant.__FEDERATION_DEVTOOLS__, "proxyRules", rawRules);
215
216
  yield (0, import_utils.injectScript)(import_utils.reloadPage, false);
216
217
  setCondition(import_constant.statusInfo.noProxy);
217
218
  lastEffectiveRulesRef.current = "";
@@ -257,6 +258,8 @@ const Layout = (props) => {
257
258
  yield (0, import_utils.setStorage)(import_sdk.MODULE_DEVTOOL_IDENTIFIER, snapshotJson);
258
259
  yield (0, import_utils.setStorage)(import_constant.BROWSER_ENV_KEY);
259
260
  yield (0, import_utils.mergeStorage)(import_constant.__FEDERATION_DEVTOOLS__, "overrides", overrides);
261
+ yield (0, import_utils.mergeStorage)(import_constant.__FEDERATION_DEVTOOLS__, "proxyRules", rawRules);
262
+ yield (0, import_utils.mergeStorage)(import_constant.__FEDERATION_DEVTOOLS__, import_constant.ENABLE_CLIP, enableClip);
260
263
  yield (0, import_utils.injectScript)(import_utils.reloadPage, false);
261
264
  window.__FEDERATION__.moduleInfo = moduleInfo2;
262
265
  onModuleInfoChange == null ? void 0 : onModuleInfoChange(moduleInfo2);
@@ -299,6 +302,10 @@ const Layout = (props) => {
299
302
  if (typeof overridesState === "string" && overridesState) {
300
303
  const parsedState = JSON.parse(overridesState);
301
304
  const overrides = parsedState == null ? void 0 : parsedState.overrides;
305
+ setEnableClip(Boolean(parsedState == null ? void 0 : parsedState[import_constant.ENABLE_CLIP]));
306
+ setEnalbeHMR(
307
+ (parsedState == null ? void 0 : parsedState[import_constant.__ENABLE_FAST_REFRESH__]) ? "enable" : "disable"
308
+ );
302
309
  if ((0, import_utils.isObject)(overrides)) {
303
310
  const overrideRules = Object.entries(overrides).map(([key, value]) => ({
304
311
  key,
@@ -308,12 +315,10 @@ const Layout = (props) => {
308
315
  (rule) => Boolean(rule.key) && Boolean(rule.value)
309
316
  );
310
317
  const filteredRules = producer.length ? overrideRules.filter((rule) => producer.includes(rule.key)) : overrideRules;
311
- if (filteredRules.length) {
312
- storeData = __spreadProps(__spreadValues({}, storeData), {
313
- [import_constant.proxyFormField]: filteredRules
314
- });
315
- overridesApplied = true;
316
- }
318
+ storeData = __spreadProps(__spreadValues({}, storeData), {
319
+ [import_constant.proxyFormField]: Array.isArray(parsedState.proxyRules) ? parsedState.proxyRules : filteredRules
320
+ });
321
+ overridesApplied = true;
317
322
  }
318
323
  }
319
324
  } catch (error) {
@@ -351,15 +356,25 @@ const Layout = (props) => {
351
356
  return () => {
352
357
  cancelled = true;
353
358
  };
354
- }, [moduleInfo, producerKey, form]);
359
+ }, [moduleInfo, producerKey, form, tabId]);
355
360
  (0, import_react.useEffect)(() => {
356
- chrome.storage.sync.get([import_constant.ENABLEHMR]).then((data) => {
357
- const enable = data[import_constant.ENABLEHMR];
358
- if (typeof enable === "boolean") {
359
- onHMRChange(enable);
361
+ let cancelled = false;
362
+ (0, import_utils.getStorageValue)(import_constant.__FEDERATION_DEVTOOLS__).then((raw) => {
363
+ try {
364
+ const config = typeof raw === "string" ? JSON.parse(raw) : {};
365
+ if (!cancelled) {
366
+ setEnalbeHMR(
367
+ (config == null ? void 0 : config[import_constant.__ENABLE_FAST_REFRESH__]) ? "enable" : "disable"
368
+ );
369
+ setEnableClip(Boolean(config == null ? void 0 : config[import_constant.ENABLE_CLIP]));
370
+ }
371
+ } catch (e) {
360
372
  }
361
373
  });
362
- }, []);
374
+ return () => {
375
+ cancelled = true;
376
+ };
377
+ }, [tabId]);
363
378
  (0, import_react.useEffect)(() => {
364
379
  validateForm(form);
365
380
  }, []);
@@ -400,20 +415,22 @@ const Layout = (props) => {
400
415
  (0, import_utils.setChromeStorage)(formData);
401
416
  run(formData);
402
417
  };
403
- const onHMRChange = (on) => {
418
+ const onHMRChange = (on) => __async(void 0, null, function* () {
404
419
  setEnalbeHMR(on ? "enable" : "disable");
405
- chrome.storage.sync.set({
420
+ yield chrome.storage.sync.set({
406
421
  [import_constant.ENABLEHMR]: on
407
422
  });
408
423
  if (on) {
409
- (0, import_utils.mergeStorage)(import_constant.__FEDERATION_DEVTOOLS__, import_constant.__ENABLE_FAST_REFRESH__, on);
424
+ yield (0, import_utils.mergeStorage)(import_constant.__FEDERATION_DEVTOOLS__, import_constant.__ENABLE_FAST_REFRESH__, on);
410
425
  } else {
411
- (0, import_utils.removeStorageKey)(import_constant.__FEDERATION_DEVTOOLS__, import_constant.__ENABLE_FAST_REFRESH__);
412
- (0, import_utils.removeStorageKey)(import_constant.__FEDERATION_DEVTOOLS__, import_constant.__EAGER_SHARE__);
426
+ yield (0, import_utils.removeStorageKey)(import_constant.__FEDERATION_DEVTOOLS__, import_constant.__ENABLE_FAST_REFRESH__);
427
+ yield (0, import_utils.removeStorageKey)(import_constant.__FEDERATION_DEVTOOLS__, import_constant.__EAGER_SHARE__);
413
428
  }
414
429
  (0, import_utils.injectScript)(import_utils.reloadPage, false);
415
- };
416
- const onClipChange = (on) => {
430
+ });
431
+ const onClipChange = (on) => __async(void 0, null, function* () {
432
+ yield (0, import_utils.mergeStorage)(import_constant.__FEDERATION_DEVTOOLS__, import_constant.ENABLE_CLIP, on);
433
+ lastFormSignatureRef.current = "";
417
434
  setEnableClip(on);
418
435
  try {
419
436
  if (tabId) {
@@ -423,7 +440,7 @@ const Layout = (props) => {
423
440
  console.error(e);
424
441
  }
425
442
  run(form.getFieldsValue());
426
- };
443
+ });
427
444
  const remotePreview = producer.map((id) => {
428
445
  const [, name] = id.split(":");
429
446
  return name || id;
@@ -65,4 +65,34 @@
65
65
  padding: 22px 24px;
66
66
  border: 1px solid rgba(228, 228, 231, 0.5);
67
67
  background: var(--color-bg-1, rgba(255, 255, 255, 0.9));
68
+ }
69
+
70
+ html[data-devtools-view="popup"] .wrapper_084ab {
71
+ gap: 10px;
72
+ }
73
+ html[data-devtools-view="popup"] .summaryCard_084ab {
74
+ padding: 10px;
75
+ min-height: 0;
76
+ gap: 6px;
77
+ flex-direction: row;
78
+ flex-wrap: wrap;
79
+ align-items: center;
80
+ }
81
+ html[data-devtools-view="popup"] .summaryHeader_084ab {
82
+ flex: 1 1 100%;
83
+ }
84
+ html[data-devtools-view="popup"] .summaryTitle_084ab {
85
+ font-size: 13px;
86
+ }
87
+ html[data-devtools-view="popup"] .summaryHint_084ab {
88
+ display: none;
89
+ }
90
+ html[data-devtools-view="popup"] .chip_084ab,
91
+ html[data-devtools-view="popup"] .moreChip_084ab,
92
+ html[data-devtools-view="popup"] .chipPlaceholder_084ab {
93
+ padding: 3px 7px;
94
+ border-radius: 4px;
95
+ }
96
+ html[data-devtools-view="popup"] .formSection_084ab {
97
+ padding: 10px;
68
98
  }
@@ -200,6 +200,25 @@ const getDevtoolsMessage = () => {
200
200
  return null;
201
201
  };
202
202
  const devtoolsMessage = getDevtoolsMessage();
203
+ if ((devtoolsMessage == null ? void 0 : devtoolsMessage[import_constant.__ENABLE_FAST_REFRESH__]) && !window.__REACT_DEVTOOLS_GLOBAL_HOOK__) {
204
+ let nextId = 0;
205
+ const renderers = /* @__PURE__ */ new Map();
206
+ window.__REACT_DEVTOOLS_GLOBAL_HOOK__ = {
207
+ supportsFiber: true,
208
+ renderers,
209
+ inject(renderer) {
210
+ const id = nextId++;
211
+ renderers.set(id, renderer);
212
+ return id;
213
+ },
214
+ onScheduleFiberRoot() {
215
+ },
216
+ onCommitFiberRoot() {
217
+ },
218
+ onCommitFiberUnmount() {
219
+ }
220
+ };
221
+ }
203
222
  const eagerShareInfo = getEagerShareInfo(devtoolsMessage == null ? void 0 : devtoolsMessage[import_constant.__EAGER_SHARE__]);
204
223
  if ((devtoolsMessage == null ? void 0 : devtoolsMessage[import_constant.__ENABLE_FAST_REFRESH__]) && eagerShareInfo) {
205
224
  const { version, scopes } = eagerShareInfo;
@@ -211,6 +230,43 @@ if ((devtoolsMessage == null ? void 0 : devtoolsMessage[import_constant.__ENABLE
211
230
  );
212
231
  }
213
232
  const fastRefreshPlugin = () => {
233
+ const react19Pending = /* @__PURE__ */ new Map();
234
+ const loadReact19 = (pkg, scopes, sync = false) => {
235
+ const existing = getScopeGlobal(pkg, scopes);
236
+ if ((existing == null ? void 0 : existing.version) === import__.REACT_19_DEV_VERSION) {
237
+ return setScopeGlobals(pkg, scopes, existing);
238
+ }
239
+ const save = (library) => {
240
+ const cached = getScopeGlobal(pkg, scopes);
241
+ if ((cached == null ? void 0 : cached.version) === import__.REACT_19_DEV_VERSION)
242
+ return setScopeGlobals(pkg, scopes, cached);
243
+ if ((library == null ? void 0 : library.version) !== import__.REACT_19_DEV_VERSION)
244
+ throw new Error(`Expected development ${pkg}@${import__.REACT_19_DEV_VERSION}.`);
245
+ if (pkg === "react" && (typeof library.createElement !== "function" || !Object.isFrozen(library.createElement("div"))))
246
+ throw new Error("React provider is not a development build.");
247
+ return setScopeGlobals(pkg, scopes, library);
248
+ };
249
+ if (sync) {
250
+ if (pkg === "react-dom")
251
+ loadReact19("react", scopes, true);
252
+ return save(loadUmdModuleSync(pkg, import__.REACT_19_DEV_VERSION, scopes));
253
+ }
254
+ const key = `${pkg}:${JSON.stringify([...scopes].sort())}`;
255
+ let pending = react19Pending.get(key);
256
+ if (!pending) {
257
+ pending = (() => __async(exports, null, function* () {
258
+ if (pkg === "react-dom")
259
+ yield loadReact19("react", scopes);
260
+ const cached = getScopeGlobal(pkg, scopes);
261
+ if ((cached == null ? void 0 : cached.version) === import__.REACT_19_DEV_VERSION)
262
+ return setScopeGlobals(pkg, scopes, cached);
263
+ return save(yield loadUmdModule(pkg, import__.REACT_19_DEV_VERSION, scopes));
264
+ }))();
265
+ react19Pending.set(key, pending);
266
+ void pending.catch(() => react19Pending.delete(key));
267
+ }
268
+ return pending;
269
+ };
214
270
  let orderResolve;
215
271
  const orderPromise = new Promise((resolve) => {
216
272
  orderResolve = resolve;
@@ -218,12 +274,13 @@ const fastRefreshPlugin = () => {
218
274
  return {
219
275
  name: "mf-fast-refresh-plugin",
220
276
  beforeRegisterShare(args) {
221
- var _a2;
277
+ var _a2, _b;
222
278
  const { pkgName, shared } = args;
223
- if (!SUPPORT_PKGS.includes(pkgName)) {
279
+ const isReact19 = /^19\./.test(shared.version);
280
+ if (!SUPPORT_PKGS.includes(pkgName) && !(isReact19 && pkgName === "react-dom/client")) {
224
281
  return args;
225
282
  }
226
- const supportPkgName = pkgName;
283
+ const supportPkgName = pkgName === "react-dom/client" ? "react-dom" : pkgName;
227
284
  const shareScopes = getShareScopes(shared.scope);
228
285
  let enableFastRefresh = false;
229
286
  let devtoolsMessage2 = {};
@@ -239,7 +296,29 @@ const fastRefreshPlugin = () => {
239
296
  if (!enableFastRefresh) {
240
297
  return args;
241
298
  }
242
- if (((_a2 = shared.shareConfig) == null ? void 0 : _a2.eager) || shared.lib) {
299
+ if (isReact19) {
300
+ shared.version = import__.REACT_19_DEV_VERSION;
301
+ shared.get = () => __async(this, null, function* () {
302
+ const library = yield loadReact19(supportPkgName, shareScopes);
303
+ return () => library;
304
+ });
305
+ if (((_a2 = shared.shareConfig) == null ? void 0 : _a2.eager) || shared.lib) {
306
+ const library = loadReact19(supportPkgName, shareScopes, true);
307
+ shared.lib = () => library;
308
+ updateEagerShareInfo(
309
+ devtoolsMessage2,
310
+ pkgName,
311
+ import__.REACT_19_DEV_VERSION,
312
+ shareScopes
313
+ );
314
+ localStorage.setItem(
315
+ import_constant.__FEDERATION_DEVTOOLS__,
316
+ JSON.stringify(devtoolsMessage2)
317
+ );
318
+ }
319
+ return args;
320
+ }
321
+ if (((_b = shared.shareConfig) == null ? void 0 : _b.eager) || shared.lib) {
243
322
  if (!(devtoolsMessage2 == null ? void 0 : devtoolsMessage2[import_constant.__EAGER_SHARE__])) {
244
323
  const eagerShareInfo2 = updateEagerShareInfo(
245
324
  devtoolsMessage2,
@@ -188,7 +188,10 @@ const getGlobalModuleInfo = (callback) => __async(void 0, null, function* () {
188
188
  callback(normalizeModuleInfoPayload((_b = window.__FEDERATION__) == null ? void 0 : _b.moduleInfo));
189
189
  }
190
190
  yield sleep(300);
191
- const listener = (message) => {
191
+ const listener = (message, sender) => {
192
+ var _a2;
193
+ if (((_a2 = sender == null ? void 0 : sender.tab) == null ? void 0 : _a2.id) !== void 0 && sender.tab.id !== getCurrentTabId())
194
+ return;
192
195
  const { data } = message;
193
196
  if (!isModuleInfoSyncMessage(data) || (data == null ? void 0 : data.appInfos)) {
194
197
  return;
@@ -43,6 +43,7 @@ __export(observability_exports, {
43
43
  mergeObservabilityReports: () => mergeObservabilityReports,
44
44
  readObservabilityConfig: () => readObservabilityConfig,
45
45
  readObservabilitySnapshot: () => readObservabilitySnapshot,
46
+ readSnapshotFromPage: () => readSnapshotFromPage,
46
47
  reloadInspectedPage: () => reloadInspectedPage
47
48
  });
48
49
  module.exports = __toCommonJS(observability_exports);
@@ -229,5 +230,6 @@ const getObservabilityReportScopeLabel = (report) => {
229
230
  mergeObservabilityReports,
230
231
  readObservabilityConfig,
231
232
  readObservabilitySnapshot,
233
+ readSnapshotFromPage,
232
234
  reloadInspectedPage
233
235
  });
@@ -0,0 +1,2 @@
1
+ var import_webmcp = require("./webmcp");
2
+ (0, import_webmcp.startDevtoolsWebMCP)();